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
1111.1713
1
1111
2011-11-07T18:37:42
Tight Approximation of Image Matching
[ "cs.DS" ]
In this work we consider the {\em image matching} problem for two grayscale $n \times n$ images, $M_1$ and $M_2$ (where pixel values range from 0 to 1). Our goal is to find an affine transformation $T$ that maps pixels from $M_1$ to pixels in $M_2$ so that the differences over pixels $p$ between $M_1(p)$ and $M_2(T(p))$ is minimized. Our focus here is on sublinear algorithms that give an approximate result for this problem, that is, we wish to perform this task while querying as few pixels from both images as possible, and give a transformation that comes close to minimizing the difference. We give an algorithm for the image matching problem that returns a transformation $T$ which minimizes the sum of differences (normalized by $n^2$) up to an additive error of $\epsilon$ and performs $\tilde{O}(n/\epsilon^2)$ queries. We give a corresponding lower bound of $\Omega(n)$ queries showing that this is the best possible result in the general case (with respect to $n$ and up to low order terms). In addition, we give a significantly better algorithm for a natural family of images, namely, smooth images. We consider an image smooth when the total difference between neighboring pixels is O(n). For such images we provide an approximation of the distance between the images to within an additive error of $\epsilon$ using a number of queries depending polynomially on $1/\epsilon$ and not on $n$. To do this we first consider the image matching problem for 2 and 3-dimensional {\em binary} images, and then reduce the grayscale image matching problem to the 3-dimensional binary case.
cs.DS
cs
Tight Approximation of Image Matching Simon Korman School of EE Tel-Aviv University Ramat Aviv, Israel Daniel Reichman Faculty of Math and CS Weizmann Institute of Science Rehovot, Israel [email protected] [email protected] Gilad Tsur Faculty of Math and CS Weizmann Institute of Science Rehovot, Israel [email protected] July 12, 2021 Abstract In this work we consider the image matching problem for two grayscale n × n images, M1 and M2 (where pixel values range from 0 to 1). Our goal is to find an affine transformation T that maps pixels from M1 to pixels in M2 so that the differences over pixels p between M1(p) and M2(T (p)) is minimized. Our focus here is on sublinear algorithms that give an approximate result for this problem, that is, we wish to perform this task while querying as few pixels from both images as possible, and give a transformation that comes close to minimizing the difference. We give an algorithm for the image matching problem that returns a transformation T which minimizes the sum of differences (normalized by n2) up to an additive error of  and performs O(n/2) queries. We give a corresponding lower bound of Ω(n) queries showing that this is the best possible result in the general case (with respect to n and up to low order terms). In addition, we give a significantly better algorithm for a natural family of images, namely, smooth images. We consider an image smooth when the total difference between neighboring pixels is O(n). For such images we provide an approximation of the distance between the images to within an additive error of  using a number of queries depending polynomially on 1/ and not on n. To do this we first consider the image matching problem for 2 and 3-dimensional binary images, and then reduce the grayscale image matching problem to the 3-dimensional binary case. 1 1 0 2 v o N 7 ] S D . s c [ 1 v 3 1 7 1 . 1 1 1 1 : v i X r a 1 1 Introduction Similarity plays a central part in perception and categorization of visual stimuli. It is no wonder that similarity has been intensely studied, among others, by cognitive psychologists [16, 6] and computer vision and pattern recognition researchers. Much of the work on computer vision, including that on image matching, involves algorithms that require a significant amount of processing time, whereas many of the uses of these algorithms would typically require real-time performance. A motivating example is that of image registration [19, 14]. Here we are given two images of a particular scene or object (e.g., two pictures taken from a video sequence) and wish to match one image to the other, for tasks such as motion detection, extraction of 3-dimensional information, noise-reduction and super-resolution. Many advances were made in dealing with this task and it can now be performed in a wide variety of situations. However, image registration algorithms are generally time consuming. Image registration is an application of a more abstract computational problem - the image matching problem [8, 9, 11]. In this problem we are given two digital n × n images M1 and M2 and wish to find a transformation that changes M1 so that it best resembles M2. In this work we consider the distance between two n×n images M1 and M2 when we perform affine transformations on their pixels. Namely, given an affine transformation T , we sum over all pixels p the absolute value of the difference between M1(p) and M2(T (p)), where the difference is considered to be 1 for pixels mapped outside M2. The distance between M1 and M2 is defined as the minimum such distance taken over all affine transformations. Our focus is on affine transformations as such transformations are often used when considering similarity between images. We limit ourselves to trasformations with a bounded scaling factor. This is congruent with applications, and prevents situations such as one image mapping to very few pixels in another. Exact algorithms for this problem generally enumerate all possible different transformations, fully checking how well each transformation fits the images. Hundt and Li´skiewicz [8] give such an algorithm for the set of affine transformations on images with n × n pixels (transformations on which we focus in this paper), that runs in time Θ(n18). They also prove a lower bound of Ω(n12) on the number of such transformations (which implies a Ω(n12) lower bound on algorithms using this technique). As known exact algorithms have prohibitive running times, image registration algorithms used in practice are typically heuristic. These algorithms often reduce the complexity of the problem by roughly matching "feature points" [19, 14] - points in the images that have relatively distinct char- acteristics. Such heuristic algorithms are not analyzed rigorously, but rather evaluated empirically. Two related problems are those of shape matching and of point set matching, or point pattern matching. In shape matching [18] the goal is to find a mapping T between two planar shapes S1 and S2, minimizing a variety of distance measures between the shapes T (S1) and S2. A problem of similar flavor is that of point set matching [5], where we are given two (finite) sets of points A and B in a Euclidean space and seek to map A to a set T (A) that minimizes the distance between T (A) and B under some distance metric. Algorithms for these exact problems were give by Alt et al' [2] and by Chew et al' [4] both require prohibitive running times. Recent research [5] has focused on finding transformations that are close to the optimal one requiring less time. It should be noted that the running times the algorithms in [5] are superlinear in the number of points in A and B. We emphasize that these works are concerned with planar shapes and point sets rather than digital images. Our main contribution is devising sublinear algorithms for the image matching problem. Sub- linear algorithms are extremely fast (and typically randomized) algorithms that use techniques 2 such as random sampling to asses properties of objects with arbitrarily small error. The number of queries made by such algorithms is sublinear in the input size, and generally depends on the error parameter. The use of sublinear algorithms in image processing was advocated by Rashkod- nikova [13] who pioneered their study for visual properties. She gave algorithms for binary (0 − 1) images, testing the properties of connectivity, convexity and being a half-plane. In her work, an image is considered far from having such a property if it has a large hamming distance from every image with the property. Ron and Tsur [15] introduced a different model that allowed testing of sparse images (where there are o(n2) different 1-pixels) for similar properties. Kleiner et al. [10] give results on testing images for a partitioning that roughly respects a certain template. Unlike the aforementioned works we do not deal only with binary images, but also consider grayscale images, where every pixel gets a value in the range [0, 1]. 1.1 Our Results In this work we prove both general results and results for smooth images. 1. General Upper Bound: We present an algorithm that when given access to any two n × n grayscale images M1 and M2 and a precision parameter  returns a transformation T such that the distance between M1 and M2 using T is at most  greater than the minimum distance between them (taken over all affine transformations). The query complexity of this algorithm is Θ(n/2), which is sublinear in n2, the size of the matrices. 2. Lower Bound: We show that every algorithm estimating matching between images within additive error smaller than 1/4 must make an expected Ω(n) number of queries. 3. Upper Bound For Smooth Images: We show that if the images M1 and M2 are smooth, that is, for both images the total difference between neighboring pixels is O(n), then for every positive  we can find a transformation T such that the distance between M1 and M2 using T is at most  greater than the minimum distance between them. This can be done using a number of queries that is polynomial in 1/ and does not depend on n. Being smooth is a property of many natural images - research has shown a power-law distribution of spatial frequencies in images [17, 12], translating to very few fast changes in pixel intensity. While we show that our algorithm works well with smooth images, we note that distinguishing between images that have a total difference between neighboring pixels of O(n) and those with a total of O(n) + k requires Ω(n2/k) queries. An unusual property of the way distance between images is defined in this work is that it is not symmetric. In fact, an image M1 may have a mapping that maps all its pixels to only half the pixels in M2, so that each pixels is mapped to a pixels with the same value, while any mapping from M2 to M1 leaves a constant fraction of the pixels in M2 mapped either outside M1 or to pixels that do not have the same color (To see this consider an image M1 that has only black points, and an image M2 that is black on one the left side and white on the other). We note that one can use the algorithms presented here also to measure symmetric types of distances by considering inverse mappings. Techniques 3 The Algorithm for the General Case: Imagine that sampling a pair of pixels, p ∈ M1 and q ∈ M2, would let us know how well each affine transformation T did with respect to the pixel p, that is, what the difference is between M1(p) and M2(T (p)). The way we define grayscale values (as ranging from 0 to 1), we could sample Θ(2) random pairs of points and have, for every transformation, an approximation of the average difference between points up to an additive error of  with constant probability. As there are polynomially many different affine transformations if we increased the number of samples to amplify the probability of correctness, we could use O(log(n)/2) queries and return a transformation that was -close to the best1. However, when we sample p ∈ M1 and q ∈ M2 uniformly at random we get a random pixel and its image under only a few of the different transformations. We show that O(n/2) queries suffice to get a good estimation of the error for all interesting transformations (that is, transformations that map a sufficiently large portion of pixels from M1 to pixels in M2). Using these pixels we can return a transformation that is close to optimal as required. The Lower Bound: We prove the lower bound by giving two distributions of pairs of images. In the first, the images are random 0− 1 images and far from each other. In the second, one image is partially created from a translation of the other. We show that any algorithm distinguishing between these families must perform Ω(n) expected queries. The proof of the lower bound is somewhat similar to the lower bound given by Batu et al. [3] on the number of queries required to approximate edit distance. Here we have a two-dimensional version of roughly the same argument. Note that a random 0 − 1 image is far from being smooth, that is, many pixels have a value significantly different from that of their neighbors. The Algorithm For Smooth Images: Our analysis of the algorithm for smooth images begins by considering binary images. The boundary of a 0− 1 image M is the set of pixels that have a neighboring pixel with a different value. We consider two affine transformations T, T (cid:48) close if for every pixel p the distance in the plane between T (p) and T (cid:48)(p) is small. Only points that are close to the boundary might be mapped to different values by close transformations T and T (cid:48) (meaning that the pixel will be mapped correctly by one and not by the other - see Figure 1). It follows that if there is a big difference in the distance between M1 and M2 when mapped by T and their distance when mapped by T (cid:48), then the perimeter, the size of the boundary, is large. This implies that when the perimeter is small, one can sample a transformation T and know a lot about the distance between images for transformations that are "close" to T . This idea can be generalized to 3-dimensional binary images. Such 0 − 1 images are a natural object in 3 dimensions as color is not a feature typically attributed to areas within a body. More importantly, however, one can use 3-dimensional binary images to model 2-dimensional grayscale images. Smooth grayscale images, i.e., images where the sum of difference (in absolute value) between neighboring pixels is O(n), translate to 3-dimensional binary images that have a small perimeter. An appropriate version of the 3-dimensional algorithm can be used to get a good approximation for the mapping between two grayscale images. Organization We begin by giving some preliminaries in Section 2. We then describe and prove the correctness of the algorithm for the general case (with a query complexity of O(n/2)). We give the lower 1The O symbol hides logarithmic factors 4 bound in the next section. Following that we give the algorithm for smooth binary images in Section 4.1. In Section 4.2 we give an explicit construction of an -net of transformations such that any transformation is close to one of the those in the net. In Section 4.3 we give the three- dimensional version of our algrithm, and in Section 4.4 we show how to use this version to work with grayscale images. 2 Preliminaries We are given two images represented by n × n matrices. For grayscale images the values of entries in the matrix are in the range [0, 1] and for binary images they are either 0 or 1. Definition 2.1 A pixel p in an n × n image M is a pair of coordinates, namely a pair (i, j) ∈ {1, . . . , n}2. We denote this as p ∈ M . Definition 2.2 The value of a pixel p = (i, j) in an image M is M [i, j], or M (p). Definition 2.3 For r ∈ R2 we denote by (cid:98)r(cid:99) the pixel p that the point r falls in. Definition 2.4 A transformation T has a scaling factor in the range [1/c, c] (for a positive constant c) if for all vectors v it holds that v/c ≤ T v ≤ cv. Here we are particularly interested in affine transformations in the plane that are used to map one pixel to another, when these transformations have a scaling factor in the range [1/c, c] for a fixed positive constant c. Such a transformation T can be seen as multiplying the pixel vector by a 2× 2 non-singular matrix and adding a "translation" vector, then rounding down the resulting numbers. When comparing two images, requiring the matrix to be non-singular prevents the transformation from mapping the image plane in one image onto a line or a point in the other. Given an affine transformation in the form of a matrix A and a translation vector t, there is a corresponding transformation T (p) = (cid:98)Ap + t(cid:99). We call T an image-affine transformation and we say that T is based on A and t. Generally speaking, when we discuss algorithms getting an image-affine transformation as input, or enumerating such transformations, we assume that these transformations are represented in matrix format. Definition 2.5 The distance between two n × n images (M1, M2) with respect to a transformation T , which we denote ∆T (M1, M2), is defined as (cid:88) M1(p) − M2(T (p))(cid:105) (cid:104){p ∈ M1 T (p) /∈ M2} + 1 n2 p∈M1T (p)∈M2 Note that the distance ∆T (M1, M2) ranges from 0 to 1. Definition 2.6 We define the Distance between two images (M1, M2) (which we denote ∆(M1, M2)) as the minimum over all image-affine transformations T of ∆T (M1, M2). Definition 2.7 Two different pixels p = (i, j) and q = (i(cid:48), j(cid:48)) are adjacent if i − i(cid:48) ≤ 1 and j − j(cid:48) ≤ 1. 5 The following definitions relate to binary (0 − 1) images: Definition 2.8 A pixel p = (x, y) is a boundary pixel in an image M if there is an adjacent pixel q such that M (p) (cid:54)= M (q). Definition 2.9 The perimeter of an image M is the set of boundary pixels in M as well as the 4n − 4 outermost pixels in the square image. We denote the size of the perimeter of M by PM . Note that PM is always Ω(n) and O(n2). 3 The General Case We now present the algorithm for general images. The lower bound we will prove in Section 3.2 demonstrates that this algorithm has optimal query complexity, despite having a prohibitive running time. The main signficance of the algorithm is in showing that one can achieve query complexity of O(n). It is an open question if one can achieve this query complexity in sublinear time or even significantly faster than our running tme. 3.1 The Algorithm Algorithm 1 Input: Oracle access to n × n images M1, M2, and a precision parameter . 1. Sample k = Θ(n/2) pixels P = p1, . . . , pk uniformly at random (with replacement) from M1. 2. Sample k pixels Q = q1, . . . , qk uniformly at random (with replacement) from M2. 3. Enumerate all image-affine transformations T1, . . . , Tm (Recall that m, the number of image- affine transformations, is in O(n18)). 4. For each transformation T(cid:96) denote by Out(cid:96) the number of pixel coordinates that are mapped by T(cid:96) out of the region [1, n]2. (cid:80) 5. For each transformation T(cid:96) denote by Hit(cid:96) the number of pairs pi, qj such that T(cid:96)(pi) = qj, pi,qj∈{p∈P,q∈QT(cid:96)(pi)=qj} M1(pi) − M2(qj) 6. Return T(cid:96) that minimizes (n2−Out(cid:96))·Bad(cid:96) (discarding transformations T(cid:96) such that Hit(cid:96) < ). and denote by Bad(cid:96) the value {p∈P,q∈QT(cid:96)(pi)=qj} 1 Theorem 3.1 With probability at least 2/3 Algorithm 1 returns a transformation T such that ∆T (M1, M2) − ∆(M1, M2) < . 1 {p∈M1,q∈M2T(cid:96)(pi)=qj} We prove Theorem 3.1 by showing that for any fixed transformation T(cid:96) (where Hit(cid:96) ≥ ) (cid:80) the sample we take from both images gives us a value Bad(cid:96) that is a good approximation of the pi,qj∈{p∈M1,q∈M2T(cid:96)(pi)=qj} M1(pi)−M2(qj) with high probability, and value applying a union bound. To show this we give several definitions and claims. For these we fix an image-affine transformation T and two images M1 and M2, so that T maps at least /2 of the points in M1 to points in M2 (note that transformations that do not map such an /2 portion of pixels are discarded by the algorithm with very high probability). 6 1. Let T (M1) be the set of pixels q ∈ M2 such that there exist pixels p ∈ M1 so that T (p) = q. 2. For a set of pixels Q ∈ M2 let T −1(Q) denote the set {p ∈ M1T (p) ∈ Q}. 3. We denote by Q(cid:48) the points that are in Q (the sample of points taken from M2) and in T (M1). 4. We denote by P(cid:48) the points p ∈ P such that T (p) ∈ Q(cid:48). 5. For a pixel q ∈ M2 we denote by q the number of pixels p ∈ M1 such that T (p) = q. 6. For a pixel q ∈ M2 we denote by q the sum over pixels p ∈ M1 such that T (p) = q of M1(p) − M2(T (p)). 7. Denote by pbad the average over pixels p from those mapped from M1 to T (M1) of M1(p) − M2(T (p)). 8. Denote by pbad the value ((cid:80) q∈Q(cid:48) q)/((cid:80) q∈Q(cid:48) q). Claim 3.1 With probability at least 1/(8n18) over the choice of P and Q the size of Q(cid:48) is Ω(n/) and the size of P(cid:48) is Ω(log(n)/3). Proof: The probability of any particular pixel in Q belonging to Q(cid:48) is at least /2, and Q is of size θ(n/2) (where pixels are chosen independently). Hence the expected number of points in Q(cid:48) is Ω(n/). An additional factor of Θ(log(n)) hidden in the Θ notation of k assures us (using Chernoff bounds) that the probability Q(cid:48) not being large enough is at most 1/(8n18) as required. Assume the first part of the claim holds. Recall that no more than a constant number of pixels from M1 are mapped to any pixel in M2, and therefore T −1(Q(cid:48)) = Ω(n/). As the pixels of P are chosen independently and uniformly at random from the n2 pixels of M1, each pixel in P is mapped to a pixel in Q(cid:48) with a probability of Ω(1/(n)). Hence, the expected size of P(cid:48) is Ω(1/3) and the second part of the claim follows (via a similar argument). Claim 3.2 With probability at least 1/(8n18) over the choice of P and Q it holds that pbad−pbad < /4. Proof: Note that pbad equals ((cid:80) q∈Q(cid:48) q)/((cid:80) ((cid:80) q∈Q(cid:48) q/Q(cid:48))−((cid:80) ((cid:80) q∈T (M1) q). Now, consider the value pbad = q∈Q(cid:48) q). Each pixel q ∈ Q(cid:48) is chosen uniformly at random and independently from the pixels in T (M1). To see that the claim holds we note that with probability at least 1− 1/(8n18) (using Hoeffding bounds and the fact that with high probability P(cid:48) is Ω(log(n)/3)) we have that q∈T (M1) q/T (M1)) = Ø() and that ((cid:80) q∈Q(cid:48) q/Q(cid:48))−((cid:80) q∈T (M1) q)/((cid:80) q∈T (M1) q/T (M1)) = Ø(). The claim follows. Claim 3.3 With probability at least 1/(8n18) over the choice of P and Q it holds that Bad(cid:96)−pbad < /2 (cid:80) (cid:80) q∈Q(cid:48) q q∈Q(cid:48) q . It follows that pbad equals Ep∈T −1(Q(cid:48))[M1(p) = M2(T (p))] Proof: We have that pbad = where p is chosen uniformly at random from T −1(Q(cid:48)). The pixels in P(cid:48) are chosen uniformly at random from T −1(Q(cid:48)) and (with sufficiently high probability), by Claim 3.1 there are Ω(log(n)/3) such pixels. The claim follows using Hoeffding bounds. We thus see that Bad(cid:96) is -close to the average difference between M1(p) and M2(T(cid:96)(p)) for pixels p ∈ M1 mapped by T(cid:96) to M2. As Out(cid:96) is exactly the number of pixels mapped by T(cid:96) out of M2, the claim follows from the definition of distance. 7 3.2 Lower Bound We build a lower bound using binay images, and parameterize the lower bound with the image perimeter (see Theorem 3.2). Note that for an image M having a perimeter of size k implies that the total difference between pixels and their neighbors in M is Θ(k). We use a bound on this total difference to discuss the smoothness of grayscale images later in this work. Theorem 3.2 Fix k > 0 such that k = o(n) (k may depend on n). Let A be an algorithm that is given access to pairs of images M1, M2 where max(PM1, PM2) = Ω(n2/k). In order to distinguish with high probability between the following two cases: 1. ∆(M1, M2) < 4/16 2. ∆(M1, M2) > 7/16 A must perform Ω(n/k) queries. In order to prove Theorem 3.2 we will first focus on the case where k = 1. Namely, we show that any algorithm that satisfies the conditions as stated in the theorem for all images with max(PM1, PM2) = Θ(n2) must perform Ω(n) queries. Following this we will explain how the proof extends to the case of a general k. We use Yao's principle - we give two distributions D1,D2 over pairs of images such that the following holds: 1. Pr(M1,M2)D1[∆(M1, M2) > 7/16] > 1 − o(1) 2. Pr(M1,M2)D2[∆(M1, M2) < 4/16] = 1 and show that any deterministic algorithm that distinguishes with high probability between pairs drawn from D1 and those drawn from D2 must perform Ω(n) expected queries. We now turn to describe the distributions. The distribution D1 is the distribution of pairs of images where every pixel in M1 and every pixel in M2 is assigned the value 1 with probability 0.5 and the value 0 otherwise, independently. Pairs in the distribution D2 are constructed as follows. M1 is chosen as in D1. We now choose uniformly at random two values sh, sv ranging each from 0 to n/8. Pixels (i, j) in M2 where i < sh or j < sv are chosen at random as in D1. The remaining pixels (i, j) satisfy M2(i, j) = M1(i − sh, j − sv). Intuitively, the image M2 is created by taking M1 and shifting it both horizontally and vertically, and filling in the remaining space with random pixels. Both distributions D1 and D2 possess the required limitation on the size of the boundaries It suffices to show this with respect to the image M1, which It is easy to see (since M1's pixels are We now proceed to prove the properties of D1 and D2. Starting with D2, given the transfor- mation T that shifts points by sv and sh, all but a 15/64'th fraction (which is smaller than 1/4) of M1's area matches exactly with a corresponding area in M2 and the following claim holds. (i.e. max(PM1, PM2) = Θ(n2)). is constructed in the same way in both distributions. independently taken to be 0 or 1 uniformly at random) that Pr[PM1 ≥ n2 4 ] = 1 − o(1). Claim 3.4 Pr(M1,M2)D2[∆(M1, M2) < 4/16] = 1 In order to prove that pairs of images drawn from D1 typically have a distance of at least 7/16 we first state the following claim [8]: 8 Claim 3.5 The number of image-affine transformations T between n × n images M1 and M2 that map at least one of M1's pixels into M2 is polynomial in n. Claim 3.6 Pr(M1,M2)D1[∆(M1, M2) > 7/16] > 1 − o(1) Proof: Consider two images M1, M2 that are sampled from D1. The value ∆T (M1, M2) for an arbitrary transformation T is ∆T (M1, M2) ≤ Prp∈M1[T (p) ∈ M2 ∧ M1(p) = M2(T (p))]. For any pixel p, over the choice of M1 and M2, it holds that Pr[T (p) ∈ M2 ∧ M1(p) = M2(T (p))] ≤ 1/2 (if T (p) ∈ M2 the probability is 1/2). The random (over the choice of M1, M2) variable ∆T (M1, M2) has an expectation of at most n2/2. As it is bounded by the sum of n2 independent 0 − 1 random variables with this expectation, the probability that ∆T (M1, M2) < (1/2 − )n2 for any positive fixed  is Θ(e−n2). As ∆(M1, M2) = minT ∆T (M1, M2), and as there are at most a polynomial number of transformations T , the claim follows using a union bound. The proof of Theorem 3.2 for the case k = 1 is a consequence of the following claim. Claim 3.7 Any algorithm that given a pair of n × n images M1, M2 acts as follows: 1. Returns 1 with probability at least 2/3 if ∆(M1, M2) ≤ 4/16. 2. Returns 0 with probability at least 2/3 if ∆(M1, M2) ≥ 7/16. must perform Ω(n) expected queries. Proof: To show this we consider any deterministic algorithm that can distinguish with probability greater than 1/2 +  (for a constant  > 0) between the distributions D1 and D2. Assume (toward a contradiction) such an algorithm A that performs m = o(n) queries exists. We will show that with very high probability over the choice of images, any new query A performs is answered independently with probability 0.5 by 0 and with probability 0.5 by 1. This implies the Theorem. The fact that any new query A performs is answered in this way is obvious for D1 - here the pixels are indeed chosen uniformly at random. We now describe a process P that answers a series of m queries performed by A in a way that produces the same distribution of answers to these queries as that produced by pairs of images drawn from D2. This will complete the proof. The process P works as follows (we assume without loss of generality that A never queries the same pixel twice): 1. Select m bits r1, . . . , rm uniformly and independently at random. These will (typically) serve as the answers to A's queries. 2. Select uniformly at random two values sh, sv ranging each from 0 to n/8. 3. For qk = (i, j) - the k'th pixel queried by A, return the following: (a) If qk is queried in M1, and M2(i + sh, j + sv) was sampled, return M2(i + sh, j + sv). (b) If qk is queried in M2, and M1(i − sh, j − sv) was sampled, return M1(i − sh, j − sv). (c) Else, return rk. 9 Having fixed r1, . . . , rm in Step 1, consider the queries q(cid:48) Obviously, P has the same distribution of answers to queries as that of images drawn from D2 - the choice of sh, sv is exactly as that done when selecting images from D2, and the values of pixels are chosen in a way that respects the constraints in this distribution. We now show that the probability of reaching Steps 3a and 3b is o(1). If P does not reach these steps it returns r1, . . . , rm and A sees answers that were selected uniformly at random. Hence, the claim follows. m that A performs when answered r1, . . . , rm−1 (that is, the query q(cid:48) 1 is the first query A performs. If it is answered by r1 it performs the query q(cid:48) 2, etc.). In fact, we will ignore the image each query is performed in, and consider only the set of pixel locations {pk = (ik, jk)}. Step 3a or 3b can only be reached if a pair of pixels pk, p(cid:96) satisfies ik − i(cid:96) = sv and jk − j(cid:96) = sh. There are Θ(m2) such pairs, and as m = o(n) we have that m2 = o(n2). As the number of choices of sv, sh is in Θ(n2), the probability of sv, sh being selected so that such an event occurs is o(1) as required. 1, . . . , q(cid:48) Proving Theorem 3.2 for the Case k > 1 (sketch). We construct distributions similar to those above, except that instead of considering single pixels we partition each image to roughly n2/k2 blocks of size k × k, organized in a grid. The distributions D1,D2 are similar, except that now we assign the same value to all the pixels in each block. For the distribution D2 we select sv, sh to shift the image by multiples of k. The remainder of the proof is similar to the case where k = 1, but the number of queries that an algorithm must perform decreases from Ω(n) to Ω(n/k), while the boundary size decreases from Θ(n2) to Θ(n2/k). 4 The Smooth Image Case 4.1 The Algorithm for Binary Images with Bounded Perimeter Given a pair of binary images M1, M2 with PM1 = O(n) and PM2 = O(n) our approach to finding an image-affine transformation T such that ∆T (M1, M2) ≤ ∆(M1, M2) +  is as follows. We iterate through a set of image affine transformations that contain a transformation that is close to optimal (for all images with a perimeter bounded as above), approximating the quality of every transformation in this set. We return the transformation that yields the best result. We first show (in Claim 4.1) how to approximate the value ∆T (M1, M2) given a transformation T . We then show that for two affine transformations ¯T , ¯T (cid:48) that are close in the sense that for every point p in the range {1, . . . , n}2 the values ¯T (p) and ¯T (cid:48)(p) are not too far (in Euclidean distance), the following holds. For the image affine transformations T, T (cid:48) based on ¯T and ¯T (cid:48) the values ∆T (M1, M2) and ∆T (cid:48)(M1, M2) are close. This is formalized in Theorem 4.1 and Corollary ??. Finally we claim that given a set T of affine transformations such that for every affine transformation there exists a transformation close to it in T , it suffices for our purposes to check all image affine transformations based on transformations in T . In Section 4.2 we give the construction of such a set. The following claims and proofs are given in terms of approximating the distance (a numer- ical quantity) between the images. However, the algorithm is constructive in the sense that it finds a transformation that has the same additive approximation bounds as those of the distance approximation. Claim 4.1 Given images M1 and M2 of size n × n and an image-affine transformation T , let d = ∆T (M1, M2). Algorithm 2 returns a value d(cid:48) such that d(cid:48) − d ≤  with probability 2/3 and 10 performs Θ(1/2) queries. Algorithm 2 Input: Oracle access to n× n images M1, M2, precision parameter  and a transfor- mation T (given as a matrix and translation vector). 1. Sample Θ(1/2) values p ∈ M1. Check for each p whether T (p) ∈ M2, and if so check whether M1(p) = M2(T (p)). 2. Return the proportion of values that match the criteria T (p) ∈ M2 and M1(p) = M2(T (p)). The approximation is correct to within  using an additive Chernoff bound. We now define a notion of distance between affine transformations (which relates to points in the plane): Definition 4.1 Let ¯T and ¯T (cid:48) be affine transformations. The ln∞ distance between ¯T and ¯T (cid:48) is defined as max (cid:107) ¯T (p) − ¯T (cid:48)(p)(cid:107)2. p∈[1,n+1)2 The notion of ln∞ distance simply quantifies how far the mapping of a point in an image according to ¯T may be from its mapping by ¯T (cid:48). Note that this definition doesn't depend on the pixel values of the images, but only on the mappings ¯T and ¯T (cid:48), and on the image dimension n. The following fact will be needed for the proof of Theorem 4.1. b. √ Claim 4.2 Given a square subsection M of a binary image and an integer b, let PM denote the PM ≥ √ number of boundary pixels in M . If M contains at least b 0-pixels and at least b 1-pixels, then Proof: Let M be a square of d × d pixels. Note that d > b. To see the claim holds we consider √ three cases. In the first case, all rows and all columns of M contain both 0 and 1 pixels. In such a case each row contains at least one boundary pixel, PM ≥ d > b, and we are done. In the second case there exists, without loss of generality, a row that does not contain the value 0, and all columns contain the value 0. Again this means there are at least d boundary pixels (one for each column), PM ≥ d > b, and we are done. Finally, consider the case that there are both rows and columns that do not contain the value 0. This means that there is a boundary pixel for each row and for each column that do contain the value 0. If there were fewer than b boundary pixels this would b rows and columns that contain 0 pixels, and M could not contain b mean there are fewer than √ different 0 pixels. This would lead to a contradiction, and thus PM ≥ √ b, and we are done. √ √ We now turn to a theorem that leads directly to our main upper-bound results. Theorem 4.1 Let M1, M2 be n × n images and let δ be a constant in (0, 2). Let T and T (cid:48) be image affine transformations based on the affine transformations ¯T , ¯T (cid:48), such that ln∞( ¯T , ¯T (cid:48)) < δn. It holds that ∆T (cid:48)(M1, M2) ≤ ∆T (M1, M2) + O √ (cid:16) δPM2 (cid:17) n 11 Proof: The distance ∆T (M1, M2) = 1 n2 (cid:12)(cid:12)(cid:12){p ∈ M1 T (p) /∈ M2 ∨ M1(p) (cid:54)= M2(T (p))}(cid:12)(cid:12)(cid:12) is composed of two parts. The first is the portion of pixels from M1 that T maps out of M2. The second is the portion of pixels in M1 that T maps to pixels that have a different value in M2. We will bound ∆T (cid:48)(M1, M2) − ∆T (M1, M2) . This amounts to bounding the change in the two values mentioned above. We begin by bounding the number of pixels from M1 that are mapped by T to pixels of M2 but aren't mapped to such pixels by T (cid:48). As ln∞( ¯T , ¯T (cid:48)) < δn, all such pixels are at most δn-far from the outermost pixels of the image. We will bound the number of such pixels by O(δn2). Since PM2 > n (for it contains all the outermost pixels in M2) and since we normalize by n2, these pixels contribute O( n ) as required. We restrict the remaining analysis to pixels that have at least a distance of δn from the outermost pixels in the image. The second value can be viewed as the number of new mismatches between M1 and M2 that are introduced, when replacing T by T (cid:48) (which is not very different from T ), and we will discuss this change (see Figure 1). Formally, if we denote this amount by misT→T (cid:48) = {p ∈ M1M1(p) = M2(T (p)) (cid:54)= M2(T (cid:48)(p))}, it would suffice to show that δPM2 misT→T (cid:48) = O(δnPM2) (the amount of mismatches is normalized by n2, the size of the image, in order to get the difference). We will bound the amount of new mismatches by breaking the image M2 into a grid of δn × δn squares (1/δ such squares on each dimension), showing how the contribution of each square to misT→T (cid:48) depends on its contribution to the perimeter of the image M2. For integers i and j, both between 1 and 1/δ, let bi,j be the δn × δn square located at the ith row and jth column of the squares grid defined above. Summing on these squares, we can write: misT→T (cid:48) = {p ∈ M1T (p) ∈ bi,j, M1(p) = M2(T (p)) (cid:54)= M2(T (cid:48)(p))} 1/δ(cid:88) 1/δ(cid:88) i=1 j=1 We now give several additional definitions: • Let misi,j T→T (cid:48) = {p ∈ M1T (p) ∈ bi,j, M1(p) = M2(T (p)) (cid:54)= M2(T (cid:48)(p))} be the contribution of bi,j to misT→T (cid:48). This definition implies that: -- misT→T (cid:48) =(cid:80)1/δ i=1 (cid:80)1/δ -- For any i and j, misi,j T→T (cid:48) j=1 misi,j T→T (cid:48) is an integer in the range [0, δ2n2] • Let Bi,j denote the 3δn × 3δn square (a block of 3 × 3 original grid squares), containing the square bi,j in its center. • Let P i,j M2 It obviously holds that: be the number of pixels in the perimeter of M2 that exists within the square Bi,j (cid:113) misi,j T→T (cid:48) < δ · n δ −1(cid:88) δ −1(cid:88) 1 1 P i,j M2 PM2 ≥ 1 9 · i=2 j=2 12 (1) (2) Since ln∞( ¯T , ¯T (cid:48)) < δn, each pixel p ∈ M1 that is mapped by T into bi,j is certainly mapped by T (cid:48) into Bi,j. It follows that T→T (cid:48) = {p ∈ M1T (p) ∈ bi,j, T (cid:48)(p) ∈ Bi,j, M1(p) = M2(T (p)) (cid:54)= M2(T (cid:48)(p))} misi,j T→T (cid:48) is the sum of pixels p ∈ M1, which are either 0-pixels or 1-pixels. Assume, with out misi,j loss of generality, that there are more such 0-pixels. These pixels account for at least half the amount: misi,j T→T (cid:48) ≤ 2 · {p ∈ M1T (p) ∈ bi,j, T (cid:48)(p) ∈ Bi,j, 0 = M1(p) = M2(T (p)) (cid:54)= M2(T (cid:48)(p))} This implies that there are at least 0.5 T→T (cid:48) 1-pixels in Bi,j where f (c) is a constant depending only on c (since our scaling factors are within the range [ 1 c , c], f (c) = O(c2) pixels from M1 are mapped to the same pixel in M2). In particular, the larger square Bi,j contains at least 0.5 T→T (cid:48) 1-pixels. T→T (cid:48) 0-pixels as well as at least 0.5 T→T (cid:48) 0-pixels in bi,j and at least 0.5 f (c) · misi,j f (c) · misi,j Using Claim 4.2, we can conclude that: f (c) · misi,j f (c) · misi,j (cid:115) ≥ P i,j M2 0.5 f (c) · misi,j T→T (cid:48) (3) and using the bounds of equations (1) and then (2) and (3), we can conclude that: δ −1(cid:88) 1 δ −1(cid:88) 1 misT→T (cid:48) = misi,j T→T (cid:48) ≤ δ · n · 1/δ(cid:88) 1/δ(cid:88) (cid:113) T→T (cid:48) ≤ 9(cid:112)2f (c)δnPM2 misi,j i=2 j=2 i=1 j=1 Definition 4.2 Let ¯A be the set of Image-Affine transformations. For a positive α, the set of transformations T = {Ti}l i=1 is an α-cover of ¯A if for every A in ¯A, there exists some Tj in T , such that ln∞(A, Tj) ≤ α. We are going to show that for any given n and δ > 0 there's a δn-cover of ¯A with size that does not depend on n but only on δ. Using this fact, given two images M1 and M2 , we will run Algorithm 2 on every member of the cover, and get an approximation of ∆(M1, M2). In fact, we find a transformation T ∈ ¯A that realizes this bound. Claim 4.3 Let T = {Ti}(cid:96) mation T ∈ T such that i=1 be a δn-cover of ¯A and let M1, M2 be two n × n images. A transfor- ∆T (M1, M2) − ∆(M1, M2) ≤ O( · max(PM1, PM2) + ) δ n can be found with high probability using O((cid:96)/2) queries. 13 Figure 1: Consider two δn−close transformations between binary images M1 and M2 (the white/gray areas in the images correspond to 0/1 pixels). The solid and dotted arrows describe the action of the two transformations on the pixels p1, . . . , p5. The areas between the dashed lines in M2 contain the pixels that are δn−close to boundary pixels. The only pixels in M1 that are possibly mapped correctly by one transformation but not by the other are those that are mapped into the 'dashed' area by one of the transformations. In this example, only p1 and p5 are mapped correctly by one, but not by the other. Proof: To find such a transformation T we will run Algorithm 2 for m = Θ(log (cid:96)) times on each of the (cid:96) transformations {Ti} with precision parameter , and set si as the median of the results given for Ti. By the correctness of Claim 4.1 and standard amplification techniques, for each i the value si will differ from ∆Ti(M1, M2) by at most  with probability at least 1 3(cid:96) (we will say such a value si is correct). Using a union bound we get that the probability of any si not being correct is at most 1/3. This will bound our probability of error, and from here on we assume all the values si are indeed correct and show that we will get a transformation as required. We now consider an image affine transformation A such that ∆(M1, M2) = ∆A(M1, M2). By the fact that T is a δn-cover, there exists a transformation Ti such that ln∞(A, Ti) ≤ δn. Given Theorem 4.1 the value ∆Ti(M1, M2) ≤ ∆(M1, M2) + O( δ n · max(PM1, PM2)) and thus the minimum n · max(PM1, PM2) + ). Choosing the transformation Tj value sj will not exceed ∆(M1, M2) + O( δ that this value is associated with, we get that ∆Tj (M1, M2) − ∆(M1, M2) ≤ O( · max(PM1, PM2) + ) δ n as required. In section 4.2 we show the existence of a δn-cover of ¯A whose size is Θ(1/δ6). We can therefore conclude with the following corollaries: Corollary 4.2 Given images M1, M2 and constants δ, , we have that ∆(M1, M2) can be approxi- mated, using O(1/2δ6) queries, with an additive error of O( δ n · max(PM1, PM2) + ). Corollary 4.3 Given images M1, M2 and constants δ,  such that PM1 = O(n) and PM2 = O(n), ∆(M1, M2) can be approximated, using O(1/2δ6) queries, with an additive error of O(δ + ). 14 4.2 Construction of a δn-cover of ¯A In this section we construct a δn-cover of ¯A, which will be a product of several 1-dimensional and 2-dimensional grids of transformations, each covering one of the constituting components of a standard decomposition of Affine transformations [7], which is given in the following claim. Claim 4.4 Every (orientation-preserving) affine transformation matrix A can be decomposed into A = T R2SR1, where T, Ri, S are translation, rotation and non-uniform scaling matrices 2. We now describe a 6-dimensional grid, which we will soon prove to be a δn-cover of ¯A, as needed. According to claim 4.4, every affine transformation can be composed of a rotation, scale, rotation and translation. These primitive transformations correspondingly have 1, 2, 1 and 2 degrees of freedom. These are: rotation angle, x and y scales, rotation angle and x and y translations. It is elementary, for instance, that if we impose a 2-dimensional grid of x and y translations, spaced in each direction by an interval of 2δn, then for any two neighboring translations T1 and T2 on this grid it holds that ln∞(T1, T2) < δn. Since the range of possible translations is limited to the interval [−n, n], the size of the 2-dimensional grid is Θ(1/δ2). Similarly for scaling, we are limited to the interval [ 1 c , c] and in order to have ln∞(S1, S2) < δn for neighboring scalings we use spacings of Θ(δ). Likewise, we cover the 1-dimensional space of rotations, with angles in the interval [0, 2π] with spacings of Θ(δ). Finally, by taking the cartesian product of these grids, we end up with a single grid of size Θ(1/δ6). It remains to be shown that the grid we defined above, which we denote by G, imposes a δn-cover √ of ¯A. Claim 4.5 For every n, for every δ(cid:48), there exists a δ(cid:48)n-cover of ¯A of size Θ(1/δ(cid:48)6). Proof: Given the grid G and any image-affine transformation A, if we denote by A(cid:48) the nearest transformation to A on the grid G, we need to show that ln∞(A, A(cid:48)) < δn. According to claim 1, such that ln∞(T, T (cid:48)), 4.4, A and A(cid:48) can be written in the form A = T R2SR1 and A(cid:48) = T (cid:48)R(cid:48) ln∞(R1, R(cid:48) We now measure how differently A and A(cid:48) might act on a pixel p, in order to obtain a bound on ln∞(A, A(cid:48)). At each stage we use the triangle inequality, accumulating additional distance introduced by each transformation as well as the ln∞ bounds on the constituting transformations. 1), ln∞(S, S(cid:48)) and ln∞(R2, R(cid:48) 2) are all at most δn. 2S(cid:48)R(cid:48) (cid:107)SR1(p) − S(cid:48)R(cid:48) 1(p)(cid:107) ≤ (cid:107)S(R1p) − S(cid:48)(R1p)(cid:107) + (cid:107)S(cid:48)(R1p) − S(cid:48)(R(cid:48) 1p)(cid:107) = (cid:107)(S − S(cid:48))(R1p)(cid:107) + (cid:107)S(cid:48)(R1p − R(cid:48) ≤ δn + c(cid:107)R1p − R(cid:48) 1p(cid:107) = δn + cδn = (c + 1)δn 1p)(cid:107) (cid:107)R2SR1(p) − R(cid:48) 2S(cid:48)R(cid:48) 1(p)(cid:107) ≤ (cid:107)R2(SR1p) − R(cid:48) 2(SR1p)(cid:107) + (cid:107)R2(SR1p) − R(cid:48) 1p)(cid:107) 2(SR1p − S(cid:48)R(cid:48) 2)(SR1p)(cid:107) + (cid:107)R(cid:48) 2(S(cid:48)R(cid:48) 1p)(cid:107) = (cid:107)(R2 − R(cid:48) ≤ δn + (cid:107)SR1p − S(cid:48)R(cid:48) 1p(cid:107) = (c + 2)δn 2arguments are similar for orientation-reversing transformations (which include reflection) 15 (cid:107)A(p) − A(cid:48)(p)(cid:107) = (cid:107)T R2SR1(p) − T (cid:48)R(cid:48) 2S(cid:48)R(cid:48) 1(p)(cid:107) ≤ (cid:107)T (R2SR1p) − T (cid:48)(R2SR1p)(cid:107) + (cid:107)T (cid:48)(R2SR1p) − T (cid:48)(R(cid:48) = (cid:107)(T − T (cid:48))(R2SR1p)(cid:107) + (cid:107)T (cid:48)(R2SR1p − R(cid:48) 1(p)(cid:107) = (c + 3)δn ≤ δn + (cid:107)R2SR1(p) − R(cid:48) The construction follows by setting δ = δ(cid:48)/(c + 3). 2S(cid:48)R(cid:48) 2S(cid:48)R(cid:48) 1p)(cid:107) 2S(cid:48)R(cid:48) 1p)(cid:107) 4.3 3-Dimensional Images In this section we generalize our techniques and results to 3-dimensional images. One important application of the 3-dimensional (0 − 1) setting is to the problem of aligning 3 dimensional solid objects, which are represented by 3-dimensional 0 − 1 matrices, where the objects are represented by the 1s. The other motivation is the need to handle 2-dimensional grayscale images. This is done in section 4.4, where our algorithm is based on a reduction from grayscale images to 3-dimensional 0 − 1 images. In this setting, we are given two images represented by n × n × n 0 − 1 matrices. The image entries are indexed by voxels, which are triplets in {1, . . . , n}3 and the affine transformations in the 3-d space act on a voxel by first multiplying it with a non-singular 3 × 3 matrix A (which accounts for rotation and anisotropic scale), then adding a 'translation' vector and finally rounding down to get a new voxel. The distance under a fixed affine transformation T between two images M1, M2 is defined in an analogous way to the 2-dimensional case (definition 2.5) and is denoted by d = ∆T (M1, M2). So is the distance between two images with respect to affine transformations (that is ∆(M1, M2)). Voxels are considered adjacent if they differ in each of their coordinates by at most 1 and a voxel is a boundary voxel if it is adjacent to different valued voxels. Finally, the perimeter of the image is the set of its boundary voxels together with its outer 6n2− 12n + 8 voxels (and it is always Ω(n2) and O(n3)). Given two images M1, M2 and an affine transformation T we can approximate ∆T (M1, M2) using the same methods as those used in Algorithm 2. The only difference is that we sample voxels rather than pixels. Thus we have: Claim 4.6 Given 3-dimensional binary images M1 and M2 of size n × n × n and an image-affine transformation T , let d = ∆T (M1, M2). There is an algorithm that returns a value d(cid:48) such that d(cid:48) − d ≤  with probability 2/3 and performs Θ(1/2) queries. Claim 4.2 generalizes to the following: Claim 4.7 Given a cubic subsection M of a binary 3-dimensional image with dimensions h×h×h, and an integer b, let PM denote the number of boundary voxels in M . If M contains at least b 0-voxels and at least b 1-voxels, then PM = O(b2/3). the voxels in M as M (i, j, k). Let us denote by M (i, j,·) the sum(cid:80)h Proof: Assume without loss of generality that there are fewer 0-voxels than 1-voxels. We index k=1 M (i, j, k), and use M (i,·, k) and M (·, j, k) in a similar manner. We first note several facts: 1. h ≥ (2b)1/3 16 2. The number of pairs (i, j) such that M (i, j,·) > 0 is at least b2/3. This holds because there are at least h3/2 different 1-voxels. As each pair (i, j) can account for at most h different 1-voxels, there must be at least h2/2 ≥ b2/3 such pairs. 3. Either the number of pairs (i, j) such that M (i, j,·) < h is at least b2/3, or the number of pairs (i, k) such that M (i,·, k) < h is at least b2/3, or the number of pairs (j, k) such that M (·, j, k) < h is at least b2/3. This follows from the following claim which is a direct consequence of Lemma 15.7.5 in Alon and Spencer's book[1]: Claim 4.8 Consider a set S of b vectors in S1 × S2 × S3. Let Si,j be the projection of S into Si × Sj (where i (cid:54)= j). If bij = Si,j then b2 ≤(cid:81) ij bij Assume without loss of generality that the number of pairs (i, j) such that M (i, j,·) < h is at least b2/3 and recall that the number of pairs (i, j) such that M (i, j,·) > 0 is at least b2/3. We consider two cases: 1. In the first case there are at least b2/3/2 pairs of indices (i, j) such that 0 < M (i, j,·) < h. Each such pair surely accounts for at least one boundary pixel, and we are done. 2. In the second case there are at least b2/3/2 pairs of indices (i, j) such that M (i, j,·) = 0 and at least b2/3/2 pairs of indices (i, j) such that M (i, j,·) = h. In this case one of the following will hold: (a) There are at least b1/3/2 indices i such that there exists an index j such that M (i, j,·) = 0 and there are at least b1/3/2 indices i such that there exists an index j such that M (i, j,·) = h. (b) There are at least b1/3/2 indices j such that there exists an index i such that M (i, j,·) = 0 and there are at least b1/3/2 indices j such that there exists an index i such that M (i, j,·) = h. We assume without loss of generality that Case 2a holds. This means that, again, one of two cases holds: (a) There are more than b1/3/2 indices i such that there are both indices j0 and j1 such that M (i, j0,·) = 0 and M (i, j1,·) = h. In this case each such index accounts for h boundary pixels, and we thus have at least hb1/3/2 ≥ b2/3/2 boundary pixels, and we are done. (b) Otherwise, there is at least one index i0 such that for all j M (i0, j,·) = 0, and there is least one index i1 such that for all j M (i1, j,·) = h. But this means that for any pair of indices (j, k) it holds that M (i0, j, k) = 0 and M (i1, j, k) = 1 and there must be at least one boundary pixel for each such pair (j, k), giving us at least h2 ≥ b2/3 boundary pixels and we are done. Our "central" theorem 4.1 generalizes to the following: 17 Theorem 4.4 Let M1, M2 be n× n× n images and let δ be a constant in (0, 3). Let T and T (cid:48) be image affine transformations based on the affine transformations ¯T , ¯T (cid:48), such that ln∞( ¯T , ¯T (cid:48)) < δn. It holds that √ dT (cid:48)(M1, M2) ≤ dT (M1, M2) + O (cid:16) δPM2 (cid:17) n Proof: (Outline of differences from the original proof) The square grids b and B are now cubes of edge size δn and 3δn respectively and are parametrized by the triplet i, j, k. Some of our observations slightly change: PM2 ≥ 1 27 · Using Claim 4.7, we can conclude that: 3(cid:113) misi,j,k T→T (cid:48) < δ · n δ −1(cid:88) δ −1(cid:88) δ −1(cid:88) 1 1 1 P i,j,k M2 i=2 j=2 k=2 P i,j,k M2 ≥ ( 0.5 f (c) · misi,j,k T→T (cid:48))2/3 and using the bounds of equations (4) and then (5) and (6), we can conclude that: δ −1(cid:88) 1 δ −1(cid:88) 1 δ −1(cid:88) 1 i=2 j=2 k=2 misT→T (cid:48) = misi,j,k T→T (cid:48) ≤ δ · n · 1/δ(cid:88) 1/δ(cid:88) 1/δ(cid:88) i=1 j=1 k=1 T→T (cid:48))2/3 ≤ 27(cid:112)2f (c)δnPM2 (misi,j,k (4) (5) (6) It is straightforward to extend the 2-dimensional case and construct a δn cover for the set of 3-dimensional affine transformations where the size of the cover depends only on δ. As in the 2-dimensional case, the matrix 3× 3 matrix A can be decomposed (using SVD decomposition) into a product of rotation, scaling and rotation matrices. Together with the final translation vector, we get a δn−cover of size 1/δ10. The existence of such a cover along with a 3-dimensional analog of claim 4.3 implies: Corollary 4.5 Given 3-dimensional images M1, M2 and fixed constants δ,  > 0 such that PM1 = O(n2) and PM2 = O(n2), the distance ∆(M1, M2) can be approximated, using O(1/2δ10) queries, with an additive error of O(δ + ). 4.4 Grayscale Images In this section we handle 2-dimensional grayscale images by no longer limiting ourselves to binary {0, 1} valued pixels but rather allowing a pixel p to have any value M (p) in the interval [0, 1]. This model covers the commonly practiced discretizations (e.g. to 256 grey levels) of the intensity information in a digital image. In the following definitions we extend the concept of the perimeter to grayscale images. 18 Definition 4.3 The gradient of a pixel in a grayscale image M is the maximal absolute difference between the pixel value and the pixel values of its adjacent pixels. Definition 4.4 The perimeter size PM of a grayscale image M is defined as the sum of its pixels' gradients (where the gradient of each of the 4n − 4 outermost pixels of the image is counted as 1). Notice, that the gradient of a pixel is a real valued number in [0, 1] and that if we consider a binary 0-1 image, its boundary pixels are exactly those with gradient one. Also, the perimeter size is Ω(n) and O(n2). When dealing with binary 0−1 images, our similarity measure between images was defined to be the maximal similarity between the images with respect to any Affine transformation on the image pixels. In the grayscale extension we would like to introduce further transformations, allowing our distance metric to capture (or be invariant to) illumination changes. That is, we would like to consider images that differ by a global linear change in pixel values to be similar. Such a linear change first multiplies all image pixels values by a 'contrast' factor con and then adds to them a 'brightness' factor bri. As is custom in the field, pixel values that deviate from the [0, 1] interval as a result of such a transformation will be truncated so that they stay within the interval. Also, we limit con to the interval [1/c, c] for some positive constant c and therefore bright can be limited to [−c, 1] (since con maps a pixel value into the range [0, c]). We denote the family of such intensity transformations by ¯BC. Definition 4.5 Let T1 and T2 be any two functions from ¯BC. The ln∞ distance between T1 and T2 is defined as the maximum over pixel values v ∈ [0, 1] of max(cid:107)T1(v) − T2(v)(cid:107)2 (which equals maxT1(v) − T2(v)). We can now define the distance between grayscale images under a combination of an affine and an intensity transformation. Definition 4.6 Let T ∈ ¯A be an Affine transformation and let L ∈ ¯BC be and intensity transfor- mation. The distance between grayscale images M1, M2, with respect to T and L is: (cid:0)1T (p) /∈M2 + 1T (p)∈M2 · M1(p) − L(M2(T (p)))(cid:1) (cid:88) p∈M1 ∆T,L(M1, M2) = 1 n2 We can now state our main result: Claim 4.9 Given n × n grayscale images M1, M2 and positive constants δ and , we can find transformations T ∈ T and L ∈ BC such that with high probability (cid:16) δ n (cid:17) · max(PM1, PM2) +  ∆T,L(M1, M2) − ∆(M1, M2) ≤ O using O(1/2δ8) queries. Proof: We will show Claim 4.9 holds by reducing the problem of approximating the distance between two 2-dimensional grayscale images to that of approximating the distance between two 3-dimensional 0− 1-images. In particular, we will map an n× n grayscale image M to an n× n× n binary image M(cid:48) defined as follows: M(cid:48)(i, j, k) = 1 if and only if M (i, j) ≥ k/n. 19 This essentially means that a pixel with intensity g is represented by a column of pixels where the bottom (cid:98)gn(cid:99) pixels are 1-pixels and the remaining are 0-pixels. The perimeter PM(cid:48) of M(cid:48) is Θ(n2) + PM · n. This follows since a gradient of g at a pixel p creates gn boundary pixels in M(cid:48). Any image-affine transformation T of the grayscale image can be applied to a voxel in M(cid:48) without changing the voxels's third coordinate, that is, we can see the transformation T as mapping between columns of voxels. Likewise, intensity transformations L can be seen as applying only to the third coordinate of a voxel, that is, mapping pixels to higher or lower locations in their corresponding columns and truncating them to n (1) if their value is larger (smaller) than n (1). This truncation is equivalent to the truncation of the pixel values to the interval [0, 1] when applying intensity transformations on grayscale images. We wish to derive a similar result to corollary 4.3. To do this, we consider a slightly different metric on 3-dimensional binary images. Namely, we limit the general family of 3-dimensional affine transformations to include only transformations that apply a two dimensional affine transformation on the first two coordinates as well as scale and translation on the third coordinate (which relate to the intensity component of the transformation). Call this family of transformations S. Now we can proceed in a similar fashion to corollary 4.3. Denote by M(cid:48) 2 the resulting 3-dimensional images after applying our reduction on the 2-dimensional grayscale images M1 and M2. It holds that ∆(M1, M2) = ∆(M(cid:48) 2) as there is a one to one correspondence between transformations of grayscale images defined by a pair T and L between M1 and M2 and transformations in ¯S between M(cid:48) 2. Furthermore, by the way our reduction was defined, such a corresponding pair of transformations yield the same distance between both pairs of images. 1 and M(cid:48) 1, M(cid:48) 1 and M(cid:48) We can now proceed along the same reasoning leading to corollary 4.3. Namely, we construct a δn cover for our limited set of 3-dimensional transformations. For the component of the 2- dimensional affine transformation we use the same cover used in section 4.2 of size Θ( 1 δ6 ). For the intensity component we use a similar construction by dividing the scale and translation ranges in the third coordinate to step sizes of Θ(δn) and Θ(δ) respectively. The resulting cover is of size Θ( 1 δ8 ) and it is easily shown to be a valid δn cover. The assertion now follows in a similar way to corrolary 4.3. The only difference is that we consider only the set of restricted transformations S rather than the set of all 3-dimensional affine transformations. We conclude with the following corollary: Corollary 4.6 Given n × n grayscale images M1, M2 and constants δ,  such that PM1 = O(n) and PM2 = O(n), the distance ∆(M1, M2) can be approximated, using O(1/2δ8) queries, with an additive error of O(δ + ). References [1] N. Alon and J.H. Spencer. The probabilistic method, volume 73. Wiley-Interscience, 2008. [2] H. Alt, K. Mehlhorn, H. Wagener, and E. Welzl. Congruence, similarity, and symmetries of geometric objects. Discrete and Computational Geometry, 3(1):237 -- 256, 1988. [3] T. Batu, F. Ergun, J. Kilian, A. Magen, S. Raskhodnikova, R. Rubinfeld, and Rahul Sami. A sublinear In Proceedings of the Thirty-Fifth Annual ACM algorithm for weakly approximating edit distance. Symposium on the Theory of Computing (STOC), pages 316 -- 324, 2003. [4] L. Paul Chew, Michael T. Goodrich, Daniel P. Huttenlocher, Klara Kedem, Jon M. Kleinberg, and Dina Kravets. Geometric pattern matching under euclidean motion. Comput. Geom., 7:113 -- 124, 1997. 20 [5] M. Gavrilov, P. Indyk, R. Motwani, and S. Venkatasubramanian. Combinatorial and experimental methods for approximate point pattern matching. Algorithmica, 38(1):59 -- 90, 2003. [6] U. Hahn, N. Chater, and L.B. Richardson. Similarity as transformation. Cognition, 87(1):1 -- 32, 2003. [7] R. Hartley and A. Zisserman. Multiple view geometry in computer vision. Cambridge university press, 2008. [8] C. Hundt and M. Li´skiewicz. Combinatorial bounds and algorithmic aspects of image matching under projective transformations. Mathematical Foundations of Computer Science 2008, pages 395 -- 406, 2008. [9] C. Hundt and M. Li´skiewicz. New complexity bounds for image matching under rotation and scaling. Journal of Discrete Algorithms, 2010. [10] I. Kleiner, D. Keren, I. Newman, and O. Ben-Zwi. Applying property testing to an image partitioning problem. IEEE Trans. Pattern Anal. Mach. Intell., 33(2):256 -- 265, 2011. [11] G.M. Landau and U. Vishkin. Pattern matching in a digitized image. Algorithmica, 12(4):375 -- 408, 1994. [12] R.P. Millane, S. Alzaidi, and W.H. Hsiao. Scaling and power spectra of natural images. In Proceedings of Image and Vision Computing New Zealand, pages 148 -- 153, 2003. [13] S. Raskhodnikova. Approximate testing of visual properties. In Proceedings of the Seventh International Workshop on Randomization and Approximation Techniques in Computer Science (RANDOM), pages 370 -- 381, 2003. [14] R. Szeliski. Image alignment and stitching: A tutorial. Foundations and Trends® in Computer Graphics and Vision, 2(1):1 -- 104, 2006. [15] G. Tsur and D. Ron. Testing properties of sparse images. In FOCS, pages 468 -- 477. IEEE Computer Society, 2010. [16] A. Tversky. Features of similarity. Psychological review, 84(4):327, 1977. [17] A. van der Schaaf and J.H. van Hateren. Modelling the power spectra of natural images: statistics and information. Vision Research, 36(17):2759 -- 2770, 1996. [18] R.C. Veltkamp. Shape matching: Similarity measures and algorithms. In smi, page 0188. Published by the IEEE Computer Society, 2001. [19] B. Zitova and J. Flusser. Image registration methods: a survey. Image and vision computing, 21(11):977 -- 1000, 2003. 21
1711.00103
2
1711
2018-01-07T20:53:40
Scheduling Monotone Moldable Jobs in Linear Time
[ "cs.DS" ]
A moldable job is a job that can be executed on an arbitrary number of processors, and whose processing time depends on the number of processors allotted to it. A moldable job is monotone if its work doesn't decrease for an increasing number of allotted processors. We consider the problem of scheduling monotone moldable jobs to minimize the makespan. We argue that for certain compact input encodings a polynomial algorithm has a running time polynomial in n and log(m), where n is the number of jobs and m is the number of machines. We describe how monotony of jobs can be used to counteract the increased problem complexity that arises from compact encodings, and give tight bounds on the approximability of the problem with compact encoding: it is NP-hard to solve optimally, but admits a PTAS. The main focus of this work are efficient approximation algorithms. We describe different techniques to exploit the monotony of the jobs for better running times, and present a (3/2+{\epsilon})-approximate algorithm whose running time is polynomial in log(m) and 1/{\epsilon}, and only linear in the number n of jobs.
cs.DS
cs
Scheduling Monotone Moldable Jobs in Linear Time∗ Klaus Jansen Felix Land January 9, 2018 Abstract A moldable job is a job that can be executed on an arbitrary number of processors, and whose processing time depends on the number of processors allotted to it. A moldable job is monotone if its work doesn't decrease for an increasing number of allotted processors. We consider the problem of scheduling monotone moldable jobs to minimize the makespan. We argue that for certain compact input encodings a polynomial algo- rithm has a running time polynomial in n and log m, where n is the number of jobs and m is the number of machines. We describe how monotony of jobs can be used to counteract the increased problem complexity that arises from compact encodings, and give tight bounds on the approximability of the problem with compact encoding: it is NP-hard to solve optimally, but admits a PTAS. The main focus of this work are efficient approximation algorithms. We describe different techniques to exploit the monotony of the jobs for better running times, and present a ( 3 2 + ε)-approximate algorithm whose running time is polynomial in log m and 1 ε , and only linear in the number n of jobs. 1 Introduction In classical scheduling models, the input consists of a description of the available processors, and a set of jobs with associated processing times. Each processor can process one job at any point in time. Additional constraints may be part of the model. One way to model complex, parallelizable tasks are moldable1 jobs, which have a variable parallelizability [4]. Formally, we are given a set J consisting of n jobs and a number m of processors. The processing time tj(1) on one processor is given for each job j, as well as the speedup sj(k) that is achieved ∗Research was in part supported by German Research Foundation (DFG) project JA 612/16- 1. 1Some authors use the term malleable. 1 when executing it on k > 1 processors. The processing time on k processors then is given as tj(k) = tj(1) sj (k). The goal is to produce a schedule that assigns for each job a starting time and a number of allotted processors such that the makespan, i.e. the completion time of the last job, is minimized. Without restriction, we assume that the speedup is non-decreasing, or equiva- lently, the processing time is non-increasing in the number of processors. A job is called monotone if its work function wj(k) = k × tj(k) is non-decreasing. This is a reasonable assumption, since an increased number of processors requires more communication. Monotony helps when designing algorithms [1, 20, 22]. Some- times even stronger2 assumptions are made, e.g. that the speedup functions are concave [24, 23, 15]. Since the problems considered here are NP-hard, we will discuss approxima- tion algorithms. An algorithm for a minimization problem is c-approximate if it produces a solution of value at most c OPT(I) for each instance I. The num- ber c ≥ 1 is called its approximation guarantee. We pay extra attention to the encoding length kIk in dependence of the number m of processors. The running time of most algorithms is polynomial in m [1, 25, 12, 13, 22, 14]. Many authors expect that the values tj(k), k ∈ {1, . . . , m} are explicitly given as a list, such that m = O(kIk). Under this as- sumption, these algorithms' running time is polynomial in the input size. On the other hand, more compact encodings are conceivable in many cases. Sometimes it is assumed that the processing time function is of a special form, e.g. linear [7] or a power function [19], which can be described with a constant number of coefficients. Since the number of processors is encoded in log m bits, the afore- mentioned algorithms can have a running time that is exponential in the input length when compact enconding is used. It is our main goal to develop fully polynomial algorithms for instances with compact input encoding, i.e. algorithms with a running time polynomial in log m. Such algorithms will outperform algorithms whose running time is polynomial in m for large values of m (super-polynomial in the input size). Only few known algorithms are fully polynomial in this sense [20, 23, 9]. Since we do not want to stipulate a certain form of speedup functions, we assume that the running times tj(k) can be accessed via some oracle in constant time. It is known that finding an exact solution without monotony Previous Results is NP-hard [4]. If the jobs are monotone, it is only known that finding an exact solution is weakly NP-hard [10]. Both results even hold for a constant number of processors. As a consequence, they also hold with compact input encoding. The problem complexity actually depends on the used input encoding. It is known that there is no polynomial time algorithm for scheduling of parallel jobs with approximation guarantee less than 3 2, unless P = NP. This can be deduced from 2For a proof that concave speedup functions imply monotony, see [15]. 2 a reduction from the partition problem to scheduling of parallel jobs [3]. By setting tj(k) = tj if k ≥ size(j) and tj(k) = ∞ otherwise, we can extend the result to scheduling of moldable jobs, although the resulting work functions are not monotone. However, this reduction is polynomial only if we use a compact encoding for the resulting instance. Furthermore, if we allow algorithms to be polynomial in m, the produced instances can be optimally solved: since the reduction is one-to-one, we can go back to the original partition instance, solve it via dynamic programming in time O(nm), and convert the solution back to the scheduling setting. Indeed, without compact encoding, the problem admits a PTAS [14]. Considering approximate algorithms, Belkhale and Banerjee [1] found a 2- approximate algorithm for scheduling monotone moldable tasks. This approx- imation guarantee was later matched without monotony by an algorithm due to Turek, Wolf, and Yu [25]. The running time was later improved by Ludwig and Tiwari [18]. Their algorithm for the case of monotone jobs was the first to achieve a running time polynomial in log m, namely O(n log2 m). Mounié, Rapine, and Trystram improved the approximation guarantee with monotony to √3 + ε ≈ 1.73, with arbitrarily small ε > 0, also with polylogarithmic depen- dence on m. They later presented a ( 3 2 + ε)-approximate algorithm with running time O(nm log 1 ε ) [21, 22]. A PTAS with running time polynomial in m was subsequently developed that does not require monotony [14]. Finally, a ( 3 2 + ε)- approximate algorithm with polylogarithmic dependence on m that also does not assume monotone jobs was developed by Jansen [9]. Our Contribution We improve the understanding of scheduling monotone moldable jobs in several ways. In Section 2 we resolve the complexity of the considered problem. Theorem 1. It is NP-complete to decide whether a set of monotone jobs can be scheduled with a given makespan. We proceed to describe an extremely efficient FPTAS for the case that the number of machines is large enough in Section 3. Theorem 2. There is an FPTAS for the case that m ≥ 8 n of O(n log2 m(log m + log 1 ε )). ε with a running time In combination with the PTAS by Jansen and Thöle [14], this yields a PTAS for scheduling of monotone moldable jobs with compact encoding of running times. The algorithm by Jansen [9] achieves the same approximation guarantee in the more general case without monotony, but has a significantly worse running time. In particular, our new algorithm's running times are polynomial in 1 ε , while Jansen's algorithm is doubly exponential in 1 ε . 3 Table 1: Running times of our ( 3 2 + ε)-dual algorithms. Algorithm T (n, m, ε) Section 4.2.5 O(n(log m + n log εm)) Section 4.3 O(cid:0)n(cid:0) 1 Section 4.3.3 O(cid:0)n 1 ε2 log m(cid:0) log m ε2 log m(cid:0) log m ε + log3(εm)(cid:1) + log n(cid:1)(cid:1) ε + log3(εm)(cid:1)(cid:1) In Section 4 we first describe the ( 3 2 +ε)-approximate algorithm due to Mounié, Rapine, and Trystram [22], and improve its running time to fully polynomial. We further present techniques to gradually reduce the dependence of the running time on the number n of jobs. Theorem 3. For each T given in Table 1, there is a ( 3 with running time O(n log2 m + log 1 ε T (n, m, ε)). 2 +ε)-approximate algorithm We make repeated use of a technique we call compression. It reduces the number of processors used by a job in exchange for a bounded increase in the running time. Compression allows us to approximate processor numbers for jobs that are allotted to a large number of processors. This enables the use of various rounding techniques. The intermediate solution then may use more than m pro- cessors, before the jobs are finally compressed such that they require at most m processors. This is similar to models with resource augmentation (see e.g. [2]), except that we can use additional processors only for jobs that are allotted to a large number of processors. 2 NP-Completeness of Monotone Moldable Job Scheduling In this section we discuss Theorem 1. To be precise, we consider the problem of deciding whether a given instance of scheduling monotone moldable jobs can be scheduled with makespan at most d, where d is also part of the input. Proof of Theorem 1. We first argue that the problem is in NP by giving a nonde- terministic polynomial procedure for solving the problem: first, guess the number of processors allotted to each job in an optimal schedule. Since these numbers are at most m, we can guess them one bit at a time in n log m steps. Afterwards, we guess the order in which the jobs start. This is a list of n numbers in {1, . . . , n}, which can be encoded in n log n bits. Again, we can guess this encoding in n log n steps. We now use list scheduling to schedule the jobs in this order while respect- ing the previously guessed processor counts. This procedure is clearly possible in polynomial time and uses n(log m + log n) (binary) guessing steps. We give a reduction from 4-Partition to prove that our scheduling problem is strongly NP-hard. Recall that an instance of 4-Partition contains a set A = 4 5 and B {a1, . . . , a4n} of natural numbers and a number B, and remains NP-hard even when all numbers are strictly between B 3 [6]. We construct an instance of the scheduling problem as follows. First, we assume thatP4n i=1 ai = nB, otherwise we output a trivial no-instance. Next, we scale the numbers such that ai ≥ 2 for each i ∈ {1, . . . , 4n}. The number of machines will be m = n. Now we create a job ji for each number ai, which has processing time tji(k) = mai − k + 1. Note that these functions are monotonically decreasing. Also mai ≥ 2m > 2k for each k < m and therefore the work satisfies wji(k + 1) = (k + 1) × tji(k + 1) = (k + 1)(mai + 1) − (k + 1)2 = k(mai + 1) − k2 + (mai + 1) − 2k − 1 = wji(k) + mai − 2k > wji(k), (1) i.e the jobs are strictly monotone. The target makespan is d = nB. It remains to show that this is indeed a reduction, i.e. that a schedule with makespan nB exists if and only if the instance of 4-Partition is a yes-instance. i=1 wji(1) = P4n all jobs is at least P4n First assume that there is a schedule with makespan d. The total work of i=1 mai = md. Due to the strict monotony, our schedule must allot exactly one processor to each job, and all machines have load d, see Fig. 1 for an example of such a schedule. The numbers corresponding to the jobs on one machine sum up to B, and because they are strictly between 5 and B B 3 , there are exactly four such numbers. Therefore, there is a solution to the instance of 4-Partition. On the other hand, if the instance of 4-Partition is a yes-instance, a schedule as depicted in Fig. 1 is easily constructed from a solution. This shows that scheduling monotone jobs is NP-hard in the strong sense. Fur- thermore, using a complexity result for 4-Partition [11], there is no algorithm that solves this problem exactly in time 2o(n) × kIkO(1), unless the Exponential Time Hypothesis fails. e m T i nB 0 · · · m Figure 1: Structure of a schedule with makespan nB 5 3 An FPTAS for Large Machine Counts In this section, we present a fully polynomial approximation scheme (FPTAS) for the case that m ≥ 8 n ε , as stated in Theorem 2. An FPTAS finds a (1 + ε)- approximate solution in time polynomial in the input length and 1 ε for each ε ∈ (0, 1]. The case where m is much larger than n is the most interesting case in our setting with compact input encoding, because otherwise m is polynomial in the input. Furthermore, this allows us to focus on the case m < 8 n ε in the following chapters. The algorithm itself is a dual approximate algorithm [8]. A c-dual approx- imate algorithm accepts a number d in addition to the instance as input. It will output a solution with makespan at most cd, provided that a solution with makespan d exists. Otherwise, it may reject the instance. It is well known that a c-approximate dual algorithm with running time T (n, m) can be turned into a (c + ε)-approximate algorithm with running time O(T ′(n, m) + log 1 ε × T (n, m)), where T ′(n, m) is the running time of an estimation algorithm with arbitrary but constant estimation ratio. An estimation algorithm with estimation ratio ρ computes a value ω that estimates the minimum makespan within a factor of ρ, i.e. ω ≤ OPT ≤ ρω. Here, we use an algorithm due to Ludwig and Tiwari [18] with running time T ′(n, m) = O(n log2 m). Although they do not explicitly state this, their algorithm can be trivially turned into one with estimation ratio 2: Their algorithm computes an allotment a which allots to each job j ∈ J a number aj of processors, and this allotment minimizes the value ω = min(cid:18) 1 mXj∈J wj(aj), max j∈J tj(aj)(cid:19) (2) among all allotments. Therefore ω ≤ OPT. On the other hand, the list scheduling algorithm, applied to the instance with the fixed allotment a, produces a schedule of makespan at most 2ω [5], so OPT ≤ 2ω. For our algorithm, we specify c = 1 + ε, resulting in a 1 + 2ε approxima- tion ratio. Our algorithms will frequently schedule jobs using the least number of processors such that its processing time is below a threshold t. Therefore tj(p) ≤ t}, see also the work of Mounié, Rapine, and let γj(t) = min{p ∈ [m] Trystram [22]. Note that γj(t) can be found in time O(log m) by binary search. The algorithm is extremely simple: allot γj((1 + ε)d) processors to each job j If this schedule requires more than m ma- and schedule them simultaneously. chines, reject. Clearly, the running time for the dual approximate algorithm is O(n log m). The final algorithm therefore requires O(n log m(log m + log 1 ε )) time. 6 3.1 Analysis It remains to show that the algorithm is indeed (1 + ε)-dual approximate. The produced schedule clearly has makespan at most (1 + ε)d by the definition of γj((1 + ε)d). To prove that the algorithm only rejects if there is no schedule with makespan d, we will argue that the produced schedule requires at most m processors, i.e. Pj∈J γj((1 + ε)d) ≤ m, provided that d ≥ d∗, where d∗ is the optimal makespan. To this end, we consider the same algorithm with a more complex allot- ment rule, which uses compression of jobs, our main technique for exploiting the monotony of the work functions. Compression reduces the number of pro- cessors allotted to a job in exchange for a bounded increase of its processing time. Lemma 4. If j is a job that uses b ≥ 1 ρ machines in some schedule, where ρ ∈ (0, 1/4], then we can free ⌈bρ⌉ machines and the schedule length increases by at most 4ρ tj(b). We call the value ρ the compression factor. Proof. Formally, the statement of the lemma is tj(⌊b(1 − ρ)⌋) ≤ (1 + 4ρ) tj(b). For the proof we set b′ = ⌈b(1 − 2ρ)⌉ ≤ b. Since b ≥ 1 ρ we have bρ ≥ 1 and thus b′ ≤ ⌊b(1 − ρ)⌋. This implies tj(⌊b(1 − ρ)⌋) ≤ tj(b′) Because our jobs are monotonic we have tj(b′) × b′ = wj(b′) ≤ wj(b) = tj(b) × b. Hence (and because 1 − 2ρ ≥ 1/2) it follows that b b(1 − 2ρ) 1 − 2ρ(cid:19) 2ρ tj(b′) ≤ tj(b) × b b′ ≤ tj(b) × = tj(b) ×(cid:18)1 − 2ρ 1 − 2ρ ≤ (1 + 4ρ) tj(b) + and the lemma follows. Our second allotment rule has two steps. (i) Allot aj = γj(d) processors to each job j. (3) (4) (ii) Compress each job that is allotted to at least 4 ε processors with a factor of ρ = ε 4. Note that ρ ≤ 1 processing time at most (1 + ε)d with this allotment rule. 4 because we assumed ε ≤ 1. According to Lemma 4, each job has 7 We claim that the resulting schedule requires at most m processors. Assume statement clearly holds. Then the number of required processors is still bounded: that this is not the case after the first step, i.e. Pj∈J aj > m, otherwise the Lemma 5. If d ≥ d∗ we have Pj∈J aj < m + n. Proof. Let J ′ = {j ∈ J aj = 1} and assume the statement holds if we remove the jobs in J ′ and their allotted machines, i.e.Pj∈J\J ′ aj < (m−J ′) + (n−J ′). Then Pj∈J aj =Pj∈J\J ′ aj + J ′ < m + n − J ′ ≤ m + n. It is therefore sufficient to show the statement for jobs with aj > 1. Assume that d ≥ d∗. Then there is a schedule with makespan at most d. For each job j let a∗ j . Using the monotony of the work function, we have j be the number of allotted processors in this schedule. Then aj ≤ a∗ (cid:18)Xj∈J (aj − 1)(cid:19)d =Xj∈J <Xj∈J =Xj∈J ≤Xj∈J (aj − 1)d (aj − 1) tj(aj − 1) wj(aj − 1) wj(aj) ≤Xj∈J wj(cid:0)a∗ (5) j(cid:1) ≤ md. Therefore (cid:0)Pj∈J aj(cid:1) − n =Pj∈J(aj − 1) < m, proving the lemma. Now partition the jobs into narrow and wide jobs, J = JN∪JW . The wide jobs are those that are compressed in the second step, i.e. JW = {j ∈ J γj(d) ≥ 1 ρ} and JN = J \ JW . Let α =Pj∈JW narrow jobs we have β ≤ n 1 we have α > m α + β ≤ m + n. It follows that (1 − ρ)α + β ≤ m, proving our claim. aj and β =Pj∈JN In the second step, at least ρα processors are freed. By definition of the ε ≤ m 2 . Since we assumed that α + β > m 2 ≥ n. According to Lemma 5 we also have ρ = 4 n 2 . Therefore ρα > ρ m To prove the claim about the first allotment rule, we note that it cannot use more processors for any job, because it picks the minimum number of allotted processors when we target a makespan of (1 + ε)d. Therefore, our algorithm is (1 + ε)-dual approximate, proving Theorem 2. aj. 3.2 A PTAS for the General Case For the general case we can still achieve a PTAS. When m ≥ 8 n ε , simply use the previously described algorithm. Otherwise apply the algorithm by Jansen and Thöle [14]. It is (1 + ε)-approximate and has a running time polynomial in n and m (but exponential in 1 ε ). Since we use this algorithm only in the case that m < 8 n ε , the running time is polynomial even when a compact input encoding is used for the processing times. 8 4 A Linear ( 3 2 + ε)-Approximation Unfortunately, the running time of the PTAS used in the last section is rather prohibitive. We therefore want to develop more efficient algorithms. The al- gorithms we present in this section are modifications of the algorithm due to Mounié, Rapine, and Trystram [22] which has running time O(nm). We aim for a fully polynomial algorithm with a running time that depends only linearly on the number n of jobs. We achieve this goal with several modification to the original algorithm. Be- fore explaining our enhancements, we describe the original algorithm by Mounié, Rapine, and Trystram. In section 4.2 we show how to modify the algorithm such that the running time is logarithmic in the number m of of machines. With these modifications, the dependence of the running time on n actually increases. We can however improve upon the general idea in section 4.3. 4.1 The Original Algorithm The algorithm is 3 2 -dual approximate. Let d be the target makespan. The algo- rithm is based on the observation that all jobs with a running time larger than d 2 in a feasible schedule of makespan d can be executed in parallel. Removing the Small Jobs We partition the jobs into small and big jobs, J = JS(d) ∪ JB(d). Small jobs are jobs that complete in time d 2 on one machine, i.e. jobs j ∈ J with tj(1) ≤ d 2. All other jobs will be denoted as big jobs. We remove the small jobs from the instance, they will be re-added in a greedy manner at the end of the algorithm. Let WS(d) =Pj∈JS(d) tj(1) be the total work of these jobs. Finding a Preliminary Schedule In this step, a schedule for the big jobs is constructed by placing them in two shelves, shelf S1 with processing time d and shelf S2 with processing time d 2. The shelves are scheduled after each other for a total makespan of 3 2 d. Since a feasible schedule of this type may not exist, we allow the second shelf to use more than m processors, see Fig. 2. We call such a schedule a two-shelf-schedule. A two-shelf-schedule can be found by solving a knapsack problem where shelf S1 uses at most m processors and the profit of each job is the amount of work saved when it is scheduled in shelf S1 instead of shelf S2, i.e. vj(d) = wj(cid:0)γj(cid:0) d 2(cid:1)(cid:1)− wj(γj(d)). Note that the monotony implies that vj(d) ≥ 0. If γj(d) is undefined for any job j, i.e. tj(m) > d, then we can safely reject d. Each job j ∈ JB(d) for which γj(cid:0) d 2, must be scheduled in S1. Those jobs can be easily handled by removing them from the knapsack problem and reducing the capacity accordingly. In order to keep the notation simple, we will however assume that no such jobs exist. We denote the 2(cid:1) is undefined, i.e. tj(m) > d 9 d 3 2 d 0 S2 S1 m Figure 2: Example of an infeasible two-shelf-schedule knapsack problem max J ′⊆JB(d)Xj∈J ′ vj(d) s.t. Xj∈J ′ γj(d) ≤ m (6) by KP(JB(d), m, d) and the profit of an optimal solution by OPTKP(JB(d), m, d). Solving the knapsack problem requires time O(nm) with a standard dynamic pro- gramming approach. Calculating the required values of γj can be done beforehand in time O(n log m), Let J ′ be a solution to this knapsack problem. Then we can create a two- shelf-schedule by placing the jobs J ′ in S1 and the jobs JB(d) \ J ′ in S2. The work of this schedule is W (J ′, d) =Xj∈J ′ = Xj∈JB(d) wj(γj(d)) + Xj∈JB(d)\J ′ 2(cid:1)(cid:1) −Xj∈J ′ wj(cid:0)γj(cid:0) d wj(cid:0)γj(cid:0) d 2(cid:1)(cid:1) vj(d). (7) At this point, we will reject d if W (J ′, d) is found to be larger than md − WS(d). The correctness of this step is shown in the following lemma. Lemma 6 ([22]). If there is a schedule for all jobs with makespan d, then there is a solution J ′ to KP(JB(d), m, d) with W (J ′, d) ≤ md − WS(d). Proof. We only consider the big jobs in the feasible schedule, and their total work WB is bounded from above by md− WS(d), because WS(d) is a lower bound on the work of the small jobs. The jobs with processing time larger than d 2 induce a feasible solution J ′ to the knapsack problem. Then vj W (J ′, d) = Xj∈JB(d) =Xj∈J ′ ≤ WB ≤ md − WS(d), 2(cid:1)(cid:1) −Xj∈J ′ wj(cid:0)γj(cid:0) d wj(γj(d)) + Xj∈JB(d)\J ′ wj(cid:0)γj(cid:0) d 2(cid:1)(cid:1) (8) 10 d 3 2 d 0 S2 S1 S0 m Figure 3: An example of a schedule after applying the transformation rules so J ′ is the claimed solution. Otherwise, the following step will transform the two-shelf-schedule into a fea- sible schedule for all jobs. Lemma 7 ([22]). Let J ′ ⊆ JB(d) be a solution of KP(JB(d), m, d) with W (J ′, d) ≤ md − WS(d). Then we can find a schedule for all jobs in J with makespan 3 2d in time O(n log n). 4.1.1 Proof of Lemma 7 Obtaining a Feasible Schedule We exhaustively apply three transformation rules that move some jobs to a new shelf S0. The jobs in S0 will be scheduled concurrent to S1 and S2 in 3 2d time units. creating a three-shelf-schedule. For an example, see Fig. 3. (i) If job j ∈ S1 has processing time tj(γj(d)) ≤ 3 j to γj(d) − 1 processors in S0. 4d and γj(d) > 1, then allocate (ii) If two jobs j, j′ ∈ S1 each have processing time at most 3 4 d and γj(d) = γj ′(d) = 1, then schedule j and j′ sequentially on one processor in S0. If there is only one job j with tj(γj(d)) ≤ 3 4 d and γj(d) = 1, a special case if also a job j′ in S1 with tj ′(γj ′(d)) > 3 applies [21]: 4d and tj(γj(d)) + tj ′(γj ′(d)) ≤ 3 2d exists, j is scheduled on top of j′ in S0. Conceptually, j′ is split into two parts. One is allocated to one processor in S0, while the remaining part remains in S1. (iii) Let p0 and p1 denote the number of processors required by S0 and S1, respectively. Let q = m − (p0 + p1). If there is j ∈ S2 with tj(q) ≤ 3 2d, allocate j with p = γj(cid:0) 3 2d(cid:1) ≤ q processors to S0 if tj(p) > d and to S1 otherwise. The resulting schedule is indeed feasible. Lemma 8 ([22]). When none of the transformation rules are applicable, the schedule uses at most m processors. 11 Since the transformation rules do not increase the number of processors allot- ted to any job, the work does not increase. In particular, if the two-shelf-schedule has total work at most md − WS(d), then the resulting schedule also has total work at most md − WS(d). Note that any job's allotment changes twice only if it is moved from S2 to S1 by rule (iii) and then from S1 to S0 by rules (i) or (ii). Therefore, the transformations can be exhaustively applied to a two-shelf-schedule in time O(n log n): Scan the shelf S1 and classify each job into one of three categories 4 d and γj(d) > 1, 4 d and γj(d) = 1, and • tj(γj(d)) ≤ 3 • tj(γj(d)) ≤ 3 • tj(γj(d)) > 3 4d. Jobs of the first category can immediately be moved to S0 according to rule (i). Jobs of the second category are stored and moved to S0 in pairs as described in rule (ii). This may leave one unpaired job an the end. Jobs of the third category are stored in a min-heap with the processing time tj(γj(d)) as key. This heap can be used to pair unpaired jobs from the second category in accordance to the special case of rule (ii). Scanning shelf S1 in this fashion can be done in time O(n log n). Afterwards, we process shelf S2 and check if rule (iii) applies. If it does, and the job should be moved to S1, we immediately categorize it and apply rules (i) and (ii) to it. This requires time O(log n) per job in S2. We also need to compute some of the values γj(d), γj(cid:0) d resulting in an overall running time of O(n(log n + log m)). 2(cid:1), and γj(cid:0) 3 2d(cid:1) for each job j ∈ JB(d), Re-adding the Small Jobs We modify the schedule such that the free time on each processor is adjacent: jobs in S0 and S1 start as early as possible, while the jobs in S2 finish at time 3 2 d. We now allocate the small jobs to the free time intervals with a next-fit approach3. The small jobs are processed in an arbitrary order. The current job j gets assigned to the next machine with load at most 3 2d − tj(1). Lemma 9. Using a next-fit algorithm, all small jobs can be integrated into a three-shelf-schedule, provided its total work is at most md − WS(d). Proof. Assume for the sake of contradiction that a small job cannot be added. Then all machines were discarded for not fitting some job, i.e. their load is larger than 3 2, those machines load was larger than 3 2d = d. Thus the total load of all machines is larger than md, a contradiction. 2d − tj(1) for a small job j. Since j is small, i.e. tj(1) ≤ d 2d − 1 3in the work of Mounié, Rapine, and Trystram [22], a different allocation rule is used, but the proof is similar. 12 This can be implemented to run in linear time. We first group adjacent processors that have the same amount of free time. Since the amount of free time only changes when a different job is scheduled on a processor, there can be at most O(n) many groups. The groups are processed in arbitrary order. If the free time of a group is at least tj(1), where j is the current job, the group is split into two groups, the first containing one processor, and the second containing the other processors. The current job is then added to the processor in the first group, and its free is updated. Otherwise the whole group is discarded. This is possible in time linear in the number of small jobs and groups, achieving an overall running time of O(n). 4.2 Knapsack with Compressible Items The dominating part of the algorithm is the solution of the knapsack problem. One might be tempted to use one of the known FPTASs for the knapsack problem to find a solution with slightly suboptimal profit. However, the profit of the knapsack problem can be much larger than the work of the schedule, such that a small decrease of the profit can increase the work of the schedule by a much larger factor. Instead, we treat the processor counts approximately, despite the fact that the the available number of processors imposes a hard constraint. We will employ compression to compensate for an increased processor usage of the solution. For a cleaner notation, we define the knapsack problem with compressible items: an instance of this problem is a tuple (I, I c, C, ρ), where I is a set of items. An item i ∈ I has size s(i) and profit p(i). The items I c ⊆ I can be compressed with factor ρ, and C denotes the capacity. A feasible solution to this instance is a set I ′ ⊆ I such that Xi∈I ′∩I c (1 − ρ) s(i) + Xi∈I ′\I c s(i) ≤ C. (9) We denote the maximum profit of the instance by OPT(I, I c, C, ρ). 4.2.1 Simple Application to the Scheduling Problem 1 Identifying the jobs as items is straightforward: Let J C = {j ∈ JB(d) γj(d) ≥ ρ} be the compressible jobs, where the compression factor ρ will be defined later depending on the desired accuracy ε. Set the knapsack sizes as s(j) = γj(d) and the profits as p(j) = vj(d) for j ∈ JB(d). If we have a solution J ′ to the knapsack problem (JB(d), J C, m, ρ), we can compress the jobs in J ′ ∩ J C such that J ′ fits on m processors. Their processing time increases by a factor of at most (1 + 4ρ), so J ′ is a feasible solution to KP(JB(d), m, (1 + 4ρ)d). To make up for the increased makespan, we use the following corollary to Lemma 7 with d′ = (1 + 4ρ)d. 13 Corollary 10. Let d′ ≥ d, and J ′ ⊆ JB(d) be a feasible solution of the knap- sack problem KP(JB(d), m, d′) with W (J ′, d) ≤ md′ − WS(d). Then we can, in time O(n log n), find a schedule with makespan at most 3 2d′. Proof. Let J ′′ = J ′ ∩ JB(d′). Then J ′′ is a feasible solution of KP(JB(d′), m, d′). Define ∆W = WS(d′) − WS(d). Note that, when targeting makespan 3 2d′, each job in J ′ \ J ′′ will be scheduled on one processor in shelf 1 and shelf 2, since these are exactly the jobs that have tj(1) ≤ d′ 2 . Therefore, they can be moved between shelves without affecting the work of the schedule, implying W (J ′′, d′) = W (J ′, d′). Using also the fact that the work functions are monotone, we obtain W (J ′′, d′) = W (J ′, d′) =Xj∈J ′ ≤Xj∈J ′ =Xj∈J ′ wj(γj(d′)) +Xj∈JB(d′)\J ′ wj(γj(d)) +Xj∈JB(d′)\J ′ wj(γj(d)) +Xj∈JB(d)\J ′ wj(cid:0)γj(cid:0) d′ 2(cid:1)(cid:1) wj(cid:0)γj(cid:0) d 2(cid:1)(cid:1) wj(cid:0)γj(cid:0) d 2(cid:1)(cid:1) −Xj∈JB(d)\JB (d′) wj(cid:0)γj(cid:0) d 2(cid:1)(cid:1) = W (J ′, d) − ∆W ≤ md′ − WS(d) − ∆W = md′ − WS(d′). (10) Applying Lemma 7 to J ′′ yields the desired schedule. To obtain a (cid:0) 3 6ε. Concerning the prerequisites of Corollary 10, it is sufficient if the profit of J ′ is at least OPT(I,∅, C, 0) = OPTKP(JB(d), m, d), because then W (J ′, d) ≤ md − WS(d), unless no schedule with makespan d exists. 2 + ε(cid:1)-dual approximate algorithm, we set ρ = 1 Algorithm 1: Scheduling of monotone moldable jobs using knapsack with compressible items Input: J, m, d, ε 1 ρ ← 1 6 ε, d′ ← (1 + 4ρ)d, J C ← {j ∈ JB(d) γj(d) ≥ 1 ρ} 2 for j ∈ JB(d) do 2(cid:1), γj(d′), γj(cid:0) 3 Precompute γj(cid:0) d 2 d′(cid:1) 4 Find solution J ′ to (JB(d), J C, m, ρ) 5 Apply Lemma 7 to J ′ ∩ JB(d′), obtain schedule for jobs J with makespan 6 if schedule is infeasible then reject d 7 else return the schedule 2(cid:1), γj(d), γj(cid:0) d′ 3 3 2d′ 14 Note that the algorithm schedules the jobs with γj(d′) processors. Compres- sion was only used to show that shelf 1 has at most m processors with these processor counts. How one can find a solution to is discussed in the rest of this section. 4.2.2 Separating Compressible and Incompressible Items Let I = I1 ∪ I2 be a partition of the items. Consider an optimal solution I ∗ ⊆ I to the knapsack problem (I, I c, C, ρ), let α ≥Pi∈I ∗∩I1 s(i) be the space available for items in I1 in the solution, and β ≥ Pi∈I ∗∩I2 s(i) the space available for the other items. Then we can solve the knapsack problems for I1 and I2 separately. Lemma 11. OPT(I, I c, C, ρ) ≤ OPT(I1, I c ∩ I1, α, ρ) + OPT(I2, I c ∩ I2, β, ρ), and equality holds if α + β = C. 1 ⊆ I1 and I ∗ 2 ⊆ I2 be optimal solutions of (I1, I c ∩ I1, α, ρ) and Proof. Let I ∗ (I2, I c ∩ I2, β, ρ), respectively. Assume for the sake of contradiction that OPT(I, I c, C, ρ) > OPT(I1, I c ∩ I1, α, ρ) + OPT(I2, I c ∩ I2, β, ρ). (11) (12) Recall that I ∗ is our optimal solution to (I, I c, C, ρ). Then Xi∈I ∗∩I1 p(i) p(i) + Xi∈I ∗∩I2 =Xi∈I ∗ > OPT(I1, I c ∩ I1, α, ρ) + OPT(I2, I c ∩ I2, β, ρ), vj(d) = OPT(I, I c, C, ρ) therefore we either havePi∈I ∗∩I1 α, or Pi∈I ∗∩I2 the optimality of I ∗ If α + β = C, then the set I ∗ p(i) > OPT(I2, I c ∩ I2, β, ρ) and Pi∈I ∗∩I2 p(i) > OPT(I1, I c ∩ I1, α, ρ) andPi∈I ∗∩I1 1 ∪ I ∗ s(i) ≤ s(i) ≤ β, contradicting 1 is a feasible solution of (I, I c, C, ρ), hence 1 and I ∗ 2 . OPT(I, I c, C, ρ) ≥ OPT(I1, I c ∩ I1, α, ρ) + OPT(I2, I c ∩ I2, β, ρ) (13) and equality must hold. In our case, we partition I = I c ∪ (I \ I c), i.e. α is the space available for compressible items. To utilize this lemma, we need to know values for α and β. Let βmax be an upper bound on the space used by incompressible jobs. We can enumerate all βmax + 1 possible values of β ≤ βmax, set α = C − β, and pick the best obtained solution. A standard dynamic programming algorithm can be used to solve the instances (I \ I c,∅, β, 0) in time O(nβmax) each. While the problem for the compressible items could be solved the same way, we are looking for an algorithm that is polynomial in log C. We propose several 15 techniques, exploiting the compressibility of the items. First, we treat the size of compressible items approximately. Second, we further bound the number of knapsack problems to solve by O( log C ρ ) by using an approximate, possibly larger value for α. We also solve all knapsack problems in one pass. 4.2.3 Solving the Knapsack Problem for Compressible Items One way to implement the dynamic program for solving the knapsack prob- lem exactly is given by Lawler [17]: assume there are nC ≤ n compressible items i1, . . . , inC , and the capacity is α. A list L of pairs (p, s) is initialized with the single pair (0, 0). In the k-th iteration, for each pair (p, s) in L, a new pair (p + p(ik), s + s(ik)) is added to L, unless s + s(ik) > α. Thus, at the end of the k-th iteration, a pair (p, s) indicates that p is the highest profit that can be obtained with the items i1, . . . , ik and total size at most s. A pair (p, s) is said to dominate (p′, s′) if p ≥ p′ and s ≤ s′. After each modification, we remove dominated pairs from the list. The optimum value then is max{p (p, w) ∈ L}. By storing additional backtracking information, an optimal solution can be found in time O(nCα) = O(nCm). Let ¯n be an upper bound to the number of compressible items in any solution. In our scheduling setting, such a bound is imposed by the fact that wide jobs are compressible. A common approach is to round the sizes s(i) and the capacity α down to the next multiple of U = ρ (1−ρ)¯n α, such that all sizes in pairs stored in L are multiples of U. This can be equivalently achieved as follows: cover the range 0, . . . , α with disjoint intervals of length U, i.e. [0, α] ⊆ [0, U) ∪ [U, 2U) ∪ [2U, 3U) ∪ . . . . This requires ⌈ α U ⌉ = O(¯n) intervals. On creation, the pairs (p, s) are normalized such that s ∈ [ℓU, (ℓ + 1)U) implies s = ℓU, i.e. the value of s is reduced by at most U such that it is a multiple of U. The profit of an optimal solution to the rounded instance can be calculated as max{p (p, s) ∈ L}. Since the actual width of the items does not decrease, the solution may be up to ¯nU units larger than the capacity, but is small enough when we take into account that all items are compressible: (1 − ρ) × (α + ¯nU) = (1 − ρ) ×(cid:18)1 + ρ (1 − ρ)(cid:19)α = α. (14) The required running time of the algorithm is O(nC ¯n). 4.2.4 Solving the Knapsack Problems in One Pass We first demonstrate how to solve the knapsack problems (I\I c,∅, β, 0) for each β in some set B in one pass. For this we modify the dynamic programming approach by Lawler outlined in Section 4.2.3 to solve the knapsack problem for several capacities. Similar to the original algorithm, we build the list L of pairs (p, s), but up to the largest capacity max B. This requires time O(nI max B), where 16 0 U1 U2 U3 α0 I (1) α1 I (2) α2 I (3) α3 I (3) 6 I (3) 7 I (3) 8 U1 U2 U3 Figure 4: Example of the interval structure used for the normalization. Here, ℓ(i) min = 6 and ℓ(i) max = 8. The top line shows the partitioning into intervals. On the intermediate lines the partitioning from Section 4.2.3 for a maximum capacity of αi is shown for each i. The highlighted parts are merged for the final partition, displayed on the bottom line. nI = n− nC is the number of incompressible items. A pair (p, s) in the list means that p is the best obtainable profit with capacity s. For each β ∈ B we now find the largest s ≤ β such that a pair (p, s) is in the list. Then p is the optimal profit for capacity β. Thus all knapsack problems can be solved in time O(nI max B). For compressible items, we additionally use the normalization technique from Section 4.2.3. Let αmin > 0 be a lower bound any non-zero α, e.g. the minimum size of a compressible item. When solving a knapsack problem for several capac- ities, we cannot normalize all sizes in the same way. Instead, we use adaptive normalization. The idea is illustrated in Fig. 4. To bound the running time, we also need to impose a requirement on the set of capacities. Lemma 12. Let A = {α1 < · · · < αk} be a set of k capacities such that for each i ∈ {1, . . . , k} we have (15) αi − αi−1 ≤ ραi, ℓ = [ℓUi, (ℓ+1)Ui)∩I (i) for ℓ ∈ {ℓ(i) where α0 = αmin. Then all knapsack problems (I c, I c, α, ρ) with α ∈ A can be solved with profit at least OPT(I c,∅, α, 0) in time O(nC ¯nA). Proof. Partition the interval [αmin, αk] into intervals I (1), . . . , I (k). For this, de- fine I (i) = [αi−1, αi) for each i ∈ {1, . . . , k}. Further partition each interval I (i) into subintervals, similar as in Section 4.2.3: for i ∈ {1, . . . , k} set Ui = ρ (1−ρ)¯n αi, and let I (i) min = ⌊ αi−1 Ui ⌋ and ℓ(i) are the subintervals that start respectively end at αi−1 and αi. See Fig. 4 for a visualization of the interval structure. We again use a dynamic program to calculate the list L of pairs (p, s), and normal- ize the widths such that s ∈ I (i) ℓ = max(ℓUi, αi−1). Then we can, for each i ∈ {1, . . . , k}, compute the profit of a solution to (I c, I c, αi, ρ) (p, s) ∈ L and s ≤ αi}: Since U1 ≤ · · · ≤ Uk, the subintervals in as max{p [0, αi] have width at most Ui. Therefore, the width of a solution for a capacity in max}. We choose ℓ(i) implies s = min I (i) min, . . . , ℓ(i) max = ⌊ αi Ui⌋. Then I (i) (i) min ℓ ℓ and I (i) (i) max ℓ 17 this range is underestimated by at most ¯nUi, which the compression compensates for, see also Eq. (14). To determine the running time, we need to count the number of subinter- min + 1 many subintervals. max − ℓ(i) vals. For i ∈ {1, . . . , k}, the interval I (i) has ℓ(i) Therefore, Ui(cid:23) −(cid:22) αi−1 Ui (cid:23) Ui − 1(cid:19) Ui −(cid:18)αi−1 (αi − αi−1)(1 − ρ) min =(cid:22) αi max − ℓ(i) ℓ(i) ≤ αi ¯n + 1 (16) ≤ ραi ραi(1 − ρ) ≤ = O(¯n). ραi ¯n + 1 = (1 − ρ)¯n + 1 In total, we have O(¯nA) many intervals. The dynamic program therefore has running time O(nC ¯nA). 4.2.5 Reducing the Number of Knapsack Problems We propose to approximate the space α available for compressible items with a value α ≥ α, and use half of the compressibility for this. Assume that α > 0, the case α = 0 will be handled separately. The uncompressed items in a solution 1−ρ. Compressed with factor ρ′ = 2ρ − ρ2, they of (I c, I c, α, ρ) have size at most have a size of at most 1−2ρ+ρ2 α = (1 − ρ) α. We therefore require α to satisfy 1−ρ α α ≤ α ≤ 1 1 − ρ α, and will construct a set of such values by using a geometric progression. Definition 13. For any positive reals L, U, and x > 1 we define geom(L, U, x) = {Lxi i ∈ 0, . . . ,⌈logx U L⌉}. (17) (18) Lemma 14. For any L ≤ U, and 1 < x < 2 we have geom(L, U, x) = O( 1 x−1 log U L ). Proof. Define y = x − 1 > 0 and imax =$2 log U L y % + 1. (19) We claim that Lximax > U, or equivalently, (1 + y)imax > U L . 18 Since x < 2 implies y < 1, we have imax > 2 log U L y ≥ log U L y 1+y . (20) Now consider that y 1+y ≤ log(1 + y) for y ≥ 0: It holds for y = 0, and we have d dy (1 + y)2 ≤ log(1 + y) d dy 1 + y 1 + y = 1 (21) y = 1 for y ≥ 0. Therefore imax > log U L 1+y ≥ y log U L log(1 + y) = log1+y U L , (22) which proves the claim. Hence geom(L, U, x) has cardinality at most imax = O( 1 y log U L ). Recall that αmin is a lower bound on any α > 0. Let A = geom(αmin 1 1−ρ ), then A contains an α with property (17) for each α ∈ {αmin, . . . , C}. Further- more, Lemma 14 yields A = O( 1 Putting everything together, we obtain Algorithm 2, a fully polynomial algo- ρ log C αmin 1 1−ρ, C, ). rithm for the knapsack problem with compressible items. Algorithm 2: Solve knapsack with compressible items 1 1 1−ρ, C, 1−ρ), A0 ← A ∪ {0} Input: I, I c, C, ρ, αmin, βmax, ¯n 1 αmin ← max(αmin, C − βmax) 2 A ← geom(αmin 3 for α ∈ A do β( α) ← C − (1 − ρ) α 4 β(0) ← βmax, B ← {β( α) α ∈ A0} 5 Solve (I \ I c,∅, β, 0) for β ∈ B 6 Solve (I c, I c, α, ρ) for α ∈ A0, solution for α = 0 is ∅ 7 for α ∈ A0 do 8 Combine solutions for (I \ I c,∅, β( α), 0) and (I c, I c, α, ρ) 9 return the best combined solution Theorem 15. Algorithm 2 finds a solution to the instance (I, I c, C, ρ′) with profit at least OPT(I,∅, C, 0) in time O(nIβmax + nC ¯n 1 Proof. First note that the choice of B is reasonable, since α ≤ 1 1−ρC for α ∈ A, implying β( α) = C − (1 − ρ) α ≥ 0. We now show that each combined solution is a feasible solution for (I, I c, C, ρ′). Let I ′ ⊆ I be a solution created in line 2 for some fixed α. Then s(I ′ ∩ I c) ≤ 1 1−ρ α and s(I ′ \ I c) ≤ β( α) = C − (1 − ρ) α. Compressing items from I c with factor ρ′ leads to a total size of at most ρ′ log C αmin ). (1 − 2ρ + ρ2) 1 1 − ρ α + C − (1 − ρ) α = C. (23) 19 For the profit, consider an optimal solution I ∗ of (I,∅, C, 0). Now define α = Pi∈I ∗∩I c s(i) and β = Pi∈I ∗\I c s(i). We claim that there is an α ∈ A0 such that α ≥ α and β( α) ≥ β. Recall that we enforced αmin ≥ C − βmax in line 2, but this is not a restriction, since there always must be C − βmax space available for compressible jobs. If α = 0, α = 0 clearly satisfies the claim. If 0 < α < αmin, then α = min A = 1 1−ρ αmin is larger than α, and since there is αmin space available for compressible jobs, β( α) = C − αmin space must suffice for the incompressible jobs. Otherwise we have α ≥ αmin, so there is one α ∈ A which satisfies Eq. (17). Furthermore, β( α) = C − (1 − ρ) α ≥ C − α ≥ β. According to Theorem 12, the profit of the found solution is at least OPT(I c,∅, α, 0) + OPT(I \ I c,∅, β( α), 0). Lemma 11 now proves that the profit is at least OPT(I,∅, C, 0). Regarding the running time, the definition of A clearly satisfies Eq. (15). Therefore, we can apply the methods described in Section 4.2.4 for lines 2 and 2. Because we ensured αmin ≥ C − βmax and α ≥ 1 1−ρ αmin for each α ∈ A, β( α) = C − (1 − ρ) α ≤ C − αmin ≤ βmax. Therefore, max B ≤ βmax and line 2 re- quires time O(nβmax). Line 2 requires time O(n¯n 1 ). These steps clearly dominate the running time of the algorithm, and ρ = Θ(ρ′). ρ log C αmin Now that we have an efficient means to solve the knapsack problem with compressible items, we can create a simple fully polynomial algorithm based on Algorithm 1. To use Algorithm 2, we need to provide good bounds on αmin, βmax and ¯n. Therefore, we only use Algorithm 1 if m < 16n. Otherwise, if m ≥ 16n, we can use our FPTAS with ε = 1 2d. Then choose αmin = 1 ρ, βmax = m = O(n), and ¯n = mρ = O(εn). Solving the knapsack problem thus requires O(n2 log εm) operations. Using the PTAS or precomputing the required values of γj requires O(n log m) time. Finding the schedule in line 1 requires O(n log n) time using Lemma 7. The dual algorithm has running time O(n(log m + n log εm)) in total. 2 to obtain a schedule with makespan 3 4.3 The Improved Algorithm In the bounded knapsack problem, the input defines k item types with sizes and profits, and an item count ct for each item type t ∈ [k]. The number of items can be much larger than the number of item types. An instance of the bounded knapsack instance with k item types and capacity C can be transformed into an instance of the regular knapsack problem with O(log m) items per type [16]. Each of these items serves as a container for an integer number of items of the same type. To further speed up the solution of the knapsack problem (JB(d), J C, m, ρ), we transform it into a bounded knapsack problem. Beforehand, we reduce the number of item types by rounding the jobs. But first, we define the threshold b for compressible jobs. We also introduce an accuracy parameter δ, which we later choose depending on ε. 20 Lemma 16. Let δ ∈ (0, 1], ρ = 1 2ρ−ρ2 . Any job that uses at least b processors can be compressed with factor 2ρ − ρ2, decreasing its processor count by a factor (1− ρ)2 and increasing its processing time by a factor of less than 1 + δ. Furthermore we have ρ = Θ(δ) and b = Θ( 1 4(√1 + δ − 1), and b = 1 δ ). Proof. Since δ ≤ 5 4, so 2ρ − ρ2 is a valid compression factor. Compression reduces the processor count by a factor (1− 2ρ + ρ2 = (1− ρ)2. The processing time increases by a factor of 4 we have 2ρ ≤ 1 1 + 4(2ρ − ρ2) = 1 + 8ρ − 4ρ2 < (1 + 4ρ)2 = 1 + δ. (24) The identity (1 + 4ρ)2 = 1 + δ implies ρ = since √1 + δ ≤ 1 + δ we have ρ ≤ 1 ρ) = Θ( 1 Finally, b = 1 2ρ−ρ2 = Θ( 1 2ρ. δ 8(1+2ρ) ≥ δ 12 , since ρ ≤ 1 4. Also, 4 δ, hence ρ = Θ(δ). δ ), because 0 < ρ2 ≤ 1 4 ρ, so 7 4ρ ≤ 2ρ − ρ2 < To define rounded sizes and profits for the items (jobs in JB(d)), we introduce a notation to round values geometrically; gr(a, L, U, x) = max{a′ ∈ geom(L, U, x) a′ ≤ a} for rounding down, and gr analogously for rounding up. For s ∈ { d 2, d}, round the processor counts down γj(s) =(γj(s) gr(γj(s), b, m, 1 + ρ) if γj(s) ≤ b otherwise and let s(j) = γj(d). If γj( d 2 ) < b, round the original profit vj(d) to p(j) =(0 gr(vj(d), δ 2 d, b 2d, 1 + δ b ) if vj(d) < δ 2 d otherwise. (25) (26) Otherwise, when γj( d tj(s) = gr(tj(γj(s)), s the rounded values, i.e. p(j) = tj( d 2) ≥ b, we consider rounded processing times for s ∈ { d 2, d}, 2, s, 1 + 4ρ) and set the profit as the saved work according to 2)γj( d 2) − tj(d)γj(d). 4.3.1 Bounding the Number of Item Types In the first step, we round the processor counts γj(d) and γj(cid:0) d than b are rounded down to the next value from geom(b, m, 1 + ρ). According to Lemma 14, this leaves us with O( log(δm) 2(cid:1). Counts larger ) many different counts. δ First, consider the types of compressible jobs, i.e. jobs that have processor count γj(d) ≥ b. Lemma 17. If we round the processing times tj(γj(s)), where s = d or s = d 2, down to the next value in geom( s δ ) many different rounded processing times (heights). 2, s, 1 + 4ρ) then there are at most O( 1 21 Proof. Consider that the height of each job is more than half of the shelf height s: Assume job j has tj(γj(s)) ≤ s 2 for the sake of contradiction. Then γj(s) > 1, otherwise it would be a small job, which we removed. We claim that reducing the processor count by 1 at most doubles the processing time, because we at most halve the processor count. More formally, we have γj(s) ≤ 2(γj(s) − 1), because γj(s) ≥ 2, and (27) (28) (γj(s) − 1) tj(γj(s) − 1) = wj(γj(s) − 1) ≤ wj(γj(s)) = γj(s) tj(γj(s)) due to monotony. Therefore tj(γj(s) − 1) ≤ γj(s) γj(s) − 1 tj(γj(s)) ≤ 2 tj(γj(s)). It follows that tj(γj(s) − 1) ≤ s, a contradiction to the definition of γj(s). The distance between two rounded processing times then must be at least s 2 × 4ρ, thus there are at most 1 4ρ rounded processing times between s 2 and s. In the case of compressible jobs, the rounding step can be simplified: Lemma 18. Compressible jobs must have one of the two largest rounded process- ing times. Proof. Let s be again the shelf height, and j be a job that is wide in the shelf, i.e. γj(s) ≥ b. Assume tj(γj(s)) ≤ 1 1+4ρ s. Then tj(⌊(1 − ρ) γj(s)⌋) ≤ s by Lemma 4, contradicting the definition of γj(s). Therefore, tj(γj(s)) > 1 1+4ρ s. Since geom( s 1+4ρs, s], tj(γj(s)) is either rounded down to that value, or the one below. 2 , s, 1 + 4ρ) contains at most one value in the interval ( 1 Jobs that are wide in shelf S1 must also be wide in shelf S2, so there are ) different processor counts and two processing times each for shelf S1 and δ2 log2(δm)) types O( log(δm) shelf S2 to consider. This leaves us with no more than kC = O( 1 of compressible items. δ Now consider the types of incompressible jobs. These jobs have b − 1 = O( 1 δ ) many different processor counts in shelf S1. They can be narrow or wide in shelf S2. If a job is wide in shelf S2, we round the processing times according to Lemma 17. Then there are O( 1 δ ) many different processing times in shelf S1, and O( log(δm) ) different processor counts, but only two processing times possible in shelf S2. Therefore, there are at most k = O( 1 δ3 log(δm)) item types for such jobs. δ If a job is narrow in shelf S2, we directly rounded the profit down to 0 or up δ ) many b ). This leaves us with O( 1 δ2 log 1 to the next value in geom( δ δ3 log 1 different profits, or O( 1 2d, 1 + δ 2d, b δ ) item types. In total, there are at most kI = O( 1 δ3 (log 1 δ + log(δm)) = O( 1 δ3 log m) types of incompressible items. 22 4.3.2 Putting it Together Our algorithm, Algorithm 3 is very similar to Algorithm 1. The main difference is how we solve the knapsack instance in line 3. We interpret it as an instance Algorithm 3: Scheduling of monotone moldable jobs using bounded knap- sack with compressible items Input: J, m, d, ε 1 δ ← 1 5ε, ρ ← 1 4(√1 + δ − 1), b ← 1 J C ← {j ∈ JB(d) γj(d) ≥ 1 ρ} 2 for j ∈ JB(d) do 2(cid:1), γj(d), γj(cid:0) d′ Precompute γj(cid:0) d 3 2ρ−ρ2 , d′ ← (1 + δ)2d, 2(cid:1), γj(d′), γj(cid:0) 3 2 d′(cid:1), s(j), p(j) 3 4 Find solution J ′ to (JB(d), J C, m, ρ) via bounded knapsack 5 Apply Lemma 7 to J ′ ∩ JB(d′), obtain schedule for jobs J with makespan 6 if schedule is infeasible then reject d 7 else return the schedule 2d′ of the bounded knapsack problem, transform it into a regular knapsack instance (I, IC, m, ρ) with O(kC log m) compressible and O(kI log m) incompressible items, and solve it using Algorithm 2. We proceed to replace the container items in the solution with the appropriate number of items (jobs) from the corresponding type. Note that we used only part of the compressibility for the solution of the knapsack problem in line 3. The rest is required to compensate for the rounding of the processor counts. Lemma 19. When the original processor counts and processing times are consid- ered, J ′ is a solution of the knapsack problem KP(JB(d), m, d′), and, unless there is no schedule with makespan d, W (J ′, d′) ≤ md′ − WS(d). Proof. We have to carefully consider the implications of our rounding of the jobs on J ′. We underestimated the processor count (size) of wide jobs by a factor of at most 1 − ρ. The total size of all selected containers does not exceed m when the size of containers for wide jobs is multiplied by a factor of 1− ρ. According to Lemma 16, one compression with factor 2ρ− ρ2 reduces the processor count by a factor of (1− ρ)2, and increases the processing time by a factor of less than 1 + δ. The jobs then fit into m machines. Even before the rounding, the processing time was at most d, so after the compression they have processing time less than (1 + δ)d < d′, so J ′ is a solution to KP(JB(d), m, d′). We further have to bound the work W (J ′, d′), assuming there is a sched- ule with makespan d. By Lemma 6 there is a two-shelf-schedule with work at most md − WS(d). This must also be true when the rounded processor counts and processing times are considered. But our solution to the knapsack problem may not be optimal, since we mod- ified the profits of the items corresponding jobs that are narrow in both shelves. 23 Because a solution can contain at most m jobs, omitting jobs with profit below δ reduces the profit by at most δ lead us to overestimate the profit of the solution by at most mb d 2 each of the at most m items has original profit at most b d by a factor of at most 1 + δ of our schedule with rounding may be up to md − WS(d) + δmd. 2d 2md. Rounding the profits of the other items up 2md, since 2 , which we increased b . Since the profit equates to the saved work, the work Undoing the rounding can also increase the work of our schedule, namely by a factor of 1 + 4ρ for the rounding of the processing times, and a factor of 1 + ρ for the rounding of the processor counts. So with the original, unrounded numbers we must have b = δ δ W (J ′, d′) ≤ (md − WS(d) + δmd)(1 + 4ρ)(1 + ρ) ≤ (m(1 + δ)d − WS(d))(1 + 4ρ)2 ≤ md(1 + δ)(1 + 4ρ)2 − WS(d) ≤ md′ − WS(d). (29) According to Corollary 10, Algorithm 3 yields a schedule with makespan 3 2d′ ≤ ( 3 2 + ε)d. The running time of line 3 includes the transformations of the instances and the solution, which can be done in O(n+kI +kC). For the solution of the knapsack instance itself, Theorem 15 states that time O(nIβmax+nC ¯n 1 ) is required, where nI = O(kI log m) and nC = O(kC log m). Using the same bounds αmin, βmax, and ¯n as before, the running time is O(n 1 this is the dominating step. ε + log3(εm)(cid:1)). Again, ε2 log m(cid:0) log m ρ′ log C αmin However, while the solution of the knapsack problem is now linear in the number n of jobs, applying the transformation rules (see Section 4.1.1). to create a feasible schedule still requires O(n log n) operations. The total running time thus is O(n 1 ε2 log m(cid:0) log m ε + log3(εm)(cid:1) + n log n). 4.3.3 Obtaining a Linear Algorithm The super-linear running time when applying the transformations stems from organizing the jobs in S1 in a heap. Instead of using the exact processing time tj(γj(d)), we can use the rounded processing time tj(d) we introduced in the last section. Then the jobs can be organized in O( 1 δ ) lists. The running time for the transformation rules then is O( n δ ). We could even organize the lists of jobs in a heap, resulting in a running time of O(n log 1 δ ). Since we underestimate the processing time of the jobs by at most δd, the 5ε will 2 + ε)-dual approximation algorithm. Since the other steps of the ε + makespan of the final schedule is at most ( 3 result in a ( 3 dual algorithm remain the same, the total running time is O(n 1 2 (1 + δ)2 + δ)d. Using δ = 1 ε2 log m(cid:0) log m 24 log3(εm)(cid:1)). Conclusion We have presented several techniques to exploit monotony of jobs, mostly based on the ability to compress wide jobs. For two different algorithms we demon- strated that these techniques can help to reduce the running time from polynomial in m to polynomial in log m. We also showed that arbitrarily good approximation guarantees can be achieved in polynomial time. On the negative side, we proved the NP-hardness of scheduling monotonic jobs. It remains open whether a better approximation guarantee than 3 2 can be achieved efficiently, e.g. in the form of an EPTAS. References [1] Krishna P. Belkhale and Prithviraj Banerjee. An approximate algorithm for the partitionable independent task scheduling problem. In Proceedings of the 1990 International Conference on Parallel Processing (ICPP 1990), pages 72–75. Pennsylvania State University Press, 1990. [2] Chandra Chekuri, Ashish Goel, Sanjeev Khanna, and Amit Kumar. Multi- processor scheduling to minimize flow time with ε resource augmentation. In Proceedings of the Thirty-sixth Annual ACM Symposium on Theory of Computing, STOC '04, pages 363–372, New York, NY, USA, 2004. ACM. [3] Maciej Drozdowski. On the complexity of multiprocessor task scheduling. In Bulletin of the Polish Academy of Sciences, Technical Sciences, volume 43, pages 381–392. 1995. [4] Jianzhong Du and Joseph Y.-T. Leung. Complexity of scheduling parallel task systems. SIAM Journal on Discrete Mathematics, 2:473–487, 1989. [5] M. R. Garey and R. L. Graham. Bounds for multiprocessor scheduling with resource constraints. SIAM Journal on Computing, 4:187–200, 1975. [6] Michael R. Garey and David S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. Series of Books in the Mathemat- ical Sciences. W. H. Freeman & Co., 1979. [7] Alexander Grigoriev and Marc Uetz. Scheduling parallel jobs with linear In Workshop on Approximation and Online Algorithms (WAOA speedup. 2006), pages 203–215. Springer, 2006. 25 [8] Dorit S. Hochbaum and David B. Shmoys. Using dual approximation algo- rithms for scheduling problems: Theoretical and practical results. Journal of the ACM, 34(1):144–162, 1987. [9] Klaus Jansen. A (3/2 + ε) approximation algorithm for scheduling moldable and non-moldable parallel tasks. In Proceedings of the 24th ACM Symposium on Parallelism in Algorithms and Architectures (SPAA 2012), pages 224–235. ACM Press, 2012. [10] Klaus Jansen, Felix Land, and Kati Land. Bounding the running time of algorithms for scheduling and packing problems. Technical Report 1302, Institute of Computer Science, University of Kiel, 2013. [11] Klaus Jansen, Felix Land, and Kati Land. Bounding the running time of algorithms for scheduling and packing problems. SIAM Journal on Discrete Mathematics, 30(1):343–366, 2016. [12] Klaus Jansen and Lorant Porkolab. Computing optimal preemptive sched- ules for parallel tasks: linear programming approaches. Mathematical Pro- gramming, 95(3):617–630, 2003. [13] Klaus Jansen and Lorant Porkolab. On preemptive resource constrained scheduling: Polynomial-time approximation schemes. SIAM Journal on Dis- crete Mathematics, 20:545–563, 2006. [14] Klaus Jansen and Ralf Thöle. Approximation algorithms for scheduling par- allel jobs. SIAM Journal on Computing, 39(8):3571–3615, 2010. [15] Klaus Jansen and Hu Zhang. Scheduling malleable tasks with precedence constraints. Journal of Computer and System Sciences, 78:245–259, 2012. [16] Hans Kellerer, Ulrich Pferschy, and David Pisinger. Knapsack Problems. Springer, 2004. [17] Eugene L. Lawler. Fast approximation algorithms for knapsack problems. Mathematics of Operations Research, 4(4):339–356, 1979. [18] Walter Ludwig and Prasoon Tiwari. Scheduling malleable and nonmalleable parallel tasks. In Proceedings of the Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 167–176. Society for Industrial and Applied Mathematics, 1994. [19] Konstantin Makarychev and Debmalya Panigrahi. Precedence-constrained scheduling of malleable jobs with preemption. In Automata, Languages, and Programming (ICALP 2014), volume 8572 of Lecture Notes in Computer Science, pages 823–834. Springer, 2014. 26 [20] Grégory Mounié, Christophe Rapine, and Denis Trystram. Efficient approxi- mation algorithms for scheduling malleable tasks. In Gary Miller and Vijaya Ramachandran, editors, Proceedings of the Eleventh annual ACM Sympo- sium on Parallel Algorithms and Architectures (SPAA 1999), pages 23–32. ACM, 1999. [21] Grégory Mounié, Christophe Rapine, and Denis Trystram. A 3 2-dual approx- imation algorithm for scheduling independent monotonic malleable tasks, 2004. [22] Grégory Mounié, Christophe Rapine, and Denis Trystram. A 3 2- approximation algorithm for scheduling independent monotonic malleable tasks. SIAM Journal on Computing, 37:401–412, 2007. [23] Peter Sanders and Jochen Speck. Efficient parallel scheduling of malleable tasks. In 2011 IEEE International Parallel & Distributed Processing Sym- posium (IPDPS), pages 1156–1166. IEEE Computer Society, 2011. [24] Denis Trystram, Mikhail Y. Kovalyov, Jacek Blazewicz, Maciej Machowiak, and Jan Weglarz. Preemptable malleable task scheduling problem. IEEE Transactions on Computers, 55:486–490, 2006. [25] John Turek, Joel L. Wolf, and Philip S. Yu. Approximate algorithms schedul- ing parallelizable tasks. In Proceedings of the fourth annual ACM symposium on Parallel algorithms and architectures (SPAA '92), pages 323–332. ACM Press, 1992. 27
1812.01343
1
1812
2018-12-04T11:28:36
Online scheduling of jobs with favorite machines
[ "cs.DS" ]
This work introduces a natural variant of the online machine scheduling problem on unrelated machines, which we refer to as the favorite machine model. In this model, each job has a minimum processing time on a certain set of machines, called favorite machines, and some longer processing times on other machines. This type of costs (processing times) arise quite naturally in many practical problems. In the online version, jobs arrive one by one and must be allocated irrevocably upon each arrival without knowing the future jobs. We consider online algorithms for allocating jobs in order to minimize the makespan. We obtain tight bounds on the competitive ratio of the greedy algorithm and characterize the optimal competitive ratio for the favorite machine model. Our bounds generalize the previous results of the greedy algorithm and the optimal algorithm for the unrelated machines and the identical machines. We also study a further restriction of the model, called the symmetric favorite machine model, where the machines are partitioned equally into two groups and each job has one of the groups as favorite machines. We obtain a 2.675-competitive algorithm for this case, and the best possible algorithm for the two machines case.
cs.DS
cs
Online scheduling of jobs with favorite machines Cong Chen1, Paolo Penna2, and Yinfeng Xu1,3 1School of Management, Xi'an Jiaotong University, Xi'an, China 2Department of Computer Science, ETH Zurich, Zurich, Switzerland 3The State Key Lab for Manufacturing Systems Engineering, Xi'an, China December 5, 2018 Abstract This work introduces a natural variant of the online machine scheduling problem on unrelated machines, which we refer to as the favorite machine model. In this model, each job has a minimum processing time on a certain set of machines, called favorite machines, and some longer processing times on other machines. This type of costs (processing times) arise quite naturally in many practical problems. In the online version, jobs arrive one by one and must be allocated irrevocably upon each arrival without knowing the future jobs. We consider online algorithms for allocating jobs in order to minimize the makespan. We obtain tight bounds on the competitive ratio of the greedy algorithm and char- acterize the optimal competitive ratio for the favorite machine model. Our bounds generalize the previous results of the greedy algorithm and the optimal algorithm for the unrelated machines and the identical machines. We also study a further restriction of the model, called the symmetric favorite machine model, where the machines are partitioned equally into two groups and each job has one of the groups as favorite machines. We obtain a 2.675-competitive algorithm for this case, and the best possible algorithm for the two machines case. 1 Introduction Online scheduling on the unrelated machines is a classical and well-studied problem. In this problem, there are n jobs that need to be processed by one of m different machines. The jobs arrive one by one and must be assigned to one machine upon their arrival, without knowing the future jobs. The time to process a job changes from machine to machine, and the goal is to allocate all jobs so as to minimize the makespan, that is, the maximum load over the 1 machines. The load of a machine is the sum of the processing times of the jobs allocated to that machine. Online algorithms are designed to solve the problems when the input is not known from the very beginning but released "piece-by-piece" as aforementioned. Since it is generally impossible to guarantee an optimal allocation, online algorithms are evaluated through the competitive ratio. An online algorithm whose competitive ratio is ρ ≥ 1 guarantees an allocation whose makespan is at most ρ times the optimal makespan. For scheduling on unrelated machines, online algorithms have a rather "bad" performance in terms of the competitive ratio. For example, the simple greedy algorithm has a competitive ratio of m, the number of machines; the best possible online algorithm achieves a competitive ratio of Θ(log m). However, some well-known restrictions (e.g., the identical machines and related machines) admit a much better performance, that is, a constant competitive ratio. In fact, many practical problems are neither as simple as the identical (or related) ma- chines cases, nor so complicated as the general unrelated machines. In a sense, practical problems are somewhat "intermediate" as the following examples suggest. Example 1 (Two types of jobs (Vakhania et al., 2014)). This restriction of unrelated ma- chines arises naturally when there are two types of products. For instance, consider the production of spare parts for cars. The manufacturer may decide to use the machines for the production of spare part 1 to produce spare part 2, and vice versa. The machine for spare part 1 (spare part 2, respectively) takes time p for part 1 (part 2, respectively), but it can also manage to produce part 2 (part 1, respectively) in time q > p. Example 2 (CPU-GPU cluster (Chen et al., 2014)). A graphics processing unit (GPU) has the ability to handle various tasks more efficiently than the central processing unit (CPU). These tasks include video processing, image analysis, and signal processing. Nevertheless, the CPU is still more suitable for a wide range of other tasks. A heterogeneous CPU-GPU system consists of a set M1 of GPU processors and a set M2 of CPU processors. The processing time of job j is pj1 on a GPU processor and pj2 on a CPU processor. Therefore, some jobs are more suitable for GPU and others for CPU. Inspired by these examples, we consider the general unrelated machines case by observing that each job in the system has a certain set of favorite machines which correspond to the shortest processing time for this particular job. In Example 1, the machines for spare parts 1 are the favorite machines for these parts (processing time p < q), and similarly for spare parts 2. In Example 2, we also have two type of machines (GPU and CPU) and some jobs (tasks) have GPUs as favorite machines and others have CPUs as favorite machines. 1.1 Our contributions and connections with prior work We study the online scheduling problem on what we call the favorite machine model. Denote the processing time of job j on machine i by pji and the minimum processing time of job j by pj = mini pji. Thus the set of favorite machines of job j is defined as Fj = {i pji = pj} and the favorite machine model is as follows: 2 (f -favorite machines) This model is simply the unrelated machine setting when every job j has at least f favorite machines (Fj ≥ f ). The processing time of job j on any favorite machine i ∈ Fj is pj, and on any non-favorite machine i /∈ Fj is an arbitrary value pji > pj. This model is motivated by several practical scheduling problems. Besides the two types of jobs/machines problems mentioned in Examples 1 and 2, the model also captures the features of some real life problems. For example, workers with different levels of proficiency for different jobs in manufacturing; tasks/data transfer cost in cloud computing and so on. It is worth noting that this model interpolates between the unrelated machines where possibly only one machine has minimal processing time for the job (f = 1) and the identical machines case (f = m). The f -favorite machines setting can also be seen as a "relaxed" version of restricted assignment problem where each job j can be allocated only to a subset Fj of machines: the restricted assignment problem is essentially the case where the processing time of a job on a non-favorite machine is always ∞. We obtain tight bounds on the Greedy algorithm1 and the well-known Assign-U algo- rithm (designed for unrelated machines by Aspnes et al. (1997)) for the f -favorite machines case, and show the optimality of the Assign-U algorithm by providing a matching lower bound. For the Greedy algorithm, the competitive ratio is m+f−1 , which generalizes the well-known bounds on the competitive ratio of Greedy for unrelated machines (f = 1) and identical machines (f = m), that is, m and 2 − 1 m, respectively. The Assign-U algorithm has the optimal competitive ratio Θ(log m f ), while it is Θ(log m) for unrelated machines. f Easier instances and the impact of "speed ratio". Note that whenever f = Θ(m), 2 , Greedy has a competitive ratio the competitive ratio is constant. In particular, for f = m of 3− 2 m. We consider the following restriction of the model above such that a finer analysis is possible. (symmetric m 2 -favorite machines) All machines are partitioned into two groups of equal size m 2 , and each job has favorite machines as exactly one of the two groups (therefore f = m 2 and m is even). Moreover, the processing time on non-favorite machines is s times that on favorite machines, where s ≥ 1 is the scaling factor (the "speed ratio" between favorite and non-favorite machines). 2 We show that the competitive ratio of Greedy is at most min{1 + (2− 2 s+1, 3− 2 s+1, s + (2− m} (< 3). A modified greedy algorithm, called GreedyFavorite, which assigns m) s each job greedily but only among its favorite machines, has a competitive ratio of 2− 1 s (< 3). As one can see, the Greedy is better than GreedyFavorite for smaller s, and GreedyFavorite is better for larger s. Thus we can combine the two algorithms to obtain a better algorithm (GGF) with a competitive ratio of at most min{2+ s2+s−2 s} (≤ 2.675). Indeed, we characterize the optimal competitive ratio for the two machines case. That is, m) s2 f + 1 1This algorithm assigns each job to a machine whose load after this job assignment is minimized. 3 , 2+ 1 s+1 for symmetric 1-favorite machines, we show that the GGF algorithm is min{1 + s2 competitive and there is a matching lower bound. s}- s+1 , 1 + 1 For this problem, our results show the impact of the speed ratio s on the competitive ratio. This is interesting because this problem generalizes the case of two related machines (Epstein et al., 2001), for which s is the speed ratio between the two machines. The two machines case has also been studied earlier from a game theoretic point of view and compared to the two related machines (Chen et al., 2017; Epstein, 2010). Relations with prior work. As mentioned above, the f -favorite machines is a special case of the unrelated machines and a general case of the identical machines. The symmetric 1-favorite machines is a generalization of the 2 related machines. Besides, there are several other "intermediate" problems that have connections with our models and results in the literature (see Figure 1 for an overview). Specifically, in the two types of machines case (Imreh, 2003; Chen et al., 2014), they have two sets of machines, M1 and M2, and the machines in each set are identical. Each job j has processing time pj1 for any machine in M1, and pj2 for any machine in M2. The so-called balanced case is the restriction in which the number of machines in the two sets are equal. Note that our m 2 -favorite machines is a generalization of the balanced case, because each job has either M1 or M2 as favorite machines, and thus f = M1 = M2 = m 2 -favorite machines case is the restriction of the balance case in which the processing time on non-favorite machines is s times that of favorite ones, i.e., either pj1 = s · pj2 or pj2 = s · pj1. 2 . The symmetric m 1.2 Related work The Greedy algorithm (also known as List algorithm) is a natural and simple algorithm, often with a provable good performance. Because of its simplicity, it is widely used in many scheduling problems. In some cases, however, better algorithms exist and Greedy is not optimal. Identical machines. For m identical machines, the Greedy algorithm has a competitive ratio exactly 2 − 1/m (Graham, 1966), and this is optimal for m = 2, 3 (Faigle et al., 1989). For arbitrary larger m, better online algorithms exist and the bound is still improving (Karger et al., 1996; Bartal et al., 1995; Albers, 1999). Till now the best-known upper bound is 1.9201 (Fleischer and Wahl, 2000) and the lower bound is 1.88 (Rudin III, 2001). Related machines (uniform processors). The competitive ratio of Greedy is (1 + 1.618 for two machines (m = 2), and it is at most 1 + are tight for m ≤ 6 (Cho and Sahni, 1980). 5)/2 ≈ √ 2m − 2/2 for m ≥ 3. The bounds √ When the number of machines m becomes larger, the Greedy algorithm is far from optimal, as its competitive ratio is Θ(log m) for arbitrary m (Aspnes et al., 1997). Aspnes et al. (1997) also devise the Assign-R algorithm with the first constant competitive ratio of 8 for related machines. The constant is improved to 5.828 by Berman et al. (2000). Some research focuses on the dependence of the competitive ratio on speed s when m is rather small. For the 2 related machines case, Greedy has a competitive ratio of 1 + 4 unrelated machines m, Θ(log m) (∗) f -favorite machines f ) (∗) , Θ(log m 1 + m−1 f m 2 -favorite machines 3 − 2 m, − two types of machines 1 + m−1 f (for f ≤ m 2 ), 3.85 balanced two types 3 − 2 m, 1 + √ 3 ≈ 2.732 min{1 + (2 − 2 2 -favorite symmetric m s+1, s + (2 − 2 m) s2 s+1, 3 − 2 m}, 2.675 m) s symmetric 1-favorite 1 + min{ s2 s+1, 1}, 1 + min{ s2 s+1, 1 s} (∗) 1 + min{ s two related machines 1 + min{ s s}, s+1, 1 s+1, 1 s} (∗) Figure 1: Comparison between prior problems and results (in red) and our problems and results (in blue). The two bounds below each problem are the competitive ratios for Greedy and best-known algorithm, respectively, and the "(∗)" mark represent the optimality of the best-known algorithm. Arrows go from a problem to a more general one, and therefore the upper bounds for the general problem apply to the special one as well. 5 s+1, 1 s} and there is a matching lower bound (Epstein et al., 2001). min{ s Unrelated machines. As to the unrelated machines, Aspnes et al. (1997) show that the competitive ratio of Greedy is rather large, namely m. In the same work, they present the algorithm Assign-U with a competitive ratio of O(log m). A matching lower bound is given by Azar et al. (1992) in the problem of online restricted assignment. Restricted assignment. The online restricted assignment problem is also known as online scheduling subject to arbitrary machine eligibility constraints. Azar et al. (1992) show that Greedy has a competitive ratio less than (cid:100)log2 m(cid:101) + 1, and there is a matching lower bound (cid:100)log2(m + 1)(cid:101). For other results of online scheduling with machine eligibility we refer the reader to the survey by Lee et al. (2013) and references therein. Two types of machines (CPU-GPU cluster, hybrid systems). Imreh (2003) proves that )-competitive for this case, where m1 and m2 (≤ m1) are the Greedy algorithm is (2 + m1−1 number of two sets of machines, respectively. In our terminology, f = m2 and m1 = m − f , f )-competitive for f ≤ m meaning that Greedy is (1 + m−1 2 . The same work also improves the bound to 4 − 2 with a modified Greedy algorithm. Chen et al. (2014) gives a 3.85- competitive algorithm for the problem, and a simple 3-competitive algorithm and a more 3 ≈ 2.732-competitive algorithm for the balanced case, that is, the case involved 1 + m1 = m2. Further models and results. Some work consider restrictions on the processing times in the offline version of scheduling problems. Specifically, Vakhania et al. (2014) consider the case of two processing times, where each processing time pji ∈ {q, p} for all i and j. Kedad- Sidhoum et al. (2018) consider the two types of machines (CPU-GPU cluster) problem, and Gehrke et al. (2018) consider a generalization, the few types of machines problem. Some work also study similar models in a game-theoretic setting (Lavi and Swamy, 2009; Auletta et al., 2015). Regarding online algorithms, several works consider restricted assignment with additional assumptions on the problem structure like hierarchical server topologies (Bar- Noy et al., 2001) (see also Crescenzi et al. (2007)). For other results of processing time restrictions, we refer the reader to the survey by Leung and Li (2008). Finally, the f -favorite machine model in our paper has been recently analyzed in a follow-up paper in the offline game-theoretic setting (Chen and Xu, 2018). m2 m1 √ 2 Model and preliminary definitions The favorite machines setting. There are m machines, M := {1, 2, . . . , m}, to process n jobs, J := {1, 2, . . . , n}. Denote the processing time of job j on machine i by pji, and the minimum processing time of job j by pj = mini∈M pji. We define the favorite machines of a job as the machines with the minimum processing time for the job. Let Fj ⊆ M be the set of favorite machines of job j. Assume that each job has at least f favorite machines, i.e., Fj ≥ f for j ∈ J . Thus, the processing time of job j on its favorite machines equals to the minimum processing time pj (i.e., pji = pj for i ∈ Fj), while the processing time on its non-favorite machines can be any value that greater than pj (i.e., pji > pj for i /∈ Fj). 6 The symmetric favorite machines setting. This setting is the following restriction of the favorite machines. There are m = 2f machines partitioned into two subsets of f machines each, that is, M = M1 ∪ M2, where M1 = {1, 2, . . . , f} and M2 = {f + 1, f + 2, . . . , 2f}. Each job j has either M1 or M2 as its favorite machines, i.e., Fj ∈ {M1, M2}. The processing time of job j is pj on its favorite machines and s · pj on non-favorite machines, where s ≥ 1. Further notation. We say that job j is a good job if it is allocated to one of its favorite machines, and it is a bad job otherwise. Let li(j) denote the load on machine i after jobs 1 through j are allocated by online (cid:40) algorithm: li(j) = li(j − 1) + pji , li(j − 1) , if job j is assigned to machine i , otherwise. In the analysis, we shall sometimes considered the machines in non-increasing order of their loads. For a sequence jobs, we denote by (cid:96)i(j) the ith highest load over all machines after the first j jobs are allocated, i.e., (cid:96)1(j) ≥ (cid:96)2(j) ≥ ··· ≥ (cid:96)m(j) , for any j ∈ J . The jobs arrive one by one (over a list) and must be allocated irrevocably upon each arrival without knowing the future jobs. the goal is to minimize the makespan, the maxi- mum load over all machines. The competitive ratio of an algorithm A is defined as ρA := CA(I) Copt(I) , where I is taken over all possible sequences of jobs, CA(I) is the cost (makespan) supI of algorithm A on sequence I, and Copt(I) is the optimal cost on the same sequence. We write CA and Copt for simplicity whenever the job sequence is clear from the context. 3 The favorite machine model In this section, we first analyze the performance of the Greedy algorithm and show its competitive ratio is precisely m+f−1 . We then show that no online algorithm can be better f ) and that algorithm Assign-U (Aspnes et al., 1997) has an optimal competitive than Ω(log m ratio of O(log m f f ) for our problem. 3.1 Greedy Algorithm Algorithm Greedy: Every job is assigned to a machine that minimizes the completion time of this job (the completion time of job j if allocated to machine i is the load li(j) of machine i after the job is allocated). Theorem 3. The competitive ratio of Greedy is at most m+f−1 f . The key part in the proof of Theorem 3 is the following lemma which says that Greedy maintains the following invariant: the sum of the f largest machines loads never exceeds the sum of all jobs' minimal processing times. 7 Lemma 4. For f -favorite machines, and for every sequence of n jobs, the allocation of Greedy satisfies the following condition: (cid:96)1(n) + (cid:96)2(n) + ··· + (cid:96)f (n) ≤ p1 + p2 + ··· + pn . (1) Proof. The proof is by induction on the number n of jobs released so far. The base case is n = 1. Since Greedy allocates the first job to one of its favorite machines, and the other machines are empty, we have(cid:80)f As for the inductive step, we assume that (1) holds for n − 1, i.e., i=1 (cid:96)i(1) = (cid:96)i(1) = p1, and thus (1) holds for n = 1. (cid:96)1(n − 1) + (cid:96)2(n − 1) + ··· + (cid:96)f (n − 1) ≤ p1 + p2 + ··· + pn−1 , (2) and show that the same condition holds for n, i.e., after job n is allocated. If job n is allocated as a good job, then the left-hand side of (2) will increase by at most pn, while the right-hand side will increase by exactly pn. Thus, equation (1) follows from the inductive hypothesis (2). If job n is allocated as a bad job on some machine b, then the following observation allows to prove the statement: before job n is allocated, the load of each favorite machine for job n must be higher than lb(n − 1) (otherwise Greedy would allocate n as a good job). Since there are at least f favorite machines for job n, there must be a favorite machine a with lb(n − 1) < la(n − 1) ≤ (cid:96)f (n − 1) . (3) Thus, lb(n − 1) is not one of the f largest loads before job n is allocated. After allocating job n, the load of machine b increases to lb(n) = lb(n − 1) + pnb. We then have two cases depending on whether lb(n) is one of the f largest loads after job n is allocated: Case 1 (lb(n) ≤ (cid:96)f (n − 1)). In this case, the f largest loads remain the same after job n is allocated, meaning that the left-hand side of (2) does not change, while the right-hand side increases (when adding job n). In other words, (1) follows from the inductive hypothesis (2). Case 2 (lb(n) > (cid:96)f (n − 1)). In this case, (cid:96)f (n − 1) will be no longer included in the first f largest loads, after job n is allocated, while lb(n) will enter the set of f largest loads: f(cid:88) f(cid:88) (cid:96)i(n) = (cid:96)i(n − 1) − (cid:96)f (n − 1) + lb(n) . i=1 i=1 Since Greedy allocates job n to machine b, it must be the case lb(n) = lb(n − 1) + pnb ≤ la(n − 1) + pn ≤ (cid:96)f (n − 1) + pn , hypothesis (2), we obtain (cid:80)f where a is the favorite machine satisfying (3). Substituting (5) into (4) and by inductive i=1 pi + pn, and thus (1) i=1 (cid:96)i(n) ≤ (cid:80)f i=1 (cid:96)i(n − 1) + pn ≤ (cid:80)n−1 holds. This completes the proof of the lemma. (4) (5) 8 li(n − 1) + pn, min i∈M\Fn li(n − 1) + pni (cid:27) (cid:26) CGreedy ≤ min ≤ min i∈Fn ≤ (cid:96)f (n − 1) + pn , min i∈Fn li(n − 1) + pn Proof of Theorem 3. Without loss of generality we, assume that the makespan of the allo- cation of Greedy is determined by the last job n (otherwise, we can consider the last job n(cid:48) which determines the makespan, and ignore all jobs after n(cid:48) since they do not increase CGreedy nor decrease Copt). After allocating the last job n, the cost of Greedy becomes (6) where the last inequality holds because job n has at least f favorite machines, and thus the least loaded among them must have load at most (cid:96)f (n − 1). Since the optimum must allocate all jobs on m machines, and job n itself requires pn on (cid:40)(cid:80)n (cid:41) j=1 pj m , pn ≥ max (cid:26) f · (cid:96)f (n − 1) + pn (cid:27) m , pn . (7) where the second inequality is due to Lemma 4 applied to the first n−1 jobs only (specifically, i=1 (cid:96)i(n − 1) ≥ f · (cid:96)f (n − 1)). By combining (6) and (7), we obtain CGreedy (cid:96)f (n − 1) + pn a single machine, we have Copt ≥ max we have(cid:80)n−1 j=1 pj ≥(cid:80)f ≤ Copt max (cid:111) (cid:17) (cid:110) f·(cid:96)f (n−1)+pn (cid:16) (cid:96)f (n−1) m f (cid:96)f (n−1) pn m pn , pn + 1 + 1  (cid:96)f (n − 1) pn + 1 , = min ≤ m + f − 1 , f where the last inequality holds because the first term decreases in (cid:96)f (n − 1)/pn and the second term increases in (cid:96)f (n − 1)/pn. Theorem 5. The competitive ratio of Greedy is at least m+f−1 Proof. We will provide a sequence of jobs whose schedule by Greedy has a makespan m+f−1 , and the optimal makespan is 1. For simplicity, we assume that in case of a tie, the Greedy algorithm will allocate the job as a bad job to a machine with the smallest index. Without loss of generality, suppose m is divisible by f . We partition the m machines into m(cid:48) := m f groups, M1, M2, . . . , Mm(cid:48), each of them containing f machines, i.e., Mi = {(i − 1)f + 1, (i − 1)f + 2, . . . , (i − 1)f + f} for i = 1, . . . , m(cid:48). The jobs are released in two phases (described in detail below): In the first phase, we force Greedy to allocate each machine in Mi a load of bad jobs equal to i− 1, and a load of . f f 9 Figure 2: Proof of Theorem 5 (bad jobs in white). . f good jobs equal to 1 − i jobs with favorite machines in Mm(cid:48) are released and contribute an additional 2 − 1 load of one machine in Mm(cid:48), and thus the makespan is m+f−1 s , Mi). In this phase, we take s > m(cid:48) − 1 +(cid:112)(m(cid:48) − 1)(m(cid:48) − 2), so that, s for a suitable s > 1 (except for Mm(cid:48)); In the second phase, several f to the We use the notation r × (p, F ) to represent a sequence of r identical jobs whose favorite machines are F , the processing time on favorite machines is p, and on non-favorite machines is s · p with s ≥ 1. Phase 1. For each i from 1 to m(cid:48) − 1, release a sequence of jobs f × (1 − i by a sequence f × ( i for each i, the jobs f × (1 − i one per machine, and the jobs f × ( i Mi+1, one per machine (as shown in Figure 2). i(1 − 1 every job to some favorite machine evenly so that all machines have load 1, except for the machines in the last group Mm(cid:48) which are left empty. Phase 2. In this phase, all jobs released have Mm(cid:48) as their favorite machines, specifically f (f − 1) × ( 1 f , Mm(cid:48)) followed by a single job (1, Mm(cid:48)). By taking s > m, no jobs will be allocated as bad jobs by Greedy. Thus, this phase can be seen as scheduling on f identical machines. Consequently, all jobs will be allocated as in Figure 2 increasing the maximum load of machines in Mm(cid:48) by 2 − 1 s , Mi) will be assigned as good jobs to the f machines in Mi, s, Mi) will be assigned as bad jobs to the f machines in At the end of Phase 1, each machine in Mi (i ∈ [1, m(cid:48) − 1]) will have load i−1 s = s ), and each machine in Mm(cid:48) will have load m(cid:48) − 1. The optimal schedule assigns s · s + 1− i s, Mi) followed At the end of Phase 2, the maximum load of machines in Mm(cid:48) is m(cid:48) − 1 + 2− 1 f , while the optimal schedule can have a makespan 1. f = m+f−1 f , while the optimal makespan is 1. 3.2 A general lower bound In this section, we provide a general lower bound for the f -favorite machines problem. The bound borrows the basic idea of the lower bound for the restricted assignment (Azar et al., 1992). The trick of our proof is that we always partition the selected machines into arbitrary groups of f machines each, and apply the idea to each of the group respectively. 10 Mm(cid:48)M3M2M1···Mm(cid:48)−1···1−1s1−2s1−3s12m(cid:48)−1m(cid:48)−22−1f(cid:122)(cid:125)(cid:124)(cid:123)1−m(cid:48)−1s···1f1f······1f1f1f1f1f1f1(cid:124)(cid:123)(cid:122)(cid:125)(f−1)×1f······(cid:124)(cid:123)(cid:122)(cid:125)fmachines1f m m f + 1. 2 = 1 2 log2 f (cid:99) + 1. f is a power of 2, i.e., m Theorem 6. Every deterministic online algorithm must have a competitive ratio at least 1 2(cid:98)log2 f = 2u−1. We provide a sequence of m Proof. Suppose first that m jobs having optimal makespan equal to 1, while any online algorithm will have a makespan at least u+1 We denote by r× (1, F ) a sequence of r identical jobs whose favorite machines are F , the processing time on favorite machines is 1, and the processing time on non-favorite machines m is greater than u+1 f + 1, so that all jobs must be allocated to favorite machines. We consider subsets of machines M1,M2, . . . ,Mu, where the first subset is M1 = M and the others satisfy Mi ⊂ Mi−1 and Mi = 1 2i−1 for i = 2, . . . u. We then release u sets of jobs iteratively. At each iteration i (i = 1, 2, . . . , u), a set of jobs J i with favorite machines Mu are released for allocation, and after the allocation, half of the "highly loaded" machines in Mi are chosen for the next set Mi+1. More in detail, for each iteration i (i = 1, 2, . . . , u) we proceed as follows: • Partition the current set Mi of machines into arbitrary groups of f machines each, that f·2i−1 = 2u−i. Then, release a set 2Mi−1 = m Mi f = m where m(cid:48) 2 = 1 2 log2 is, into groups Mi,1, Mi,2, . . . , Mi,m(cid:48) of jobs J i: (cid:40) 2 × (1, Mi,l)(cid:9). J i := where Ji,l :=(cid:8) f i i = Ji,1 ∪ Ji,2 ∪ . . . ∪ Ji,m(cid:48) {f × (1,Mu)} , i , if 1 ≤ i ≤ u − 1 ; if i = u ; • The next set Mi+1 of machines consists of the f /2 most loaded machines in each subgroup i,2 ∪ ··· ∪ M(cid:48) , i,m(cid:48) i,l ⊂ M i,l being the subset of f /2 most loaded machines in group Mi,l after jobs J i after jobs J i have been allocated. Specifically, we let Mi+1 := M(cid:48) for M(cid:48) have been allocated. i,1 ∪ M(cid:48) i We then show that the following invariant holds at every iteration. Note that the following lemma shows a separation of our method and the one of Azar et al. (1992). Specifically, the maximum load increases by 1/2 at each iteration in our lower bound, but increases by 1 in Azar et al. (1992). Lemma 7. The average load of machines in Mi is at least i−1 assigned for 1 ≤ i ≤ u. before the jobs in J i are 2 Proof. The proof is done by induction on i. For the base case i = 1, the lemma is trivial. As for the inductive step, suppose the lemma holds for i. Denote the average load of Mi,l before the allocation of jobs J i by Avg(i, l), and the i,j after the allocation of jobs J i by Avg(cid:48)(i, l). We claim that Avg(cid:48)(i, l) ≥ average load of M(cid:48) Avg(i, l) + 1/2 after the allocation of jobs J i. Note that Mi and Mi+1 are the union of all i,l, respectively. Thus, we have that the average load of Mi+1 is at least groups Mi,l and M(cid:48) i−1 2 + 1 (the inductive hypothesis). This concludes 2, since the average load of Mi is i−1 2 = i 2 11 the proof of the inductive step, and thus the lemma follows. Next, we prove that the claim Avg(cid:48)(i, l) ≥ Avg(i, l) + 1/2 holds: Case 1. There is a machine in Mi,l\M(cid:48) consists of the f /2 most loaded machines in Mi,l, each machine in M(cid:48) least Avg(i, l) + 1/2. Thus, we obtain that Avg(cid:48)(i, l) ≥ Avg(i, l) + 1/2. Case 2. Each machine in Mi,l\M(cid:48) the total load of Mi,l is k · Ave(i, l) + k/2 after the allocation of J i. Since Mi,l\M(cid:48) at most k/2· (Avg(i, l) + 1/2), the average load of the f /2 machines in M(cid:48) i,l has load no greater than Avg(i, l) + 1/2. Observe that i,l has load i,l must be at least i,l that has load at least Avg(i, l) + 1/2. Since M(cid:48) i,l i,l will also have load at Avg(cid:48)(i, l) ≥ k · Avg(i, l) + k 2 − k 2 (Avg(i, l) + 1 2) k/2 = Avg(i, l) + 1 2 . An optimal cost of 1 can be achieved by using the machines in Mi,l\M(cid:48) By applying Lemma 7 with i = u, we have that the average load of Mu is at least u−1 before the allocation of jobs J u. Thus, after jobs in J u are allocated, the average load of Mu is at least u−1 2 , i.e., the online cost is at least u+1 2 + 1 = u+1 2 . i,l for J i (for i) and using machines in Mu for J u. Therefore, the competitive 1 ≤ i ≤ u− 1 and 1 ≤ l ≤ m(cid:48) f + 1. Finally, if m ratio is at least u+1 2 log2 f is not a power of 2, we simply apply the previous construction to a subset of m∗ machines, for m∗ m f . This gives the desired lower bound f = 2(cid:98)u(cid:99)−1 and u = 1 + log2 2 = 1 (cid:98)u(cid:99)+1 m 2 = 1 2(cid:98)log2 m f (cid:99) + 1. 2 3.3 General upper bound (Algorithm Assign-U is optimal) In this section, we prove a matching upper bound for f -favorite machines. Specifically, we show that the optimal online algorithm for unrelated machines (algorithm Assign-U by Aspnes et al. (1997) described below) yields an optimal upper bound: Theorem 8. Algorithm Assign-U can be used to achieve O(log m f ) competitive ratio. Following Aspnes et al. (1997), we show that the algorithm has an optimal competitive ratio ρ (Lemma 9) for the case the optimal cost Copt(J ) is known, and then apply a standard doubling approach to get an algorithm with competitive ratio 4ρ for the case the optimum is not known in advance (Theorem 8). In the following, we use a "tilde" notation to denote a normalization by the optimal cost Copt(J ), i.e., x = x/Copt(J ). Algorithm Assign-U (Aspnes et al., 1997): Each job j is assigned to machine i∗, where i∗ is the index minimizing ∆i = ali(j−1)+pji − ali(j−1), where a > 1 is a suitable constant. Lemma 9. If the optimal cost is known, Assign-U has a competitive ratio of O(log m f ). Proof. Without loss of generality, we assume that the makespan of the allocation of Assign- U is determined by the last job n (this is the same as the proof of Theorem 3 above). Let 12 l∗ i (j) be the load of machine i in the optimal schedule after the first j jobs are assigned. Define the potential function: Φ(j) = , (8) where a, γ > 1 are constants. Similarly to the proof in Aspnes et al. (1997), we have that the potential function (8) is non-increasing for a = 1 + 1/γ (see Appendix A.1 for details). Since Φ(0) ≥ Φ(n − 1) and l∗ γ · m ≥ m(cid:88) ali(n−1)(cid:16) i (n − 1) ≤ 1, we have γ − l∗ i (n − 1) ali(n−1)(γ − 1) ≥ f · a(cid:96)f (n−1)(γ − 1) . ali(j)(cid:16) m(cid:88) i=1 (cid:17) γ − l∗ i (j) (cid:17) ≥ m(cid:88) (cid:18) γ i=1 (cid:19) i=1 Thus, it follows that (cid:96)f (n − 1) ≤ loga γ − 1 · m f · Copt . (9) Claim 10. CAssign-U ≤ (cid:96)f (n − 1) + pn . Proof. Suppose Assign-U assigns the last job n to machine i(cid:48), it holds that CAssign-U = li(cid:48)(n − 1) + pni(cid:48) , since we suppose job n is the last completed job. Case 1. Job n is allocated as a good job, i.e., pni(cid:48) = pn. According to the rule of Assign-U, machine i(cid:48) must be one of the machines in Fn that has the minimum load. Since there are at least f favorite machines, it holds that li(cid:48)(n − 1) ≤ (cid:96)f (n − 1). Thus, CAssign-U ≤ (cid:96)f (n − 1) + pn. Case 2. Job n is allocated as a bad job, i.e., pni(cid:48) > pn. Let i(cid:48)(cid:48) be the machine who has the minimum load in Fn. Note that li(cid:48)(cid:48)(n − 1) ≤ (cid:96)f (n − 1). According to the rule of Assign-U, it holds that li(cid:48)(n − 1) ≤ li(cid:48)(cid:48)(n − 1); otherwise, we have ∆i(cid:48) ≥ ∆i(cid:48)(cid:48), which is contradictory to that Assign-U assigns job n to machine i(cid:48). Since ∆i(cid:48) ≤ ∆i(cid:48)(cid:48) and li(cid:48)(n − 1) ≤ li(cid:48)(cid:48)(n − 1) ≤ (cid:96)f (n − 1), we have li(cid:48)(cid:48) (n−1) li(cid:48)(cid:48) (n−1)+pni(cid:48)(cid:48) li(cid:48) (n−1)+pni(cid:48) Copt − a Copt , a Copt li(cid:48) (n−1) − a Copt ≤ a ≤ (cid:96)f (n−1)+pni(cid:48)(cid:48) Copt , implying so that li(cid:48) (n−1)+pni(cid:48) Copt ≤ li(cid:48)(cid:48) (n−1)+pni(cid:48)(cid:48) Copt CAssign-U = li(cid:48)(n − 1) + pni(cid:48) ≤ (cid:96)f (n − 1) + pni(cid:48)(cid:48) = (cid:96)f (n − 1) + pn . According to Claim 10 and (9), we have CAssign-U Copt ≤ (cid:96)f (n − 1) + pn Copt ≤ loga (cid:16) γ (cid:17) γ − 1 · m f + pn Copt ≤ loga γ − 1 · m f (cid:16) γ (cid:17) + 1 . Since the latter quantity is O(log m f ), this proves Lemma 9. By using the standard doubling approach, Lemma 9 implies Theorem 8 (see Appendix A.2). 13 4 The symmetric favorite machine model This section focuses on the symmetric favorite machines problem, where M = {M1, M2} (M1 = M2 = f ), Fj ∈ {M1, M2} for each job j, and the processing time of job j on a non- favorite machine is s (≥ 1) times that on a favorite machine. We analyze the competitive ratio of Greedy as a function of the parameter s. Though Greedy has a constant competitive ratio for this problem, another natural algorithm called GreedyFavorite performs better for larger s. At last, a combination of the two algorithms, GreedyOrGreedyFavorite, obtains a better competitive ratio, and the algorithm is optimal for the two machines case. 4.1 Greedy Algorithm The next two theorems regard the competitive ratio of the Greedy algorithm for the sym- metric favorite machines case. Theorem 11. For the symmetric m competitive ratio at most 2 -favorite machines case, the Greedy algorithm has a (cid:26) (cid:18) (cid:19) s2 (cid:18) (cid:19) s ρGreedy := min 1 + 2 − 1 f , s + s + 1 2 − 1 f , 3 − 1 f s + 1 (cid:27) , where f = m 2 and m is the number of machines. Since this upper bound increases in s (s ≥ 1), we have the following inequalities: 2 − 1 m ≤ ρGreedy ≤ 3 − 2 m , and both bounds can be achieved by the actual competitive ratio ρGreedy of algorithm Greedy. Note that for s = 1, the lower bound is indeed tight as it corresponds to the analysis of Greedy on m identical machines (Graham, 1966). More generally, we have the following result (whose proof is deferred to Appendix A.3 for readability sake): Theorem 12. The upper bound in Theorem 11 is tight (ρGreedy = ρGreedy) in each of the following cases: 1. For f = 1, ρGreedy = min{1 + s2 2. For f = 2 and 1 ≤ s ≤ 1.605, ρGreedy = 1 + 3s2 3. For 3 ≤ f ≤ s s+1, 2}; 2(s+1); s−1 (implying 1 ≤ s ≤ 1.5), ρGreedy = 1 + (2 − 1 f ) s2 s+1; √ s−1 and 1 ≤ s ≤ 1+ 4. For f > s 5. For 2 ≤ f < s, ρGreedy = 3 − 1 f . 2 5 , ρGreedy = s + (2 − 1 f ) s s+1; 14 4.1.1 Proof of Theorem 11 Because this is a special case of the general model, we have ρGreedy ≤ 3− 1 (by recalling that m = 2f ). Thus, we just need to prove (cid:110) 1 +(cid:0)2 − 1 , s +(cid:0)2 − 1 (cid:1) s s + 1 f (cid:111) . CGreedy Copt ≤ min f from Theorem 3 Without loss of generality, we assume that the makespan of the allocation of Greedy is determined by the last job n. Suppose that the first n − 1 jobs have been already allocated (cid:80) by Greedy, and denote lα = mini∈M1 l(n−1) , Lβ = be the total load of good jobs of Lα and Lβ, re- f . Without loss of generality, we assume that spectively. Observe that lα ≤ Lα machines in M1 are the favorite machines of the last job n. and Lgood f and lβ ≤ Lβ , lβ = mini∈M2 l(n−1) . Also let Lgood l(n−1) l(n−1) i∈M2 α i∈M1 i β i i i We first give a lower bound of the optimal cost Copt: Claim 13. Copt ≥ max , f·lα+f·s·lβ +s2·pn f·s2+f·s , pn (cid:110) f·s·lα+f·lβ +s·pn f·s2+f·s (cid:111) f s + 1 (cid:1) s2 , Lα =(cid:80) Proof. Denote by Pα and Pβ the total minimum processing time of the jobs which have M1 and M2 as their favorite machines, respectively, i.e., (cid:88) (cid:88) j: Fj =M1 j: Fj =M2 Pα = Pβ = pj = Lgood α + pj = Lgood β + 1 s 1 s (Lβ − Lgood β ) + pn , (Lα − Lgood α ) . (10) (11) A lower bound on the optimal cost can be obtained by considering the following fractional assignment. First, allocate all jobs as good jobs, i.e., assign Pα to M1 and Pβ to M2. Then, reassign a fraction of them to make all machines to have the same load. We next distinguish two cases: Case 1 (Pα ≥ Pβ). In this case, the reassignment is to move 1 in M2 so that s+1(Pα− Pβ) of Pα to machines Pα − 1 s + 1 (Pα − Pβ) = Pβ + s (Pα − Pβ). s + 1 Therefore, along with (10) and (11), the optimal cost is at least: Copt ≥ s · Pα + Pβ Lα + s · Lβ + s2 · pn + (s2 − 1)Lgood α = f (s + 1) f · s2 + f · s Furthermore, substituting (10) and (11) into Pα ≥ Pβ we have (Lα − Lβ) − s s + 1 β ≥ 1 s + 1 α − Lgood Lgood pn . . (12) 15 (cid:26) 1 (cid:27) pn, 0 . Therefore, α ≥ max Lgood Substituting (13) into (12), we have s + 1 (cid:26)s · Lα + Lβ + s · pn f · s2 + f · s Copt ≥ max (Lα − Lβ) − s s + 1 Lα + s · Lβ + s2 · pn f · s2 + f · s , (13) (cid:27) . Along with Copt ≥ pn, Lα ≥ f · lα and Lβ ≥ f · lβ, we obtain the inequation of this claim. Case 2 (Pα < Pβ). Similarly to the previous case, we have Copt ≥ Pα + s · Pβ (cid:26) f (s + 1) = In this case, (10) and (11) imply β ≥ max Lgood Substituting (15) into(14), we have s · Lα + Lβ + s · pn + (s2 − 1)Lgood β f · s2 + f · s (cid:27) − 1 s + 1 (Lα − Lβ) + s s + 1 pn, 0 , (cid:26) Lα + s · Lβ + s2 · pn f · s2 + f · s Copt ≥ max s · Lα + Lβ + s · pn f · s2 + f · s , (cid:27) . (14) (15) Along with Copt ≥ pn, Lα ≥ f · lα and Lβ ≥ f · lβ, we obtain the inequation of this claim and complete the proof. We next consider the cost of the Greedy algorithm. Recall that job n has M1 as favorite machines. After job n is allocated, we have CGreedy ≤ min{lα + pn, lβ + s · pn} . Two cases arise depending on the largest between the two quantities in (16): Case 1 (lα + pn ≤ lβ + s · pn). This case implies lβ ≥ lα − (s − 1) · pn , CGreedy ≤ lα + pn . Therefore, we have ≤ CGreedy Copt (cid:111) , pn , f·lα+f·s·lβ +s2·pn f·s2+f·s lα + pn f·s2+f·s (cid:110) f·s·lα+f·lβ +s·pn (cid:110) f (s+1)lα+(f +s−f s)pn (cid:26) (f s2 + f s)(x + 1) (cid:26) (cid:1) s2 1 +(cid:0)2 − 1 f (s + 1)x + f + s − f s lα + pn f s2+f s f s + 1 max max ≤ = min ≤ min , f (s+1)lα+(f s+s2−f s2)pn f s2+f s , , s +(cid:0)2 − 1 (cid:1) s s + 1 f (cid:27) , (cid:111) , pn (f s2 + f s)(x + 1) f (s + 1)x + f s + s2 − f s2 , x + 1 (16) (17) (18) (cid:27) 16 where the first inequality is by (18) and Claim 13; the second inequality is by (17); the third equation is obtained by defining x := lα/pn; the first term of the last inequality is obtained by the second and third terms of the third equation (one decreases in x and one increases in x); similarly, the second term of the last inequality is obtained by the first and third terms of the third equation. Case 2 (lα + pn ≥ lβ + s · pn). This case implies Similarly to the previous case, we can obtain lα ≥ lβ + (s − 1) · pn and CGreedy ≤ lβ + s · pn . (cid:26) 1 +(cid:0)2 − 1 f (cid:1) s2 s + 1 , s +(cid:0)2 − 1 f (cid:1) s s + 1 (cid:27) . CGreedy Copt ≤ min The above two cases conclude the proof of the theorem. 4.2 GreedyFavorite Algorithm We next consider another algorithm called GreedyFavorite which simply assigns each job j to one of its favorite machines in Fj. Algorithm GreedyFavorite: Assign each job to one of its favorite machines, chosen in a greedy fashion (minimum load). It turns out that this natural variant of Greedy performs better for large s. f + 1 s , where f = m 2 -favorite machines, the GreedyFavorite algorithm has a Theorem 14. For symmetric m competitive ratio of 2 − 1 Proof. Note that in GreedyFavorite all jobs are assigned as good jobs. Suppose the overall maximum load occurred on machine 1 in M1. Moreover, if there is any job executed on machines in M2, we can remove all of it, which will not decrease CGreedyFavorite . Therefore, all jobs have the same favorite machines M1, and GreedyFavorite assigns all of them to M1. 2 and m is the number of machines. Copt We also use lα to represent the minimum load over M1 before job n is allocated. Denote by Pα the total minimum processing time of the jobs who have M1 as their favorite machines, which is also the total minimum processing time of all the jobs here. Obviously, Pα ≥ f · lα + pn CGreedyFavorite ≤ lα + pn . (19) (20) The optimal schedule can allocate some of the jobs to M2 to balance the load over all machines. Thus, the optimal cost will be at least Copt ≥ max (Pα − x) · 1 f , x · s f ≥ s s + 1 Pα · 1 f ≥ s s + 1 (21) (cid:0)lα + (cid:1) , pn f (cid:26) (cid:27) 17 where x is the load of jobs that are assigned to M2 to balance the load over all machines. According to (20), (21) and Copt ≥ pn, we have (cid:40) (cid:41) CGreedyFavorite Copt ≤ min lα + pn s+1(lα + pn f ) s , lα + pn pn ≤ 2 − 1 f + 1 s . (22) Thus the upper bound on the competitive ratio is proved. To see that this bound is tight for any f and s, consider the following sequence of jobs: f (f − 1) × ( 1 f , M1), f × ( 1 s , M1), (1, M1) . According to algorithm GreedyFavorite, all these jobs are assigned to M1 in a greedy fashion, and thus CGreedyFavorite = 1 s . The optimal solution will instead assign the f jobs ( 1 f + 1 s , M1) to M2, thus implying Copt = 1. s + 1 = 2 − 1 f (f − 1) + 1 4.3 A better algorithm As one can see, the Greedy is better than GreedyFavorite for smaller s, and Greedy- Favorite is better for larger s. Thus we can combine the two algorithms to obtain a better algorithm. Algorithm GreedyOrGreedyFavorite (GGF): If s ≤ s∗, run Greedy; otherwise run GreedyFavorite. 2 -favorite machines, if s∗ (cid:39) 1.481 then ρGGF ≤ min{2 + Corollary 15. For symmetric m s2+s−2 s} ≤ 2.675. , 2 + 1 s+1 Proof. By Theorem 11, we have ρGreedy ≤ s + By Theorem 14, we have (cid:18) (cid:19) s s + 1 ≤ s + 2s s + 1 = 2 + s2 + s − 2 s + 1 . 2 − 1 f Note that if s ≤ 1.481, 2 + s2+s−2 s+1 ≤ 2 + 1 s+1 > 2 + 1 s , thus ρGreedyFavorite ≤ 2 − 1 f . + 1 s ≤ 2 + 1 s (cid:27) s , otherwise 2 + s2+s−2 s2 + s − 2 , 2 + 1 s ≤ 2.675 . (cid:26) ρGGF ≤ min 2 + s + 1 18 (cid:110) (cid:111) . s 4.4 Tight bounds for two machines (symmetric 1-favorite ma- chines) In this section, we show that the GGF algorithm is optimal for the symmetric case with two machines, i.e., the symmetric 1-favorite machines. 1 + s2 s+1, 1 + 1 Theorem 16. For symmetric 1-favorite machines, any deterministic online algorithm has competitive ratio ρ ≥ min Proof. Consider a generic algorithm Alg. Note that we have two machines, M1 contains machine 1 and M2 contains machine 2 only. Without loss of generality, assume the first job is assigned to machine 1 and this machine then has load 1, that is, job 1 is either (1, M1) or (1/s, M2). Job 2 is (s, M1). If Alg assigns job 2 to machine 1, then CAlg = 1 + s while Copt = s, thus implying ρAlg ≥ 1 + 1 s . Otherwise, if job 2 is assigned to machine 2, then a third job (s + 1, M2) arrives. No matter where Alg assigns job 3, the cost for Alg will be CAlg = s2 + s + 1. As the optimum is Copt = s + 1, we have ρAlg ≥ 1 + s2 s+1 in the latter case. By combining Theorem 11, Theorem 14, and Theorem 16, we obtain the following: Corollary 17. For symmetric 1-favorite machines, if s∗ (cid:39) 1.481 then ρGGF = min{1 + s2 s+1 , 1 + 1 s} ≤ 1.7549. Therefore, the GGF algorithm is optimal. 5 An extension of our model In this section, we discuss a simple extension, which explains why the instances, where f is small, still have a good competitive ratio. The main idea is to consider favorite machines as the machines which have "approximately" the minimal processing time for the job. For example, a job with processing times (0.99, 1, 1, 1, 2) might be considered to have approximate processing times (1, 1, 1, 1, 2). In the latter case, the job has 4 favorite machines, instead of 1. More formally, we consider the following modified algorithm A of a generic online algo- rithm A. For a set of jobs J , fix a parameter c ≥ 1 and denote Fj := {i : pji ≤ c · pj}. Run algorithm A assuming processing times are (cid:40) pji := if i ∈ Fj , otherwise. pj pji Note that in the rescaled processing times above the number f of favorite machines per job satisfies f ≥ f and pji ≤ c · pji. Ideally, we would like f as big as possible and c as small as possible, as the following observation indicates. Observation 18. If algorithm A is ρ(f )-competitive for a certain class of instances, where f denotes the minimum number of favorite machines per job in the input instance, then the modified algorithm A is at most c · ρ( f )-competitive on the same class of instances. 19 6 Conclusion and open questions This work studies online scheduling for the favorite machine model. Our results are sup- plements to several classical problems and reveal the relations among them (as indicated in Figure 1). For the general f -favorite machines case, we provide tight bounds on both Greedy and Assign-U algorithms and show that the latter is the best-possible online al- gorithm. To some extent, the key factor f in our model captures some of the main features that make the model perform well or badly: low or high competitive ratio. In particular, when f = 1, the model is exactly the unrelated machines; when f = m, the model is exactly the identical machines. Finally, the analysis of symmetric favorite machines allows a direct comparison with the two related machines. Acknowledgments This work was supported by the National Natural Science Foundation of China [71601152]; and the China Postdoctoral Science Foundation [2016M592811]. Part of this work has been done while the first author was visiting ETH Zurich. References Susanne Albers. Better bounds for online scheduling. SIAM Journal on Computing, 29(2): 459 -- 473, 1999. James Aspnes, Yossi Azar, Amos Fiat, Serge Plotkin, and Orli Waarts. On-line routing of virtual circuits with applications to load balancing and machine scheduling. Journal of the ACM, 44(3):486 -- 504, 1997. Vincenzo Auletta, George Christodoulou, and Paolo Penna. Mechanisms for scheduling with single-bit private values. Theory Comput. Syst., 57(3):523 -- 548, 2015. Yossi Azar, Joseph Seffi Naor, and Raphael Rom. The competitiveness of on-line assignments. In Proceedings of the third annual ACM-SIAM symposium on Discrete algorithms, pages 203 -- 210. Society for Industrial and Applied Mathematics, 1992. Amotz Bar-Noy, Ari Freund, and Joseph Naor. On-line load balancing in a hierarchical server topology. SIAM Journal on Computing, 31(2):527 -- 549, 2001. Yair Bartal, Amos Fiat, Howard Karloff, and Rakesh Vohra. New algorithms for an ancient scheduling problem. Journal of Computer and System Sciences, 51(3):359 -- 366, 1995. Piotr Berman, Moses Charikar, and Marek Karpinski. On-line load balancing for related machines. Journal of Algorithms, 35(1):108 -- 121, 2000. 20 Cong Chen and Yinfeng Xu. Selfish load balancing for jobs with favorite machines. Opera- tions Research Letters, 2018. ISSN 0167-6377. doi: https://doi.org/10.1016/j.orl.2018.11. 004. Cong Chen, Paolo Penna, and Yinfeng Xu. Selfish jobs with favorite machines: Price of anarchy vs. strong price of anarchy. In Proc. of the 11th Annual International Conference on Combinatorial Optimization and Applications (COCOA), pages 226 -- 240, 2017. Lin Chen, Deshi Ye, and Guochuan Zhang. Online scheduling of mixed cpu-gpu jobs. Inter- national Journal of Foundations of Computer Science, 25(06):745 -- 761, 2014. Yookun Cho and Sartaj Sahni. Bounds for list schedules on uniform processors. SIAM Journal on Computing, 9(1):91 -- 103, 1980. Pilu Crescenzi, Giorgio Gambosi, Gaia Nicosia, Paolo Penna, and Walter Unger. On-line load balancing made simple: Greedy strikes back. J. Discrete Algorithms, 5(1):162 -- 175, 2007. Leah Epstein. Equilibria for two parallel links: the strong price of anarchy versus the price of anarchy. Acta Informatica, 47(7):375 -- 389, 2010. ISSN 1432-0525. Leah Epstein, John Noga, Steve Seiden, Jir´ı Sgall, and Gerhard Woeginger. Randomized on-line scheduling on two uniform machines. Journal of Scheduling, 4(2):71 -- 92, 2001. Ulrich Faigle, Walter Kern, and Gyorgy Tur´an. On the performance of on-line algorithms for partition problems. Acta cybernetica, 9(2):107 -- 119, 1989. Rudolf Fleischer and Michaela Wahl. On-line scheduling revisited. Journal of Scheduling, 3 (6):343 -- 353, 2000. Jan Clemens Gehrke, Klaus Jansen, Stefan EJ Kraft, and Jakob Schikowski. A ptas for scheduling unrelated machines of few different types. International Journal of Foundations of Computer Science, 29(04):591 -- 621, 2018. Ronald L Graham. Bounds for certain multiprocessing anomalies. Bell System Technical Journal, 45(9):1563 -- 1581, 1966. Csan´ad Imreh. Scheduling problems on two sets of identical machines. Computing, 70(4): 277 -- 294, Aug 2003. ISSN 1436-5057. David R Karger, Steven J Phillips, and Eric Torng. A better algorithm for an ancient scheduling problem. Journal of Algorithms, 20(2):400 -- 430, 1996. Safia Kedad-Sidhoum, Florence Monna, Gr´egory Mouni´e, and Denis Trystram. A family of scheduling algorithms for hybrid parallel platforms. International Journal of Foundations of Computer Science, 29(01):63 -- 90, 2018. 21 Ron Lavi and Chaitanya Swamy. Truthful mechanism design for multidimensional scheduling via cycle monotonicity. Games and Economic Behavior, 67(1):99 -- 124, 2009. ISSN 0899- 8256. Kangbok Lee, Joseph Y.-T. Leung, and Michael L. Pinedo. Makespan minimization in online scheduling with machine eligibility. Annals of Operations Research, 204(1):189 -- 222, Apr 2013. Joseph Y.-T. Leung and Chung-Lun Li. Scheduling with processing set restrictions: A survey. International Journal of Production Economics, 116(2):251 -- 262, 2008. ISSN 0925-5273. John F Rudin III. Improved bounds for the online scheduling problem. PhD thesis, The University of Texas at Dallas, 2001. Nodari Vakhania, Jose Alberto Hernandez, and Frank Werner. Scheduling unrelated ma- International Journal of Production Research, 52(13): chines with two types of jobs. 3793 -- 3801, 2014. A Postponed proofs A.1 The potential function is non-increasing (for proof of Lemma 9) Recall that the potential function is defined as Φ(j) =(cid:80)m i=1 ali(j)(γ − l∗ i (j)). Assume that job j is assigned to machine i(cid:48) by algorithm Assign-U and to machine i by the optimal schedule, i.e., li(cid:48)(j) = li(cid:48)(j − 1) + pji(cid:48) and l∗ i (j − 1) + pji. Then we have i (j) = l∗ Φ(j) − Φ(j − 1) = (γ − l∗ i(cid:48)(j − 1))(ali(cid:48) (j) − ali(cid:48) (j−1)) − ali(j−1) pji ≤ γ(ali(cid:48) (j−1)+pji(cid:48) − ali(cid:48) (j−1)) − ali(j−1) pji ≤ γ(ali(j−1)+pji − ali(j−1)) − ali(j−1) pji = ali(j−1)(γ(apji − 1) − pji) . (by ∆i(cid:48) ≤ ∆i) By taking a = 1 + 1/γ, we get γ(apji − 1) − pji ≤ 0 since 0 ≤ pji ≤ 1, so that the potential function is non-increasing. A.2 Doubling approach (proof of Theorem 8) Let ρ be the competitive ratio of Assign-U when the optimal cost Copt is known. By using doubling approach one can easily get a 4ρ-competitive algorithm for the case optimal cost is not known. This approach has been used in Aspnes et al. (1997). We report the details below for completeness. We run Assign-U in phases, and let Λi be the estimation of Copt at the beginning of phase i. Initially (beginning of phase 1) when the first job arrives, let Λ1 be the minimum processing 22 time of the first job. Whenever the makespan exceeds ρ times the current estimation, ρΛi, the current phase i ends and the next phase i + 1 begins with doubled estimation Λi+1 = 2Λi as the new estimation of the Copt to run Assign-U. During a single phase, jobs are assigned independently of the jobs assigned in the previous phases. It is easy to see that this approach increases the competitive ratio ρ by at most a multiplicative factor 4 (a factor of 2 due to the load in all but the last phase, and another factor of 2 due to imprecise estimation of Copt). More in detail, each phase i can increase the load of every machine by at most ρΛi. If i=1 Λi. 2u−1 )Λu, since Λi+1 = 2Λi. We also have Λu = 2Λu−1 < 2Copt, because Λu−1 < Copt (otherwise in phase u − 1 the makespan will not 2u−1 )ρΛu < 4ρCopt. u denotes the number of phases, then the final makespan will be no more than ρ(cid:80)u Note that(cid:80)u exceeds ρΛu−1 according to Lemma 9). Thus we have ρ(cid:80)u 2u−1 )Λu = (2 − 1 i=1 Λi = (2 − 1 2 + ··· + 1 i=1 Λi = (1 + 1 A.3 Proof of Theorem 12 In some of the proofs we shall make use of the following initial set of "small" jobs: f × (, M1), f × ( (cid:124) 2 s , M1), f × ( 2 s , M2), f × ( (cid:123)(cid:122) t/ blocks 2 s , M1), f × ( 2 s , M2) . . . (cid:125) (23) where the total number of jobs is f · t/, and  is chosen so that t/ is integer. According to the algorithm Greedy, only the first first f jobs of length  are assigned as good jobs, while all other jobs are assigned as bad jobs. Moreover, all machines in each class will have the same load t and t − . These jobs can be redistributed to the machines in order to built arbitrary load (up to some arbitrarily small additive ). Taking  → 0, we can obtain the following result. Lemma 19. At the beginning of a schedule by algorithm Greedy, if s < 2, each machine can have a load of t so that all jobs executed during [0, t] are bad jobs, and each bad job is extremely "small" so that they can be redistributed to create an arbitrary load on any machine. 5 Proof of Theorem 12. We give five instances each of them resulting in a lower bound for the corresponding case. √ Case 1 (f = 1). If 1 ≤ s ≤ 1+ s+1, M2) and (1, M1). The Greedy algorithm assigns the first job to machine 2, and the last two jobs to machine 1, which leads to CGreedy = 1 + s2 s+1. In optimal schedule all jobs are allocated as good jobs, i.e., Copt = 1. √ If s > 1+ 2 s , M2) and (1, M1). The Greedy assigns the first job to machine 2, and the last two jobs to machine in 1, which leads to CGreedy = 2. Again, in optimal schedule all jobs are allocated as good jobs, i.e., Copt = 1. , the jobs sequence is ( s−1 , the jobs sequence is ( 1 s+1 , M2), ( s s , M2), ( 1 2 5 Therefore, ρGreedy = min{1 + s2 s+1 , 2} is tight for any s ≥ 1. 2(s+1), S6 =(cid:80)6 Case 2 (f = 2 and 1 ≤ s ≤ 1.605). Let lα = 3s2 and lgood β = 2−s 2(s+1). The sequence of jobs corresponds to the following three steps: i=1(s − 1)i = s−1 2−s(1 − (s − 1)6) 23 β + (s− 1)6 s β = f +s−f·s β + (s − 1)6 ≥ 0 due to 1 ≤ s ≤ 1.605. β −(s−1)6 β − (s − 1)6, M2) and 2 × ( lgood Step 1: We use Lemma 19 to let each machine have and initial load lα − S6 − lgood of bad jobs, where lα − S6 − lgood Step 2: Four jobs arrive: 2 × (lgood , M2). According to Greedy, the first two jobs will be assigned to machine 3 and 4 respectively as good jobs. But the last two jobs will be assigned to machine 1 and 2 as bad jobs. At this point, all the four machines have the same load lα − S6. Step 3: This sequence of jobs arrive: 2× ((s− 1)6, M2), 2× ((s− 1)5, M2), 2× ((s− 1)4, M1), 2 × ((s − 1)3, M2), 2 × ((s − 1)2, M1), 2 × (s − 1, M2). According to Greedy, the first two jobs are allocated as good jobs, while the others are allocated as bad jobs. At this point, the load of machine 1 and 2 is lα, while machine 3 and 4 have load lα − (s − 1). Step 4: Job (1, M1) arrives, which will be assigned to machine 3 as a bad job. Therefore, CGreedy = lα + 1 = 1 + 3s2 2(s+1). The optimal schedule is to assign all jobs as good jobs. By calculation we have Copt = 1. Thus, ρGreedy = 1 + 3s2 Case 3 (3 ≤ f ≤ s and lgood Note that when u → ∞, we have au → 0, i.e. 3 ≤ f ≤ s s−1. Step 1: We use Lemma 19 to let each machine have an initial load lα − Su − lgood bad jobs, where lα − Su − lgood and 1 ≤ s ≤ 1.5. Step 2: These 2f jobs arrive: f × (lgood , M2). According to Greedy, the first f jobs will be assigned to M2 as good jobs with one machine each, while the last f jobs will be assigned to M1 as bad jobs with one machine each. At this point, all the 2f machines has the same load of lα − Su. Step 3: This sequence of jobs arrives: f × (au, M2), f × (au−1, M2), f × (au−2, M1), f × (au−3, M2), f × (au−4, M1),. . . , f × (a2, M1), f × (a1, M2). According to Greedy, the first f jobs will be allocated as good jobs while the others as bad jobs. At this point, each machine in M1 has load lα, and each machine in M2 has load lα − (s − 1). Step 4: Job (1, M1) arrives, which is assigned to one machine in M2 as a bad job. Therefore, CGreedy = lα + 1 = 1 + (2 − 1/f ) s2 s+1. f (s+1) , where u is even number. Suppose 3 ≤ f ≤ s+1, ai = (s − 1)i, Su =(cid:80)u 2(s+1) is tight for 1 ≤ s ≤ 1.605. i=1 ai = s−1 β + au ≥ 0 due to 3 ≤ f ≤ s−1). Let lα = (2 − 1/f ) s2 2−s(1 − au) and 1 ≤ s ≤ 1.5. β − au, M2) and f × ( s s−1+(s+1)au β −au lgood s s s−1+(s+1)au β + au of The optimal schedule will allocate all jobs as good jobs. We next give such an optimal β +au s for each of M1 and M2; schedule to show that Copt = 1 is achievable: (Step 1 jobs.) All the jobs in Step 1 will be allocated as good jobs in optimal schedule, meaning f × lα−Su−lgood (Step 2 jobs.) All the jobs in Step 2 will be assigned to M2; (Step 3 jobs.) All the jobs in Step 3 will be allocate as good jobs, meaning f × (a2 + a4 + ··· + au−2) will be assigned to M1, while the rest of them to M2; (Step 4 jobs.) The last job in Step 4 will be assigned to M1. assigned to one machine, i.e., the load of some (cid:98) f For the jobs allocated to M1, notice that every 2 jobs of f ×(a2 +a4 +···+au−2) should be 2(cid:99) machines are all 2× (a2 + a4 +··· + au−2), 24 and 1 ≤ s ≤ 1.5. where 2× (a2 + a4 +··· + au−2) = 2au−2(s−1)2 Then the other jobs can be easily arranged within time 1, since the jobs in Step 1 are all "small" jobs. s(s−2) < 1 since 3 ≤ f ≤ s−1+(s+1)au s 5 s s s s 5 2 5 2 α + (lgood β +au s s−1+(s+1)au β −au lgood s f (s+1) , ai = (s − 1)i, Su =(cid:80)u For the jobs allocated to M2, the jobs can be equally divided into f parts with each part lα−Su−lgood + (a1 + a3 +··· + au−1 + au)= 1. Thus all machines and 1 ≤ s ≤ 1.5. Taking β − au) + has in M2 also have the same load of 1. Therefore, Copt = 1. s+1 is tight for 3 ≤ f ≤ Thus, ρGreedy = 1 + (2− 1/f ) s2 u → ∞, we have au → 0, i.e. 3 ≤ f ≤ s s−1. √ s−1 and 1 ≤ s ≤ 1+ 2 ). Let lα = s + f·s−f−s Case 4 (f > s 2−s(1 − au) and lgood = f·s−f−s s−1 √ 1 ≤ s ≤ 1+ Step 1: We use Lemma 19 to let each machine have an initial load lα− Su of bad jobs, where lα − Su > 0 due to f > Step 2: This sequence of jobs arrives: f × (au, M1), f × (au−1, M1), f × (au−2, M2), f × (au−3, M1), f × (au−4, M2),. . . , f × (a2, M1), f × (a1, M2). According to Greedy, the first f jobs will be allocated as good jobs while the others as bad jobs. Up to now each machine in M1 has load of lα, and each machine in M2 has load of lα − (s − 1). Step 3: Job (1, M1) arrives, which will be assigned to one machine in M2 as a bad job. Therefore, CGreedy = lα + 1 = s + (2 − 1/f ) s s+1. . When u → ∞, we have au → 0, i.e. f > f (s+1) , where u is odd number. Suppose f > √ and 1 ≤ s ≤ 1+ i=1 ai = and s−1−(s+1)au s−1−(s+1)au s−1−(s+1)au . . s s α −au α −au s − lgood s + f × (lgood s + f × (lgood s − lgood α −au For the optimal cost, we will show a schedule so that Copt = 1. Part of the jobs in Step 1 will be allocated as bad jobs in optimal schedule, specifically some jobs with total minimum processing time f× lgood having M2 as their favorite machine set will be allocated to M1 as bad jobs, i.e., M1 will have jobs with total load f × lα−Su α − au) while M2 will have jobs with total load f × ( lα−Su ); all the jobs in Step 2 and 3 will be allocate as good jobs, meaning f × (au + au−1 + au−3 + ··· + a2) + 1 will be assigned to M1, while the rest of them to M2. To sum up, M1 have jobs with total load α − au) + f × (au + au−1 + au−3 + ··· + a2) + 1 = f , while M2 have f × lα−Su f × ( lα−Su ) + f × (au−2 + au−4 + ··· + a1) = f . Then we give a schedule so that each machine has the same load 1. For the jobs allocated to M1, we first arrange the f × (au + au−1 + au−3 +··· + a2) and 1. The job with length 1 will be assigned to machine 1, and jobs (f − 1) × (au + au−1 + au−3 + ··· + a2) will be assigned to the remaining f − 1 machines with (au + au−1 + au−3 + ··· + a2) each. The remaining (au + au−1 + au−3 + ··· + a2) will be divided into 2 parts, a2 assigned to machine 2 and (au + au−1 + au−3 + ··· + a4) to machine 3. Note that (au + au−1 + au−3 + ··· + a2) + a2 < 1 and 2(au + au−1 + au−3 + ··· + a2) − a2 < 1, due to f > and au ≤ s − 1. Till now, no machine has load more than 1, and the remaining jobs are all "small" jobs which can be arbitrary divided and assigned to make every machine with load 1. For the jobs allocate to M2, they can be equally divided into f parts with each size 1. Therefore, all machines have the same load 1. √ , 1 ≤ s ≤ 1+ s−1−(s+1)au 5 2 s s 25 s s−1−(s+1)au . Taking Thus, ρGreedy = s + (2 − 1/f ) s s+1 is tight for f > u → ∞, we have au → 0, i.e. f > s s−1. Case 5 (2 ≤ f < s). Consider this jobs sequence: f × (1 − 1/s, M2), f × (1/s, M2), f (f − 1) × (1/f, M1) and (1, M1). According to algorithm Greedy, the first f jobs will be assigned to f machines in M2 respectively, so that each machine in M2 has load 1 − 1/s. Then the next f jobs will be assigned to f machines in M1 respectively, so that each machine in M1 has load 1. In terms of the f (f −1) jobs with length 1/f , all of them will be assigned to machines in M1 with f −1 job each machine. Note that none of the f (f −1) jobs will go to M2, since 1− 1 f > 1+ f−1 f . Now all machines in M1 have the same load 2 − 1 f . At last, the final job with length 1 will s + s. Therefore, CGreedy = 3 − 1 be assigned to one machine in M1, since 2 − 1 f . For the optimal cost, it is easy to have Copt = 1 by assigning each job to its favorite class Therefore, ρGreedy = 3 − 1/f is tight for 2 ≤ f < s. f + 1 < 1 − 1 of machines. √ and 1 ≤ s ≤ 1+ 5 2 s + s 26
1206.5343
1
1206
2012-06-23T00:14:04
Nonuniform Vote Aggregation Algorithms
[ "cs.DS", "math.CO" ]
We consider the problem of non-uniform vote aggregation, and in particular, the algorithmic aspects associated with the aggregation process. For a novel class of weighted distance measures on votes, we present two different aggregation methods. The first algorithm is based on approximating the weighted distance measure by Spearman's footrule distance, with provable constant approximation guarantees. The second algorithm is based on a non-uniform Markov chain method inspired by PageRank, for which currently only heuristic guarantees are known. We illustrate the performance of the proposed algorithms on a number of distance measures for which the optimal solution may be easily computed.
cs.DS
cs
Nonuniform Vote Aggregation Algorithms Farzad Farnoud (Hassanzadeh), Behrouz Touri, and Olgica Milenkovic University of Illinois, Urbana-Champaign, IL E-mail: {hassanz1, touri1, milenkov}@illinois.edu Abstract We consider the problem of non-uniform vote aggregation, and in particular, the algorith- mic aspects associated with the aggregation process. For a novel class of weighted distance measures on votes, we present two different aggregation methods. The first algorithm is based on approximating the weighted distance measure by Spearman's footrule distance, with prov- able constant approximation guarantees. The second algorithm is based on a non-uniform Markov chain method inspired by PageRank, for which currently only heuristic guarantees are known. We illustrate the performance of the proposed algorithms on a number of distance measures for which the optimal solution may be easily computed. 1 Introduction Vote (rank) aggregation has a long history, dating back to the first democratic elections held in the polis of Athens under Solon and Cleisthenis [1]. The early voting process involved ranking two candidates, so that the problem of determining the winner reduced to simple plurality vote counts. In more recent political history, it was recognized that plurality methods, as well as majority pairwise counts for multiple candidate ranking systems are plagued by a number of issues. These issues were most succinctly identified by de Borda and Condorcet [2], and pertain to the fact that votes may be non-transitive, that "strong candidates" may loose out to "weak candidates" due to their close mutual competition, and that majority pairwise counts may differ substantially from plurality counts. The above described issues with aggregating multiple votes/rankings led to a line of work centered around the use of distance measures between rankings [3] and an underlying axiomatic approach [4]. The idea behind the distance-based approach is that one can cast the aggregation problem as one of evaluating the median of a set of points in a given metric space. Well-known metrics used for computing the median include Kendall's τ and Spearman's footrule [5]. One of the drawbacks of aforementioned distance-based aggregation methods is that the dis- tance functions do not cater to the need of certain applications where similar items are to be treated similarly in the aggregation process, and where the top vs. the bottom of the list carry dif- ferent relevance in the ranking [6]. An example for the first scenario may be in ranking candidates for a number of positions, with the constraint that some candidate diversity criteria are met. An example for the second scenario may be in ranking candidates where only a small fraction at the top is considered for a position. In two companion papers [7,8], we studied a very general class of distance measures, termed cost- constrained transposition distances, or weighted transposition distance, which, among other things, 1 address the two aggregation issues described above. The crux of this new approach to measuring distances between rankings is to assign non-uniform swapping costs (weights) to different pairs of locations in the list, or equivalently, different pairs of elements in the inverse list. Aggregation methods based on weighted transpositions are currently unknown, and the topic of interest in this paper. The results we present pertain to algorithmic aspects of the weighted vote/rank aggregation problem [9 -- 12]. We describe three algorithms: a constant-approximation algorithm that uses an analytical bound between the weighted distance and a generalization of Spearman's footrule, and then solves a minimum weight matching problem; this algorithm is inspired by a procedure de- scribed in [13, 14]; an aggregation method reminiscent of PageRank [13], where the "hyperlink probabilities" are chosen according to the swapping weights; and a combination of the first algo- rithm with local descent methods. The paper is organized as follows. A brief introduction to vote aggregation and the problem formulation are given in Section 2. The main contribution of the paper is presented in Section 3, which contains the proposed aggregation algorithms. Results of various rank aggregation processes on an Academic Climate Study dataset gathered at UIUC are presented in Section 4. 2 Preliminaries Suppose that an election process includes m voters, each of which provides a ranking of n can- didates. These rankings are collected in a set Σ = {σ1, σ2, · · · , σm}, where each ranking σi is represented by a permutation in Sn, the symmetric group of order n. Given a distance function d over the permutations in Sn, the distance-based aggregation prob- lem can be stated as follows. Find the ranking π∗ that minimizes the cumulative distance from Σ, i.e., m π∗ = arg min π∈Sn Xi=1 d(π, σi). (1) Clearly, the choice of the distance function d is an important feature of the aggregation method. We describe next a few such distance measures, including Kendall's τ and Spearman's footrule distance [9]. Let e = 12 · · · n denote the identity permutation (ranking). Definition 1. A transposition (a b) in a permutation π is the swap of elements in positions a and b. When there is no confusion, we consider a transposition to be a permutation. If a − b = 1, the transposition is referred to as an adjacent transposition. It is well-known that any permutation may be reduced to the identity via transpositions or adjacent transpositions. The former process is referred to as sorting, while the later is known as sorting with adjacent transpositions. The smallest number of transpositions needed to sort a permutation π is known as the Cayley distance, T (e, π), while the smallest number of adjacent transpositions needed to sort a permutation is known as the Kendall's τ distance, K(e, π). Let Θ = {(a b) : a 6= b, a, b ∈ [n]} be the set of transpositions, and endow Θ with a non- negative weight function ϕ : Θ → R+ where ϕ(a, b) is the weight of transposition (a b). The distance measure of interest is defined as the minimum weight of a sequence of transpositions needed to transform one permutation π into another permutation σ. This distance measure is termed the weighted transposition distance, and is denoted by dϕ(π, σ) [7]. It can easily be shown 2 that most distance measures used for rank aggregation represent special cases of the weighted transposition distance: • Kendall's τ , K(π, σ) = dϕK (π, σ), where ϕK(i, j) = 1, for i − j = 1 and ϕK(i, j) = ∞ otherwise. • Spearman's footrule, F (π, σ), defined asPn dϕF (π, σ), where ϕF (i, j) = i − j. i=1 π−1(i) − σ−1(i), may be written as F (π, σ) = • Cayley's distance, T (π, σ) = dϕT (π, σ), where ϕT (i, j) = 1 for all i, j. In what follows, we focus on the weighted Kendall distance, where ϕ(i, i + 1) = ϕ(i + 1, i) = wi, with wi being non-negative, and ϕ(i, j) = ∞ for j − i 6= 1. The weighted Kendall distance between two permutations addresses the issue of the top-versus- bottom problem as follows. To model the significance of the top of the list versus the bottom of the list, one may choose wi = n − i. This means that the weight of swapping the first and the second rank (location) is n − 1 while the weight of swapping the n − 1st and the nth rank (location) is 1. In this case, transposition weights decay arithmetically as we move towards the end of the list. We may also choose wi = ci for 0 ≤ c < 1. In this case, the weight decay is geometric. Weighted transposition distance, in its general form, can be used to model similarities between elements by assigning small weights to transpositions involving similar elements and large weights to transpositions involving dissimilar elements. Note that in this case, the weights relate to transposing elements and not ranks, and thus the distance between two permutations π and σ is defined as dϕ(π−1, σ−1). In the next section, we describe how to perform efficient (approximate) rank aggregation using the weighted Kendall distance. Our results are inspired by related algorithmic approaches proposed in [13]. 3 Algorithmic Results Rank aggregation is a combinatorial optimization problem over the set of permutations, and as such, it is computationally costly. Aggregation with Kendall's τ distance is known to be NP- hard [13]. However, assuming that π∗ is the solution to (1), the ranking σi closest to π∗ provides a 2-approximation for the rank aggregate. This easily follows from the fact that Kendall's τ satisfies the triangle inequality. As a result, one only has to evaluate the pairwise distances of the votes Σ in order to identify a constant approximation aggregate for the problem. Although we do not provide a detailed proof of this claim, the same is true of the weighted Kendall distance. 3.1 Minimum Weight Bipartite Matching Algorithms For any distance function that may be written as d(π, σ) = Pn k=1 f (π−1(k), σ−1(k)), where f denotes an arbitrary non-negative function, one can find an exact solution to (1) as follows [13]. Consider a complete weighted bipartite graph G = (X, Y ), with X = {1, 2, · · · , n} corresponding to the n ranks to be filled and Y = {1, 2, · · · , n} corresponding to the elements of [n], i.e., the candidates. Let (i, j) denote an edge between i ∈ X and j ∈ Y . We say that a perfect bipartite matching P corresponds to a permutation π whenever (i, j) ∈ P if and only if π(i) = j. If the 3 weight of (i, j) equals m i.e., the weight incurred by π(i) = j, then the minimum weight perfect matching corresponds to a solution of (1). f (i, σ−1 l (j)), (2) Xl=1 For example, if ϕ is a metric path weight functions1, we have dϕ(π, σ) = = n n Xj=1 Xj=1 ϕ(π−1(j), σ−1(j)) f (π−1(j), σ−1(j)) where f = ϕ. Furthermore, note that Pn k=1 f (π−1(k), σ−1(k)) is a generalization of Spearman's footrule and thus for Spearman's footrule, one may find the exact solution as well. Let H denote a complete, undirected graph with vertex set V = [n]. To each edge (i, j), i, j ∈ [n] assign the weight ϕ(i, j). Furthermore, let p∗(i, j) denote the shortest path (i.e., minimum weight path) between i and j in H, and let weight(p∗) stand for the weight of the shortest path. Theorem 2. For any non-negative weight function ϕ, we have (1/2)D(π, σ) ≤ dϕ(π, σ) ≤ 2D(π, σ) where n D(π, σ) = Due to space limitations, the proof is omitted. Xi=1 weight(cid:0)p∗(π−1(i), σ−1(i))(cid:1) . l=1 D(π, σi) and π∗ = arg minπPm Proposition 3. Let π′ = arg minπPm dϕ(π, σi). The permuta- tion π′ is a 4-approximation to the optimal rank aggregate π∗. If ϕ is a metric, or if it corresponds to weighted Kendall distance, then π′ is a 2-approximation of π∗. l=1 Proof. The first part of the proof follows from the simple observation that m m dϕ(π∗, σi) ≥ (1/2) D(π∗, σi) and So, by optimality of π′ with respect to D, Xl=1 Xl=1 m Xl=1 Xl=1 Xl=1 m Xl=1 dϕ(π′, σi) ≤ 2 D(π′, σi). m m dϕ(π′, σi) ≤ 4 dϕ(π∗, σi) and thus π′ provides a 4-approximation. The other claim may be proved similarly, by referring to the results of [7]. 1A metric path weight is a weight function obtained by arranging the elements in [n] on a straight path and by assigning non-negative weights to the edges of the path. The weight of transposing elements in positions a and b, ϕ(a, b), is the weight of the unique path between a and b. 4 The permutation π′ can be obtained using minimum weight bipartite matching by letting In particular, for weighted Kendall distance, we let f (i, j) = weight (p∗(i, j)) . f (i, j) = j−1 Xl=i ϕ(l, l + 1). A simple approach for improving the performance of matching based algorithms is to couple them with local descent methods. More specifically, the local descent method works as follows. As- sume that an estimate of the aggregate at step ℓ equals π(ℓ). Let Θa = {(k k + 1) : k = 1, . . . , n − 1} be the set of all adjacent transpositions. Then π(ℓ+1) = π(ℓ) arg min τ ∈Θa d(π(ℓ) τ, σi). m Xi=1 The search terminates when the cumulative distance of the aggregate from the set Σ cannot be decreased further. We choose the starting point π(0) to be the ranking π′ obtained by the minimum weight bipartite matching algorithm. This method will henceforth be referred to as Bipartite Matching with Local Search (BMLS). 3.2 Vote Aggregation using PageRank For a ranking π ∈ Sn and a, b ∈ [n], π is said to rank a before b if π−1(a) < π−1(b). We denote this relationship with a <π b. The notation a ≤π b has a similar meaning, and is used in the case that one allows b = a. An algorithm for rank aggregation based on PageRank and HITS algorithms for ranking web pages was proposed in [13]. PageRank is one of the most important algorithms developed for search engines used by Google, with the aim of scoring web-pages based on their relevance. Each webpage that has hyperlinks to other webpages is considered as a voter, while the voter's preferences for candidates is expressed via the hyperlinks. When a hyperlink to a webpage is not present, it is assumed that the voter does not support the given candidate's webpage. The ranking of the webpages is obtained by computing the equilibrium distribution of the chain, and ordering the pages according to the values of their probabilities. The connectivity of the Markov chain provides transitive information about pairwise candidate preferences, and states with high input probability correspond to candidates ranked highly in a large number of lists. This idea can be easily adapted to the rank aggregation scenario in several different settings. In such an adaptation, it is assumed that the states of the Markov chain correspond to the candidates to be voted on and that the transition probabilities are functions of the votes. Dwork et al. [13, 14] proposed four different ways for computing the transition probabilities from the votes. For completeness, we briefly describe the methods below before we proceed to describe a new approach for evaluating the transition probabilities for the case of the weighted Kendall distance. Let P denote the state transition probability matrix of the chain, with Pij denoting the prob- ability of going from state (candidate) i to state j. Furthermore, let αij(σ) =(1, 0, if j ≤σ i, otherwise 5 and That is, αij is the number of voters that ranked candidate j at least as high as candidate i. In the first case (Case 1), the transition probabilities are computed according to αij(σ). αij =Xσ∈Σ Pij = I(αij > 0) Pk I(αik > 0) , Pij(σ) 1 mXσ∈Σ αij(σ) . Pk αik(σ) mXσ∈Σ Pij(σ) 1 Pij(σ) = Pij = where I(x > 0) equals 1 if x > 0 and equals 0 otherwise. In the second scenario (Case 2) the probabilities are set to with Pij = For Case 3, the transition probabilities are evaluated as with Pij(σ) = αij (σ) . The fourth method (Case 4) differs from the previous methods in so far that it uses transition probabilities based on majority votes, and will not be used in our subsequent studies. for j <σ i and Pii(σ) = 1 − n n Pj αij (σ) Our Markov chain model for weighted Kendall distance is similar to Case 3, with a major modification that includes incorporating transposition weights into the transition probabilities. To accomplish this task, we proceed as follows. Let wk = ϕ(k, k + 1), and let iσ = σ−1(i) for candidate i, i = 1, · · · , n. Note that iσ > jσ if and only if i >σ j. For l > k, let l−1 denote the sum of the weights of transpositions (k k + 1), (k + 1 k + 2), · · · , (l − 1 l). We set w(k : l) = wh Xh=k βij(σ) = max l:jσ≤l<iσ w(l : iσ) iσ − l (3) if jσ < iσ, βij(σ) = 0 if jσ > iσ, and The transition probabilities equal with βii(σ) = Xk:kσ>iσ βki(σ). Pij = 1 m m Xk=1 Pij(σk), Pij(σ) = . βij(σ) Pk βik(σ) 6 Method w = [1, 0, 0, 0] w = [1, 1, 1, 1] w = [1, 1, 0, 0] w = [0, 1, 0, 0] Aggregate ranking and average distance OPT BMLS MC [1, 4, 3, 2, 5], 0.7273 [1, 2, 3, 4, 5], 0.7273 [1, 2, 5, 4, 3], 0.7273 [2, 3, 4, 5, 1] , 2.3636 [2, 3, 4, 5, 1] , 2.3636 [2, 3, 4, 5, 1] , 2.3636 (cid:2)2, 3, 4, 5, 1(cid:3), 1.455 (cid:2)2, 3, 1, 5, 4(cid:3), 1.455 (cid:2)2, 1, 3, 4, 5(cid:3), 1.546 (cid:2)3, 2, 5, 4, 1(cid:3), 0.636 (cid:2)2, 3, 1, 5, 4(cid:3), 0.636 (cid:2)2, 3, 1, 4, 5(cid:3), 0.636 Table 1: The aggregate rankings and the average distance of the aggregate ranking from the votes for different weight functions w. Intuitively, the transition probabilities described above may be interpreted in the following manner. The transition probabilities are obtained by averaging the transitions probabilities corre- sponding to individual votes σ ∈ Σ. For each vote σ, let us first consider the case jσ = iσ − 1. In this case, the probability of going from candidate i to candidate j is proportional to wjσ = ϕ(jσ, iσ). This implies that if wjσ > 0, one moves from candidate i to candidate j with positive probability. Furthermore, larger values for wjσ result in higher probabilities for moving from i to j. Next, consider a candidate k with kσ = iσ − 2. In this case, it seems reasonable to let the probability of transitioning from candidate i to candidate k be proportional to wjσ +wkσ . However, since k is ranked before j by vote σ, it is natural to require that the probability of moving to candidate k from candidate i is at least as high as the probability of moving to candidate j from candidate i. This reasoning leads to βik = max{wjσ, wjσ +wkσ } and motivates using the maximum in (3). Finally, the probability of staying with candidate i is proportional to the sum of the β's from candidates placed below candidate i. 2 2 4 Results The performance of the Markov chain approaches described above cannot be evaluated analytically. A common approach when dealing with heuristic methods for hard combinatorial optimization problems is to test the performance of the scheme on examples for which the optimal solutions are easy to evaluate in closed form. In what follows, we evaluate the various aggregation approaches on a simple test example, with m = 11. The set of votes (rankings) Σ is given in matrix form by   1 1 1 2 2 3 3 4 4 5 5 2 2 2 3 3 2 2 2 2 2 2 3 3 3 4 4 4 4 5 5 3 3 4 4 4 5 5 5 5 3 3 4 4 5 5 5 1 1 1 1 1 1 1 1 .   Here, each column corresponds to a vote, e.g., σ1 = [1, 2, 3, 4, 5]. Let us consider candidates 1 and 2. Using a plurality rule, one would arrive at the conclusion that candidate 1 should be the winner, given that 1 appears most often at the top of the list. Under a number of other aggregation rules, including Kendall's τ and Borda's method, candidate 2 would be the winner. 7 Group Graduate (28) Undergrad (73) Method BMLS MC BMLS MC Aggregate Ranking Average Distance 10, 12, 9, 8, 1, 3, 2, 11, 7, 4, 6, 5 10,12, 9, 8, 1, 11, 3, 2, 7, 5, 4, 6 12, 9, 8, 1, 3, 10, 4, 2, 11, 7, 5, 6 12, 9, 8, 1, 3, 10, 4, 7, 2, 11, 5, 6 5.0918 5.1087 5.4044 5.4106 Table 2: Aggregate rankings for undergraduate and graduate students. Group Female, Undergrad (32) Male, Undergrad (31) DNI, Undergrad (10) Method BMLS MC BMLS MC BMLS MC Aggregate Ranking Average Distance 12, 9, 1, 8, 3, 7, 4, 10, 2, 5, 11, 6 12, 9, 8, 1, 3, 10, 7, 2, 5, 4, 11, 6 12, 9, 8, 3, 1, 10, 11, 7, 4, 2, 5, 6 12, 9, 8, 10, 1, 3, 11, 2, 7, 4, 5, 6 8, 12, 4, 1, 3, 9, 7, 2, 10, 11, 6, 5 12, 8, 4, 1, 3, 9, 10, 11, 7, 2, 6, 5 5.3218 5.3634 5.3457 5.421 4.2796 4.4338 Table 3: Aggregate rankings for female and male students. Our goal is to see how the distance based rank aggregation algorithms would position these two candidates. The numerical results regarding this example are presented in Table 1. In the tables, OPT refers to the optimum solution which was found by exhaustive search and MC refers to the Markov chain method. Furthermore, minimum weight bipartite matching is obtained using [15]. If the weight function is w(1) = [1, 0, 0, 0], the optimal aggregate vote clearly corresponds to the plurality winner. That is, the winner is the candidate with most voters ranking him/her as the top candidate. A quick check of Table 1 reveals that all three methods identify the winner correctly. Note that the ranks of candidates other than candidate 1 obtained by the different methods are different, however this does not affect the distance between the aggregate ranking and the votes. The next weight function that we consider is the uniform weight function, w(u) = [1, 1, 1, 1]. This weight function corresponds to the conventional Kendall's τ distance. As shown in Table 1, all three methods produce [2, 3, 4, 5, 1] , and the aggregates returned by BMLS and MC are optimum. The weight function w(2) = [1, 1, 0, 0] corresponds to ranking of the top 2 candidates. OPT and BMLS return 2, 3 as the top two candidates, while both preferring 2 to 3. The MC method, however, returns 2, 1 as the top two candidates, with a preference to 2 over 1, and a suboptimal cumulative distance. It should be noted that the the MC method is not designed to only minimize the average distance. Another important factor in determining the winners via the MC method is that "winning against strong candidates makes one strong". In this example, candidate 1 beats the strongest candidate, candidate 2, three times, while candidate 3 beats candidate 2 only twice and this fact seems to be the reason for the MC algorithm to prefer candidate 1 to candidate 3. Nevertheless, the equilibrium probabilities of candidates 1 and 3 obtained by the MC method are very close to each other, as the vector of probabilities is [0.137, 0.555, 0.132, 0.0883, 0.0877]. The weight function, w(t2) = [0, 1, 0, 0], corresponds to identifying the top 2 candidates (it is not important which candidate is the first and which is the second.) The OPT and BMLS identify {2, 3} as the top two candidates. The MC method returns the stationary probabilities [0, 1, 0, 0, 0] which means that candidate 2 is an absorbing state in the Markov chain. This occurs because candidate 2 is ranked first or second by all voters. The existence of absorbing states is a drawback of Markov chain methods. One solution is to remove 2 from the votes and reapply MC. The MC method in this case results in the stationary distribution [p (1) , p (3) , p (4) , p (5)] = [0.273, 0.364, 0.182, 0.182] , 8 which gives us the ranking [3, 1, 4, 5]. Together with the fact that candidate 2 is the strongest candidate, we obtain the ranking [2, 3, 1, 4, 5]. Equipped with this insight, we now perform an aggregation study on a set of rankings collected from UIUC undergraduate and graduate students, pertaining to criteria for the quality of academic experience (University Climate Study Data), listed below. The weight function w = [w1, · · · , wn−1] was chosen as wi = (3/4)i−1, i = 1, · · · , n − 1. 1. Campus friendliness and inclusiveness 2. Availability of recreational and cultural facilities 3. Quality of classrooms and dorms 4. Extracurricular student groups and activities 5. Geographical proximity to family/partner 6. Commitment of campus to build a diverse community 7. Being able to express one's personal identity freely 8. Being able to make friends on campus 9. Safety and security 10. Availability of financial support/scholarship 11. Availability of personal counseling/academic tutoring 12. Friendliness/quality of faculty/instructors The results of the vote aggregation are presented in Tables 2 and 3. In Table 3, a group of 10 students who Did Not Indicate their sex is referred to as DNI. An interesting finding is that the most important criteria for undergraduate students is the effectiveness and friendliness of instructors. Acknowledgment: The authors are grateful to Tzu-Yueh Tseng for helping with the numerical simulations and to Eitan Yaakobi for useful discussions. The work was supported by the NSF grants CCF 0821910, CCF 0809895, and CCF 0939370. References [1] R. K. Sinclair, Democracy and Participation in Athens. Cambridge University Press, 1988. [2] C. K. Rowley, F. G. Schneider, and D. C. Mueller, "Public choice: An introduction," in Readings in Public Choice and Constitutional Political Economy, pp. 31 -- 46, Springer US, 2008. [3] M. Deza and E. Deza, Encyclopedia of distances. Springer Verlag, 2009. [4] K. J. Arrow, Social choice and individual values. No. 12, Yale Univ Pr, 1963. 9 [5] P. Diaconis, "Group representations in probability and statistics," Lecture Notes-Monograph Series, vol. 11, 1988. [6] R. Kumar and S. Vassilvitskii, "Generalized distances between rankings," in Proceedings of the 19th international conference on World wide web, WWW '10, (New York, NY, USA), pp. 571 -- 580, ACM, 2010. [7] F. Farnoud and O. Milenkovic, "Sorting of permutations by cost-constrained transpositions," Information Theory, IEEE Transactions on, vol. 58, pp. 3 -- 23, Jan. 2012. [8] F. Farnoud, B. Touri, and O. Milenkovic, "Novel distance measures for rank aggregation," submitted, CDC 2012. [9] J. G. Kemeny, "Mathematics without numbers," Daedalus, vol. 88, no. 4, pp. pp. 577 -- 591, 1959. [10] W. D. Cook and M. Kress, "Ordinal ranking with intensity of preference," Management Sci- ence, vol. 31, pp. 26 -- 32, 01 1985. [11] D. Sculley, "Rank aggregation for similar items," in Proceedings of the Seventh SIAM Inter- national Conference on Data Mining, 2007. [12] F. Schalekamp and A. van Zuylen, "Rank aggregation: Together we're strong," Proc. of 11th ALENEX, pp. 38 -- 51, 2009. [13] C. Dwork, R. Kumar, M. Naor, and D. Sivakumar, "Rank aggregation revisited," Manuscript (Available at: www.eecs.harvard.edu/ michaelm/CS222/rank2.pdf ), 2001. [14] C. Dwork, R. Kumar, M. Naor, and D. Sivakumar, "Rank aggregation methods for the web," in Proceedings of the 10th international conference on World Wide Web, pp. 613 -- 622, ACM, 2001. [15] Y. Cao, "An efficient implementation of the munkres algorithm for the assignment problem (matlab code)." http://www.mathworks.com/matlabcentral/fileexchange/20328, Version 2.3, September 2011. 10
1401.4931
2
1401
2015-05-26T10:28:30
A domination algorithm for $\{0,1\}$-instances of the travelling salesman problem
[ "cs.DS", "math.CO" ]
We present an approximation algorithm for $\{0,1\}$-instances of the travelling salesman problem which performs well with respect to combinatorial dominance. More precisely, we give a polynomial-time algorithm which has domination ratio $1-n^{-1/29}$. In other words, given a $\{0,1\}$-edge-weighting of the complete graph $K_n$ on $n$ vertices, our algorithm outputs a Hamilton cycle $H^*$ of $K_n$ with the following property: the proportion of Hamilton cycles of $K_n$ whose weight is smaller than that of $H^*$ is at most $n^{-1/29}$. Our analysis is based on a martingale approach. Previously, the best result in this direction was a polynomial-time algorithm with domination ratio $1/2-o(1)$ for arbitrary edge-weights. We also prove a hardness result showing that, if the Exponential Time Hypothesis holds, there exists a constant $C$ such that $n^{-1/29}$ cannot be replaced by $\exp(-(\log n)^C)$ in the result above.
cs.DS
cs
A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF THE TRAVELLING SALESMAN PROBLEM DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL Abstract. We present an approximation algorithm for {0, 1}-instances of the travelling salesman problem which performs well with respect to com- binatorial dominance. More precisely, we give a polynomial-time algorithm which has domination ratio 1 − n−1/29. In other words, given a {0, 1}-edge- weighting of the complete graph Kn on n vertices, our algorithm outputs a Hamilton cycle H ∗ of Kn with the following property: the proportion of Hamilton cycles of Kn whose weight is smaller than that of H ∗ is at most n−1/29. Our analysis is based on a martingale approach. Previously, the best result in this direction was a polynomial-time algorithm with domina- tion ratio 1/2 − o(1) for arbitrary edge-weights. We also prove a hardness result showing that, if the Exponential Time Hypothesis holds, there exists a constant C such that n−1/29 cannot be replaced by exp(−(log n)C) in the result above. 1. Introduction Many important combinatorial optimization problems are known to be NP- hard, and this has led to a vast body of research in approximation algorithms. One well-known way to measure the performance of an approximation algorithm is to consider its approximation ratio, i.e. the cost ratio of the approximate solution to an optimal solution in the worst case. Another is to consider the proportion of all feasible solutions that are worse than the approximate solution in the worst case. The two measures should be viewed as complementary as there are examples of approximation algorithms that perform well with respect to one measure but badly with respect to the other. It is the latter measure, called combinatorial dominance, that we consider in this paper. In general, the domination ratio of an approximation algorithm A for an optimization problem P is the largest r = r(n) such that for each instance I of P of size n, A outputs a solution that is not worse than an r proportion of all feasible solutions. The study of this approximation measure was initiated by Glover and Punnen in [11], where they analysed the domination ratio of various heuristics for the travelling salesman problem. 1.1. Travelling salesman problem. Let us begin by formally defining the travelling salesman problem. Let Kn = (Vn, En) be the complete graph on n D. Kühn, D. Osthus and V. Patel were supported by the EPSRC, grant no. EP/J008087/1. D. Kühn was also supported by the ERC, grant no. 258345. D. Osthus was also supported by the ERC, grant no. 306349. 1 2 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL vertices and let Hn be the set of all (n − 1)!/2 Hamilton cycles of Kn. For an edge weighting w of Kn (i.e. a function w : En → R) and a subgraph G = (V, E) of Kn, we define w(G) := Xe∈E w(e). The travelling salesman problem (TSP) is the following algorithmic problem: given an instance (n, w) of TSP, where n is a positive integer and w is an edge weighting of Kn, determine a Hamilton cycle H∗ of Kn which satisfies w(H∗) = min H∈Hn w(H). The asymmetric travelling salesman problem (ATSP) is a directed version of TSP, in which one considers Hamilton cycles in complete directed graphs and in which the weights of the two oppositely directed edges between two vertices are allowed to be different from each other. 1.2. TSP and approximation ratio. We now give some brief background on TSP and approximation ratio. It is well known that TSP is NP-hard [10], and indeed, NP-hard to approximate to within a constant factor [28]. On the other hand, Christofides [4] gave a 3/2-approximation algorithm for metric-TSP, that is, TSP in which the edge-weights of Kn satisfy the triangle inequality. However, even for {1, 2}-TSP, Papadimitriou and Vempala [23] showed there is no 220 219 - approximation algorithm unless P = N P . Here {1, 2}-TSP is the special case of TSP where all edge-weights are either 1 or 2, and this is in fact a special case of metric TSP. Arora [2] and Mitchell [21] independently gave a PTAS for Euclidean-TSP, a special case of metric-TSP in which the edge-weights of Kn arise as the distances between vertices that have been embedded in Euclidean space of fixed dimension. 1.3. TSP and combinatorial dominance. A TSP algorithm is an algorithm which, given any instance (n, w) of TSP, outputs some Hamilton cycle of Kn. For r ∈ [0, 1] and (n, w) a fixed instance of TSP, we say that a TSP algorithm A has domination ratio at least r for (n, w) if, given (n, w) as input, the algorithm A outputs a Hamilton cycle H∗ of Kn satisfying {H ∈ Hn : w(H∗) ≤ w(H)} ≥ r. Hn The domination ratio of a TSP algorithm is the maximum r such that the algorithm has domination ratio at least r for all instances (n, w) of TSP. (Thus, the aim is to have a domination ratio close to one.) We often refer to a TSP algorithm as a TSP-domination algorithm to indicate our intention to evaluate its performance in terms of the domination ratio. The notion of combinatorial dominance (although slightly different to above) was first introduced by Glover and Punnen [11]. They gave various polynomial- time TSP-domination algorithms and showed that their algorithms have domi- nation ratio Ω(cn/n!) for some constant c > 1. Glover and Punnen [11] believed A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 3 that, unless P = N P , there cannot be a polynomial-time TSP-domination al- gorithm with domination ratio at least 1/p(n) for any polynomial p. This was disproved by Gutin and Yeo [15], who gave a polynomial-time ATSP-domination algorithm with domination ratio at least 1/(n − 1). It was later found that this had already been established in the early 1970's [26, 27]. Alon, Gutin, and Krivelevich [1] asked whether one can achieve a domination ratio Ω(1). Kühn and Osthus [19] resolved this question by proving an algorithmic Hamilton de- composition result which, together with a result by Gutin and Yeo [14], gives a polynomial-time ATSP-domination algorithm with domination ratio at least 1/2 − o(1). It is worth noting (see [16]) that some simple, well-known TSP heuristics give the worst possible domination ratio, that is, for certain instances of TSP, these heuristics produce the unique worst (i.e. most expensive) Hamilton cycle. In particular this is the case for the greedy algorithm, in which one recursively adds the cheapest edge maintaining a disjoint union of paths (until the end), and the nearest neighbour algorithm, in which one builds (and finally closes) a path by recursively adding the cheapest neighbour of the current end-vertex. Other algorithms have been shown to have small domination ratio [25], e.g. Christofides' algorithm [4] has domination ratio at most ⌊n/2⌋!/ 1 2 (n − 1)! = exp(−Ω(n)), even for instances of TSP satisfying the triangle inequality. Our main result gives an algorithm with domination ratio of 1 − o(1) for the TSP problem restricted to {0, 1}-instances, i.e. for instances where all the edge- weights lie in {0, 1}. Note that this clearly implies the same result whenever the weights may take two possible values; in particular it implies the same result for {1, 2}-instances. The latter is the more usual formulation, but for our algorithm we find it more natural to work with weights in {0, 1} rather than in {1, 2}. Theorem 1.1. There exists an O(n5)-time TSP-domination algorithm which has domination ratio at least 1 − 6n−1/28 for every {0, 1}-instance (n, w) of TSP. In fact we have a TSP-domination algorithm which, for most {0, 1}-instances of TSP, has domination ratio that is exponentially close to 1. Theorem 1.2. Fix η ∈ (0, 1/2). There exists an O(n5)-time TSP-domination algorithm which has domination ratio at least 1 − O(exp(−η4n/104)) for every {0, 1}-instance (n, w) of TSP satisfying w(Kn) = d(cid:0)n 2(cid:1) for some d ∈ [η, 1 − η]. We use a combination of algorithmic and probabilistic techniques as well as some ideas from extremal combinatorics to establish the results above. On the hardness side, assuming the Exponential Time Hypothesis (discussed in Sec- tion 6), we show that there is no TSP-domination algorithm for {0, 1}-instances that substantially improves the domination ratio in Theorem 1.1 and, in partic- ular, there is no TSP-domination algorithm that achieves the domination ratio of Theorem 1.2 for general {0, 1}-instances of TSP. We can prove weaker bounds assuming P 6= N P . Theorem 1.3. 4 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL (a) Fix ε ∈ (0, 1 2 ). If P 6= N P , then there is no polynomial-time TSP- domination algorithm which, for all {0, 1}-instances (n, w) of TSP, has domination ratio at least 1 − exp(−nε). (b) There exists a constant C > 0 such that if the Exponential Time Hypoth- esis holds, then there is no polynomial-time TSP-domination algorithm which, for all {0, 1}-instances (n, w) of TSP, has domination ratio at least 1 − exp(−(log n)C). Previously, Gutin, Koller and Yeo [12] proved a version of Theorem 1.3(a) for general instances of TSP, and we use some of the ideas from their reduction in our proof. 1.4. Combinatorial dominance and other algorithmic problems. Alon, Gutin and Krivelevich [1] gave algorithms with large domination ratios for sev- eral optimization problems. For example, they gave a (1 − o(1))-domination algorithm for the minimum partition problem and an Ω(1)-domination algo- rithm for the max-cut problem. Berend, Skiena and Twitto [3] introduced a notion of combinatorial dominance for constrained problems, where not all per- mutations, subsets or partitions form feasible solutions. They analysed various algorithms for the maximum clique problem, the minimum subset cover and the maximum subset sum problem with respect to their notion of combinatorial dominance. See e.g. [13, 18] for further results on domination analysis applied to other optimization problems. 1.5. Organisation of the paper. In the next section, we introduce some basic terminology and notation that we use throughout the paper. In Section 3, we present an algorithm, which we call Algorithm A, that will turn out to have a large domination ratio for 'most' {0, 1}-instances of TSP. We define it as a ran- domized algorithm and describe how it can be derandomized using the method of conditional expectations of Erdős and Selfridge. In Section 4, we develop the probabilistic tools needed to evaluate the domination ratio of Algorithm A. In particular, our approach is based on a martingale associated with a random TSP tour. We begin Section 5 by evaluating the domination ratio of Algorithm A and proving Theorem 1.2. We also present and evaluate two other algorithms, Algorithm B and Algorithm C, which have large domination ratios for {0, 1}- instances of TSP where Algorithm A does not work well (roughly speaking, this is the case when almost all weights are 0 or almost all weights are 1). The anal- ysis of Algorithms B and C is based on a result from extremal combinatorics. We conclude Section 5 by proving Theorem 1.1. Section 6 is devoted to the proof of Theorem 1.3. We end with concluding remarks and an open problem in Section 7. 2. Preliminaries We use standard graph theory notation. Let G = (V, E) be a graph. We sometimes write V (G) and E(G) for the vertex and edge set of G and we write e(G) for number of edges of G. A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 5 We write H ⊆ G to mean that H is a subgraph of G. For U ⊆ V , we write G[U ] for the graph induced by G on U , EG(U ) for the set of edges in G[U ], and eG(U ) for the number of edges in G[U ]. Similarly for A, B ⊆ V not necessarily disjoint, we write G[A, B] for the graph given by G[A, B] := (A∪ B, EG(A, B)), where EG(A, B) := {ab ∈ E : a ∈ A, b ∈ B}. Define eG(A, B) := EG(A, B). For v ∈ V , we write degG(v) for the number of neighbours of v in G. A set D ⊆ V is called a vertex cover if V \ D is an independent set in G, i.e. if EG(V \ D) = ∅. For any set A, we write A(2) for the set of all unordered pairs in A. Thus if A is a set of vertices, then A(2) is the set of all edges between the vertices of A. Recall that we write Kn = (Vn, En) for the complete graph on n vertices, where Vn and En is the vertex and edge set respectively of Kn. A function w : En → R is called a weighting of Kn. For E ⊆ En, and more generally, for a subgraph G = (V, E) of Kn, we define w(G) = w(E) := Xe∈E w(e) and w[G] = w[E] := Xe∈E w(e). Recall that we write Hn for the set of all (n − 1)!/2 Hamilton cycles of Kn. We write Hn for the set of all (n − 1)! directed Hamilton cycles of Kn. For n even, we define Mn to be the set of all perfect matchings of Kn. An optimal matching of Kn is any set of ⌊n/2⌋ independent edges in Kn; thus an optimal matching is a perfect matching if n is even and is a matching spanning all but one vertex of Kn if n is odd. At certain points throughout the course of the paper, we shall distinguish between the cases when n is odd and even. The case when n is odd requires a little extra care, but the reader loses very little by focusing on the case when n is even. We have already defined the domination ratio of a TSP-domination algorithm, but we give here an equivalent reformulation which we shall use henceforth. Note that, for r ∈ [0, 1] and (n, w) a fixed instance of TSP, a TSP algorithm A has domination ratio at least r for (n, w) if and only if, given (n, w) as input, the algorithm A outputs a Hamilton cycle H∗ of Kn satisfying P(w(H) < w(H∗)) ≤ 1 − r, where H is a uniformly random Hamilton cycle from Hn. Note that for the TSP problem, if λ > 0, then two instances (n, w) and (n, λw) are completely equivalent, and so by suitably scaling w, we can and shall always assume that w : En → [−1, 1]. for optimal matchings is polynomial-time solvable [5]. While the TSP problem is known to be NP-hard, the corresponding problem Theorem 2.1. There exists an O(n4)-time algorithm which, given (n, w) as input (where n ≥ 2 and w is a weighting of Kn), outputs an optimal matching M∗ of Kn, such that w(M∗) = min M∈Mn w(M ). 6 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL We call this algorithm the minimum weight optimal matching algorithm. 3. An algorithm We now informally describe a simple polynomial-time algorithm that turns out to give a domination ratio close to one for many instances of TSP. Given an instance (n, w) of TSP, we apply the minimum weight optimal matching algorithm to find an optimal matching M∗ of Kn of minimum weight. We then extend M∗ to a Hamilton cycle H∗ of Kn using a randomized approach. This last step can be transformed into a deterministic polynomial-time algorithm using the method of conditional expectations of Erdős and Selfridge [8, 9, 22]. Note that in this section and the next, we allow our weightings to take values in the interval [−1, 1]. This does not make the analysis more difficult than in the {0, 1}-case. Lemma 3.1. There exists an O(n5)-time algorithm which, given an instance (n, w) of TSP (with n ≥ 3) and any optimal matching M of Kn as input, outputs a Hamilton cycle H of Kn satisfying (1) w( H) ≤(cid:18)1 − 1 n − 2(cid:19) w( M ) + 1 n − 2 where ρ(n) = 1 if n is odd and ρ(n) = 0 if n is even. w(Kn) + ρ(n), Assume first that n ≥ 4 is even. For G ⊆ Kn, we write HG for a Proof. uniformly random Hamilton cycle from Hn that contains all edges of G. We have E(w(H M )) = Xe∈En w(e) + Xe∈En\E( M ) n − 2 w(e) 1 Let H be a Hamilton cycle of Kn such that w( H) ≤ E(w(H M )); thus H satisfies (1). It remains for us to show that we can find such a Hamilton cycle in O(n5)- time. The following claim provides a subroutine that we shall iteratively apply to obtain the desired algorithm. By a non-trivial path, we mean a path with at least two vertices. If G = (Vn, E) ⊆ Kn is the union of vertex-disjoint non-trivial paths, let J(E) denote those edges of Kn that join the end-vertices of two distinct paths of G together. Claim. Let w be a weighting of Kn and let G = (Vn, E) be a union of i ≥ 2 vertex-disjoint non-trivial paths. Then in O(n4)-time, we can find e∗ ∈ J(E) such that Furthermore G ∪ e∗ is the union of i − 1 vertex-disjoint non-trivial paths. E(w(HG∪e∗)) ≤ E(w(HG)). P(e ∈ H M )w(e) = Xe∈E( M ) (w(Kn) − w( M )) 1 n − 2 n − 2(cid:19) w( M ) + 1 1 n − 2 w(Kn). = w( M ) + =(cid:18)1 − A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 7 First note that we can determine J(E) in O(n2)-time and that for each e ∈ J(E), G ∪ e is the disjoint union of i − 1 non-trivial paths. Furthermore, for each e ∈ J(E), we can compute E(w(HG∪e)) in O(n2)-time. Indeed, assuming first 2(i−2) for all e′ ∈ J(E ∪ {e}) since that i > 2, note that P(e′ ∈ HG∪e) = J(E ∪{e}) is regular of degree 2(i− 2) and each edge at a given vertex is equally likely to be in HG∪e. Now we have 1 E(w(HG∪e)) = w(G ∪ e) + Xe′∈J(E∪{e}) P(e′ ∈ HG∪e)w(e′) = w(G ∪ e) + 1 2(i − 2) Xe′∈J(E∪{e}) w(e′), so we see that computing E(w(HG∪e)) takes O(n2)-time. (For i = 2, we have E(w(HG∪e)) = w(G ∪ e) + w(e′), where e′ is the unique edge that closes the Hamilton path G ∪ e into a Hamilton cycle.) Since E(w(HG)) = 1 J(E) Xe∈J(E) E(w(HG∪e)), there exists some e∗ ∈ J(E) such that E(w(HG∪e∗)) ≤ (w(HG)). By computing E(w(HG∪e)) for each e ∈ J(E), we can determine e∗ in O(n4)-time. This proves the claim. We now iteratively apply the subroutine from the claim n/2 − 1 times. Thus let A0 := M , and let G0 := (Vn, A0), and for each i = 1, . . . , n/2 − 1, let Gi := (Vn, Ai) be obtained from Gi−1 := (Vn, Ai−1) by setting Ai := Ai−1∪{ei}, where ei is obtained by applying the subroutine of the claim to Gi−1. By induction, it is clear that Gi is the disjoint union of n/2− i ≥ 2 non-trivial paths for i = 0, . . . , n/2 − 2, and so the claim can be applied at each stage. By induction it is also clear for all i = 1, . . . , n/2 − 1, that E(HGi) ≤ E(H M ). Let H be the Hamilton cycle obtained by closing the Hamilton path Gn/2−1. Then we have w( H) = E(w(HGn/2−1)) ≤ E(H M ), as required. The running time of the algorithm is dominated by the O(n) applications of the subroutine from the claim each taking O(n4)-time, giving a running time of O(n5). Now consider the case when n ≥ 3 is odd. Let (n, w) be an instance of TSP with n ≥ 3 odd and M an optimal matching of Kn = (Vn, En). We introduce a weighting w′ of Kn+1 ⊇ Kn defined as follows. Let v be the unmatched vertex of Kn in M and let v′ be the unique vertex in Kn+1 but not in Kn. Set w′(e) := w(e) for all e ∈ En, set w(v′x) := w(vx) for all x ∈ Vn \ {v}, and set w(vv′) := 0. Let M′ be the perfect matching of Kn+1 given by M′ := M ∪{vv′}. We apply the algorithm for n even to (n + 1, w′) and M′ to produce a Hamilton 8 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL cycle H′ satisfying w′(Kn+1) w′( H′) ≤(cid:18)1 − ≤(cid:18)1 − ≤(cid:18)1 − 1 1 n − 1(cid:19) w′( M′) + n − 1(cid:19) w( M ) + n − 2(cid:19) w( M ) + 1 1 n − 1 1 n − 1 1 n − 2 w(Kn) + 1 w(Kn) + 1, where the second inequality follows from the fact that w( M ) = w′( M′) and w′(Kn+1) ≤ w(Kn) + n − 1. Now contracting the edge vv′ in H′ to give a Hamilton cycle H of Kn, and noting that w′( H′) = w( H), the result immediately follows. (cid:3) We end the section by formally describing the steps of our main algorithm, which we call Algorithm A. 1. Using the minimum weight optimal matching algorithm (Theorem 2.1), find a minimum weight optimal matching M∗ of Kn. (O(n4) time) 2. Apply the algorithm of Lemma 3.1 to extend M∗ to a Hamilton cycle H∗ satisfying w(H∗) ≤ (1 − 1 n−2 )w(M∗) + 1 n−2 w(Kn) + ρ(n). (Recall that ρ(n) = 1 if n is odd and ρ(n) = 0 otherwise.) So Algorithm A has running time O(n5). In the next few sections, we evaluate the performance of this algorithm for certain instances of TSP. 4. Martingale estimates Our next task is to find for each instance (n, w) of TSP and each r ∈ [0, 1], a non-trivial threshold t(w, r) satisfying P(w(H) < t(w, r)) ≤ r, where H is a uniformly random Hamilton cycle from Hn. We achieve this using martingale concentration inequalities, for which we now introduce the necessary setup, following McDiarmid [20]. Let (Ω,F, P) be a finite probability space with (Ω,∅) = F0 ⊆ F1 ⊆ ··· ⊆ Fn = F a filtration of F. A martingale is a sequence of finite real-valued random variables X0, X1, . . . , Xn such that Xi is Fi-measurable and E(Xi Fi−1) = Xi−1 for all i = 1, . . . , n. Note that for any real-valued F-measurable random variable X, the sequence of random variables given by Xi := E(X Fi) is a martingale. The difference sequence Y1, . . . , Yn of a martingale X0, X1, . . . , Xn is the sequence of random variables given by Yi := Xi − Xi−1. The predictable quadratic variation of a martingale is defined to be the random variable W given by W := n Xi=1 E(Y 2 i Fi−1). A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 9 We shall use the following variant of Freedman's inequality; see e.g. Theo- rem 3.15 in the survey [20] of McDiarmid. Theorem 4.1. Let X0, X1, . . . , Xn be a martingale with difference sequence Y1, . . . , Yn and predictable quadratic variation W . If there exist constants R and σ2 such that Yi ≤ R for all i and W ≤ σ2, then t2/2 P(Xn − X0 ≥ t) ≤ 2 exp(cid:18)− σ2 + Rt/3(cid:19) . In our setting, we work with the probability space ( Hn,F, P), where P is the uniform distribution on Hn (and so F is the power set of Hn). Given an instance (n, w) of TSP, we aim to study the random variable X : Hn → R given by X(H) := w(H) (here H is directed but we interpret w(H) in the obvious way to mean the sum of the weights of the undirected edges of H). Thus X = w(H), where H is a uniformly random Hamilton cycle of Hn. We define a filtration F0 ⊆ ··· ⊆ Fn−1 = F, where Fk is given by fixing the first k vertices of Hamilton cycles. Let us define this more formally. We start by fixing a distinguished vertex v0 of Kn that represents the start of our Hamilton cycle (we will say more later on how v0 should be chosen). Define seq(Vn, k) to be the set of sequences (v1, . . . , vk) of length k where v1, . . . , vk are distinct vertices from Vn \ {v0}. For s = (v1, . . . , vk) ∈ seq(Vn, k), define Hn(s) to be the set of Hamilton cycles whose first k vertices after v0 are v1, . . . , vk in that order. Then Fk is the σ-field generated by {Hn(s) : s ∈ seq(Vn, k)}, and it is clear that F0 ⊆ ··· ⊆ Fn−1 = F is a filtration of F. Thus we obtain a martingale X0, . . . , Xn−1 by setting Xi := E(X Fi). We call this the Hamilton martingale for (n, w). Note that Xn−2 = Xn−1 = X (this is because knowing the order of the first n − 1 vertices of an n-vertex Hamilton cycle determines it completely). Let us return to the question of how the distinguished vertex v0 should be chosen. Given our instance (n, w) of TSP, by simple averaging we can and shall choose v0 to be a vertex such that (2) w(v0v) ≤ 2w[Kn] n . Xv∈Vn\{v0} We require such a choice of v0 in order to effectively bound the difference se- quence and predictable quadratic variation of Hamilton martingales in the fol- lowing lemma. Lemma 4.2. Let (n, w) be an instance of TSP and assume that w[Kn] = d(cid:0)n 2(cid:1) for some d ∈ [0, 1]. Let X0, X1, . . . , Xn−1 be the Hamilton martingale for (n, w), let Y1, . . . , Yn−1 be its difference sequence and let W be its predictable quadratic variation. Then we have the following uniform bounds Yi ≤ 6 for all i and W ≤ 60(√dn + 1). Before we prove the lemma, we prove a few basic properties of w. 10 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL Proposition 4.3. Suppose (n, w) is an instance of TSP with w[Kn] = d(cid:0)n some d ∈ [0, 1]. For every A ⊆ Vn with A = r, we have w[A(2)] ≤ dr(cid:0)r dr := min{1, d(cid:0)n 2(cid:1)}. Furthermore 2(cid:1)/(cid:0)r 2(cid:1) for 2(cid:1), where n−1 dr ≤ 2√dn + 1. Proof. For (n, w) and A as in the statement of the proposition, we clearly n−1 Xr=2 have that w[A(2)] ≤ min{(cid:0)r 2(cid:1), w[Kn]} = dr(cid:0)r 2(cid:1). Furthermore, we have √dn⌉+1 ⌈ n−1 d(cid:18)n 2(cid:19)/(cid:18)r 2(cid:19) Xr=⌈ Xr=2 √dn⌉+1 √dn⌉ + dn(n − 1) Xr=⌈√dn⌉+1(cid:18) 1 ⌈√dn⌉ ≤ 2√dn + 1. √dn⌉ + dn(n − 1) r − 1 − Xr=2 r(cid:19) dr ≤ ≤ ⌈ = ⌈ 1 + n−1 1 Given an instance (n, w) of TSP and a Hamilton cycle H ∈ H whose vertices are ordered v0, v1, . . . , vn−1, we write w+ H(vi) := Xi+1≤j≤n−1 w(vivj). (cid:3) Proposition 4.4. Suppose (n, w) is an instance of TSP with w[Kn] = d(cid:0)n some d ∈ [0, 1] and let H ∈ Hn. Then w+ H (vi−1) n − i ≤ √dn + 2. n−2 2(cid:1) for Xi=1 Let (n, w) and H be as in the statement of the proposition and let Proof. v0, v1, . . . , vn−1 be the ordering of vertices given by H. Let e1, e2, . . . , e(n 2) be the lexicographic ordering on the edges of Kn induced by the vertex ordering of H. If ei = vjvk with j < k, then set λi := 1/(n − j − 1). Thus n−2 Xi=1 w+ H(vi−1) n − i ≤ n−1 Xi=1 w+ H (vi−1) n − i = (n 2) Xi=1 λiw(ei). maximising the weights of edges at the end of the lexicographic order. Therefore Note that the λi form an increasing sequence and so P λiw(ei) is maximised (subject to the constraints that w(e) ∈ [−1, 1] for all e and w[Kn] = d(cid:0)n 2(cid:1)) by we obtain an overestimate of P λiw(ei) by assigning a weight of 1 to the last A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 2(cid:1) edges (and 0 to all other edges), where r is chosen such that (cid:0)r (cid:0)r The last inequality is satisfied by taking r := ⌈√dn⌉ + 1, and so √dn⌉ + 1. = r = ⌈ n−1 n−2 n−1 w+ H (vi−1) n − i ≤ Xi=1 w+ H(vi−1) n − i ≤ Xi=1 Xi=n−r n − i n − i 2(cid:1) ≥ d(cid:0)n 2(cid:1). 11 (cid:3) Before proving Lemma 4.2 we introduce some further notation. For any H ∈ Hn, define si(H) = (v1, . . . , vi) ∈ seq(Vn, i), where v1, . . . , vi are the first i vertices (after v0) of H, in that order. If Z is a random variable on ( Hn,F, P), then as usual, we write Z(H) for the value of Z at H ∈ Hn. For s = (v1, . . . , vk) ∈ seq(Vn, k), we write E(Z s) = E(Z v1, . . . , vk) to mean the expected value of Z given that the first k vertices (after v0) of our uniformly random Hamilton cycle from Hn are v1, . . . , vk in that order. Thus we have E(Z Fi)(H) = E(Z si(H)) for all H ∈ Hn and in particular, we have Xi(H) = E(X si(H)). Finally, for any s = (v1, . . . , vi) ∈ seq(Vn, i), write V (s) := {v0, v1, . . . , vi} and V (s) := Vn \ V (s). Proof of Lemma 4.2. Fix a Hamilton cycle H ∈ Hn and let v0, v1, . . . , vn−1 be the order of vertices in H. Let sk = sk( H) = (v1, . . . , vk). Also, let H be a uniformly random Hamilton cycle from Hn. We have for each k = 0, . . . , n − 2 that 1 = Xk( H) = E(X sk) = Xe∈En n − k − 1 Xv∈V (sk) n − k − 1 Xe∈V (sk)(2) w(vkv) + P(e ∈ H sk(H) = sk)w(e) n − k − 1 Xv∈V (sk) Xi=1 w(vi−1vi). w(e) + + 2 1 k w(v0v) Using the above, and after cancellation and collecting terms, we obtain, for each k = 1, . . . , n − 2 Yk( H) = Xk( H) − Xk−1( H) = A1 + A2 − A3 − A4 − A5 + A6, where Ai = Ai( H) is given by 1 A1 :=(cid:18) A2 := 2(cid:18) n − k − 1 − n − k − 1 − 1 1 n − k(cid:19) Xv∈V (sk−1) n − k(cid:19) Xe∈V (sk−1)(2) 1 A3 := 1 n − k − 1 w(v0vk), A6 := w(vk−1vk). w(v0v), A4 := w(vkv), 1 n − k − 1 Xv∈V (sk) n − k Xv∈V (sk−1) 1 w(e), A5 := w(vk−1v), 12 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL In order to bound Yk( H), we bound each of A1, . . . ,A6 in similar ways using the fact that w(e) ≤ 1 for all edges e. We have A1 ≤ 1 (n − k)(n − k − 1) Xv∈V (sk−1) w(v0v) ≤ V (sk−1) (n − k)(n − k − 1) ≤ 1. We have 2V (sk−1)(2) = 1. A2 ≤ 2w[V (sk−1)(2)] (n − k)(n − k − 1) ≤ (n − k)(n − k − 1) Similarly, A3,A4,A5,A6 ≤ 1. Thus we have Yk( H) ≤P6 since H is arbitrary, we have Yk ≤ 6 as required. In order to bound W ( H), we must estimate E(Y 2 i=1 Ai ≤ 6, and k Fk−1)( H). We have E(Y 2 k sk−1( H)) = E(Y 2 k Fk−1)( H) = E(Y 2 1 V (sk−1) Xy∈V (sk−1) E(Y 2 = k v1, . . . , vk−1) k v1, . . . , vk−1, y). Recall that Yk is Fk-measurable, so if Hk,y ∈ Hn(v1, . . . , vk−1, y), then E(Y 2 k v1, . . . , vk−1, y) = Y 2 k (Hk,y) ≤ 6Yk(Hk,y). Therefore E(Y 2 k Fk−1)( H) ≤ 6 n − k Xy∈V (sk−1) Yk(Hk,y) ≤ 6 n − k 6 Xi=1 Xy∈V (sk−1) Ai(Hk,y). Setting Bi := 1 n − k Xy∈V (sk−1) Ai(Hk,y), A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 13 we have w(v0v) (2) ≤ 2d(n − 1) (n − k)(n − k − 1) w(e) ≤ dn−k, , , (2) w(v0y) ≤ n − k − 1 Xv∈V (v1,...vk−1,y) 1 2d(n − 1) (n − k)(n − k − 1) w(yv) B1 ≤ B2 ≤ B3 ≤ B4 ≤ = B5 ≤ B6 ≤ 1 2 1 1 (n − k)(n − k − 1) Xv∈V (sk−1) (n − k)(n − k − 1) Xe∈V (sk−1)(2) (n − k)(n − k − 1) Xy∈V (sk−1) n − k Xy∈V (sk−1) (n − k)(n − k − 1) Xe∈V (sk−1)(2) n − k Xv∈V (sk−1) w(vk−1v) = n − k Xy∈V (sk−1) w(vk−1y) = 2 1 1 w(e) ≤ dn−k, w+ (vk−1) H n − k w+ (vk−1) H n − k , , where the bound the bound for B2 and B4 follows from Proposition 4.3. Using these bounds, we obtain E(Y 2 k Fk−1)( H) ≤ 6(cid:18) 4d(n − 1) (n − k)(n − k − 1) + 2dn−k + 2 n − k w+ H Summing this expression over k = 1, . . . , n− 2, and using thatPn−1 Proposition 4.3, and Proposition 4.4, gives r=2 (vk−1)(cid:19) . r(r−1) ≤ 1, 1 W ( H) = E(Y 2 k Fk−1)( H) = n−2 n−1 Xk=1 E(Y 2 k Fk−1)( H) Xk=1 ≤ 6(cid:16)4d(n − 1) + 2(2√dn + 1) + 2(√dn + 2)(cid:17) = 24d(n − 1) + 36√dn + 36 ≤ 60(√dn + 1), n−1 Fn−2)( H) = 0, which follows since, as we where we have used that E(Y 2 noted earlier, Xn−1 = Xn−2. This proves this lemma, since H is arbitrary. (cid:3) 5. {0, 1}-weightings In this section, we provide a polynomial-time TSP-domination algorithm with large domination ratio for instances (n, w) of TSP in which w : En → {0, 1}. 14 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL We call such instances {0, 1}-instances of TSP. In fact our algorithm consists of three separate algorithms, each adapted for different types of {0, 1}-instances. We begin with the following classical result of Erdős and Gallai [7] on the number of edges needed in a graph to guarantee a matching of a given size. Theorem 5.1. Let n, s be positive integers. Then the minimum number of edges in an n-vertex graph that forces a matching with s edges is max(cid:26)(cid:18)2s − 1 2 (cid:19),(cid:18)n 2(cid:19) −(cid:18)n − s + 1 2 (cid:19)(cid:27) + 1. We recast the above result into a statement about {0, 1}-instances of TSP and the existence of optimal matchings of Kn with small weight. Proposition 5.2. Let (n, w) be a {0, 1}-instance of TSP with n ≥ 1 and w(Kn) = d(cid:0)n 2(cid:1) for some d ∈ [0, 1] satisfying n−1 ≤ d ≤ 1 − 4n−1. Then there exists a optimal matching M∗ of Kn such that w(M∗) ≤ f (n, d), where f (n, d) :=( 1 1 2 dn − 1 2 dn − 1 8 dn + 1 8 (1 − d)2n + 1 if d ≤ 9 25 ; if d ≥ 9 25 . We remark that for a random perfect matching M of Kn (where n is even), we have E(w(M )) = 1 2 dn. Thus it is instructive to compare the expressions in the statement of Proposition 5.2 with 1 2 dn. We note in particular that when d is bounded away from 0 and 1, we can find a perfect matching whose weight is sig- nificantly smaller than that of an average perfect matching, but as d approaches 0 or 1, all perfect matchings tend to have roughly the same weight. Proof. Let G be the n-vertex subgraph of Kn whose edges are the edges of If s = 1 2 Kn of weight zero; thus e(G) = (1 − d)(cid:0)n 2(cid:1). √1 − dn then it is easy to check that (1 − d)(cid:0)n 2(cid:1) ≥ (cid:0)2s−1 if s = (1 − √d)n then it is easy to check that (1 − d)(cid:0)n 2(cid:1) ≥ (cid:0)n √d)n(cid:27)(cid:23) . Thus Theorem 5.1 implies that G has a matching of size at least g(n, d) :=(cid:22)min(cid:26) 1 √1 − dn, (1 − 2 2 (cid:1) + 1, and (cid:1) + 1. 2(cid:1) −(cid:0)n−s+1 2 Note that if M is any matching of G with s edges, then we can extend M arbitrarily to an optimal matching M′ of Kn such that w(M′) ≤ (n/2) − s. Thus there is an optimal matching M∗ of Kn with w(M∗) ≤ n/2 − g(n, d) ≤ 1 + max(cid:26) 1 2 (1 − √1 − d)n,(cid:18)√d − 1 2(cid:19) n(cid:27) . It is easy to compute that the maximum above is given by its first term if d ∈ [0, 9/25] and the second when d ∈ [9/25, 1]. Now using that √1 − d ≥ 1− 3 4 d for d ∈ [0, 9/25] and that √d ≤ 1 8 (1 − d)2 for d ∈ [0, 1], the proposition easily follows. (The latter inequality can be checked by substituting 1− x for d, squaring both sides, and rearranging.) 2 d− 1 2 + 1 (cid:3) A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 15 Next we combine the various results we have gathered so far to prove Theo- rem 1.2 by showing that Algorithm A (see end of Section 3) has a domination ratio exponentially close to 1 for {0, 1}-instances of TSP with fixed density, i.e. density that is independent of n. In fact, we will not make use of Theorem 1.2 in order to prove Theorem 1.1: instead we will make use of a similar and slightly more technical result in which d may depend on n. Proof of Theorem 1.2. Given an instance (n, w) as in the statement of the theorem, Proposition 5.2 implies that there exists an optimal matching M∗ of Kn satisfying w(M∗) ≤ 1 8 η2n + O(1). Thus Algorithm A, which has running time O(n5) outputs a Hamilton cycle H∗ satisfying 2 dn − 1 n − 2(cid:19)(cid:18) 1 1 2 η2n + O(1). w(H∗) ≤(cid:18)1 − = dn − 1 8 dn − 1 8 η2n + O(1)(cid:19) + 1 n − 2 d(cid:18)n 2(cid:19) + ρ(n) Set t := dn − w(H∗) ≥ 1 8 η2n + O(1). Let X0, X1, . . . , Xn−1 be the Hamilton martingale for (n, w), so that Xn−1 = w(H) where H is a uniformly random Hamilton cycle from Hn and X0 = E(w(H)) = dn. From Theorem 4.1 and Lemma 4.2, we have P(w(H) ≤ w(H∗)) ≤ P(Xn−1 ≤ X0 − t) ≤ 2 exp(cid:18)− t2/2 σ2 + Rt/3(cid:19) ≤ O(exp(−η4n/104)), where R = 6 and σ2 = 60(√dn + 1) ≤ 60n + O(1). (cid:3) We remark that, although we used Theorem 4.1 (the variant of Freedman's inequality) in the proof above, Azuma's inequality, which is much simpler to apply, gives the same bounds. However, Azuma's inequality is not strong enough to derive our main result, and in particular, it is not strong enough to derive Theorem 5.4. Our next goal is to give a result similar to Theorem 1.2 in which the density of our {0, 1}-instance of TSP can depend on n. We begin with the following definition. Definition 5.3. For d ∈ [0, 1], ε > 0 and an integer n > max{6, exp(ε−1)}, we call a {0, 1}-instance (n, w) of TSP an (n, d, ε)-regular instance if (i) w(Kn) = d(cid:0)n 2(cid:1); (ii) there exists an optimal matching M∗ of Kn such that either w(M∗) ≤ 1 2 dn − mε(n, d) or w(M∗) ≤ 1 2 dn − mε(n, 1 − d), where mε(n, d) := 40(ε + ε1/2) log n + 40ε1/2d1/4pn log n. Note that w(Kn) = w[Kn] for {0, 1}-instances of TSP. Theorem 5.4. If (n, w) is an (n, d, ε)-regular instance of TSP, then Algo- rithm A has domination ratio at least 1 − 2n−ε for (n, w). 16 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL Suppose (n, w) is an (n, d, ε)-regular instance of TSP and set m := Proof. mε(n, d). Assume first that there exists an optimal matching M∗ of Kn with w(M∗) ≤ dn/2 − m. Then Algorithm A outputs a Hamilton cycle H∗ with w(H∗) ≤(cid:18)1 − 1 n − 2(cid:19) (dn/2 − m) + n − 2(cid:19) m + ρ(n) 1 = dn −(cid:18)1 − ≤ dn − m/2, 1 n − 2 d(cid:18)n 2(cid:19) + ρ(n) where the last inequality follows because n > 6 and m > 4 (which follows because n > exp(ε−1)). Set t := m/2. Let X0, X1, . . . , Xn−1 be the Hamilton martingale for (n, w), so that Xn−1 = w(H) where H is a uniformly random Hamilton cycle from Hn and X0 = E(w(H)) = dn. From Theorem 4.1 and Lemma 4.2, we have P(w(H) ≤ w(H∗)) ≤ P(Xn−1 ≤ X0 − t) ≤ 2 exp(cid:18)− where R = 6 and σ2 = 60(√dn + 1). We have that t2/2 σ2 + Rt/3(cid:19) , t2/2 t2/2 2Rt/3(cid:27) = min(cid:26) t2 4σ2 , σ2 + Rt/3 ≥ min(cid:26) t2/2 2σ2 , (40(ε + ε1/2) log n + 40ε1/2d1/4pn log n)2 ≥ 400ε log n(√dn + 1), 8(cid:27) . t Noting that t2 = 1 4 we have t2/4σ2 ≥ ε log n. Also t/8 ≥ ε log n, and so we have P(w(H) ≤ w(H∗)) ≤ 2 exp(−ε log n) = 2n−ε, as required. Now set m := mε(n, 1 − d) and assume there is an optimal matching M∗ of Kn with w(M∗) ≤ dn/2 − m. As before Algorithm A outputs a Hamilton cycle H∗ with w(H∗) ≤ dn − m/2. Again set t := m/2. This time let X0, X1, . . . , Xn−1 be the Hamilton martingale for ¯w := 1 − w. From Theorem 4.1 and Lemma 4.2, we have P(w(H) ≤ w(H∗)) = P( ¯w(H) ≥ ¯w(H∗)) ≤ P(Xn−1 ≥ X0 + t) t2/2 ≤ 2 exp(cid:18)− σ2 + Rt/3(cid:19) , where R = 6 and σ2 = 60(√1 − dn + 1) (since ¯w(Kn) = (1 − d)(cid:0)n the same argument as before with d replaced by 1 − d, we obtain 2(cid:1)). Following P(w(H) ≤ w(H∗)) ≤ 2n−ε, as required. (cid:3) A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 17 Corollary 5.5. For every ε > 0 there exists n0 ∈ N such that for all n > n0, the following holds. Define fε(n) := 104(1 + 2ε)n−2/3 log n and gε(n) := 104(1 + ε)n−2/7 log n. If fε(n) ≤ d ≤ 1 − gε(n), and (n, w) is a {0, 1}-instance of TSP with w(Kn) = d(cid:0)n (n, d, ε)-regular instance. least 1 − 2n−ε for (n, w). 2(cid:1) then (n, w) is an In particular Algorithm A has domination ratio at Proof. First assume fε(n) ≤ d ≤ 9 25 . From Definition 5.3, it is sufficient to exhibit an optimal matching M∗ of Kn for which w(M∗) ≤ 1 2 dn − mε(n, d). By Proposition 5.2 (note that d satisfies the condition of Proposition 5.2), there 2 dn− 1 16 dn− 1 exists an optimal matching M∗ of Kn such that w(M∗) ≤ 1 16 dn+1. Thus we see that w(M∗) ≤ 1 1 16 Now assume that 9 dn ≥ 40(ε + ε dn ≥ 40ε One can check that both inequalities hold if d ≥ fε(n). exhibit an optimal matching M∗ of Kn for which w(M∗) ≤ 1 Set d := 1 − d and note gε(n) ≤ d ≤ 16 optimal matching M∗ of Kn such that w(M∗) ≤ 1 that w(M∗) ≤ 1 25 ≤ d ≤ 1 − gε(n). From Definition 5.3, it is sufficient to 2 dn − mε(n, 1 − d). 25 . By Proposition 5.2, there exists an n + 1. Thus we see 2 2 dn − 1 8 d 1 1 2 d 4pn log n. 2 dn − mε(n, d) if 1 2 ) log n + 1 and 1 16 2 dn − mε(n, d) if n ≥ 40(ε + ε 2 d 1 16 1 2 ) log n + 1 and 2 d 1 16 n ≥ 40ε 1 2 d One can check that both inequalities hold if d ≥ gε(n). 1 4pn log n. (cid:3) We have seen in the previous corollary and theorem that Algorithm A has a large domination ratio for {0, 1}-instances of TSP when d is bounded away from 0 and 1, or when there exists an optimal matching of Kn whose weight is significantly smaller than the average weight of an optimal matching. The- orem 5.10 and Theorem 5.13 give polynomial-time TSP-domination algorithms for all remaining {0, 1}-instances. Before we can prove these, we require some preliminary results. Our first lemma is a structural stability result. Suppose G ⊆ Kn is a graph with d(cid:0)n 2(cid:1) edges, and let w be a weighting of Kn such that w(e) = 1 if e ∈ E(G) and w(e) = 0 otherwise. Then for a random optimal matching M of Kn, we have E(w(M )) = dn/2 if n is even and E(w(M )) = d(n − 1)/2 if n is odd; this shows that G has a matching of size at least d(n − 1)/2. We cannot improve much on this if d is close to zero: consider the graph H with a small set A ⊆ V (H) such that E(H) consists of all edges incident to A. The next lemma says that any graph whose largest matching is only slightly larger than dn/2 must be similar to the graph H described above. 18 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL Lemma 5.6. Fix an integer s ≥ 2 and let G be an n-vertex graph with e(G) = d(cid:0)n 2(cid:1) for some d ∈ (0, (4s)−1]. If the largest matching of G has at most 1 2 dn + r edges for some positive integer r < n/(8s), then G has a vertex cover D with d(n + 2) + sd2(n + 1) + (7s + 2)r. D ≤ Let 1 2 S := {v ∈ D : degG(v) ≤ sD}. Then S ≤ 2sd2(n + 1) + (14s + 4)r + 3d. Furthermore, D and S can be found in O(n4)-time. Proof. Let M∗ be any matching of G of maximum size and set m := e(M∗); hence 1 2 dn + r (the lower bound follows from the remarks before the statement of the lemma). Let U be the set of vertices of G incident to edges of M∗; thus d(n − 1) ≤ U = 2m ≤ dn + 2r and U is a vertex cover (by the maximality of M∗). Let 2 d(n − 1) ≤ m ≤ 1 We bound the size of A as follows. We have A := {u ∈ U : degG(u) ≤ 2sm} ⊆ U. degG(u) ≤ A2sm + U \ An = 2mn − A(n − 2sm) Rearranging gives d(cid:18)n 2(cid:19) = e(G) ≤ Xu∈U ≤ (dn + 2r)n − A(n − sdn − 2sr). A ≤ (1 − sd − 2sr/n)−1(cid:18)1 ≤ (1 + 2sd + 4sr/n)(cid:18) 1 2 2 dn + dn + 1 2 d + 2r(cid:19) d + 2r(cid:19) ; 1 2 1 2 2sdr + 8sr2 the last inequality follows by noting that (1 − x)−1 ≤ 1 + 2x for x ≤ 1 sd + 2sr/n ≤ 1 using that r ≤ n/(8s) gives 2 and that 2 (by our choices of s, r, d). Expanding the expression above, and 1 2 1 2 1 2 n 8sr2 d + sd2 + 2r + dn + sd2n + 6sdr + d(n + 2) + sd2(n + 1) + (7s + 2)r. d(n + 2) + sd2(n + 1) + (6sd + 2)r + A ≤ ≤ ≤ Let B := U \ A. Claim 1. No edge of M∗ lies in B. Indeed suppose e = xy is an edge of M∗ with x, y ∈ B. Then degG(x), degG(y) > 2sm ≥ U + 2 (since s ≥ 2). Hence there exist distinct x′, y′ ∈ V \ U such that xx′, yy′ ∈ E(G). Replacing e with the two edges xx′, yy′ in M∗ gives a larger matching, contradicting the choice of M∗. This proves the claim. n A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 19 Let C := {u ∈ A : uv ∈ E(M∗), v ∈ B}. By Claim 1, we have B = C and B, C are disjoint. Claim 2. There are no edges of G between C and V \ U , i.e. EG(C, V \ U ) = ∅. Indeed suppose e = xy ∈ E(G) with x ∈ C and y ∈ V \ U . By definition of C, there exists z ∈ B such that xz ∈ E(M∗). By the definition of B, degG(z) > 2sm ≥ U + 2, and so we can find z′ ∈ V \ U distinct from y such that zz′ ∈ E(G). Then we can replace xz with the two edges xy, zz′ in M∗ to obtain a larger matching, contradicting the choice of M∗. This proves the claim. Claim 3. C is an independent set. Indeed, suppose e = xy ∈ E(G) with x, y ∈ C. By definition of C, there exist x′, y′ ∈ B such that xx′, yy′ ∈ E(M∗). By definition of B, degG(x′), degG(y′) > 2sm ≥ U + 2, and so there exist distinct x′′, y′′ ∈ V \ U such that x′x′′, y′y′′ ∈ E(G). Now replace xx′, yy′ with xy, x′x′′, y′y′′ in M∗ to obtain a larger matching, contradicting the choice of M∗. This proves the claim. Set D := U \ C. First we check that D is a vertex cover; indeed note that V \ D = (V \ U ) ∪ C. But EG(V \ U ), EG(V \ U, C), and EG(C) are all empty using respectively the fact that U is a vertex cover, Claim 2, and Claim 3. Also, we have D = U − C = U − B = U \ B = A d(n + 2) + sd2(n + 1) + (7s + 2)r. 1 2 ≤ Finally, let S := {v ∈ D : degG(v) ≤ sD} ⊆ {v ∈ D : degG(v) ≤ sU} = A ∩ D. So, we have S ≤ A ∩ D = A + D − A ∪ D = A + D − U d(n + 2) + sd2(n + 1) + (7s + 2)r(cid:19) − d(n − 1) ≤ 2(cid:18) 1 2 = 2sd2(n + 1) + (14s + 4)r + 3d. Note that M∗ can be found in O(n4)-time by suitably adapting the minimum weight optimal matching algorithm (Theorem 2.1). From this, A, B, C, D, and S can all be constructed in O(n2)-time, as required. (cid:3) Next we give a polynomial-time algorithm for finding a maximum double matching in a bipartite graph: it is a simple consequence of the minimum weight optimal matching algorithm from Theorem 2.1. Given a bipartite graph G = (V, E) with vertex classes A and B, a double matching of G from A to B is a subgraph M = (V, E′) of G in which degM (v) ≤ 2 for all v ∈ A and degM (v) ≤ 1 for all v ∈ B. 20 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL Theorem 5.7. There exists an O(n4)-time algorithm which, given an n-vertex bipartite graph G with vertex classes A and B as input, outputs a double matching M∗ of G from A to B with e(M∗) = max M e(M ), where the maximum is over all double matchings of G from A to B. We call this algorithm the maximum double matching algorithm. Proof. Recall that the minimum weight optimal matching algorithm of The- orem 2.1 immediately gives an O(n4)-time algorithm for finding a maximum matching in a graph. Given G, define a new bipartite graph G′ by creating a copy a′ of each vertex a ∈ A so that a′ and a have the same neighbourhood. Note that every matching M′ of G′ corresponds to a double matching M of G by identifying each a ∈ A with its copy a′ and retaining all the edges of M′; hence e(M ) = e(M′). Therefore finding a double matching in G from A to B of maximum size is equivalent to finding a matching of G′ of maximum size, and we can use the minimum weight optimal matching algorithm of Theorem 2.1 to find such a matching. (cid:3) Next we prove a lemma that says that for a small subset S of vertices of Kn, almost all Hamilton cycles avoid S 'as much as possible'. Lemma 5.8. Fix ε ∈ (0, 1/2) and n ≥ 4. Let S ⊆ Vn be a subset of the vertices 2−ε. Let H ∈ Hn be of the n-vertex complete graph Kn = (Vn, En) with S ≤ n a uniformly random Hamilton cycle of Kn. Let E := E1 ∩ E2, where E1 is the event that H uses no edge of S and E2 is the event that eH(v, S) ≤ 1 for all v ∈ Vn \ S. Then 1 P(E) ≥ 1 − 6n−2ε. Proof. For each e ∈ En, we have P(e ∈ E(H)) = 2/(n − 1), and so (3) P(E1) = P(E(H) ∩ S(2) ≥ 1) ≤ E(E(H) ∩ S(2)) =(cid:18)S 2 (cid:19) 2 n − 1 ≤ 1 2 n1−2ε 2 n − 1 ≤ 2n−2ε. Let R be the random variable counting the number of vertices v ∈ Vn \ S such that eH (v, S) = 2. We have (4) P(E2) ≤ E(R) = Vn \ SP(eH (v, S) = 2) n2−2ε = Vn \ S S(S − 1) (n − 1)(n − 2) ≤ (n − 2)2 ≤ 4n−2ε. The lemma follows immediately from (3) and (4). (cid:3) A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 21 We are now ready to present a polynomial-time TSP-domination algorithm which has a large domination ratio for {0, 1}-instances of TSP in which w(Kn) = d(cid:0)n 2(cid:1) with d close to 1 and in which all optimal matchings have weight close to dn/2. Let us first formalise this in a definition. Definition 5.9. For n ≥ 4 a positive integer, r > 0, d ∈ [0, 1], and ε ∈ (0, 1/2) we call a {0, 1}-instance (n, w) of TSP an (n, d, r, ε)-dense instance if (i) w(Kn) = d(cid:0)n (ii) w(M ) ≥ 1 (iii) 6d 2 2(cid:1) with 1 − d ≤ 1/12; 2 dn − r for all optimal matchings M of Kn; and 1 (n + 1) + 46r + 3d ≤ n 2−ε, where d := 1 − d. Theorem 5.10. There exists an O(n4)-time TSP-domination algorithm which has domination ratio at least 1 − 6n−2ε for all (n, d, r, ε)-dense instances (n, w) of TSP. We call this Algorithm B. 2. Using the algorithm of Lemma 5.6 (with s = 3), find a vertex cover D Proof. We begin by describing Algorithm B in steps with the running time of each step in brackets. We then explain each step. Let (n, w) be a (n, d, r, ε)- dense instance of TSP and let G = (Vn, E) ⊆ Kn be the graph in which we have e ∈ E if and only if w(e) = 0. We set V := Vn in order to reduce notational clutter. 2(cid:1), where d := 1− d. (O(n2) time) 1. Construct G and note that e(G) = d(cid:0)n for G such that D ≤ 1 3. Construct the bipartite graph G′ := G[D, V \ D]. (O(n2) time) 4. Apply the maximum double matching algorithm (Theorem 5.7) to G′ to obtain a double matching M∗ of G′ from D to V \ D of maximum size. (O(n4)-time). 5. Extend M∗ arbitrarily to a Hamilton cycle H∗ of Kn (i.e. choose H∗ to be any Hamilton cycle of Kn that includes all the edges of M∗). (O(n) time) (n + 1) + 23r. (O(n4) time) 2 d(n + 2) + 3d 2 Altogether, the running time of the algorithm is O(n4). Note that in Step 2, the conditions of Lemma 5.6 are satisfied by (n, d, r, ε)-dense instances of TSP. Also the algorithm of Lemma 5.6 gives us the set S = {v ∈ D : degG(v) ≤ 3D}, 2 where S ≤ 6d of Algorithm B. (n + 1) + 46r + 3d ≤ n 1 2−ε, which we shall require in the analysis Next we show that this algorithm has domination ratio at least 1 − 6n−2ε for (n, w) by showing that for a uniformly random Hamilton cycle H ∈ Hn, we 2−ε, we can apply Lemma 5.8 have P(w(H) < w(H∗)) ≤ 6n−2ε. Since S ≤ n to conclude that P(E) ≥ 1 − 6n−2ε, where E := E1 ∩ E2 with E1 being the event that H uses no edge of S and E2 being the event that eH(v, S) ≤ 1 for all v ∈ V \ S. We show that if H is any 1 22 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL Hamilton cycle in E ⊆ Hn then w(H∗) ≤ w(H), i.e. P(w(H) < w(H∗) E) = 0. (5) Assuming (5), we can prove the theorem since P(w(H) < w(H∗)) = P(w(H) < w(H∗) E)P(E) + P(w(H) < w(H∗) E)P(E) ≤ 0 + P(E) ≤ 6n−2ε, as required. In order to verify (5), it is sufficient to show that E(H∗) ∩ E(G) ≥ E(H) ∩ E(G) for all H ∈ E. Claim. L := E(M∗) ∩ EG(S, V \ D) is a maximum-sized double matching of G[S, V \ D] from S to V \ D. Suppose, for a contradiction, that there is some double matching L′ of G[S, V \D] from S to V \ D with more edges than L. Then since every vertex of D \ S has degree at least 3D in G, we can greedily extend L′ to a double matching M∗∗ of G[D, V \ D] such that in M∗∗, every vertex of D \ S has degree 2. Hence e(M∗∗) = e(L′) + 2D \ S > e(L) + 2D \ S ≥ e(M∗), contradicting the maximality of M∗. This proves the claim. Now for H ∈ E ⊆ Hn, we have that E(H) ∩ EG(S, V \ D) is a double matching of G[S, V \ D] from S to V \ D. Hence by the claim and the definition of H∗ (6) E(H)∩EG(S, V \D) ≤ E(M∗)∩EG(S, V \D) ≤ E(H∗)∩EG(S, V \D). Writing DS := D \ S, we have that E(H) ∩ E(G) = [E(H) ∩ EG(DS, V )] ∪ [E(H) ∩ EG(V \ DS)] = [E(H) ∩ EG(DS, V )] ∪ [E(H) ∩ EG(S, V \ D)]. Now we see that E(H) ∩ E(G) ≤ 2DS + E(H) ∩ EG(S, V \ D). Also note that eH ∗ (v, V \ D) = eM ∗(v, V \ D) = 2 for all v ∈ DS since M∗ is maximal and vertices in DS have degree at least 3D in G. Hence E(H∗) ∩ E(G) ≥ 2DS + E(H∗) ∩ EG(S, V \ D). But now (6) implies E(H∗) ∩ E(G) ≥ E(H) ∩ E(G), as required. (cid:3) Finally we provide a TSP-domination algorithm that has a large domina- tion ratio for sparse {0, 1}-instances of TSP. Before we do this, we require one subroutine for our algorithm. Lemma 5.11. There exists an O(n3)-time algorithm which, given an n-vertex graph G with δ(G) ≥ n/2 + 3 2 k and k independent edges e1, . . . , ek, outputs a Hamilton cycle H∗ of G such that e1, . . . , ek ∈ E(H∗). A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 23 The proof of this lemma is a simple adaptation of the proof of Dirac's theorem, but we provide the details for completeness. A threshold of n/2+k/2 was proved by Pósa [24], but it is not clear whether the proof is algorithmic. Proof. Let ei = xiyi, and set S := {x1, . . . , xk, y1, . . . , yk} so that S = 2k. By the degree condition of G, every pair of vertices have at least 3k common neighbours and so G is 3k-connected. In particular, we can pick distinct vertices z1, . . . , zk−1 ∈ V (G)\S such that zi is a common neighbour of yi and xi+1. Hence P := x1y1z1x2y2z2 ··· zk−1xkyk is a path of G containing all the edges e1, . . . , ek. This can be found in O(nk) time. We say any path or cycle Q is good if it contains all the edges e1, . . . , ek; in particular P is good. We show that if Q is a good path or cycle with V (Q) < n or e(Q) < n, then we can extend Q to a good path or cycle Q′ such that either V (Q′) > V (Q) or e(Q′) > e(Q). If Q is a good cycle with V (Q) < n, then since G is 3k-connected, there is some vertex c ∈ V (G) \ V (Q) that is adjacent to some b ∈ V (Q). Let a and a′ be the two neighbours of b on Q. Since e1, . . . , ek are independent edges, either ab or a′b, say ab, is not amongst e1, . . . , ek. Thus we can extend Q to the good path Q′ := aQbc, and we see V (Q′) = V (Q) + 1. This takes O(n2) time. Now suppose Q is a good path with end-vertices a and b, i.e. Q = aQb, and one of the end-vertices, say b, has a neighbour c in V (G)\V (Q). Then we can extend Q to a good path Q′ := aQbc, and V (Q′) > V (Q). Checking whether we are in this case and obtaining Q′ takes O(n) time. Finally suppose Q is a good path with end-vertices a and b, but where a and b have all their neighbours on Q. Since a and b have at least n/2 + 3 2 k neighbours, there are at least 3k edges xx+ ∈ E(Q), where Q = aQxx+Qb and ax+, xb ∈ E(G). Thus there are at least 2k such edges that are not one of e1, . . . , ek; let xx+ be such an edge. Then Q′ := ax+QbxQa is a cycle with e(Q′) > e(Q). Checking whether we are in this case and obtaining Q′ takes O(n) time. Thus extending P at most 2n times as described above gives us a Hamilton (cid:3) cycle, and the running time of the algorithm is dominated by O(n3). 2(cid:1) with d ≤ 1 Definition 5.12. For 0 < ε < 1/2, we call a {0, 1}-instance (n, w) of TSP a (n, d, ε)-sparse instance if w(Kn) = d(cid:0)n Theorem 5.13. Fix 0 < ε < 1/2. There exists an O(n4)-time TSP-domination algorithm which has domination ratio at least 1 − 6n−2ε for any (n, d, ε)-sparse instance of TSP with n ≥ 225. We call this Algorithm C. Proof. Assume n ≥ 225 and let (n, w) be an (n, d, ε)-sparse instance of TSP so that w(Kn) = d(cid:0)n 2−ε. Let G = (Vn, E) be the graph where e ∈ E if and only if w(e) = 0. We write G for the complement of G. Let 2(cid:1) with d ≤ 1 S := {v ∈ Vn : degG(v) ≤ 2n/3}, and let S := V \ S. 4 n− 1 2−ε. 4 n− 1 24 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL 1 2−ε. Claim. We have S ≤ n In G, we have that S = {v ∈ Vn : degG(v) ≥ (n/3) − 1}. Then 2(cid:19) ≤ 1 n 8 3 − 1(cid:17) ≤ e(G) = d(cid:18)n 2S(cid:16) n 2−ε(cid:18)n 2(cid:19) ≤ 1 which implies the required bounds. n− 1 1 4 3 2−ε, We note for later that (7) δ(G[S]) ≥ 2 3 n − S ≥ 2 3 n − n 1 2−ε ≥ 1 2 n + 3 2 n 1 2−ε ≥ 1 2 n + 3 2S. where the penultimate inequality follows since n ≥ 225. brackets; we then elaborate on each step below. We now describe the steps of our algorithm with the run time of each step in 1. Construct G. (O(n2) time) 2. Obtain the set S ⊆ Vn as defined above. (O(n2) time) 3. Construct G′ := G[S, S]. (O(n2) time) 4. Apply the maximum double matching algorithm (Theorem 5.7) to G′ to obtain a double matching M∗ of G′ from S to S of maximum size. (O(n4) time) (2) . (O(n) time) 5. Arbitrarily extend M∗ to a maximum double matching M∗∗ of Kn[S, S] from S to S, i.e. degM ∗∗(v) = 2 for all v ∈ S, degM ∗∗(v) ≤ 1 for all v ∈ S, and E(M∗) ⊆ E(M∗∗). (O(n2) time) 6. For each v ∈ S, determine its two neighbours xv, yv ∈ S in M∗∗, and let ev := xvyv ∈ S 7. Apply the algorithm of Lemma 5.11 to obtain a Hamilton cycle H∗ of G[S] ∪ {ev : v ∈ S} that includes all edges {ev : v ∈ S}. (O(n3) time) to obtain a Hamilton cycle H∗∗ of Kn. (O(n) time) 8. Replace each edge ev = xvyv in H∗ by the two edges vxv, vyv ∈ E(M∗∗) Note that the edges ev determined in Step 6 are independent because M∗∗ is a double matching. This together with (7) means that we can indeed apply the algorithm of Lemma 5.11 in Step 7. Altogether, the algorithm takes O(n4) time. Finally, let us verify that the algorithm above gives a domination ratio of at least 1− 6n−2ε by showing that for a uniformly random Hamilton cycle H ∈ Hn, we have P(w(H) < w(H∗∗)) ≤ 6n−2ε. As in the proof of Theorem 5.10, it suffices to show P(w(H) < w(H∗∗) E) = 0, (8) where E := E1 ∩ E2 with E1 being the event that H uses no edge of S and E2 being the event that eH(v, S) ≤ 1 for all v ∈ Vn \ S. In order to verify (8), it suffices to show that E(H∗∗)∩E(G) ≥ E(H)∩E(G) for all H ∈ E ⊆ Hn. Assuming H ∈ E, note that E(H) ∩ EG(S, S) is a double matching of G[S, S] from S to S; hence by the definition of M∗ and H∗∗, we have E(H) ∩ EG(S, S) ≤ E(M∗) = E(H∗∗) ∩ EG(S, S). A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 25 Also E(H∗∗) ∩ EG(S) = n − 2S = E(H) ∩ EG(S). Using these two inequalities and the fact that E(H) ∩ E(S(2)) = E(H∗∗) ∩ E(S(2)) = ∅ (since H, H∗∗ ∈ E) we have E(H) ∩ E(G) = E(H) ∩ EG(S) + E(H) ∩ EG(S, S) ≤ E(H∗∗) ∩ EG(S) + E(H∗∗) ∩ EG(S, S) = E(H∗∗) ∩ E(G), as required. (cid:3) Finally we show that we can combine our three algorithms to give a complete algorithm for arbitrary {0, 1}-instances of TSP. Lemma 5.14. Let ε := 1 instance of TSP with n > n0 and w(Kn) = d(cid:0)n 28 . There exists n0 such that if (n, w) is a {0, 1}- 2(cid:1) for some d ∈ [0, 1], then either (n, w) is (n, d, ε)-regular or (n, d, ε)-sparse or (n, d, r, ε)-dense (for some r). Furthermore, we can decide in O(n4) time which of the three cases hold (and also determine a suitable value of r in the third case). Proof. We choose n0 ∈ N sufficiently large for our estimates to hold. Assume that (n, w) is a {0, 1}-instance of TSP with n > n0 which is not (n, d, ε)-regular. By Corollary 5.5, we either have d < 104(1 + 2ε)n− 2 3 log n or d := 1 − d < 104(1 + ε)n− 2 7 log n. (n, d, ε)-sparse. Assuming the former, we have d ≤ 1 The only remaining possibility is that d < 104(1 + ε)n− 2 In addi- tion, since (n, w) is not (n, d, ε)-regular, we may assume that, for every optimal matching M of Kn, we have 2−ε for n > n0. Thus (n, w) is 7 log n. 4 n− 1 w(M ) ≥ 1 2 dn − mε(n, d), 4√n log n. Setting where we recall that mε(n, d) = 40(ε + ε r := mε(n, d), we now verify that (n, w) is (n, d, r, ε)-dense to complete the proof. 1 2 ) log n + 40ε 1 2 d 1 Parts (i) and (ii) of Definition 5.9 clearly hold. For part (iii) note that r = mε(n, d) ≤ 40 log n + 40d 2 and that 6d bounds, we have (n + 1) ≤ 109(1 + ε)2n 1 4pn log n ≤ 40 log n + 40 · 10(1 + ε)n 3 7 log n ≤ 500n 3 7 log n, 7 log2 n ≤ 2 · 109n 3 3 7 log2 n. Using these 2 6d (n + 1) + 46r + 3d ≤ 3 · 109n 3 7 log2 n ≤ n 1 2−ε, provided that n0 is sufficiently large. 26 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL For ε = 1/28 and n ≥ n0, one can determine in O(n4) time whether (n, w) satisfies Definition 5.3, 5.9, or 5.12; one simply needs to determine w(Kn) and an optimal matching of minimum weight using Theorem 2.1. (cid:3) Finally, we can prove our main result Proof of Theorem 1.1. Given an instance (n, w) with n > n0 and w(Kn) = d(cid:0)n 2(cid:1) for some d ∈ [0, 1], Lemma 5.14 tells us that (n, w) is either (n, d, ε)- regular or (n, d, r, ε)-dense (for some r) or (n, d, ε)-sparse, where ε = 1/28. Furthermore, we can determine which case holds in O(n4) time. We accordingly apply Algorithm A, B, or C, and by Theorem 5.4, 5.10, or 5.13 respectively, we achieve a domination ratio of at least 1−max{2n−ε, 6n−2ε} ≥ 1−6n−1/28. (cid:3) 6. Hardness Results In this section we give upper bounds on the possible domination ratio of a polynomial-time TSP-domination algorithm for {0, 1}-instances, assuming ei- ther P 6= N P or the Exponential Time Hypothesis. This is achieved by a simple reduction from the Hamilton path problem to the algorithmic TSP-domination problem for {0, 1}-instances. Our reduction uses an idea from [12], where a result similar to Theorem 1.3(a) was proved, but for general TSP rather than {0, 1}-instances of TSP. The Hamilton path problem is the following algorithmic problem: given an instance (n, G), where n is a positive integer and G is an n-vertex graph, deter- mine whether G has a Hamilton path. This problem is NP complete [10], which implies Theorem 6.1(a). The Exponential Time Hypothesis [17] states that the 3-satisfiability problem (3-SAT) cannot be solved in subexponential time. It would imply that there is no exp(o(n))-time algorithm to solve 3-SAT, where n is the number of clauses of an input formula. Since 3-SAT can be reduced to the Hamilton path problem in polynomial time (and space), this gives us Theorem 6.1(b). Theorem 6.1. algorithm. (a) If P 6= N P , then the Hamilton path problem has no polynomial-time (b) There is some ε0 > 0 such that, if the Exponential Time Hypothesis holds, then there is no algorithm that solves the Hamilton path problem for all instances (n, G) in time exp(o(nε0)). We can use Theorem 6.1 to obtain the hardness result Theorem 1.3 for TSP- domination ratios. Proof of Theorem 1.3. For part (a), we give a polynomial-time reduction from the Hamilton path problem. Suppose D is a polynomial-time TSP-domination algorithm with domination ratio at least 1−exp(−nε) i.e., given a {0, 1}-instance of (n, w) of TSP, D outputs a Hamilton cycle H∗ such that {H : w(H) < w(H∗)} ≤ exp(−nε)Hn. A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 27 We show that we can use D to determine whether any graph G has a Hamil- ton path in time polynomial in V (G), contradicting Theorem 6.1(a). Assume G is an n-vertex graph and let G be its complement. Choose n′ such that ⌊n′ε/ log n′⌋ = n; thus n′ is bounded above by a polynomial in n. Consider the n′-vertex graph G′ = (V ′, E′) obtained from G by first partitioning V ′ into two sets S, S with S = n and S = n′ − n, and setting G′[S] to be isomorphic to G, setting G′[S] to be empty, and setting G′[S, S] to be the complete bipartite graph between S and S. We define an instance (n′, w) of TSP where the edge weighting w of Kn′ ⊇ G′ = (V ′, E′) is given by w(e) = 1 for each e ∈ E′ and w(e) = 0 for e 6∈ E′. Applying D to (n′, w), we obtain a Hamilton cycle H∗ of Kn′ in time polyno- mial in n′ (which is therefore polynomial in n). We claim that G has a Hamilton path if and only if w(H∗) = 2, and this proves Theorem 1.3(a). To see the claim, first assume that w(H∗) = 2. Note that for any H ∈ Hn′, we have w(H[S, S]) ≥ 2, and if we have equality, then H[S] is a Hamilton path of Kn′[S] (and H[S] is a Hamilton path of Kn′[S]). Since w(H∗) = 2, we have w(H[S, S]) = 2 and w(H∗[S]) = 0. Thus H∗[S] is a Hamilton path of Kn′[S] and every edge of H∗[S] is an edge of G. Hence G has a Hamilton path. To see the claim in the other direction, suppose G has a Hamilton path P and consider the set HP of all Hamilton cycles H of Kn′ such that H[S] = P . Note that w(H) = 2 for all H ∈ HP and that (9) HP = (n′ − n)! = 2[(n′ − 1)··· (n′ − n + 1)]−1Hn′ ≥ 2(n′)−nHn′ = 2 exp(−n log n′)Hn′ > exp(−n′ε)Hn′; the last inequality follows by our choice of n′. Since D has domination ratio at least 1 − exp(−n′ε) for (n′, w), D must output a Hamilton cycle H∗ with w(H∗) = 2. This proves the claim and completes the proof of (a). The proof of (b) follows almost exactly the same argument as above. Set 0 + 2, where ε0 is as in the statement of Theorem 6.1(b), and set C := 2ε−1 β(n) := exp(−(log n)C). {0, 1}-instance of (n, w) of TSP, outputs a Hamilton cycle H∗ such that Suppose D is an O(nk)-time algorithm (for some k ∈ N) which, given a {H : w(H) < w(H∗)} ≤ β(n)Hn. We show that we can use D to determine whether any n-vertex graph G has a Hamilton path in time exp(o(nε0)), contradicting Theorem 6.1(b). We set n′ := ⌈exp(nε0/2/k)⌉ and apply D to the n′-vertex graph G′ constructed in the same way as in part (a). The algorithm takes time O(n′k) = exp(o(nε0)) and the proof of the claim proceeds in the same say as in part (a), except that (9) is replaced by HP > β(n′)Hn′. (cid:3) 28 DANIELA KÜHN, DERYK OSTHUS AND VIRESH PATEL 7. Concluding remarks and an open problem In view of Theorem 1.1, it is natural to ask whether there exists a poly- nomial-time TSP-domination algorithm with domination ratio 1 − o(1) for gen- eral instances of TSP. Below we discuss some of the challenges which this would involve. Note that the average weight of a perfect matching in a weighted complete graph Kn is w(Kn)/(n − 1). For instances (n, w) of TSP for which there exists a perfect matching M∗ of Kn with w(M∗) 'significantly' smaller than w(Kn)/(n − 1), our techniques immediately imply that Algorithm A gives a large domination ratio. We call these typical instances. However instances of TSP where all perfect matchings have approximately the same weight (after some suitable normalisation) need to be treated separately, and we call these special instances. For weights in {0, 1}, there are essentially two different types of special instances: either most edges have weight 0 or most edges have weight 1. Even then, some additional ideas were needed to treat the special instances. If we allow weights in [−1, 1], there are many different types of special instances and the challenge is to find a way to treat all of these cases simultaneously. As an example of a special instance, consider a weighting of Kn where we take S ⊆ Vn with S close to n/2 and set w(e) := 1 if e ∈ S(2), w(e) := −1 if e ∈ S , and w(e) := 0 if e ∈ E(S, S). Then any perfect matching has weight close to zero. (2) References [1] N. Alon, G. Gutin and M. Krivelevich, Algorithms with large domination ratio, J. Algo- rithms 50 (2004), 118 -- 131. [2] S. Arora, Polynomial time approximation schemes for Euclidean traveling salesman and other geometric problems, J. ACM 45 (1998), 753 -- 782. [3] D. Berend, S. Skiena, Y. Twitto, Combinatorial dominance guarantees for problems with infeasible solutions, ACM Transactions on Algorithms 5 (2008), article 8. [4] N. Christofides, Worst-case analysis of a new heuristic for the traveling salesman problem, Technical Report 388, GSIA, Carnegie-Mellon University, 1976. [5] J. Edmonds, Maximum matching and a polyhedron with 0, 1-vertices, Journal of Research of the National Bureau of Standards 69B (1965), 125 -- 130. [6] P. Erdős, A problem on independent r-tuples, Ann. Univ. Sci. Budapest. Eőtvős Sect. Math. 8 (1965), 93 -- 95. [7] P. Erdős, T. Gallai, On maximal paths and circuits of graphs, Acta Math. Acad. Sci. Hung. 10 (1959), 337 -- 356. [8] P. Erdős and J.L. Selfridge, On a combinatorial game, Journal of Combinatorial Theory, Series A 14 (1973), 289 -- 301. [9] P. Erdős and J. Spencer, The Probabilistic Method (2nd edition), Wiley-Interscience 2000. [10] M.R. Garey and D.S. Johnson, Computers and Intractability: A Guide to the Theory of NP-completeness, Freeman 1979. [11] F. Glover and A.P. Punnen, The traveling salesman problem: new solvable cases and linkages with the development of approximation algorithms, Journal of the Operational Research Society 8 (1997), 502 -- 510. [12] G. Gutin, A. Koller and A. Yeo, Note on upper bounds for TSP domination number, J Algorithmic Oper. Res. 1 (2006), 52 -- 54. [13] G. Gutin, A. Vainshtein and A. Yeo, Domination analysis of combinatorial optimization problems. Discrete Applied Mathematics 129 (2003), 513 -- 520. A DOMINATION ALGORITHM FOR {0, 1}-INSTANCES OF TSP 29 [14] G. Gutin and A. Yeo, TSP tour domination and Hamilton cycle decompositions of regular digraphs, Oper. Res. Letters 28 (2001), 107 -- 111. [15] G. Gutin and A. Yeo, Polynomial approximation algorithms for the TSP and QAP with a factorial domination number, Discrete Applied Mathematics 119 (2002), 107 -- 116. [16] G. Gutin, A. Yeo and A. Zverovich, Traveling salesman should not be greedy: domination analysis of greedy-type heuristics for the TSP, Discrete Applied Mathematics 117 (2002), 81 -- 86. [17] R. Impagliazzo and R. Paturi, On the complexity of k-sat, J. Comput. Syst. Sci. 62 (2001), 367 -- 375. [18] A.E. Koller and S.D. Noble, Domination analysis of greedy heuristics for the frequency assignment problem, Discrete Mathematics 275 (2004), 331 -- 338. [19] D. Kühn and D. Osthus, Hamilton decompositions of regular expanders: a proof of Kelly's conjecture for large tournaments, Advances in Mathematics 237 (2013), 62 -- 146. [20] C. McDiarmid, Concentration, Probabilistic methods for algorithmic discrete mathematics, 195 -- 248, Algorithms, Combin., 16, Springer, Berlin, 1998. [21] J. Mitchell, Guillotine subdivisions approximate polygonal subdivisions: A simple polynomial-time approximation scheme for geometric TSP, k-MST, and related problems, SIAM J. Comput. 28 (1999), 1298 -- 1309. [22] R. Motwani and P. Raghavan, Randomized Algorithms, Cambridge University Press, 1995. [23] C. H. Papadimitriou and S. Vempala, On the approximability of the traveling salesman problem, Combinatorica 26 (2006), 101 -- 120 [24] L. Pósa, On the circuits of finite graphs, Publ. Math. Inst. Hungar. Acad. Scien. 9 (1963), 355 -- 361. [25] A.P. Punnen, F. Margot and S.N. Kabadi, TSP heuristics: domination analysis and complexity, Algorithmica 35 (2003), 111 -- 127. [26] V.I. Rublineckii, Estimates of the accuracy of procedures in the traveling salesman prob- lem, Numerical Mathematics and Computer Technology 4 (1973), 18 -- 23. (in Russian) [27] V.I. Sarvanov, On the minimization of a linear form on a set of all n-elements cycles, Vestsi Akad. Navuk BSSR, Ser. Fiz.-Mat. Navuk 4 (1976), 17 -- 21. (in Russian) [28] S. Sahni and T. Gonzalez, P-complete approximation problems, J. Assoc. Comput. Mach. 23 (1976), 555 -- 565. Daniela Kühn, Deryk Osthus, Viresh Patel School of Mathematics University of Birmingham Edgbaston Birmingham B15 2TT UK E-mail addresses: {d.kuhn, d.osthus}@bham.ac.uk, [email protected]
1911.12138
1
1911
2019-11-26T05:03:39
Scheduling with Non-Renewable Resources: Minimizing the Sum of Completion Times
[ "cs.DS", "cs.DM" ]
The paper considers single-machine scheduling problems with a non-renewable resource. In this setting, we are given a set jobs, each of which is characterized by a processing time, a weight, and the job also has some resource requirement. At fixed points in time, a certain amount of the resource is made available to be consumed by the jobs. The goal is to assign the jobs non-preemptively to time slots on the machine, so that at any time their resource requirement does not exceed the available amounts of resources. The objective that we consider here is the minimization of the sum of weighted completion times. We give polynomial approximation algorithms and complexity results for single scheduling machine problems. In particular, we show strong NP-hardness of the case of unit resource requirements and weights ($1|rm=1,a_j=1|\sum C_j$), thus answering an open question of Gy\"orgyi and Kis. We also prove that the schedule corresponding to the Shortest Processing Time First ordering provides a $3/2$-approximation for the same problem. We give simple constant factor approximations and a more complicated PTAS for the case of $0$ processing times ($1|rm=1,p_j=0|\sum w_jC_j$). We close the paper by proposing a new variant of the problem in which the resource arrival times are unknown. A $4$-approximation is presented for this variant, together with an $(4-\varepsilon)$-inapproximability result.
cs.DS
cs
Scheduling with Non-Renewable Resources: Minimizing the Sum of Completion Times∗ Simon Omlor§ Krist´of B´erczi† Tam´as Kir´aly‡ November 28, 2019 Abstract 9 1 0 2 v o N 6 2 ] S D . s c [ 1 v 8 3 1 2 1 . 1 1 9 1 : v i X r a The paper considers single-machine scheduling problems with a non-renewable resource. In this setting, we are given a set jobs, each of which is characterized by a processing time, a weight, and the job also has some resource requirement. At fixed points in time, a certain amount of the resource is made available to be consumed by the jobs. The goal is to assign the jobs non-preemptively to time slots on the machine, so that at any time their resource requirement does not exceed the available amounts of resources. The objective that we consider here is the minimization of the sum of weighted completion times. We give polynomial approximation algorithms and complexity results for single schedul- ing machine problems. In particular, we show strong NP-hardness of the case of unit re- source requirements and weights (1rm = 1, aj = 1(cid:80) Cj), thus answering an open question times (1rm = 1, pj = 0(cid:80) wjCj). We close the paper by proposing a new variant of the of Gyorgyi and Kis. We also prove that the schedule corresponding to the Shortest Process- ing Time First ordering provides a 3/2-approximation for the same problem. We give simple constant factor approximations and a more complicated PTAS for the case of 0 processing problem in which the resource arrival times are unknown. A 4-approximation is presented for this variant, together with an (4 − ε)-inapproximability result. Keywords: Scheduling, Non-renewable resources, Weighted sum of completion times, Po- lynomial-time approximation scheme, Approximation algorithm, Strong NP-hardness 1 Introduction The problem of scheduling with non-renewable resources appears naturally in practical problems where resources like raw materials, energy, or financial constraints are taken into account. These problems are interesting both from the practical and from the theoretical point of view. In the general setting, we are given a set of jobs and a set of machines. Each job is equipped with a requirement vector that encodes the needs of the given job for the different types of resources. There is an initial stock for each resource, and some additional resource arrival times in the future are known together with the arriving quantities. The aim is to find a schedule of the jobs on the machines such that the resource requirements are met. ∗Supported by DAAD with funds of the Bundesministerium fur Bildung und Forschung (BMBF) and by DFG project MN 59/4-1. †MTA-ELTE Egerv´ary Research Group, Department of Operations Research, Eotvos Lor´and University, Bu- dapest, Hungary. Email: [email protected]. ‡MTA-ELTE Egerv´ary Research Group, Department of Operations Research, Eotvos Lor´and University, Bu- §TU Hamburg, Institute for Algorithms and Complexity, Hamburg, Germany. Email: [email protected]. dapest, Hungary. Email: [email protected]. 1 We will use the standard αβγ notation of Graham, Lawler, Lenstra and Kan [4]. Grigoriev, Holthuijsen and Van De Klundert [5] extended this notation by adding the restriction rm = r to the β field, meaning that there are r resources (raw materials). In the present paper, we concentrate on problem 1rm = 1(cid:80) wjCj, that is, when we have a single machine, a single resource, and the goal is to minimize the weighted sum of completion times. While there is a long list of results on the approximability of the makespan objective, much less is known about the complexity and approximability of the total weighted completion time objective. sense. This was also proved independently by Gafarov, Lazarev and Wener in [2]. Kis [12] showed that the problem remains weakly NP-hard even when the number of resource arrival Previous work Scheduling problems with resource restrictions were introduced by Carlier [1] and Slowinski [13]. Carlier settled the computational complexity of several variants for the sinlge machine case [1]. In particular, it was shown that 1rm = 1(cid:80) wjCj is NP-hard in the strong times is 2. On the positive side, he gave an FPTAS for 1rm = 1, q = 2(cid:80) wjCj. A variant such that ti = iM and bi = M for i = 1, . . . , n, and M = (cid:80) of the problem where each job has processing time 1, there are q = n resource arrival times j∈J aj/n is an integer, was considered in [2]. Recently, Gyorgyi and Kis [11] gave polynomial time algorithms for several special cases, and also showed that the problem remains weakly NP-hard even under the very strong assumption that the processing time, the resource requirement and the weight are the same for each job. They also provided a 2-approximation algorithm for this variant, and a polynomial-time approximation scheme (PTAS) when the number of resource arrival times is a constant and the processing time equals the weight for each job, while the resource requirements are arbitrary. In contrast to the case of total weighted completion objective, much is known about schedul- ing problems with non-renewable resources for the maximum makespan and maximum lateness objectives. Slowinski [13] studied the preemptive scheduling of independent jobs on parallel unrelated machines with the use of additional renewable and non-renewable resources under financial constraints. Toker, Kondakci and Erkip [14] examined a single machine scheduling problem under non-renewable resource constraint, using the makespan as a performance crite- rion. Xie [15] generalized this result to the problem with multiple financial resource constraints. Grigoriev, Holthuijsen and Van De Klundert [5] presented polynomial time algorithms, ap- proximations and complexity results for single scheduling machine problems with unit or all equal processing times, and maximum lateness and makespan objectives. In a series of pa- pers [6, 7, 8, 9, 10], Gyorgyi and Kis presented approximation schemes and inapproximability results both for single and parallel machine problems with the makespan and the maximum lateness objectives. In [11], they proposed a bracnh-and-cut algorithm for minimizing the max- imum lateness. Our results The first problem that we consider is 1rm = 1, aj = 1(cid:80) Cj. The complexity Theorem 1. 1rm = 1, aj = 1(cid:80) Cj is strongly NP-hard. of this problem was posed as an open question in [11]. We show that the problem is NP-hard in the strong sense. In the light of Theorem 1, one might be interested in finding an approximation algorithm for the problem. Given any scheduling problem on a single machine, the Shortest Processing Time First (SPT) schedule orders the jobs by processing times, i.e. pspt−1(i) ≤ pspt−1(i+1) for all i. We prove that spt provides a 3/2-approximation. Although the algorithm is merely scheduling according to the SPT order, the analysis if the algorithm is rather involved. 2 Theorem 2. The SPT schedule gives a 3 approximation guarantee is tight. 2 -approximation for 1rm = 1, aj = 1(cid:80) Cj, and the The second problem considered is the special case when the processing time is 0 for every job. This setting is a relaxation of those instances where the processing times are short and the resource arrival times are far away from each other. First we give a 6-approximation based on a non-trivial greedy approach. Theorem 3. There exists a 6-approximation for 1rm = 1, pj = 0(cid:80) Cjwj with running time O(n log(n)). portant ideas of the general PTAS. We give a slightly more complicated (4 + ε)-approximation that illustrates one of the im- Theorem 4. There exists a (4 + ε)-approximation for 1rm = 1, pj = 0(cid:80) Cjwj with running time polynomial in 1/ε and the input length. As a next step toward an efficient approximation algorithm, we present a PTAS for the case of a constant number of resource arrival times. This procedure will be used as a subroutine in our algorithm for the general case. k )-approximation for 1rm = 1, pj = 0(cid:80) Cjwj with running Theorem 5. There exists an (1 + q time O(nqk+1). number of resource arrival times. Finally, we prove the main result of the paper, which is a PTAS for the case of an arbitrary Theorem 6. There exists a PTAS for 1rm = 1, pj = 0(cid:80) Cjwj. The last problem that we is another variant of 1rm = 1, pj = 0(cid:80) Cjwj where the arrival times are unknown. We denote this problem by 1rm = 1, pj = 0, ti unkown(cid:80) Cjwj. Theorem 7. There exists a (4+ε)-approximation for 1rm = 1, pj = 0, ti unkown(cid:80) Cjwj with running time polynomial in 1/ε and the input length. Moreover, there is no (4−ε)-approximation algorithm for the problem for any ε > 0. Organization The rest of the paper is organized as follows. Basic notation and terminology are introduced in Section 2. A strong NP-hardness proof and a 3/2-approximation algorithm for problem 1rm = 1, aj = 1(cid:80) Cj are given in Section 3. Results on problem 1rm = 1, pj = 0(cid:80) Cj are discussed in Section 4, where a greedy 6-approximation, a (4 + ε)-approximation, a PTAS for the case of constant resource arrival times, and a PTAS for the general case are presented. We close the paper by proposing a new variant of the problem in which the resource arrival times are unknown. A 4-approximation is presented for this case, together with an (4 − ε)-inapproximability result. 2 Preliminaries that arrives at time point ti is denoted by bi. We might assume that (cid:80)q Throughout the paper, we will use the following notation. We are given a set J of n jobs. Each job j ∈ J has a non-negative integer processing time pj, a non-negative weight wj, and a resource requirement aj. The resources arrive at time points t1, . . . , tq, and the amount of resource j=1 aj holds. We will always assume that t1 = 0, as this does not effect the approximation ratio of our algorithms. i=1 bi =(cid:80)n 3 The jobs should be processed non-preemptively on a single machine. A schedule is an ordering of the jobs, that is, a mapping σ : J → [n], where σ(j) = i means that job j is the ith job scheduled on the machine. The completion time of job j in schedule σ is denoted by Cσ j . We will drop the index σ if the schedule is clear from the context. In any reasonable schedule, there is an idle time before a job j only if there is not enough resource left to start j after finishing the last job before the idle period. Hence the completion time of job j is basically determined by the ordering and by the resource arrival times, as j will be scheduled at the first moment when the preceding jobs are already finished and the amount of available resource is at least aj. 3.1 Strong NP-completeness The aim of this section is to prove Theorem 1. 3 The problem 1rm = 1, aj = 1(cid:80) Cj Theorem 1. 1rm = 1, aj = 1(cid:80) Cj is strongly NP-hard. numbers B ∈ N, n ∈ N, and xj ∈ N (j = 1, . . . , 3n) such that B/4 < xj < B/2 and(cid:80)3n nB. A feasible solution is a partition J1, . . . , Jn of [3n] such that Ji = 3 and (cid:80) Let K = 4nB. The reduction to 1rm = 1, aj = 1(cid:80) Cj involves three types of jobs. We prove NP-completeness by reduction from the 3-Partition problem. The input contains j=1 xj = xj = B for every i ∈ [n]. In contrast to the Partition problem, the 3-partition problem remains NP-complete even when the integers xj are bounded above by a polynomial in n. That is, the problem remains NP-complete even when the numbers in the input are represented as unary numbers [3, Pages 96 -- 105 and 224]. Proof. Recall that all aj and wj values are 1, and each job has an integer processing time pj. The number of resource arrival times is part of the input. j∈Ji Normal jobs These correspond to the numbers xj in the 3-Partition instance, so there are 3n of them and the processing time pj of the j-th normal job is xj. Small jobs Their processing time is 1 and there are nK of them. Large jobs Their processing time is K and there are nK of them. There are also three types of resource arrivals: Type 1 Three resources arrive at times i(B + K) (i = 0, . . . , n − 1). Type 2 One resource arrives at i(B + K) + j (i = 0, . . . , n − 1, j = B, . . . , B + K − 1). Type 3 One resource arrives at n(B + K) + iK (i = 0, . . . , nK − 1). Suppose that the 3-Partition instance has a feasible solution J1, . . . , Jn. We consider the following schedule S: resources of Type 1 are used by normal jobs, such that jobs in Ji are scheduled between (i − 1)(B + K) and iB + (i − 1)K (in spt order). Type 2 resources are used by small jobs that start immediately. Type 3 resources are used by the large jobs that also start immediately at the resource arrival times (see Figure 1). Instead of(cid:80) Cj, consider the equivalent shifted objective function(cid:80)(Cj − tj − pj), where tj is the arrival time of the resource used by job j and pj is its processing time -- we assume without loss of generality that resources are used by jobs in order of arrival. Note that all terms 4 Figure 1: The schedule corresponding to a feasible solution of 3-Partition. of(cid:80)(Cj − tj − pj) are nonnegative. As small jobs and large jobs start immediately at the arrival of the corresponding resource in schedule S, their contribution to the shifted objective function is 0. The jobs in Ji have total processing time B, and their contribution to the shifted objective function is two times the processing time of the shortest job plus the processing time of the second shortest job, which is at most B. Hence the schedule S has objective value at most nB. We claim that if the 3-Partition instance has no feasible solution, then the objective value of any schedule is strictly larger than nB. First, notice that if a large job is scheduled to start before time n(B + K), then (cid:80)(Cj − tj − pj) has a term strictly larger than nB as there is a resource that arrives while the large job is processed and is not used for more than nB time units. Similarly, if the first large job starts at n(B + K) but uses a resource that arrived earlier, then the resource that arrives at n(B + K) is not used for more than nB time units. We can conclude that the first large job uses the resource arriving at n(B + K). If the first large job does not start at n(B +K), then all large jobs have positive contribution to the objective value, so again, the objective value is larger than nB. We can therefore assume that the large jobs start exactly at n(B + K) + iK (i = 0, . . . , nK − 1) and that there is no idle time before (B + K)n. In particular this means all other jobs are already completed at (B + K)n. Consider Type 2 resources arriving at i(B + K) + j (j = B, . . . , B + K − 1) for some fixed i. If the first or the second resource is not used immediately, then none of the subsequent ones are, so the objective value is more than nB. Hence, the first resource must be used immediately by a small job. Suppose that some resource in this interval is used by a normal job. If it is followed by a small job, then we may improve the objective value by exchanging the two. Thus, in this case, we can assume that the last resource of the interval is used by a normal job, and also the Type 1 resources arriving at (i + 1)(B + K) are used by normal jobs. But this is impossible, because normal jobs have processing time at least B/4 + 1, and a small job starts at time (i + 1)(B + K) + B. To sum up, we can assume that all resources of Type 2 are used immediately by small jobs. This means that normal jobs have to use resources of Type 1, and must exactly fill the gaps of length B between the arrival of resources of Type 2. This is only possible if the 3-partition instance has a feasible solution, concluding the proof of Theorem 1. 3.2 Shortest processing time first for unit resource requirements In the previous section, we have seen that scheduling with a non-renewable resource is strongly NP-hard already for unit resource requirements. Now we show that scheduling the jobs accord- ing to an spt ordering provides a 3/2-approximation for the problem with unit weight and unit resource requirements, thus proving Theorem 2. 2 -approximation for 1rm = 1, aj = 1(cid:80) Cj, and the Theorem 2. The SPT schedule gives a 3 approximation guarantee is tight. 5 bbb0BB+Kbbbbbb(n−1)(B+K)nB+(n−1)Kn(B+K)bbbn(B+K)+nK2−Kn(B+K)+nK2n(B+K)+KJ1Jnlargejoblargejobsmalljobssmalljobs Our strategy is to simplify the instance by revealing its structural properties while not opt . This way we get an upper bound for the approximation factor. We first consider Proof. To prove the theorem consider any instance I. We denote the completion times for the spt ordering by Cj and their sum by spt. Furthermore, let Sspt−1(i) := Cspt−1(i) − pspt−1(i) denote the starting time of the ith job in the spt schedule. Let opt be the optimal schedule for I. We denote the completion times for opt by C(cid:48) j and their sum by opt. Furthermore, let opt−1(i) − popt−1(i) denote the starting time of the ith job in the optimal schedule. opt−1(i) := C(cid:48) S(cid:48) decreasing spt the resource arrival times. Claim 8. We may assume that the ith resource arrives at S(cid:48) Proof. As the ith resource is used by job opt−1(i), the arrival time of that resource is at most S(cid:48) opt−1(i), then opt does not opt−1(i). change and spt cannot decrease. If we move the arrival time of the resource to exactly S(cid:48) opt−1(i) for i = 1, . . . , n. The next claim shows that we can get rid of the idle times in the optimal schedule. Claim 9. We may assume that there is no idle time in schedule opt, that is, S(cid:48) C(cid:48) opt−1(i−1) for i = 2, . . . , n. opt−1(i−1). We reduce t(i(cid:48)) by ∆ = t(i) − Proof. Suppose that there is some i such that ti > C(cid:48) opt−1(i−1) for all i(cid:48) ≥ i. Then for each i(cid:48) ≥ i, the completion time C(cid:48) C(cid:48) opt−1(i(cid:48)) decreases by ∆. For each i(cid:48) ≥ i, the completion time Cspt−1(i(cid:48)) decreases by at most ∆. This follows from the fact that the resource arrival times decrease by ∆ and the completion time of the previous job can decrease by at most ∆ (which can be shown by induction). Hence opt decreases by at least as much as spt. Since spt ≥ opt, the ratio spt opt will not decrease by this change. opt−1(i) = Next, we modify the processing times. Claim 10. We may assume that popt−1(1) > pspt−1(1) and that pspt−1(1) = 0. Proof. If both schedules start with the same job, then we can remove the job from the instance and decrease b1 by 1. Then opt decreases by the same amount as spt. We can repeat this until the schedules start with jobs of different processing times. Now popt−1(1) > pspt−1(1), since spt starts with the shortest job. Decreasing the processing time of job spt−1(1) to 0 (without changing any arrival time) decreases spt by pspt−1(1) and opt by at least pspt−1(1). We can eliminate idle times in the new optimal schedule as in the proof of Claim 9. Claim 11. We may assume that pj ∈ {0, 1} for all j ∈ J. Proof. Let pmax = maxj∈J pj be the maximum processing time. Scaling the processing times by dividing all processing and arrival times by pmax has no effect on spt opt , hence we may assume that pmax = 1. Now assume that there is a job j(cid:48) with p = pj(cid:48) ∈ (0, 1). Let p+ = min{pj j ∈ J, pj > p} and p− = max{pj j ∈ J, pj < p}. Let Jp = {j ∈ J pj = p} be the set of jobs with processing time p. We will show that we can either increase the processing time of all jobs in Jp to p+ or decrease the processing time of all jobs in Jp to p− without decreasing spt opt . For j ∈ J, let hj denote the number of jobs processed after j plus 1 with respect to schedule opt, i.e. hj = n − opt−1(j) + 1. Changing the processing times of all jobs in Jp by some ∆ ∈ [p− − p, p+ − p] and adopting the arrival times of the resources will increase opt by hj. Indeed, every time we change the processing time of one job j, the completion time of j and of all jobs after j will be increased by ∆. Note that ∆ can be negative, which means the completion times can also 'decrease' by ∆. ∆(cid:80) j∈Jp 6 Notice that the order of the jobs in the spt schedule is not changed. Consider the spt schedule before the change. Let job j ∈ J be any job, and let j0 be the the first job that is processed after the last idle time before the starting time of j. Let fj be the number of jobs j(cid:48) ∈ Jp j(cid:48) ≤ Sj0. For each of those jobs, the arrival time of the resource needed to start j0 will with C(cid:48) be changed by ∆fj. Thus, the starting time of job j0 in the changed spt schedule is at least Sj0 + ∆fj. Now let gj be the number of jobs j(cid:48) ∈ Jp that are processed in the time interval [Sj0, Cj) before the change. For each of those jobs, the processing time is changed by ∆ and the job is started at or after the new starting time of job j0. Thus the new completion time of j is j∈J (fj + gj)∆ if ∆ > 0, at least Cj + ∆fj + ∆gj. Consequently, spt will increase by at least(cid:80) and decrease by at most(cid:80) j∈J (fj + gj)∆ if ∆ < 0. If j∈Jp opt , then increasing the processing times in Jp to p+ will not decrease spt opt . Otherwise, decreasing the processing times in Jp to p− will not decrease spt opt . Each time we apply this operation, the number of distinct processing times decreases by 1. Finally, we get an instance where the only processing times are pmin = 0 and pmax = 1. (cid:80) (cid:80) j∈J (fj +gj ) hj ≥ spt Lastly, we modify the order of the jobs in the optimal solution. If opt and spt process a job of length 0 at the same time, then we can remove the job from the instance and reduce the number of resources that arrive at this time by 1. This will reduce opt and spt by the same amount. Let t be the time at which schedule spt first starts to process a job of length 1. On one hand, opt does not process jobs of length 0 before t by the above argument. On the other hand, there is no idle time after t in spt, because that would mean idle time in opt. Thus, if we move all jobs of length 0 and their corresponding resource arrivals in opt to time t, then spt does not change but opt decreases. We may thus assume that schedule opt processes every job of length 0 at t. Figure 2: Schedules opt and spt after the reductions. The 0 length jobs are scheduled in opt to the first resource arrival time when multiple resources arrive. We conclude that opt first processes k1 jobs of length 1, then k1 jobs of length 0 and then k2 jobs of length 1, while spt starts with the jobs of length 0 having a lot of idle time in the beginning and then consecutively processes all jobs of length 1 (see Figure 2). The weighted sums of completion times are then given by opt = k1(k1 + 1) 2 + k2 1 + k2k1 + k2(k2 + 1) 2 and spt = k1(k1 − 1) 2 + k2k1 + + (k1 + k2)k1 + k2(k2 + 1) 2 . k1(k1 + 1) 2 7 bbbOPTSPTbbbk1jobsoflength1k1jobsoflength0k2jobsoflength1bbbbbbbbbk1jobsoflength0k1+k2jobsoflength1 We get opt − spt = 3 2 k2 1 4 + k2 2 4 − k1k2 2 + 3k1 + k2 4 ≥ (k1 − k2)2 4 ≥ 0, showing that the approximation factor is at most 3 2 . 2 k2 2 as we have spt = 9 converges to 3 of Theorem 2. Setting k2 = k1 and letting k1 go to infinity gives us a sequence of instances such that spt opt 1 + O(k1). This concludes the proof 1 + O(k1) and opt = 3k2 4 The problem 1rm = 1, pj = 0(cid:80) Cjwj In this section we consider problem 1rm = 1, pj = 0(cid:80) Cjwj, another special case of 1rm = 1(cid:80) Cjwj. The problem clearly is NP-hard even for q = 2 as the knapsack problem can be Recall that Kis [12] gave a FPTAS for 1rm = 1(cid:80) Cjwj when there are two resource arrival reduced to it. Indeed, maximizing the weight of the items in the knapsack is equivalent to the task of maximizing the weight of jobs that are scheduled at the first resource arrival time. times. First we give a 6-approximation for the problem based on a greedy approach. Next, we give a more complicated 4-approximation that illustrates one of the important ideas of the more general PTAS. Then we provide a PTAS for the case when q, the number of resource arrival times is a constant. This algorithm will be used as a subroutine in the PTAS for the general case. Finally, we prove the main result of the paper which is a PTAS for the case of an arbitrary number of resource arrival times. Since the processing times are 0, every job is processed at one of the arrival times in any optimal schedule. Thus a schedule can be represented by a mapping π : J → [q], where π(j) denotes the index of the resource arrival time when job j is processed. A schedule is feasible if j aj holds, this is equivalent to (1) (2) the resource requirements are met, that is, if(cid:88) i bi =(cid:80) for all 1 ≤ k ≤ q. As we assume that(cid:80) (cid:88) j:π(j)≤k aj ≤(cid:88) aj ≥(cid:88) i≤k bi j:π(j)≥k bi i≥k for all 1 ≤ k ≤ q. Define Bk =(cid:80) i≥k bi, and consider the set of jobs that are not processed before a given time point ti. Then (2) says that if the resource requirements of these jobs add up to at least Bi, then our schedule is feasible. We will mostly use the second characterization of feasibility, as our algorithms assign the jobs to later time points first. The intuition is that the total weight Wi of jobs that are not processed at a time point ti gives a lower bound for their contribution to the objective function. Therefore it is better to approximate Wi, rather than the weight of the jobs already processed, given by (cid:17) − Wi. (cid:16)(cid:80) j∈J wj 4.1 A greedy 6-approximation for arbitrary q The idea of our first algorithm is to have a balance between adding jobs that have small weights and jobs that have high resource requirements. More precisely, we will assign jobs to the time points going back in time. When we add a job to the set of jobs scheduled after a given time 8 point, we will choose the most inefficient job, i.e. the job minimizing wj/aj among all jobs that have weight at most the weight W of all jobs that have already been chosen up to this point. If there is no job with weight at most W , then we simply choose a job with minimal weight. Intuitively, this rule guarantees that the jobs we choose are not too efficient but their total weight is not too large either. Algorithm 1 Greedy algorithm for 1rm = 1, pj = 0(cid:80) Cjwj. Input: Jobs J with J = n, resource requirements aj, weights wj, resource arrival times t1 ≤ . . . ≤ tq and resource quantities b1, . . . bq. Output: A feasible schedule π. 1: Set A = 0. 2: Set W = 0. 3: for i from 0 to q − 1 do while A < Bq−i do 4: 5: 6: 7: 8: 9: 10: 11: if there is an unassigned job j with wj ≤ W then Let j be an unassigned job with wj ≤ W minimizing wj/aj. else Let j be an unassigned job minimizing wj. W ← W + wj A ← A + aj Set π(j) = q − i. 12: return π Theorem 3. There exists a 6-approximation for 1rm = 1, pj = 0(cid:80) Cjwj with running time O(n log(n)). Proof. We claim that Algorithm 1 satisfies the requirements of the theorem. To prove this, we show that at the end of each iteration of the for loop, W is a 6-approximation for the problem of finding a minimum weight job set S consuming at least Bi resources. Let opt be the optimum value of this problem. Since the Bi's are monotone decreasing and the algorithm does not consider the Bi's when picking the jobs, it is enough to show that the statement holds for the case q = 2, i = 0. Consider the last iteration of the while loop when W < opt holds at the beginning of the loop. Since there exists a set of jobs of total weight opt, the value of W at the end of this iteration is bounded by 2 · opt. After this iteration, our algorithm will always pick jobs that are at least as inefficient as any of the jobs picked by the optimum solution. Consequently, the while loop will end at the latest when the weight of the jobs scheduled after this iteration is at least opt. Now consider the last iteration of the while loop. At the beginning of the iteration, we have A < Bq−i and W is bounded by 3 · opt by the above. Since there exists a set of jobs of total weight opt, W is at most doubled during the iteration. This means that W is bounded by 6· opt at the end of the while loop, as stated. The running time follows by ordering the jobs according to their weight and by using AVL trees for picking j in the while loop. The following example shows that the bound is tight. We have 5 jobs with weights w1 = w2 = 1 − 2ε, w3 = 1 − ε, w4 = 1 and w5 = 3. The resource requirements are a1 = a2 = ε/5, a3 = 1− ε/2, a4 = 1 and a5 = 4. The resource arrival times are t1 = 0 and t2 = 1, with resource quantities b1 = 5 − ε/10 and b2 = 1. Here the optimum solution is to schedule the job with 9 weight 1 to time point t2 and all the remaining jobs to time point t1. However, our algorithm will schedule the job with weight 1 to time point t1 and all the remaining jobs to t2. 4.2 A (4 + ε)-approximation for arbitrary q Now we give a slightly better approximation for the problem. The algorithm is slightly more complicated than the one presented in Section 4.1, but the proof illustrates one of the important ideas of the general PTAS. Theorem 4. There exists a (4 + ε)-approximation for 1rm = 1, pj = 0(cid:80) Cjwj with running time polynomial in 1/ε and the input length. Proof. The idea of the algorithm is as follows. We may assume without loss of generality that resource arrival times are integer. First we shift all resource arrival times to powers of 2. For each time point t = ti in the shifted instance, we apply the FPTAS by Kis [12] to the instance which has only two resource arrival times t1 and t, and the resource quantity for t is Bi. Denote the set of jobs assigned to t this way by Si. Then, going back from the last time point tq to the first one t1, we assign all unassigned jobs from Si to ti, i.e. π(j) = max{i : j ∈ Si}. More formally, let I be an instance of 1rm = 1, pj = 0(cid:80) t2 = 1. We define a new instance I(cid:48) of 1rm = 1, pj = 0(cid:80) j Cjwj. We assume t1 = 0 and j Cjwj with shifted resource arrival Claim 12. A solution to I with weighted sum of completion times W can be transformed into a solution of I(cid:48) with weighted sum of completion times at most 2W . Furthermore, any feasible schedule for I(cid:48) also is a feasible schedule for I. i} for i = 1, . . . , q. Let π be the solution for I. Then Proof. Let us define si = min{t(cid:48) assigning all jobs that are assigned to time point ti to si gives us a feasible solution to I(cid:48). By this change, the completion of any job is at most doubled (recall that each ti is assumed to be integer). Since the available amount of resources at each time in I(cid:48) is at most as much as in I, a feasible schedule for I(cid:48) is also a feasible schedule for I. i : ti ≤ t(cid:48) Claim 13. There exists a polynomial time (2 + ε)-approximation algorithm for constant ε for all instances I where the resource arrival times are integer powers of 2. Proof. We use the procedure that we described, i.e. we solve the instance for each of the time points using an α-approximation provided by [12], where α = 1 + ε. Let πopt be an optimum solution and let J opt be the set of jobs j with πopt(j) = k. We have k (cid:40) times as follows. Set and b(cid:48) i = t(cid:48) i = 0 2i−2 (cid:40) (cid:80)[bi : ti ∈ (2i−3, 2i−2] ] bi if i = 1, for i = 2, . . . ,(cid:100)log2(tq)(cid:101) + 2, if i = 1, 2, for i = 3, . . . ,(cid:100)log2(tq)(cid:101) + 2. w(Si) ≤ α w(J opt k ) q(cid:88) k=i 10 for i = 1, . . . , q. Then we get (cid:88) j∈J 2α wjCπopt j = (2α) · 2i−2w(J opt ) i i=2 q(cid:88) ≥ q(cid:88) ≥ q(cid:88) ≥ q(cid:88) i=2 i=2 α · 2i−2w(J opt i ) + α q(cid:88) α2i−2 k=i 2i−2w(Si), w(J opt k ) ∞(cid:88) j=1 −j2i−2w(J opt 2 i ) i=2 thus the approximation ratio follows. The theorem follows from the two claims. 4.3 PTAS for constant q The aim of this section is to give a PTAS for the case when the number of resource arrival times is a constant. The algorithm is a generalization of a well known PTAS for the knapsack problem, and will be used later as a subroutine in the PTAS for an arbitrary number of resource arrival times. The idea is to choose a number k ∈ Z+, guess the k heaviest jobs that are processed at each resource arrival time ti, and then determine the remaining jobs that are scheduled at ti in a greedy manner. Since we go over all possible sets containing at most k jobs for each resource arrival time, there is an exponential dependence on the number q of resource arrival times in the running time. k )-approximation for 1rm = 1, pj = 0(cid:80) Cjwj with running Theorem 5. There exists an (1 + q time O(nqk+1). Proof. We claim that Algorithm 2 satisfies the requirements of the theorem. Let πopt be an optimal schedule and define J opt be the set of the k heaviest . Let Ji = {j ∈ J : π(j) = i} denote the set jobs in J opt of jobs assigned to time ti in our solution. In each iteration of the for loop of Step 4, let ji be the last job added to Ji if such a job exists. 1 ∪···∪ Sopt is considered in Step 1. Let Wq−(cid:96) denote the value of W at the end of the iteration of the for loop corresponding to i = (cid:96) in Step 4. By Steps 3 and 9, we have Assume that we are at the iteration of the algorithm when the subpartition Sopt i = {j ∈ J : πopt(j) = i}. Let Sopt ≥ k, otherwise let Sopt i = J opt if J opt q i i i i q(cid:88) (cid:88) i=(cid:96) j∈J opt i wj. Wq−(cid:96) ≤ 1 k As our algorithm always picks the most inefficient job, we also have j∈Ji\{ji} where Ji \ {ji} = Ji if ji is not defined for i. i=(cid:96) q(cid:88) (cid:88) wj ≤ q(cid:88) (cid:88) wj, j∈J opt i i=(cid:96) 11 Algorithm 2 PTAS for 1rm = 1, pj = 0(cid:80) Cjwj when q is a constant. Input: Jobs J with J = n, resource requirements aj, weights wj, resource arrival times t1 ≤ . . . ≤ tq and resource quantities b1, . . . bq. Output: A feasible schedule π. 1: for all subpartitions S1 ∪ ··· ∪ Sq ⊆ J with Si ≤ k for i > 1 do 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: Set A = 0. Set W = 0. for i from 0 to q − 2 do for j ∈ Sq−i do π(j) = q − i A ← A + aj W ← max{W, min{wj : j ∈ Sq−i}} while A < Bq−i do if Sq−i = k then if there exists an unassigned job j with wj ≤ W then Let j be an unassigned job with wj ≤ W minimizing wj/aj. π(j) = q − i A ← A + aj else break For all remaining jobs set π(j) = 1. 17: 18: Let π be the best schedule found. 19: return π Combining these two observations, for (cid:96) = 1, . . . , q we get q(cid:88) (cid:88) j∈Ji i=(cid:96) wj = q(cid:88) ≤ q(cid:88) i=(cid:96) i=(cid:96) j∈Ji\{ji} wji wj + q(cid:88) (cid:88) (cid:88) wj + (q − (cid:96) + 1) · W(cid:96) q(cid:88) (cid:88) i=(cid:96) j∈J opt i wj, i=(cid:96) j∈J opt i ≤ (1 + q k ) where the first inequality follows from the fact that wji ≤ Wi ≤ W(cid:96) whenever i ≥ (cid:96). This proves that the schedule that we get is a (1 + q k )-approximation. We get a factor of nqk in the running time for guessing the sets Sk. Assigning the remaining jobs can be done in linear time by ordering the jobs and using AVL-trees, thus we get an additional factor of n. q , concluding the proof of the theorem. In order to get a PTAS, we set k = ε 4.4 PTAS for arbitrary q We turn to the proof of the main result of the paper. As in Section 4.2, we shift resource arrival times; here we use powers of 1 + ε, for a suitably small ε. Let I be an instance of 1rm = 1, pj = 0(cid:80) are integer, and that t1 = 0, t2 = 1. We define a new instance I(cid:48) of 1rm = 1, pj = 0(cid:80) j Cjwj. We assume that resource arrival times j Cjwj 12 (cid:40) with shifted resource arrival times as follows. Set t(cid:48) i = 0 (1 + ε)i−2 (cid:40) (cid:80)[bi : ti ∈ ((1 + ε)i−3, (1 + ε)i−2] ] bi and b(cid:48) i = if i = 1, for i = 2, . . . ,(cid:100)log1+ε(tq)(cid:101) + 2, if i = 1, 2, for i = 3, . . . ,(cid:100)log1+ε(tq)(cid:101) + 2. The proof of the following claim is the same as that of Claim 12. Claim 14. A solution to I with weighted sum of completion times W can be transformed into a solution of I(cid:48) with weighted sum of completion times at most (1 + ε)W . Furthermore, any feasible schedule for I(cid:48) also is a feasible schedule for I. Due to the claim, we may assume that the positive arrival times are powers of 1 + ε. For convenience of notation, in this section we will assume that the largest arrival time is 1, and arrival times are indexed in decreasing order, starting with t0 = 1. That is, ti = (1 + ε)−i (i = 0, . . . , q − 2), and tq−1 = 0. We will also assume that for a given constant r, bq−r−1 = ··· = bq−2 = 0. This can be achieved by adding r dummy arrival times. Theorem 6. There exists a PTAS for 1rm = 1, pj = 0(cid:80) Cjwj. Proof. Let us fix an even integer r and ε > 0; we will later assume that r is very large compared to ε−1. We assume that resource arrival times are as described above, and are indexed in decreasing order. In the algorithm, we fix jobs at progressively decreasing arrival times, by using the PTAS of the previous section for r + 1 arrival times on different instances except for the first step, when we may use the PTAS for less than r + 1 arrival times. We will run our algorithm r/2 times with slight modifications, and pick the best result. Each run is characterized by a parameter (cid:96) ∈ {1, . . . , r/2}. In the first step, we consider arrival times t0, t1, . . . , tr/2+(cid:96)−1, 0. We move the resources arriving before tr/2+(cid:96)−1 to 0, and use the PTAS for r/2 + (cid:96) + 1 arrival times on this instance. We fix the jobs that are scheduled at arrival times t0, t1, . . . , t(cid:96)−1. Consider now the jth step for some j ≥ 2. Define s = (j−2)r/2+(cid:96) and consider arrival times ts, ts+1, . . . , ts+r−1, 0. Move the resources arriving before ts+r−1 to 0, and decrease bs, bs+1, . . . in this order as needed, so that the total requirement of unfixed jobs equals the total resource. Use the PTAS for r + 1 arrival times on this instance. Fix the jobs that are scheduled at arrival times ts, ts+1, . . . , ts+r/2−1. The algorithm runs while s + r− 1 ≤ q − 2, i.e., jr/2 + (cid:96) ≤ q − 1. Since the smallest r arrival times (except for 0) are dummy arrival times, the algorithm considers all resource arrivals. The schedule given by the algorithm is clearly feasible, because when jobs at ti are fixed, the total resource requirement of jobs starting no earlier than ti is at least the total amount of resource arriving no earlier than ti. To analyze the approximation ratio, we introduce the following notation: Wi is the total weight that the algorithm schedules at ti; W (cid:48) i is the weight that the algorithm temporarily schedules at ti when i is in the interval [ts+r/2, ts+r−1] (or, in the first step, in the interval [t(cid:96), t(cid:96)+r/2−1]); W ∗ is the total weight scheduled at ti in the optimal solution. i Since we use the PTAS for r/2 + (cid:96) + 1 arrival times in the first step, we have (cid:96)−1(cid:88) (cid:96)+r/2−1(cid:88) (1 + ε) −iWi + (1 + ε) −iW (cid:48) i ≤ (1 + ε) (1 + ε) −iW ∗ i , i=0 i=(cid:96) i=0 13 (cid:96)+r/2−1(cid:88) as the right-hand side is (1 + ε) times the objective value of the feasible solution obtained from the optimal solution by moving jobs arriving before t(cid:96)+r/2−1 to 0. For s = jr/2 + (cid:96), we compare the output of the PTAS with a different feasible solution: we schedule total weight W (cid:48) i at ti for i = s + r/2 + 1, . . . , s + r− 1, and at ts+r/2 we schedule all jobs that are no earlier than ts+r/2 in the optimal schedule but are no later than ts+r/2 in the PTAS schedule. We get the inequality (j+1)r/2+(cid:96)−1(cid:88) i at ti for i = s, s + 1, . . . , s + r/2 − 1, total weight W ∗ (j+2)r/2+(cid:96)−1(cid:88) (j+1)r/2+(cid:96)−1(cid:88) i=jr/2+(cid:96) ≤ (1 + ε) (j+2)r/2+(cid:96)−1(cid:88) −iWi + −iW ∗ −iW (cid:48) −iW (cid:48) i=(j+1)r/2+(cid:96) (1 + ε) (1 + ε) (1 + ε) (1 + ε) i i + i=jr/2+(cid:96) i=(j+1)r/2+(cid:96) +(1 + ε) −(j+1)r/2−(cid:96) i (j+1)r/2+(cid:96)−1(cid:88) i=0 The sum of these inequalities gives q−2(cid:88) q−2(cid:88) (1 + ε) −iWi ≤ ε (1 + ε) −iW (cid:48) i=0 i=(cid:96) + (1 + ε) q−2(cid:88) i=0 (1 + ε) (1 − ε) −(jr/2+(cid:96)) −iW ∗ i  W ∗ i . To bound the first term on the right hand side of (3), first we observe that r/2+(cid:96)−1(cid:88) (1 + ε) −iW (cid:48) i ≤ (1 + ε) (1 + ε) −iW ∗ i , i=(cid:96) i=0 q−2(cid:88) i=0 i + (1 + ε)  (cid:88) r/2+(cid:96)−1(cid:88) j:jr/2+(cid:96)>i  . W ∗ i (3) because the left side is at most the value of the PTAS in the first step, while the right side is (1 + ε) times the value of a feasible solution. Similarly, (j+2)r/2+(cid:96)−1(cid:88) i=(j+1)r/2+(cid:96) (1 + ε) −iW (cid:48) i ≤ (j+2)r/2+(cid:96)−1(cid:88) i=jr/2+(cid:96) (1 + ε) (1 + ε) −iW ∗ i + (1 + ε) −jr/2−(cid:96)  , W ∗ i jr/2+(cid:96)−1(cid:88) i=0 because the left side is at most the value of the PTAS in the (j + 1)-th step, and the right side is (1 + ε) times the value of the following feasible solution: take the optimal solution, move jobs scheduled before t(j+2)r/2+(cid:96)−1 to 0, and move jobs scheduled after tjr/2+(cid:96) to tjr/2+(cid:96). Adding 14 these inequalities, we get 2 q−2(cid:88) 2 q−2(cid:88) (cid:32) i=0 i=0 q−2(cid:88) (cid:16) i=0 ε ε(1 + ε) (1 + ε) −iW ∗ i + ε(1 + ε) (1 + ε) −iW ∗ i + −jr/2−1 (1 + ε) ε(1 + ε) 2 (1 + ε) −iW ∗ q−2(cid:88) i=(cid:96) ε (1 + ε) j:jr/2+(cid:96)>i i ≤ i=0 −iW (cid:48) (1 + ε)  (cid:88) q−2(cid:88)  ∞(cid:88) q−2(cid:88) (cid:17) q−2(cid:88) j=0 i=0 i + (1 + ε)r/2−1 (1 + ε)r/2 − 1 q−2(cid:88) i=0  ≤  = i −jr/2−(cid:96)  W ∗  (1 + ε) (cid:33) i −iW ∗ (1 + ε) −iW ∗ i = 2(1 + ε) + (1+ε)r/2 (1+ε)r/2−1 (1 + ε) −iW ∗ i . The last expression is at most 4ε times the optimum value if r is large enough. i=0 The last term of the right side of (3) is too large to get a bound that proves a PTAS. However, we can bound the average of these terms for different values of (cid:96). The average is r/2(cid:88) q−2(cid:88)  (cid:88)  (1 − ε) (cid:96)=1 i=0 j:jr/2+(cid:96)>i (1 + ε) 2 r  ∞(cid:88) q−2(cid:88) i=0 j=1 (1 − ε) −(jr/2+(cid:96))  W ∗ i ≤ q−2(cid:88) i=0 (1 + ε) 2 r −j (1 + ε) −iW ∗ i = (1 + ε) 2 rε (1 − ε) −iW ∗ i , q−2(cid:88) which is at most ε times the optimum if r is large enough. To summarize we obtained that for large enough r, the average objective value of our algorithm for (cid:96) = 1, 2, . . . , r/2 is upper bounded by q−2(cid:88) q−2(cid:88) q−2(cid:88) 4ε (1 + ε) −iW ∗ i + (1 + ε) (1 + ε) −iW ∗ i + ε (1 + ε) −iW ∗ i = (1 + 6ε) (1 + ε) −iW ∗ i , i=0 i=0 i=0 i=0 which is (1+6ε) times the objective value of the optimal solution. This proves that the algorithm that chooses the best of the r/2 runs is a PTAS. 0(cid:80) 4.5 Undetermined resource arrival times A question one might ask is the following: Given α > 1 and an instance of 1rm = 1, pj = j Cjwj, is there a schedule π such that the set Si = {j : π(j) ≥ i} is an α-approximation to the problem of finding a minimum weight job set S ⊆ J consuming at least Bi resources for i = 1, . . . , q? The motivation is that such a solution would also give an α-approximation for the instance. The greedy algorithm of Section 4.1 shows that the answer to the question is yes if α ≥ 6. Let us consider now a variant of the problem where the arriving resource quantities are given, but the resource arrival times are not known in advance. Then the smallest α for which the answer is 'YES' in the above problem is the best approximation ratio we can achieve. 15 Theorem 7. There exists a (4+ε)-approximation for 1rm = 1, pj = 0, ti unkown(cid:80) Cjwj with running time polynomial in 1/ε and the input length. Moreover, there is no (4−ε)-approximation algorithm for the problem for any ε > 0. Proof. Our approximation algorithm is based on the following claim. Claim 15. There exists a schedule π such that for each i the set Si = {j : π(j) ≥ i} is a 4-approximation for the problem of finding a minimum weight job set S ⊆ J consuming at least Bi resources. Proof. For i = 1, . . . , q, let Ji be an optimal solution to the problem of finding a minimum weight job set S ⊆ J consuming at least Bi resources. Define f (i) = min{k : w(Jk) ≤ 2w(Ji)} for i = 2, . . . , q and let us consider the following procedure. Algorithm 3 Subroutine for (4 + ε)-approximation to 1rm = 1, pj = 0, ti unkown(cid:80) Cjwj. Input: Jobs J with J = n, resource requirements aj, weights wj, resource quantities b1, . . . bq. Output: A feasible schedule π. 1: Set i = q. 2: while i ≥ 1 do 3: 4: 5: Set Si+1 = {j : π(j) > i}. Set π(j) = i for j ∈ Jf (i) \ Si+1. i ← f (i) − 1 6: return π It is not difficult to see that π fulfills the resource requirements. We prove by induction that w(Si) ≤ 4w(Ji) holds for i = 1, . . . , q. As Sq = Jf (q), the inequality w(Sq) ≤ 4w(Jq) clearly holds. Assume now that i ≤ q − 1. If no jobs are assigned to ti, then w(Si) = w(Si+1) ≤ 4w(Ji+1) ≤ 4w(Ji). Otherwise i = f (i(cid:48)) − 1, where i(cid:48) is the index considered in the previous iteration of the while loop in Step 2. Observe that no jobs are assigned to time points between the ith and the i(cid:48)th ones. By induction, we get w(Si) = w(Jf (i) ∪ Si(cid:48)) ≤ w(Jf (i)) + w(Si(cid:48)) ≤ 2w(Ji) + 4w(Ji(cid:48)) ≤ 4w(Ji). Here the second inequality holds by induction and by the definition of f , while the last inequality follows from the fact that i < f (i(cid:48)) which implies w(Ji) > 2w(Ji(cid:48)). Algorithm 3 provides a (4+ε)-approximation for 1rm = 1, pj = 0, ti unkown(cid:80) Cjwj which has running time polynomial in the input size and 1 ε as follows. Using either an FPTAS for the knapsack problem or the FPTAS of Kis [12], we determine an approximation the sets Ji. Then we apply Algorithm 3 to schedule the jobs. This concludes the proof of the first part of the theorem. The following set of instances shows that α is at least 4. We are given (n− 1)m jobs denoted m and ai = 2−i. Furthermore, we have (n − 1)m by 1, 2, . . . , (n − 1)m with weights wi = n − i resource arrival times that are unknown. The resource quantities are given by bq = 2−q and bi = 2−i − Bi+1 = 2−i−1 for i < q. In order to fulfill the resource requirements, the set of jobs scheduled at or after time ti has to contain at least one of the jobs j ≤ i. Observe that the optimal solution of finding a minimum weight job set Ji consuming at least Bi resources consists of the single job i. Let j1 be the job processed at time t1. Now we create a sequence starting with j1. Since the jobs that are greater or equal than j1 have total resource requirements less than Bj1−1, we 16 have to schedule at least one job j2 < j1 at or after tj1−1. This argument can be iterated to find a job j3 < j2 which is scheduled at or after tj2−1, and so on. Claim 16. For any β < 4, there exist n and m such that for the sequence j1, j2, . . . constructed as above, there is some i with claim. Then βwji−1 ≥(cid:80)i+1 Proof. Suppose to the contrary that there is no triple n, m, i satisfying the requirements of the k=1 wjk for all n, m, i. If m is large enough, then wji and wji−1 are m ≤ εm for some εm then wji−1 ≤ wji + εm. Thus we get very close to each other, i.e. βwji−1 ≤ βwji + βεm. By increasing n, the length of our sequence increases as well. Indeed, by the indirect assumption, we have if 1 wji+1 ≤ i+1(cid:88) k=1 wjk ≤ βwji−1 < 4wji−1 < 4wji + 4εm. i+1(cid:88) k=1 βwji−1 < wjk . Since we also have wj1 ≤ 4 and wj ≥ 1 for all jobs j, this implies that the number of elements in the sequence is at least log5 n. Let us define zi = wji and z(cid:48) k=1 zk. By the indirect assumption, β(zi + 1 m ) ≥ zi+1 + z(cid:48) i = (cid:80)i−1 i+1, thus we have (β − 1)zi − z(cid:48) i + 4εm ≥ zi+1. We omit the εm for now to keep the reasoning simple. We claim that which only depends on β. We have (β − 1)zi − z(cid:48) β < 4. Observe that z(cid:48) is minimal if (β − 1)zi − z(cid:48) i zi i − zi+1 ≥ 0, and thus we get 3zi > z(cid:48) i = zi+1. By transforming the equation zi + z(cid:48) for some γ > 1 i assuming z(cid:48) i zi γ z(cid:48) i+1 zi+1 = = (β − 1)zi − z(cid:48) i , i z(cid:48) i+1 zi+1 ≥ γ z(cid:48) i zi we get γ = i + ziz(cid:48) z2 (β − 1)ziz(cid:48) i i − z(cid:48)2 i . (4) Using (zi − z(cid:48) i)2 ≥ 0, (β − 2) < 2 and ziz(cid:48) i > 0 we get i + z(cid:48)2 z2 i > 2ziz(cid:48) i or equivalently i + ziz(cid:48) z2 i > 3ziz(cid:48) i − z(cid:48)2 i ≥ 3ziz(cid:48) β − 1 β−1 . It follows that there exists some N such that z(cid:48) i − 3 β − 1 z(cid:48)2 i = 3 N zN Thus γ > 3 ((β − 1)ziz(cid:48) i − z(cid:48)2 i ). > 3 and thus we get βzN < 4zN ≤ zN + z(cid:48) N , contradicting the indirect assumption. By Claim 16, there exists a time point ti with (cid:80) j:π(j)≥i wj > βBi. By setting ti(cid:48) = 0 (or very close to 0) for i(cid:48) < i and ti(cid:48) = 1 (or very close to 1) for i(cid:48) ≥ i, the schedule can only be a (β − ε)-approximation if we do not know the resource arrival times in advance. 17 Acknowledgement The authors are grateful to Erika B´erczi-Kov´acs and to Matthias Mnich for the helpful discus- sions. Krist´of B´erczi was supported by the J´anos Bolyai Research Fellowship of the Hungarian Academy of Sciences and by the ´UNKP-19-4 New National Excellence Program of the Min- istry for Innovation and Technology. Project no. NKFI-128673 has been implemented with the support provided from the National Research, Development and Innovation Fund of Hungary, financed under the FK 18 funding scheme. Tam´as Kir´aly was supported by the Hungarian National Research, Development and Innovation Office -- NKFIH, grant number K120254. This research was supported by Thematic Excellence Programme, Industry and Digitization Subpro- gramme, NRDI Office, 2019. References [1] J. Carlier. Probl`emes d'ordonnancement `a contraintes de ressources: algorithmes et com- plexit´e. Universit´e Paris VI-Pierre et Marie Curie, Institut de programmation, 1984. [2] E. R. Gafarov, A. A. Lazarev, and F. Werner. Single machine scheduling problems with financial resource constraints: Some complexity results and properties. Mathematical Social Sciences, 62(1):7 -- 13, 2011. [3] M. R. Garey and D. S. Johnson. Computers and intractability. A Guide to the Theory of NP-Completeness, 1979. [4] R. L. Graham, E. L. Lawler, J. K. Lenstra, and A. R. Kan. Optimization and approximation in deterministic sequencing and scheduling: a survey. In Annals of discrete mathematics, volume 5, pages 287 -- 326. Elsevier, 1979. [5] A. Grigoriev, M. Holthuijsen, and J. Van De Klundert. Basic scheduling problems with raw material constraints. Naval Research Logistics (NRL), 52(6):527 -- 535, 2005. [6] P. Gyorgyi. A ptas for a resource scheduling problem with arbitrary number of parallel machines. Operations Research Letters, 45(6):604 -- 609, 2017. [7] P. Gyorgyi and T. Kis. Approximation schemes for single machine scheduling with non- renewable resource constraints. Journal of Scheduling, 17(2):135 -- 144, 2014. [8] P. Gyorgyi and T. Kis. Approximability of scheduling problems with resource consuming jobs. Annals of Operations Research, 235(1):319 -- 336, 2015. [9] P. Gyorgyi and T. Kis. Reductions between scheduling problems with non-renewable re- sources and knapsack problems. Theoretical Computer Science, 565:63 -- 76, 2015. [10] P. Gyorgyi and T. Kis. Approximation schemes for parallel machine scheduling with non- renewable resources. European Journal of Operational Research, 258(1):113 -- 123, 2017. [11] P. Gyorgyi and T. Kis. Minimizing the maximum lateness on a single machine with raw material constraints by branch-and-cut. Computers & Industrial Engineering, 115:220 -- 225, 2018. [12] T. Kis. Approximability of total weighted completion time with resource consuming jobs. Operations Research Letters, 43(6):595 -- 598, 2015. 18 [13] R. Slowi´nski. Preemptive scheduling of independent jobs on parallel machines subject to financial constraints. European Journal of Operational Research, 15(3):366 -- 373, 1984. [14] A. Toker, S. Kondakci, and N. Erkip. Scheduling under a non-renewable resource constraint. Journal of the Operational Research Society, 42(9):811 -- 814, 1991. [15] J. Xie. Polynomial algorithms for single machine scheduling problems with financial con- straints. Operations Research Letters, 21(1):39 -- 42, 1997. 19
1305.1407
2
1305
2013-10-01T04:09:07
Interdiction Problems on Planar Graphs
[ "cs.DS", "math.OC" ]
Interdiction problems are leader-follower games in which the leader is allowed to delete a certain number of edges from the graph in order to maximally impede the follower, who is trying to solve an optimization problem on the impeded graph. We introduce approximation algorithms and strong NP-completeness results for interdiction problems on planar graphs. We give a multiplicative $(1 + \epsilon)$-approximation for the maximum matching interdiction problem on weighted planar graphs. The algorithm runs in pseudo-polynomial time for each fixed $\epsilon > 0$. We also show that weighted maximum matching interdiction, budget-constrained flow improvement, directed shortest path interdiction, and minimum perfect matching interdiction are strongly NP-complete on planar graphs. To our knowledge, our budget-constrained flow improvement result is the first planar NP-completeness proof that uses a one-vertex crossing gadget.
cs.DS
cs
Interdiction Problems on Planar Graphs Feng Pan1 and Aaron Schild2 1D-6, Los Alamos National Laboratory, [email protected] 2Princeton University, [email protected] October 30, 2018 Abstract Interdiction problems are leader-follower games in which the leader is allowed to delete a certain number of edges from the graph in order to maximally impede the follower, who is trying to solve an optimization problem on the impeded graph. We introduce approximation algorithms and strong NP-completeness results for interdiction problems on planar graphs. We give a multiplicative (1 + ǫ)-approximation for the maximum matching interdiction problem on weighted planar graphs. The algorithm runs in pseudo-polynomial time for each fixed ǫ > 0. We also show that weighted maximum matching interdiction, budget-constrained flow improvement, directed shortest path interdiction, and minimum perfect matching interdiction are strongly NP- complete on planar graphs. To our knowledge, our budget-constrained flow improvement result is the first planar NP-completeness proof that uses a one-vertex crossing gadget. 1 Introduction Interdiction problems are often used to understand the robustness of solutions to combinatorial optimization problems on graphs. For any optimization problem on a graph, one can formulate an interdiction variant by creating a leader-follower game. In edge interdiction problems, every edge of the graph has an interdiction cost associated with it. The leader is given a budget and is allowed to delete any set of edges with total cost no more than the given budget. The follower then solves the given optimization problem on the remaining graph. The leader wants to pick the set of edges to delete that impedes the follower as much as possible. In this paper, we focus on edge interdiction problems relating to shortest path interdiction, maximum flow interdiction, and matching interdiction problems. First, we give definitions for the maximum matching interdiction, budget-constrained maximum flow, shortest path interdiction, and minimum perfect matching interdiction problems. For a given directed graph G with a nonnegative edge capacities, let α(G, s, t) denote the value of the maximum flow from s to t. The Budget-Constrained Flow Improvement Problem (BCFIP) [20], a problem that is closely related to the maximum flow interdiction problem, is defined as follows: Input: A directed graph G = (V, E) with a capacity function w : E → Z≥0, a transport cost function c : E → Z≥0, an integer budget B > 0, and two distinct distinguished nodes s, t ∈ V . Output: A subset I ⊆ E with c(I) ≤ B that maximizes α(G[I], s, t), where G[I] denotes the subgraph of G induced by the edges in I. 1 B(G, s, t) denote the optimal value for BCFIP. Let αE A matching in a graph is a set of edges such that no two edges share an endpoint. For an edge-weighted graph G = (V, E) with edge weight function w : E → Z≥0, let ν(G) be the weight of a maximum weight matching in G. The Maximum Matching Edge Interdiction Problem (MMEIP), originally defined by Zenklusen in [23], is defined as follows: Input: An edge-weighted graph G = (V, E) with a weight function w : E → Z≥0, an interdiction cost function c : E → Z≥0, and an integer interdiction budget B > 0. Output: A subset I ⊆ E with c(I) ≤ B that minimizes ν(G\I). B (G) denote the optimal value for MMEIP. Let νE Let ρ(G, u, v) denote the total weight of a shortest path between u and v in an edge-weighted graph G. DSPEIP is defined as follows: Input: An edge-weighted directed graph G = (V, E) with a weight function w : E → Z≥0, an interdiction cost function c : E → Z≥0, an integer interdiction budget B > 0, and two distinct nodes u, v ∈ V . Output: A subset I ⊆ E with c(I) ≤ B that maximizes ρ(G\I, u, v). B(G, u, v) denote the optimal value for DSPEIP. Let ρE A perfect matching in a graph is a matching such that every vertex in the graph is incident with some edge in the matching. For an edge-weighted graph G, let µ(G) denote the weight of the minimum weight perfect matching if it exists. If no perfect matching exists in G, let µ(G) = ∞. We introduce the Minimum Perfect Matching Edge Interdiction Problem (MPMEIP) as follows: Input: An edge-weighted graph G = (V, E) with edge weight function w : E → Z≥0, interdic- tion cost function c : E → Z≥0, and interdiction budget B > 0. It is assumed that, for every set I ⊆ E with c(I) ≤ B, G\I has a perfect matching. Output: A subset I ⊆ E with c(I) ≤ B that maximizes µ(G\I). Let µE B(G) denote the optimal value for MPMEIP. 1.1 Prior work Interdiction problems have practical applications in assessing the robustness of infrustructure net- works. Some previous applications include drug trafficking [22], military planning [9], protecting utility networks from terrorist attacks [14], and controlling the spread of an infection [2]. Many researchers have worked towards understanding the complexity of interdiction problems on general graphs. BCFIP is known to be strongly NP-complete on bipartite graphs and weakly NP-complete on series parallel graphs [20]. Directed shortest path interdiction is strongly NP- complete on general graphs [16] and is strongly NP-hard to approximate within any factor better than 2 on general graphs [15]. A node-wise variant of the shortest path interdiction problem is solvable in polynomial time [15]. Heuristic solutions are known for shortest path interdiction. Israeli and Wood [13] gave a MIP formulation and used Benders' Decomposition to solve it efficiently on graphs with up to a few thousand vertices. The maximum flow interdiction problem is strongly NP-hard on general graphs, though a con- tinuous variant of the problem has a pseudoapproximation that for every ǫ > 0 either returns a solution within a 1 + 1 ǫ -factor of the optimum or returns a better than optimal solution that uses 2 Approximation factor lower bounds Problem name Max-Flow Interdiction General hardness Strongly NP-C Planar hardness Pseudo-polynomial[18] DSPEIP BCFIP MPMEIP (introduced) MMEIP (2 − ǫ)-inapproximable (NP-H) [15] Strongly NP-C [20] Strongly NP-C Strongly NP-C [23] Strongly NP-C Strongly NP-C Strongly NP-C Strongly NP-C Problem name General approximation Planar approximation Approximation factor upper bounds Max-Flow Interdiction DSPEIP BCFIP MPMEIP (introduced) Open Open Open Open 1[18] Open Open Open MMEIP O(1) weighted [6], 4 unweighted[23] Pseudo-PTAS Figure 1: A summary of known results about the problems we consider. Our results are displayed in bold. "Open" means that no nontrivial approximation algorithm is known. "NP-C" abbreviates "NP-complete." "NP-H" abbreviates "NP-hard." at most 1 + ǫ times the allocated budget [5, 22]. A standard linear programming formulation of the maximum flow interdiction problem, even after adding two families of valid inequalities, has an integrality gap of Ω(n1−ǫ) for all ǫ ∈ (0, 1) [1]. MMEIP is strongly NP-complete on bipartite graphs, even with unit edge weights and inter- diction costs. Zenklusen [23] introduced a constant factor approximation algorithm for MMEIP on graphs with unit edge weights. This algorithm makes use of iterative LP rounding. Zenklusen [23] also showed that MMEIP is solvable in pseudo-polynomial time on graphs with bounded treewidth. Fewer researchers have worked on interdiction problems restricted to planar graphs. Phillips [18] gave a pseudo-polynomial time algorithm for the directed maximum flow edge interdiction problem. Zenklusen [24] extended this algorithm to allow for some vertex deletions and showed that the planar densest k-subgraph problem reduces to maximum flow interdiction with multiple sources and sinks on planar graphs. Zenklusen [23] left the complexity of matching interdiction on planar graphs as an open problem. 1.2 Our contributions In this paper, we give a pseudo-polynomial time approximation scheme for MMEIP on undirected planar graphs. A pseudo-polynomial time approximation scheme (Pseudo-PTAS) is an algorithm that takes a parameter ǫ ∈ (0, 1) as additional input and outputs a solution with objective value within a multiplicative (1+ǫ)-factor of the optimum (or a (1−ǫ) factor for maximization problems). Furthermore, the algorithm terminates in polynomial time for fixed ǫ. In Section 3, we give a pseudo-polynomial algorithm that achieves the following guarantee: Theorem 1.1. Let I be an edge set with c(I) ≤ B that minimizes ν(G\I). There is an algorithm that, for every ǫ > 0, returns a set bI of edges for which ν(G\bI) ≤ (1 + ǫ)ν(G\I) 3 and c( I) ≤ B. Furthermore, for every fixed ǫ, the algorithm runs in polynomial time with respect to the size of the graph, the sum of the edge weights, and the sum of the interdiction costs of all edges (pseudo-polynomial time). To obtain our Pseudo-PTAS for MMEIP, we extend Baker's technique [3] for interdiction prob- lems on planar graphs. To our knowledge, our algorithm is the first using Baker's technique in solving any network interdiction problem. With Baker's technique, MMEIP can be solved approx- imately in pseudo-polynomial time by using using a tree decomposition with bounded width. We give the approximation ratio and run-time analysis in Section 3. A pseudo-polynomial algorithm is known for solving maximum flow interdiction on directed planar graphs. [18] No pseudo-polynomial algorithms for solving other network interdiction prob- lems on planar graphs are known. We explain this nonexistence by showing that BCFIP, DSPEIP, MPMEIP, and MMEIP are strongly NP-complete even on planar graphs. In Sections 4, 5, 6, and 7 respectively, we prove the following results: Theorem 1.2. It is strongly NP-complete to decide, given an integer budget B > 0 and an integer k ≥ 0, whether or not αE B(G, s, t) > k, even when G is a directed planar graph and s and t border a common face. Theorem 1.3. Given an edge-weighted directed planar graph G, it is strongly NP-complete to decide, given an integer budget B > 0 and an integer k ≥ 0, whether or not ρE B(G, u, v) > k. Theorem 1.4. Given an edge-weighted undirected bipartite planar graph G, it is strongly NP- complete to decide, given an integer budget B > 0 and an integer k ≥ 0, whether or not µE B(G) > k. Theorem 1.5. Given an edge-weighted undirected bipartite planar graph G, it is strongly NP- complete to decide, given an integer budget B > 0 and an integer k ≥ 0, whether or not νE B (G) < k. The strong NP-completeness of MMEIP on planar graphs implies that our Pseudo-PTAS is optimal with respect to approximation ratio, resolving the question asked by Zenklusen [23] about the complexity of MMEIP on planar graphs. We introduce a novel crossing removal technique to show that the BCFIP problem is strongly NP-complete on directed planar graphs. Prior NP-completeness results on planar graphs (e.g. [8, 7, 21]) reduce problems on general graphs to their counterparts on planar graphs by replacing edge crossings with a constant-size graph called a crossing gadget. While crossing gadgets are known for many different problems, they change the numerical value of the solution and, therefore, cannot be approximation-preserving. To our knowledge, we introduce the first simple crossing gadget that preserves the optimal value. We then show that the reduction from maximum flow interdiction (with source and sink on the same face) to multi-objective shortest path on planar graphs [18] also gives an approximation- preserving reduction from s − t planar BCFIP to shortest path interdiction on directed planar graphs. A well-known reduction from the shortest path problem to the assignment problem [11] fails to preserve planarity. We give a new approximation-preserving reduction that reduces directed shortest path interdiction to minimum perfect matching interdiction on planar graphs. Finally, we reduce minimum perfect matching interdiction to MMEIP on planar graphs using edge weight ma- nipulations. Our results distinguish BCFIP, shortest path interdiction, minimum perfect matching interdiction, and MMEIP from the maximum flow interdiction problem, which is solvable in pseudo- polynomial time on planar graphs. In Section 2, we give some notation that we use throughout this paper. In Section 3, we present our Pseudo-PTAS for MMEIP. In Section 4, we prove that BCFIP is strongly NP-complete on planar 4 graphs. In Section 5, we reduce BCFIP to directed shortest path interdiction on planar graphs. In Section 6, we reduce directed shortest path interdiction to minimum perfect matching interdiction. In Section 7, we reduce minimum perfect matching interdiction to MMEIP. We conclude with Section 8, in which we discuss open problems relating to interdiction. 2 Preliminaries For a (undirected or directed) graph G, let V (G) denote its vertex set and E(G) denote its edge set. Edges in a directed graph are denoted by ordered pairs (u, v) for u, v ∈ V (G), while edges in an undirected graph are denoted by unordered pairs {u, v}. For a (undirected or directed) graph G, let G[U ] denote the subgraph induced by the vertices in U ⊆ V (G), i.e. the subgraph of G for which V (G[U ]) = U and E(G[U ]) = {{u, v} ∈ E(G) : u, v ∈ U } (undirected graph, for a directed graph replace {u, v} with (u, v)). For F ⊆ E(G), let G[F ] denote the subgraph of G induced by the edges in F , i.e. the graph with V (G[F ]) = {v ∈ V (G) : ∃w{w, v} ∈ F } (undirected) or V (G[F ]) = {v ∈ V (G) : ∃(w, v) ∈ F ∨ (v, w) ∈ F } (directed) and E(G[F ]) = F . For a set S ⊆ V (G), let δ(S) ⊆ E(G) be the set of edges with exactly one endpoint in S. For a directed graph, let δ+(S) = {(u, v) ∈ E(G) : u ∈ S, v /∈ S} and let δ−(S) = {(u, v) ∈ E(G) : u /∈ S, v ∈ S}. Note that δ(S) = δ−(S) ∪ δ+(S) for any S ⊆ V (G) if G is directed. For a vertex v ∈ V (G), let δ(v) = δ({v}), δ+(v) = δ+({v}), and δ−(v) = δ−({v}). For a directed graph G, let s, t : E(G) → V (G) denote s((u, v)) = u and t((u, v)) = v for all (u, v) ∈ E(G). For any function f : E(G) → R and F ⊆ E(G), let f (F ) =Pe∈F f (e). 2.1 Tree decompositions and treewidth For a set S, let P(S) denote its power set. For an undirected graph G, a tree decomposition [19, 10] of G is a pair (T, B : V (T ) → P(V (G))) where T is a tree. Furthermore, B has the following properties: • ∪w∈V (T )B(w) = V (G) • For all {u, v} ∈ E(G), there is some w ∈ V (T ) such that u, v ∈ B(w). • For any v ∈ V (G), let Uv ⊆ V (T ) be the set of vertices w ∈ V (T ) for which v ∈ B(w). Then, T [Uv] is connected. Let kT = maxw∈V (T ) B(w) − 1 denote the width of T . The treewidth of G is the minimum width of any tree decomposition of G. 2.2 Planar graphs In this paper, we use the combinatorial definition of planar graphs given in [17]. First, we define undirected planar graph embeddings. Consider a set of objects E, which can be thought of as a set of undirected edges. The set of darts is defined as F = E × {−1, 1}. Define a graph G from E as a pair (π, F ) where π is a permutation on the edge set. π is a product of cycles. Let V (G), the vertex set of G, be the set of these cycles. Define three maps headG : F → V (G), tailG : F → V (G), and rev : F → F as follows. Let rev((e, x)) = (e, −x). Note that each dart d ∈ F is in a unique cycle of V (G). Let headG(d) be the unique cycle containing d and let tailG(d) = tailG(rev(d)). An undirected planar graph is also an 5 undirected graph with vertex set V (G) and edge set E(G) = {{tailG(d), headG(d)} : ∀d ∈ F } and let EG : F → E(G) be defined by EG(d) = {tailG(d), headG(d)} for any d ∈ F . The dual graph of G is the graph G∗ := (π ◦ rev, F ). For each edge e, there are precisely two darts d1 and d2 such that EG(d1) = EG(d2) = e. Let DG : E(G) → E(G∗) be the bijection defined by DG(e) := EG∗(d1). Note that EG∗(d1) = EG∗(d2) since d1 = rev(d2) = rev(d2). G is a undirected planar graph if G satisfies Euler's formula, i.e. V (G) − E(G) + V (G∗) = 2. The set of faces of G is defined to be F (G) := V (G∗). Define BG : F (G) → 2V (G) by BG(f ) := V (G[D−1 G (δ(f ))]) and call BG(f ) the set of boundary vertices of f . Now, we define directed planar graphs. Let E and E′ be sets of objects with E ⊆ E′ and let R : E′ → E′ be a bijection with R ◦ R = id and R(e′) 6= e′ for all e′ ∈ E′. E can be thought of as a set of directed edges of a graph, E′ can be thought of as the edge set of the undirected version of the graph, and R can be thought of as the map from an edge to its reverse direction copy. R induces a perfect matching on the elements of E′. A directed planar graph G is a tuple (π, E, E′, R), where π is a permutation on the elements of E′. Furthermore, there is a bijection b between E′ and a set of darts F such that b(R(e′)) = rev(b(e′)) for all e′ ∈ E′, where H = (π, b(E′)). We put a further constraint on G that (π, b(E′)) must be an undirected planar graph. Let V (G) := V ((π, b(E′))) and E(G) := {(tailG(b(e), headG(b(e))) : ∀e ∈ E}. The dual graph G∗ of a directed planar graph G is the directed planar graph (π ◦ rev, E, E′, R). There is a bijection cG : E → E(G) defined by cG(e) = (tailG(b(e), headG(b(e))) for all e ∈ E. Let DG : E(G) → E(G∗) be the map DG = cG∗ ◦ c−1 G . Define the set of faces F (G) := F (H) and the boundary vertices by BG := BH. Since rev ◦ rev = id, the identity permutation, (G∗)∗ = G. One can also show the following propositions: Proposition 2.1. In an undirected planar graph G, let Cs,t ⊆ V (G) be a set such that δ(Cs,t) is a minimum s − t cut with respect to some edge capacity function c : E(G) → R≥0. Furthermore, suppose that s, t ∈ BG(f∞) for some f∞ ∈ F (G). Then, DG(δ(Cs,t)) is a simple cycle in G∗ that passes through f∞. Proposition 2.2. Consider an undirected planar graph G = (π, F ) and consider a face f . f is a cycle C = (d1, d2, . . . , dr) of the permutation π ◦ rev. Let ti := tailG(di) = headG(di−1). Suppose that there are indicies i and j, i ≤ j with i − j 6= 1, 0, −1 (mod r) such that ti = tj. Then G\ti is disconnected. Proof. Since i − j 6= 1, 0, −1 (mod r), there are vertices ta and tb along the boundary cycle with a ∈ [i, j) and b /∈ [i, j) with a 6= i, b 6= j. Create a new graph by replacing ti with two vertices u and v connected by an edge e. Call this graph G′ = (π′, F ′). Note that this graph still satisfies Euler's formula, as the number of vertices increased by one, the number of edges increased by one, and the number of faces did not change. Deleting e from G′ does not change the number of faces or vertices. However, it does decrease the number of edges, so G′\e violates Euler's formula. Therefore, it must be disconnected and any path between ta and tb in G′ must contain e. Contracting e to obtain G shows that any path between ta and tb contains ti = tj. Therefore, ta cannot be connected to tb in G\ti. For an integer k > 0, call an undirected planar graph G a k-outerplanar graph if there is a face f ∞ ∈ F (G) such that for every vertex v ∈ V (G), there is a path containing at most k − 1 edges to a vertex w ∈ BG(f ∞). Bodlaender [4] showed the following theorem: Theorem 2.3. k-outerplanar graphs have treewidth at most 3k − 1. Furthermore, a tree decom- position of width at most 3k − 1 can be found in O(kn) time. 6 Data: An edge-weighted graph G with edge weight function w : E(G) → Z≥0, interdiction cost function c : E(G) → Z≥0, interdiction budget B ≥ 0, and an approximation threshold ǫ > 0 ǫ ⌉; Result: An interdiction set bI ⊆ E(G) with c(bI) ≤ B Let k = ⌈ 2 Fix an arbitrary vertex v; Do a BFS of G from v to obtain edge sets {Ei}r foreach i ∈ {0, 1, . . . , k − 1} do i=0; ⌊ r−i k ⌋ j=0 Ei+jk; Let Fi = ∪ Let Gi be the subgraph of G induced by E(G)\Fi; Let Hi be the subgraph of G induced by Fi; for b = 0, b ≤ B, b = b + 1 do Run Zenklusen's Algorithm on Gi with budget b to obtain a set Iib1 ⊆ E(Gi); Run Zenklusen's Algorithm on Hi with budget B − b to obtain a set Iib2 ⊆ E(Hi); Let Iib = Iib1 ∪ Iib2; end end Return the set Iib for i ∈ {0, 1, . . . , k − 1} and b ∈ {0, 1, . . . , B} that minimizes ν(G\Iib); Figure 2: Algorithm for MMEIP on planar graphs 2.3 Line graphs Let G be an undirected graph. The line graph Lu(G) is an undirected graph with V (Lu(G)) := E(G) and E(Lu(G)) := {{e1, e2} : ∀e1, e2 ∈ E(G) e1 and e2 share an endpoint}. For a directed graph H, the line graph Ld(H) is defined by V (Ld(H)) = E(H) and E(Ld(H)) = {(e1, e2) : ∀e1 = (u1, v1), e2 = (u2, v2) ∈ E(H), v1 = u2}. One can show the following proposition: Proposition 2.4. The directed line graph of a directed planar graph with maximum degree 3 is a directed planar graph. 3 A Pseudo-PTAS for maximum matching interdiction on planar graphs In this section, we introduce a pseudo-polynomial time approximation scheme for the maximum matching interdiction problem (MMEIP). We use many ideas from Baker's framework introduced in [3]. First, we give our Pseudo-PTAS. We will use Zenklusen's algorithm for bounded treewidth graphs in [23] as a subroutine. Now, we prove that the algorithm produces a good interdiction set. First, we show three properties of maximum weight matchings, which encapsulate our use of the structure of matchings to obtain a Pseudo-PTAS: Proposition 3.1. Let G be an edge-weighted graph with weight function w : E(G) → Z≥0 and let H be a subgraph of G. Then, ν(H) ≤ ν(G). Proof. All matchings in H are matchings in G, so the result follows. 7 Proposition 3.2. Let G be an edge-weighted graph with weight function w : E(G) → Z≥0. Consider any F ⊆ E(G). Let G1 be the subgraph of G induced by the edge set F and let G2 be the subgraph of G induced by the edge set E(G)\F . Then, ν(G) ≤ ν(G1) + ν(G2). Proof. Consider a maximum weight matching M of G. Note that M ∩ E(G1) is a matching in G1 and that M ∩ E(G2) is a matching of G2. Since E(G1) ∩ E(G2) = ∅, ν(G) = w(M ) = w(M ∩ E(G1)) + w(M ∩ E(G2)) ≤ ν(G1) + ν(G2) as desired. Proposition 3.3. Let G be an edge-weighted graph with weight function w : E(G) → Z≥0. Pick any node v ∈ V (G) and do a breadth-first search starting from v and label the vertices of G with their distance from v. Let Ei be the set of edges from vertices with label i to vertices with label ⌊ r−i k ⌋ i + 1. Fix an integer k > 1. For all i ∈ {0, 1, . . . , k − 1}, let Fi = ∪ j=0 Ei+jk, where r is the number of labels, and let Gi be the subgraph of G induced by Fi. Then, k−1Xi=0 ν(Gi) ≤ 2ν(G) Proof. Note that for k > 1, no edge in Ei+jk shares an endpoint with any edge in Ei+j ′k for j 6= j′. Therefore, if bGi denotes the subgraph of G induced by Ei, then ν(bGi+jk) k ⌋Xj=0 ν(Gi) = ⌊ r−i Let F ′ = ∪ G′′ be the subgraph of G induced by F ′′. Then, reindexing shows that ⌊ r 2 ⌋ j=0E2j and let F ′′ = ∪ ⌊ r−1 2 ⌋ j=0 E2j+1. Let G′ be the subgraph of G induced by F ′ and let k−1Xi=0 ν(Gi) = rXj=0 ν(bGj) = ν(G′) + ν(G′′) ≤ 2ν(G) We prove Theorem 1.1 by proving two theorems about the performance of Algorithm 1. We restate them here: Theorem 3.4 (Approximation guarantee for Algorithm 1). Let I be an edge set with c(I) ≤ B that minimizes ν(G\I). The set bI returned by Algorithm 1 satisfies ν(G\bI) ≤ (1 + ǫ)ν(G\I) Proof. By Proposition 3.3 applied to G\I, there is some i such that ν(Hi\I) ≤ 2 k ν(G\I). Let b = c(I\Fi). Since c(I) ≤ B, c(I ∩ Fi) ≤ B − b. Zenklusen's algorithm returns the optimal interdiction sets on Gi and Hi for the budgets b and B − b respectively. Therefore, ν(Gi\Iib1) ≤ ν(Gi\I) and 8 ν(Hi\Iib2) ≤ ν(Hi\I). By Proposition 3.1, ν(Gi\I) ≤ ν(G\I). Summing inequalities and applying Proposition 3.2 shows that ν(G\Iib) ≤ ν(Gi\Iib1) + ν(Hi\Iib2) ≤ ν(Gi\I) + ν(Hi\I) ≤ (1 + 2 k )ν(G\I) ≤ (1 + ǫ)ν(G\I) Since ν(G\bI) ≤ ν(G\Iib), we are done. Theorem 3.5 (Runtime guarantee for Algorithm 1). For fixed ǫ, this algorithm terminates in pseudo-polynomial time on planar graphs and, more generally, apex-minor-free graphs. More pre- cisely, on planar graphs, it terminates in time O((2B/ǫ)(V (G)(C + 1)82/ǫ+1 ) + (2B/ǫ)E(G)pV (G)) where C = w(E(G)). Proof. Zenklusen's algorithm [23] has runtime O(V (G)B2(C + 1)2t+1 ) on graphs with treewidth at most t. The breadth-first search at the beginning of the algorithm takes O(E + V ) time. The innermost for loop is run B + 1 times per execution of the outermost for loop, which runs at most k ≤ 2 ǫ + 1 times. By Theorem 2.3, the treewidths of Gi and Hi are at most 3k − 1 and 2 respectively. The computation on Gi dominates the computation on Hi. Using the Hopcroft-Karp algorithm [12] to find the best interdiction set on the last line of Algorithm 1 gives the last term of the runtime. 4 Strong NP-hardness of budget-constrained flow improvement on directed planar graphs In this section, we prove Theorem 1.2. We reduce from the maximum independent set problem on general graphs. Before proving Theorem 1.2, we discuss the proof of the following easier result, which was shown using a different reduction in [20]: Lemma 4.1. The decision version of BCFIP is strongly NP-complete on general directed graphs. Proof. Consider an undirected graph G for which we want to decide if there is an independent set in G of size at least k. Create a graph G1 with one vertex for every vertex of G, one vertex for every edge of G, and two distinguished vertices s and t. The edges in G1 will be split into four sets E1, E2, E3, and E4. There will be directed edges in G1 of the following types: 1. One edge from s to each vertex vv corresponding to a vertex of G. (E1) 2. For every edge e = {u, v} ∈ E(G), two directed edges (vu, e) and (vv, e) in E(G1). (E2) 3. One edge from each vertex ve corresponding to an edge of G to t. (E3) 9 4. One edge from each vertex vv corresponding to a vertex of G to t. (E4) Let d be the maximum degree of any node in G. The capacity function w1 : E(G1) → Z≥0 will be defined as follows: w1(e) = d 1 1 d − degG(η(e)) : e ∈ E1 : e ∈ E2 : e ∈ E3 : e ∈ E4   where η : E4 → V (G) returns the vertex of G corresponding to the left endpoint of the input edge of G1. The cost function c1 : E(G1) → Z≥0 will be defined as follows: c1(e) =(cid:26) 1 : e ∈ E1 0 : e /∈ E1 This construction is depicted in Figure 3. The proof of the following proposition implies the lemma: Proposition 4.2. αE k. k (G1, s, t) = kd if and only if there is an independent set in G of size at least Proof of the if direction. Suppose that G has an independent set S ⊆ V (G) with S ≥ k and let S′ be the corresponding set of vertices in G1. The following function f : E(G) → Z≥0 is a valid flow on G1: f ({v1, v2}) = d 1 1 d − degG(η(e)) 0 : {s, v2} ∈ E1, v2 ∈ S′ : {v1, v2} ∈ E2, v1 ∈ S′ : {v1, t} ∈ E3, v1 ∈ δ(S) (v1 corresponds to an edge in G here) : {v1, t} ∈ E4, v1 ∈ S′ : otherwise   The cost of the nonzero edges in this flow is k, as there are precisely k edges in E1 with positive flow value. The value of this flow is kd, so αE k (G1, s, t) ≥ kd. Since at most k edges from E1 can be paid for, there is a cut of total capacity kd in the subgraph of G induced by paid-for edges. Therefore, αE k (G1, s, t) ≤ kd and this direction is complete. Proof of the only if direction. Suppose that αE k (G1, s, t) = kd. Let f : E(G1) → Z≥0 be a flow with flow value kd. Since at most k edges of E1 can be paid for, f (e) = 0 or f (e) = d for all e ∈ E1. Furthermore, exactly k edgese in E1 have the property that f (e) = d. The right endpoints of these k edges correspond to vertices in G and are denoted as set T . Next, we show that T is an independent set in G. Suppose instead that T is not an independent set and that for two vertices u, v ∈ T , e = {u, v} ∈ E(G). Let u′ and v′ be the corresponding vertices to u and v respectively in V (G1) and let e′ be the vertex in V (G1) corresponding to e. Since f ({s, u′}) = f ({s, v′}) = d, which is full flow, all outgoing edges from u′ and v′ must have full flow. This means that f ({u′, e′}) = f ({v′, e′}) = 1 and that f ({e′, t}) = 2 > w1({e′, t}) = 1, a contradiction. Therefore, T is an independent set in G of size at least k. 10 Since this reduction takes polynomial time, Lemma 4.1 is proven. a c b d 31 31 31 31 10 10 10,a 10,b 10,c 20 10,d Figure 3: The reduction in the proof of Lemma 4.1, with wc as the edge labels. Dashed edges must be paid for, while dark edges are never deleted (since they have cost 0). All edges in E2 (which are the unlabeled edges here) have label 10. There are two properties of this reduction that facilitate crossing removal: 1. If G has an independent set of size k, then there exists a set F ⊆ E(G1) that will give rise to an optimal flow with full flow along all edges in F . 2. If G has an independent set T of size k, δ+(v) ∪ δ−(v) ⊆ F for every vertex v ∈ V (G1) corresponding to a vertex of T . 11 We will prove Theorem 1.2 by removing crossings from G1. First, we will discuss the key idea. The first property states that the existence of an independent set of size at least k guaranteed that all edges transfered either no flow or full flow in. If two edges cross and both have full flow, adding a vertex at their intersection does not alter flow from the original network. If two edges cross and only one edge has full flow, we need to ensure the flow is not redistributed by adding a vertex at the crossing. We will show that there exists a combination of edge capacities and costs to guarantee that no redistribution of flow can result in maximum flow. We will now describe how to remove crossings from G1 to obtain a planar graph G2 with an associated capacity function w2 : E(G2) → Z≥0 and cost function c2 : E(G2) → Z≥0: 1. Embed G1 in an x − y coordinate system so that it has the following properties: • s has coordinates (0, 0) • t has coordinates (1, 0) • all right endpoints of edges in E1 (left endpoints of E2 and E4) have x-coordinate 1 3 • all right endpoints of edges in E2 (left endpoints of E3) have x-coordinate 2 3 • all edges in E1, E2, and E3 are embedded as line segments • all edges in E4 are embedded so that they do not cross edges in E3 2. Obtain G2 by adding vertices at all edge crossings in the x − y coordinate embedding of G1. Note that all of the added crossings will have x-coordinate in the interval ( 1 3 ). Each edges in G2 has a parent edge in G1. For edges in E1 and E3, there are no crossings, and each edge in E1 and E3 has exactly one child edge in G2. The added crossings splits an edge in E2 and E4 into multiple child edges. Thus, an each in E2 and E4 can possibly have multiple child edges. 3 , 2 3. Now, construct w2 as follows: (a) Arbitrarily label the vertices of G1 that correspond to edges of G with the integers 1 through E(G) inclusive. (b) For any edge e ∈ E(G2) with its parent (a copy of itself) in E1 (within G1), let w2(e) = E(G)2. (c) For any edge e ∈ E(G2) with its parent in E2, let w2(e) be the label (assigned above in (a)) of the right endpoint of the parent of e in G1. (d) For any edge e ∈ E(G2) with its parent (a copy of itself) in E3, let w2(e) be the label (assigned above in (a)) of the left endpoint of the parent of e in G1. (e) For any edge e ∈ E(G2) with its parent in {u, t} ∈ E4, let w2(e) = E(G)2 − Xe∈E(G2): w2(e) e∈δ+(u),κ(e)∈E2 where κ : 2E(G2) → 2E(G1) returns the parent edge of a child edge G2. See Fig. 4. 4. Finally, construct c2 as follows: (a) Sort the crossing vertices added to G1 in increasing order by x-coordinate (with ties i=1, where r denotes the number of added points. broken arbitrarily) to obtain a list {vi}r 12 (b) For any edge e ∈ E(G2) with its parent in E1, let c2(e) = w2(e) = E(G)2. (c) For any edge e = {vi, vj} ∈ E(G2) with its parent in E2 or E4, let c2(e) = (j − i)w2(e). (d) For any edge e = {u, vi} ∈ E(G2) with its parent in E2 or E4 and u having x-coordinate 1 3 , let c2(e) = iw2(e). (e) For any edge e = {vi, w} ∈ E(G2) with its parent in E2 and w having x-coordinate 2 3 , let c2(e) = (r + 1 − i)w2(e). (f) For any edge e = {vi, t} ∈ E(G2) with its parent in E4, let c2(e) = (r + 2 − i)w2(e). (g) For any edge e = {u, w} ∈ E(G2) with its parent in E2, u with x-coordinate 1 3 , and w with x-coordinate 2 3 , let c2(e) = (r + 1)w2(e). (h) For any edge e = {u, t} ∈ E(G2) with its parent in E4 and u with x-coordinate 1 3 , let 3 , let (i) For any edge e = {w, t} ∈ E(G2) with its parent in E3 and w with x-coordinate 2 c2(e) = (r + 2)w2(e). c2(e) = w2(e). Proposition 4.3. For any positive integer k, the total edge cost of a flow with value at least kE(G)2 must be at least (r + 3)kE(G)2. Proof. In the embedding construction of G2, there are with r + 3 cuts associated with the con- struction in order by x-coordinate. Let {zi}r 3 , and zr+1 = 2 3 . Let cut Ci ⊆ E(G2) for i ∈ {1, 2, . . . , r + 1} be the set of edges intersected by the line x = zi−1+zi 2 i=1 be the x-coordinates of the crossings, z0 = 1 . Let C0 = E1 and Cr+2 = E3 ∪ E4. The cost of an edge e with capacity w2(e) in G2 is assigned as w2(e) times the number of these r + 3 cuts that e is in. For any s − t path in G2, the path intersects each of the r + 3 cuts exactly once. Therefore, the cost of sending one unit of flow in G2 is at least (r + 3), and sending kE(G)2 units of flow costs at least (r + 3)kE(G)2. This completes the proof. Proposition 4.4. For any positive integer k, the total edge cost of a flow with value at least kE(G)2 that has partial flow along at least one edge must be at least (r + 3)kE(G)2 + 1. Proof. Let e ∈ E(G2) be an edge with partial flow under a flow f : E(G2) → Z≥0. Consider one of the r + 3 cuts discussed in the proof of Proposition 4.3 that contains e. It suffices to show that the cost of edges in this cut is at least kE(G)2 + 1. Since the capacities and flows through edges are integers and flow on e is less than its capacity, c2(e) − f (e) ≥ 1, which implies the result. Proposition 4.5. Let G2 be the planar graph that results from edge crossing removal. Consider two edges e, e′ ∈ E(G1) that cross in the x − y embedding of G1. Consider any edges f, f ′ ∈ E(G2) with parent edges e and e′ respectively. Then, w2(f ) 6= w2(f ′). Proof. Note that all children of e have the same maximum capacity. The same holds for children of e′. Parts (a) and (c) of Part 3 of the construction ensure that if e, e′ ∈ E2, then w2(f ) 6= w2(f ′). Note that no two edges in E4 cross in the embedding of G1. The only other possible scenario with a crossing occurs when e ∈ E2 and e′ ∈ E4. It suffices to show that w2(f ′) ≥ E(G)2−E(G) > E(G) if E(G) ≥ 4 (if E(G) ≤ 3, we can solve the instance with brute force in constant time). This suffices because the weight of any edge with a parent in E2 is at most E(G). 2 These three properties are important for proving the next lemma. This lemma implies Theorem 1.2 since the reduction takes polynomial time, the edge weights are polynomially bounded in the size of the graph, and G2 is planar. 13 Lemma 4.6. G has an independent set of size at least k if and only if there is a flow on G2 with total edge cost at most (r + 3)kE(G)2 with value kE(G)2. Proof. First, suppose that G has an independent set S ⊆ V (G) with S ≥ k. Construct a flow f : E(G2) → Z≥0 as follows: 1. Start by finding a flow f ′ : E(G1) → Z≥0, where G1 has a new capacity function w′ 2 : E(G1) → Z≥0 defined by w′ 2(p) = w2(e) for any child e of p (since all children have the same capacity). Let S1 ⊆ V (G1) be the vertices G1 corresponding to vertices of S in G and let T1 ⊆ V (G1) be the vertices of G1 corresponding to edges in δ(S) in G. Since S is an independent set of G, the function f ′(p) =(cid:26) w′ 0 2(p) : p ∈ δ(S1) ∪ δ+(T1) : p /∈ δ(S1) ∪ δ+(T1) is a flow on G1 under the capacity function w′ 2 with flow value kE(G)2. 2. Define f by f (e) = f ′(p) for all e ∈ E(G2) with parent p ∈ E(G1). Note that f also has flow value kE(G)2. One can check that the flow f has cost (r+3)kE(G)2 as well, completing this direction. Now, suppose that G2 has a flow f : E(G2) → Z≥0 with total edge cost (r+3)kE(G)2 and value kE(G)2. By Proposition 4.4, all edges either have no flow or full flow. Let F ⊆ E(G2) be the set of edges with full flow. We will start by showing that there is a flow f ′ on G1 with capacity function 2 such that for all edges e ∈ E(G2) with parent p ∈ E(G1), f (e) = f ′(p). Let the sequence w′ of crossings as they were ordered for assigning edge costs in Part (4a) be {xi}r i=1. For every p ∈ E2 ∪ E4, it suffices to show that its children have equal flow values under f . Consider a crossing xi. Let e1, e2 be the incoming edges and let e′ 2) = w2(e2) and w2(e′ 1) = w2(e1). By Proposition 4.5, w2(e2) 6= w2(e1). There are four cases that must be dealt with, since all edges either have full flow or no flow with respect to f : 2 be the outgoing edges, with w2(e′ 1, e′ 1. f (e1) = f (e2) = 0. In this case, the only possible flow for e′ 1 and e′ 2 is f (e′ 1) = f (e′ 2) = 0. 2. f (e1) = w2(e1) and f (e2) = w2(e2). This is full flow, so f (e′ 1) = w2(e1) and f (e′ 2) = w2(e2). 3. f (e1) = w2(e1) and f (e2) = 0. If any flow is sent along e′ 1) = 0 and e′ 2 has partial flow (since w2(e′ 1) 6= w2(e′ 2, then e′ 1 has partial flow or 2)). Therefore, no flow is sent on e′ 2 f (e′ and f (e′ 2) = 0, f (e′ 1) = w2(e1). 4. f (e1) = 0 and f (e2) = w2(e2). It is not possible to send full flow along e′ 1 in this case (similar to the previous case), so f (e′ 1) = 0 and f (e′ 2) = w2(e2). In all cases, note that f (e1) = f (e′ 1) and f (e2) = f (e′ 2). Since this is true at all crossings, f may be lifted to a flow f ′ : E(G1) → Z≥0 with f ′(p) = f (e), where p is the parent of e ∈ E(G2). As in the proof of Lemma 4.1, form an set S ⊆ V (G) by taking the vertices of G corresponding to left endpoints of edges with full flow under f ′ in G1. Note that S = k, since there must be exactly k edges in E1 with full flow and all other edges with no flow to give a flow value of kE(G)2. It suffies to show that S is an independent set of G. Suppose, instead, that there are two vertices v1, v2 ∈ S such that {v1, v2} ∈ E(G). This implies that there is a vertex u in G1 corresponding to 14 {v1, v2} such that there are two incoming edges with full flow. However, this cannot occur, as this sum of the flows in these two edges will be double the capacity of the outgoing edge from u in E3. This is a contradiction, so S must be an independent set. 31 31 31 31 10 10 00 20 10,a 10,b 10,c 10,d 1616 1616 1616 1616 17 1352 13 13 212 1260 24 26 312 22 11 36 24 742 321 33 412 1236 416 428 11,a 1352 1236 714 1260 22,b 33,c 44,d Figure 4: The result of crossing removal in the proof of Theorem 1.2. Labels are wc. Note that six crossings were added, so r = 6 in this example. It costs at least 9 units of budget to send a unit of flow from s to t. Furthermore, at any added crossing, the capacities of the incoming edges are distinct. 15 5 Strong NP-hardness of shortest path interdiction on directed planar graphs To prove Theorem 1.3, we reduce from BCFIP on planar graphs with source and sink adjacent to a face together, invoking Theorem 1.2 to finish the proof. We use the max-flow min-cut theorem, the dual graph, and the fact that BCFIP is still strongly NP-complete when s and t are adjacent to one face to show that the max-flow problem can be transformed into a shortest path problem. The idea is similar to that of [18] to show that the maximum flow interdiction problem is solvable in pseudo-polynomial time. Consider a directed planar graph G, capacity function w : E(G) → Z≥0, cost function c : E(G) → Z≥0, budget B > 0, source vertex s, and sink vertex t which collectively form an instance of BCFIP. Furthermore, assume that s and t are adjacent to a face together and G\s and G\t are connected (note that this is satisfied by the construction in Section 4). Without loss of generality, let this face be the infinite face of G. We will now construct a planar instance of DSPEIP as follows: 1. Embed G in the plane as (π, E(G), E′, R), where E′ = {(u, v), (v, u) : ∀(u, v) ∈ E(G)} and R((u, v)) = (v, u) for all u, v ∈ V (G). Let G1 = G∗ be the directed planar dual with respect to this embedding (see Figure 5) and let w ∈ V (G1) be the vertex corresponding to the infinite face of G. 2. Split w into two vertices u and v to obtain the vertices of a graph G2 and split the edges incident with w as follows. Let W = {wi}k i=1 be a closed undirected walk in G of vertices adjacent to the infinite face of G that visits s and t exactly once with w1 adjacent to wk. Let E(W ) denote the set of edges on this walk. This walk exists because G\s and G\t are connected (see Proposition 2.2). Without loss of generality, suppose that s appears before t in W . Partition E(W ) into two sets Est and Ets, where Est consists of edges that appear after s and before t in W and Ets = E(W )\Est. Have edges of DG(Est) be incident with u instead of w and have the edges of DG(Ets) be incident with v instead of w. Let g2 : E(G) → E(G2) be the edge set bijection described by this construction. 3. Create a new graph G3 from G2 in which every edge is replaced with three copies, two in the same direction and one in the opposing direction. Let g3a : E(G) → E(G3) and g3b : E(G) → E(G3) injectively map edges of G to same direction copies in G3 and let g3c : E(G) → E(G3) injectively map edges of G to reversed edges of G3. Note that the sets g3a(E(G)), g3b(E(G)), and g3c(E(G)) form a partition of E(G3). 4. Let w3(g3a(e)) = w(e) and w3(g3b(e)) = w3(g3c(e)) = 0 for each edge e ∈ E(G). 5. Let c3(g3a(e)) = B + 1, c3(g3b(e)) = c(e), and c3(g3c(e)) = B + 1 for each edge e ∈ E(G). Now, we prove Theorem 1.3: Proof. Since the directed shortest path problem is in P, DSPEIP is in NP. Consider a graph G with a capacity function w : E(G) → Z≥0, cost function c : E(G) → Z≥0, budget B, and source/sink nodes s and t. By the max-flow min-cut theorem, solving BCFIP on G is equivalent to solving the following problem on G: Given: The directed graph G with its capacity function w, cost function c, budget B, and source/sink nodes s and t. 16 17 1616 11 1616 1616 22 11 36 24 1236 1616 1352 13 212 13 1352 1260 24 22 742 412 26 312 321 1236 714 33 33 1260 416 44 428 Figure 5: Reduction in the proof of Theorem 1.3. Dotted edges are edges from the old graph (from Figure 4), while filled edges represent three different edges in the new graph. Every filled directed edge with weight wc in the new graph corresponds to one edge with weight 0c in the same direction, one edge with weight w∞ in the same direction, and one edge with weight 0∞ in the opposite direction. 17 Figure 6: The first crossing diagram denotes the right orientation, while the second crossing diagram denotes the left orientation. Dotted edges are in G, while full edges are in G3. Note that for every edge e ∈ E(G), g3a(e) and g3b(e) cross it in the right orientation, while g3c(e) crosses e in the left orientation. Find: A set of edges I ⊆ E(G) with c(I) ≤ B such that the total capacity of a minimum cut in G[I] is maximized. More precisely, I is a set that maximizes min S⊆V (G):s∈S,t /∈S w(δ+(S) ∩ I) = α(G[I], s, t) Now, construct the directed graph G3 by applying the previously described planar BCFIP to planar DSPEIP reduction with edge weight function w3 : E(G3) → Z≥0, interdiction cost function c3 : E(G3) → Z≥0, and budget B (the same budget as for G). First, we show that ρ(G3\g3b(I), u, v) ≥ α(G[I], s, t) for any I ⊆ E(G). For this, it suffices to show that any u − v shortest path in G3\g3b(I) from u to v can be made into an s − t cut in G[I] with the same weight. Consider a directed path P ⊂ E(G3)\g3b(I). Consider a simultaneous embedding of G and G3 in which no two edges of G cross, no two edges of G3 cross, and every edge e ∈ E(G) crosses g3a(e), g3b(e), and g3c(e). This also implies that every edge g3a(e) ∈ E(G3) crosses e ∈ E(G) (similarly for g3b and g3c). In this embedding, edges of G3 cross edges of G in two different orientations (see Figure 6). Partition P into two sets Pright and Plef t by crossing orientation. Note that Plef t ⊆ g3c(E(G)). Therefore, w3(Plef t) = 0. The edges in Pright are either in g3a(I) or g3b(E(G)). If there is an edge e ∈ E(G)\I such that g3a(e) ∈ P , then P can be made shorter or kept the same length in G3 by replacing g3a(e) with g3b(e). Therefore, we may assume that Pright only contains edges in g3a(I) or g3b(E(G)\I). DG(g−1 3a (P ) ∪ g−1 3b (P ) ∪ g−1 G1. By Proposition 2.1, g−1 G[I] only contains edges in I, w3(Pright) = w(g−1 from G[I] disconnects s and t in G[I]. Therefore, ρ(G3\g3b(I), u, v) ≥ α(G[I], s, t). 3c (P )) is a cycle (not necessarily directed) that passes through w in 3c (P ) is an s − t cut. Since w3(g3b(E(G)\I)) = 0 and 3c (Plef t) 3b (P ) ∪ g−1 3a (Pright)) and removing g−1 3a (Pright) ∪ g−1 3a (P ) ∪ g−1 To complete the proof of Theorem 1.3, it suffices to show that ρ(G3\g3b(I), u, v) ≤ α(G[I], s, t) for any I ⊆ E(G) such that c(I) ≤ B. We just need to show that any minimum s − t cut in G[I] can be made into a path of G3\g3b(I) from u to v with equal weight. A minimum s − t cut in G[I], say given by the set S with s ∈ S, t /∈ S, corresponds to a cycle in the undirected dual graph that passes through the vertex corresponding to the infinite face of G[I] by Proposition 2.1. Splitting this cycle at the vertex corresponding to the infinite face into u and v shows that there is a directed path in G3\g3b(I) from u to v that crosses the edges in δ(S) ∩ I and no other edges in G[I]. If this path crosses any edges e ∈ E(G)\I, it can pass through g3b(e) if it crosses with right orientation or g3c(e) if it crosses with left orientation. When the path crosses any edges e ∈ I, it can pass through g3a(e) if it crosses with right orientation or g3c(e) if it crosses with left orientation. This will cause the path to have the same weight as the cut, showing that ρ(G3\g3b(I), u, v) ≤ α(G[I], s, t). 18 6 Strong NP-hardness of minimum perfect matching interdiction on planar bipartite graphs To prove Theorem 1.4, we introduce a new reduction from the directed shortest path problem to the minimum perfect matching problem. Unlike the currently used reduction in [11], this reduction preserves planarity. Like the reduction in [11], this reduction produces a bipartite graph. Given a directed planar graph G (instance of DSPEIP) with weight function w : E(G) → Z≥0, interdiction cost function c : E(G) → Z≥0, interdiction budget B > 0, path start node u, and path end node v, we construct three planar graphs before obtaining an instance of MPMEIP: 1. Construct a directed planar graph G1 on which solving DSPEIP is equivalent to solving DSPEIP on G. All vertices of G1 except for u and v have degree at most 3. (a) Attach leaves u1 to u and v1 to v, with a directed edge from u1 to u and from v to v1. (b) Replace any vertex w ∈ V (G) with δ(w) > 3 (including the added leaves in the previous step) with a counterclockwise directed cycle of δ(w) edges. Number the new vertices w1, . . . , wδ(w) and suppose that the counterclockwise order of incoming and outgoing edges for w is e1, . . . , eδ(w). For the edge ei, reassign the endpoint that is w to wi. Let this graph be G1. Let f : E(G) → E(G1) map edges of G to the corresponding edge of G1. (c) If e ∈ E(G), let w1(f (e)) = w(e). If e ∈ E(G1)\f (E(G)), let w1(e) = 0. (d) If e ∈ E(G), let c1(f (e)) = c(e). If e ∈ E(G1)\f (E(G)), let c1(e) = B + 1. See an illustration of this construction in Figure 7. 2. Construct the line graph L(G1) and add two vertices u2 and v2 to the graph. Construct G2 from this graph by adding an edges {u2, e} for the edge e ∈ δ+(u1) in G1 and {e, v2} for the edge e ∈ δ−(v1) in G1. Let f1 : E(G1) → V (G2) be the injection induced by this construction. Note that directed paths from u1 to v1 in G1 are mapped to undirected paths in G2. Since G1 only has vertices (besides u1 and v1) with maximum degree three, G2 is planar by Proposition 2.4. See an illustration of this step in Figure 8 3. Construct a weighted undirected planar graph G3 from G2. Minimum perfect matchings in subgraphs obtainable by interdiction of G3 correspond to shortest paths from u1 to v1 in subgraphs of G1. (a) For every edge e ∈ E(G1), split f1(e) ∈ V (G2) into four vertices f2a(f1(e)), f2b(f1(e)), f2c(f1(e)), f2d(f1(e)) ∈ V (G3) and three edges {f2a(f1(e)), f2b(f1(e))}, {f2b(f1(e)), f2c(f1(e))}, {f2c(f1(e)), f2d(f1(e))} ∈ E(G3). Define g2a : f1(E(G1)) → E(G3) by g2a(f1(e)) = {f2a(f1(e)), f2b(f1(e))} Define g2b and g2c similarly. Endpoints of edges of G2 are reassigned to f2b, f2c, or f2d of the corresponding endpoints. (b) Let w3(g2b(f1(e))) = w1(e) for all e ∈ E(G1). For all other edges e ∈ E(G3), let w3(e) = 0. 19 31 21 11 31 21 21 31 11 61 41 3 0 0 0 0 0 3 2 2 1 2 3 1 0 6 0 0 4 0 0 Figure 7: Depiction of Step 1, Section 6. All added edges have edge weight 0∞. Since v is a leaf of G, no edges weight with weight 0 is added to make v a leaf. 3 0 0 0 0 0 3 2 2 1 2 3 1 0 6 0 0 4 0 0 Figure 8: Depiction of Step 2, Section 6 (c) Let c3(g2b(f1(e))) = c1(e) for all e ∈ E(G1). For all other edges e ∈ E(G3), let c3(e) = B + 1. (d) Rename u2 and v2 with u3 and v3 respectively. See an illustration of this construction in Figure 9 Since finding a minimum weight perfect matching in a graph is in P, MPMEIP is in NP. Note that the construction for Theorem 1.3 has the property that for all interdiction sets I ⊆ E(G) with c(I) ≤ B, there is a directed path from u to v in G\I. We will now show that this construction suffices for proving strong NP-hardness of MPMEIP through three theorems. Theorem 6.1. For any interdiction set I ⊆ E(G) with c(I) ≤ B, there is a perfect matching in G3\g2b(f1(f (I))) with the weight of a shortest path from u to v in G\I. (i.e. µ(G3\g2b(f1(f (I)))) ≤ ρ(G\I, u, v)). Proof. Let P ⊆ E(G) be a shortest path from u to v in G\I (since a path from u to v exists in G\I). Note that f (P ) is not a path from u1 to v1 in G1 if P passes through vertices with degree at Figure 9: Depiction of one vertex subdivision in Step 3, Section 6 0 20 least four. However, every vertex in G with degree at least four is replaced with a directed cycle to obtain G1. Therefore, for two consecutive edges e, e′ ∈ P with e′ following e and shared endpoint w, there is a path with weight 0 from t(f (e)) to s(f (e′)). All of these added edges are in G1\f (I), since c1(d) = B + 1 for each added edge d. Since P passes through every vertex of G at most once, the result of adding segments from each directed cycle corresponding to a vertex of G with degree at least four is a path. Call this path Q ⊆ E(G1). Since all added edges have weight zero, w1(Q) = w(P ). We now show that there is a perfect matching N ⊆ E(G3)\g2b(f1(f (I))) with w3(N ) = w1(Q). For any u − v simply path L in G1, there exists the unique perfect matching in G3 in which g2b(f1(L)) ∪ g2a(f1(E(G1)\L)) ∪ g2c(f1(E(G1)\L)) is a part of the matching. Note that w3(g2b(f1(Q))) = w1(Q) and that M := g2b(f1(Q)) ∪ g2a(f1(E(G1)\Q)) ∪ g2c(f1(E(G1)\Q)) is a matching in G3\g2b(f1(f (I))). Furthermore, M is a subset of a unique perfect matching N ⊆ E(G3)\g2b(f1(f (I))) with w3(N ) = w3(M ) = w1(Q) = w(P ). Therefore, N is the desired perfect matching. Theorem 6.2. For any interdiction set I ⊆ E(G) with c(I) ≤ B, there is a path in G\I from u to v with the weight of a minimum weight perfect matching in G3\g2b(f1(f (I))). (i.e. µ(G3\g2b(f1(f (I)))) ≥ ρ(G\I, u, v)). 1 (g−1 1 (g−1 Proof. It suffices to show that ρ(G1\f (I), u1, v1) ≤ µ(G3\g2b(f1(f (I)))). Consider a perfect match- ing M ⊆ E(G3)\g2b(f1(f (I))). M exists by the proof of Theorem 6. Note that w1(f −1 2b (M ))) = w3(M ) and that f −1 2b (M )) is a directed path from u to v in G1 unioned with directed cycles. Let C ⊆ E(G1) be one of these directed cycles. Note that adding the edges g2a(f1(C)) ∪ g2c(f1(C)) to M results in a cycle. Removing the edges of this cycle besides g2a(f1(C)) ∪ g2c(f1(C)) from M (which includes g2b(f1(C))) and adding g2a(f1(C)) ∪ g2c(f1(C)) results in another perfect matching N in G3\g2b(f1(f (I))) with w3(N ) ≤ w3(M ). This contradicts the fact that M is a minimum perfect matching (unless N has the same weight, in which we could have started out with it). Furthermore, f −1 2b (N )) has one fewer directed cycle. Therefore, there is a minimum perfect matching K ⊆ E(G3)\g2b(f1(f (I))) with f −1 2b (K)) a directed path from u1 to v1. Therefore, we are done. 1 (g−1 1 (g−1 Theorem 6.3. If G is a directed planar graph, then G3 is an undirected planar bipartite graph. Proof. Replacing vertices with cycles preserves planarity. Since the vertices in G1 have degree at most three, the construction to obtain G2 preserves planarity. Finally, the construction to obtain G3 preserves planarity, so all of this construction preserves planarity. Now, it suffices to show that for any input directed graph G, G3 is bipartite. For this, one can show that G3 only has even cycles. Let C ⊆ E(G3) be a cycle in G3. Note that u3 and v3 cannot be a part of C. Furthermore, D := f −1 2c (C)) is a cycle in the undirected version of G1. Although D may not be a directed cycle in G1, the number of vertices on the cycle D at which the direction of the edges reverses must be even. 2b (C) ∪ g−1 2a (C) ∪ g−1 1 (g−1 Let T ⊆ V (G1) be the vertices of D and let S ⊆ T be the set of vertices at which D switches direction. Every vertex w in G1 is associated with one or two edges in G3 that connect f2a(e) and f2d(e′) for edges e, e′ ∈ G1 with t(e) = s(e′) = w. D switches direction at w only when C passes through exactly two edges corresponding to w in G3. Also, D maintains direction through w only when C passes through one edge corresponding to w in G3. Therefore, C = 3D + T + S = 4D + S. Since S is even by the previous paragraph, C is even, as desired. 21 7 Strong NP-hardness of maximum matching interdiction on pla- nar bipartite graphs We will prove Theorem 1.5 by edge weight manipulations. For an edge-weighted graph G with a perfect matching, let γ(G) be the maximum weight of any perfect matching in G. We will start by showing that the decision version of the following problem is strongly NP-complete on bipartite planar graphs: Input: An edge-weighted graph G = (V, E) with edge weight function w : E → Z≥0, interdic- tion cost function c : E → Z≥0, and interdiction budget B > 0. It is assumed that, for every set I ⊆ E with c(I) ≤ B, G\I has a perfect matching. Output: The subset I ⊆ E with c(I) ≤ B that minimizes γ(G\I). Now, we will reduce MPMEIP to this problem, which is NP because the maximum perfect matching problem is in P. Suppose we are given a graph G with weight function w : E(G) → Z≥0, cost function c : E(G) → Z≥0, and interdiction budget B > 0 on which we want to solve MP- MEIP. Let W = maxe∈E(G) w(e) and consider the weight function w′ : E(G) → Z≥0 defined by w′(e) = W − w(e) for all e ∈ E(G). To prove strong NP-completeness, it suffices to show the following lemma (since edge weights are still bounded by a polynomial in the size of the graph): Lemma 7.1. For any interdiction set I ⊆ E(G) with c(I) ≤ B, γw′(G\I) = W V (G) 2 − µw(G\I). Proof. First, we will show that γw′(G\I) ≤ W V (G) − µw(G\I). By the definition of MPMEIP, G\I has a perfect matching. Let M ⊆ E(G)\I be one such perfect matching. Note that M = V (G) . Therefore, w′(M ) = W V (G) − w(M ). Taking M to be the maximum perfect matching with respect to w′ shows that γw′(G\I) = W V (G) − µw(G\I). Taking M to be the minimum perfect matching with respect to w shows that γw′(G\I) ≥ w′(M ) = W V (G) − µw(G\I), as desired. − w(M ) ≤ W V (G) 2 2 2 2 2 2 Finally, we will use this strong NP-completeness result to show that MMEIP is strongly NP- complete on planar graphs. Note that MMEIP is in NP because the maximum matching problem is in P. Let w′′ : E(G) → Z≥0 be defined by w′′(e) = w′(e) + 2νw′(G) + 2. It suffices to show the following lemma, since the weights w′′ are polynomially bounded in the size of the graph: Lemma 7.2. For any interdiction set I ⊆ E(G) with c(I) ≤ B, γw′(G\I)+V (G)νw′(G)+V (G) = νw′′(G\I). Proof. Consider a perfect matching M ⊆ E(G)\I. Note that w′(M ) + V (G)νw′(G) + V (G) = w′′(M ) because M = V (G) . Therefore, if M is the maximum weight perfect matching with re- spect to w′ in G\I, then γw′(G\I) + V (G)νw′(G) + V (G) = w′′(M ) ≤ νw′′(G\I). 2 Now, suppose that M is a maximum weight matching with respect to w′′. Suppose, for the sake of contradiction, that M ≤ V (G) 2 − 1. Then, 22 νw′′(G\I) = w′′(M ) ≤ w′(M ) + (2νw′(G) + 2)( V (G) 2 − 1) ≤ (V (G) − 1)νw′(G) + V (G) − 2 However, the weight of any perfect matching with respect to w′′ is at least (νw′(G) + 1)V (G) > (V (G) − 1)νw′(G) + V (G) − 2, which contradicts the fact that M is a maximum weight matching. Therefore, M = V (G) and is perfect. Therefore, 2 νw′′(G\I) = w′′(M ) = w′(M ) + (2νw′(G) + 2) V (G) 2 ≤ γw′(G\I) + V (G)νw′(G) + V (G) as desired. 8 Conclusion and open problems In this paper, we described the complexity of edge interdiction problems when restricted to planar graphs. We presented a Pseudo-PTAS for the weighted maximum matching interdiction problem (MMEIP) on planar graphs. The algorithm extends Baker's Technique for local bilevel min-max optimization problems on planar graphs. Furthermore, we gave strong NP-hardness results for budget-constrained maximum flow (BCFIP), directed shortest path interdiction (DSPEIP), mini- mum perfect matching interdiction (MPMEIP), and maximum matching interdiction (MMEIP) on planar graphs. The latter three results followed from the strong NP-completeness of BCFIP on directed planar graphs with source and sink on a common face. This strong NP-completeness proof first reduced the maximum independent set problem to BCFIP on general directed graphs. We then noticed that optimal flows on these directed graphs had either full flow or no flow along all edges. To take advantage of this fact, we introduced a sweepline technique for assigning transportation costs and edge capacities in order to ensure that no two crossing edges had the same capacity. After introducing this embedding technique, edge crossings could be replaced with just one vertex. There are many interesting open problems relating to interdiction. While hardness of approxi- mation results are known for shortest path interdiction [15], it is only known that a (2 − ǫ)-factor pseudo-polynomial time approximation would imply that P = N P . While heuristic solutions are known for the shortest path interdiction problem [13], no approximation algorithms with nontrivial approximation (or pseudoapproximation) guarantees are known. For the maximum matching in- terdiction problem, Zenklusen [23] showed several hardness of approximation results. Nonetheless, no hardness of approximation results are known for MMEIP (computing νE B (G) within a multi- plicative factor). A pseudoapproximation is known for a continuous variant of the maximum flow interdiction problem [5]. However, no algorithms and no hardness of approximation results are known for the (discrete) maximum flow interdiction problem on general directed graphs. While we now know that BCFIP, directed shortest path interdiction, mimimum perfect matching interdiction, and MMEIP are strongly NP-complete on planar graphs, there are no known Pseudo- PTASes for BCFIP, shortest path interdiction, and minimum perfect matching interdiction when 23 restricted to planar graphs. Acknowledgements The authors are supported by Defense Threat Reduction Agency grant BRCALL08-A-2-0030, the Office of the Dean of the College at Princeton University, the Center for Nonlinear Studies at Los Alamos National Laboratory, and the DHS-STEM Research Fellowship Program. This research was performed under an appointment to the U.S. Department of Homeland Security (DHS) Science and Technology (S&T) Directorate Office of University Programs HS-STEM Summer Internship Program, administered by the Oak Ridge Institute for Science and Education (ORISE) through an interagency agreement between the U.S. Department of Energy (DOE) and DHS. ORISE is managed by the Oak Ridge Associated Universities (ORAU) under DOE contract number DE- AC05-06OR23100. All opinions expressed in this paper are the author's and do not necessarily reflect the policies and views of DHS, DOE, and ORAU/ORISE. References [1] Douglas S. Altner, Ozlem Ergun, and Nelson A. Uhan. The maximum flow network interdiction problem: Valid inequalities, integrality gaps, and approximability. Oper. Res. Lett., 38(1):33 -- 38, 2010. [2] N. Assimakopoulos. A network interdiction model for hospital infection control. Comput. Biol. Med., 17(6):413 -- 422, 1987. [3] Brenda S. Baker. Approximation algorithms for np-complete problems on planar graphs. J. ACM, 41(1):153 -- 180, 1994. [4] Hans L. Bodlaender. Some classes of graphs with bounded treewidth. Bulletin of the EATCS, 36:116 -- 125, 1988. [5] Carl Burch, Robert Carr, Sven Krumke, Madhav Marathe, Cynthia Phillips, and Eric Sund- berg. A decomposition-based pseudoapproximation algorithm for network flow inhibition. In DavidL. Woodruff, editor, Network Interdiction and Stochastic Integer Programming, vol- ume 22 of Operations Research/Computer Science Interfaces Series, pages 51 -- 68. Springer US, 2003. [6] Michael Dinitz and Anupam Gupta. Packing interdiction and partial covering problems. In IPCO, pages 157 -- 168, 2013. [7] Michael R. Garey and David S. Johnson. The rectilinear steiner tree problem in np complete. SIAM Journal of Applied Mathematics, 32:826 -- 834, 1977. [8] Michael. R. Garey, David S. Johnson, and Robert E. Tarjan. The planar hamiltonian circuit problem is np-complete. SIAM J. Comput., 5(4):704 -- 714, 1976. [9] Montgomery D.C. Ghare, P.M. and W.C. Turner. Optimal interdiction policy for a flow network. Naval Research Logistics Quarterly, 18:37 -- 45. [10] Rudolf Halin. S-functions for graphs. Journal of Geometry, 8(1-2):171 -- 186, 1976. 24 [11] A. J. Hoffman and H. M. Markowitz. A note on shortest path, assignment, and transportation problems. Naval Research Logistics Quarterly, 10(1):375 -- 379, 1963. [12] John E. Hopcroft and Richard M. Karp. A n5/2 algorithm for maximum matchings in bipartite graphs. In SWAT (FOCS), pages 122 -- 125, 1971. [13] Eitan Israeli and R. Kevin Wood. Shortest-path network interdiction. Networks, 40:2002, 2002. [14] R. Kevin Wood Javier Salmeron and Ross Baldick. Worst-case interdiction analysis of large- scale electric power grids. IEEE Transactions on Power Systems, 24:96 -- 104, 2009. [15] Leonid Khachiyan, Endre Boros, Konrad Borys, Khaled M. Elbassioni, Vladimir Gurvich, G´abor Rudolf, and Jihui Zhao. On short paths interdiction problems: Total and node-wise limited interdiction. Theory Comput. Syst., 43(2):204 -- 233, 2008. [16] K. Malik, A. K. Mittal, and S. K. Gupta. The k most vital arcs in the shortest path problem. Oper. Res. Lett., 8(4):223 -- 227, August 1989. [17] Bojan Mohar and Carsten Thomassen. Graphs on Surfaces. Johns Hopkins series in the mathematical sciences. Johns Hopkins University Press, 2001. [18] Cynthia A. Phillips. The network inhibition problem. In STOC, pages 776 -- 785, 1993. [19] Neil Robertson and P.D Seymour. Graph minors. iii. planar tree-width. Journal of Combina- torial Theory, Series B, 36(1):49 -- 64, 1984. [20] S. Schwarz and Sven Krumke. On budget-constrained flow improvement. Information Pro- cessing Letters, 66(6):291 -- 297, 1998. [21] Larry Stockmeyer. Planar 3-colorability is polynomial complete. SIGACT News, 5(3):19 -- 25, July 1973. [22] R.Kevin Wood. Deterministic network interdiction. Mathematical and Computer Modelling, 17(2):1 -- 18, 1993. [23] Rico Zenklusen. Matching interdiction. Discrete Applied Mathematics, 158(15):1676 -- 1690, 2010. [24] Rico Zenklusen. Network flow interdiction on planar graphs. Discrete Applied Mathematics, 158(13):1441 -- 1455, 2010. 25
1502.07406
1
1502
2015-02-26T00:09:23
Improved Approximation Algorithms for k-Submodular Function Maximization
[ "cs.DS" ]
This paper presents a polynomial-time $1/2$-approximation algorithm for maximizing nonnegative $k$-submodular functions. This improves upon the previous $\max\{1/3, 1/(1+a)\}$-approximation by Ward and \v{Z}ivn\'y~(SODA'14), where $a=\max\{1, \sqrt{(k-1)/4}\}$. We also show that for monotone $k$-submodular functions there is a polynomial-time $k/(2k-1)$-approximation algorithm while for any $\varepsilon>0$ a $((k+1)/2k+\varepsilon)$-approximation algorithm for maximizing monotone $k$-submodular functions would require exponentially many queries. In particular, our hardness result implies that our algorithms are asymptotically tight. We also extend the approach to provide constant factor approximation algorithms for maximizing skew-bisubmodular functions, which were recently introduced as generalizations of bisubmodular functions.
cs.DS
cs
Improved Approximation Algorithms for k-Submodular Function Maximization Satoru Iwata ∗ Shin-ichi Tanigawa† Yuichi Yoshida‡ October 9, 2018 Abstract This paper presents a polynomial-time 1/2-approximation algorithm for maximizing nonneg- ative k-submodular functions. This improves upon the previous max{1/3, 1/(1+a)}-approximation by Ward and Zivn´y [15], where a = max{1,p(k − 1)/4}. We also show that for monotone k- submodular functions there is a polynomial-time k/(2k − 1)-approximation algorithm while for any ε > 0 a ((k + 1)/2k + ε)-approximation algorithm for maximizing monotone k-submodular functions would require exponentially many queries. In particular, our hardness result implies that our algorithms are asymptotically tight. We also extend the approach to provide constant factor approximation algorithms for maxi- mizing skew-bisubmodular functions, which were recently introduced as generalizations of bisub- modular functions. 1 Introduction Let 2V denote the family of all the subsets of V . A function g : 2V → R is called submodular if it satisfies g(Z1) + g(Z2) ≥ g(Z1 ∪ Z2) + g(Z1 ∩ Z2) for every pair of Z1 and Z2 in 2V . Submodular function maximization contains important NP- hard optimization problems such as max cut and certain facility location problems. It is known to be intractable in the standard value oracle model, and approximation algorithms have been studied extensively. In particular, Feige, Mirrokni, and Vondr´ak [6] have developed constant factor approximation algorithms for the unconstrained maximization of nonnegative submodular functions and shown that no approximation algorithm can achieve the ratio better than 1/2. Buchbinder, Feldman, Naor, and Schwartz [2] provided much simpler algorithms that substantially improve the approximation factor. In particular their randomized version, called the randomized double-greedy algorithm, achieves the factor of 1/2, which is the best possible in the oracle value model. ∗Department of Mathematical Informatics, Graduate School of Information Science and Technology, University of Tokyo, Tokyo 113-8656, Japan ([email protected]). Supported by JSPS Grant-in-Aid for Scientific Research (B) No. 23300002. †Research Institute for Mathematical Sciences, Kyoto University, Kyoto 606-8502 Japan ([email protected]). Supported by JSPS Grant-in-Aid for Scientific Research (B) No. 23300002. ‡National Institute of Informatics, and Preferred Infrastructure, Inc. ([email protected]). Supported by JSPS Grant-in-Aid for Young Scientists (B) (No. 26730009), MEXT Grant-in-Aid for Scientific Research on Innovative Areas (No. 24106003), and JST, ERATO, Kawarabayashi Large Graph Project. 1 In this paper we shall consider the maximization of nonnegative k-submodular functions which generalizes the submodular function maximization. Let (k + 1)V := {(X1, . . . , Xk) Xi ⊆ V (i = 1, . . . , k), Xi ∩ Xj = ∅ (i 6= j)}. A function f : (k + 1)V → R is called k-submodular if, for any x = (X1, . . . , Xk) and y = (Y1, . . . , Yk) in (k + 1)V , we have where f (x) + f (y) ≥ f (x ⊔ y) + f (x ⊓ y) x ⊓ y := (X1 ∩ Y1, . . . , Xk ∩ Yk) x ⊔ y := X1 ∪ Y1 \ [i6=1 Xi ∪ Yi  , . . . , Xk ∪ Yk \ [i6=k Xi ∪ Yi   .  k-submodular functions were first introduced by Huber and Kolmogorov [9] as a generalization of bisubmodular functions, which correspond to 2-submodular functions in the above notation. Examples of bisubmodular functions include the rank functions of delta-matroids and the cut capacity functions of bi-directed networks, and the minimization problem has been extensively studied [8, 12]. Examples of k-submodular functions will be explained later. Ward and Zivn´y [15] and the present authors [11] independently observed that algorithms for submodular function maximization due to Buchbinder, Feldman, Naor, and Schwartz [2] can be naturally extended to bisubmodular function maximization. In particular the randomized double greedy algorithm for submodular functions can be seen as a randomized greedy algorithm in the bisubmodular setting and it achieves the best approximation ratio 1/2. Ward and Zivn´y [15] further analyzed the randomized greedy algorithm for k-submodular function maximization and proved that its approximation ratio is 1/(1 + a), where a = max{1,p(k − 1)/4}. They also gave a deterministic 1/3-approximation algorithm. In this paper we shall present an improved 1/2-approximation algorithm for maximizing k- submodular functions. Our algorithm follows the randomized greedy framework as in [11, 15], and the main idea is the use of a different probability distribution derived from a geometric sequence at each step. By extending the argument by Feige, Mirrokni, and Vondr´ak [6] we also show that for any ε > 0, a ((k + 1)/2k + ε)-approximation for the k-submodular function maximization problem would require exponentially many queries, implying the tightness of our result for large k. In fact, our inapproximability result holds for a much restricted class of monotone k-submodular functions, where a k-submodular function is said to be monotone if f (x) ≤ f (y) for any x = (X1, . . . , Xk) and y = (Y1, . . . , Yk) in (k + 1)V with Xi ⊆ Yi for 1 ≤ i ≤ k. On the other hand we show that there is a k/(2k − 1)-approximation for monotone k-submodular functions. In particular it attains an approximation ratio of 2/3 for bisubmodular functions. In order to understand the relation between k-submodular function maximization and other maximization problems, it is useful to understand characteristic properties of k-submodular func- tions, called orthant submodularity and pairwise monotonicity. To see them, define a partial order (cid:22) on (k + 1)V such that, for x = (X1, . . . , Xk) and y = (Y1, . . . , Yk) in (k + 1)V , x (cid:22) y if Xi ⊆ Yi for every i with 1 ≤ i ≤ k. Also, define ∆e,if (x) = f (X1, . . . , Xi−1, Xi ∪ {e}, Xi+1, . . . , Xk) − f (X1, . . . , , Xk) 2 j=1 Xj, and i ∈ [k], which is a marginal gain when adding e to the i-th component of x. Then it is easy to see that the k-submodularity implies the orthant submodularity: for x ∈ (k + 1)V , e /∈ Sk ∆e,if (x) ≥ ∆e,if (y) (x, y ∈ (k + 1)V with x (cid:22) y, e /∈ [j∈[k] Yj, and i ∈ [k]), and the pairwise monotonicity: ∆e,if (x) + ∆e,jf (x) ≥ 0 (x ∈ (k + 1)V , e /∈ [ℓ∈[k] Xℓ, and i, j ∈ [k] with i 6= j). Ward and Zivn´y [15] showed that these properties indeed characterize k-submodular functions, extending the corresponding result for bisubmodular functions [1]. Theorem 1.1 (Ward and Zivn´y [15]). A function f : (k + 1)V → R is k-submodular if and only if f is orthant submodular and pairwise monotone. The k-submodular function maximization problem is closely related to the submodular function maximization with a partition matroid constraint. Consider a partition {U1, . . . , Un} of a finite set U such that Ui = k and a partition matroid on U such that I ⊆ U is independent if and only if I ∩ Ui ≤ 1 for every 1 ≤ i ≤ n. By identifying each Ui with [k], one can identify each independent set I with an element x of (k + 1)V , where V = {1, . . . , n}. Therefore, for a given submodular function g : 2U → R+, its restriction to the family of independent sets can be considered as a function from (k + 1)V to R+ satisfying orthant submodularity. In general, if g is monotone, the submodular function maximization with a matroid constraint admits (1 − 1/e)-approximation [4], which is known to be best possible in the value oracle model [13]. On the other hand, when g is non-monotone, the current best approximation ratio is 1/e [7] for general matroids, and deriving the tight bound is recognized as a challenging problem even for uniform matroids (see [3]). The k- submodular function maximization is in between: it admits 1/2-approximation whereas it assumes pairwise monotonicity, which is strictly weaker than monotonicity. It is also worth mentioning that in the k-submodular function maximization there always exists a maximizer which is a partition of V (c.f. Proposition 2.1), which corresponds with a base in the partition matroid. Vondr´ak [14] showed that, under a matroid base constraint, any (1 − 1/ν + ε)- approximation requires exponentially many queries for any ε > 0, where ν denotes the fractional packing number (see [14] for the definition). One can easily show that ν = k in our case, and hence this general result does not give a nontrivial bound for large k. We should also remark that, in the k-submodular function maximization problem, function values are determined over (k + 1)V and hence over the independent sets in the corresponding submodular function maximization with a partition matroid constraint. It is not in general true that such a non-negative (monotone) function can be extended to a non-negative (monotone) submodular function over 2U . An important special case of the submodular function maximization with a partition matroid constraint is the submodular welfare problem. In the submodular welfare problem, given a finite set V and monotone submodular functions gi : 2V → R+ for 1 ≤ i ≤ k, we are asked to find a partition {X1, . . . , Xk} of V that maximizes Pk i=1 gi(Xi). Feldman, Naor and Schwartz [7] gave a (1− (1− 1/k)k )-approximation approximation algorithm, which is known to be best possible in the 3 value oracle model [14]. Now, consider h : (k + 1)V → R+ given by h(X1, . . . , Xk) = k Xi=1 gi(Xi) ((X1, . . . , Xk) ∈ (k + 1)V ). Then the submodularity and the monotonicity of gi imply the orthant submodularity and the pairwise monotonicity of h, and hence h is monotone k-submodular by Theorem 1.1. Thus the monotone k-submodular function maximization generalizes the submodular welfare problem. In fact we will show that the approximation algorithm by Dobzinski and Schapira [5] for the submodular welfare problem can be extended to the monotone case. A similar construction gives another interesting application of the k-submodular function max- imization. For a submodular function g : 2V → R+, define h′ : (k + 1)V → R+ by h′(X1, . . . , Xk) = k Xi=1 g(Xi) ((X1, . . . , Xk) ∈ (k + 1)V ). The resulting h′ satisfies orthant submodularity but may not satisfy pairwise monotonicity in general. However if g is symmetric (i.e., g(X) = g(V \ X) for X ⊆ V ) it turns out that h′ is pairwise monotone and thus it is k-submodular by Theorem 1.1. Therefore, for a symmetric submodular function g, our algorithm gives a 1 2 -approximation for the problem of finding a partition i=1 g(Xi). Note that this problem generalizes the Max k-cut {X1, . . . , Xk} of V that maximizes Pk As another extension of the bisubmodularity, Huber, Krokhin, and Powell [10] have introduced the concept of skew-bisubmodularity. For α ∈ [0, 1], a function f : 3V → R is called α-bisubmodular if, for any x = (X1, X2) and y = (Y1, Y2) in 3V , problem. f (x) + f (y) ≥ f (x ⊓ y) + αf (x ⊔ y) + (1 − α)f (x ⊔y), where x ⊔y = (X1 ∪ Y1, (X2 ∪ Y2) \ (X1 ∪ Y1)). 2√α A function f : 3V → R is called skew-bisubmodular if it is α-bisubmodular for some α ∈ [0, 1]. We show that a randomized greedy algorithm provides an approximate solution within the factor of (1+√α)2 for maximizing an α-bisubmodular function. This means that the double greedy algorithm of Buchbinder et al. [2] relies on a symmetry of submodular functions. Combining this with another simple algorithm, we obtain an approximate algorithm whose approximate ratio is at least 8 25 for any α ∈ [0, 1]. This result has been included in our previous technical report [11], but not in a reviewed article. The rest of this paper is organized as follows. In Section 2, we present our approximation algo- rithms for the k-submodular function maximization. In Section 3, we discuss the inapproximability. In Section 4 we analyze a randomized greedy algorithm for maximizing α-bisubmodular functions, and then we present an improvement that leads to a constant-factor approximation algorithm. 2 Approximation algorithms for k-submodular functions In this section we give approximation algorithms for the k-submodular function maximization prob- lem. To analyze k-submodular functions it is often convenient to identify (k + 1)V as {0, 1 . . . , k}V , 4 that is, the set of V -dimensional vectors with entries in {0, 1, . . . , k}. Namely, we associate (X1, . . . , Xk) ∈ (k + 1)V with x ∈ {0, 1, . . . , k}V by Xi = {e ∈ V x(e) = i} for 1 ≤ i ≤ k. Hence we sometimes abuse notation, and simply write x = (X1, . . . , Xk) by regarding a vector x as a subpartition of V . For x ∈ {0, 1, . . . , k}V , let supp(x) = {e ∈ V x(e) 6= 0}, and let 0 be the zero vector in {0, 1, . . . , k}V . 2.1 Framework Our approximation algorithms are obtained from the following meta-framework (Algorithm 1) for maximizing k-submodular functions by changing the probability distributions used in the frame- work. Algorithm 1 Input: A nonnegative k-submodular function f : {0, 1, . . . , k}V → R+. Output: A vector s. s ← 0. for each e ∈ V do Set a probability distribution p over {1, . . . , k}. Let s(e) ∈ {1, . . . , k} be chosen randomly, with Pr[s(e) = i] = pi for all i ∈ {1, . . . , k}. return s The approximation algorithms for bisubmodular functions [11] and more generally for k-submodular functions [15] are specializations of Algorithm 1, where the probability distribution is chosen to be proportional to its marginal gain. We now evaluate the quality of the solution of Algorithm 1 by applying the analysis in [11, 15]. We first remark the following key fact (see [11, 15] for the proof). Proposition 2.1. For any k-submodular function f : (k + 1)V → R+, there exists a partition of V that attains the maximum value of f . We also need the following notation, which will be used throughout this section. Let n = V . By Proposition 2.1 there is an optimal solution o with supp(o) = V . Let s be the output of the algorithm. We consider the j-th iteration of the algorithm, and let e(j) be the element of V considered in the j-th iteration, p(j) be the probability that i-th coordinate is chosen in the j-th iteration, and s(j) be the solution after the i-th iteration, where s(0) = 0. Also for 0 ≤ j ≤ n let o(j) = (o ⊔ s(j)) ⊔ s(j), that is, the element in {0, 1, . . . , k}V obtained from o by replacing the coordinates on supp(s(j)) with those of s(j), and for 1 ≤ j ≤ n let t(j−1) = (o⊔ s(j))⊔ s(j−1), that is, the one obtained from o(j) by changing o(j)(e(j)) with 0. Also for i ∈ [k] let y(j) i = ∆e(j),if (s(j−1)) and let a(j) i = ∆e(j),if (t(j−1)). Due to the pairwise monotonicity, we have i y(j) i + y(j) a(j) i + a(j) i′ ≥ 0 i′ ≥ 0 (i, i′ ∈ [k], i 6= i′), (i, i′ ∈ [k], i 6= i′). Also from s(j) (cid:22) t(j), the orthant submodularity implies y(j) i ≥ a(j) i (i ∈ [k]). 5 (1) (2) (3) Applying the analysis in [11, 15], we have the following. Lemma 2.2. Let c ∈ R+. Conditioning on s(j−1), suppose that k Xi=1 i∗ − a(j) (a(j) i )p(j) k Xi=1 i ≤ c( i p(j) y(j) i ) (4) holds for each j with 1 ≤ j ≤ n, where i∗ = o(e(j)). Then E[f (s)] ≥ 1 Proof. Conditioning on s(j−1), we have E[f (o(j−1)) − f (o(j))] =Pi(a(j) f (s(j−1))] = Pi y(j) and E[f (s(j)) − . Hence, by (4), we have E[f (o(j−1)) − f (o(j))] ≤ cE[f (s(j)) − f (s(j−1))] (without conditioning on s(j−1)). Note also that o(0) = o and o(n) = s by definition. Hence 1+c f (o). i∗ − a(j) i p(j) i )p(j) i i f (o) − E[f (s)] = E[f (o(j−1)) − f (o(j))] n Xj=1 Xj=1 ≤ c( n E[f (s(j)) − f (s(j−1))]) = c(E[f (s)] − f (0)) ≤ cE[f (s)], and we get the statement. 2.2 A 1 2 -approximation algorithm for non-monotone k-submodular functions In this section, we show a polynomial-time randomized 1 k-submodular functions. Our algorithm is described in Algorithm 2. 2 -approximation algorithm for maximizing Theorem 2.3. Let o be a maximizer of a k-submodular function f and let s be the output of Algorithm 2. Then E[f (s)] ≥ 1 Proof. By Lemma 2.2 it suffices to prove (4) for every 1 ≤ j ≤ n for c = 1. For simplicity of the description we shall omit the superscript (j) if it is clear from the context. Our goal is to show 2 f (o). (yi + ai)pi ≥ ai∗, X1≤i≤k (5) which is equivalent to (4) with c = 1. Recall that yi + yi′ ≥ 0 and ai + ai′ ≥ 0 for i, i′ ∈ [k] with i 6= i′, and yi ≥ ai for i ∈ [k] (c.f. (1), (2) and (3)). If i+ ≤ 1, then we need to show a1 + y1 ≥ ai∗. Since yi + yi′ ≥ 0 for i, i′ ∈ [k], we have y1 ≥ 0. Hence a1 + y1 ≥ ai∗ holds if i∗ = 1. If i∗ 6= 1 then 0 ≥ yi∗ ≥ ai∗ , and hence a1 ≥ 0 by a1 + ai∗ ≥ 0. This implies a1 + y1 ≥ 0 ≥ ai∗. If i+ = 2, we need to show (a1 + y1)y1 + (a2 + y2)y2 ≥ ai∗(y1 + y2). Now (a1 + y1)y1 + (a2 + y2)y2 = a1y1 + a2y2 + (y1 − y2)2 + 2y1y2 ≥ a1y1 + a2y2 + 2y1y2. If i∗ = 1, then a1y1 + a2y2 + 2y1y2 ≥ a1(y1 + y2) + (a2 + a1)y2 ≥ a1(y1 + y2) as required. By a symmetric calculation the claim follows if i∗ = 2. If i∗ ≥ 3, then 0 ≥ yi∗ ≥ ai∗, and hence a1 ≥ 0, a2 ≥ 0. We thus have (a1 + y1)y1 + (a2 + y2)y2 ≥ 0 ≥ ai∗(y1 + y2). 6 Input: A nonnegative k-submodular function f : {0, 1, . . . , k}V → R+. Output: A vector s ∈ {0, 1, . . . , k}V . Algorithm 2 s ← 0. for each e ∈ V do 0 otherwise. if i = 1 otherwise 0 (1 ≤ i ≤ k). else if i+ = 2 then yi ← ∆e,if (s) for 1 ≤ i ≤ k. Assume y1 ≥ y2 ≥ ··· ≥ yk. i+ ←(the maximum integer i such that yi > 0 if y1 > 0, if i+ ≤ 1 then pi ←(1 pi ←( yi pi ←  if i ≤ i+ − 1 if i = i+ otherwise ( 1 2 )i 2 )i+−1 ( 1 0 if i ∈ {1, 2} otherwise (1 ≤ i ≤ k). y1+y2 0 else (1 ≤ i ≤ k). Let s(e) ∈ {1, . . . , k} be chosen randomly, with Pr[s(e) = i] = pi for all i ∈ {1, . . . , k}. return s Hence assume i+ ≥ 3. Note that yi ≥ yi∗ ≥ ai∗ for i ≤ i∗. (6) Let r ∈ argmin{ai i ∈ [k]}. Such r is unique if ar < 0. If r = i∗, we have Pi aipi ≥ ai∗ (Pi pi) = ai∗ . Since Pi yipi ≥ 0, (5) follows. Hence we assume r 6= i∗. If i∗ ≥ i+, we have Pi yipi =Pi≤i+ yipi ≥Pi≤i+ ai∗pi = ai∗ by (6) and Pi aipi =Pi6=r aipi + arpr ≥ 0 by Pi6=r pi ≥ pr and ai + ar ≥ 0 for i 6= r. Therefore (5) holds. We thus assume i∗ < i+. Now we have Xi (yi + ai)pi ≥ Xi≤i∗ = Xi<i∗ aipi ai∗pi +Xi>i∗ aipi +Xi ai∗pi + 2ai∗ pi∗! + Xi>i∗ For the first term we have aipi + Xi6=r,i∗ aipi + arpr  . (7) ai∗pi + 2ai∗ pi∗ = ai∗ Xi<i∗ Xi<i∗ pi + 2pi∗! = ai∗ 1 −(cid:18) 1 2(cid:19)i∗−1 + 2 ·(cid:18) 1 2(cid:19)i∗! = ai∗. 7 Hence it suffices to show that the second term of (7) is nonnegative. This is trivial if ar ≥ 0. Hence assume ar < 0. Since i∗ < i+, we have Xi>i∗ pi + Xi6=r,i∗ 2(cid:19)i∗ pi =(cid:18) 1 + Xi6=r,i∗ pi = pi∗ + Xi6=r,i∗ pi = 1 − pr. (8) Therefore, if r < i∗, we get pr −Xi>i∗ pi − Xi6=r,i∗ aipi + arpr ≥ ar pi Xi>i∗  = ar(pr − (1 − pr)) = ar(2pr − 1) ≥ 0, where the first inequality follows from ai + ar ≥ 0 for i 6= r, the second equality follows from (8), and the fourth follows from ar < 0 and pr ≤ 1/2. Hence we further assume r > i∗. Then pr ≤ 1/4 by r 6= 1 and i+ ≥ 3. Hence, by ar < 0, pi Xi>i∗ aipi + arpr ≥ Xi>i∗,i6=r  = ar(2pr − (pi∗ − pr) − (1 − pr − pi∗)) = ar(4pr − 1) ≥ 0. aipi + 2arpr ≥ ar 2pr − Xi>i∗,i6=r aipi + Xi6=r,i∗ aipi + Xi6=r,i∗ aipi + Xi6=r,i∗ pi − Xi6=r,i∗ Thus we conclude that the second term of (7) is nonnegative and (5) holds. 2.3 A k 2k−1 -approximation algorithm for monotone k-submodular functions In this section, we show a polynomial-time randomized 2k−1 -approximation algorithm for maxi- mizing monotone k-submodular functions. Our algorithm is described in Algorithm 3. We note that a similar algorithm and analysis appeared in [5] for the submodular welfare problem, which is a special case of the monotone k-submodular function maximization problem. k It is clear that Algorithm 3 runs in polynomial time. Below we consider the approximation ratio of Algorithm 3. Theorem 2.4. Let o be a maximizer of a monotone nonnegative k-submodular function f and let s be the output of Algorithm 3. Then E[f (s)] ≥ k Proof. By Lemma 2.2 it suffices to prove (4) for every 1 ≤ j ≤ n for c = 1 − 1 the description we shall omit the superscript (j) if it is clear from the context. k . For simplicity of 2k−1 f (o). We first consider the case β = 0. Since f is monotone, we have yi = ai = 0 for all 1 ≤ i ≤ k. Now suppose β > 0. Our goal is to show Hence, (4) clearly holds with c = 1 − 1 k . X1≤i≤k yt i(ai∗ − ai) ≤(cid:16)1 − 1 k(cid:17) X1≤i≤k yt+1 i . (9) If k = 1, then (9) follows since i∗ = 1 and both sides are equal to zero. Hence we assume k ≥ 2. Let γ = (k − 1) t . Since f is a monotone k-submodular function, we have that ai ≥ 0 for all i ∈ {1, . . . , k}. Then, we have 1 t = t 1 Xi6=i∗ yt i(ai∗ − ai) ≤ Xi6=i∗ yt iai∗ ≤ Xi6=i∗ yt iyi∗ = 1 γ(cid:18)γyi∗ ·Xi6=i∗ yt i(cid:19). (10) 8 Algorithm 3 Input: A monotone k-submodular function f : {0, 1, . . . , k}V → R+. Output: A vector s ∈ {0, 1, . . . , k}V . s ← 0. t ← k − 1. for each e ∈ V do k yt i yi ← ∆e,i(s) for 1 ≤ i ≤ k. Pi=1 β ← if β 6= 0 then pi ← yt pi ←(1 Let s(e) ∈ {1, . . . , k} be chosen randomly, with Pr[s(e) = i] = pi for all i ∈ {1, . . . , k}. (1 ≤ i ≤ k). if i = 1 otherwise (1 ≤ i ≤ k). else i β 0 return s From the weighted AM-GM inequality, a 1 t+1 b t t+1 ≤ 1 t+1 a + t t+1 b holds for all a, b ≥ 0. By setting a = (γyi∗)t+1 and b = (Pi6=i∗ yt (10) ≤ i)(t+1)/t, we have From Holder's inequality, Pi ai ≤ (Pi a setting ai = yt i, we have t+1 t i ) 1 γ(cid:18) 1 t + 1 (γyi∗)t+1 + t t + 1(cid:16)Xi6=i∗ yt i(cid:17) t+1 t (cid:19). (11) 1 t+1 holds for any non-negative ai's. By t t yt+1 t+1 (Pi 1t+1) t + 1(cid:16)Xi6=i∗ t(k − 1)1/t t + 1 Xi6=i∗ k(cid:17)Xi yt+1 i 1 . (11) ≤ = = 1 1 t + 1 γ(cid:18) 1 γ(cid:18) 1 t + 1Xi t + 1 γt (γyi∗ )t+1 + (γyi∗ )t+1 + yt+1 i =(cid:16)1 − 1t+1(cid:17) 1 t(cid:19) i (cid:17) ·(cid:16)Xi6=i∗ i (cid:19) yt+1 Thus we established (9) and we have k/(2k − 1)-approximation by Lemma 2.2. 3 Inapproximability As we remarked in the introduction, for a symmetric submodular function f : 2V → R+, a function g : {0, 1 . . . , k}V → R+ defined by g(X1, . . . , Xk) = k Xi=1 f (Xi) ( {X1, . . . , Xk} ∈ {0, . . . , k}V ) 9 is k-submodular. Hence one can consider an approximation algorithm for maximizing f by ap- plying an α-approximation algorithm for k-submodular functions to g and then returning Xi ∈ argmax{f (Xj) j ∈ [k]} for output (X1, . . . , Xk) of the approximation algorithm. Let (X∗1 , . . . , X∗k ) be a maximizer of g and X∗ be a maximizer of f . Since f is symmetric, we have g(X∗1 , . . . , X∗k ) ≥ 2f (X∗). Therefore we have kf (Xi) ≥ Pj f (Xj) = g(X1, . . . , Xk) ≥ αg(X∗1 , . . . , X∗k ) ≥ 2αf (X∗). Thus it gives a 2α/k-approximation algorithm for the symmetric submodular function maximiza- tion. It was proved by Feige, Mirrokni, and Vondr´ak [6] that any approximation algorithm for sym- metric submodular functions with polynomial queries cannot achieve the approximation ratio better that 1/2. This implies that the best approximation ratio for the k-submodular maximization prob- lem is at most α ≤ k/4. This argument, via embedding of a symmetric submodular function to a k-submodular function, gives the tight approximation bound for bisubmodular function, but for k ≥ 4 it does not give a nontrivial bound. directly extend the argument of [6] and establish the following bound. Instead of embedding submodular functions to k-submodular functions, in this section we shall Theorem 3.1. For any ε > 0, a ( k+1 maximization problem would require exponentially many queries. 2k + ε)-approximation for the monotone k-submodular function Proof. For simplicity we assume that ε is rational. Let V be a finite set with n = V such that εn is an integer. The framework of the proof is from [6] (see also [14]) and it proceeds as follows. We shall define a k-submodular function f and a k-submodular function gP for each k-partition P = {A1, . . . , Ak} of V , where a k-partition means a partition of V into k subsets. Those functions look the same as long as queries are "balanced" (whose definition will be given below). Suppose P is randomly taken in the sense that each element is added to one of the k parts uniformly at random. Then it turns out that with high probability all queries would be balanced as long as the number of queries is polynomial in k and n. In particular, we cannot get any information about P. Thus one cannot distinguish f and gP by any deterministic algorithm with a polynomial number of queries. Hence, by Yao's min-max principle, any (possibly, randomized) algorithm with a polynomial number of queries cannot distinguish f and gP and cannot achieve an approximation ratio better than maxx f (x) maxx gP (x) , which will be k+1 2k . Now we define f and gP . For x = (X1, . . . , Xk) ∈ {0, 1, . . . , k}V , let n0(x) = V \Sk define f : {0, . . . , k}V → Z+ by (x ∈ {0, . . . , k}V ). f (x) = (k + 1 + 2kε)n2 − (k − 1)n0(x)2 − 2(1 + kε)nn0(x) i=1 Xi. We To define gP , take any k-partition P = {A1, . . . , Ak}. For x = (X1, . . . , Xk), let ci,j(x) = Xi ∩ Aj for 1 ≤ i ≤ k and 1 ≤ j ≤ k, and let dj(x) =Pk i=1 ci,j+i−1 for 1 ≤ j ≤ k, where the index is taken modulo k (0 is regarded as k). Then gP : {0, . . . , k}V → Z+ is defined by gP (x) = f (x) + X1≤a<b≤k (x ∈ {0, . . . , k}V ), ha,b P (x) where ha,b P (x) := (max{da(x) − db(x) − εn, 0})2. The properties of f and gP are listed in the following claims. 10 Claim 3.2. f and gP for each k-partition P of V are nonnegative monotone k-submodular func- tions. Proof. Clearly they are nonnegative. To see the monotonicity and k-submodularity of f , take any x and e /∈ supp(x). Then ∆e,if (x) = 2(k − 1)n0(x) + 2(1 + kε)n − 1. This is clearly nonnegative and hence f is monotone. Also, since n0(·) is non-increasing, f is orthant submodular and hence f is k-submodular by Theorem 1.1. Next we consider gP . Take any x and e /∈ supp(x), and suppose that e ∈ Aj. When adding e into Xi, ci,j(x) increases by one and hence dj−i+1(x) increases by one. Hence for 1 ≤ a < b ≤ k we have   ∆e,iha,b P (x) = Hence 2((da(x) − db(x)) − εn) + 1 if a = j − i + 1 and da(x) − db(x) ≥ εn −2((db(x) − da(x)) − εn) + 1 if a = j − i + 1 and db(x) − da(x) ≥ εn −2((da(x) − db(x)) − εn) + 1 if b = j − i + 1 and da(x) − db(x) ≥ εn 2((db(x) − da(x)) − εn) + 1 if b = j − i + 1 and db(x) − da(x) ≥ εn otherwise. 0 ∆e,igP (x) = 2(k − 1)n0(x) + 2(1 + kε)n − 1 + X1≤b≤k,b6=j−i+1 To see the orthant submodularity of gP , observe that 2n0 + ∆e,ihj−i+1,b b with b 6= j − i + 1. Since P ∆e,ihj−i+1,b (x). P is non-increasing for each ∆e,igP (x) = 2(1 + kε)n − 1 + X1≤b≤k,b6=j−i+1 (2n0(x) + ∆e,ihj−i+1,b (x)), P n. Hence ∆e,igP is non-increasing, implying the orthant submodularity. To see the monotonicity, let B+ = {b dj−i+1(x) − db(x) ≥ εn} and B− = {b db(x) − dj−i+1(x) ≥ εn}. Note also thatP1≤b≤k db(x) =P1≤a≤k,1≤b≤k ca,b(x) =P1≤a≤k,1≤b≤k Xa∩Ab ≤ ∆e,igP (x) = 2(k − 1)n0(x) + 2(1 + kε)n − 1 + Xb∈B+∪B− ≥ 2 n − Xb∈B+∪B−  + 2(k − B+)εn ≥ 0. 2(dj−i+1(x) − db(x)) + (B− − B+)εn + k − 1 db(x) This completes the proof of Claim 3.2. Claim 3.3. maxx f (x) = (k + 1 + 2kε)n2 and maxx gP (x) ≥ 2kn2(1 − O(ε)). 11 Proof. Since f is k-submodular, the maximum is attained for a k-partition by Proposition 2.1, i.e., n0(x) = 0. Hence the maximum value of f is (k + 1 + 2kε)n2. To see the second statement, take x = (X1, . . . , Xk) such that Xi = Ai for 1 ≤ i ≤ k. Then d1(x) = n and dj(x) = 0 for 2 ≤ j ≤ n− 1, and thus maxx gP (x) ≥ (k + 1)n2 + (k− 1)(n− εn)2. Now take a random k-partition P of V , and consider any deterministic algorithm that tries to distinguish f and gP , where the algorithm do not know P. The algorithm issues some queries to the value oracle. Call a query to f (x) unbalanced if di(x) − dj(x) ≥ εn for some i, j ∈ [k], and otherwise balanced. Note that di(x)− dj(x) can be seen as a sum of independent random variables {Ze}e∈V , where Ze = 1 if di(x) is increased due to e, that is, e ∈ Xk ∩ Ai+k−1 for some k, Ze = −1 if dj(x) is increased due to e, that is, e ∈ Xk ∩ Aj+k−1 for some k, and Ze = 0 otherwise. By Hoeffding's inequality1, the probability that di(x) − dj(x) ≥ εn for a query is at most 2e− nε2 2 . Hence by the union bound the probability that a query is unbalanced is at most k2e− nε2 for any fixed sequence of e nε2 4 queries, the probability that a query is unbalanced is still at most 2 . Therefore, 4 k2e− nε2 2 = k2e− nε2 4 . Therefore, with probability at least 1 − k2e− nε2 4 , all the queries will be e balanced. As long as queries are balanced, the algorithm gets the same answer regardless of P, and it will never find out any information about the k-partition P. In other words, with high probability, the algorithm will never distinguish between f and gP . However, the maximum of f is (1 + k + 2kε)n2 while the maximum of gP is at least 2k(1 − O(ε))n2. This means that there is no polynomial-query algorithm with approximation ratio better than 1+k 2k . nε2 4 Approximation algorithms for skew-bisubmodular functions In this section, we discuss the problem of maximizing an α-bisubmodular function. An adaptation 2√α (1+√α)2 for α ∈ [0, 1]. of the greedy algorithm is shown to achieve the approximation ratio of This ratio converges to zero as α goes to zero. In order to improve the performance for small α, we give another simple approximation algorithm that achieves the approximation ratio of 3+2α in Section 4.2. By taking the maximum of the outputs of these two algorithms, we obtain the 25 for any α ∈ [0, 1] (the minimum of the two ratio is achieved when approximation ratio of α = 1 16 ). Concerning the maximum of an α-bisubmodular function, we have the following counterpart of 8 1 Proposition 2.1. Lemma 4.1. For any α-bisubmodular function f : 3V → R+ with α ∈ [0, 1], there exists a partition of V that attains the maximum value of f . Proof. Suppose that (S, T ) ∈ 3V attains the maximum value of f . By the α-bisubmodularity of f , we have αf (S, V \ S) + f (V \ T, T ) ≥ (1 + α)f (S, T ), which implies that f (S, V \ S) = f (V \ T, T ) = f (S, T ). Thus the maximum value of f is attained by a partition of V . 1Let X1, . . . , Xn be independent random variables in [−1, 1], and let ¯X = 1 n (X1 + · · · + Xn). Then P( ¯X − E( ¯X) ≥ t) ≤ 2e− nt 2 2 12 4.1 A randomized greedy algorithm We now extend the randomized greedy algorithm for the bisubmodular function (i.e., Algorithm 2 for 2-submodular functions). Intuitively, α-bisubmodularity is a variant of bisubmodularity directed toward the first argument by parameter α. Following this intuition, we shall adjust the choice probability as shown in Algorithm 4. Algorithm 4 Input: A nonnegative α-submodular function f : {0, 1, 2}V → R+. Output: A vector s ∈ {0, 1, 2}V . if i = 1 if i = 2. else if y1 < 0 then if i = 1 if i = 2. s ← 0. for each e ∈ V do yi ← ∆e,if (s) for i = 1, 2. if y2 < 0 then pi ←(1 pi ←(0 pi ←( αy1 Let s(e) ∈ {1, 2} be chosen randomly, with Pr[s(e) = i] = pi for all i ∈ {1, 2}. if i = 2. if i = 1 else αy1+y2 y2 αy1+y2 0 1 return s Note that, by the α-bisubmodularity of f , we have α∆e,1f (x) + ∆e,2f (x) ≥ 0 for any x ∈ 3V and e /∈ supp(x), which implies αy1 + y2 ≥ 0. The following theorem provides a performance analysis of this algorithm. (12) Theorem 4.2. For any α ∈ [0, 1], the randomized greedy algorithm for maximizing α-bisubmodular functions provides an approximate solution within a factor of 2√α (1+√α)2 . Proof. Note that Lemma 2.2 holds for any function on {0, 1, . . . , k}V as long as the maximum is taken by a partition of V , which is the case in the α-bisubmodular function maximization by Lemma 4.1. Hence it suffices to prove (4) for every 1 ≤ j ≤ n for c = (1 + α)/(2√α). For simplicity of the description we shall omit the subscript (j). Our goal is to show (ai∗ − a1)p1 + (ai∗ − a2)p2 ≤ c(y1p1 + y2p2) (13) for each i∗ ∈ {1, 2} by using αa1 + a2 ≥ 0 yi ≥ ai (i = 1, 2), 13 which follow from the α-bisubmodularity. (13). A symmetric argument also implies (13) if y2 < 0. If y1 < 0, then a1 < 0 and y2 ≥ a2 ≥ −αa1 ≥ 0, and hence cy2 ≥ y2 ≥ min{a1− a2, 0}, implying By αy1 + y2 ≥ 0, the remaining case is when y1 ≥ 0 and y2 ≥ 0. If i∗ = 1, then (a1 − a2)p2 = 2 − (√αy1 − y2)2) 1 + y2 2√α(αy1 + y2) (1 + α)(αy2 (1 + α)y1y2 αy1 + y2 = (a1 − a2)y2 (1 + α)a1y2 αy1 + y2 ≤ αy1 + y2 ≤ 1 + y2 (1 + α)(αy2 2) 2√α(αy1 + y2) 1 + α 2√α = ≤ (y1p1 + y2p2). Thus (13) holds. On the other hand, if i∗ = 2, (a2 − a1)p1 = ≤ (a2 − a1)αy1 (1 + α)a2y1 αy1 + y2 ≤ αy1 + y2 ≤ 1 + y2 (1 + α)(αy2 2) 2√α(αy1 + y2) 1 + α 2√α = (y1p1 + y2p2). (1 + α)y1y2 αy1 + y2 = (1 + α)(αy2 2 − (√αy1 − y2)2) 1 + y2 2√α(αy1 + y2) Thus (13) holds. 4.2 The second algorithm In this section, we describe another algorithm for maximizing α-bisubmodular functions, which achieves a better approximation ratio than the randomized greedy algorithm for small α. For an α-bisubmodular function f : 3V → R+ with α ∈ [0, 1], we define f′ : 2V → R+ by f′(X) = f (X,∅) for X ∈ 2V . Since f′(X) is a non-negative submodular function, we can apply the randomized double greedy algorithm of [2] to obtain a 1 2 -approximate solution Z to the maximization of f′. Our second algorithm for α-bisubmodular function maximization is rather simple: Take the better of (∅, V ) and (Z,∅). Theorem 4.3. The second algorithm for α-bisubmodular function maximization problem provides a 3+2α -approximate solution for any α ∈ [0, 1]. 1 Proof. Let (S, T ) be an optimal solution. By the α-bisubmodularity, we have f (S,∅) + f (∅, V ) ≥ f (∅,∅) + αf (∅, T ) + (1 − α)f (S, T ), f (S,∅) + f (∅, T ) ≥ f (∅,∅) + f (S, T ), which imply (1 + α)f (S,∅) + f (∅, V ) ≥ (1 + α)f (∅,∅) + f (S, T ) ≥ f (S, T ). Let (A, B) be the output by the algorithm. Then, E[f (A, B)] ≥ max(cid:26) 1 2 f (S,∅), f (∅, V )(cid:27) ≥ 2 + 2α 3 + 2α · 1 2 f (S,∅) + 1 3 + 2α f (∅, V ) 1 = 3 + 2α ((1 + α)f (S,∅) + f (∅, V )) ≥ 3 + 2α f (S, T ). 1 Combining this with the first algorithm, we obtain an approximate solution within a factor of maxn 2√α (1+√α)2 , 1 3+2αo. The minimum of this ratio is 8 25 , which is achieved when α = 1 16 . 14 References [1] K. Ando, S. Fujishige, and T. Naitoh. A characterization of bisubmodular functions. Discrete Mathematics, 148(1):299 -- 303, 1996. [2] N. Buchbinder, M. Feldman, J. Naor, and R. Schwartz. A tight linear time (1/2)-approximation for unconstrained submodular maximization. In Proceedings of the 53rd Annual IEEE Sym- posium on Foundations of Computer Science, pages 649 -- 658, 2012. [3] N. Buchbinder, M. Feldman, J. Naor, and R. Schwartz. Submodular maximization with car- dinality constraints. In Proceedings of the 25th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1433 -- 1452, 2014. [4] G. Calinescu, C. Chekuri, M. P´al, and J. Vondr´ak. Maximizing a submodular set function subject to a matroid constraint. SIAM Journal on Computing, 40(6):1740 -- 1766, 2011. [5] S. Dobzinski and M. Schapira. An improved approximation algorithm for combinatorial auc- tions with submodular bidders. In Proceedings of the 17th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1064 -- 1073, 2006. [6] U. Feige, V. S. Mirrokni, and J. Vondr´ak. Maximizing non-monotone submodular functions. SIAM Journal on Computing, 40(4):1133 -- 1153, 2011. [7] M. Feldman, J. Naor, and R. Schwartz. A unified continuous greedy algorithm for submodular maximization. In Proceedings of the 52nd Annual Symposium on Foundations of Computer Science (FOCS), pages 570 -- 579. IEEE, 2011. [8] S. Fujishige and S. Iwata. Bisubmodular function minimization. SIAM J. Discrete Math., 19:1065 -- 1073, 2006. [9] A. Huber and V. Kolmogorov. Towards mininizing k-submodular functions. In Proceedings of 2nd International Symposium on Combinatorial Optimization, pages 451 -- 462, 2012. [10] A. Huber, A. Krokhin, and R. Powell. Skew bisubmodularity and valued csps. SIAM J. Com- put., 43:1064 -- 1084, 2014. [11] S. Iwata, S. Tanigawa, and Y. Yoshida. Bisubmodular function maximization and extensions. Technical report, METR 2013-16, the University of Tokyo, 2013. [12] S. T. McCormick and S. Fujishige. Strongly polynomial and fully combinatorial algorithms for bisubmodular function minimization. Math. Programming, 122:87 -- 120, 2010. [13] V. Mirrokni, M. Schapira, and J. Vondr´ak. Tight information-theoretic lower bounds for welfare maximization in combinatorial auctions. In Proceedings of the 9th ACM conference on Electronic commerce, pages 70 -- 77. ACM, 2008. [14] J. Vondr´ak. Symmetry and approximability of submodular maximization problems. In Pro- ceedings of the 50th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 651 -- 670, 2009. 15 [15] J. Ward and S. Zivn´y. Maximizing k-submodular functions and beyond. arXiv:1409.1399v1, 2014, A preliminary version appeared in Proceedings of the 25th Annual ACM-SIAM Sympo- sium on Discrete Algorithms, pages 1468 -- 1481, 2014. 16
1906.09224
1
1906
2019-06-21T16:13:17
Multidimensional Dominance Drawings
[ "cs.DS" ]
Let $G$ be a DAG with $n$ vertices and $m$ edges. Two vertices $u,v$ are incomparable if $u$ doesn't reach $v$ and vice versa. We denote by \emph{width} of a DAG $G$, $w_G$, the maximum size of a set of incomparable vertices of $G$. In this paper we present an algorithm that computes a dominance drawing of a DAG G in $k$ dimensions, where $w_G \le k \le \frac{n}{2}$. The time required by the algorithm is $O(kn)$, with a precomputation time of $O(km)$, needed to compute a \emph{compressed transitive closure} of $G$, and extra $O(n^2w_G)$ or $O(n^3)$ time, if we want $k=w_G$. Our algorithm gives a tighter bound to the dominance dimension of a DAG. As corollaries, a new family of graphs having a 2-dimensional dominance drawing and a new upper bound to the dimension of a partial order are obtained. We also introduce the concept of transitive module and dimensional neck, $w_N$, of a DAG $G$ and we show how to improve the results given previously using these concepts.
cs.DS
cs
Multidimensional Dominance Drawings Giacomo Ortali∗ and Ioannis G. Tollis∗∗ ∗University of Perugia [email protected] ∗∗Computer Science Department, University of Crete, Heraklion, Crete, Greece and Tom Sawyer Software, Inc. Berkeley, CA 94707 U.S.A. [email protected] 9 1 0 2 n u J 1 2 ] S D . s c [ 1 v 4 2 2 9 0 . 6 0 9 1 : v i X r a Abstract. Let G be a DAG with n vertices and m edges. Two vertices u, v are incomparable if u doesn't reach v and vice versa. We denote by width of a DAG G, wG, the maximum size of a set of incomparable vertices of G. In this paper we present an algorithm that computes a dominance drawing of a DAG G in k dimensions, where wG ≤ k ≤ n 2 . The time required by the algorithm is O(kn), with a precomputation time of O(km), needed to compute a compressed transitive closure of G, and extra O(n2wG) or O(n3) time, if we want k = wG. Our algorithm gives a tighter bound to the dominance dimension of a DAG. As corollaries, a new family of graphs having a 2-dimensional dominance drawing and a new upper bound to the dimension of a partial order are obtained. We also introduce the concept of transitive module and dimensional neck, wN , of a DAG G and we show how to improve the results given previously using these concepts. Introduction 1 Dominance drawings of directed acyclic graphs (DAGs) are very important in many areas of research, including graph drawing [7], computational geometry [4], information visualization[17], even in very large databases [18,20], just to men- tion a few. They combine the aspect of drawing a DAG on the grid with the fact that the transitive closure of the DAG is apparently obvious by the domi- nance relation between grid points associated with the vertices. In other words, in a dominance drawing a vertex v is reachable from a vertex u if and only if all the coordinates of v are greater than or equal to the coordinates of u in Γ . In a DAG G with n vertices and m edges two vertices u, v are incomparable if u doesn't reach v and vice versa. We denote by width of a DAG G, wG, the maximum size of a set of incomparable vertices of G. Notice that it is not pos- sible to find dominance drawings in 2-dimensions for most DAGs. The smallest number d for which a given DAG G has a d-dimensional dominance drawing is called dominance drawing dimension, denoted by dG, and it is a known NP-hard problem to compute it [19]. In this paper we present algorithms for computing a k-dimensional dominance drawing of G, where k ≥ dG. Our algorithms are efficient and are based on various decomposition techniques on the DAG. In 2-dimensions the dominance drawing method for planar DAGs has many important aesthetic properties, including small number of bends, good vertex placement, and symmetry display [4,3]. A 2-dimensional dominance drawing Γ of a planar DAG G can be computed in linear time, such that for any two vertices u and v there is a directed path from u to v in G if and only if x(u) ≤ x(v) and y(u) ≤ y(v) in Γ [4,3]. Since most DAGs have dominance dimension higher that two, the concept of weak dominance drawings was introduced in [10,11]. This concept has many applications including the drawing of DAGs in the overloaded orthogonal model [12]. In weak dominance, for any two vertices u and v if there is a directed path from u to v in G then x(u) ≤ y(v) and y(u) ≤ y(v) in Γ . However, the reverse does not hold. Hence, we have a falsely implied path (fip) when x(u) ≤ y(v) and y(u) ≤ y(v), but there is no path from u to v. Kornaropoulos and Tollis [10] proved that the problem of minimizing the number of fips is NP-hard and gave some upper bounds on the number of fips. Several researchers adopted the concept of weak dominance drawing in order to construct a compact representation of the reachability information of very large graphs that are produced by very large datasets in the database commu- nity [18]. Li, Hua, and Zhou considered high dimensional dominance drawings in order to reduce the number of fips and obtain efficient solutions to the reach- ability problem [13]. Namely, they use high dimensional dominance drawings in order to reduce the number of fips and describe heuristics to obtain a system that resolves reachability queries in linear (or constant) time as demonstrated by their experimental work [13]. In this paper we present an algorithm, called kD-Draw, that computes a dominance drawing of a DAG G in k dimensions, where wG ≤ k ≤ n 2 . The time required by the algorithm is O(kn), with a precomputation time of O(km), needed to compute a "special" transitive closure of G, called compressed transi- tive closure. If we want to have k = wG then an extra O(n2wG) or O(n3) time is required to find a proper decomposition of G. Algorithm kD-Draw defines a new upper bound to the dominance dimension of a DAG. As corollaries we obtain (a) a new family of graphs that admit a 2-dimensional dominance drawing and (b) a new upper bound to the dimension of a partial order. We also introduce the concepts of transitive modules and dimensional neck wN of a DAG G and we show how to use them in order to improve our results using these concepts. Our paper is structured as follows: In Section 2 we describe necessary pre- liminary results. In Section 3 we first introduce the new dominance drawing technique for 2 dimensions, and then these results are extended to k dimensions. We introduce a new upper bound to the dominance dimension of a DAG and we discuss some additional implications of the results of this section. In Section 4 we introduce the concept of transitive modules and we use it to improve the upper bound on the number of dimensions presented in the previous section. In Sec- tion 5 we present our conclusions and we discuss interesting open problems that naturally arise from our two different approaches to k-dimensional dominance drawing. 2 2 Preliminaries Let G = (V, E) be an directed acyclic graph (DAG) with n vertices and m edges. An st-graph is a DAG with one source s and one sink t. In order to simplify our presentation, for the rest of the paper we will assume that every DAG is an st-graph. We do it without loss of generality, since we can obtain an st-graph from any DAG by adding a virtual source and a virtual sink and connecting them to all sources and sinks, respectively. Testing if G has dominance drawing dimension 2 requires linear time [15], while testing if its dimension is greater than or equal to 3 is NP-complete [19]. An efficient algorithm to compute 2- dimensional dominance drawings for planar st-graphs is shown in [3]. A partial order is a mathematical formalization of the concept of ordering. Any partial order P can be viewed as a transitive DAG. The results obtained for DAGs and their dominance drawing dimension transfer directly to partial orders and their dimension and vice-versa. Hence, we can talk about the results known for partial orders and for DAGs with no distinction. In [8] Hiraguchi proved a theorem that 2 , as gives a tight upper bound on the dominance dimension of G, which is n shown in the following lemma [8] (for a different proof, see [1]): Lemma 1. The dominance dimension of an st-graph G having n vertices is at most n 2 . In other words: dG ≤ n 2 . Now we introduce the concept of channel, which is a generalization of the concept of path. Then we will introduce a graph decomposition into channels, called channel decomposition. This decomposition will be used in the next section to improve the upper bound stated in Lemma 1. A channel C is an ordered set of vertices such that, given any two vertices v, w ∈ C, v precedes w in the order of channel C if and only if w is reachable from v in G. If u precedes v in the order of a channel C then v is a successor of u in C. We denote by channel decomposition of G a set of channels Sc = {C1, ..., Ck} so that the source s and the sink t of G are contained in every channel and every other vertex of G is contained in exactly one channel. The number of channels of a decomposition Sc is called size of Sc. Figure 1 shows an st-graph and a minimum size channel decomposition of it. The source and the sink of the st-graph G depicted in Part (a) are respectively 0 and 15. Red edges of Part (b) connect two consecutive vertices of a same channel. The dashed red edges represent edges of the transitive closure of G that do not belong to G. The channel decomposition showed in Part (b) is Sc = {C1, C2, C3, C4}, where: C1 = {0, 1, 4, 5, 12, 13, 15}; C2 = {0, 3, 7, 11, 15}; C3 = {0, 2, 6, 10, 14, 15}; C4 = {0, 8, 9, 15}. Notice that this channel decomposition is minimum, since the width of G is four. We will revisit this graph and will show a different dominance drawing obtained using the concept of transitive modules that we will introduce in Section 4. 3 (a) (b) Fig. 1: (a) An st-graph and a channel decomposition of it, with source 0 and sink 15. (b) A minimum size channel decomposition of G is Sc = {C1, C2, C3, C4}, where: C1 = {0, 1, 4, 5, 12, 13, 15}; C2 = {0, 3, 7, 11, 15}; C3 = {0, 2, 6, 10, 14, 15}; C4 = {0, 8, 9, 15}. 2.1 Minimum Size Channel Decomposition In this section we introduce the concept of width of an st-graph and we give a short description of an algorithm that computes a minimum size channel de- composition of an st-graph. Two vertices u, v ∈ V are incomparable if u doesn't reach v and vice versa. We denote by width of a DAG G, wG, the maximum size of a set of incomparable vertices of G. Computing the width of a graph requires linear time [9]. Additionally, the following result is proved in [5]: Lemma 2. The minimum size of a channel decomposition of G is equal to the width wG of G. Jagadish [9] presented an algorithm to compute a channel decomposition with the minimum number of channels in O(n3) time. To make our paper self-contained, in the next paragraph we outline a simple variation of this algorithm. First we compute a graph G(cid:48) from G such that: (a) any vertex v of G is associated with exactly two vertices of G(cid:48), that we call xv and yv; (b) (xv, yv) is an edge of G(cid:48) for any couple of vertices xv, yv; and (c) each edge (u, v) of G is associated with an edge (yu, xv) of G(cid:48). Any channel C = (s, vi, ..., vj, t) starting from the source s and ending at the sink t of G corresponds to a channel C(cid:48) = (xs, ys, xvi, yvi , ..., xvj , yvj , xy, yt) of G(cid:48). Now we solve the standard max- flow problem on the acyclic graph G(cid:48) by techniques such as [6]. In order to find a channel C of G from the flow of G(cid:48) we firstly add vertex s as the first element of C and we decrease the flow sent through edge (xs, ys) by one; then, if v is the last vertex added to C, we look for an edge (yv, xu) having a positive flow, we decrease its flow by one and we add u as the last element of C. We repeat this process until t is added to C. We find channels until every vertex of G belongs to at least one channel. A vertex could be inserted to more than one channels; in this case we simply remove it from all the channels it belongs to, except for one. The computed channels constitute a minimum size channel decomposition. 4 01512386910711131412540151238691071113141254C1C2C3C4 A faster algorithm, that runs in in O(wGn2) time, to compute a channel decomposition with the minimum number of channels is presented in [2]. We call this algorithm "Algorithm Channels-Generation". Hence, we have the following lemma: Lemma 3. Algorithm Channels-Generation computes a channel decomposition of a DAG G having wG channels in O(wGn2) time. 2.2 Projections and Compressed Transitive Closure Now we are ready to introduce the concept of projection of a vertex v on a channel C. We will also briefly talk about a data structure, called compressed transitive closure, that can be used to store all the projections for any vertex efficiently. The projections of a vertex v will be used to decide its coordinates in all the dimensions of our multidimensional dominance drawing. We denote by u = (i, j) the fact that u is the jth vertex of channel Ci. By the definition of channel decomposition we have t = (i,Ci) and s = (i, 0) for any i ∈ [1, k]. We denote by projection of a vertex u ∈ V on a channel C ∈ S the vertex v ∈ C having the lowest position in C among all the vertices of C reachable from u. We denote it by P rojC(u) = v, if u ∈ C then P rojC(u) = u. Notice that all the vertices can reach at least a vertex of every channel, since the sink t of the graph belongs to all the channels. Hence, the projection uC is defined for any couple (u, C) ∈ (V, Sc). The following lemma is immediate by the definition of projection: Lemma 4. Let u ∈ V be a vertex and let P rojCi(u) = v = (i, j) be the projec- tion of u on Ci; u can reach a vertex v(cid:48) = (i, j(cid:48)) ∈ Ci if and only if j(cid:48) ≥ j. Lemma 4 shows that we can use the projections to study the reachability properties of G. Jagadish describes in [9] a data structure that we can use to store all the projections of any vertex of G efficiently. This data structure is called compressed transitive closure. In the same paper he shows how to compute the compressed transitive closure of G in O(km) time, store it in O(kn) space and use it to read any projection P rojC(u) = v for any vertex u and any channel C in constant time. Figure 2 shows a representation of the compressed transitive closure of graph G depicted in Figure 1(a) given a channel decomposition of it, which is depicted in Figure 1(b). In order to have a better visualization, we restrict the repre- sentation of the compressed transitive closure to only two channels. Figure 2(a) shows the compressed transitive closure restricted to channels C1 and C2. The red edges connect vertices of the same channel. Let u and v be two vertices not belonging to the same channel. A gray edge (u, v) indicates that v is the pro- jection of u on the channel of vertex v. Part (b), Part (c), Part (d), Part (e), Part (f) represent the compressed transitive closure for the pairs of channels: (C1, C3), (C1, C4), (C2, C3), (C2, C4) and (C3, C4), respectively. 5 (a) (b) (c) (d) (e) (f) Fig. 2: Representation of the compressed transitive closure of graph G depicted in Fig- ure 1(a) given the channel decomposition of it that is depicted in Figure 1(b). In order to have a clearer figure, we restrict the representation of the compressed transitive closure by showing pairs of channels at a time. 6 01513711131254C1C20151261013141254C1C30189131254C1C4150152361071114C2C3015389711C2C4015286910C3C414 3 Multidimensional Dominance Drawing Let Sc = {C1, ..., Ck} be a channel decomposition of size k of st-graph G = (V, E). In this section we explain how we can use Sc and the projections of the vertices of G in order to create a dominance drawing of G in k dimensions. In Subsection 3.1 we present Algorithm 2-Dimensional-Draw (or simply 2D- Draw), that, for k = 2, computes a 2 dimensional dominance drawing of G. In Subsection 3.2 we extend the 2-dimensional algorithm by introducing Algo- rithm k-Dimensional-Draw (or simply kD-Draw), that computes a k dimensional dominance drawing of G for any channel decomposition of size k. 3.1 Base case: 2 Channels Let Sc = {C1, C2} be a channel decomposition of an st-graph G = (V, E) of size 2. We will present Algorithm 2D-Draw that receives as input G and Sc and produces a two dimensional dominance drawing Γ of G. The algorithm uses the order of the vertices in each channel, C1 and C2, in order to assign X and Y coordinates to the vertices of C1 and C2. Then the algorithm assigns appropriate X coordinates to the vertices that do not belong to channel C1 and Y coordinates to the vertices that do not belong to channel C2. It does this by assigning an X-coordinate to each vertex in C2 using the corresponding projection's X-coordinate, that was already assigned before (as shown in Line 4). Similarly, it assigns a Y -coordinate to each vertex in C1 using the corresponding projection Y -coordinate, that was already assigned before (as shown in Line 6). This process is shown in Lines 7-12. If(i = 1): X(v) = j Else: Algorithm 2D-Draw(G, Sc) Γ = new 2-dimensional drawing 1. For any v = (i, j) ∈ V : 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Y (v) = j: For any v ∈ C1 P rojC1 (v) = (1, j) X(v) = j P rojC2 (v) = (2, j) Y (v) = j For any v ∈ C2 output: Γ Figure 3 is an illustration of Algorithm 2D-Draw. Part (a) shows an st- graph G. The source of G is vertex 0 and the sink of G is vertex 7. Part (b) shows a channel decomposition Sc = {C1, C2} of G, where: C1 = {0, 3, 4, 7}; C2 = {0, 1, 2, 5, 6, 7}. Part (c) shows the projections of the vertices of G on 7 the channels they don't belong to. Part (d) shows the X coordinate assignment for the vertices of C1 and the Y coordinate assignment for the vertices of C2. These assignments are shown by writing the number of a vertex next to the corresponding coordinate; this is performed in Lines 2-6 of Algorithm 2D-Draw. Part (e) shows the assignment of the other coordinate to every vertex of G, that performed by Algorithm 2D-Draw in Lines 7-12 by using the projections of the vertices. For example, The projection of vertex 1 of channel C2 is 4, hence, X(1) = X(4). (a) (b) (c) (d) (e) Fig. 3: Illustration of Algorithm 2D-Draw: (a) an st-graph G; (b) a two-channel de- composition Sc = {C1, C2} of G, where: C1 = {0, 3, 4, 7}; C2 = {0, 1, 2, 5, 6, 7}; (c) the projections of the vertices of G on the channels they do not belong to; (d) the X coordinate assignment for the vertices of C1 and the Y coordinate assignment for the vertices of C2; (e) the assignment of the other coordinate of every vertex of G. We denote by r(u, v) = yes the fact that there exists a path starting from u and ending at v in G and by r(u, v) = no the fact that this path does not exist. Let Γ be a drawing of G. We denote by u (cid:22) v the fact that all the coordinates of u are less than or equal to the coordinates of v in all dimensions 8 6521340765213407C1C265213407C1C20012345123XY1256734701256734XY of Γ . The main result of this subsection is that Algorithm 2D-Draw computes a 2-dimensional dominance drawing of G. In other words, we prove that, for any u, v ∈ G: r(u, v) = yes ⇔ u (cid:22) v. This result will be proved in Lemma 8. Before we are able to prove that however, we need the following three lemmas (Lemma 5, Lemma 6 and Lemma7) that will be used in the proof of Lemma 8. Lemma 5. Any two distinct vertices v, w ∈ V are placed on distinct points in Γ . Proof. Let v = (1, j) and u = (h, l) be two different vertices. Without loss of generality we suppose that v ∈ C1 . We have two cases: (1) u ∈ C1; (2) u ∈ C2. We need to prove that X(v) (cid:54)= X(u) or Y (v) (cid:54)= Y (u): 1. h = 1 and u = (1, l). We have X(v) = j (cid:54)= l = X(u), since in this case j = l would imply that v and u are the same vertex. 2. h = 2 and u = (2, l). Let v(cid:48) = P rojC2 = (2, l(cid:48)) and u(cid:48) = P rojC1 = (1, j(cid:48)) be the projections of v and u. According to the algorithm X(v) = j, Y (v) = l(cid:48) and X(u) = j(cid:48), Y (u) = l. The vertices v and u would be placed in the same point if and only if l = l(cid:48) and j = j(cid:48), thus v = u(cid:48) and u = v(cid:48). In this case r(v, u) = yes and r(u, v) = yes by definition of projection, so there must be a cycle in G. This is a contradiction, since G is a DAG. Consequently X(v) (cid:54)= X(u) or Y (v) (cid:54)= Y (u). Lemma 6. Let v be a vertex of G. The source s is dominated by v and the sink t dominates v in Γ . In other words: X(s) ≤ X(v) ≤ X(t) and Y (s) ≤ Y (v) ≤ Y (t). Proof. Algorithm 2D-Draw places s such that X(s) = Y (s) = 0 and it places t such that X(t) = C1 and Y (t) = C2. Moreover, it places any v such that 0 ≤ X(v) ≤ C1 and 0 ≤ Y (v) ≤ C2. Lemma 7. Let u and v be two vertices of G. If u ∈ C1: r(u, v) = yes ⇔ X(u) ≤ X(v). Else, if u ∈ C2: r(u, v) = yes ⇔ Y (u) ≤ Y (v). Proof. If u ∈ C1 Algorithm 2D-Draw places v such that X(v) = j, where P rojC1 (v) = (1, j). If u ∈ C2 Algorithm 2D-Draw places v such that Y (v) = j, where P rojC2(v) = (2, j). The proof is given by Lemma 4. Now, we are ready to prove Lemma 8, which states that Algorithm 2D-Draw computes a dominance drawing. Lemma 8. Drawing Γ = 2D-Draw(G, Sc), computed by Algorithm 2D-Draw is a dominance drawing. Proof. Let v = (1, j) and u = (h, l) be two vertices, and assume without loss of generality, that v ∈ C1. If u or v is the source or the sink the theorem is true by Lemma 6. Recall that by Lemma 5 Algorithm 2D-Draw never places two distinct vertices on the same point of Γ . Hence, in order to prove that Γ is a dominance drawing we have to prove: u (cid:22) v ⇔ r(u, v) = yes. By Lemma 7 9 we have that: u (cid:22) v ⇒ r(u, v) = yes. Thus we have to prove the following: u (cid:22) v ⇐ r(u, v) = yes. For that, suppose that u is reachable from v. Let u(cid:48), v(cid:48) be the projections of u, v on the channel they don't belong to, respectively. If r(u, v) = yes we have two cases: (1) v and u are in the same channel or (2) they belong to different channels. 1. Let v(cid:48) = P rojC2(v) = (2, j(cid:48)) and u(cid:48) = P rojC1(u) = (2, l(cid:48)) be the projections of v and u. We have that l < j, since r(u, v) = yes and by definition of channels, therefore X(u) = l < j = X(v). If u(cid:48) is a successor of v(cid:48) then there is a cycle, therefore u(cid:48) = v(cid:48) or v(cid:48) is a successor of u(cid:48). This implies that l(cid:48) ≤ j(cid:48), which implies that Y (u) ≤ Y (v), since Y (v) = j(cid:48) and Y (u) = l(cid:48). Hence, u (cid:22) v. 2. In this case v = (1, j), u = (2, l), u(cid:48) = P rojC1 (u) = (1, l(cid:48)) and v(cid:48) = P rojC2(v) = (2, j(cid:48)). We have X(v) = j, X(u) = l(cid:48) and r(u, v) = yes. By Lemma 7 we conclude X(u) ≤ X(v). We have Y (v) = j(cid:48) and Y (u) = l. Additionally, if it were Y (v) = j(cid:48) < l = Y (u) then r(v, u) by Lemma 7. In this case G has a cycle, which is a contradiction. Since by hypothesis r(u, v) = yes therefore Y (u) = l ≤ l(cid:48) = Y (v) and u (cid:22) v. 3.2 Generalization: from 2 to k Channels In this subsection we extend the result obtained above by showing how to con- struct dominance drawings in k dimensions. The algorithm that we present is called Algorithm kD-Draw. The input to the algorithm is a graph G and a channel decomposition with k channels, Sc = {C1, ..., Ck}. The output of the algorithm is a dominance drawing Γ of G in k dimensions. Similar to the two dimensional case, the k-dimensional algorithm uses the order of the vertices in each channel, C1, ..., Ck, in order to assign coordinates, D1, ..., Dk. Clearly, in the previous section we had k = 2, and the dimensions were called D1 = X and D2 = Y . Given any vertex v = (i, j) ∈ Ci, Algorithm kD-Draw will assign the ith dimension of v as Di(v) = j. Then the algorithm assigns appropriate coordi- nates Dh(v), for all h (cid:54)= i, as follows: Dh(v) = l, where l is the position of the corresponding projection of v in channel Ch, i.e., u = P rojCh(v) = (h, l). In other words, the position of u in channel Ch. This is done for all vertices and all dimensions/channels. Algorithm kD-Draw(G,Sc = {C1, ..., Ck}) 1. 2. 3. 4. 5. 6. 7. 8. Γ = new k-dimensional drawing For any v = (i, j) ∈ V : For any v ∈ V : Di(v) = j For any Ch ∈ Sc such that v (cid:54)∈ Ch: P rojCh (v) = (h, l) Dh(v) = l output: Γ 10 Figure 4 shows an illustration of Algorithm kD-Draw. The input of the algo- rithm is the same graph G as depicted in Figure 1(a) and the channel decompo- sition Sc of G as depicted in Figure 1(b). In this case k = 4, hence, Algorithm kD-Draw will produce a 4-dimensional dominance drawing of G. Part (a) shows the initialization step, where the algorithm assigns the value of the coordinate in the dimension Di for every vertex v ∈ Ci (0 ≤ i ≤ 4). These assignments are shown by writing the number of a vertex next to the corresponding coordi- nate; this operation is performed in Lines 2-3 of the algorithm. Part (b) shows the assignment of the other coordinates. The vertex placement is performed by kD-Draw in Lines 4-7 by using the projections of the vertices, which are shown in Figure 2. We do not show the edges on the graph, since in the depicted two planes of the 4-dimensional drawing some vertices are positioned in a same point and it could create ambiguities in the representation of the edges. Clearly, if k = 2, kD-Draw and 2D-Draw compute the same drawing. Hence, kD-Draw is a generalization of 2D-Draw. As we did in the previous section, be- fore proving that Γ = kD-Draw(G, Sc) is a dominance drawing we prove some intermediate results. Lemma 9. Any two distinct vertices v, w ∈ V are placed on distinct points in Γ . Proof. Let v = (i, j) and u = (h, l) be two vertices of G. It is sufficient to prove that there exists at least one dimension Dx such that Dx(v) (cid:54)= Dx(u) for any pair of vertices u, v. Following arguments similar to the ones used in the proof of Lemma 5 it is easy to prove that Di or Dh can be Dx. The following two lemmas can be proved using similar arguments to the ones used to prove Lemma 6 and Lemma 7: Lemma 10. For any vertex v ∈ G: s (cid:22) v and v (cid:22) t. Lemma 11. Let u ∈ Ci and v be two vertices of G. r(u, v) = yes ⇔ Di(u) ≤ Di(v). We are ready now to prove the main result of this section: Theorem 1. Let G be an st-graph and Sc = {C1, ..., Ck} be a channel decom- position of G. Given G, Sc and the set of all the projections for any vertex (provided by the compressed transitive closure), Algorithm kD-Draw computes a k-dimensional dominance drawing Γ of G. Moreover: (a) kD-Draw requires O(kn) time. (b) A preprocessing step required to compute all the projections of the vertices of G takes time O(mk). (c) If k is required to be equal to the width of G, wG, then the preprocessing step requires time O(n3) or O(wGn2). 11 (a) (b) Fig. 4: Illustration of Algorithm kD-Draw on graph G depicted in Figure 1(a) and the channel decomposition Sc of G depicted in Figure 1(b): (a) shows the initialization step, where the algorithm assigns the value of the coordinate in dimension Di for every vertex v ∈ Ci (0 ≤ i ≤ 4); (b) shows the assignment of the other coordinates, computed by Algorithm kD-Draw in Lines 4-7 by using the projections of the vertices, as shown in Figure 2. We do not show the edges of the graph, since in the depicted two planes of the 4-dimensional drawing some vertices are positioned in a same point and it could create ambiguities in the representation of the edges. 12 012365401234D1D20123540123D3D437111514515131200891526101514D1D2D3D412,4512136,8,9,10,14,150371101,23,4,5,7,11,12,13,14,1561098 Proof. First, we prove the correctness of the algorithm, i.e., we prove that the drawing computed by our algorithm is a dominance drawing. Then we will prove the time complexity of the algorithm. Let v = (i, j) and u = (h, l) be two different vertices. If u or v are the source or the sink the theorem is clearly true by Lemma 10. Otherwise, without loss of generality, suppose that i = 1 i.e., v = (1, j). Lemma 9 proves that u and v are never placed in a same point. Moreover, Lemma 11 proves that u (cid:22) v ⇒ r(u, v) = yes. We need to prove that: r(u, v) = yes ⇐ u (cid:22) v. Let Dp be a dimension of Γ (p ∈ [1, k]). We prove that Dp(u) ≤ Dp(v) for any possible value of p. First we assume that p = i or p = h. Next, we consider all other cases. 1. We can prove that Dp(u) ≤ Dp(v) using arguments similar to the ones used 2. Suppose u(cid:48) = P rojCp (u) = (p, l(cid:48)) and v(cid:48) = P rojCp (v) = (p, j(cid:48)). We have r(u, v(cid:48)) = yes, since r(u, v) = yes and r(v, v(cid:48)) by definition of projection. The vertex u(cid:48) has the lowest position in Cp among the vertices of Cp reachable from u. Therefore it must be equal to v(cid:48) or one of its successors. Consequently l(cid:48) ≤ j and Dp(u) ≤ Dp(v). in Case (1) of the proof of Lemma 8. Finally, regarding the computational time: (a) kD-Draw needs O(n) time for the Lines 2-3 and O(nk) time for the Lines 4-7 by Lemma 4. (b) We store the projections of the vertices of G in a compressed transitive closure. The time needed to compute the compressed transitive closure is O(km) [9]. (c) A channel decomposition with the minimum number of channels, k, can be computed in O(n3) or O(wGn2) time [9,2]. is a dominance draw- Dominance Drawing with Distinct Coordinates ing where the value of the coordinates of the vertices in every dimension is a topological sorting of the vertices (i.e., distinct coordinates). In the rest of the section we show how we can compute a k-dimensional dominance Drawing with distinct coordinates ΓT of G given a k-dimensional dominance drawing Γ of G. Suppose that the vertices of G are topologically sorted and let T (v) be the order of vertex v in the topological sorting. Let Dg be a dimension of Γ and let {v1, ..., vl} be the set of vertices having the same coordinate in dimension Dg, i.e., Dg(v1) = Dg(v2) = ... = Dg(vl) = α. Suppose T (v1) < T (v2) < ... < T (vl). Let Vα,g be the set of vertices having coordinate higher than α in dimension Dg. We shift the vertices of Vα,g by l positions and we shift every vertex vi, i = 1, 2, ..., l by i− 1 positions. We do continue with this process until there is no pair of vertices placed in the same position. It is easy to see that the resulting drawing ΓT is a dominance drawing with distinct coordinates. Figure 5 shows a dominance drawing with distinct coordinates obtained from the dominance drawings shown in Figure 4(b). 13 Fig. 5: A dominance drawing with distinct coordinates obtained from the drawings shown in Figure 4(b) 14 0124357121113689101415D1D20D3D4126810934571112131415 3.3 Corollaries The dominance drawing algorithm presented above provides interesting corollar- ies in the general dimension theory of DAGs. Namely, the following corollary is a direct consequence of Lemma 1, Lemma 2 and Theorem 1. We point out that Algorithm kD-Draw provides a new upper bound to the dominance dimension of an st-graph: Corollary 1. Let G be any st-graph (or DAG) with n vertices. Then dG ≤ min( n 2 , wG). As discussed in the introduction, any st-planar graph has a 2-dimensional domi- nance drawing [4,3]. The next corollary presents a new family of DAGs that have a 2-dimensional dominance drawing. Obviously these DAGs are not contained in the st-planar family. Corollary 2. Every DAG G of width 2 has a 2-dimensional dominance drawing. As discussed in the preliminaries, a partial order is a mathematical formaliza- tion on the concept of ordering and the results obtained for DAGs and their dominance drawing dimension transfer directly to partial orders and their di- mension and vice versa. Therefore, let dP be the dimension of partial order P . As a consequence of the previous corollary we have the following: Corollary 3. Let P be any partial order with n elements. Then dP ≤ min( n 2 , wP ). 4 Modules and Dominance Drawings In this section we will exploit the concept of modules in directed acyclic graphs in order to obtain dominance drawings having potentially less dimensions. Let G = (V, E) be an st-graph with n vertices and m edges. A module M of G is a non-empty subset of V such that all vertices in M have the same sets of predecessors and successors in V − M. Decomposing a graph into modules may help in various graph problems [16]. The trivial modules of G are: the set V and the singleton sets {v}, for any v ∈ V . A graph is called prime if it does not possess non-trivial modules. Two modules overlap if they have a non empty intersection, and one does not contain the other. A module is a strong module if it does not overlap with any module, otherwise it is a weak module. A modular decomposition of G is a representation of all modules of G. The decomposition forms a tree, whose nodes are the strong modules of G, ordered by the subset relationship. In particular, the root of the modular decomposition tree is V , and its leaves are the singleton sets. The congruence partition CP = {M1, ..., Mh} of V is a partition of V into modules (i.e., each vertex belongs to exactly one module Mi, with 1 ≤ i ≤ h). It is easy to obtain a congruence partition from a modular decomposition. Each DAG has an exponential number of congruence partitions [14,16]. The quotient graph G0 of G given CP is the graph obtained from G by merging the nodes 15 of each module in CP . We denote by µi the vertex representing Mi in G0. The following lemma is true due to the definitions of module and of quotient graph: Lemma 12. Let u, v be two vertices of G such that u ∈ Gi and v ∈ Gj. Vertex µj is reachable from vertex µi in G0 if and only if v is reachable from u in G. Let G∗ be the transitive closure of G. A module M of G∗ is a transitive module of G. The transitive congruence partition CP of V is a partition of V into transitive modules. The transitive quotient graph G/CP is the graph obtained from G by merging the nodes of each transitive module in CP . Figure 6(a) shows a transitive congruence partition CP = {M1, M2, M3, M4} of the graph G depicted in Figure 1(a), where: M1 = { 0, 1, 2}; M2 = {3, 4, 5, 7, 11, 12, 13}; M3 = {6, 8, 9, 10}; M4 = {14, 15}. Figure 6(b) shows the quotient graph G0 of G given CP . (a) (b) Fig. 6: (a) A transitive congruence partition CP = {M1, M2, M3, M4} of graph G shown in Figure 1(a), where: M1 = {0, 1, 2}; M2 = {3, 4, 5, 7, 11, 12, 13}; M3 = {6, 8, 9, 10}; M4 = {14, 15}; (b) the quotient graph G0. A modular decomposition of G can be computed in linear time [14,16]. Hence, computing a transitive modular decomposition of G requires O(nm) times, since it is equivalent to computing the modular decomposition of G∗. From now on we will only deal with transitive modules, transitive congruence partitions and transitive quotient graph, so in our description we will omit the term "transi- tive". Let CP = {M1, ..., Mh} be a congruence partition of G and let G0 be the quotient graph G/CP . We denote by µi the vertex representing Mi in G0. We denote by module-induced graph of Mi the graph Gi = (Mi, E(Mi)), where E(Mi) is the subset of edges of E which are incident to two vertices of Mi. Without loss of generality we assume that every Gi is an st-graph. If Gi is not an st-graph we do the operations described in the next paragraph. 16 M1M2M3M40151238691071113141254µ1µ2µ3µ4G0 If Gi contains the source of the graph, we add a virtual sink ti to it; if it contains the sink of the graph, we add a virtual source si to it; else, we add a virtual source si and a virtual sink ti to it. Then: we add some edges connecting all the vertices of V − Mi reaching Mi to si; we add some edges connecting ti to all the vertices of V − Mi reached by Mi; we remove all the edges of V − Mi adjacent to a vertex of Mi different from si and ti. Figure 7 shows the graph obtained by adding a sink and a source to every module of the graph depicted in Figure 6 following the steps described in the above paragraph. Fig. 7: The graph obtained from the graph G shown in Figure 6 after adding a sink and a source to every module of the G. Figure 8 shows the induced graphs of graph G shown in Figure 7. Let G(CP ) = {G0, G1, ..., Gh} be the set of all the module-induced graphs of G augmented with G0. We denote by wi the width of Gi (i.e., wGi = wi). We denote by dimensional neck wN of CP and G(CP ) the value of the maximum width among all the graphs in G(CP ). Any graph Gi ∈ G(CP ) is isomorphic to a subgraph of G∗ and the width of G is equal to the width of it s transitive closure. Hence, wN ≤ wG∗ = wG. Let G(CP ) = {G0, G1, ..., Gh} be the set of all the module-induced graphs of G augmented with G0. We denote by wi the width of Gi (wGi = wi). We denote by dimensional neck wN of CP and G(CP ) the value of the maximum width among all the graphs in G(CP ). Any graph Gi ∈ G(CP ) is isomorphic 17 t2s2t1t3s3s415=t4143711131254869100=s112M1M2M3M4 Fig. 8: The induced graphs of graph G shown in Figure 7. to a subgraph of G∗ and the width of G is equal to the width of its transitive closure. This means that wn ≤ wG∗ = wG. Hence we have the following: Lemma 13. The dimensional neck of G(CP ) is not greater than the width of G. In other words, wN ≤ wG. We are interested in calculating a dominance drawing Γi for each graph Gi of CP . Moreover, we want to merge these drawings into a single dominance drawing of G. In order to do that, we want the drawings Γ0, ..., Γh to have the same number of dimensions. Notice that, given a channel decomposition of a graph Gi having size α, it is always possible to compute a channel decomposition of Gi = (Vi, Ei) having size α+β, for any β, by adding to the channel decomposition β (dummy) channels containing only the source and the sink of Gi. The following algorithm, called Algorithm Drawings-Computation, receives as input the set G(CP ) = {G0, ..., Gh} and it gives as output the set of wN- dimensional dominance drawings Γ1, ..., Γh, where Γi is a wN-dimensional dom- inance drawing of Gi, for any i = 1, 2, ..., h. In Line 1 we compute the dimensional neck wN of G(CP ). This is trivial, since we can simply compute the width of any DAG in G(CP ) (as described in [9]) and pick up the highest one. This operation requires linear time. In Lines 2-3 we C of minimum size for any Gi by using Al- compute a channel decomposition Si gorithm Channels-Generation, which was introduced in Section 2.2. In Lines 4-6 we add channels containing only the source and the sink of Gi to any Si C until its size is wN. Then we compute a wN-dimensional dominance drawing Γi of each Gi using Algorithm kD-Draw, as described in Section 3. Algorithm Drawings-Computation(G(CP )) 1. 2. 3. 4. C = Channels-Generation(Gi) Si While Si Compute the dimensional neck wN of G(CP ). For each Gi = G0, G1, ..., Gh c contains less than wN channels 18 G4G3G2G1t2s23711131254t10=s112t3s386910s415=t414 5. 6. 7. 8. CSi SC.add(CSi c+1 = {si, ti} c+1) Γi = kD-Draw(Gi, Si C) output: Γ0, ..., Γh Figure 9 shows the output of Algorithm Drawings-Computation given the set G(CP ) = {G0, G1, G2, G3, G4}, where G0 is depicted in Figure 6(b) and the induced graphs G1, G2, G3, and G4 are depicted in Figure 8. Part (a) shows: a channel decomposition {C01, C02} of minimum size of G0, computed in Line 3 of Algorithm Drawings-Computation, where C01 = {µ1, µ2, µ4} and C02 = {µ1, µ3, µ4}; the dominance drawing Γ0 of G0, computed in Line 7 of Algo- rithm Drawings-Computation. Similarly: Part (b) shows {C11, C12}, where C11 = {0, 1, t1} and C12 = {0, 2, t1}, and Γ1; Part (c) shows {C21, C22}, where C21 = {s2, 3, 4, 5, 12, 13, t2} and C22 = {s2, 7, 11, t2}, and Γ2; Part (d) shows {C31, C32}, where C31 = {s3, 6, 10, t3} and C32 = {s3, 8, 9, t3}, and Γ3; Part (e) shows {C41, C42}, where C41 is the empty channel {s4, 15} and C42 = {s4, 14, 15}, and Γ4. We recall that computing wN from a graph requires linear time [9]. It is easy to see that the time complexity of the algorithm depends on Line 3, where we compute the minimum-size channel decomposition of any graph in G(CP ), and Line 7, where we compute the dominance drawings Γ0, ..., Γh. In order to characterize this time complexity we give some further definitions. We denote by ni the number of vertices of Gi. We recall that the number of vertices of G0 is equal to the number of modules of CP and that the number of vertices of any Gi is equal to the number of vertices of the module Mi. Hence, n0 = CP and ni = Mi for any 0 < i ≤ h. Let ρ be the maximum ni for i ∈ [0, h] and let wρ be the maximum width among the graphs of G(CP ) having wρ vertices. Lemma 14. The maximum number of vertices of a module of CP , ρ, is greater than or equal to the dimensional neck of G(CP ). In other words, wN ≤ ρ. Proof. Let Gi be the graph such that wi = wN. We have that wN is less than ni by Lemma 1 and ni is less than ρ by the definition of ρ. In other words: wN ≤ ni ≤ ρ. The time complexity of Line 3 is O(wρρ2), Lemma 3, and the time complexity of Line 8 is O(wN ρ). Moreover, O(wN ρ) ∈ O(wρρ2) by Lemma 14. It means that the computational complexity of Algorithm Drawings-Computation depends on Line 3. Hence, we have the following lemma: Lemma 15. Algorithm Drawings-Computation requires O(wρρ2) time. Lemma 15 tells that the time complexity of the algorithm depends on the max- imum number of vertices ρ belonging to a same module and on the width wrho of the graph having such a number of vertices. As discussed earlier, our final goal is to merge the wN-dimensional dominance drawings Γ0, ..., Γh of graphs G0, ..., Gh into a wN-dominance drawing Γ of the 19 (a) (c) (b) (d) (e) Fig. 9: The output of Algorithm Drawings-Computation given the set G(CP ) = {G0, G1, G2, G3, G4}, where G0 is depicted in Figure 6(b) and the induced graphs G1, G2, G3, and G4 are depicted in Figure 8. 20 µ1µ2µ3µ4C01C02XYµ1µ3µ4µ2t10=s112C11C120=s1XYt121t2s23711131254C21C223451213t2711XYt3s386910s3t310968C31C32XYs415=t414C41C42s4XY1415=t4 original graph G. Our strategy is to create space in the dominance drawing Γ0 of the quotient graph G0 in order to insert the drawings Γ1, ..., Γh in it by simply using vertex µi as the new origin of drawing Γi for any i ∈ [1, h]. We create space by shifting, as described in Algorithm Shifter. It receives as input the drawings Γ0, ..., Γh and gives as output a modified drawing Γ0, where the vertices are shifted. Suppose that we want to shift µj with respect of µi in dimension Dg (notice that all the possible ordered couples of vertices of G0 are chosen in Lines 1-2 and that all the dimensions are chosen for every ordered couple of vertices in Line 3). We shift µj if and only if one of the fol- lowing conditions is true: its coordinate in some dimension Dg is greater than the corresponding coordinate of µi; the coordinates of µi and µj are equal (in dimension Dg) and µj is reachable from µi. This check is done in Line 4. In that case, let y be the maximum value of a coordinate in Dg in drawing Γj, i.e., the coordinate of tj (Line 6). We shift µj in dimension Dg by y positions (Line 7). For each µj ∈ G0 such that i (cid:54)= j: For each Dg = D1, ..., DwN For each µi ∈ G0: Algorithm Shifter(Γ0, ..., Γh) 1. 2. 3. 4. 5. 6. 7. output: Γ0 If [Dg(µi) < Dg(µj) ∨ (Dg(µi) = Dg(µj) ∧ r(µi, µj))] Let y be equal to the coordinate of tj in Γj Dg(µj)+ = y Figure 10 is an illustration of Algorithm Shifter. The algorithm receives as input the drawings depicted in Figure 9. Part (a) shows drawing Γ0. Part (b) shows the drawing Γ0 after we perform the shifting to accommodate Γ1. Part (c) shows drawing Γ0 after we perform the shifting to accommodate Γ2. Finally, Part (d) shows drawing Γ0 after we perform the shifting to accommodate Γ3. The space reserved for each Γ1, Γ2, and Γ3 during the algorithm is shown with a red box. Recall that the number of vertices of G0 is equal to h, which is the number of modules of CP . Moreover, the number of dimensions of Γ0 are wN. Algorithm Shifter shifts in constant time every vertex of G0 with respect to every other vertex of G0 in every dimension of Γ0 in constant time. Hence, we have the following lemma: Lemma 16. The time complexity of Algorithm Shifter is O(wN h2). Finally, putting everything together, we present Algorithm Neck-Dimensional- Draw (or simply ND-Draw). It takes as input G(CP ) and produces as output a dominance drawing of G. First we compute the dominance drawings Γ0, ..., Γh of the module induced graphs G0, ..., Gh ∈ G(CP ) by using Algorithm Drawings- Computation (Line 1 of ND-Draw). Next we use Algorithm Shifter to shift the vertices of Γ0 in order to create space for the vertices of G1, ..., Gh, which are already placed in Γ1, ..., Γh (Line 2). Finally, we place every vertex of v ∈ Gi in Γ0 (Lines 3-8). We denote by Dg(v, Γ0) the coordinate of the vertex v in the 21 (a) (b) (c) (d) Fig. 10: Illustration of Algorithm Shifter using as input the drawings depicted in Fig- ure 9: (a) shows the drawing Γ0; (b) shows Γ0 after the shifting done with respect to Γ1; (c) shows Γ0 after the shifting done with respect to Γ2; (d) shows Γ0 after the shifting done with respect to Γ3. The space reserved for Γ1, Γ2, and Γ3 during the algorithm is always shown with red boxes. 22 µ1µ3µ4µ2µ1µ3µ4µ2Γ1µ1µ3µ2µ4Γ2Γ1µ1µ3µ2µ4Γ3Γ1Γ2XY dimension Dg of drawing Γ0. The coordinate in the dimension Dg of v in Γ0 is the sum of the coordinate of µi in Γ0 with the coordinate of v in Γi (Line 6). This calculation is made for every v ∈ V . The output of the algorithm is a dominance drawing Γ of G having wN dimensions. Algorithm ND-Draw(G(CP )) 1. 2. 3. 4. 5. 6. 7. 8. For any v ∈ Gi output: Γ = Γ0 Γ0, ..., Γh = Drawings-Computation(G(CP )) Γ0 = Shifter(Γ0, ..., Γh) For each Γi = Γ1, ..., Γh: For each Dg = D1, ..., DwN Dg(v, Γ0) = Dg(µi, Γ0) + Dg(v, Γi) remove µi from Γ0 Figure 11 shows a representation of the output of Algorithm ND-Draw when the input of the algorithm is the set G(CP ) = {G0, G1, G2, G3, G4}, where G0 is depicted in Figure 6(b) and the induced graphs G1, G2, G3, and G4 are depicted in Figure 8. This drawing is obtained by substituting the drawings in Figure 9 in the respective space reserved for them in Figure 10 as described by Algorithm ND-Draw. Figure 12 shows the drawing of Figure 11 where the added sources and sinks are removed and the original edges of the graph are restored. Notice that this is the same DAG as the one shown in Figure 1 along with its four channels. According to that channel decomposition, the DAG requires four dimensions, whereas, after using the module decomposition technique it requires only two dimensions. Important Observation on the New Dominance Drawing Technique The graph shown in Figure 11 and Figure 12 is the same graph G shown in Figure 1. Recall that G has a minimum size channel decomposition as shown in Figure 1 (b) Sc = {C1, C2, C3, C4}, where: C1 = {0, 1, 4, 5, 12, 13, 15}; C2 = {0, 3, 7, 11, 15}; C3 = {0, 2, 6, 10, 14, 15}; C4 = {0, 8, 9, 15}. Therefore according to Algorithm kD-Draw it can be drawn as a 4-dimensional dominance drawing, which is the best that can be done by using only the channel decomposition approach. However, after using the module decomposition techniques of this section, we are able to reduce the number of required dimensions to two, as shown Figures 11 and 12. Therefore, the use of module decomposition allows us to "group" parts of the graph so that the total number of dimensions is cut in half for this example graph. 23 Fig. 11: Output of Algorithm ND-Draw when the input is the set G(CP ) = {G0, G1, G2, G3, G4}, where G0 is depicted in Figure 6(b) and the induced graphs G1, G2, G3, and G4 are depicted in Figure 8. This drawing is obtained by substituting the drawings in Figure 9 in the respective space reserved for them of Figure 10 as described by Algorithm ND-Draw. 24 0s3s2s4t1213451213t2711t310981415XY Fig. 12: The drawing of Figure 11 where the added sources and sinks are removed and the original edges of the graph are restored. 25 0213451213711109814156XY We are ready now to state the main result of this section: Theorem 2. Let G be an st-graph and CP = {M1, ..., Mh} be a congruence partition of G. Let G(CP ) = {G0, G1, ..., Gh} be the set of all the module-induced graphs of G augmented with the quotient graph G0. Let wN be the dimensional neck of G(CP ). Algorithm ND-Draw computes a wN-dimensional dominance drawing Γ of G in O(wρρ2 + wN (h2 + n)) time. Proof. First, we prove the correctness of the algorithm, i.e., we prove that the computed drawing is a dominance drawing. Then we prove the time complexity of the algorithm. Let u, v be two vertices, where u ∈ Gi and v ∈ Gj. We need to prove that r(u, v) = yes ⇔ u (cid:22) v for any choice of u and v. We have r(u, v) = yes ⇔ u (cid:22) v in G if j = i, since the relative position of u and v in Γ do not change in Γi, which is a dominance drawing of Gi. Suppose i (cid:54)= j and r(u, v) = yes. In that case µi reaches µj in G0 by Lemma 12 and µi (cid:22) µj in Γ0, since Γ0 is a dominance drawing of G0. The vertex µj is shifted with respect of µi in any dimension Dg in Γ0 by Dg(u, Γi) ≤ Dg(ti, Γi) positions. Moreover, Dg(u, Γ0) = Dg(µi, Γ0)+Dg(u, Γi) ≤ Dg(µj, Γ0) ≤ Dg(v, Γ0), which implies that u (cid:22) v. Now suppose i (cid:54)= j and r(u, v) = no. In this case, there exists at least one dimension Dx for which Dx(µi) > Dx(µj) by Lemma 9 and Lemma 12. The vertex µi is not shifted with respect of µj in Dx. On the contrary, µj is shifted with respect of µi by Dx(ti, Γi) positions. Hence, Dx(µi) > Dx(µj) also after the shifting and in the final drawing. The computational time required has three contributions: O(wρρ2) time is needed due to Line 1 and Lemma 15; O(wnh2) time is needed due to Line 2 and Lemma 16; O(wN n) time is needed since every vertex is placed in wN dimensions. The following corollaries are similar to the ones presented in Subsection 3.3, but they give improved bounds since the dimensional neck wN is potentially much better than the width wG of any DAG G: Corollary 4. Let G be an st-graph (or DAG) having n vertices and a congruence partition CP . If wN is the dimensional neck of G(CP ), then: dG ≤ min( n 2 , wN ) Corollary 5. Every DAG G having a congruence partition CP with dimensional neck equal to 2 has a 2-dimensional dominance drawing. If we define a congruence partition and its dimensional neck for a partial order P as we did for the DAGs, we have the following corollary: Corollary 6. For any partial order P having n elements and any congruence partition of it. If wN is the dimensional neck of CP , then: dP ≤ min( n 2 , wN ) 5 Conclusions and Open Problems The contributions of our paper are as follows: we proved that every DAG G of 2 , wG) is width 2 has a 2-dimensional dominance drawing; we proved that min( n an upper bound of the dominance dimension dG of the DAG G; we proved that 26 2 , wP ) is an upper bound for the dimension dP of a partial order P ; we min( n introduced the dimensional neck wN of a DAG G, we proved that wN ≤ wG and we improved the upper bounds described above using this new parameter. This clearly visible by the fact that the DAG of Figure 1 requires four dimensions due to the given channel decomposition, whereas it requires only two dimensions after applying the module decomposition techniques. An interesting open problem is to reduce the number of dimensions of the drawings computed by the algorithms described in this paper in order to have a weak dominance drawing with a bounded number of fips. In this direction approximation algorithms as well as heuristic algorithms should be developed. Another open problem could be the extension of the family of DAGs having a 2-dimensional dominance drawing with DAGs having width higher than 2. We propose to study the problem of computing a congruence partition having a minimum dimensional neck, since it let us compute dominance drawing with less dimensions in less time. It could be interesting to better understand the relationship between this problem and the NP-hard problem of computing the dominance dimension of a DAG. Additionally, we propose to study the problem of computing a congruence partition having small size (h), a small wρ, and a small ρ, since the time complexity of ND-Draw depends also on these param- eters. Finally, perhaps the most interesting open problem is to find families of graphs and prove a mathematical relationship between the number of dimensions (wG) required by Algorithm kD-Draw and the number of dimensions required by Algorithm ND-draw, similar to the one that we observed for the example graph of Figure 1 shown in Figures 4 and 12. Acknowledgement: We thank Roberto Tamassia for useful discussions and for pointing our attention to Hiraguchi's results. 27 References 1. K. P. Bogart. Maximal dimensional partially ordered sets i. hiraguchi's theo- rem. Discrete Mathematics, 5(1):21 -- 31, 1973. URL: https://doi.org/10.1016/ 0012-365X(73)90024-1, doi:10.1016/0012-365X(73)90024-1. 2. Y. Chen and Y. Chen. On the dag decomposition. British Journal of Mathematics and Computer Science, 2014. 10(6): 1-27, 2015, Article no.BJMCS.19380, ISSN: 2231-0851. 3. G. Di Battista, P. Eades, R. Tamassia, and I. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, 1998. pp. 112 -- 127. 4. G. Di Battista, R. Tamassia, and I. G. Tollis. Area requirement and symmetry dis- play of planar upward drawings. Discrete & Computational Geometry, 7:381 -- 401, 1992. URL: https://doi.org/10.1007/BF02187850, doi:10.1007/BF02187850. 5. R. P. Dilworth. A decomposition theorem for partially ordered sets. ann. math. 52, (1950), 161-166. 6. Y. A. Dinitz. Algorithm for solution of a problem of maximum flow in networks with power estimation. Soviet Math. Doklady, 11:1277 -- 1280, 1970. URL: https: //ci.nii.ac.jp/naid/10021311931/en/. 7. H. A. ElGindy, M. E. Houle, W. Lenhart, M. Miller, D. Rappaport, and S. White- sides. Dominance drawings of bipartite graphs. In Proceedings of the 5th Canadian Conference on Computational Geometry, Waterloo, Ontario, Canada, August 1993, pages 187 -- 191, 1993. 8. T. Hiraguchi. On the dimension of partially ordered sets. Sci. Rep. Kanazawa Univ., pages 77 -- 94, 1951. 9. H. V. Jagadish. A compression technique to materialize transitive closure. ACM Trans. Database Syst., 15(4):558 -- 598, 1990. URL: http://doi.acm.org/10.1145/ 99935.99944, doi:10.1145/99935.99944. 10. E. M. Kornaropoulos and I. G. Tollis. Weak dominance drawings and linear exten- sion diameter. CoRR, abs/1108.1439, 2011. URL: http://arxiv.org/abs/1108. 1439, arXiv:1108.1439. 11. E. M. Kornaropoulos and I. G. Tollis. Weak dominance drawings for directed acyclic graphs. In Graph Drawing - 20th International Symposium, GD 2012, Redmond, WA, USA, September 19-21, 2012, Revised Selected Papers, pages 559 -- 560, 2012. URL: https://doi.org/10.1007/978-3-642-36763-2_52, doi: 10.1007/978-3-642-36763-2\_52. 12. E. M. Kornaropoulos and I. G. Tollis. Algorithms for overloaded orthogonal draw- ings. J. Graph Algorithms Appl., 20(2):217 -- 246, 2016. URL: https://doi.org/ 10.7155/jgaa.00391, doi:10.7155/jgaa.00391. 13. L. Li, W. Hua, and X. Zhou. HD-GDD: high dimensional graph domi- nance drawing approach for reachability query. World Wide Web, 20(4):677 -- 696, 2017. URL: https://doi.org/10.1007/s11280-016-0407-z, doi:10.1007/ s11280-016-0407-z. 14. R. M. McConnell and F. de Montgolfier. Linear-time modular decomposition of di- rected graphs. Discrete Applied Mathematics, 145(2):198 -- 209, 2005. URL: https: //doi.org/10.1016/j.dam.2004.02.017, doi:10.1016/j.dam.2004.02.017. 15. R. M. McConnell and J. Spinrad. Linear-time transitive orientation. SODA, pages 19 -- 25, 1997. 16. R. M. McConnell and J. P. Spinrad. Modular decomposition and transitive orien- tation. Discrete Mathematics, 201(1-3):189 -- 241, 1999. URL: https://doi.org/ 10.1016/S0012-365X(98)00319-7, doi:10.1016/S0012-365X(98)00319-7. 28 17. J. M. Six and I. G. Tollis. Automated visualization of process diagrams. In P. Mutzel, M. Jünger, and S. Leipert, editors, Graph Drawing, pages 45 -- 59, Berlin, Heidelberg, 2002. Springer Berlin Heidelberg. 18. R. R. Veloso, L. Cerf, W. M. Jr., and M. J. Zaki. Reachability queries in very large graphs: A fast refined online search approach. In Proceedings of the 17th International Conference on Extending Database Technology, EDBT 2014, Athens, Greece, March 24-28, 2014., pages 511 -- 522, 2014. URL: https://doi.org/10. 5441/002/edbt.2014.46, doi:10.5441/002/edbt.2014.46. 19. M. Yannakakis. The complexity of the partial order dimension problem. SIAM J. Algebraic and Discrete Methods, 3:303 -- 322, 1982. 20. J. Zhou, S. Zhou, J. X. Yu, H. Wei, Z. Chen, and X. Tang. Dag reduction: Fast answering reachability queries. In Proceedings of the 2017 ACM International Conference on Management of Data, SIGMOD '17, pages 375 -- 390, New York, NY, USA, 2017. ACM. URL: http://doi.acm.org/10.1145/3035918.3035927, doi:10.1145/3035918.3035927. 29
1708.03962
2
1708
2017-08-15T14:48:09
Dynamic Minimum Spanning Forest with Subpolynomial Worst-case Update Time
[ "cs.DS" ]
We present a Las Vegas algorithm for dynamically maintaining a minimum spanning forest of an $n$-node graph undergoing edge insertions and deletions. Our algorithm guarantees an $O(n^{o(1)})$ worst-case update time with high probability. This significantly improves the two recent Las Vegas algorithms by Wulff-Nilsen [STOC'17] with update time $O(n^{0.5-\epsilon})$ for some constant $\epsilon>0$ and, independently, by Nanongkai and Saranurak [STOC'17] with update time $O(n^{0.494})$ (the latter works only for maintaining a spanning forest). Our result is obtained by identifying the common framework that both two previous algorithms rely on, and then improve and combine the ideas from both works. There are two main algorithmic components of the framework that are newly improved and critical for obtaining our result. First, we improve the update time from $O(n^{0.5-\epsilon})$ in Wulff-Nilsen [STOC'17] to $O(n^{o(1)})$ for decrementally removing all low-conductance cuts in an expander undergoing edge deletions. Second, by revisiting the "contraction technique" by Henzinger and King [1997] and Holm et al. [STOC'98], we show a new approach for maintaining a minimum spanning forest in connected graphs with very few (at most $(1+o(1))n$) edges. This significantly improves the previous approach in [Wulff-Nilsen STOC'17] and [Nanongkai and Saranurak STOC'17] which is based on Frederickson's 2-dimensional topology tree and illustrates a new application to this old technique.
cs.DS
cs
Dynamic Minimum Spanning Forest with Subpolynomial Worst-case Update Time Danupon Nanongkai1, Thatchaphol Saranurak1, and Christian Wulff-Nilsen2 1KTH Royal Institute of Technology, Sweden 2University of Copenhagen, Denmark Abstract We present a Las Vegas algorithm for dynamically maintaining a minimum spanning forest of an n-node graph undergoing edge insertions and deletions. Our algorithm guarantees an O(no(1)) worst-case update time with high probability. This significantly improves the two recent Las Vegas algorithms by Wulff-Nilsen [37] with update time O(n0.5−ǫ) for some constant ǫ > 0 and, independently, by Nanongkai and Saranurak [24] with update time O(n0.494) (the latter works only for maintaining a spanning forest). Our result is obtained by identifying the common framework that both two previous algo- rithms rely on, and then improve and combine the ideas from both works. There are two main algorithmic components of the framework that are newly improved and critical for obtaining our result. First, we improve the update time from O(n0.5−ǫ) in [37] to O(no(1)) for decremen- tally removing all low-conductance cuts in an expander undergoing edge deletions. Second, by revisiting the "contraction technique" by Henzinger and King [15] and Holm et al. [19], we show a new approach for maintaining a minimum spanning forest in connected graphs with very few (at most (1 + o(1))n) edges. This significantly improves the previous approach in [37, 24] which is based on Frederickson's 2-dimensional topology tree [11] and illustrates a new application to this old technique. 7 1 0 2 g u A 5 1 ] S D . s c [ 2 v 2 6 9 3 0 . 8 0 7 1 : v i X r a i Contents 1 Introduction 2 Preliminaries 2.1 Some Known Results for Dynamic MSF . . . . . . . . . . . . . . . . . . . . . . . . . 3 The Extended Unit Flow Algorithm 4 Locally Balanced Sparse Cut 5 Expander Pruning 5.1 One-shot Expander Pruning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Dynamic Expander Pruning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.1 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.2 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Pruning on Arbitrary Graphs 1 4 5 6 9 11 12 14 14 15 17 7 Reduction from Graphs with Few Non-tree Edges Undergoing Batch Insertions 18 19 19 20 21 22 23 24 26 27 28 7.1 Reduction to Decremental Algorithms for Few Non-tree Edges . . . . . . . . . . . . . 7.1.1 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.2 Update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.3 Correctness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.1.4 Running Time 7.2 Contraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2.1 Property of Contracted Graphs/Forests . . . . . . . . . . . . . . . . . . . . . 7.2.2 The Proof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 Reduction to Decremental Algorithm for Few Edges 7.4 Reduction to Restricted Decremental Algorithm for Few Edges 8 MSF Decomposition 8.1 Expansion Decomposition that Respects a Given Partition . . . . . . . . . . . . . . . 8.2 MSF Decomposition Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.1 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Dynamic MSF Algorithm 9.1.1 Preprocessing and Definitions Related to Compressed Clusters 9.1.2 Update 9.1 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 Correctness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sketch Graph Preserves MSF . . . . . . . . . . . . . . . . . . . . . . . . . . . Sketch Graph is Extremely Sparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3.1 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3.2 Maintaining the Sketch Graph . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3.3 Maintaining MSF of the Sketch Graph . . . . . . . . . . . . . . . . . . . . . . 9.3.4 Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2.1 9.2.2 9.3 Running Time 10 Open Problems ii 29 31 33 33 36 37 37 42 42 43 45 46 46 47 48 50 51 A Reduction from One-shot Expander Pruning to LBS Cuts A.1 The Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.1.1 Upper Bounding vol(P ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.1.2 Upper bounding volH (BH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.1.3 Lower Bounding Conductance . . . . . . . . . . . . . . . . . . . . . . . . . . . A.1.4 Running time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B Omitted Proofs B.1 Proof of Lemma 3.4 (Unit Flow) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 55 56 58 59 60 61 61 iii 1 Introduction In the dynamic minimum spanning forest (MSF) problem, we want to maintain a minimum spanning forest F of an undirected edge-weighted graph G undergoing edge insertions and deletions. In particular, we want to construct an algorithm that supports the following operations. algorithm outputs a minimum spanning forest F of G. • Preprocess(G): Initialize the algorithm with an input graph G. After this operation, the • Insert(u, v, w): Insert edge (u, v) of weight w to G. After this operation, the algorithm • Delete(u, v): Delete edge (u, v) from G. After this operation, the algorithm outputs changes outputs changes to F (i.e. edges to be added to or removed from F ), if any. to F , if any. The goal is to minimize the update time, i.e., the time needed for outputting the changes to F given each edge update. We call an algorithm for this problem a dynamic MSF algorithm. Below, we denote respectively by n and m the upper bounds of the numbers of nodes and edges of G, and use O to hide polylog(n) factors. The dynamic MSF problem is one of the most fundamental dynamic graph problems. Its solu- tions have been used as a main subroutine for several static and dynamic graph algorithms, such as tree packing value and edge connectivity approximation [35], dynamic k-connectivity certificate [10], dynamic minimum cut [34] and dynamic cut sparsifier [2]. More importantly, this problem together with its weaker variants – dynamic connectivity and dynamic spanning forest (SF)1 – have played a central role in the development in the area of dynamic graph algorithms for more than three decades. The first dynamic MSF algorithm dates back to Frederickson's algorithm from 1985 [11], which provides an O(√m) update time. This bound, combined with the general sparsification technique of Eppstein et al. from 1992 [10], implies an O(√n) update time. Before explaining progresses after the above, it is important to note that the update time can be categorized into two types: An update time that holds for every single update is called worst- case update time. This is to contrast with an amortized update time which holds "on average" 2. Intuitively, worst-case update time bounds are generally more preferable since in some applications, such as real-time systems, hard guarantees are needed to process a request before the next request arrives. The O(√n) bound of Frederickson and Eppstein et al. [11, 10] holds in the worst case. By allowing the update time to be amortized, this bound was significantly improved: Henzinger and King [17] in 1995 showed Las Vegas randomized algorithms with O(log3 n) amortized update time for the dynamic SF. The same authors [16] in 1997 provided an O( 3√n log n) amortized update time for the more general case of dynamic MSF. Finally, Holm et al. [19] in 1998 presented deterministic dynamic SF and MSF algorithms with O(log2 n) and O(log4 n) amortized update time respectively. Thus by the new millennium we already knew that, with amortization, the dynamic MSF problem admits an algorithm with polylogarithmic update time. In the following decade, this result has been refined in many ways, including faster dynamic SF algorithms (see, e.g. [18, 32, 21] for randomized ones and [36] for a deterministic one), a faster dynamic MSF algorithm [20], and an Ω(log n) lower bound for both problems [26]. Given that these problems were fairly well-understood from the perspective of amortized update time, many researchers have turned their attention back to the worst-case update time in a quest 1The dynamic SF problem is the same as the dynamic MSF problem but we only need to maintain some spanning forest of the graph. In the dynamic connectivity problem, we need not to explicitly maintain a spanning forest. We only need to answer the query, given any nodes u and v, whether u and v are connected in the graph. 2In particular, for any t, an algorithm is said to have an amortized update time of t if, for any k, the total time it spends to process the first k updates (edge insertions/deletions) is at most kt. Thus, roughly speaking an algorithm with a small amortized update time is fast "on average" but may take a long time to respond to a single update. 1 to reduce gaps between amortized and worst-case update time (one sign of this trend is the 2007 work of Patraşcu and Thorup [27]). This quest was not limited to dynamic MSF and its variants (e.g. [29, 33, 1, 7, 6]), but overall the progress was still limited and it has become a big technical challenge whether one can close the gaps. In the context of dynamic MSF, the O(√n) worst-case update time of [11, 10] has remained the best for decades until the breakthrough in 2013 by Kapron, King and Mountjoy [22] who showed a Monte Carlo randomized algorithm with polylogarithmic worst-case bound for the dynamic connectivity problem (the bound was originally O(log5 n) in [22] and was later improved to O(log4 n) in [13]). Unfortunately, the algorithmic approach in [22, 13] seems insufficient for harder problems like dynamic SF and MSF3, and the O(√n) barrier remained unbroken for both problems. It was only very recently that the polynomial improvement to the O(√n) worst-case update time bound was presented [37, 24]4. Wulff-Nilsen [37] showed a Las Vegas algorithm with O(n0.5−ǫ) update time for some constant ǫ > 0 for the dynamic MSF problem. Independently, Nanongkai and Saranurak [24] presented two dynamic SF algorithms: one is Monte Carlo with O(n0.4+o(1)) update time and another is Las Vegas with O(n0.49306) update time. Nevertheless, the large gap between polylogarithmic amortized update time and the best worst-case update time remains. Our Result. We significantly reduce the gap by showing the dynamic MSF algorithm with sub- polynomial (O(no(1))) update time: Theorem 1.1. There is a Las Vegas randomized dynamic MSF algorithm on an n-node graph that can answer each update in O(no(1)) time both in expectation and with high probability. Needless to say, the above result completely subsumes the result in [37, 24]. The o(1) term above hides a O(log log log n/ log log n) factor.5 Recall that Las Vegas randomized algorithms always return correct answers and the time guarantee is randomized. Also recall that an event holds with high probability (w.h.p.) if it holds with probability at least 1− 1/nc, where c is an arbitrarily large constant. Key Technical Contribution and Organization. We prove Theorem 1.1 by identifying the common framework behind the results of Nanongkai-Saranurak [24] and Wullf-Nilsen [37] (thereafter NS and WN), and significantly improving some components within this framework. In particular, in retrospect it can be said that at a high level NS [24] and WN [37] share the following three components: 1. Expansion decomposition: This component decomposes the input graph into several expanders and the "remaining" part with few (o(n)) edges. 2. Expander pruning: This component helps maintaining an MSF/SF in expanders from the first component by decrementally removing all low-conductance cuts in an expander undergoing edge deletions. 3Note that the algorithms in [22, 13] actually maintain a spanning forest; however, they cannot output such forest. In particular, [22, 13] assume the so-called oblivious adversary. Thus, [22, 13] do not solve dynamic SF as we define here, as we require algorithms to report how the spanning forest changes. See further discussions on the oblivious adversary in [24]. 4Prior to this, Kejlberg-Rasmussen et al. [23] improved the bound slightly to O(pn(log log n)2/ log n) for dynamic SF using word-parallelism. Their algorithm is deterministic. 5Note that by starting from an empty graph and inserting one edge at a time, the preprocessing time of our algorithm is clearly O(m1+o(1)), where m is the number of edges in the initial graph. However, note further that the o(1) term in our preprocessing time can be slightly reduced to O(plog log m/ log m) if we analyze the preprocessing time explicitly instead. 2 3. Dynamic MSF/SF on ultra-sparse graphs: This components maintains MSF/SF in the "re- maining" part obtained from the first component by exploiting the fact that this part has few edges6. The key difference is that while NS [24] heavily relied on developing fast algorithms for these components using recent flow techniques (from, e.g., [28, 25]), WN [37] focused on developing a sophisticated way to integrate all components together and used slower (diffusion-based) algorithms for the three components. In this paper we significantly improve algorithms for the second and third components from those in NS [24], and show how to adjust the integration method of WN [37] to exploit these improvements; in particular, the method has to be carefully applied recursively. Below we discuss how we do this in more detail. (i) Improved expander pruning (Details in Sections 3 to 6). We significantly improve the running time of the one-shot expander pruning algorithm by NS [24]7 and the dynamic expander pruning by WN [37]. For the one-shot case, given a single batch of d edge deletions to an expander, the one-shot expander pruning algorithm by NS [24] takes O(d1.5+o(1)) time for removing all low-conductance cuts. We improve the running time to O(d1+o(1)). To do this, in Section 3 we first extend a new local flow-based algorithm 8 for finding a low-conductance cut by Henzinger, Rao and Wang [14], and then use this extension in Section 4 to get another algorithm for finding a locally balanced sparse (LBS) cut. Then in Section 5.1 we apply the reduction from LBS cut algorithms by NS [24] and obtain an improved one-shot expander pruning algorithm. For the dynamic case, given a sequence of edge deletions to an expander, the dynamic expander pruning algorithm by WN [37] dynamically removes all low-conductance cuts and takes O(n0.5−ǫ) time for each update. We improve the update time to O(no(1)). Our algorithm is also arguably simpler and differ significantly because we do not need random sampling as in [37]. To obtain the dynamic expander pruning algorithm, we use many instances of the static ones, where each instance is responsible on finding low-conductance cuts of different sizes. Each instance is called periodically with different frequencies (instances for finding larger cuts are called less frequently). See Section 5.2 for details. (ii) Improved dynamic MSF algorithm on "ultra-sparse" graphs (Details in Section 7). We show a new way to maintain dynamic MSF in a graph with few (o(n)) "non-tree" edges that can also handle a batch of edge insertions. Both NS and WN [24, 37] used a variant of Frederickson's 2-dimensional topology tree [11] to do this task9. In this paper, we change the approach to reduce this problem on graphs with few non-tree edges to the same problem on graphs with few edges and fewer nodes; this allows us to apply recursions later in Section 9. We do this by applying the classic "contraction technique" of Henzinger and King [15] and Holm et al. [19] in a new way: This technique was used extensively previously (e.g. [16, 15, 19, 20, 37]) to reduce fully-dynamic algorithms to decremental algorithms (that can only handle deletions). Here, we use this technique so that we can recurse. In Sections 8 and 9, we take a close look into the integration method in WN [37] which is used to compose the three components. We show that it is possible to replace all the three components with the tools based on flow algorithms from either this paper or from NS [24] instead. 6For the reader who are familiar with the results in [24] and [37]. The first component are shown in Theorem 4 in [37] and Theorem 5.1 in [24]. The second are shown in Theorem 5 in [37] and Theorem 6.1 in [24]. The third are shown in Theorem 3 from [37] and Theorem 4.2 in [24]. 7In [24], the authors actually show the local expansion decomposition algorithm which is the same as one-shot expander pruning but it does not only prune the graph but also decompose the graph into components. In retrospect, we can see that it is enough to instead use the one-shot expander pruning algorithm in [24]. 8By local algorithms, we means algorithms that can output its answer without reading the whole input graph. 9Unlike [37], the algorithm in [24] cannot handle inserting a batch of many non-tree edges. 3 In particular, in Section 8 we consider a subroutine implicit in WN [37], which is built on top of the expansion decomposition algorithm (the first component above). To make the presentation more modular, we explicitly state this subroutine and its needed properties and name it MSF decomposition in Section 8. This subroutine can be used as it is constructed in [37], but we further show that it can be slightly improved if we replace the diffusion-based expansion decomposition algorithm in [37] with the flow-based expansion decomposition by NS [24] in the construction. This leads to a slight improvement in the o(1) term in our claimed O(no(1)) update time. Then, in Section 9, we combine (using a method in WN [37]) our improved MSF decomposition algorithm (from Section 8) with our new dynamic expander pruning algorithm and our new dynamic MSF algorithm on ultra-sparse graphs (for the second and third components above). As our new algorithm on ultra-sparse graphs is actually a reduction to the dynamic MSF problem on a smaller graph, we recursively apply our new dynamic MSF algorithm on that graph. By a careful time analysis of our recursive algorithm, we eventually obtain the O(no(1)) update time. 2 Preliminaries When the problem size is n, we denote O(f (n)) = O(f (n)polylog(n)), for any function f . We denote by ∪ and S the disjoint union operations. We denote the set minus operation by both \ and −. For any set S and an element e, we write S − e = S − {e} = S \ {e}. Let G = (V, E, w) be any weighted graph where each edge e ∈ E has weight w(e). We usually denote n = V and m = E. We also just write G = (V, E) when the weight is clear from the context. We assume that the weights are distinct. For any set V ′ ⊆ V of nodes, G[V ′] denotes the subgraph of G induced by V ′. We denote V (G) the set of nodes in G and E(G) the set of edges in G. In this case, V (G) = V and E(G) = E. Let MSF(G) denote the minimum spanning tree of G. For any set E′ ⊆ E, let end(E′) be the set of nodes which are endpoints of edges in E′. Sometimes, we abuse notation and treat the set of edges in E′ as a graph G′ = (end(E′), E′) and vice versa. For example, we have MSF(E′) = MSF(G′) and E − MSF(G′) = E − E(MSF(G′)). The set of non-tree edges of G are the edges in E − MSF(G). However, when it is clear that we are talking about a forest F in G, non-tree edges are edges in E − F . A cut S ⊆ V is a set of nodes. A volume of S is vol(S) =Pv∈S deg(v). The cut size of S is denoted by δ(S) which is the number of edges crossing the cut S. The conductance of a cut S is φ(S) = min{vol(S),vol(V −S) . The conductance of a graph G = (V, E) is φ(G) = min∅6=S⊂V φ(S). δ(S) Remark 2.1 (Local-style input). Whenever a graph G is given to any algorithm A in this paper, we assume that a pointer to the adjacency list representing G is given to A. This is necessary for some of our algorithms which are local in the sense that they do not even read the whole input graph. Recall that in an adjacency list, for each node v we have a list ℓv of edges incident to v , and we can access the head ℓv in constant time. (See details in, e.g., [8, Section 22.1]) Additionally, we assume that we have a list of nodes whose degrees are at least 1 (so that we do not need to probe lists of single nodes). We extensively use the following facts about MSF. Fact 2.2 ([10]). For any edge sets E1 and E2, MSF(E1 ∪ E2) ⊆ MSF(E1) ∪ MSF(E2). Let G′ = (V ′, E′) be a graph obtained from G by contracting some set of nodes into a single node. We always keeps parallel edges in G′ but sometimes we do not keep all the self loops. We will specify which self loops are preserved in G′ when we use contraction in our algorithms. We usually assume that each edge in G′ "remember" its original endpoints in G. That is, there are two-way 4 pointers from each edge in E′ to its corresponding edge in E. So, we can treat E′ as a subset of E. For example, for a set D ⊆ E of edges in G, we can write E′ − D and this means the set of edges in G′ excluding the ones which are originally edges in D. With this notation, we have the following fact about MSF: Fact 2.3. For any graph G and (multi-)graph G′ obtained from G by contracting two nodes of G, MSF(G′) ⊆ MSF(G). Definition 2.4 (Dynamic MSF). A (fully) dynamic MSF algorithm A is given an initial graph G to be preprocessed, and then A must return an initial minimum spanning forest. Then there is an online sequence of edge updates for G, both insertions and deletions. After each update, A must return the list of edges to be added or removed from the previous spanning tree to obtain the new one. We say A is an incremental/decremental MSF algorithm if the updates only contain insertions/deletions respectively. The time an algorithm uses for preprocessing the initial graph and for updating a new MSF is called preprocessing time and update time respectively. In this paper, we consider the problem where the update sequence is generated by an adversary10. We say that an algorithm has update time t with probability p, if, for each update, an algorithm need at most t time to update the MSF with probability at least p. Let G be a graph undergoing a sequence of edge updates. If we say that G has n nodes, then G has n nodes at any time. However, we say that G has at most m edges and k non-tree edges, if at any time, G is updated in such a way that G always has at most m edges and k non-tree edges. We also say that G is an m-edge k-non-tree-edge graph. Let F = MSF(G). Suppose that there is an update that deletes e ∈ F . We say that f is a replacement/reconnecting edge if F ∪ f − e = MSF(G − e). 2.1 Some Known Results for Dynamic MSF We use the following basic ability of the top tree data structure (see e.g. [30, 3]). Lemma 2.5. There is an algorithm A that runs on an n-node edge-weighted forest F undergoing edge updates. A has preprocessing time O(n log n) and update time O(log n). At any time, given two nodes u and v, then in time O(log n) A can 1) return the heaviest edge in the path from u to v in F , or 2) report that u and v are not connected in F . A classic dynamic MSF algorithm by Frederickson [11] has O(√m) worst-case update time. Using the same approach, it is easy to see the following algorithm which is useful in a multi-graph where m is much larger than n2: Lemma 2.6. There is a deterministic fully dynamic MSF algorithm for an n-node graph with m initial edges and has O(m) preprocessing time and O(n) worst-case update time. Next, Wulff-Nilsen [37] implicitly showed a decremental MSF algorithms for some specific setting. In Section 9, we will use his algorithms in the same way he used. The precise statement is as follows: 10There are actually two kinds of adversaries: oblivious ones and adaptive ones. In [24], they formalize these defi- nitions precisely and discuss them in details. In this paper, however, we maintain MSF which is uniquely determined by the underlying graph at any time (assuming that the edge weights are distinct). So, there is no difference in power of the two kinds of adversaries and we will not distinguish them. 5 Lemma 2.7. Let G = (V, E) be any m-edge graph undergoing edge deletions, and let S ⊆ V be a set of nodes such that, for any time step, every non-tree edge in E(G) − MSF(G) has exactly one endpoint in S. Moreover, every node u ∈ V \ S has constant degree. Then, there is a decremental MSF algorithm A that can preprocess G and S in time O(m) and handle each edge deletion in O(S) time.11 3 The Extended Unit Flow Algorithm In this section, we show an algorithm called Extended Unit Flow in Theorem 3.3. It is the main tool for developing an algorithm in Section 4 called locally balanced sparse cut, which will be used in our dynamic algorithm. The theorem is based on ideas of flow algorithms by Henzinger, Rao and Wang [14]. Flow-related notions. We derive many notations from [14], but note that they are not exactly the same. (In particular, we do not consider edge capacities, but instead use the notion of congestion.) A flow is defined on an instance Π = (G, ∆, T ) consisting of (i) an unweighted undirected graph G = (V, E), (ii) a source function ∆ : V → Z≥0, and (iii) a sink function T : V → Z≥0. A preflow is a function f : V × V → Z such that f (u, v) = −f (v, u) for any (u, v) ∈ V × V and f (u, v) = 0 for every (u, v) /∈ E. Define f (v) = ∆(v) +Pu∈V f (u, v). A preflow f is said to be source-feasible (respectively sink-feasible) if, for every node v,Pu f (v, u) ≤ ∆(v) (respectively f (v) ≤ T (v).). If f is both source- and sink-feasible, then we call it a flow. We define cong(f ) = max(u,v)∈V ×V f (u, v) as the congestion of f . We emphasize that the input and output functions considered here (i.e. ∆, T, f , and cong) map to integers. One way to view a flow is to imagine that each node v initially has ∆(v) units of supply and an ability to absorb T (v) units of supply. A preflow is a way to "route" the supply from one node to another. Intuitively, in a valid routing the total supply out of each node v should be at most its initial supply of ∆(v) (source-feasibility). A flow describes a way to route such that all supply can be absorbed (sink feasibility); i.e. in the end, each node v has at most T (v) units of supply. The congestion measures how much supply we need to route through each edge. With the view above, we call f (v) (defined earlier) the amount of supply ending at v after f . For every node v, we denote exf (v) = max{f (v) − T (v), 0} as the excess supply at v after f and abf (v) = min{T (v), f (v)} as the absorbed supply at v after f . Observe that exf (v) + abf (v) = f (v), for any v, and f is a feasible flow iff exf (v) = 0 for all nodes v ∈ V . When f is clear from the context, we simply use ex and ab to denote exf and abf . For convenience, we denote ∆(·) =Pv ∆(v) as the total source supply, T (·) =Pv T (v) as the total sink capacity, exf (·) =Pv exf (v) as the total excess, and abf (·) =Pv abf (v) as the total supply absorbed. Remark 3.1 (Input and output formats). The input graph G is given to our algorithms as described in Section 2; in particular, our algorithms do not need to read G entirely. Functions ∆ and T are input in the form of sets {(v, ∆(v)) ∆(v) > 0} and {(v, T (v)) T (v) < deg(v)}, respectively. Our algorithms will read both sets entirely. Our algorithms output a preflow f as a set {((u, v), f (u, v)) f (u, v) 6= 0}. When f is out- putted, we can assume that we also obtained functions exf and abf which are represented as sets 11For those readers who are familiar with [37], Wulff-Nilsen showed in Section 3.2.2 of [37] how to maintain the MSF in the graph G2(C) which has the same setting as in Lemma 2.7. G2(C) is defined in [37], which is the same as C 2 in Section 9. In [37], the set of large-cluster vertices (or super nodes) in G2(C) corresponds to the set S in Lemma 2.7 and every non-tree edge in G2(C) has exactly one endpoint as a large cluster node. There, the number of large cluster vertices is S = O(nǫ) and the algorithm has update time S = O(nǫ) for some constant ǫ > 0. 6 {(v, exf (v)) exf (v) > 0} and {(v, abf (v)) abf (v) > 0}, respectively. This is because the time for computing these sets is at most linear in the time for reading ∆ and T plus the time for outputting f . Remark 3.2 (T (·)). We need another notation to state our result. Throughout, we only consider sink functions T such that T (v) ≤ deg(v) for all nodes v ∈ V . When we compute a preflow, we usually add to each node v an artificial supply T (v) = deg(v) − T (v) to both ∆(v) and T (v) so that T (v) = deg(v). Observe that adding the artificial apply does not change the problem (i.e. a flow and preflow is feasible in the new instance if and only if it is in the old one). We define T (·) =Pv T (v) = 2m − T (·) as the total artificial supply. This term will appear in the running time of our algorihtm. The main theorem. Now, we are ready to state the main result of this section. Theorem 3.3 (Extended Unit Flow Algorithm). There exists an algorithm called Extended Unit Flow which takes the followings as input: • a graph G = (V, E) with m edges (possibly with parallel edges but without self loops), • positive integers h ≥ 1 and F ≥ 1, • a source function ∆ such that ∆(v) ≤ F deg(v) for all v ∈ V , and • a sink function T such that ∆(·) ≤ T (·) (also recall that T (v) ≤ deg(v), ∀v ∈ V , as in Remark 3.2). In time O(hF (∆(·) + T (·)) log m) the algorithm returns (i) a source-feasible preflow f with congestion cong(f ) ≤ 2hF and (ii) exf (·). Moreover, either • (Case 1) exf (·) = 0, i.e. f is a flow, or • (Case 2) the algorithm returns a set S ⊆ V such that φG(S) < 1 nodes in S are outputted.) h and vol(S) ≥ exf (·) F . (All Interpretation of Theorem 3.3. One way to interpret Theorem 3.3 is the following. (Note: readers who already understand Theorem 3.3 can skip this paragraph.) Besides graph G and source and sink functions, the algorithm in Theorem 3.3 takes integers h and F as inputs. These integers indicate the input that we consider "good": (i) the source function ∆ is not too big at each node, i.e. ∀v ∈ V, ∆(v) ≤ F deg(v), and (ii) the graph G has high conductance; i.e. φ(G) > 1/h. Note that for the good input it is possible to find a flow of congestion O(hF ): each set S ⊆ V there can bePv∈S ∆(v) ≤ F · vol(S) initial supply (by (i)), while there are δ(S) > vol(S)/h edges to route this supply out of S (by (ii)); so, on average there is Pv∈S ∆(v) ≤ hF supply routed through each edge. This is essentially what our algorithm achieves in Case 1. If it does not manage to compute a flow, it computes some source-feasible preflow and outputs a "certificate" that the input is bad, i.e. a low-conductance cut S as in Case 2. Moreover, the larger the excess of the preflow, the higher the volume of S; i.e. vol(S) is in the order of exf (·)/F . In fact, this volume-excess relationship is the key property that we will need later. One way to make sense of this relationship is to notice that if vol(S) ≥ exf (·)/F , then we can put as much as F · vol(S) ≥ exf (·) initial supply in S. With conductance of S low enough (φG(S) ≤ 1 2h suffices), we can force most of the initial supply to remain in S and become an excess. Note that this explanation is rather inaccurate, but might be useful to intuitively understand the interplay between vol(S), exf (·) and F . Finally, we note again that our algorithm is local in the sense that its running time is lower than the size of G. For this algorithm to be useful later, it is important that the running time is δ(S) 7 almost-linear in (∆(·) + T (·)). Other than this, it can have any polynomial dependency on h, F and the logarithmic terms. The rest of this section is devoted to proving Theorem 3.3. The main idea is to slightly extend the algorithm called Unit Flow by Henzinger, Rao and Wang [14]. The Unit Flow Algorithm. The following lemma, which is obtained by adjusting and sim- plifying parameters from Theorem 3.1 and Lemma 3.1 in [14]. See Appendix B.1 for the details. Lemma 3.4. There exists an algorithm called Unit Flow which takes the same input as in Theo- rem 3.3 (i.e. G, h, F , ∆, and T ) except an additional condition that T (v) = deg(v) for all v ∈ V . In time O(F h∆(·) log m), the algorithm returns a source-feasible preflow f with congestion at most 2hF . Moreover, one of the followings holds. 1. exf (·) = 0 i.e. f is a flow. 2. A set S is returned, where φG(S) < 1 ∀v /∈ S: exf (v) = 0. h . Moreover, ∀v ∈ S: exf (v) ≤ (F − 1) deg(v) and We also note the following fact which holds because the Unit Flow algorithm is based on the push-relabel framework, where each node v sends supply to its neighbors only when ex(v) > 0 and pushes at most ex(v) units of supply. Fact 3.5. The returned preflow f in Lemma 3.4 is such that, for any v ∈ V , Pu∈V f (v, u) ≤ 0 if f (v) < T (v). The Extended Unit Flow Algorithm. Next, we slightly extend the Unit Flow algorithm so that it can handle sink functions T where for some node v, T (v) < deg(v). Proof of Theorem 3.3. Given G, h, F , ∆, and T as inputs, the Extended Unit Flow algorithm proceeds as follows. Let ∆′ and T ′ be source and sink functions where, for all nodes v ∈ V, ∆′(v) = ∆(v) + T (v) and T ′(v) = T (v) + T (v) = deg(v), respectively. Note that ∆′(·) = ∆(·) + T (·) ≤ T (·) + T (·) = 2m, and ∆′(v) ≤ (F + 1) deg(v) for all v ∈ V . According to Remark 3.1, we can construct the compact representation of ∆′ and T ′ in time O(∆(·) + T (·)). Let A denote the Unit Flow algorithm from Lemma 3.4. We run A with input (G, h, F +1, ∆′, T ′). A will run in time O(h(F +1)∆′(·) log m) = O(F h(∆(·)+T (·)) log m). Then, A returns a source- feasible preflow f with congestion 2hF for an instance (G, ∆′, T ′) and the excess function ex′f (see Remark 3.1). If A also returns a set S, then the Extended Unit Flow algorithm also returns S; otherwise, we claim that f is a flow (not just a preflow) for the instance (G, ∆, T ), as follows. Recall that for any v ∈ V , the followings hold. f (u, v) f′(v) = ∆′(v) +Xu f (v) = ∆(v) +Xu ex′f (v) = max{f′(v) − T ′(v), 0} exf (v) = max{f (v) − T (v), 0} f (u, v) We argue that f is a source-feasible preflow for (G, ∆, T ) with congestion 2hF . As guaranteed by A, f has congestion 2hF . The following claim shows that f is source-feasible, i.e. for all v, Pu f (v, u) ≤ ∆(v). 8 Claim 3.6. Pu f (v, u) ≤ max{0, ∆′(v) − T ′(v)} ≤ ∆(v) for any v ∈ V . Proof. There are two cases. If f′(v) < T ′(v), thenPu f (v, u) ≤ 0 by Fact 3.5. If f′(v) ≥ T ′(v), then Pu f (v, u) = ∆′(v)−f′(v) ≤ ∆′(v)−T ′(v). SoPu f (v, u) ≤ max{0, ∆′(v)−T ′(v)}. Since ∆(v) ≥ 0, we only need to show ∆′(v) − T ′(v) ≤ ∆(v). Indeed, ∆′(v) − T ′(v) = ∆(v) − T (v) ≤ ∆(v). Therefore, we conclude that f is a source-feasible preflow for (G, ∆, T ) with congestion 2hF . Next, we show that the excess function exf w.r.t. ∆ and T is the same function as the excess function ex′f w.r.t. ∆′ and T ′, which is returned by A. Claim 3.7. For any v ∈ V , ex′f (v) = exf (v). Proof. It suffices to show f′(v) − T ′(v) = f (v) − T (v) for all v ∈ V . f′(v) − f (v) = ∆′(v) − ∆(v) = T (v) = T (v) − T ′(v). Indeed, for every v ∈ V , Therefore, by Claim 3.7, in the first case where A guarantees ex′f (·) = 0, we have exf (·) = ex′f (·) = 0, i.e. f is a flow for (G, ∆, T ). In the second case where A returns a cut S where φG(S) < 1 h , we have that ∀v ∈ S, exf (v) = ex′f (v) ≤ ((F + 1) − 1) deg(v) = F deg(v) and ∀v /∈ S, exf (v) = ex′f (v) = 0. By summing over all nodes v, we have exf (·) = Pv∈S exf (v) + Pv /∈S exf (s) ≤ FPv∈S deg(v) = F vol(S). That is, vol(S) ≥ exf (·)/F . 4 Locally Balanced Sparse Cut In this section, we show an algorithm for finding a locally balanced sparse cut, which is a crucial tool in Section 5. The main theorem is Theorem 4.4. First, we need this definition: Definition 4.1 (Overlapping). For any graph G = (V, E), set A ⊂ V , and real 0 ≤ σ ≤ 1, we say that a set S ⊂ V is (A, σ)-overlapping in G if vol(S ∩ A)/vol(S) ≥ σ. δ(S) Let G = (V, E) be a graph. Recall that a cut S is α-sparse if it has conductance φ(S) = < α. Consider any set A ⊂ V , an overlapping parameter 0 ≤ σ ≤ 1 and a min{vol(S),vol(V −S)} conductance parameter 0 ≤ α ≤ 1. Let S∗ be the set of largest volume that is α-sparse (A, σ)- overlapping and such that vol(S∗) ≤ vol(V − S∗). We define OPT(G, α, A, σ) = vol(S∗). If S∗ does not exist, then we define OPT(G, α, A, σ) = 0. From this definition, observe that OPT(G, α, A, σ) ≤ OPT(G, α′, A, σ) for any α ≤ α′. Now, we define the locally balanced sparse cut problem formally: Definition 4.2 (Locally Balanced Sparse (LBS) Cut). Consider any graph G = (V, E), a set A ⊂ V , and parameters csize ≥ 1, ccon ≥ 1, σ and α. We say that a cut S where vol(S) ≤ vol(V − S) is a (csize, ccon)-approximate locally balanced sparse cut with respect to (G, α, A, σ) (in short, (csize, ccon, G, α, A, σ)-LBS cut) if φ(S) < α and csize · vol(S) ≥ OPT(G, α/ccon, A, σ). (1) In words, the (csize, ccon, G, α, A, σ)-LBS cut can be thought of as a relaxed version of OPT(G, α, A, σ): On the one hand, we define OPT(G, α, A, σ) to be a highest-volume cut with low enough conduc- tance and high enough overlap with A (determined by α and σ respectively). On the other hand, a (csize, ccon, G, α, A, σ)-LBS cut does not need to overlap with A at all; moreover, its volume is only compared to OPT(G, α/ccon, A, σ), which is at most OPT(G, α, A, σ), and we also allow the gap of csize in such comparison. We note that the existence of a (csize, ccon, G, α, A, σ)-LBS cut S implies that any (A, σ)-overlapping cut of volume more than csize · vol(S) must have conductance at least α/ccon (because any (A, σ)-overlapping cut with conductance less than α/ccon has volume at most csize · vol(S)). 9 Definition 4.3 (LBS Cut Algorithm). For any parameters csize and ccon, a (csize, ccon)-approximate algorithm for the LBS cut problem (in short, (csize, ccon)-approximate LBS cut algorithm) takes as input a graph G = (V, E), a set A ⊂ V , an overlapping parameter 0 ≤ σ ≤ 1, and an conductance parameter 0 ≤ α ≤ 1. Then, the algorithm either • (Case 1) finds a (csize, ccon, G, α, A, σ)-LBS cut S, or • (Case 2) reports that there is no (α/ccon)-sparse (A, σ)-overlapping cut, i.e. OPT(G, α/ccon, A, σ) = 0. From Definition 4.3, if there exists an (α/ccon)-sparse (A, σ)-overlapping cut, then a (csize, ccon)- approximate LBS cut algorithm A can only do Case 1, or if there is no α-sparse cut, then A must do Case 2. However, if there is no (α/ccon)-sparse (A, σ)-overlapping cut but there is an α-sparse cut, then A can either do Case 2, or Case 1 (which is to find any α-sparse cut in this case). The main result of this section is the following: Theorem 4.4. Consider the special case of the LBS cut problem where the input (G, A, σ, α) vol(V −A) , 1]. In this case, there is a is always such that (i) 2vol(A) ≤ vol(V − A) and (ii) σ ∈ [ 2vol(A) (O(1/σ2), O(1/σ2))-approximate LBS cut algorithm that runs in O( vol(A) ασ2 ) time. We note that in our later application it is enough to have an algorithm with poly( log n ασ )). imation guarantees and running time almost linear in vol(A) (possibly with poly( log n ασ ) approx- Before proving the above theorem, let us compare the above theorem to related results in the literature. Previously, Orecchia and Zhu [25] show two algorithms for a problem called local cut improvement. This problem is basically the same as the LBS cut problem except that there is no guarantee about the volume of the outputted cut. Nanongkai and Saranurak [24] show that one of the two algorithms by [25] implies a ( 3 σ )-approximate LBS cut algorithm with running time O(( vol(A) )1.5). While the approximation guarantees are better than the one in Theorem 4.4, this algorithm is too slow for us. By the same techniques, one can also show that the other algorithm by [25] implies a (n, 3 ασ ) similar to Theorem 4.4, but the approximation guarantee on csize is too high for us. Thus, the main challenge here is to get a good guarantee on both csize and running time. Fortunately, given the Extended Unit Flow algorithm from Section 3, it is not hard to obtain Theorem 4.4. σ )-approximate LBS cut algorithm with running time O( vol(A) σ , 3 σ Proof of Theorem 4.4. The rest of this section is devoted to proving Theorem 4.4. Let (G, A, σ, α) be an input as in Theorem 4.4. Define F = ⌈1/σ⌉ and h = ⌈1/α⌉. Define the source and sink functions as 0 ∆(v) =(⌈1/σ⌉ deg(v) ∀v ∈ A T (v) =(0 ∀v ∈ A deg(v) ∀v /∈ A ∀v /∈ A Now we run the Extended Unit Flow algorithm from Theorem 3.3, with input (G, h, F, ∆, T ). Note that this input satisfies the conditions in Theorem 3.3: • h ≥ 1 and F ≥ 1 because σ ≤ 1 and α ≤ 1, • for all v ∈ V, ∆(v) ≤ ⌈1/σ⌉ deg(v) = F deg(v) and T (v) ≤ deg(v), and 10 2vol(A) m vol(A) ≤ vol(V − A) =Pv /∈A deg(v) = T (·) . • ∆(·) = ⌈1/σ⌉ vol(A) ≤l vol(V −A) The Extended Unit Flow algorithm A finishes in time O(hF (∆(·) + T (·)) log m) = O( vol(A) ασ2 ), where the equality is because of the inequalities above and the fact that ¯T (·) =Pv∈A deg(v) = vol(A). When A finishes, we obtain a source-feasible preflow f with congestion cong(f ) ≤ 2hF = ασ ), total excess exf (·), and possibly a cut S (when exf (·) > 0). Let csize = 2F O( 1 σ = O(1/σ2) and ccon = 2α·cong(f ) = O(1/σ2). We output as follows. σ • If exf (·) = 0, we report that there is no (α/ccon)-sparse (A, σ)-overlapping cut (i.e. OPT(G, α/ccon, A, σ) = 0) as in Case 2 of Definition 4.3. • Otherwise, we output S as an (csize, ccon, G, α, A, σ)-approximate LBS cut as in Case 1 of Definition 4.3. To prove that the above algorithm is correct, observe that it suffices to prove that OPT(G, 2exf (·)/σ. Indeed, if exf (·) = 0, then this implies OPT(G, α/ccon, A, σ) = 0 by the choice of ccon. Otherwise, we have exf (·) > 0. Recall from Theorem 3.3 that the outputted set S is such that φG(S) < 1 h ≤ α and vol(S) ≥ exf (·)/F . This means that OPT(G, α/ccon, A, σ) ≤ 2exf (·)/σ ≤ csize · vol(S). Therefore, we conclude with the following claim: Claim 4.5. For any (A, σ)-overlapping cut S′ where vol(S′) > 2exf (·)/σ, we have φ(S′) ≥ That is, OPT(G, Proof. Let ∆(S′) =Pv∈S ′ ∆(v) be the total source supply from nodes in S′, exf (S′) =Pv∈S ′ exf (v) be the total excess supply in nodes in S′, and abf (S′) =Pv∈S ′ abf (v) be the total supply absorbed by nodes in S′. Observe that ∆(S′) = ⌈1/σ⌉ vol(A ∩ S′) and abf (S′) ≤ vol(S′ − A). So we have 2cong(f ) , A, σ) ≤ 2exf (·)/σ. 2cong(f ) . σ σ σ 2cong(f ) , A, σ) ≤ cong(f ) · δ(S′) ≥ ∆(S′) − exf (S′) − abf (S′) 1 σ vol(A ∩ S′) − exf (·) − vol(S′ − A). This implies ≥ cong(f ) · φ(S′) ≥ = = 1 σ vol(A ∩ S′) − exf (·) − vol(S′ − A) vol(S′) 1 σ vol(A ∩ S′) − exf (·) − (vol(S′) − vol(A ∩ S′)) vol(S′) ( 1 σ + 1)vol(A ∩ S′) − exf (·) − vol(S′) ≥ ( 1 σ + 1)σ − vol(S′) σ 2 σ 2 − 1 = . 5 Expander Pruning The main result of this section is the dynamic expander pruning algorithm. This algorithm was a key tool introduced by Wulff-Nilsen [37, Theorem 5] for obtaining his dynamic MSF algorithm. We significantly improve his dynamic expander pruning algorithm which is randomized and has n0.5−ǫ0 11 update time for some constant ǫ0 > 0. Our algorithm is deterministic and has no(1) update time. Although the algorithm is deterministic, our final dynamic MSF algorithm is randomized because there are other components that need randomization. First we state the precise statement (explanations follow below). Theorem 5.1 (Dynamic Expander Pruning). Consider any ǫ(n) = o(1), and let α0(n) = 1/nǫ(n). There is a dynamic algorithm A that can maintain a set of nodes P for a graph G undergoing T = O(mα2 0(n)) edge deletions as follows. Let Gτ and Pτ be the graph G and set P after the τ th deletion, respectively. with maximum degree 3. • Initially, in O(1) time A sets P0 = ∅ and takes as input an n-node m-edge graph G0 = (V, E) ǫ(n) / log 1 • After the τ th deletion, A takes nO(log log 1 ǫ(n) ) = no(1) time to report nodes to be added to Pτ−1 to form Pτ where, if φ(G0) ≥ α0(n), then ∃Wτ ⊆ Pτ s.t. Gτ [V − Wτ ] is connected. (2) The goal of our algorithm is to gradually mark nodes in a graph G = (V, E) so that at all time – as edges in G are deleted – all nodes that are not yet marked are in the same connected component in G. In other words, the algorithm maintains a set P of (marked) nodes, called pruning set, such that there exists W ⊆ P where G[V − W ] is connected (thus Equation (2)). In our application in Section 9, we will delete edges incident to P from the graph, hence the name pruning set. Recall that the algorithm takes an input graph in the local manner, as noted in Remark 2.1, thus taking no(1) time. Observe that if we can set P = V from the beginning, the problem becomes trivial. The challenge here is that we must set P = ∅ in the initial step, and thus must grow P smartly and quickly (in no(1) time) after each deletion so that Equation (2) remains satisfied. Observe further that this task is not possible to achieve in general: if the first deletion cuts G into two large connected components, then P has to grow tremendously to contain one of these components, which is impossible to do in no(1) time. Because of this, our algorithm is guaranteed to work only if the initial graph has high enough expansion; in particular, an initial expansion of α0(n) as in Theorem 5.1 suffices for us. Organization. The rest of this section is for proving Theorem 5.1. The key tool is an algorithm called the one-shot expander pruning, which was also the key tool in Nanongkai and Saranurak [24] for obtaining their Las Vegas dynamic SF algorithm. We show an improved version of this algorithm in Section 5.1 using the faster LBS cut algorithm we developed in Section 4. In Section 5.2, we show how to use several instances of the one-shot expander pruning algorithm to obtain the dynamic one and prove Theorem 5.1. 5.1 One-shot Expander Pruning In the following, we show the one-shot expander pruning algorithm which is significantly improved from [24]. In words, the one-shot expander pruning algorithm is different from the dynamic one from Theorem 5.1 in two aspects: 1) it only handles a single batch of edge deletions, instead of a sequence of edge deletions, and so only outputs a pruning set P once, and 2) the pruning set P has a stronger guarantee than the pruning set for dynamic one as follows: P does not only contains all nodes in the cuts that are completely separated from the graphs (i.e. the separated connected components) but P contains all nodes in the cuts that have low conductance. Moreover, P contains exactly those nodes and hence the complement G[V − P ] has high conductance. For the dynamic expander pruning algorithm, we only have that there is some W ⊆ P where G[V − W ] is connected. 12 The theorem below shows the precise statement. Below, we think of Gb = (V, E ∪ D) as the graph before the deletions, and G = Gb − D as the graph after deleting D. In [24], Nanongkai and Saranurak show this algorithm where the dependency on D is ∼ D1.5+δ, while in our algorithm the dependency of D is ∼ D1+δ. Theorem 5.2 (One-shot Expander Pruning). There is an algorithm A that can do the following: • A is given G,D, αb, δ as inputs: G = (V, E) is an n-node m-edge graph with maximum degree ∆, αb is a conductance parameter, δ ∈ (0, 1) is a parameter, and D is a set of edges where D ∩ E = ∅ where D = O(α2 • Then, in time t = O( ∆D1+δ Moreover, if φ(Gb) ≥ αb, then we have b m/∆). Let Gb = (V, E ∪ D). ), A either reports φ(Gb) < αb, or outputs a pruning set P ⊂ V . δα6+δ b – volG(P ) ≤ 2D/αb, and – a pruned graph H = G[V − P ] has high conductance: φ(H) ≥ α = Ω(αb 2/δ). We call t the time limit and α the conductance guarantee of A. If we do not care about the just time limit, then there is the following algorithm gives a very good conductance guarantee: find the cut C∗ of conductance at most αb/10 that have maximum volume and output P = C∗. If vol(P ) > 2D/αb, then report φ(Gb) < αb. Otherwise, we must have φ(G[V − P ]) = Ω(αb). This can be shown using the result by Spielman and Teng [31, Lemma 7.2]. However, computing the optimum cut C∗ is NP-hard. In [24], they implicitly showed that using only the LBS cut algorithm, which is basically an algorithm for finding a cut similar to C∗ but the guarantee is only approximately and locally, one can quickly obtain the one-shot expander pruning algorithm whose conductance guarantee is not too bad. Below, we explicitly state the reduction in [24]. See Appendix A for the proof12. Lemma 5.3 ([24]). Suppose there is a (csize(σ), ccon(σ))-approximate LBS cut algorithm with run- ning time tLSB(n, vol(A), α, σ) when given (G, A, σ, α) as inputs where G = (V, E) is an n-node graph, A ⊂ V is a set of nodes, σ is an overlapping parameter, and α is a conductance parameter. Then, there is a one-shot expander pruning algorithm with input (G, D, αb, δ) that has time limit t = O((D αb )δ · csize(αb/2) δ · tLSB(n, ∆D αb , αb, αb)) and conductance guarantee α = αb 5ccon(αb/2)1/δ−1 . Having the above lemma and our new LBS cut algorithm from Section 4, we conclude: Proof of Theorem 5.2. From Theorem 4.4 we have that tLSB(n, vol(A), α, σ) = O( vol(A) O(1/σ2) and ccon(σ) = O(1/σ2). So ασ2 ) and csize(σ) = tLSB(n, ∆D αb , αb, αb) = O( ∆D α4 b ) 12Strictly speaking, in [24], they use LBS cut algorithm to obtain the local expansion decomposition algorithm which has slight stronger guarantee. Actually, even in [24], they only need the one-shot expander pruning algorithm. So the proof of Lemma 5.3 is simpler than the similar one in [24]. Moreover, the reduction give a deterministic one-shot expander pruning algorithm, but in [24], they obtain a randomized local expansion decomposition algorithm. 13 and hence We also have α = csize(αb/2) t = O((D αb )δ · δ 5ccon(αb/2)1/δ−1 = Ω(αb · (α2 αb ∆D α4 b · ) = O( ∆D1+δ δα6+δ b ). b )1/δ−1) = Ω(αb 2/δ). 5.2 Dynamic Expander Pruning In this section, we exploit the one-shot expander pruning algorithm from Section 5.1. To prove Theorem 5.1, it is more convenience to prove the more general statement as follows: Lemma 5.4. There is an algorithm A that can do the following: • A is given G0, α0, ℓ as inputs: G0 = (V, E) is an n-node m-edge graph with maximum degree ∆, and α0 = 1 nǫ and ℓ are parameters. Let P0 = ∅. • Then G0 undergoes the sequence of edge deletions of length T = O(α2 • Given the τ -th update, A takes O(ℓ2∆nO(1/ℓ+ǫℓℓ)) time. Then, A either reports φ(G0) < α0 and halt, or A updates the pruning set P to Pτ where Pτ−1 ⊆ Pτ ⊆ V . 0m/∆). • If φ(G0) ≥ α0 then, for all τ , there exists Wτ ⊆ Pτ where Gτ [V − Wτ ] is connected. From Lemma 5.4, we immediately obtain Theorem 5.1 by choosing the right parameters. Proof of Theorem 5.1. We set ℓ = log 1 ǫ 2 log log 1 ǫ , so that ℓℓ = O( 1 ǫ1/2 ). Hence, nO(1/ℓ+ǫℓℓ) = nO(log log 1 = nO(log log 1 ǫ / log 1 ǫ +ǫ1/2) ǫ / log 1 ǫ ) = no(1) when ǫ = o(1). We apply Lemma 5.4 with this parameters ℓ and α0 = 1 nǫ and we are done. The rest of this section is for proving Lemma 5.4. 5.2.1 The Algorithm Let G0, α0, ℓ be the inputs for the algorithm for Lemma 5.4. To roughly describe the algorithm, there will be ℓ + 1 levels and, in each level, this algorithm repeated calls an instance of the one-shot expander pruning algorithm from Theorem 5.2. In the deeper level i (large i), we call it more frequently but the size of the set D of edges is smaller. We describe the details and introduce some notations below. We fix δ = 2/ℓ. For any n, δ, α, let fn,δ(α) = (c0α)2/δ be the conductance guarantee of the remaining graph from Theorem 5.2 where c0 is some constant. We define αi = fn,δ(αi−1) for each level 1 ≤ i ≤ ℓ + 1. Note that, we have a rough bound αi = Ω((c0α0)ℓi ) for all i.. Given any input G′ = (V ′, E′),D′, α′, δ, we denote (X′, P ′) = P runeα′(G′, D′) as the output of the one-shot expander pruning algorithm from Section 5.1 where P ′ ⊂ V is the outputted pruning set and X′ = G′[V ′−P ′] is the pruned graph. Note that we omit writing δ in P runeα′(G′, D′) because δ = 2/ℓ is always fixed. For convenience, we say that a graph X is an induced α-expander from time τ if X = Gτ [U ] for some U ⊂ V and X has conductance at least α, i.e. φ(X) ≥ α. For any time period [τ, τ′], we denote D[τ,τ ′] ⊂ E a set of edges to be deleted from time τ to τ′. Observe the following fact which follows by the definitions and Theorem 5.2: 14 Fact 5.5. Suppose that X is an induced αi-expander from time τ and (X′, P ′) = P runeαi(X, D[τ +1,τ ′]). Then X′ is an induced αi+1-expander from time τ′. To maintain the pruning set P , we will additionally maintain a level-i graphs X i and a level-i τ be X i and P i at time τ respectively. pruning set P i for each level 1 ≤ i ≤ ℓ + 1. Let X i 0 = ∅, and X i and P i will be updated periodically For each level i, we initially set X i for every di time steps where di = n1−i/ℓ for i ≤ ℓ and dℓ+1 = 1. Note that dℓ = 1. In particular, this means: Fact 5.6. For any number k ≥ 0 and time τ ∈ [kdi, (k + 1)di), we have X i 0 = G0 and P i τ and P i τ = P i kdi τ = X i and P i kdi . In each time step, we spend time in each of the ℓ + 1 levels. See the precise description on each level in Algorithm 5.1. At any time, for any i, whenever we call P runeαi(X i,·) and it report that φ(X i) < αi, our algorithm will report that φ(G0) < α0 and halt. Initialization: X 0 = G0 and P0 = ∅. For each 1 ≤ i ≤ ℓ, di = n1−i/ℓ, X i 0 = ∅. 1. For each level 1 ≤ i ≤ ℓ, for each number ki ≥ 0, in time period [kidi + 1, (ki + 1)di]: 0 = G0, P i (a) Let ki−1 be such that ki−1di−1 < kidi + 1 ≤ (ki−1 + 1)di−1. (b) During the period, distribute evenly the work to: i. Update (X i ii. Include P i (ki+1)di into the pruning set P . (ki+1)di , P i (ki+1)di ) = P runeαi−1(X i−1 ki−1di−1 , D[min{1,(ki−1−1)di−1+1},kidi]). 2. For level ℓ + 1, at time τ : (a) Update (X ℓ+1 τ (b) Include P ℓ+1 , P ℓ+1 ) = P runeαℓ(X ℓ into the pruning set P . τ τ τ , D[τ,τ ]). Algorithm 5.1: Dynamic expander pruning algorithm 5.2.2 Analysis Lemma 5.7. Suppose φ(G0) ≥ α0. For any 1 ≤ i ≤ ℓ and ki, X i time max{0, (ki − 1)di}. Proof. When ki = 0, this is trivial. We now prove the claim for ki > 0 by induction on i. Let ki−1 be a number from Step 1.a such that ki−1di−1 < kidi + 1 ≤ (ki−1 + 1)di−1. X i−1 is an induced αi−1-expander from time (ki−1 − 1)di−1 by induction hypothesis. By Step 1.b.ii and Fact 5.5, we have X i is an induced αi-expander from time kidi. By translating back the time by di steps, we can conclude the claim. Lemma 5.8. Suppose φ(G0) ≥ α0. For any time τ , X ℓ+1 τ . is an induced αℓ+1-expander from time is an induced αi-expander from ki−1di−1 (ki+1)di kidi τ Proof. Note that dℓ = 1. By Lemma 5.7 when i = ℓ, we have that after the τ -th update, X ℓ τ is an induced αℓ-expander from time τ − 1. By Step 2.a and Fact 5.5, Xℓ+1 is an induced αℓ+1-expander from time τ . 15 Lemma 5.9. Suppose φ(G0) ≥ α0. Then the algorithm never reports that φ(G0) < α0. Proof. Recall that the algorithm will report φ(G0) < α0 only when, for some i and j, the call of P runeαi(X i j) < αi. By Fact 5.6, Lemma 5.7 and Lemma 5.8, if φ(G0) ≥ α0, then X i j ) ≥ αi. So the algorithm never reports that φ(G0) < α0. j is an induced αj-expander for all j and in particular φ(X i j,·) reports that φ(X i The following proposition is easy to see by Step 1.b.ii and Step 2.b in Algorithm 5.1: Proposition 5.10. For any 1 ≤ i ≤ ℓ + 1 and ki, P i Lemma 5.11. For any τ , V − V (X ℓ+1 Proof. It suffices to prove that V (X ℓ+1 τ By Step 1.a and 1.b.i, we can write τ ) ⊆ Pτ . ) ⊇ V −Pτ . Let kℓ = τ . We have V (X ℓ+1 τ kidi ⊆ Pkidi. ) = V (X ℓ kℓdℓ )−P ℓ+1 τ . V (X ℓ kℓdℓ) = V (X ℓ−1 = V (X ℓ−2 ... (kℓ−1−1)dℓ−1 (kℓ−2−2)di−2 kℓdℓ ) − P ℓ ) − P ℓ−1 (kℓ−1−1)dℓ−1 − P ℓ kℓdℓ P ℓ−i (kℓ−i−i)dℓ−i = V (X 0) − [0≤i<ℓ = V − [0≤i<ℓ P ℓ−i (kℓ−i−i)dℓ−i where ki−i is the largest number where (kℓ−i − 1)dℓ−i ≤ kℓ−i+1dℓ−i+1. (For convenience, let X i 0 = G0 and P i X i ℓ. Therefore, by Proposition 5.10, we have P ℓ−i that V (X ℓ Proposition 5.10 again. j = j = ∅ for any negative j < 0.) Observe that (kℓ−i − i)dℓ−i ≤ kℓdℓ for all i ≤ (kℓ−i−i)dℓ−i ⊆ P(kℓ−i−i)dℓ−i ⊆ Pkℓdℓ . This implies ⊇ V − Pτ , by ) ⊇ V − Pkℓdℓ = V − Pτ . We conclude V (X ℓ+1 ) − P ℓ+1 ) = V (X ℓ kℓdℓ kℓdℓ τ τ Now, we can conclude the correctness of the algorithm: Corollary 5.12. After given the τ -th update, the algorithm either correctly reports φ(G0) < α0 and halt, or updates the pruning set P to Pτ where Pτ−1 ⊆ Pτ ⊆ V . If φ(G0) ≥ α0 then, for all τ , there exists Wτ ⊆ Pτ where Gτ [V − Wτ ] is connected. Proof. By Lemma 5.9, we have that the algorithm either correctly reports that φ(G0) < α0 and halt, or updates the pruning set P to Pτ and Pτ−1 ⊆ Pτ ⊆ V because we only grow P through time. Let Wτ = V − V (X ℓ+1 τ which is an αℓ+1-expander by Lemma 5.8, when φ(G0) ≥ α0. In particular Gτ [V − Wτ ] is connected. ). By Lemma 5.11, we have Wτ ⊆ Pτ and also Gτ [V − Wτ ] = X ℓ+1 τ Finally, we analyze the running time. Lemma 5.13. For each update, the algorithm takes O(ℓ2∆nO(1/ℓ+ǫℓℓ)) time. Proof. We separately analyze the running time for each level. At level i, in time period [kidi + 1, (ki + 1)di], the bottleneck is clearly for calling P runeαi−1(X i−1 , D[min{1,(ki−1−1)di−1+1},kidi]). Note that D[min{1,(ki−1−1)di−1+1},kidi] ≤ di−1. By Theorem 5.2, this takes time ti = O( ). 1+δ ∆·d i−1 δα6+δ i−1 ki−1di−1 16 Since we distribute the work evenly in the period, this takes ti/di = O( step. This is because δ = 2/ℓ, di = n1−i/ℓ, and so ∆·d δα6+δ 1+δ i−1 i−1 di ) = O( ∆n3/ℓ δα6+δ i−1 ) per Since there are ℓ + 1 level, this takes in total per time step 1+δ i−1/di ≤ nδ · di−1/di = nδ+1/ℓ = n3/ℓ. d Xi≤ℓ+1 O( ∆n3/ℓ δα6+2/ℓ i−1 ) = O( ℓ2∆n3/ℓ α8 ℓ ) = O( ℓ2∆n3/ℓ ((c0α0)ℓℓ )8 ) = O(ℓ2∆nO(1/ℓ+ǫℓℓ)). by ℓ ≥ 1 and δ=2/ℓ by αi = Ω((c0α0)ℓi ) By Corollary 5.12 and Lemma 5.13, this concludes the proof of Lemma 5.4, and hence Theo- rem 5.1. 6 Pruning on Arbitrary Graphs In Theorem 5.1, we show a fast deterministic algorithm that guarantees connectivity of the pruned graph G[V − W ] only when an initial graph is an expander. If the initial graph is not an expander, then there is no guarantee at all. With a simple modification, in this section, we will show a fast randomized algorithm for an arbitrary initial graph that either outputs the desired pruning set or reports failure. Moreover, if the the initial graph is an expander, then it never fails with high probability. This section is needed in order to make our final algorithm Las Vegas. If we only want a Monte Carlo algorithm, then it is enough to use Theorem 5.1 when we combine every component together in Section 9. Theorem 6.1. Consider any ǫ(n) = o(1), and let α0(n) = 1/nǫ(n). There is a dynamic algorithm A that can maintain a set of nodes P for a graph G undergoing T = O(mα2 0(n)) edge deletions as follows. Let Gτ and Pτ be the graph G and set P after the τ th deletion, respectively. • Initially, in O(n log 1 (V, E) with maximum degree 3. p ) time A sets P0 = ∅ and takes as input an n-node m-edge graph G0 = ǫ(n) / log 1 • After the τ th deletion, A takes O(nO(log log 1 report nodes to be added to Pτ−1 to form Pτ where ǫ(n) ) log 1 p ) = O(no(1) log 1 p ) time to either 1) ∃Wτ ⊆ Pτ s.t. Gτ [V − Wτ ] is connected or 2) reports failure. If φ(G0) ≥ α0(n), then A never fails with probability 1 − p. Proof. Let ASF be an instance of the Monte Carlo dynamic spanning forest by Kapron et al. [22] that guarantees to maintain a correct spanning forest with probability 1 − p when the update sequence has length poly(n). Let Aprune be an instance of the dynamic expander pruning from Theorem 5.1. Given ASF and Aprune, the algorithm is very simple. 17 The preprocessing algorithm is just to initialize ASF and Aprune on the graph G in time O(n log 1 p ) and O(1) respectively. Then, given a sequence of edge deletions, Aprune maintains the pruning set P and ASF maintains a spanning forest F of the current graph G. We say that F spans V − P iff all the nodes in V − P are in the same connected component of F . The update algorithm is just to check if F spans V − P . If yes, then we report P as the desired pruning set. If no, then we report failure. p ). Moreover, we can check if F spans V − P easily by implementing ET-tree on F . This takes O(log n) update time. The time used by Aprune is O(nO(log log 1 ǫ(n) )). So the total update time is at most O(nO(log log 1 Now, we analyze the update algorithm. The update time of ASF is O(logO(1) n·log 1 ǫ(n) / log 1 ǫ(n) / log 1 ǫ(n) ) log 1 p ) It remains to show the correctness. If the algorithm does not fail, then F spans V − P . Hence, there is W ⊂ P where G[V − W ] is connected. Finally, if φ(G0) ≥ α0(n), then by Theorem 5.1 we have that there is W ⊂ P where G[V − W ] is connected. Then, F must span V − P ⊆ V − W with high probability, because F is a spanning forest of G with high probability by the guarantee in [22]. 7 Reduction from Graphs with Few Non-tree Edges Undergoing Batch Insertions In this section, we show the following crucial reduction: Theorem 7.1. Suppose there is a decremental MSF algorithm A for any m′-edge graph with max degree 3 undergoing a sequence of edge deletions of length T (m′), and A has tpre(m′, p) preprocessing time and tu(m′, p) worst-case update time with probability 1 − p. Then, for any numbers B and k where 15k ≤ m′, there is a fully dynamic MSF algorithm B for any m-edge graph with at most k non-tree edges such that B can: • preprocess the input graph in time t′pre(m, k, B, p) = tpre(15k, p′) + O(m log2 m), • handle a batch of B edge insertions or a single edge deletion in time: t′u(m, k, B, p) = O( B log k k · tpre(15k, p′) + B log2 m + k log k T (k) + log k · tu(15k, p′)), where p′ = Θ(p/ log k) and the time guarantee for each operation holds with probability 1 − p. The proof of Theorem 7.1 is by extending the reduction by Wulff-Nilsen [37] in two ways. First, the resulting algorithm is more efficient when there are few non-tree edges. Second, the resulting algorithm can also quickly handle a batch of edge insertions. Although, the extension of the reduction is straightforward and also uses the same "contraction" technique by Henzinger and King [15] and Holm et al. [19], we emphasize that our purpose for using the "contraction" technique is conceptually very different from all previous applications of the (sim- ilar) technique [16, 19, 20, 37]. The purpose of all previous applications is for reducing decremental algorithms to fully dynamic algorithms. However, this goal is not crucial for us. Indeed, in our application, by slightly changing the algorithm, the input dynamic MSF algorithm for Theorem 7.1 can also be fully-dynamic and not decremental. But it is very important that the reduction must 18 give an algorithm that is faster when there are few non-tree edges and can handle batch insertions. Therefore, this work illustrates a new application of the "contraction" technique. There are previous attempts for speeding up the algorithm when there are few non-tree edges. In the dynamic SF algorithm of Nanongkai and Saranurak [24] and the dynamic MSF algorithm of Wulff-Nilsen [37], they both also devised the algorithms that run on a graph with k non-tree edges by extending the 2-dimensional topology tree of Frederickson [11]. The algorithms have O(√k) update time. In the context of [24, 37], they have k = n1−ǫ0 for some small constant ǫ0 > 0 where n is the number of nodes, and hence O(√k) = O(n0.5−ǫ0/2). This eventually leads to their dynamic SF and MSF algorithms with update time n0.5−Ω(1). In our application paper, we will have k = n1−o(1) and the update time of O(√k) is too slow. Fortunately, using the reduction from this section, we can reduce to the problem where the algorithm runs on graphs with only O(k) edges, and then recursively run our algorithm on that graph. Together with other components, this finally leads to the algorithm with subpolynomial update time. The rest of this section is for proving Theorem 7.1. Although the proof is by straightforwardly extending the reduction of Wulff-Nilsen [37] which is in turn based on the reduction by Holm et al. [19], the reduction itself is still quite involved. Moreover, in [37], it is only outlined how to extend from [19]. Therefore, below, we give a more detailed proof for completeness. 7.1 Reduction to Decremental Algorithms for Few Non-tree Edges In this section, we reduce from fully dynamic MSF algorithms running on a graph with k non-tree edges and can handle a batch insertion to decremental MSF algorithms running on a graph with k non-tree edges as well. We will reduce further to decremental algorithms running on a graph with O(k) edges in later sections. This can be done by straightforwardly adjusting the reduction from [19, 37], we extend the reduction so that the resulting algorithm can handle batch insertions, and the input algorithm also runs on graph with few non-tree edges. Lemma 7.2. Suppose there is a decremental MSF algorithm A for any m-edge graph with at most k non-tree edges and has preprocessing time tpre(m, k, p) and update time tu(m, k, p). Then, for any B ≥ 5⌈log k⌉, there is a fully dynamic MSF algorithm B for any m-edge graph with at most k non-tree edges such that B can: • preprocess the input graph in time t′pre(m, k, B, p) = tpre(m, k, p′) + O(m log m), • handle a batch of B edge insertions or an edge deletion in time: t′u(m, k, B, p) = O( ⌈log k⌉Xi=0 tpre(m, min{2i+1B, k}, p′)/2i + B log m + log k · tu(m, k, p′)), where p′ = O(p/ log k) and the time guarantee for each operation holds with probability 1 − p. 7.1.1 Preprocessing We are given an input graph G = (V, E) for B and parameters B and p. Let F = MSF(G) denote the MSF of G through out the update sequence. Let N = E − F denote the set of non-tree edges. We have that E ≤ m and N ≤ k at each step. 19 Let L = ⌈log k⌉ and p′ = p/c0L for some large enough constant c0. In the algorithm, we will maintain subgraphs Gi,j of G for each 0 ≤ i ≤ L and 1 ≤ j ≤ 4. Additionally, there is a a subgraph GL,0 of G. Let Ni,j = E(Gi,j) − MSF(Gi,j). We maintain an invariant that N = Si,j Ni,j and Ni,j ≤ min{2iB, k}. that maintains MSF(Gi,j). algorithm is simply to initialize DL,1 and the top tree T (F ) on F , Let Di,j be an instance of the decremental MSF algorithm A from the assumption of Lemma 7.2 Initially, we set GL,1 = G and other Gi,j = ∅. The preprocessing 7.1.2 Update Given the τ -th update, we say that we are at time step τ . There are two cases: either inserting a batch of edges or deleting an edge. In either cases, after handling the update, we then apply the clean-up procedure. We now describe the procedure. Inserting a Batch of Edges: Let I be a set of edges to be inserted where I ≤ B. We define the set R as follows. For each edge e = (u, v) ∈ I, if u and v are not connected in F , then add e to F . Otherwise, u and v are connected in F by the unique path Pu,v. Let f be the edge with maximum weight in Pu,v. Note that f can be found using the top tree T (F ). If w(e) > w(f ), then we include e to R. If w(e) < w(f ), then we set F ← F ∪ e − f and include f to R. Observe that R ≤ B. Then we run the clean-up procedure with input R. Deleting an Edge: Let e be the edge to be deleted. For all i and j, we set Gi,j ← Gi,j − e and update Di,j accordingly. Let R0 be the set of reconnecting edges of MSF(Gi,j) returned from Di,j over all i and j. Among edges in R0, let f be the lightest edge that can reconnect F . If f exists, set F ← F ∪ f − e and R ← R0 − f . Otherwise, F ← F − e and R ← R0. Then we run the clean-up procedure with input R. Observe that R ≤ 4L + 1. In the following, suppose that D′ is an instance of decremental MSF algorithm running Clean-up: on some graph G′. Let N′ = E(G′) − MSF(G′). For any i and j, when we write Di,j ← D′, this means that we set the instance Di,j to be D′. So Gi,j = G′. If we write Di,j ← ∅, this means that we destroy the instance Di,j. So Gi,j = ∅. The time needed for setting Di,j ← D′ or Di,j ← ∅ is constant because it can be done by swapping pointers. Let R be the set of input edges for the clean-up procedure. Let R′ be another set of edges that we will define below. Now, we describe the clean-up procedure. For each i starting from 0 to L + 1, we execute the clean-up procedure for level i. For any fixed i, the procedure for level i is as follows. For i = 0, we initialize an instance of dynamic contracted MSF algorithm D′0 on G′0 = (V, F ∪ R ∪ R′). We set D0,j ← D′0 for some j ∈ {1, 2} where D0,j = ∅. For i > 0, all the steps τ not divisible by 2i are for initializing an instance of decremental MSF algorithm D′i on a graph G′i that will be specified below. If 2i divides τ , we claim that D′i is finished initializing on some graph G′i. For 0 ≤ i ≤ L, we set Di,j ← D′i for some j ∈ {1, 2} If i = L + 1, we just set DL,0 ← D′i. Then, for any 1 ≤ i ≤ L + 1, we set where Di,j = ∅. (Di−1,3,Di−1,4) ← (Di−1,1,Di−1,2) and (Di−1,1,Di−1,2) ← (∅,∅). We do the following during the time period [τ, τ + 2i) for initializing D′i on G′i. Let I1 = [τ, τ + 2i−1) and I2 = [τ + 2i−1, τ + 2i) be the first and second halves of the period. During I1, we evenly distribute the work for initializing D′i on G′i where G′i = (V, F ∪ N′i), N′i = Ni−1,3 ∪ Ni−1,4 for 0 < i ≤ L and N′L+1 = NL,0 ∪ NL,3 ∪ NL,4 for i = L + 1. We note that and Ni−1,3, Ni−1,4 and F are the sets of edges at time τ and hence G′i is a subgraph of G. After I1, we have finished the initialization D′i on the 2i−1-step-old version of G′i. Therefore, during I2, we update D′i at "double speed" so that after these 2i−1 steps, D′i is running on the up-to-date G′i as desired. More precisely, 20 at time τ + 2i−1 + k, we feed to D′i the updates of G′i from time τ + 2i−1 + 2k and τ + 2i−1 + 2k + 1, for each 0 ≤ k < 2i−1. Now, we can define the set R′. At any time τ , before we run the clean-up procedure for level 0. We set R′ to be the set of reconnecting edges returned by all D′i that are given edge deletions at double speed. 7.1.3 Correctness To see that the description for clean-up procedure is valid, observe the following: Proposition 7.3. For any i and j, Gi,j is a subgraph of G at any time. Proposition 7.4. For all 0 ≤ i ≤ L, before setting Di,j ← D′i for some j ∈ {1, 2}, we have Di,j = ∅ for some j = {1, 2}. Proof. We set Di,j ← D′i only when 2i divides τ . But once 2i+1 divides τ , we run the procedure for level i + 1 and set (Di,1,Di,2) ← (∅,∅). Lemma 7.5. Suppose that N ⊆Si,j Ni,j. When e ∈ F is deleted, let f∗ be the lightest reconnecting edge for F in G. Then f∗ ∈ R0. Proof. Before deleting e ∈ F , we have f∗ ∈ N and hence f∗ ∈ Ni,j for some i, j. As Gi,j is a subgraph of G, f∗ is also the lightest reconnecting edge in Gi,j after deleting e in Gi,j. So f∗ returned by Di,j and is included into R0. The following lemma concludes the correctness of the algorithm for Lemma 7.24. statements are maintained after each update using the claims below. the set of new non-tree edges (i.e. the new edges in N ) because, before inserting I, F = MSF(G). When the update is an edge deletion, R is exactly the set of non-tree edges in all Gi,j that become Lemma 7.6. Throughout the updates, we have N =Si,j Ni,j and F = MSF(G). After preprocessing, N =Si,j Ni,j and F = MSF(G) by construction. We will prove that both First, we prove N ⊆ Si,j Ni,j. When the update is a batch I of edge insertions, R is exactly tree edges (i.e. the edges removed fromSi,j Ni,j but potentially still in N ). Now, after the clean-up procedure for level 0, we have that either N0,1 or N0,2 is set from ∅ to R ∪ R′ (i.e. R is included intoSi,j Ni,j). Therefore, N ⊆Si,j Ni,j after the procedure for level 0. Claim 7.7. For 1 ≤ i ≤ L + 1, N ⊆Si,j Ni,j after applying the clean-up procedures of level i. Proof. For i ≤ L, suppose we are at time τ divisible by 2i and we set Di,j ← D′i where Di,j = ∅, (Di−1,3,Di−1,4) ← (Di−1,1,Di−1,2) and (Di−1,1,Di−1,2) ← (∅,∅). That is, the edges of Ni−1,3∪Ni−1,4 contributing to Si,j Ni,j are replaced by the edges in N′i. We argue that after this we still have N ⊆Si,j Ni,j. This is because, at time τ − 2i, when we start the initialization of D′i on G′i, we set N′i = Ni−1,3 ∪ Ni−1,4 exactly. Then, from time τ − 2i to τ , all reconnecting edges returned by D′i are included in to R′ in every step. That is, R′ contains the edges that are removed from N′i but potentially still in N . As R′ is included intoSi,j Ni,j at every step, we are done. For i = L + 1, we set DL,0 ← D′i, (DL,3,DL,4) ← (DL,1,DL,2) and (DL,1,DL,2) ← (∅,∅). Although, DL,0 6= ∅ before we set DL,0 ← D′i, we have that N′i = NL,0 ∪ NL,3 ∪ NL,4 exactly at 2i steps ago. Using the same argument, we have N ⊆Si,j Ni,j after the procedure. Second, we prove thatSi,j Ni,j ⊆ N which follows from the two claims below. 21 Claim 7.8. Whenever an edge f is removed from N , then f is removed fromSi,j Ni,j. Proof. Observe that an edge f can be removed from the set N by one of two reasons: 1) f is deleted from G, or 2) some edge e is deleted and f is a reconnecting edge. If f is deleted G, then f is deleted from all Gi,j. If f is a reconnecting edge, by Lemma 7.5, we know f is the lightest reconnecting edge in G. But Gi,j is a subgraph of G for all i and j. If f ∈ Ni,j for any i, j, then f must be the lightest reconnecting edge in Gi,j and hence f is removed from Ni,j. In either case, when f is removed from N , then f is removed fromSi,j Ni,j as well. Claim 7.9. Whenever an edge f is added intoSi,j Ni,j, then f is added into N . Proof. For any fixed i, f can be added into Sj Ni,j only when 2i divides τ and we set Di,j ← D′i. Now, when we start the initialization of D′i on G′i at time τ − 2i, we set G′i = (V, F ∪ N′i) and so N′i ⊆ N at that time. From time τ − 2i to τ , there is no edges added to N′i because no MSF-edge can become non-tree edge in a graph undergoing only edge deletions. Moreover whenever an edge f is removed N , it is removed from N′i for the same reason as in Claim 7.8. So at time τ , we have N′i ⊆ N . Now, we have that Si,j Ni,j = N is maintained. To show that F = MSF(G) after the update, whenever an edge e is deleted, by N ⊆Si,j Ni,j and Lemma 7.5, the lightest reconnecting edge f∗is included in R0. So F ← F ∪ f∗ − e and F becomes MSF(G). For each inserted edge e = (u, v), we may only remove the heaviest edge f in the path u to v in F . So F = MSF(G) as well. This concludes the proof of Lemma 7.6. 7.1.4 Running Time First, we need this lemma. Lemma 7.10. For any i and j, Ni,j ≤ min{2i+1B, k}. Proof. First, Ni,j ⊆ N by Lemma 7.6 and so Ni,j ≤ N ≤ k. Next, we will prove that Ni,j ≤ 2iB, for any i and j by induction. As we know NL,0 ≤ k and we always set (Di,3,Di,4) ← (Di,1,Di,2) for all i ≤ L, it remains to bound only Ni,1 and Ni,2 for all i ≤ L. For i = 0, in the clean-up procedure we only set N0,1 and N0,2 as the input set R. When there is a batch insertion, we have that R ≤ B. When there is an edge deletion, we have R ≤ 4L + 1 because, for each i, j, the instance Di,j can return one reconnecting edge per time step. Also, observe that R′ ≤ 2(L + 1) because, for 1 ≤ D′i ≤ L + 1, D′i can return two reconnecting edge per time step (as they are possibly updated at double speed). Therefore, N0,1,N0,2 ≤ R ∪ R′ ≤ max{B, 4L + 1} + 2(L + 1) ≤ 2B as B ≥ 5L. Next, for 0 < i ≤ L, in the clean-up procedure we only set Ni,1 and Ni,2 as the set N′i where N′i = Ni−1,3 ∪ Ni−1,4 So Ni,1,Ni,2 ≤ N′i ≤ 2 · 2iB = 2i+1B. Now, we can conclude the preprocessing and update time of the algorithm for Lemma 7.24. Lemma 7.11. The preprocessing algorithm takes tpre(m, k, p′) + O(m log m) time. Proof. We can compute F = MSF(G) in time O(m log m). The algorithm is to just initialize the top tree T (F ) on F and the decremental MSF Di,j for all i, j. By Lemma 2.5, we initialize T in time O(m). Then, as NL,1 = N and N ≤ k, we can initialize all DL,1 in time tpre(m, k, p′). Next, we bound the time spent on the clean-up procedure at each step. 22 Lemma 7.12. For each update, the time spent on the clean-up procedure is O( ⌈log k⌉Xi=0 tpre(m, min{2i+1B, k}, p′)/2i + log k · tu(m, k, p′)) with probability 1 − p/2. Proof. For each i, we analyze the time spent on the clean-up procedure of level i. When the time step τ is divisible by 2i, this takes O(1) time because all we do is only setting Di,j ← D′ for some D′ for several j. After that, for the period I1 = [τ, τ + 2i−1), we distribute evenly the work for initializing D′i. This takes tpre(m,N′i, p′)/2i−1 time per step. For the period I2 = [τ + 2i−1, τ + 2i), we feed the updates to D′i at "double speed". This takes 2 · tu(m,N′i, p′) time per step. By Lemma 7.10, the total time for step for the clean-up procedure of level i is tpre(m, min{2i+1B, k}, p′) 2i−1 + 2 · tu(m, min{2i+1B, k}, p′)). Finally, as L = ⌈log k⌉, summing the time for all levels give the bound in lemma. Moreover, the bound holds with probability 1 − p′ × O(L) ≤ 1 − p/2. Lemma 7.13. The time for inserting a batch of edges of size at most B and the time for deleting an edge is at most O( ⌈log k⌉Xi=0 tpre(m, min{2i+1B, k}, p′)/2i + log k · tu(m, k, p′) + B log m) with probability 1 − p. Proof. We show the update time outside the clean-up procedure. For insertion, we need O(B log m) time be the property of top tree. For deletion, we needPi,j tu(m,Ni,j, p′) = O(tu(m, k, p′) log k) by Lemma 7.10, and the bound holds with probability 1 − p′O(L) ≤ 1 − p/2. By Lemma 7.12, we are done and the bound holds with probability 1 − 2 · p/2 = 1 − p. Lemma 7.6, Lemma 7.11, and Lemma 7.13 concludes the proof of Lemma 7.2. 7.2 Contraction From Lemma 7.2, we have reduced the problem to decremental algorithms on graphs with few non- tree edges. We want to further reduce the problem to decremental algorithms on graph with few edges (using some additional data structures). Informally, we would like to prove the following: Lemma 7.14 (Informal statement of Lemma 7.23). Suppose there is a decremental MSF algorithm A′ for any m′-edge graph with preprocessing time tpre(m′, p) and update time tu(m′, p). Then, for any m, k where 5k ≤ m′, and B, let G = (V, E) be a graph with m-edge graph and at most k non-tree edges. Then, with some additional data structures, there is a decremental dynamic MSF algorithm B for G with preprocessing time t′pre(m, k, p) = tpre(5k, p) + O(k log m) and edge-deletion time t′u(m, k, p) = tu(5k, p) + O(log m) with probability 1 − p. The rest of this section is devoted to the proof of Lemma 7.23. We use the contraction technique by Holm et al. [19]. Below, we define some related notions and analyze their properties. Then, we show the proof of the reduction. 23 7.2.1 Property of Contracted Graphs/Forests For any tree T = (V, E) and the set S ⊆ V of terminals, the connecting paths of T with respect to S are the path that the minimal collections of disjoint paths in T that "connect" the terminals in S. Below is the formal definition: Definition 7.15 (Connecting Paths). Given a tree T = (V, E) and a set of terminals S ⊆ V , the set PS(T ) of connecting paths of T with respect to S is defined as follows: 1. PS(T ) is a collection of edge-disjoint paths. 2. The graph SP∈PS(T )P is a (connected) subtree of T . 3. For any terminal u ∈ S, u is an endpoint of some path P ∈ PS(T ). 4. For any endpoint u of P ∈ PS(T ), either u ∈ S or there are other two paths P ′, P ′′ ∈ PS(T ) whose endpoint is u. (connected) tree T in F . The definition can be extended as follows: for any forest F = (V, E) and a set of terminal S (where possibly S 6⊂ V ), PS(F ) = ST∈FPS∩V (T )(T ) is the disjoint-union of PS∩V (T )(T ) over all Condition 4 in Definition 7.15 implies the minimality of PS(T ). Indeed, suppose otherwise that u is an endpoint of P ∈ PS(T ) but u /∈ S and there is only one other path P ′ whose endpoint is u. Then, we can replace P and P ′ with a path P ′′ = P ∪ P ′ while other conditions are still satisfied. The following lemma formally shows that the definition of PS(F ) is uniquely defined. Lemma 7.16. For any tree T = (V, E) and a set S ⊆ V of terminals, PS(T ) is uniquely defined. Proof. Suppose there are two different sets P and P′ of connecting paths of T with respect to S. Let end(P) and end(P′) be the set of endpoints of paths in E and E′. Condition 3 states that S ⊆ end(P) ∩ end(P′). Let H = SP∈PP and H′ = SP∈P ′P . Condition 2 states that both H and H′ are (connected) subtrees of T . Observe that all the sets of leaves of H and H′ must be the same. Otherwise, we can assume w.l.o.g. that there is a leaf u of H where u ∈ V (H) \ V (H′). By Condition 4, u ∈ S as u is a leaf in H. But u /∈ end(P′) which contradicts that fact that S ⊆ end(P′). Now, as H and H′ share the same at of leaves, it follows that H and H′ are the same subtree in T . As P and P′ are different, w.l.o.g. there is a node u ∈ end(P) \ end(P′). As S ⊆ end(P′), we have that u /∈ S. By Condition 4, u is an endpoint of three paths P, P ′, P ′′ ∈ P which are edge- disjoint by Condition 1. In particular, degH(u) ≥ 3. Next, as u ∈ V (H) = V (H′) but u /∈ end(P′), we have that u is an internal node of some path P ′ ∈ P. So degH ′(u) = 2. This is a contradiction because H and H′ are the same subtree but 2 = degH ′(u) = degH(u) ≥ 3. Below, for any set of edges E′, let end(E′) denote the set of endpoints of edges in E′. Observe the following: Proposition 7.17. For any graph G = (V, E), forest F ⊆ E, and any S ⊇ end(E − F ), each connecting path in PS(F ) is an induced path in G. Definition 7.18 (Contracted Graphs/Forests and Super Edges). For any weighted graph G = (V, E, w), forest F ⊆ E and a set S ⊇ end(E − F ) of terminals, the contracted (multi)-graph G′ and contracted forest F ′ with respect to S is obtained from G and F respectively by 1) removing all edges in F \ SP∈PS(F )P , and 2) replacing each connecting path Puv = (u, . . . , v) ∈ PS(F ) 24 in F with an edge (u, v), called super edge, with weight w(u, v) = maxe∈Puv w(e). We denote (G′, F ′) = ContractS(G, F ). For each e ∈ Puv ⊆ F , we say (u, v) ∈ F ′ is the super edge covering e with respect to S. In the following propositions, we show some properties of the contracted graph and forest. Let G = (V, E) be a graph and F ⊆ E be a forest. Denote by N = E − F the set of non-tree edges and S ⊇ end(N ) a set of terminal contains points non-tree edges. Let (G′, F ′) = ContractS(G, F ) be the contracted graph and forest with respect to S. First, we show that the number of edges in the contracted graph is linear in the number of original non-tree edges plus the number of terminals. Proposition 7.19. E(G′) = N ∪E(F ′) and E(G′) ≤ N + 2S. Proof. We have that E(G′) = N ∪E(F ′) by construction. It is enough to prove that E(F ′) ≤ 2S. For each tree T in F , let T ′ be the corresponding contracted tree in F ′. Again, let end(PG(T )) is the set of endpoints of paths in PG(T ) and let ST = S ∩ V (T ) be the set of terminal in T . We have V (T ′) = end(PG(T )) ⊇ ST . Also, for all u ∈ end(PG(T )) \ ST , degT ′(u) ≥ 3 by Condition 4 of Definition 7.15. It is well known that, in any tree, the number of nodes with degree at least three is at most the number of nodes with degree at most two. So ST ≥ end(PG(T )) \ ST and hence end(PG(T )) ≤ 2ST. Note that E(T ′) = V (T ′) − 1 = end(PG(T )) − 1. So ST ≤ 2S. E(F ′) = XT ′∈F ′ E(T ′) ≤ XT∈F end(PG(T )) ≤ 2XT∈F Proposition 7.20. If F = MSF(G), then F ′ = MSF(G′). Proof. As E(G′) = N ∪E(F ′) by Proposition 7.19, we only need to prove that N ∩ MSF(G′) = ∅. For each e = (u, v) ∈ N , then u and v must be connected in F , otherwise F is not spanning. Let Pu,v ⊆ F be a path in F connecting u and v. We have that w(e) > maxf∈Pu,v w(f ) otherwise F is not an MSF. Let P ′u,v ⊆ F ′ be a path in F ′ connecting u and v. Observe that each edge e′ ∈ P ′u,v corresponds to a connecting path Pe′ ⊆ Pu,v. So w(e′) ≤ maxf∈Pu,v w(f ). So we have maxe′∈P ′ u,v w(e′) = maxf∈Pu,v w(f ) < w(e). That is, e /∈ MSF(G′). Here, we show the change of 1) the contracted graph/forest (G′, F ′), 2) the MSF of the graph MSF(G), and 3) the MSF of the contracted graph MSF(G′) when we delete an edge e from G. Note that the set S of terminal does not change. F ′ = F ′1. Proposition 7.21. Suppose that F = MSF(G). For any edge e of G, let G1 = G − e, F1 = F − e (so F1 = F if e /∈ F ) and (G′1, F ′1) = ContractS(G1, F1) (note that S = end(E − F )). 1. If e ∈ N , then (G′1, F ′1) = (G′ − e, F ′), MSF(G1) = F = F1 and MSF(G′1) = F ′ = F ′1. 2. Else, if e ∈ F \ SP∈PS (F )P , then (G′1, F ′1) = (G′, F ′), MSF(G1) = F − e = F1 and MSF(G′1) = 3. Else, e ∈ SP∈PS(F )P and there is a super edge e′ = (u′, v′) ∈ F ′ covering e with respect to S. Then, (G′1, F ′1) = (G′ − e′, F ′ − e′). Then, one of two cases holds: (a) MSF(G1) = F − e = F1 and MSF(G′1) = F ′ − e′ = F ′1, or (b) There is f ∈ N where MSF(G1) = F ∪f −e = F1∪f and MSF(G′1) = F ′∪f −e′ = F ′1∪f . 25 7.2.2 The Proof Holm et al. [19] show the following crucial structure based on top tree. Lemma 7.22 (Lemma 15 of [19]). There is an algorithm C that runs in two phases: 1. In the first phase: C maintains an at-most-m-edge forest F undergoing a sequence of edge insertions and deletions. C can handle each edge update of F in O(log m). 2. Then, in the second phase: given any set N of edges, C can return (G′, F ) = ContractS(G, F ) in time O(N log m) where G = (V, F ∪ N ) and S = end(N ). Moreover, for any edge e ∈ F , C can return a super edge e′ = (u′, v′) ∈ F ′ covering e with respect to S, if e′ exists, in time O(log m). Having Lemma 7.22 together with Proposition 7.21, we can prove the main reduction of this section. Lemma 7.23. Suppose there is a decremental MSF algorithm A′ for any m′-edge graph with pre- processing time tpre(m′, p) and update time tu(m′, p). Then, for any m, k where 5k ≤ m′, and B, let G = (V, E) be a graph with m-edge graph and at most k non-tree edges. Suppose that F = MSF(G) and N = E − F are given. Moreover, there is a given instance C of the algorithm Lemma 7.22 that is running its first phase on F . Then, there is a decremental dynamic MSF al- gorithm B for G with preprocessing time t′pre(m, k, p) = tpre(5k, p) + O(k log m) and edge-deletion time t′u(m, k, p) = tu(5k, p) + O(log m) with probability 1 − p. Proof. The preprocessing algorithm for B is the following. First, we switch C to the second phase and give the non-tree edges N to C, and obtain (G′, F ) = ContractS(G, F ) where S = end(N ). By Proposition 7.19, E(G′) ≤ N + 2S ≤ 5k. After that we initialize A′ on G′ with probability parameter p in time tpre(E(G′), p) = tpre(5k, p). In total this takes t′pre(m, k, p) = tpre(5k, p) + O(k log m). Throughout that the edge-deletion sequence for B, the set S is fixed. We will maintain the following invariant 1) F = MSF(G), 2) (G′, F ′) = Contract(G, F ), and 3) for each e ∈ F , we can find a super edge e′ = (u′, v′) ∈ F ′ covering e with respect to S in time O(log m). Given an edge e to be deleted, let G1 = G − e, let F1 = F − e (so F1 = F if e /∈ F ) and (G′1, F ′1) = Contract(G1, F1). We note that we can obtain (G′1, F ′1) in time O(log m). Indeed, by Proposition 7.21 either (G′1, F ′1) = (G′, F ′), (G′1, F ′1) = (G′ − e, F ′) or (G′1, F ′1) = (G′ − e′, F ′ − e′) where e′ ∈ F ′ is a super edge covering e w.r.t. S. By the invariants 3, we can check which case of Proposition 7.21 holds, and compute (G′1, F ′1) in time O(log m). Then, we feed the change from G′ to G′1 to A′. This takes tpre(5k, p) because there is at most 1 edge update from G′ to G′1 according the Proposition 7.21. Finally, there are two cases. For the first case, suppose that A′ returns a reconnecting edge f , i.e. MSF(G′1) = MSF(G′) ∪ f − e′. We are in Case 3.b of Proposition 7.21. We update F to be F1 ∪ f in O(1) time to satisfy invariant 1 as F1 ∪ f = MSF(G1). We update F ′ to be F ′1 ∪ f in time O(1). As F ′1 ∪ f = MSF(G′1) and (G′1, MSF(G′1)) = Contract(G1, MSF(G1)) by Proposition 7.20, so invariant 2 is satisfied. Observe that f is the only new edge in F and f ∈ F ′ is also the super edge covering f w.r.t. to S. So invariant 3 is easily maintained. For the second case, A does not return a reconnecting edge. We simply update F and F ′ to F1 and F ′1 in O(1) time. By other cases of Proposition 7.21, all the three invariants are maintained. 26 7.3 Reduction to Decremental Algorithm for Few Edges In this section, we show how to speed up the resulting algorithm from Lemma 7.2 using Lemma 7.23. Recall that in the reduction in Lemma 7.2 reduces to decremental MSF algorithms which runs on graphs with few non-tree edges. While the reduction in Lemma 7.23 can quickly reduce further to decremental MSF algorithms running on graphs with few edges, Lemma 7.23 needs some additional data structures to be prepared. So we will show how to augment the reduction in Lemma 7.2 so that at any time the needed additional data structures for Lemma 7.23 is prepared. This gives the following lemma: Lemma 7.24. Suppose there is a decremental MSF algorithm A for any m′-edge graph with pre- processing time tpre(m′, p) and update time tu(m′, p). Then, for any m, k where 5k ≤ m′, and B, there is a fully dynamic MSF algorithm B for any m-edge graph with at most k non-tree edges such that B can: • preprocess the input graph in time t′pre(m, k, B, p) = tpre(5k, p′) + O(m log2 m), and • handle a batch of B edge insertions or an edge deletion in time: t′u(m, k, B, p) = O( B log k k tpre(5k, p′) + B log2 m + log k · tu(5k, p′)), · where p′ = O(p/ log k) and the time guarantee for each operation holds with probability 1 − p. To prove Lemma 7.24, we show how to augment the reduction in Lemma 7.2 as follows. For each 0 ≤ i ≤ L + 1 and 1 ≤ j ≤ 6, we let Ci,j be the instance of the algorithm from Lemma 7.22. We say that Ci,j is ready, if it is in its first phase and Ci,j is running on F = MSF(G) undergoing edges updates. When we want to start the initialization of D′i, we claim that, for some j, Ci,j is ready. Then, the ready Ci,j will be shift to its second phase by plugging into the reduction Lemma 7.24. More precisely, Ci,j will be given a set N′i where G′i = (V, F ∪ N′i) and Ci,j needs to return the contracted graph and forest Contract(G′i, F ). We say that Ci,j is occupied by D′i. For any D′,D′′, suppose that Ci,j was occupied by D′ and we set D′′ ← D′, then we say Ci,j is occupied by D′′. If Ci,j was occupied by D′ and we set D′ ← D′′, then we say Ci,j is not occupied by anyone and we say Ci,j is free. But note that Ci,j can be free but not ready. Now, we show how we make sure that for some j, Ci,j is ready when we want to start the initialization of D′i. In the beginning all Ci,j are free. After computing F = MSF(G), we inserting Preprocessing. edges in F into all Ci,j so that all Ci,j are ready. In total, this takes additional O(L × m log m) = O(m log2 m) time to the preprocessing algorithm in Lemma 7.2. Updates. Fix any i and j. Suppose that at time τ , Ci,j was ready and then is occupied by D′i. Observe the following. At time τ + 2i, Ci,j will be occupied by Di,j ′ for some j′ ∈ {1, 2} as we set Di,j ← D′i. Then, at time τ + 3 · 2i, Ci,j will be occupied by Di,j ′′ for some j′′ ∈ {3, 4} as we set Di,j ′′ ← Di,j ′. Then, at time τ + 5 · 2i, Ci,j will be free. Then, during the next 2i steps, we will make sure that Ci,j is ready by spending time O(B log m) per step. Let Fτ be the MSF that Ci,j was running on at time τ . When Ci,j become occupied, we will maintain the difference of edges in Fτ and the current MSF F . At time τ + 5 · 2i, the difference between Fτ and F is at most O(B · 2i) edges. So we can update Fτ to become F in 2i steps, using O( B2i log m ) = O(B log m) time per step. Summing over all i and j, this takes additional O(L × B log m) = O(B log2 m) time per step to the update algorithm in Lemma 7.2. Therefore, for any fixed i, only every 2i steps one of Ci,j can changed from being ready to being occupied. But in the next 6·2i steps such Ci,j will become ready. As we have 6 instances Ci,1, . . . ,Ci,6. At any time, when we want to start the initialization of D′i, Ci,j is ready for some j. 2i 27 Proof of Lemma 7.24. Recall that A is the algorithm from the assumption of Lemma 7.24 with preprocessing time tpre(m′, p) and update time tu(m′, p), and B is the resulting algorithm of Lemma 7.24 with preprocessing time t′pre(m, k, B, p) and update time t′u(m, k, B, p). Let A′ be a decremental MSF algorithm runs on graphs with m-edge and k-non-tree-edge with parameter p. Denote the preprocessing time of A′ by tA′ pre(m, k, p) and the update time of A′ by tA′ u (m, k, p). To prove Lemma 7.24, we will use Lemma 7.2 to first reduce B to A′. Then, with additional preprocessing time of O(m log2 m) and update time of O(B log2 m), the argument above shows that we can further reduce A′ to A using Lemma 7.23. That is, we have tA′ pre(m, k, p) = tpre(5k, p) + O(k log m) and tA′ u (m, k, p) = tu(5k, p) + O(log m). Hence, the preprocessing of B is t′pre(m, k, B, p) + O(m log2 m) = tA′ pre(m, k, p′) + O(m log m) + O(m log2 m) by Lemma 7.2 = tpre(5k, p′) + O(m log2 m), and the update time of B is t′u(m, k, B, p) + O(B log2 m) = O( = O( ⌈log k⌉Xi=0 ⌈log k⌉Xi=0 tA′ pre(m, min{2i+1B, k}, p′)/2i + B log m + log k · tA′ u (m, k, p′)) + O(B log2 m) by Lemma 7.2 tpre(5 · min{2i+1B, k}, p′)/2i + B log m + log k · tu(5k, p′)) + O(B log2 m) = O( B log k k · tpre(5k, p′) + B log2 m + log k · tu(5k, p′)). The last equality follows because we claim that tpre(5·min{2i+1B, k}, p′)/2i = O( B see this, there are two cases. If 2i+1B ≥ k, then tpre(5·min{2i+1B,k},p′) If 2i+1B < k, then tpre(5·min{2i+1B,k},p′) 2i−1· where the inequality is because tpre(k, p′) is at least linear in k. This concludes the proof. 2i−1 = O( B = O( B k )·tpre(5k, p′). To k )·tpre(5k, p′). k ) · tpre(5k, p′) = tpre(5k,p′) ,p′) k = tpre(5·2i+1B,p′) 2i−1 tpre(5·2i+1B· 2i+1B k 2i+1B 2i−1 ≤ 2i−1 7.4 Reduction to Restricted Decremental Algorithm for Few Edges The final step is apply the following standard reduction: Proposition 7.25. Suppose there is an algorithm A as in Theorem 7.1. Then, there is a decremental MSF algorithm A′ for any m′-edge graph with preprocessing time O(m′) + tpre(3m′, p/3) and update time O(m′/T (m′)) + 3tu(3m′, p/3) with probability 1 − p. From Lemma 7.24, we immediately obtain Theorem 7.1. Proof of Theorem 7.1. Given the algorithm A, by Proposition 7.25 there is an algorithm A′ for any m′-edge graph with preprocessing time tA′ pre(m′, p) = O(m′) + tpre(3m′, p/3) and update time tA′ u (m′, p) = O(m′/T (m′)) + 3tu(3m′, p/3) with probability 1 − p. Plugging A′ to Lemma 7.24, we obtain the resulting algorithm B of Theorem 7.1 that can run on any m-edge graph with at most k non-tree edges. Let p′ = O(p/ log k) be from Theorem 7.1 and p′′ = p′/3. B has the preprocessing time 28 t′pre(m, k, B, p) = tA′ pre(5k, p′) + O(m log2 m) = tpre(15k, p′′) + O(m log2 m), and B has the update time t′u(m, k, B, p) = O( B log k k = O( = O( B log k k B log k k · tA′ pre(5k, p′) + B log2 m + log k · tA′ · (k + tpre(15k, p′′)) + B log2 m + log k · ( · tpre(15k, p′′) + B log2 m + k log k T (k) u (5k, p′)) k + log k · tu(15k, p′′)). + 3tu(15k, p′′))) T (k) 8 MSF Decomposition In this section, we show an improved algorithm for computing a hierarchical decomposition of a graph called MSF decomposition. This decomposition is introduced by Wulff-Nilsen [37, Section 3.1] and it is the main subroutine in the preprocessing algorithm of his dynamic MSF algorithm and also of ours. Our improved algorithm has a better trade-off between the running time and the "quality" of the decomposition as will be made precise later. The improved version is obtained simply by using the flow-based expansion decomposition algorithm13 by Nanongkai and Saranurak [24] as the main subroutine, instead of using diffusion/spectral-based algorithms as in [37]. Moreover, as the expansion decomposition algorithm is defined based on expansion (which is defined in Section 8.1) and not conductance, this is easier to work with and it simplifies some steps of the algorithm in Section 8.1. Before stating the main result in Theorem 8.3, we need the following definition: Definition 8.1 (Hierarchical Decomposition). For any graph G = (V, E), a hierarchical decompo- sition H of G is a rooted tree. Each node C ∈ H corresponds to some subgraph of G which is called a cluster. There are two conditions that H needs to satisfy: 1) the root cluster of H corresponds to the graph G itself, 2) for each non-leaf cluster C ∈ H, let {C′i}i be the children of C. Then vertices of {C′i}i form a partition of vertices in C, i.e. V (C) = SiV (C′i). The root cluster is a level-1 cluster. A child of level-i cluster is a level-(i + 1) cluster. The depth of H is the depth of the tree. Let EC = E(C) − SiE(C′i) be the set of edges in C which are not edges in any of C′i's. We call an edge e ∈ EC a C-own edge, and an edge f ∈ E(C) − EC = SiE(C′i) a C-child edge. We note that, for any cluster C with a child C′, it is possible that E(C′) ( E(C[V (C′)]). That is, there might be some edge e = (u, v) ∈ E(C) where u, v ∈ V (C′) but e /∈ E(C′). In other words, there can be a C-own edge (u, v) where both u, v ∈ V (C′). Observe the following: Fact 8.2. Let H be a hierarchical decomposition of a graph G = (V, E). Then SC∈HEC = E. weights ranging from number 1 to m. Throughout this section, let γ = nO(√log log n/ log n) = no(1) Throughout this section, we assume that, in an input graph with m-edge, the edges have distinct where n is the number of nodes in a graph. The main result of this section is the below theorem: 13The expansion decomposition algorithm was used as a main preprocessing algorithm for their dynamic SF algo- rithm. 29 Theorem 8.3. There is a randomized algorithm called MSF decomposition, MSFdecomp, which takes the following as input: • a connected graph G = (V, E, w) with n nodes, m edges and max degree 3, where w : E → {1, . . . , m} is the weight function of edges in G, d ≥ 3, slow and shigh where shigh ≥ slow. • a failure probability parameter p ∈ (0, 1], a conductance parameter α ∈ [0, 1], and parameters p ) where γ = nO(√log log n/ log n), the algorithm returns (i) a graph G′ = (V, E, w′) with a new weight function w′ : E → R and (ii) a hierarchical decomposition H of the re-weighted graph G′ with following properties: In time O(ndγ log 1 1. For all e ∈ E, w′(e) ≥ w(e). 2. {e ∈ E w(e) 6= w′(e)} ≤ αdγn.14 3. For any cluster C ∈ H and any set of edges D, MSF(C − D) = SC ′:child of C MSF(C′ − D) ∪(MSF(C − D) ∩ (EC − D)). 4. H has depth at most d. 5. A cluster C is a leaf cluster iff E(C) ≤ shigh. 6. Each leaf cluster contains at least slow/3 nodes. 7. For level i, SC:non-leaf, level-iEC ≤ n/(d − 2) + αγn. 8. With probability 1 − p, all non-root clusters C ∈ H are such that φ(C) = Ω(α/slow). We call the lower bound of conductance for all non-root clusters is the conductance guarantee of the hierarchical decomposition H, which is Ω(α/slow) in our algorithm. Compared with the MSF decomposition algorithm in [37, Section 3.1], our algorithm runs significantly faster and has a better trade-off guarantee between conductance of the cluster and the number of edges re-weighted. In particular, the running time of our algorithm does not depends on the conductance parameter α. Now, we give some intuition why this decomposition can be useful in our application. Given an input n-node graph G, we set α = 1/γ3, d = γ, slow = γ, and shigh = n/γ. The algorithm increases the weight of only (1/γ)-fraction of edges resulting in the re-weighted graph G′, and then it outputs the hierarchy decomposition H of G′. Property 3 of H is crucial and it implies that MSF(G′) = SC∈H(MSF(C)∩ EC ), and this holds even after deleting any set of edges. This suggests that, to find MSF(G), we just need separately find MSF(C) ∩ EC, i.e., the C-own edges that are in MSF(C), for every cluster C ∈ H. That is, the task of maintaining the MSF is also "decomposed" according the decomposition. Other properties are about bounding the size of some sets of edges and the conductance of clusters. These properties will allow our dynamic MSF algorithm to have fast update time. The rest of this section is for proving Theorem 8.3. 14We can actually prove that {e ∈ E w(e) 6= w′(e)} ≤ O(αγn) but this does not improve the running time significantly. 30 8.1 Expansion Decomposition that Respects a Given Partition The expansion decomposition algorithm [24] is an algorithm that, roughly, given a graph G = (V, E), it outputs a partition Q = {V1, . . . , Vk} of V such that, for each i, G[Vi] has no sparse cuts and there are not many edges crossing different parts of Q. The goal of this section is to extend the algorithm to ensure that each part Vi is not too small. See Lemma 8.5 for the precise statement. This requirement is needed for the construction of the MSF decomposition, as shown in [37], because each leaf cluster must not be too small (Property 6 in Theorem 8.3). The algorithm in this subsection speeds up and simplifies the algorithm in [37, Section 6] which does the same task. Before stating Lemma 8.5, we need the following definition. Definition 8.4. Let P be a partition of set V . We say that a set S ⊂ V respects P if for each set U ∈ P, either U ⊆ S or U ∩ S = ∅. Let Q be another partition of V . We say that Q respects P if, for each set S ∈ Q, S respects P. We prove the following extended expansion decomposition algorithm: Lemma 8.5. There is a randomized algorithm A that takes as inputs a connected graph G = (V, E) with n-node and max degree 3, a partition P of V where, for each set of nodes U ∈ P, G[U ] is connected and c0s ≤ U ≤ s for some constant c0, a conductance parameter α ∈ [0, 1], and a failure probability parameter p. Then, in time O(nγ log 1 p ), A outputs a partition Q = {V1, . . . , Vk} of V with the following properties: 1. Q respects P. 2. {(u, v) ∈ E u ∈ Vi and v ∈ Vj where i 6= j} ≤ αγn. 3. For all Vi ∈ Q, G[Vi] is connected. With probability 1 − p, for all Vi ∈ Q, φ(G[Vi]) = Ω(α/s). Note that by giving a partition P where each U ∈ P has size around s, the algorithm in Lemma 8.5 will output the partition Q where each part Vi ∈ Q has size at least Ω(s). To prove this, we use the expansion decomposition algorithm by Nanongkai and Saranurak [24] in a black-box manner. Before stating the algorithm in Lemma 8.7, we recall that, for any graph G = (V, E), the expansion of G is h(G) = minS⊂V . Note the following connection to conductance: min{S,V −S} δ(S) Fact 8.6. In any connected graph G = (V, E) with max degree ∆ = O(1), φ(G) = Θ(h(G)). Proof. For any set S ⊂ V , we have vol(S) ≥ S as G is connected, and vol(S) ≤ ∆S as G has ) for all S ⊂ V , max degree ∆. So vol(S) = Θ(S). Hence, and so φ(G) = Θ(h(G)). min{vol(S),vol(V −S)} min{S,V −S} δ(S) = Θ( δ(S) Lemma 8.7 (Expansion Decomposition [24] (Paraphrased)). There is a randomized algorithm A that takes as inputs a (multi-)graph G = (V, E) with n ≥ 2 vertices and m edges and an expansion parameter α > 0, and a failure probability parameter p. Then, in O(mγ log 1 p ) time, A outputs a partition Q = {V1, . . . , Vk} of V , 1. {(u, v) ∈ E u ∈ Vi and v ∈ Vj where i 6= j} ≤ αγn. 2. With probability 1 − p, for all Vi ∈ Q, h(G[Vi]) ≥ α. 31 The algorithm for Lemma 8.5 is very simple. Given a graph G = (V, E) and a partition P, we contract each set of nodes U ∈ P into a single node resulting in a contracted graph GP . Then run the expansion decomposition in Lemma 8.7 on GP and obtain the partition Q′ of nodes in GP . We just output Q which is obtained from Q by "un-contracting" each set of P. Now, we show the correctness of this simple approach. Lemma 8.8. Let G = (V, E) be a graph with max degree ∆ and P be a partition of V where, for each set of nodes U ∈ P, G[U ] is connected and U ≤ s. Let GP be a graph obtained from G by contracting each set U ∈ P into a single node. If h(G) ≤ 1 = h(G). Next, consider another cut S′ ⊂ V in Proof. Consider a cut S ⊂ V in G where G where S′ is the union of all sets U ∈ P such that U ⊆ S. Clearly, S′ ⊆ S and so V −S′ ≥ V −S. We claim that S′ ≥ S/2. Let PS be the collection of set U which contain nodes both in S and V − S. Note that δ(S) ≥ PS because, for each U ∈ PS, G[U ] is connected. We have 2s , then h(GP ) ≤ 4s2∆h(G). min{S,V −S} δG(S) S′ = S − XU∈PS U ∩ S ≥ S − sPs ≥ S − sδG(S) ≥ S − sh(G)S ≥ S/2 Next, we bound δG(S′). Note that as U ≤ s as h(G) ≤ 1 2s . E(U, S′) δG(S′) ≤ δG(S) + XU∈PS ≤ δG(S) + ∆sPS ≤ (1 + ∆s)δG(S) ≤ 2∆sδG(S). δG(S ′) 2∆sδG(S) 1 min{S ′,V −S ′} ≤ P ) = δG(S′) because S′ respects P. Also, sS′ Therefore, we have that hG(S′) = P be a set of nodes in GP obtained from S′ by contracting each set U ∈ P into a node. Observe that δGP (S′ P ≥ V − S because U ≤ s for all U ∈ P. So, we can conclude P} ≤ 2 min{S,V −S} P ≥ S′ and sV (GP ) − S′ δGP (S′ P ) P,V (GP ) − S′ = 4∆s · h(G). Next, let S′ = s · hG(S′) ≤ 4s2∆h(G). 1 s min{S′,V − S′} h(GP ) ≤ min{S′ δG(S′) Proof of Lemma 8.5. Now, we are ready the proof the main lemma. Proof of Lemma 8.5. The precise algorithm is the following. Given the input (G,P, α, p) where G has max degree ∆ = 3, we first construct a multi-graph GP = (V ′, E′) obtained from G by contracting each set U ∈ P into a node. Note that GP has at most n c0s nodes, as U ≥ c0s for all U ∈ P, and GP has O(n) edges. Then we run the expansion decomposition algorithm from Lemma 8.7 with (GP , c0sα, p) as inputs, and outputs a partition Q′ = {V ′1, . . . , V ′k} of V ′. For each V ′i ∈ Q′, let Vi ⊆ V be the set obtained from V ′i by "un-contracting" each set in U ∈ P. The 32 algorithm just returns Q = {V1, . . . , Vk} as its output. The total running time is O(nγ log 1 Lemma 8.7 and because other operations take linear time. Now, we prove the correctness. p ) by Clearly, Q respects P by constriction. Also, we have {(u, v) ∈ E u ∈ Vi, v ∈ Vj, i 6= j} = {(u, v) ∈ E′ u ∈ V ′i , v ∈ V ′j , i 6= j} = αγn, ≤ (c0sα)γ n c0s by Lemma 8.7. Next, note that φ(G[Vi]) = Θ(h(G[Vi])) by Fact 8.6 and the fact that G has max degree 3. So it is enough to show that h(G[Vi]) = Ω(α/s) for all i with probability 1 − p. By Lemma 8.8, for all 1 ≤ i ≤ k, we have that if h(G[Vi]) < h(GP [V ′i ])/4s2∆, then h(G[Vi]) > 1/2s = Ω(α/s) and we are done. So we assume otherwise, which means that h(G[Vi]) ≥ h(GP [V ′i ])/4s2∆ ≥ c0sα/4s2∆ = Ω(α/s) for all 1 ≤ i ≤ k with probability 1 − p. We note that we can additionally make sure that G[Vi] is connected with certainty in linear time. This concludes the proof. 8.2 MSF Decomposition Algorithm In this section, we just plug the extended version of the expansion decomposition algorithm from Section 8.1 to the approach by Wulff-Nilsen [37] for constructing the MSF decomposition. One minor contribution of this section is that we present the MSF decomposition in a more modular way than how it is presented in [37]. In particular, we list and prove all the needed properties of the MSF decomposition here and hide all the implementation details from the other sections. In particular, the notion of M -clusters (as defined below) is hidden from other sections. We hope that this facilitate the future applications of this decomposition. First, we need the following algorithm by Frederickson: Lemma 8.9 (Frederickson [11]). There is an algorithm which takes as input a tree T = (V, E) with n nodes and max degree 3 and a parameter s. Then, in O(n) time, the algorithm outputs a partition C = {Vi}i of V where s/3 ≤ Vi ≤ s and T [Vi] is connected for all i. The algorithm MSFdecomp(G, p, α, d, slow, shigh) for Theorem 8.3 is as follows. First, we compute the MSF M of G. Then, given (M, slow) to Lemma 8.9, we compute the outputted partition PM called M -partition. For each V ′ ∈ PM , we call M [V ′] an M -cluster. Denote by CM and E(CM ) the set of M -clusters and the union of edges of M -clusters respectively. Note that CM is just a forest where each tree has size between slow/3 and slow. Next, let d′ = d − 2. For 1 ≤ i ≤ d′, we denote d′ , m − (i − 1) m by Ei the set of edges of weights in the range (m − i m d′ ] which are not in E(CM ). For any i > d′, let Ei = ∅. Finally, we call Build(G,PM , 1) from Algorithm 8.1. Let ExpDecomp denote the extended expansion decomposition algorithm from Lemma 8.5. 8.2.1 Analysis First, we note that, in Step 2.a, a valid input is given to Lemma 8.5: Proposition 8.10. In the recursion by invoking Build(G,PM , 1), if Build(C,P, i) is called, then P is a partition of V (C). Moreover, P ⊆ PM . Proof. We prove by induction. The base case is trivial because PM is a partition of V (G). Next, by induction hypothesis, suppose that P is a partition of V (C) and P ⊆ PM . So (C,P, α, p/n) is a 33 The numbers n, m, p, α, d, slow, shigh are fixed by the input of Theorem 8.3. 1. If E(C) ≤ shigh, return. // i.e. C is a leaf cluster. 2. Else, // i.e. C is a non-leaf cluster. (a) Compute Q = ExpDecomp(C,P, α, p/2n). Write Q = {V 1, . . . , V k}. (b) For all j ≤ k, set C j = (V j, Ej) where Ej = E(C[V j]) − Ei as a child cluster of C. (c) Set EC = E(C) − SjEj as a set of C-own edges. (d) For all e ∈ EC , set w′(e) ← max{w(e), m − i m (e) For all j ≤ k, run Build(C j,P j, i + 1) where P j = {V ′ ∈ P V ′ ⊆ V j}. d′ + 0.5} Algorithm 8.1: Build(C,P, i) valid input for the algorithm from Lemma 8.5 in Step 2.a. Let Q = {V 1, . . . , V k} be the outputted partition of V (C). By Lemma 8.5, Q respects P. Therefore, for all j, P j = {V ′ ∈ P V ′ ⊆ V j} in Step 2.e is actually a partition of V j. That is, for all child clusters C j of C, when Build(C j,P j, i) is called, P j is a partition of V (C j) = V j and P j ⊆ P ⊆ PM . As all the steps are valid, we obtain a hierarchical decomposition denoted by H with the following basic properties. Proposition 8.11. We have the following: 1. Build(G,PM , 1) returns a hierarchical decomposition H. 2. For any cluster C ∈ H, V (C) respects PM . 3. A cluster C ∈ H is a leaf cluster iff C has at most shigh edges. Moreover, each leaf cluster contains at least slow/3 nodes. 4. With probability 1 − p, all non-root clusters C ∈ H are such that φ(C) = Ω(α/slow). Proof. (1): There are two conditions we need to show about H. First, the root cluster clearly corresponds to the graph G itself. Next, for any non-leaf cluster C, let C 1, . . . , C k be the children of C. We have that {V (C 1), . . . , V (C k)} is a partition of V (C) by Lemma 8.5 used in Step 2.a. (2): This follows from Proposition 8.10. (3): The first statement is by Step 1. For the second statement, for all clusters C ∈ H, V (C) (4): By Step 2.a, all non-root clusters C is outputted from Lemma 8.5. Since Lemma 8.5 is respects PM . So V (C) ≥ slow/3. called at most 2n times, the claim holds with probability 1 − 2n · p 2n = 1 − p. In the outputted hierarchical decomposition H, observe that C ∈ H is a level-i cluster iff Build(C,P, i) is called in the level-i recursion when we call Build(G,PM , 1). For any i, let E≥i = Sj≥iEj. Note that, for i > d′, E≥i = ∅. By Step 2.b of Algorithm 8.1, observe the following: Proposition 8.12. For any level-i cluster C, E(C) ⊆ E≥i ∪E(CM ). Lemma 8.13. H has depth at most d. 34 Proof. Recall that d = d′ + 2. Let C′ be a level-(d′ + 2) cluster and C be the parent cluster of C′. Since C is a level-(d′ + 1) cluster, by Proposition 8.12, E(C) ⊆ E(CM ). This means that, C is a forest. As C′ is connected by Lemma 8.5, C′ cannot intersect more than two M -clusters. So V (C′) ≤ slow and, hence, E(C′) ≤ slow. As slow ≤ shigh, C′ must be returned as a leaf cluster by Step 1. For any level-i non-leaf cluster C, let Ei(C) = Ei ∩ E(C) and let ∂C be the set of edges whose endpoints are in different child clusters. By Step 2.b and Step 2.c, observe the following: Proposition 8.14. For any level-i non-leaf cluster C, the set of C-own edges is EC = Ei(C)∪ ∂C. We note that Proposition 8.14 is not true for a leaf cluster C because EC may contains some Having this claim, the lemma follows because the recursion depth is at most d by Lemma 8.13, and, for any depth i, any two level-i clusters C and C′ are node-disjoint. M -cluster edges (i.e. E(CM )). Lemma 8.15. {e ∈ E w(e) 6= w′(e)} ≤ αdγ · n. Proof. For any level-i cluster C ∈ H, we claim that (cid:8)e ∈ EC w(e) 6= w′(e)(cid:9) ≤ αγ · V (C). Suppose that C is a level-i cluster. If C is a leaf cluster, then(cid:8)e ∈ EC w(e) 6= w′(e)(cid:9) = ∅. So we assume C is a non-leaf cluster. By Proposition 8.14 EC = Ei(C) ∪ ∂C. For any edge e ∈ Ei(C), we have w(e) ≥ m − i m d′ + 1, so w′(e) = w(e) by Step 2.d. So {e ∈ E(C) w(e) 6= w′(e)} ⊆ ∂(C). By Lemma 8.5, ∂C ≤ αγ · V (C). So this concludes the claim. Lemma 8.16. For level i, SC:non-leaf, level-iEC ≤ n/(d − 2) + αγn. ∂C ⊆ Ei ∪ SC∈Ci and hence SC∈Ci EC = SC∈Ci Ei(C)∪ ∂C. We have Ei ≤ n/d′ = n/(d − 2). Also, by Lemma 8.5, ∂C ≤ αγ · V (C) ∂C ≤ αγn because any two level-i clusters C and C′ are node-disjoint. Proof. Let Ci be the set of level-i non-leaf clusters. By Proposition 8.14, Lemma 8.17. For any cluster C ∈ H and any set of edges D, SC∈Ci MSF(C − D) = MSF(C′ − D) ∪(MSF(C − D) ∩ (EC − D)). Proof. We only prove that SC ′:child of C MSF(C′) ∪(MSF(C)∩EC) = MSF(C). The lemma follows by observing that the argument holds true even when the set of edges D are removed from all clusters. We write [C ′:child of C E(C) = EC ∪ = EC ∪( E(C′) [C ′:child of C [C ′:child of C E(C′) ∩ E(CM )) ∪( E(C′) − E(CM )). [C ′:child of C E(CM ) ⊆ MSF(G) and C is a subgraph of G where some edges not in E(CM ) have their weight increased. This means that we can construct MSF(C) using an instance I of Kruskal's algorithm First, we know that edges in SC ′:child of CE(C′) ∩ E(CM ) are tree-edges in MSF(C) because where the initial forest is the edges in SC ′:child of C E(C′) ∩ E(CM ). Next, suppose that C is a level-i cluster. So SC ′:child of C E(C′) − E(CM ) ⊆ E≥i+1 by Propo- sition 8.12. By Step 2.d, any C-own edge e ∈ EC is heavier than any E≥i+1. So the instance I 35 will scan all edges in SC ′:child of CE(C′) − E(CM ) before any edges in EC . After finishing scanning SC ′:child of CE(C′) − E(CM ), I has constructed, as a part of MSF(C), the following: MSF(cid:18)( [C ′:child of C [C ′:child of C [C ′:child of C E(C′) ∩ E(CM )) ∪( E(C′)) E(C′) − E(CM ))(cid:19) Since there are only the edges in EC that I have not scanned yet, this means that [C ′:child of C = MSF( = MSF(C′) as C′'s are node disjoint. [C ′:child of C MSF(C′) ∪(MSF(C) ∩ EC) = MSF(C). p ). Lemma 8.18. The MSF decomposition algorithm MSFdecomp(G, p, α, d, slow, shigh) runs in time O(ndγ log 1 Proof. The bottleneck is the time for calling Build(G,PM , 1). For any level-i cluster C ∈ H, when Build(C,P, i) is called, this takes time O(αγV (C) log n p ) excluding the time in the further recursion. Again, the lemma follows because the recursion depth is at most d by Lemma 8.13, and, for any depth i, any two level-i clusters C and C′ are node-disjoint. Proposition 8.11, Lemma 8.13, Lemma 8.15 and Lemma 8.17 concludes the correctness of The- orem 8.3. Lemma 8.18 bounds the running time. 9 Dynamic MSF Algorithm In this section, we prove the main theorem: Theorem 9.1. There is a fully dynamic MSF algorithm on an n-node m-edge graph that has p ) and worst-case update time preprocessing time O(m1+O(√log log m/ log m) log 1 O(nO(log log log n/ log log n) log 1 p ) = O(m1+o(1) log 1 p ) with probability 1 − p. p ) = O(no(1) log 1 By using a standard reduction or a more powerful reduction from Theorem 7.1, it is enough to show the following: Lemma 9.2. There is a decremental MSF algorithm A on an n-node m-edge graph G with max de- gree 3 undergoing a sequence of edge deletions of length T = Θ(n1−O(log log log n/ log log n)). A has pre- processing time O(n1+O(√log log n/ log n) log 1 p ) and worst-case update time O(nO(log log log n/ log log n) log 1 p ) with probability 1 − p. We note that essentially all the ideas in this section, in particular the crucial definition of compressed clusters, already appeared in Wulff-Nilsen [37]. In this section, we only make sure that, with our improved tools from previous sections, we can integrate all of them using the same approach as in [37]. Obviously, the run time analysis must change because our algorithm is faster and need somewhat more careful analysis. Although the correctness follows as in [37], the terminology changes a bit because MSF decomposition from Theorem 8.3 is presented in a more modular way. The high-level idea in [37] of the algorithm A is simple. To maintain MSF(G), we maintain a graph H, called the sketch graph, where at any time MSF(G) = MSF(H) and H contains only few non-tree edges with high probability. Then we just maintain MSF(H) using another algorithm for graphs with few non-tree edges. 36 Organization. The rest of this section is for proving Lemma 9.2. In Section 9.1, we describe the whole algorithm which combines all the tools from previous sections. The preprocessing algorithm is in Section 9.1.1 and the update algorithm is in Section 9.1.2. We summarize all the main notations in Table 1. Next, in Section 9.2, we show that the sketch graph H is indeed maintained such that MSF(G) = MSF(H) (shown in Section 9.2.1) and H has few non-tree edges (shown in Section 9.2.2). Note that this implies that MSF(G) is correctly maintained. Lastly, we analyze the running time in Section 9.3. We first bound the preprocessing time in Section 9.3.1, the time needed for maintaining the sketch graph H itself in Section 9.3.2, and the time needed for maintaining MSF(H) in H in Section 9.3.3. We put everything together and conclude the proof in Section 9.3.4. 9.1 The Algorithm For any number m and p ∈ (0, 1), in this section, the goal is to describe the decremental MSF algorithm A(m, p) for any m-edge graph G = (V, E, w) with max degree 3 such that A(m, p) can handle T (m) edge deletions and, with probability 1 − p, has preprocessing and update time tpre(m, p) and tu(m, p). We will show that tpre(m, p) = O(m1+O(√log log m/ log m) log 1 p ), tu(m, p) = O(mO(log log log m/ log log m) log 1 p ) and T (m) = Θ(m1−O(log log log m/ log log m)). This will imply Lemma 9.2. By induction on m, we assume that, for any m0 ≤ m − 1 and p0 ∈ (0, 1), we have obtained the decremental MSF algorithm A(m0, p0) that can run on any m0-edge graph G0 with max degree 3 undergoing a sequence edge deletions of length T (m0). Let tpre(m0, p0) and tu(m0, p0) denote the preprocessing and update time of A on G0, respectively, that hold with probability at least 1 − p0. By this assumption, Theorem 7.1 implies the following. For any number m1, k1, B1 and p1 ∈ (0, 1) where k1 ≤ (m − 1)/15, there is a fully dynamic algorithm Af ew(m1, k1, B1, p1) that can run on any (multi-)graph G1 with at most m1 edges and at most k1 non-tree edges. Moreover Af ew(m1, k1, B1, p1) can handle inserting a batch of edges of size B1. Let tf ew pre (m1, k1, B1, p1), tf ew ins (m1, k1, B1, p1), tf ew del (m1, k1, B1, p1) denote the preprocessing time, the batch insertion time, and the deletion time of Af ew(m1, k1, B1, p1) respectively, that hold with probability at least 1− p1. Below, we will slightly abuse notation. For any graph G2, and parameters B2 and p2, we denote Af ew(G2, B2, p2) as an instance of Af ew(m2, k2, B2, p2) running on G2 with at most m2 edges and k2 non-tree edges. In the following subsections, we will first describe how we preprocess the input graph G for A(m, p) in Section 9.1.1. In the process, we introduce several definitions related to compressed clusters which were defined in [37] and will be the central definitions of our algorithm. Then, we describe how we update in Section 9.1.2. 9.1.1 Preprocessing and Definitions Related to Compressed Clusters Let n be the number of nodes in G. We can assume that G is initially connected otherwise we run the algorithm on each connected component of G. So n = Θ(m) initially. Since we will handle only T (m) = o(m) edge deletions, we have n = Θ(m) at all time. Let γ = nO(√log log n/ log n) be the factor from Theorem 8.3. We run the MSF decomposition algorithm MSFdecomp(G, α, p, d, slow, shigh) where α = 1/γ3, d = γ, slow = γ, and shigh = n/γ. So we obtain a re-weighted graph G′ = (V, E, w′) together with its hierarchical decomposition H with conductance guarantee α0 = Ω(α/slow) = Ω(1/γ4). We denote by E6= = {e ∈ E w(e) 6= w′(e)} the set of re-weighted edges. Let E6=(w) and E6=(w′) be the set of weighted edges from E6= where the weight of e is w(e) and w′(e) respectively. By Theorem 8.3, we know that a cluster C ∈ H is a leaf cluster iff E(C) ≤ shigh (before any edge deletion). For convenience, we call each leaf cluster a 37 small cluster and non-leaf cluster a large cluster. For any child cluster C′ of C, we say C′ is a small (large) child of C iff C′ is a small (large) cluster. Proposition 9.3. Any cluster C ∈ H has at most O(n/shigh) large child clusters. Proof. All the large children of C are edge-disjoint and each of them contains at least shigh edges. by separately initializing A(C, p) on each small cluster C. (Note that we E(C) ≤ shigh ≤ m − 1 and so we can initialize A on C by our assumption.) For any large cluster C, let Msmall(C) = disjoint, we have the following: Let Gsmall = SC:smallC. be the union of all small clusters. We maintain the MSF Msmall of Gsmall SC ′:small child of C MSF(C′). As every small cluster has a unique parent and small clusters are node- Proposition 9.4. Msmall = SC:largeMsmall(C). For each large cluster C ∈ H excluding the root cluster, we initialize the dynamic pruning algorithm Pruning on C using Theorem 6.1 with a conductance parameter α0. Whenever some edge in C is deleted, Pruning will update a set P C 0 = ∅. Let π denote the update time of Pruning on each C. Given that the sequence of edge deletions in C is at most O(α2 0 ⊆ V (C) of nodes in C. Initially, P C 0E(C)) (as we will show later), as α0 = 1/nO(q log log n log n ), we have π = nO(log log(q log n log log n )/ log(q log n log log n )) log 1 p = nO(log log log n/ log log n) log 1 p by Theorem 6.1. For each large cluster (including the root cluster) C ∈ H, it is more convenient to define P C as a union of P C ′ 0 . We call P C the total pruning set of C. Recall the definition of C-own edges EC from Definition 8.1. For any (U ) = {(u, v) ∈ EC u ∈ U or v ∈ U} the set of C-own edges incident set U ⊆ V (C), denote by E to U . 0 over all large child cluster C′ of C. That is, P C = SC ′:large child of CP C ′ C Now, we define an important definition called compressed clusters. Definition 9.5. For any large cluster C and any set of nodes U ⊆ SC ′:large child of CV (C′), the compressed cluster of C with respect to U , denoted by C(U ) is obtained from C by 1) replacing each small child C′ by MSF(C′), and 2) contracting nodes in each large child cluster C′ into a single node (called super node), and 3) removing edges (used to) incident to U , i.e. removing E (U ). C For convenience, we define the contraction in the step 2 above such that all C-own edges are preserved. That is, all the self loops are removed except the ones which are C-own edges. Let EC(U ) = EC − E (U ) be the set of C-own edges which is not incident to U . The following observation shows some basic structure of C(U ): Proposition 9.6. For any large cluster C ∈ H and U ⊆ V (C), we have C • E(C(U )) = Msmall(C) ∪EC(U ), and • Msmall(C) ⊆ MSF(C(U )). Proof. For the first statement, we partition edges in the cluster C into C-child edges in small children of C, C-child edges in large children of C, and C-own edges. Recall the definitions from Definition 8.1. That is, E(C) = [C ′:small child of C E(C′) ∪ [C ′:large child of C E(C′) ∪ EC. 38 We show how E(C) is changed during the process of constructing C(U ). First, replacing each small child C′ of C by MSF(C′) is to replace SC ′:small child of CE(C′) by Msmall(C). Second, contracting the large children of C is to remove SC ′:large child of CE(C′). Third, as U ⊆ SC ′:large child of CV (C′), re- moving edges incident to U is to replace EC by EC(U ). So we have that E(C(U )) = Msmall(C) ∪EC(U ). For the second statement, by Theorem 8.3, we have MSF(C) ⊇ [C ′:child of C MSF(C′) = Msmall(C) ∪ [C ′:large child of C MSF(C′). Let bC be obtained from C after replacing each small child C′ by MSF(C′) and contracting large children. Note that C(U ) can be obtained from bC by removing all edges incident to U . We claim that Msmall(C) ⊆ MSF(bC). Indeed, contracting large children of C is the same as contracting edges in SC ′:large child of C MSF(C′). But SC ′:large child of C MSF(C′) ⊆ MSF(C), so the remaining MSF- edges do not change. So Msmall(C) ⊆ MSF(bC). As U ⊆ SC ′:large child of CV (C′), the set of edges incident to U is disjoint from Msmall(C), so Msmall(C) ⊆ MSF(C(U )). Let SC(U ) ⊆ V (C(U )) be the set of super nodes in C(U ). By Proposition 9.3 C has at most O(n/shigh) = O(γ) large child clusters, so we have the following: Proposition 9.7. SC(U ) = O(γ). i ∪EC(U ) 2 ∪EC(U ) 3 1 where EC(U ) Next, we partition EC(U ) = EC(U ) is the set of edges e ∈ EC(U ) where (i − 1) endpoints of e are incident to SC(U ). Let C i(U ) = (V (C), Msmall(C) ∪EC(U ) ) for all i = 1, 2, 3. The reason that it is useful to partition EC(U ) into three parts is because, for i ∈ {2, 3}, there is a small set of nodes that "cover" all non-tree edges in Ci(U ): Proposition 9.8. For i ∈ {2, 3}, all non-tree edges in Ci(U ) are incident to SC. Proof. By Proposition 9.6, we have that Msmall(C) ⊆ MSF(C i(U )). So all non-tree edges in Ci(U ) can only be edges in EC(U ) is incident to SC. for i ∈ {2, 3}, each edge e ∈ EC(U ) . By definition of EC(U ) i i i i In the algorithm, for each large cluster C, what we really maintain are always the compressed clusters with respect to P C. We define them with respect to any set U just for the analysis. So we denote C = C(P C ) and call it simply the compressed cluster of C. Also, EC, EC i and C i are similarly defined, for i = 1, 2, 3. Although two arbitrary clusters C and D in H may be not edge-disjoint, we have that this is the case for compressed clusters. Proposition 9.9. Compressed clusters are edge-disjoint. That is, for any large clusters C, D ∈ H, E(C) ∩ E(D) = ∅. Proof. Msmall(C) and Msmall(D) are disjoint by Proposition 9.4. For any set U ⊆ V (C) and U′ ⊆ V (D), EC(U ) and ED(U ′) are disjoint. This follows because EC(U ) ⊆ EC, ED(U ′) ⊆ ED, and EC ∩ ED = ∅ by Fact 8.2. So, by Proposition 9.6, E(C(U )) ∩ E(D(U′)) = ∅. For each large cluster C, we maintain MSF(C 1) using Af ew(C 1, 1, p). Next, we maintain MSF(C 2) using an instance of the algorithm A2 from Lemma 2.7. Note the constraint in Lemma 2.7 is satisfied. Indeed, Proposition 9.8 implies that every non-tree edge in C2 has exactly one endpoint in the set of super nodes SC. Moreover, every node u ∈ V (C 2) \ SC has degree at most 3 just because G has max degree 3. Next, we maintain MSF(C 3) using instances of the algorithm A3 from Lemma 2.6. 39 Remark 9.10. Note that edges in C3 consist of Msmall(C) and EC So MSF(C 3) = Msmall(C) ∪MSF(EC MSF(EC O(γ) nodes by Proposition 9.7. 3 , and they do not share endpoints. 3 ). As Msmall(C) is already maintained, it is enough to maintain 3 . This graph has only 3 ). So, actually, we run A3 on the graph consisting of edges from EC Now, we describe the main object of our algorithm. The sketch graph is H = (V, E(H)) where E(H) = E6=(w) ∪ Msmall ∪ [C:large C (E (P C) ∪ [i=1,2,3 MSF(C i) ∪ J C). (3) where J C ⊆ EC is called a set of junk edges of a large cluster C. Initially, J C = ∅ for all large cluster C. We will describe how J C is updated later. Note that H can be a multigraph because of E6=(w). Remark 9.11. For each edge MSF(C i), we include its original endpoints into E(H) and not the endpoint in the compressed cluster C where some nodes are already contracted as one node. This can be done easily by associating the original endpoints of each edge whenever we contract some nodes. The last step of our preprocessing algorithm is to initialize Af ew(H, B, p) on H and obtain MSF(H). We summarize the preprocessing algorithm in Algorithm 9.1. 1. (G′,H) = MSFdecomp(G, α, p, d, slow, shigh) where α = 1/γ3, d = γ, slow = γ, and shigh = n/γ. 2. Initialize A(C, p) for each small cluster C and obtain Msmall = MSF(Gsmall) where Gsmall = SC:smallC. 3. For each large cluster C (excluding root cluster), initialize Pruning on C with a conductance parameter α0 = Ω(1/γ4) = 1/nO(q log log n log n ). 4. For each large cluster C, (a) construct C1, C2, and C3. (b) Initialize Af ew(C1, 1, p) and obtain MSF(C1). (c) Initialize Ai(C i) and obtain MSF(C i), for i = 2, 3. 5. Construct the sketch graph H where V (H) = V and E(H) = E6=(w) ∪ Msmall ∪ [C:large (P C) ∪ [i=1,2,3 where, for each large cluster C, P C = ∅ and J C = ∅ initially. (E C MSF(C i) ∪ J C ) 6. Initialize Af ew(H, B, p) on H where B = O(πd) and obtain MSF(H). Algorithm 9.1: Preprocessing algorithm. 40 Notation Description MSFdecomp Pruning Af ew A2 A3 G = (V, E, w) γ G′ = (V, E, w′) H E(C) EC E(C) − EC E6= E6=(w), E6=(w′) Gsmall Msmall H π Msmall(C) P C 0 P C C E (U ) C(U ) C EC EC i C i J C Algorithms MSF decomposition algorithm from Theorem 8.3 Dynamic expander pruning algorithm from Theorem 6.1 Dynamic MSF for graphs with few non-tree edges obtained by induction and using Theorem 7.1 from Lemma 2.7 from Lemma 2.6 Graphs, Edges and Parameters The input graph The factor γ = nO(√log log n/ log n) from Theorem 8.3 The re-weighted graph where (G′,H) = MSFdecomp(G, α, p, d, slow , shigh) where α = 1/γ3, d = γ, slow = γ, and shigh = n/γ The hierarchical decomposition of G′ The set of edges in a cluster C ∈ H. Note that, possibly, (u, v) /∈ E(C) but u, v ∈ V (C) The set of C-own edges. EC = E(C) − SC ′:child of CE(C′) The set of C-child edges E6= = {e ∈ E w(e) 6= w′(e)} The set of edges in E6= with weight assigned by w and w′, respectively SC:smallC MSF(Gsmall) = SC:smallMSF(C) The sketch graph. See Equation (3). The update time of Pruning. π = nO(log log log n/ log log n) log 1 p . Inside a large cluster C The pruning set P C that was initialized in C SC ′:small child of C MSF(C) The total pruning set of C. P C = SC ′:large child of CP C ′ C 0 . 0 ⊆ V (C) of C maintained by an instance of Pruning (U ) = {(u, v) ∈ EC u ∈ U or The set of C-own edges incident to U . E v ∈ U}. The compressed cluster of C with respect to U . See Definition 9.5. The compressed cluster of C. C = C(P C) = (V (C), Msmall(C) ∪EC ). The set of C-own edges. EC = EC − E not incident to P C. The set of edges in e ∈ EC where (i − 1) endpoints of e are incident to super nodes in C. Note that EC = EC C i = (V (C), Msmall(C) ∪EC i ) The set of junk edges in C (P C ) is the set of C-own edges 1 ∪EC 2 ∪EC 3 . C Table 1: Definitions in Section 9 41 9.1.2 Update Now, we describe how to update the sketch graph H given an edge deletion of G, so that at every step we have MSF(G) = MSF(H) and H is extremely sparse. We will handle at most T (m) = m/(3πdγ) ≤ n/πdγ edge deletions. From now, we just write T = T (m). We describe how H changes by showing, in the following order, how we update 1) E6=(w), 2) Msmall and, for each large cluster C, 3) E (P C), 4) MSF(C i) for i = 1, 2, 3, and lastly 5) J C . C Let e be a given edge of G to be deleted. We set G ← G− e and G′ ← G′ − e. By Fact 8.2, there is the unique cluster C where e is a C-own edge (i.e. e ∈ EC). We set EC ← EC − e. In particular, all ancestor clusters C′ of C are changed: E(C′) ← E(C′) − e accordingly. For each large cluster C where e ∈ E(C), the total pruning set P C = SC ′:large child of CP C ′ is updated by the instances of Pruning that was initialized in each large child C′ of C. Recall that P C only grows. If e ∈ E6=(w), then we set E6=(w) ← E6=(w) − e. This determines the changes of E6=(w), Msmall, and E (P C ) for each large cluster C. C 0 For any large C and i = 1, 2, 3, recall that Ci = C i(P C) = (V (C), Msmall(C) ∪EC(P C ) ) is determined by P C and Msmall(C). The description above already determines how C i changes. Hence, MSF(C i) is determined as well. Finally, for J C, whenever some edge f is removed from MSF(C i), for some C and i ∈ {1, 2, 3} but f is actually not deleted from G yet, then we include f into J C as a junk edge. i Remark 9.12. We call these edges junk edges because of the following reason. Even if H did not include junk edges, then we can show that the algorithm is still correct, i.e. MSF(H) = MSF(G). However, junk edges are needed for the performance reason: Given an edge deletion in G, there can be O(πd) many edges removed fromSC:large,i=2,3 MSF(C i). But removing that many edges in H will take too much time when we recursively maintain MSF(H) in H. So we just mark these removed edges as junk edges, but do not actually remove them from H. By the way we maintain junk edges, we have: Proposition 9.13. Given an edge e to be deleted from G, only e can be removed from C (E [C:large (P C) ∪ [i=1,2,3 MSF(Ci) ∪ J C). Reporting Failure. During the sequence of updates, our algorithm might report "failure". Once there is a failure, we terminate the whole algorithm and then restart from the preprocessing. Here, we list the events such that if they happen, the algorithm will report failure. First, we report failure if any instance of A or Af ew takes time more than the time bound which is guaranteed to hold with high probability. More formally, this is when an instance A(m0, p0), for some m0, p0 takes time more than tu(m0, p0) for some update, or when an instance Af ew(m1, k1, B1, p1) takes time more than tf ew ins (m1, k1, B1, p1) for some batched insertion of size B. Second, we also report failure whenever some instance of Pruning from Theorem 6.1 reports failure. It will be shown later in Lemma 9.29 that failure happens with very low probability. del (m1, k1, B1, p1) for some edge deletion or more than tf ew 9.2 Correctness In this section, we suppose that the algorithm does not fails. (Actually, we only need that no instance of Pruning fails.) Then the sketch graph H is maintained with the two desired properties. 42 First, we show in Section 9.2.1 that H "preserves" the MSF i.e. MSF(H) = MSF(G). Second, we show in Section 9.2.2 that H is extremely sparse i.e. E(H) − MSF(H) = O(n/γ). Before proving the main goals, we prove a small technical lemma which ensures that the sequence of updates in each large cluster is not too long for the dynamic expander pruning algorithm from Theorem 6.1. Lemma 9.14. For each large cluster C, there is at most O(α2 Proof. As E(C) ≥ shigh = n/γ and α0 = Ω(1/γ4), so α2 of update sequence is T ≤ n/(πdγ) ≤ n/γ9 = O(α2 0E(C)) edge deletions in C. 0E(C) = Ω(n/γ9). But the total length 0E(C)) for large enough n. From now, in this section we assume that no instance of Pruning fails. 9.2.1 Sketch Graph Preserves MSF Now, the goal is to prove the following: Lemma 9.15. MSF(H) = MSF(G). As the algorithm maintains MSF(H), we can conclude from this lemma that MSF(G) is correctly maintained. C (P C) ∪Si=1,2,3 MSF(C i) ∪ J C ), i.e. H = H′ ∪E6=(w). We first Let H′ = Msmall ∪SC:large(E show that it suffices to show that MSF(G′) ⊆ H′. Lemma 9.16. If MSF(G′) ⊆ H′, then MSF(G) = MSF(H). Proof. Suppose that MSF(G′) ⊆ H′. Observe that H′ is a subgraph of G′, so MSF(G′) = MSF(H′). Let G′′ = G′ ∪E6=(w) be a multi-graph obtained from G′ by inserting E6=(w) into G′. Note that G′′ = G ∪E6=(w′). Since G′′ can obtained from G by inserting a parallel edge heavier than edges in G, we have MSF(G) = MSF(G′′) So MSF(G) = MSF(G′′) = MSF(G′ ∪E6=(w)) = MSF(H′ ∪E6=(w)) = MSF(H) as MSF(G′) = MSF(H′) because H = H ∪E6=(w). The following lemma implies that MSF(G′) ⊆ H′ because the root cluster of H corresponds to G′. Lemma 9.17. For any cluster C ∈ H, MSF(C) ⊆ H′. Proof. We prove by induction on the hierarchy H in a bottom-up manner. For the base case, for each leaf cluster C, MSF(C) ⊆ Msmall ⊆ H′ by definition. Next, we will prove that, for any large cluster C, MSF(C) ⊆ H′, given that MSF(C′) ⊆ H′ for all child clusters C′ of C. By Theorem 8.3, we have that MSF(C) = SC ′:child of C MSF(C′) ∪(MSF(C)∩ EC). So it suffices to show that MSF(C) ∩ EC ⊆ H′. Recall that the total pruning set of C is P C = SC ′:large child of CP C ′ 0 where C′[V (C′) − W C ′ large child C′ of C, there exists a set W C ′ assume that no instance of Pruning fails. Let W C = SC ′:large child of CW C ′ 0 . By Theorem 6.1, for each 0 ] is connected, because we 0 . We need the following 0 ⊆ P C ′ two claims: 43 C (W C). EC = MSF(D1). Claim 9.18. MSF(C) ∩ EC ⊆Si=1,2,3 MSF(C i(W C)) ∪ E Proof. Since MSF(C) = SC ′:child of C MSF(C′) ∪(MSF(C) ∩ EC) after any edge deletions by Theo- rem 8.3, one can identify MSF(C)∩ EC by running Kruskal's algorithm on C where the initial forest consists of edges in SC ′:child of C MSF(C′). In other words, let bC denote the graph obtained from C by replacing each the small child C′ by MSF(C′). Let D1 be the graph obtained from bC by contracting each connected component in SC ′:child of C MSF(C′) into a single node. By the property of Kruskal's algorithm, we have MSF(C)∩ Let D2 be the graph obtained from bC by contracting, for each large child C′ of bC, the set into a single node. Using the fact that C′[V (C′) − W C ′ V (C′) − W C ′ 0 ] is connected, we know that V (C′)−W C ′ is a subset of a connected component in MSF(C′). That is, D1 can be obtained from D2 by further contracting nodes. By Fact 2.3, MSF(D1) ⊆ MSF(D2). Since we know MSF(D1) ⊆ EC , we have MSF(D1) ⊆ MSF(D2) ∩ EC. Observe that C(W C) is exactly the graph that can be obtained from D2 by removing the nodes in W C = SC ′:large child of CW C ′ 0 . Let E′ be the edges in D2 with some endpoint incident to W C. So MSF(D2 − E′) = MSF(C(W C)). Having all these, we can conclude MSF(C) ∩ EC ⊆ MSF(D2) ∩ EC 0 0 = MSF((D2 − E′) ∪E′) ∩ EC ⊆ (MSF(D2 − E′) ∪ E′) ∩ EC = (MSF(C(W C)) ∪ E′) ∩ EC ⊆ MSF(C(W C)) ∪ E (W C) = MSF( [i=1,2,3 ⊆ [i=1,2,3 MSF(C i(W C)) ∪ E E(C i(W C))) ∪ E C C by Fact 2.2 as E′ ∩ EC = E (W C) E(C i(W C)) = E(C(W C)) C by [i=1,2,3 by Fact 2.2. C (W C) (W C) C C Claim 9.19. For i = 1, 2, 3, MSF(C i(W C)) ∪ E Proof. Let E′ = E(C i(W C)) − E(C i(P C )). Note that E′ ⊆ E (W C). Indeed, for any edge e ∈ E(C i(W C)) − E(C i(P C)), e must be a C-own edge in Ci that is incident to P C because e is removed if P C is pruned. Also, e is not incident to W C because e is not removed if W C is pruned. So we have (W C) ⊆ MSF(C i(P C )) ∪ E (P C ) − E (P C). C C MSF(C i(W C)) = MSF(C i(P C) ∪ E′) ⊆ MSF(C i(P C)) ∪ E′ ⊆ MSF(C i(P C)) ∪ (E C (P C) − E C (W C)). Applying union of E C (W C) on both sides completes the claim. by Fact 2.2 44 By the above two claims, we have that MSF(C) ∩ EC ⊆ [i=1,2,3 ⊆ [i=1,2,3 ⊆ H′ which completes the proof. MSF(C i(W C)) ∪ E C (W C) MSF(C i(P C)) ∪ E C (P C ) by Claim 9.18 by Claim 9.19 as Ci(P C ) = C i by definition, By Lemma 9.16 and Lemma 9.17, this implies Lemma 9.15. That is, MSF(H) = MSF(G). 9.2.2 Sketch Graph is Extremely Sparse The goal here is to prove the following: Lemma 9.20. E(H) − MSF(H) = O(n/γ). To prove this, we need to define some definitions. Fix i ∈ {1, 2, 3}. Let G′i = (V, Msmall ∪ SC:largeEC Recall that EC is the C-own edges in C incident whose (i− 1) endpoints are incident to super nodes i in C. Note that G′i is a subgraph of G′. We can also define a corresponding hierarchical decompo- sition Hi of G′i. For each small cluster C in H, let Ci = (V (C), MSF(C)) = (V (C), Msmall[V (C)]) be a small cluster in Hi. For each large cluster C in H, let Ci be a large cluster in Hi where V (Ci) = V (C) and the set of Ci-own edges is ECi = EC i . From this definition, for every cluster C ∈ H, there is a corresponding cluster Ci ∈ Hi. For each large cluster C ∈ H, Ci is a subgraph of the compressed cluster C. We have the following relation between C i and Ci: i ). i:child of Ci Lemma 9.21. For any large cluster C ∈ H and i ∈ {1, 2, 3}, MSF(C i) ⊆ MSF(Ci). Proof. Observe that Ci can be obtained from Ci by contracting each large child C′i of Ci into a single node. By Fact 2.3, MSF(C i) ⊆ MSF(Ci). Lemma 9.22. For any cluster Ci ∈ Hi, MSF(Ci) ⊆ MSF(G′i) . Proof. By Theorem 8.3 and the fact that G′i is a subgraph of G′. We have the following: for any cluster Ci ∈ Hi, MSF(Ci) = SC ′ MSF(C′i) ∪(MSF(Ci) ∩ ECi). In particular, MSF(C′i) ⊆ MSF(Ci) for any child cluster C′i of Ci. Therefore, MSF(Ci) ⊆ MSF(G′i) because G′i is the root cluster of Hi. Lemma 9.23. SC:large MSF(C i) \ Msmall ≤ n Proof. By Lemma 9.21 and Lemma 9.22, we haveSC:large MSF(C i) ⊆SC:large MSF(Ci) ⊆ MSF(G′i). So it suffices to bound MSF(G′i)\Msmall. Next, observe that Msmall = SCi:smallMSF(Ci) ⊆ MSF(G′i) by the definition of small Ci and Lemma 9.22. Therefore, MSF(G′i)\ Msmall is at most the number of connected components in Msmall. Before the first edge deletion, we have that all small clusters are connected and each small cluster has at least slow/3 nodes by Theorem 8.3. So there are at most slow/3 connected components in Msmall at that time. After T edge deletions, the number of connected components can be increased by at most T . So MSF(G′i) \ Msmall ≤ n slow/3 + T . slow/3 + T . n 45 Proof of Lemma 9.20. Now, we can bound the number of the non-tree edges of H. C Msmall = O( n slow/3 + T ) = O(n/γ). Next, for each edge update on each large cluster, Pruning spends time by at most π by the Proof. Recall that E(H) = E6=(w) ∪ Msmall ∪SC:large(E (P C ) ∪Si=1,2,3 MSF(C i) ∪ J C). First, by Theorem 8.3, E6=(w) ≤ αdγn = O(n/γ). Next, by Lemma 9.23, Si=1,2,3;C:large MSF(C i) \ definition of π. Therefore, PC:large P C ≤ T × πd because, for each deletion of an edge e, e is contained in at most d clusters as the depth of H is at most d by Theorem 8.3, and, for each large cluster C whose edge is deleted, P C can grow by at most π. Hence, SC:large E (P C) = O(PC:large P C) = O(T πd) = O(n/γ). Finally, we bound SC:large J C. By definition, J C contains edges that are removed from MSF(C i), over all Ci and i ∈ {1, 2, 3}, but are not deleted from G yet. So J C ⊆ E 9.3 Running Time (P C). Hence SC:large J C ≤ SC:large E (P C) = O(n/γ) as well. C C C In this section, we assume again that the algorithm does not fails. Under this assumption, we analyze the running time of the algorithm. We bound the preprocessing time in Section 9.3.1, the time needed for maintaining the sketch graph H itself in Section 9.3.2, and finally, in Section 9.3.3, the time needed for maintaining MSF(H) in H that changes more than one edge per time step. Recall the following notations. An instance A(m0, p0), for any m0 and p0, has preprocessing time tpre(m0, p0) and deletion time tu(m0, p0). Also, an instance Af ew(m1, k1, B1, p1), for any m1, k1, B1, and p1, has preprocessing time tf ew ins (m1, k1, B1, p1), and deletion time tf ew pre (m1, k1, B1, p1), batch insertion time tf ew del (m1, k1, B1, p1). 9.3.1 Preprocessing Next, we bound the preprocessing time, which in turn is needed for bounding the update time later in Lemma 9.28. Lemma 9.24. Given an n-node m-edge graph G with max degree 3 and a parameter p, Algorithm 9.1 takes O(m1+O(√log log n/ log n) log 1 p ) time. Proof. Consider each step in Algorithm 9.1. In Step 1, we just run the MSF decomposition which takes O(ndγ log 1 p ) by Theorem 8.3. In Step 2, we initialize A(C, p) for each small cluster C. This takes time p ) = O(nγ2 log 1 XC:small tpre(E(C), p) ≤ n shigh · tpre(O(shigh), p) = γ · tpre(O(n/γ), p). where the inequality is because tpre(m, p) is at least linear in m, and E(C) ≤ shigh for each small cluster C. Step 3 takes total time O(n log(1/p) · d) = O(mγ log(1/p)) because Pruning from Theorem 6.1 initializes on a large cluster C in time O(V (C) log(1/p)) and the depth of the decom- position is d. In Step 4.a, the total time for constructing all compressed clusters C and C 1, C 2, C 3 is just O(n). In Step 4.b, for each large cluster C, we initialize Af ew(C1, 1, p). Note that the set of non-tree 1 by Proposition 9.6. So the initialization takes edges in C 1 is contained in E(C 1)− Msmall(C) = EC 46 1 , 1, p) time. In total this takes time tf ew pre (E(C 1),EC XC:large pre (E(C 1),EC tf ew 1 , 1, p) = XC:large 1 ), O(p/ log n)) 1 ), O(p/ log n)) + O(E(C 1))) (tpre(O(EC = O(n) + XC:large tpre(O(EC = O(n) + X1≤i≤d XC:large, level-i ≤ O(n) + X1≤i≤d = O(n) + γ · tpre(O(n/γ), O(p/ log n)) tpre(O(n/γ), O(p/ log n)) tpre(O(EC 1 ), O(p/ log n)) by Theorem 7.1 by d = γ, O(n/γ) by Theorem 8.3 and tpre(m, p) is at least linear in m. where the inequality follows becausePC:large, level-i EC 1 ≤PC:large, level-i EC ≤ n/(d− 2) + αγn = In Step 4.c, by Lemma 2.6 and Lemma 2.7, the total time for initializing A2(C 2) and A3(C 3) over all large clusters C, is O(n) because compressed cluster are edge-disjoint and A2 and A3 have near-linear preprocessing time. In Step 5, we initialize Af ew(H, B, p). This takes time tf ew pre (E(H),E(H) − MSF(H), B, p) = tpre(O(E(H) − MSF(H)), O(p/ log n)) + O(E(H) log n) = tpre(O(n/γ), p) + O(n) by Lemma 9.20. Note that m = Θ(n). Now, we conclude that the total preprocessing time is tpre(m, p) = O(mγ2 log 1 p ) + O(γ) × tpre(O(m/γ), O(p/ log m)). To solve this recurrence, we use the following fact: Fact 9.25. Let f (n) and g(n) be a function where g(n) = Ω(n). If f (n) ≤ c· a· f (n/a) + g(n), then f (n) = O(g(n) · cloga n). Recall that γ = nO(√log log n/ log n). Let d0 = logO(γ) m = O( log m √log m log log m ) = O(q log m log log m ). After solving the recurrence, we have tpre(m, p) = O(mγ2 log logd0 m × cd0 0 ) p 1 p × mO(√1/ log m log log m)) = O(mγ2 log = O(m1+O(√log log m/ log m) log 1 p ) for some constant c0 9.3.2 Maintaining the Sketch Graph We bound the time for maintaining the sketch graph H. For convenience, we first show the following lemma. 47 Lemma 9.26. For some large cluster C and i ∈ {2, 3}, Ai(C i) takes O(γ) time to update MSF(Ci) for each edge update in E(C i). Proof. For i = 2, by Proposition 9.7 the set of super nodes SC has size SC = O(γ). So Lemma 2.7, A2(C 2) has O(γ) update time. For i = 3, by Remark 9.10, the graph that A3(C 3) actually runs on 3 , and this graph has O(γ) nodes. So each update takes O(γ) is induced by the set of edges in EC time by Lemma 2.6. The next lemma bounds the time for maintaining the sketch graph H. Lemma 9.27. Suppose that the algorithm does not fail. For each edge deletion in G, H can be updated in time tu(n/γ, p) + tf ew ins (n, O(n/γ), 1, p) + O(πγ2). Moreover, there are at most 2 edge deletions and B = O(πγ) edge insertions in H. del (n, O(n/γ), 1, p) + tf ew Proof. Recall that E(H) = E6=(w) ∪ Msmall ∪SC:large(E that we are given an edge deletion in G. C (P C) ∪Si=1,2,3 MSF(Ci) ∪ J C). Suppose C C Given the edge deletion in G, there is at most one small cluster C where MSF(C) ⊆ Msmall is changed. MSF(C) can be updated by A(C, p) in time tu(E(C), p) = tu(n/γ, p). In Msmall, there are at most 1 edge deletion and at most 1 edge insertion. (P C ) can be updated in time O(πd) = O(πγ). This is because 1) H has depth at most d by Theorem 8.3 and so each edge is contained in at most d clusters, and 2) for each large cluster C whose edge is deleted, Pruning spends time at As we assume that no instance of Pruning fails,SC:large E most π. Therefore, the size ofSC:large E Next, we bound the time for maintainingSi=1,2,3;C:large MSF(C i). For i = 1, we have that there (P C ) can grow by at most O(πγ) as well. is at most one compressed cluster C where the deleted edge e ∈ E(C 1) because of edge-disjointness by Proposition 9.9. Observe that E(C 1) is determined only by EC and Msmall(C), and not P C . If e ∈ Msmall(C), then this generates at most one edge deletion and at most one insertion in E(C 1). Else, e ∈ EC, then there is one deletion in E(C 1). So the total cost spent by Af ew(C1, 1, p) is at most tf ew del (E(C 1),EC ins (n, O(n/γ), 1, p). For i = 2, 3, we have that E(C i) depends also on P C. Hence, there are at most O(πγ) edge updates in SC:large E(C i). For each edge update in E(C i) for some large cluster C, Ai(Ci) Si=2,3;C:large MSF(Ci) is O(πγ) × O(γ) = O(πγ2). The time for updatingSC:large J C is subsumed To bound the edge changes in H, by Proposition 9.13, there is no edge removed fromSC:large(E Si=1,2,3 MSF(C i) ∪ J C) except the deleted edge itself. So there are at most 2 edge deletions (from by other steps. Therefore, the total update time is at most tu(n/γ, p) + tf ew tf ew ins (n, O(n/γ), 1, p) + O(πγ2). takes O(γ) time to update MSF(C i) by Lemma 9.26. Therefore the total time for updating edges in E6=(w) or Msmall) and B = O(πγ) edge insertions in H. del (n, O(n/γ), 1, p) + tf ew 1 , 1, p) + tf ew ins (E(C 1),EC 1 , 1, p) = tf ew del (n, O(n/γ), 1, p) + C (P C )∪ 9.3.3 Maintaining MSF of the Sketch Graph Finally, we bound the time to maintain MSF(H) which is the same as MSF(G) by Lemma 9.15. Lemma 9.28. Suppose that the algorithm does not fail. The algorithm for Lemma 9.2 has update time O(mO(log log log m/ log log m) log 48 1 p ). Proof. By Lemma 9.27, we need to spend time at most tu(n/γ, p) + tf ew del (n, O(n/γ), 1, p) + tf ew ins (n, O(n/γ), 1, p) + O(πγ2) for maintaining the sketch graph H itself. Moreover, there are only 2 edge deletions and B = O(πγ) edge insertions in H. Given these updates, we can update MSF(H) using Af ew(H, B, p) in time 2tf ew del (E(H),E(H) − MSF(H), B, p) + tf ew del (n, O(n/γ), B, p) + tf ew = 2tf ew ins (n, O(n/γ), B, p) ins (E(H),E(H) − MSF(H), B, p) by Lemma 9.20. Note that m = Θ(n). Write k = Θ(m/γ). We have that the total update time to maintain MSF(H) is tu(m, p) ≤ tu(k, p) + 3tf ew = O( B log k del (O(m), k, B, p) + 2tf ew · tpre(O(k), O(p/ log m)) + B log2 m + k ins (O(m), k, B, p) + O(πγ2) k log k T (k) + log k · tu(O(k), O(p/ log m))) + O(πγ2) = O(log k · tu(O(k), O(p/ log m))) + O(mO(log log log m/ log log m) log 1 p ). The first equality is because of Theorem 7.1. To show the last equality, note first that by Lemma 9.24, B log k k · tpre(O(k), p′) = O( k B log k · k1+O(√log log m/ log m) log = O(πγkO(√log log m/ log m) log = O(mO(log log log m/ log log m) log 1 p ) 1 p ). 1 p ) B = O(πγ) Next, note that T (m) = m/(3πdγ) = m1−Θ(log log log m/ log log m). So T (k) = k1−Θ(log log log k/ log log k) and we have k log k k1−Θ(log log log k/ log log k) = O(mO(log log log m/ log log m)). Also, O(B log2 m + πγ2) = O(mO(log log log m/ log log m)). Therefore, we have T (k) = k log k tu(m, p) = O(log m · tu(O(m/γ), O(p/ log m))) + O(mO(log log log m/ log log m) log √log m log log m ) = O(q log m So solve this recurrence, note that d0 = logO(γ) m = O( of the recursion. After solving the recurrence, we have log m log log m ) is the depth 1 p ). tu(m, p) = O(logd0 m) × O(mO(log log log m/ log log m) log logd0 m p ) = O(mO(log log log m/ log log m) log 1 p ). 49 9.3.4 Wrapping Up As a last step, we show that the algorithm fails with low probability. Lemma 9.29. For each update, the algorithm fails with probability O(γp). Proof. There are two types of events that cause the algorithm to fail: 1) "A or Af ew fails": some instance of A or Af ew takes time longer than the guaranteed time bound, 2) "Pruning fails": some instance of Pruning reports failure. Now, we fix some time step and will bound the probability of the occurrence of each type of events. First, let E1 be the event that some instance of A or Af ew fails. We list the instances of A and Af ew first. Consider Algorithm 9.1. For each small cluster C, there is the instance A(C, p) (in Step 2). For each large cluster C, there is the instance Af ew(C 1, 1, p) (in Step 4.a). Lastly, there is the instance Af ew(H, B, p) on the sketch graph H. Now, these instances can fail every time we feed the update operations to them. So we list how we feed the update operations to them. Look inside the proof of Lemma 9.27. Given an edge e to be deleted, there is at most one small cluster C where we feed the edge deletion of e to A(C, p). Also, there is at most one compressed cluster C that we need to feed the update to Af ew(C 1, 1, p). There are at most one insertion and one deletion. For the sketch graph H, by Lemma 9.27 there are at most two edge deletions and one batch of edge insertion fed to Af ew(H, B, p). In total, there are O(1) many operations that we feed to the instances of A or Af ew. Each time, an instance can fail with probability at most p by the definition of the parameter p in A(C, p), Af ew(C 1, 1, p) and Af ew(H, B, p). So Pr[E1] = O(p). Second, let E2 be the event that some instance of Pruning reports failure. Let E′2 be the event that all large clusters C are such that φ(C) = Ω(α0). We have that Pr[E2] = Pr[E2 ¬E′2] Pr[¬E′2] + Pr[E2 E′2] Pr[E′2] ≤ Pr[¬E′2] + Pr[E2 E′2]. By Theorem 8.3, Pr[¬E′2] ≤ p. Next, for each large cluster C, if φ(C) = Ω(α0), then the instance of Pruning on C fails at some step with probability at most p by Theorem 6.1. Moreover, there are only O(d) = O(γ) many large clusters that are updated for each step. By union bound, Pr[E2 E′2] ≤ O(γp). This implies that Pr[E2] = O(γp). This conclude that the algorithm fails with probability at most Pr[E1] + Pr[E2] = O(γp) at each step. Finally, we conclude the proof of Lemma 9.2 and which implies Theorem 9.1, our main result. Proof of Lemma 9.2. By Lemma 9.15, we have that the sketch graph H is such that MSF(H) = MSF(G). As the instance Af ew(H, B, p) maintains MSF in H, we conclude that MSF(G) is correctly maintained. The algorithm has preprocessing time tpre(m, p) = O(m1+O(√log log m/ log m) log 1 p ) by Lemma 9.24. Given a sequence of edge deletions of length T (m) = m/(3πdγ) = Θ(m1−O(log log log m/ log log m)), the algorithm take time tu(m, p) = O(mO(log log log m/ log log m) log 1 p ) for each update with probability 1 − O(γp), by Lemmas 9.28 and 9.29. As noted before, we have m = Θ(n) throughout the sequence of updates. Finally, we can obtain the proof of Lemma 9.2 by slightly adjusting the parameter p so that update time bound holds with the probability 1 − p instead of 1 − O(γp). 50 10 Open Problems Dynamic MSF. First, it is truly intriguing whether there is a deterministic algorithm that is as fast as our algorithm. The current best update time of deterministic algorithms is still O(√n) [11, 10, 23] (even for dynamic connectivity). Improving this bound to O(n0.5−Ω(1)) will already be a major result. Secondly, can one improve the O(no(1)) update time to O(polylog(n))? There are now several barriers in our approach and this improvement should require new ideas. Lastly, it is also very interesting to simplify our algorithm. Expander-related Techniques. The combination of the expansion decomposition and dynamic expander pruning might be useful for other dynamic graph problems. Problems whose static al- gorithms are based on low-diameter decomposition (e.g. low-stretch spanning tree) are possible candidates. Indeed, it is conceivable that the expansion decomposition together with dynamic expander pruning can be used to maintain low diameter decomposition under edge updates, but additional work maybe required. Worst-case Update Time Against Adaptive Adversaries. Among major goals for dynamic graph algorithm are (1) to reduce gaps between worst-case and amortized update time, and (2) to reduce gaps between update time of algorithms that work against adaptive adversaries and those that require oblivious adversaries. Upper bounds known for the former case (for both goals) are usually much higher than those for the latter. However, worst-case bounds are crucial in real-time applications, and being against adversaries is often needed when algorithms are used as subroutines of static algorithms. Note that of course deterministic algorithms always work against adaptive adversaries. The result in this paper is a step towards both goals. The best amortized bound for dynamic MSF is O(polylog(n)) [19, 20]. For dynamic SF problem, the result by [22, 13] implies the current best algorithm against oblivious adversaries with O(polylog(n)) worst-case update time. Our dynamic MSF algorithm is against adaptive adversaries and has O(no(1)) worst-case update time. This significantly reduces the gaps on both cases. It is a challenging goal to do the same for other fundamental problems. For example, dynamic 2-edge connectivity has O(polylog(n)) amortized update time [19] but only O(√n) worst-case bound [12, 10]. Dynamic APSP has O(n2) amortized bound [9] but only O(n2+2/3) worst-case bound [1]. There are fast algorithms against oblivious adversaries for dynamic maximal matching [4], spanner [5], and cut/spectral sparsifier [2]. It will be exciting to have algorithms against adaptive adversaries with comparable update time for these problems. Acknowledgement. This project has received funding from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme under grant agreement No 715672. Nanongkai and Saranurak were also partially supported by the Swedish Research Council (Reg. No. 2015-04659). References [1] Ittai Abraham, Shiri Chechik, and Sebastian Krinninger. Fully dynamic all-pairs shortest paths with worst-case update-time revisited. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 440–452, 2017. (cit. on p. 2, 51) [2] Ittai Abraham, David Durfee, Ioannis Koutis, Sebastian Krinninger, and Richard Peng. On fully dynamic graph sparsifiers. In IEEE 57th Annual Symposium on Foundations of Computer 51 Science, FOCS 2016, 9-11 October 2016, Hyatt Regency, New Brunswick, New Jersey, USA, pages 335–344, 2016. (cit. on p. 1, 51) [3] Stephen Alstrup, Jacob Holm, Kristian de Lichtenberg, and Mikkel Thorup. Maintaining information in fully dynamic trees with top trees. ACM Transactions on Algorithms, 1(2):243– 264, 2005. (cit. on p. 5) [4] Surender Baswana, Manoj Gupta, and Sandeep Sen. Fully dynamic maximal matching in O (log n) update time. In IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS 2011, Palm Springs, CA, USA, October 22-25, 2011, pages 383–392, 2011. (cit. on p. 51) [5] Surender Baswana, Sumeet Khurana, and Soumojit Sarkar. Fully dynamic randomized algo- rithms for graph spanners. ACM Trans. Algorithms, 8(4):35, 2012. (cit. on p. 51) [6] Sayan Bhattacharya, Monika Henzinger, and Danupon Nanongkai. Fully dynamic approximate maximum matching and minimum vertex cover in O(log3 n) worst case update time. In Pro- ceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 470–489, 2017. (cit. on p. 2) [7] Greg Bodwin and Sebastian Krinninger. Fully dynamic spanners with worst-case update time. In 24th Annual European Symposium on Algorithms, ESA 2016, August 22-24, 2016, Aarhus, Denmark, pages 17:1–17:18, 2016. (cit. on p. 2) [8] Thomas H.. Cormen, Charles Eric Leiserson, Ronald L Rivest, and Clifford Stein. Introduction to algorithms, volume 6. MIT press Cambridge, 2001. (cit. on p. 4) [9] Camil Demetrescu and Giuseppe F. Italiano. A new approach to dynamic all pairs shortest In Proceedings of the 35th Annual ACM Symposium on Theory of Computing, June paths. 9-11, 2003, San Diego, CA, USA, pages 159–166, 2003. (cit. on p. 51) [10] David Eppstein, Zvi Galil, Giuseppe F. Italiano, and Amnon Nissenzweig. Sparsification - a technique for speeding up dynamic graph algorithms. J. ACM, 44(5):669–696, 1997. Announced at FOCS 1992. (cit. on p. 1, 2, 4, 51) [11] Greg N. Frederickson. Data structures for on-line updating of minimum spanning trees, with applications. SIAM J. Comput., 14(4):781–798, 1985. Announced at STOC'83. (cit. on p. i, 1, 2, 3, 5, 19, 33, 51) [12] Greg N. Frederickson. Ambivalent data structures for dynamic 2-edge-connectivity and k small- est spanning trees. SIAM J. Comput., 26(2):484–538, 1997. Announced at FOCS 1991. (cit. on p. 51) [13] David Gibb, Bruce M. Kapron, Valerie King, and Nolan Thorn. Dynamic graph connectivity with improved worst case update time and sublinear space. CoRR, abs/1509.06464, 2015. (cit. on p. 2, 51) [14] 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, 2017. (cit. on p. 3, 6, 8, 61) 52 [15] Monika Rauch Henzinger and Valerie King. Fully dynamic 2-edge-connectivity algorithm in polylogarithmic time per operation. Technical note 1997-004, Digital Equipment Corp., Systems Research Ctr., 130 Lytton Rd., Palo Alto, CA, 94301, USA, 12 Jun 1997. (cit. on p. i, 3, 18) [16] Monika Rauch Henzinger and Valerie King. Maintaining minimum spanning trees in dynamic graphs. In Automata, Languages and Programming, 24th International Colloquium, ICALP'97, Bologna, Italy, 7-11 July 1997, Proceedings, pages 594–604, 1997. (cit. on p. 1, 3, 18) [17] Monika Rauch Henzinger and Valerie King. Randomized fully dynamic graph algorithms with polylogarithmic time per operation. J. ACM, 46(4):502–516, 1999. Announced at STOC 1995. (cit. on p. 1) [18] Monika Rauch Henzinger and Mikkel Thorup. Sampling to provide or to bound: With appli- cations to fully dynamic graph algorithms. Random Struct. Algorithms, 11(4):369–379, 1997. (cit. on p. 1) [19] 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. Announced at STOC 1998. (cit. on p. i, 1, 3, 18, 19, 23, 26, 51) [20] Jacob Holm, Eva Rotenberg, and Christian Wulff-Nilsen. Faster fully-dynamic minimum span- ning forest. In Algorithms - ESA 2015 - 23rd Annual European Symposium, Patras, Greece, September 14-16, 2015, Proceedings, pages 742–753, 2015. (cit. on p. 1, 3, 18, 51) [21] Shang-En Huang, Dawei Huang, Tsvi Kopelowitz, and Seth Pettie. Fully dynamic connectivity in o(log n(log log n)2) amortized expected time. In SODA, 2017. (cit. on p. 1) [22] Bruce M. Kapron, Valerie King, and Ben Mountjoy. Dynamic graph connectivity in polyloga- rithmic worst case time. In Sanjeev Khanna, editor, Proceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2013, New Orleans, Louisiana, USA, January 6-8, 2013, pages 1131–1142. SIAM, 2013. (cit. on p. 2, 17, 18, 51) [23] Casper Kejlberg-Rasmussen, Tsvi Kopelowitz, Seth Pettie, and Mikkel Thorup. Faster worst case deterministic dynamic connectivity. In Piotr Sankowski and Christos D. Zaroliagis, editors, 24th Annual European Symposium on Algorithms, ESA 2016, August 22-24, 2016, Aarhus, Denmark, volume 57 of LIPIcs, pages 53:1–53:15. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2016. (cit. on p. 2, 51) [24] Danupon Nanongkai and Thatchaphol Saranurak. Dynamic spanning forest with worst-case update time: adaptive, las vegas, and o(n1/2 - ǫ)-time. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2017, Montreal, QC, Canada, June 19-23, 2017, pages 1122–1129, 2017. (cit. on p. i, 2, 3, 4, 5, 10, 12, 13, 19, 29, 31) [25] Lorenzo Orecchia and Zeyuan Allen Zhu. Flow-based algorithms for local graph clustering. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1267–1286, 2014. (cit. on p. 3, 10) [26] Mihai Patrascu and Erik D. Demaine. Logarithmic lower bounds in the cell-probe model. SIAM J. Comput., 35(4):932–963, 2006. Announced at SODA'04 and STOC'04. (cit. on p. 1) 53 [27] Mihai Patrascu and Mikkel Thorup. Planning for fast connectivity updates. In 48th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2007), October 20-23, 2007, Providence, RI, USA, Proceedings, pages 263–271, 2007. (cit. on p. 2) [28] Richard Peng. Approximate undirected maximum flows in O(mpolylog(n)) time. In SODA, pages 1862–1867. SIAM, 2016. (cit. on p. 3) [29] Piotr Sankowski. Dynamic transitive closure via dynamic matrix inverse. In 45th Symposium on Foundations of Computer Science (FOCS 2004), 17-19 October 2004, Rome, Italy, Proceedings, pages 509–517, 2004. (cit. on p. 2) [30] Daniel Dominic Sleator and Robert Endre Tarjan. A data structure for dynamic trees. J. Comput. Syst. Sci., 26(3):362–391, 1983. (cit. on p. 5) [31] Daniel A. Spielman and Shang-Hua Teng. Spectral sparsification of graphs. SIAM J. Comput., 40(4):981–1025, 2011. (cit. on p. 13) [32] Mikkel Thorup. Near-optimal fully-dynamic graph connectivity. In F. Frances Yao and Eu- gene M. Luks, editors, Proceedings of the Thirty-Second Annual ACM Symposium on Theory of Computing, May 21-23, 2000, Portland, OR, USA, pages 343–350. ACM, 2000. (cit. on p. 1) [33] Mikkel Thorup. Worst-case update times for fully-dynamic all-pairs shortest paths. In Harold N. Gabow and Ronald Fagin, editors, Proceedings of the 37th Annual ACM Symposium on Theory of Computing, Baltimore, MD, USA, May 22-24, 2005, pages 112–119. ACM, 2005. (cit. on p. 2) [34] Mikkel Thorup. Fully-dynamic min-cut. Combinatorica, 27(1):91–127, 2007. Announced at STOC'01. (cit. on p. 1) [35] Mikkel Thorup and David R Karger. Dynamic graph algorithms with applications. In Algorithm Theory-SWAT 2000, pages 1–9. Springer, 2000. (cit. on p. 1) [36] Christian Wulff-Nilsen. Faster deterministic fully-dynamic graph connectivity. In Proceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2013, New Orleans, Louisiana, USA, January 6-8, 2013, pages 1757–1769, 2013. (cit. on p. 1) [37] Christian Wulff-Nilsen. Fully-dynamic minimum spanning forest with improved worst-case update time. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2017, Montreal, QC, Canada, June 19-23, 2017, pages 1130–1143, 2017. (cit. on p. i, 2, 3, 4, 5, 6, 11, 18, 19, 29, 30, 31, 33, 36, 37) 54 A Reduction from One-shot Expander Pruning to LBS Cuts In this section, we show the proof of Lemma 5.3. Theorem A.1 (Restatement of Lemma 5.3). Suppose there is a (csize(σ), ccon(σ))-approximate LBS cut algorithm with running time tLSB(n, vol(A), α, σ) when given (G, A, σ, α) as inputs where G = (V, E) is an n-node graph, A ⊂ V is a set of nodes, σ is an overlapping parameter, and α is a conductance parameter. Then, there is a one-shot expander pruning algorithm as in Theorem 5.2 with input (G, D, αb, ǫ) that has time limit t = O((D αb )ǫ · csize(αb/2) ǫ · tLSB(n, ∆D αb , αb, αb)) and conductance guarantee α = αb 5ccon(αb/2)1/ǫ−1 . More precisely, there is an algorithm A that can do the following: )ǫ · csize(αb/2) ǫ · tLSB(n, ∆Dαb • A is given G,D, αb, ǫ as inputs: G = (V, E) is an n-node m-edge graph with maximum degree ∆, αb is a conductance parameter, ǫ ∈ (0, 1) is a parameter, and D is a set of edges where D ∩ E = ∅ where D = O(α2 • Then, in time t = O((Dαb output a set of pruning nodes P ⊂ V . Moreover, if φ(Gb) ≥ αb, then we have , αb, αb)), A either reports φ(Gb) < αb, or b m/∆). Let Gb = (V, E ∪ D). – volG(P ) ≤ 2D/αb, and – a pruned graph H = G[V − P ] has high conductance: φ(H) ≥ α = αb 5ccon(αb/2)1/ǫ−1 .. Observe that ǫ is a trade-off parameter such that, on one hand when ǫ is small, the algorithm is fast but has a bad conductance guarantee in the output, on the other hand when ǫ is big, the algorithm is slow but has a good conductance guarantee. A.1 The Reduction Throughout this section, let ǫ be the parameter and let G,D, p, αb be the inputs of the algorithm where G = (V, E) is an n-node graph, D is a set of edges where D∩ E = ∅. p is a failure probability parameter, and αb is a conductance parameter where αb < 1 γω(1) . We call Gb = (V, E ∪ D) the before graph. We want to compute the set of pruning nodes P ⊂ V with properties according to Theorem 5.2. We now define some more notations. Let A be the set of endpoints of D. Let Acut be the deterministic algorithm for finding LBS cuts from Theorem 4.4. We set the overlapping parameter σ = αb/2 for Acut. Let csize = csize(σ), ccon = ccon(σ) be the approximation ratios of Acut. L ≤ 1/ǫ. We denote α = αb Hence, αL < ··· < α2 < α1 = αb/5 < αb/4. For any graphs H = (VH , EH ), I = (VI , EI ), and a number ℓ, the main procedure decomp(H, I, ℓ) is defined as in Algorithm A.1. For any α′ and B ⊂ VH , recall that OPT(H, α′) is the size of the largest α′-sparse cut S in H where S ≤ VH − S, and OPT(H, α′, B, σ) is the size of the largest α′-sparse (B, σ)-overlapping cut S in H where S ≤ VH − S. By definition, OPT(H, α′) ≥ OPT(H, α′, B, σ). The algorithm is simply to run decomp(G, G, 1) with time limit ¯t. If decomp(G, G, 1) takes time Let ¯s1, . . . , ¯sL be such that ¯s1 = 2D/αb + 1, ¯sL ≤ 1, and ¯sℓ = ¯sℓ−1/(¯s1)ǫ for 1 < ℓ < L. Hence, . Let α1, . . . , αL be such that αL = α and αℓ = αℓ+1ccon for ℓ < L. 5cL−1 con more than t, then we reports that φ(Gb) < αb (FAIL). 55 1. Set BH = (A ∪ AH) ∩ VH where AH is the set of endpoints of edges in ∂G(VH ) 2. If volH(VH − BH) < 3 3. If ℓ = L, then return. σ volH(BH ), then report φ(Gb) < αb (FAIL). 4. If Acut(H, αℓ, BH , σ) reports OPT(H, αℓ/ccon, BH , σ) = 0, i.e. there is no (αℓ/ccon)-sparse (BH , σ)-overlapping cut, then return. 5. Else, Acut(H, αℓ, BH , σ) outputs an αℓ-sparse cut S in H where OPT(H, αℓ/ccon, BH , σ)/csize ≤ vol(S) ≤ vol(VH )/2. (a) If S ≥ ¯sℓ+1/csize, then include S into pruning set P and recurse on decomp(H[VH \ S], I, ℓ). (b) Else, recurse on decomp(H, H, ℓ + 1). Algorithm A.1: decomp(H, I, ℓ) where H = (VH , EH ) and I = (VI , EI ) A.1.1 Upper Bounding vol(P ) In this section, we prove that if φ(Gb) ≥ αb and the algorithm does not fail by other reasons, then we have volG(P ) ≤ 2D/αb. We will show that the algorithm might fail only if φ(Gb) < αb in Appendix A.1.2. Let us list all sets of nodes P1, . . . , Pt that are outputted by Algorithm A.1 in either Step 2 or Step 5.a and constitute the pruning set P =Si Pi. Note that Pi ∩ Pi′ = ∅ for any i, i′. The sets such that Pi is "cut from" Hi, i.e. H 1 = G, H 2 = G[V − P 1], . . . , H t = G[V −St−1 P1, . . . , Pt is ordered by the time they are outputted. Let H 1, . . . , H t the corresponding subgraphs i=1 Pi]. Note the following fact: Fact A.2. For any i ≤ t, φHi(Pi) < αb/4. Proof. Since all Pi's are returned in Step 5.a and αℓ ≤ α1 < αb/4. Next, we have the following: i=1 δH i(Pi) Proposition A.3. δG(P ) ≤Pt Proof. We will prove that ∂G(P ) ⊆ St for some j ≤ t. Then v ∈ V − P ⊆ V (H j) − Pj because V (Hj) = V −Sj−1 (u, v) ∈ ∂H j (Pj) ⊂St Proposition A.4. For any t′ ≤ t, if volG(St′ i=1 P i) ≤ vol(G)/2, then φG(St′ i=1 ∂H i(Pi). i=1 ∂Hi(Pi). Let (u, v) ∈ ∂G(P ). Suppose that u ∈ Pj i=1 Pi. Therefore, i=1 Pi) < αb/4. 56 Proof. We have φG( t′[i=1 Pi) = = i=1 Pi) i=1 Pi) i=1 Pi) i=1 volG(Pi) i=1 δH i(Pi) i=1 volHi(Pi) δG(St′ volG(St′ δG(St′ Pt′ ≤ Pt Pt′ δH i(Pi) volHi(Pi) φH i(Pi) < αb/4 ≤ max i≤t′ = max i≤t′ as vol( t′[i=1 P i) ≤ vol(G)/2 as Pi's are disjoint by Proposition A.3 by Fact A.2. The following lemma is the key observation: Lemma A.5. Suppose that φ(Gb) ≥ αb. If a cut S is G where vol(S) ≤ vol(G)/2 is such that φG(S) < αb/2, then volG(S) ≤ 2D/αb. Proof. Suppose otherwise that vol(S) > 2D/αb. Then, as G = Gb − D, we have δG(S) ≥ δGb(S) − D > αbvol(S) − αbvol(S)/2 = αbvol(S)/2, which means, φG(S) > αb/2 > α′, a contradiction. Next, we argue against a corner case where vol(P ) > vol(G)/2. Lemma A.6. If φ(Gb) ≥ αb and volG(V ) = ω(D/αb), then vol(P ) ≤ vol(G)/2. Proof. Suppose that vol(P ) > vol(G)/2. We will show that volG(V ) = O(D/αb) which is a i=1 Pi). Let P<k = i=1 Pi. We partition the vertices into 3 sets: P<k, Pk and Q = V − (P<k ∪ Pk). Note that Hk = G[V − P<k]. First, we list some properties of P<k. Because vol(P<k) < volG(V )/2, by Proposition A.4, we have φG(P<k) < αb/4 and hence, by Lemma A.5, volG(P<k) < 2D/αb ≪ volG(V )/6. contradiction. Let k ≤ t be the such that vol(Sk−1 Sk−1 i=1 Pi) ≤ volG(V )/2 < vol(Sk Next, we list some properties of Pk. We have φHk (Pk) < αb/4 and volG(Pk) ≤ EG(P<k, Pk) + volHk (Pk) ≤ volG(P<k) + volHk (Q) ≤ volG(P<k) + volG(Q). Last, we list properties of Q. We have that δG(Q) = δG(P<k∪Pk) ≤ δG(P<k)+δHk (Pk) using the same argument as in Proposition A.3. We claim that volG(P<k) + volG(Pk) ≤ 2volG(Q). Because volG(V ) = volG(P<k) + volG(Pk) + volG(Q) ≤ 2volG(P<k) + 2volG(Q) ≤ vol(G)/3 + 2volG(Q), 57 and so we have volG(Q) ≥ volG(V )/3 and hence volG(P<k) + volG(Pk) ≤ 2 Therefore, we have the following: 3 volG(V ) ≤ 2volG(Q). φG(Q) = δG(Q) volG(Q) ≤ δG(P<k) + δHk (Pk) (volG(P<k) + volG(Pk))/2 ≤ 2 max{φG(P<k), φHk (Pk)} < αb/2. This means that volG(Q) < 2D/αb by Lemma A.5. So we can conclude the contradiction: volG(V ) = volG(P<k) + volG(Pk) + volG(Q) = O(D/αb). By the above lemma, we immediately have a strong bound on vol(P ). Note that D < α2 implies that volG(V ) = ω(D/αb) Corollary A.7. If φ(Gb) ≥ αb, then volG(P ) ≤ 2D/αb. Proof. By Lemma A.6, vol(P ) ≤ vol(G)/2 and hence φG(P ) < αb/4 by Proposition A.4, this implies that vol(P ) ≤ 2D/αb by Lemma A.5. b m/30∆ A.1.2 Upper bounding volH (BH ) First, we prove that D < α2 b m/30∆ implies that 3 σ volH (BH ) ≤ volH (VH − BH) unless φ(Gb) < αb. Proposition A.8. If φ(Gb) ≥ αb, then volH (BH ) ≤ 4∆D/αb. Proof. We have volH (BH) ≤ volH (A) + volH(AH ) ≤ 2∆D + ∆EG(P, V − P ) ≤ 2∆D + ∆volG(P ) ≤ 2∆D + 2∆D/αb ≤ 4∆D/αb by Corollary A.7 Lemma A.9. Suppose that D < α2 Algorithm A.1 never holds. b m/30∆. If φ(Gb) ≥ αb, then the condition in Step 2 of Proof. Suppose that the condition in Step 2 holds. Let P be the pruning set that Algorithm A.1 outputted so far. We have that H = G[VH ] = G[V − P ] such that volH (VH − BH) < 3 σ volH (BH ) where BH = (A ∪ AH) ∩ VH , A is the endpoints of D, and AH is the set of endpoints of edges in ∂G(VH ) = ∂G(P ). This implies that volH (VH ) = volH (VH − BH) + volH (BH ) < (1 + 3 σ )volH (BH ). Together, we have that volH(V − P ) = volH(VH ) ≤ 16∆ σ (D/αb) by Proposition A.8. This implies volG(V ) = volG(P ) + δG(P ) + volH(V − P ) ≤ 2volG(P ) + volH (V − P ) ≤ 60∆D/α2 b . But this is contradiction because it means D ≥ α2 b m/30∆. 58 by Corollary A.7 and σ=αb/2. This implies that the parameters for Acut are valid when it is called. Lemma A.10. Whenever Acut(H, αℓ, BH , σ) is called, we have that σ ≥ 3vol(B) requirement for Acut as stated in Theorem 4.4. Proof. Observe that Acut can be called only when the condition in Step 2 of Algorithm A.1 is false: vol(VH − BH) ≥ 3 A.1.3 Lower Bounding Conductance vol(VH−BH ) and 4vol(BH ) ≤ vol(VH − BH ). σ vol(BH ). That is, σ ≥ 3vol(BH ) vol(VH−BH ) satisfying the Next, given that φ(Gb) ≥ αb, we would like to prove an important invariant: if decomp(H, I, ℓ) is called, then OPT(I, αℓ) < ¯sℓ. In order to prove this, we need two lemmas. Lemma A.11. Suppose that φ(Gb) ≥ αb. If decomp(H, I, 1) is called, then OPT(I, α1) < 2D/αb + 1 = ¯s1. Proof. Observe that when ℓ = 1, we have I = G. Lemma A.5 implies that OPT(G, α1) ≤ OPT(G, αb/2) ≤ 2D/αb. Recall that, in an induced subgraph H = G[VH ] in G, we denote BH = (A ∪ AH) ∩ VH where where A is the endpoints of D and AH is the set of endpoints of edges in ∂G(VH ). Lemma A.12. Suppose that φ(Gb) ≥ αb. OPT(H, α′) = OPT(H, α′, BH, σ) for any α′ < αb/2 and induced subgraph H = G[VH ]. Proof. In words, we need to prove that any α′-sparse cut S ⊂ VH where S ≤ VH − S must be (BH , σ)-overlapping in H. First, consider any cut edge (u, v) ∈ ∂Gb(S) in the before graph Gb where u ∈ S. We claim that either (u, v) ∈ ∂H(S) or u ∈ A ∪ AH . Indeed, if u /∈ A ∪ AH , i.e. u is not incident to any edge in D nor ∂G(VH ), so all edges incident to u are inside H, and hence (u, v) ∈ ∂H (S). It follows that δGb(S) ≤ δH (S) + vol(S ∩ (A ∪ AH)). Suppose that there is an α′-sparse cut S ⊂ VH which is not (BH , σ)-overlapping, i.e. vol(S ∩ (A ∪ AH)) < σvol(S) = αb 2 vol(S). Then we have that δH(S) ≥ δGb(S) − vol(S ∩ (A ∪ AH )) > αbvol(S) − αbvol(S)/2 = αbvol(S)/2. That is, φH(S) ≥ αb/2 > α′, which is a contradiction. Now, we can prove the main invariant: Lemma A.13. Suppose that φ(Gb) ≥ αb. If decomp(H, I, ℓ) is called, then the invariant OPT(I, αℓ) < ¯sℓ is satisfied. Proof. When ℓ = 1, OPT(I, αℓ) < ¯s1 by Lemma A.11. In particular, the invariant is satisfied when decomp(G, G, 1). The invariant for decomp(H[VH \ S], I, ℓ) which is called in Step 5.a is the same as the one for decomp(H, I, ℓ), and hence is satisfied by induction. Finally, we claim that the invariant is satisfied when decomp(H, H, ℓ+1) is called, i.e., OPT(H, αℓ+1) < ¯sℓ+1. By Step 5.a, S < ¯sℓ+1/csize. By Step 5, OPT(H, αℓ+1, BH , σ)/csize ≤ S as αℓ+1 = αℓ/ccon. Since H is induced by VH and αℓ+1 ≤ α1 < αb/2 satisfying the conditions in Lemma A.12, we have OPT(H, αℓ+1) = OPT(H, αℓ+1, BH , σ). Therefore, OPT(H, αℓ+1) ≤ csizeS < ¯sℓ+1 as desired. Finally, we bound the conductance of the components of Gd. 59 Lemma A.14. Suppose that φ(Gb) ≥ αb. The pruned graph H = G[V − P ] has conductance φ(H) ≥ α. Proof. H is in either Step 3 or 4 in Algorithm A.1. First, if H is returned in Step 3, then decomp(H, H, L) was called. By the invariant, we have OPT(H, αL) < ¯sL ≤ 1, i.e. there is no αL- sparse cut in H. As αL = α, φ(H) ≥ α. Second, if H is returned in Step 4, then Acut(H, αℓ, B, σ) reports that OPT(H, αℓ/ccon, BH , σ) = 0. As αℓ/ccon < αb/2, OPT(H, αℓ/ccon) = 0 by Lemma A.12. That is, φ(H) ≥ αℓ/ccon ≥ αL = α. Now, it is left to analyze the running time. A.1.4 Running time In this section, we prove that if φ(Gb) ≥ αb, then decomp(G, G, 1) takes at most t time. In other words, if decomp(G, G, 1) takes more that ¯t time, then φ(Gb) < αb and the algorithm will just halt and report that φ(Gb) < αb (FAIL). To analyze the running time, we need some more notation. We define the recursion tree T of decomp(G, G, 1). Actually, T is a path. • Each node of T represents the parameters of the procedure decomp(H, I, ℓ). • (G, G, 1) is the root node. • For each (H, I, ℓ), if decomp(H, I, ℓ) returns the pruned graph H, then (H, I, ℓ) is a leaf. • If decomp(H, I, ℓ) recurses on decomp(H[VH \ S], I, ℓ), then there is an edge ((H, I, ℓ), (H[VH \ S], I, ℓ)) ∈ T and is called a right edge. • If decomp(H, I, ℓ) recurses on decomp(H, H, ℓ+1), then there is an edge ((H, I, ℓ), (H, H, ℓ+1)) in T and is called a down edge. For any n-node graph G, α is a conductance parameter, A is a set of nodes in G, and σ is an overlapping parameter, let tLSB(n, vol(A), α, σ) denote the running time of the LSB cut algorithm Acut(G, α, Aσ). Lemma A.15. Suppose that φ(Gb) ≥ αb. If the depth of the recursion tree T is dT , then the total running time is O(dT × tLSB(n, ∆Dαb , αb, αb)). Proof. At any level of recursion, the running time on decomp(H, I, ℓ), excluding the time spent in the next recursion level, is just the running time of Acut(H, αℓ, BH, σ) which is tLSB(VH, vol(BH ), αℓ, σ) ≤ O(tLSB(n, ∆Dαb σ = αb/2. So the total running time is O(dT × tLSB(n, ∆Dαb , αb, αb)) because VH ≤ n, vol(BH ) = O( ∆Dαb ) Proposition A.8, αℓ ≤ αb, and , αb, αb)) is if there are dT levels. Now, we bound the depth dT of T . Recall L ≤ 1/ǫ and ¯s1 = 2D/αb + 1. Lemma A.16. Suppose that φ(Gb) ≥ αb. T contains at most L down edges, and Lcsize¯sǫ edges. That is, the depth of T is dT = Lcsize¯sǫ Proof. There are at most L down edges in T because Step 3 in Algorithm A.1 always terminates the recursion when ℓ = L. Next, it suffices to prove that there cannot be k = csize¯sǫ 1 right edges between any down edges in T . Let P = (H1, I, ℓ), . . . , (Hk, I, ℓ) be a path of T which maximally )ǫ · csize ǫ ). 1 = O((Dαb 1 right 60 contains only right edges. Note that I = H1 because (H1, I, ℓ) must be either a root or a deeper endpoint of a down edges. Suppose for contradiction that P ≥ k. For each i, let Si be the cut such that Hi+1 = Hi[VHi \ Si] and φHi(Si) < αℓ. Since {Si}i≤k i=1 Si) < αℓ using the same argument as in Proposi- i=1 Si ≥ k¯sℓ+1/csize ≥ i=1 Si contradicts the invariant for decomp(H1, I, ℓ), where I = H1, which says are mutually disjoint. We conclude φH1(Sk tion A.4. However, we also have that Si ≥ ¯sℓ+1/csize, for all i, and hence Sk 1¯sℓ+1 = ¯sℓ. So Sk ¯sǫ OPT(H1, αℓ) < ¯sℓ. Note that the invariant must hold by Lemma A.13. Corollary A.17. Suppose that φ(Gb) ≥ αb. decomp(G, G, 1) runs in time t = O((Dαb tLSB(n, ∆Dαb Proof. We have dT = O( Dǫ runs in time O((Dαb ) by Lemma A.16. By Lemma A.15, we have that decomp(G, G, 1) )ǫ · csize ǫ · , αb, αb)). , αb, αb)). α1+ǫ ǫ b )ǫ · csize ǫ · tLSB(n, ∆Dαb Now, we can conclude the main theorem. Proof of Theorem A.1. Suppose that φ(Gb) ≥ αb. By Corollary A.7, we have that the pruning set P has small volume volG(V ) ≤ 2D/αb. By Lemma A.14, the pruned graph H = G[V − P ] has high conductance: φ(C) ≥ α = 5ccon(αb/2)1/ǫ−1 . Finally, Corollary A.17 decomp(G, G, 1) runs in time t = O((Dαb Indeed, given that D = When decomp(G, G, 1) reports failure, we claim that φ(Gb) < αb. b m/∆), we have that decomp(G, G, 1) does not fails in Step 2 by Lemma A.9. So decomp(G, G, 1) O(α2 can return FAIL only when its running time exceeds t which can only happens when φ(Gb) < αb. · tLSB(n, ∆Dαb )ǫ · csize(αb/2) , αb, αb)). αb ǫ B Omitted Proofs B.1 Proof of Lemma 3.4 (Unit Flow) The proof is basically by adjusting and simplifying parameters of the following statement from [14]. 15 Lemma B.1 (Theorem 3.1 and Lemma 3.1 in [14]). There exists an algorithm called Unit Flow which takes the followings as input: a graph G = (V, E) with m edges (with parallel edges but no self loop), positive integers h′, F ′, and U , a source function ∆ such that ∆(v) ≤ F ′·deg(v) for all v ∈ V , and a sink function T where T (v) = deg(v) for all v ∈ V . In time O(F ′h′∆(·)), the algorithm returns a source-feasible preflow f with congestion at most U . Moreover, one of the followings holds. 1. exf (·) = 0 i.e. f is a flow. 2. exf (·) ≤ ∆(·) − 2m. More specifically, for all v ∈ V , deg(v) units of supply is absorbed at v. 3. A set S ⊆ V is returned, where S is such that ∀v ∈ S, deg(v) ≤ f (v) ≤ F ′·deg(v) and ∀v /∈ S, f (v) ≤ deg(v). Furthermore, if h ≥ log m, then φG(S) ≤ 20 log 2m + F ′ U . h′ 15We note that the original statement of [14] guarantees some additional properties. We do not state them here as they are not needed. Moreover, the result of the algorithm is a flow in the graph G(U ) which is the graph G where the capacity of each edge is U , for a given parameter U . We adapt the original statement to use the notion of congestion instead. It is easy to see that a flow in G(U ) is a flow in G with congestion U and vice versa. 61 By restricting to only when ∆(·) ≤ 2m and h′ ≥ log m, we can simplify Lemma B.1 to Lemma B.2 below. Note that, when T (v) = deg(v), we have exf (v) = max{f (v) − T (v), 0} = exf (v) = max{f (v) − deg(v), 0}. Lemma B.2. There exists an algorithm called Unit Flow which takes the followings as input: a graph G = (V, E) with m edges (with parallel edges but no self loop), positive integers h′ ≥ log m, F ′, and U , a source function ∆ such that ∆(v) ≤ F ′ · deg(v) for all v ∈ V and ∆(·) ≤ 2m, and a sink function T where T (v) = deg(v) for all v ∈ V . In time O(F ′h′∆(·)), the algorithm returns a source-feasible preflow f with congestion at most U . Moreover, one of the followings holds. 1. exf (·) = 0 i.e. f is a flow. 2. A cut S is returned where φG(S) ≤ 20 log(2m) h′ and ∀v /∈ S: exf (v) = 0. + F ′ U . Moreover, ∀v ∈ S: exf (v) ≤ (F ′−1) deg(v) To get Lemma 3.4, set F = F ′ , h = 2h = 1 h . Note that the condition h′ ≥ log m becomes h ≥ 1. Also note that in the input of Theorem 3.3 (thus Lemma 3.4), ∆(·) ≤ T (·) ≤ 2m, thus the condition that ∆(·) ≤ 2m in Lemma B.2 can be dropped. This completes the proof of Lemma 3.4. 41 log(2m) and U = 2hF . So 20 log(2m) U < 1 2h + 1 h′ + F ′ h′ 62
1807.09686
1
1807
2018-07-25T16:04:01
Directory Reconciliation
[ "cs.DS", "cs.DC" ]
We initiate the theoretical study of directory reconciliation, a generalization of document exchange, in which Alice and Bob each have different versions of a set of documents that they wish to synchronize. This problem is designed to capture the setting of synchronizing different versions of file directories, while allowing for changes of file names and locations without significant expense. We present protocols for efficiently solving directory reconciliation based on a reduction to document exchange under edit distance with block moves, as well as protocols combining techniques for reconciling sets of sets with document exchange protocols. Along the way, we develop a new protocol for document exchange under edit distance with block moves inspired by noisy binary search in graphs, which uses only $O(k \log n)$ bits of communication at the expense of $O(k \log n)$ rounds of communication.
cs.DS
cs
Directory Reconciliation Michael Mitzenmacher∗ Tom Morgan† 8 1 0 2 l u J 5 2 ] S D . s c [ 1 v 6 8 6 9 0 . 7 0 8 1 : v i X r a Abstract We initiate the theoretical study of directory reconciliation, a generalization of document exchange, in which Alice and Bob each have different versions of a set of documents that they wish to synchronize. This problem is designed to capture the setting of synchronizing different versions of file directories, while allowing for changes of file names and locations without significant expense. We present protocols for efficiently solving directory reconciliation based on a reduction to document exchange under edit distance with block moves, as well as protocols combining techniques for reconciling sets of sets with document exchange protocols. Along the way, we develop a new protocol for document exchange under edit distance with block moves inspired by noisy binary search in graphs, which uses only O(k log n) bits of communication at the expense of O(k log n) rounds of communication. 1 Introduction Document exchange is a well studied two party communication problem, in which Alice and Bob have documents (strings) a and b respectively and they wish to communicate efficiently so that Bob can recover a. They are given a small bound k on the edit distance (or edit distance with block moves) between a and b, and wish to use communication proportional to k, rather than to the lengths of their strings. This has immediate applications to version control software, in which a server and client wish to synchronize different versions of the same files. In such a setting, document exchange would match each file with the corresponding file with the same name on the other side; this can be done in parallel. However, if files are allowed to change names or locations in the file structure, the this approach could introduce significant inefficiencies, as a large file whose name is changed may have to be transmitted in its entirety between the parties. We introduce the problem of directory reconciliation to address this issue. In this problem Alice and Bob each have a directory, which we define to be a set of documents. We have a small bound d on the number of edits (character insertions, deletions, and substitutions) required to transform Alice's directory into Bob's.1 The goal of directory reconciliation is for Bob to recover Alice's directory using as little communication as possible. In our version control application, a file's name and location could be encoded as a prefix for the document, and now a one character change to a file's name corresponds only to a single edit, rather than the deletion of a whole file and the creation of a new one. Directory reconciliation is also applicable to situations where we wish to synchronize file collections that are closely related but do not have file names linking them. ∗Harvard University School of Engineering and Applied Sciences. email: [email protected]. Michael Mitzenmacher was supported in part by NSF grants CNS-1228598, CCF-1320231, CCF-1563710 and CCF-1535795. †Harvard University School of Engineering and Applied Sciences. email: [email protected]. Tom Mor- gan was supported in part by NSF grants CNS-1228598 and CCF-1320231. 1Note that we use k as our edit bound for document exchange and d for our edit bound for directory reconciliation. This is for historical consistency, and it helps to keep clear which problem we are solving. 1 We present two approaches to solving directory reconciliation. The first approach is designed to minimize total communication; we accomplish this by using more rounds of communication. To achieve this, we show that directory reconciliation can be reduced to document exchange under edit distance with block moves. Recall that a block move operation selects a contiguous substring of any length, deletes it from its current location and inserts it elsewhere in the string. The state of the art for this form of document exchange is the IMS sketch [11] which is a one round protocol using O(k log n log(n/k)) bits of communication. In section 3 we present our main technical result, a new protocol for document exchange under edit distance with block moves that achieves O(k log n) bits of communication at the expense of using more rounds communication (O(k log n) of them). This protocol draws inspiration from techniques for noisy binary search, but requires new techniques and analysis in order to meet our communication requirements. Our second approach is designed to be more communication efficient in terms of the number of rounds. This approach is based on combining document exchange protocols with techniques for reconciling sets of sets [14]. We provide one round directory reconciliation protocols that are generally superior to what we achieve from our reduction to the IMS sketch. In particular, they perform significantly better when the directory consists of a large number of small files. Additionally, we provide efficient directory reconciliation protocols that use only a constant number of rounds for the setting when the bound d is unknown. These results motivate studying directory reconciliation problem as a distinct problem from document exchange, as they improve upon what is possible by direct reduction to document exchange. 1.1 Related Work The formal study of document exchange began with Orlitsky [17] and has received significant at- tention since then; see, for example, [2, 11, 4]. We summarize the current state-of-the-art document exchange protocols in subsection 2.1. All of the modern protocols use only a single round of com- munication. While there was a line of work on multi-round protocols [19, 5, 12, 21], these protocols are dominated by the one round IMS sketch [11], which incorporates the ideas behind them. The rsync algorithm [1, 22] is a well known practical tool for synchronizing files or directories. However, rsync and related tools have poor worst case performance with regards to the amount of data they communicate. Furthermore, rsync performs directory synchronization by individually synchroniz- ing files with common names/locations and thus behaves poorly if a file's name/location changes, an issue we seek to remedy with our model of directory reconciliation. Set reconciliation is a related problem in which Alice and Bob each have a set, and they wish to communicate efficiently so that Bob can recover Alice's set given knowledge of a small bound d on the difference between their sets [13, 20]. One of the solutions to set reconciliation makes use of the Invertible Bloom Lookup Table (IBLT) [7, 8]. We make extensive use of IBLTs in several of our protocols, and describe them further in subsection 2.2. Set of sets reconciliation extends set reconciliation to the scenario where Alice and Bob's set elements are themselves sets, as proposed in [14]. Here the bound d is on the number of element additions and deletions needed to make their sets of sets equal. Mitzenmacher and Morgan [14] develop several protocols for this problem that we adapt to the setting of document exchange, once again making heavy use of IBLTs. Noisy binary search is the problem of searching via comparison for an item in a list or graph in which those comparisons have some chance of returning an incorrect response [3, 6]. Solutions for this include multiplicative weights based algorithms which incrementally reinforce the likelihood that each possible candidate is the target. Our multi-round document exchange protocol draws heavily from these ideas, by using noisy hash based comparisons to incrementally discover common 2 substrings of Alice and Bob's documents. More specifically, we repeatedly use a variation of noisy binary search to find the longest substring of Bob's document that is a prefix of Alice's document. While similar to Nisan and Safra's use of noisy binary search to find the longest common prefix of two strings [16], the expansion to substrings greatly complicates realizing our desired communication bound. 2 Preliminaries We focus on two problems, directory reconciliation and document exchange. In the problem of directory reconciliation, Alice and Bob each have a directory, represented as a set of at most s documents, each of which is binary string of length at most h.2 Recall that to interpret a file directory as a set, the file's name and directory location are encoded as a prefix of the document. Hence moving a file or changing its name corresponds to a small number of character edits to the corresponding document in our set. The sum of the sizes of each parties' documents is at most n. Bob's directory is equal to Alice's after a series of at most d edits (single character insertions, deletions, and substitutions) to Alice's protocols designed to terminate with Bob fully recovering Alice's directory. documents. Let bd be an upper bound on the number of documents that differ between Alice and Bob. In general, we may not have such a bound in which case we use bd = min(d, s). We develop In document exchange, Alice and Bob each have a binary string (a and b respectively) of length at most n. We have a bound k on either ∆e(a, b), the edit distance between a and b, or ∆¯e(a, b), the edit distance with block moves. ∆e(a, b) is equal to the minimum number of character insertions, deletions and substitutions to transform a into b. ∆¯e(a, b) is equal to the minimum number of block moves, character insertions, deletions, and substitutions to transform a into b. The goal of a document exchange protocol is to allow Bob to recover a as efficiently as possible. Throughout this paper, we work in the word RAM model, with words of size Θ(log n) for both problems. We refer to the number of rounds of communication in a protocol for the total number of messages sent. A one round protocol therefore consists of a single message from Alice to Bob. All of our protocols use the public randomness model, meaning that any random bits used in the protocol are shared between Alice and Bob automatically, without additional communication. This simplifies our presentation as our protocols make heavy use of various hash functions, and public randomness allow Alice and Bob to be able to use the same hash functions without communication anything about them. Our protocols can be converted to the private randomness model using minimal additional communication via standard techniques [15]. In practice, one would instantiate the public randomness model by sharing of a small random seed to be used for generating all of the random bits used in the protocol. 2.1 Document Exchange Protocols Our protocols often use existing document exchange protocols as subroutines. Here we review the current state-of-the-art document exchange protocols for the setting of edit distance, and edit distance with block moves.3 The following is the best known protocol for document exchange under edit distance with block moves. 2We use a binary alphabet here for convenience. Our results easily extended to larger alphabets. 3At the time of this writing, there is a newly released protocol for document exchange under edit distance without block moves of [10]. As this paper is still in pre-print form, and in particular currently lacks a concrete running time for its document exchange protocol, we have opted not to discuss it here. 3 Theorem 2.1 (Theorem 1 of [11]). Document exchange under edit distance with block moves can be solved in one round using O(k log n log(n/k)) bits of communication and O(n log(n/k)) time, with probability at least 1 − 1/poly(n). The protocol for this theorem is fairly simple. For each of Θ(log(n/k)) levels, Alice transmits an encoding of a. For each level i in [Θ(log(n/k))], she splits her string into 2ik blocks, computes a Θ(log n) bit hash of each one, and encodes them using the systematic part of a systematic error correcting code for correcting O(k) errors. At the bottom level, where the blocks are of size Θ(log n), she encodes the blocks themselves rather than hashes of them. After receiving this message, Bob iterates through the levels. Since the first level has O(k) blocks, he can decode it immediately and recover Alice's hashes. He applies a rolling hash to every length n/k contiguous substring of b and if any of Alice's hashes match any of his own, then by inverting the hash (assuming no hash collisions) he knows the contents of that block of a. Bob then continues through the levels, each time using what he has recovered so far of Alice's string to decode the next level's code. Since there are O(k) edits between their strings, it can be shown that each level will only have O(k) hashes that aren't present in Bob's string. By decoding the final level, Bob will have recovered Alice's whole string. The protocol only fails if there are hash collisions, which, given the hash size and number of strings hashed, occurs with probability 1 − 1/poly(n). block moves. Now we turn to the best known protocol for document exchange under edit distance without Theorem 2.2 (Theorem 9 of [2]). Assuming k < nε for a sufficiently small constant ε > 0, document exchange under edit distance can be solved in one round using O(k(log2 k + log n)) bits of communication and O(n(log k + log log n)) time, with probability at least 1 − 1/poly(k log n). Note that for the case where k ≥ nε, Theorem 2.1 represents the best known document ex- change protocol, even under edit distance without block moves. Theorem 2.2 is based on a careful application of the CGK encoding of [4], which embeds from the edit distance space into Hamming space. Theorem 2.2 results from applying this encoding O(log log n) times, each time matching up common pieces of a and b using the encoding, until at the final level the unmatched strings are of small enough size that applying Theorem 2.1 yields the desired bound. 2.2 Invertible Bloom Lookup Tables Several of our protocols make use of the Invertible Bloom Lookup Table (IBLT) [8], a data structure representing a set that was designed to solve the set reconciliation problem. We summarize the structure and its properties here; more details can be found in [7, 8]. An IBLT is a hash table with q hash functions and m cells, which stores sets of key-value pairs. (It can be used to just store keys also.) We add a key-value pair (each from a universe of size O(u)) to the table by updating each of the q cells that the key hashes to. (We assume these cells are distinct; for example, one can use a partitioned hash table, with each hash function having m/q cells.) Each cell has a number of entries: a count of the number of keys hashed to it, an XOR of all of the keys hashed to it, an XOR of a checksum of all of the keys hashed to it, and, if we are using values, an XOR of all the values hashed to it. The checksum, produced by another hash function, is O(log u) bits and is meant to guarantee that with high probability, no cells containing distinct keys will have a colliding checksum. We can also delete a key-value pair from an IBLT through the same operation as adding it, except that now the counts are decremented instead of incremented. An IBLT is invertible because if m is large enough compared to n, the number of key-value pairs inserted into it, we can recover those n pairs via a peeling process. Whenever a cell in the 4 table has a count of 1, the key XOR will be equal to the unique key inserted there, and the value XOR will be equal to the unique value inserted there. We can then delete the pair from the table, potentially revealing new cells with counts of 1 allowing the process to continue until no key-value pairs remain in the table. This yields the following theorem. Theorem 2.3 (Theorem 1 of [8]). There exists a constant c > 0 so that an IBLT with m cells (O(m log u) space) and at most cm key-value pairs will successfully extract all keys with probability at least 1 − O(1/poly(m)). A useful property of IBLTs is that we can "delete" pairs that aren't actually in the table, by allowing the cells' counts to become negative. In this case, the IBLT represents two disjoint sets, one for the inserted or "positive" pairs and one for the deleted or "negative" pairs. This addition requires a minor modification to the peeling process, which allows us to extract both sets. Now just as we peeled cells with 1 counts by deleting their pairs from the table, we also peel cells with −1 counts by adding theirs pairs to the table. Unfortunately, a cell with count of 1 or −1 might have multiple pairs (some from each set) hashed there, whose counts only add up to ±1. However, we remedy this issue by using our checksums. With high probability, a cell with a count of ±1 will actually represent only a single pair if and only if the checksum of the cell's key XOR equals the cell's checksum XOR. This property of IBLTs allows us to insert each of the items in a single set into the IBLT, then delete the items from another set from the IBLT. Inverting the IBLT then reveals the contents of the symmetric set difference of the original two sets, and by Theorem 2.3 will succeed with high probability so long as the size of this set difference is at most cm. In most of our uses of the IBLT, we only have keys, and no associated values. As such, unless otherwise noted, assume that our IBLTs lack value fields, and when we insert or delete an item from the IBLT, we are treating it as a key. We sometimes refer to "encoding" a set in an IBLT as inserting all of its elements into it. We similarly "decode" a set difference from an IBLT by extracting its keys. There is one final nice property of IBLTs that we exploit. Let T1 and T2 be two IBLTs with the same number of cells and the same hash functions. Let S1 and S2 be two sets, and we insert the items of S1 into T1 and the items of S2 into T2. If S1 and S2 are disjoint, then we can "add" T1 and T2 together to make a single IBLT encoding S1 ∪ S2. We do this iterating through i ∈ [m], adding the ith cells of T1 and T2 together by summing their counts and XORing their other fields. Similarly, we can "subtract" T1 and T2 to yield a single IBLT encoding the symmetric set difference of S1 and S2. 2.3 Notation Given a (1-indexed) vector s of length n, we will use the notation si:j to refer to subset of s consisting of indices i through j inclusive. Similarly, s:i refers to the length i prefix of s and si: refers to the the length n − i + 1 suffix of s. We will frequently use Θ(log n) bit hashes as identifiers for strings. We use the property that for a sufficiently large constant in the order notation, we have no collisions among at most poly(n) such hashes with probability at least 1 − 1/poly(n). 3 Multi-Round Document Exchange Protocol Before we provide our own protocol for document exchange, we show that directory reconciliation can be solved via a straightforward reduction to document exchange under edit distance with block 5 moves. The current state-of-the-art protocol for this problem is Theorem 2.1, and this reduction provides a baseline against which we compare the rest of our protocols. Theorem 3.1. Directory reconciliation can be solved in one round using O(d log n log(n/d)) bits of communication and O(n log(n/d)) time with probability at least 1 − 1/poly(n). The protocol for this starts with each party computing a Θ(log n) bit hash of each of their documents. They concatenate their documents together, with each pair separated by a random Θ(log n) bit delineation string, then perform document exchange on their concatenated documents via Theorem 2.1, and finally Bob decomposes Alice's concatenated document into Alice's direc- tory. As we argue in Appendix A, the edit distance with block moves between the concatenated documents is at most 2d, and thus Theorem 2.1 yields the desired bounds. Now we develop a protocol for document exchange under edit distance with block moves that achieves a communication cost of O(k log n). We do this with a multi-round protocol, inspired by noisy binary search algorithms [6], that identifies the common blocks between Alice and Bob's strings via many rounds of back and forth communication. Theorem 3.2. Document exchange under edit distance with block moves can be solved in O(k log n) rounds using O(k log n) bits of communication and O(n2 log n) time, with probability at least 1 − 2−Θ(k√log n) − 1/poly(n). This implies a protocol for directory reconciliation via the same reduction as in Theorem 3.1. Corollary 3.3. Directory reconciliation can be solved in O(d log n) rounds using O(d log n) bits of communication and O(n2 log n) time, with probability at least 1 − 2−Θ(d√log n) − 1/poly(n). The main technical work in our protocol comes from the following lemma. Lemma 3.4. Given κ ≤ n, Alice can find the longest prefix of her document up to length n/κ that is a contiguous substring of Bob's document in O(log n) rounds using O(log n) bits of communication and O((n2/κ) log n) time, with probability at least 1 − 2−√ln n. We prove Lemma 3.4 later, building off of techniques from noisy binary search in graphs [6]. We use this lemma as a subroutine in our protocol for Theorem 3.2 by incrementally building up a larger and larger prefix of Alice's document that is known to Bob. Along the way Lemma 3.4 may fail due to its own internal randomness, but we make no assumptions on what mode that failure takes. Lemma 3.4's protocol may abort and report failure, it may report a prefix of Alice's document that is too long, and thus is not a substring of Bob's document, or it may report a prefix that is a substring of Bob's document but is not the longest possible one. We show that so long as most of our applications of Lemma 3.4 succeed, no matter what form the failures take, our resulting protocol for document exchange will succeed. Proof of Theorem 3.2. Let a ∈ {0, 1}n be Alice's document and b ∈ {0, 1}n be Bob's document. Our protocol will happen in t ≤ 10k phases. After each phase, Bob will have recovered a progressively larger prefix of a. After the ith phase he will have recovered a(i), where a(i) is a prefix of a and a(t) = a with probability at least 1 − 2−Θ(k√log n) − 1/poly(n). We use a − a(i) to refer to the string a after removing the prefix a(i). Given a string s, we use s to refer to the length of s. In the ith phase, Alice and Bob uses Lemma 3.4 (setting κ = k) to find the largest prefix s (up to length n/k) of a − a(i−1) contained in b. If s is shorter than log2 n, Alice directly transmits the first log2 n bits of a − a(i−1), thus a(i) = a(i−1) + log2 n. Otherwise, Alice transmits s, along with a Θ(log n) bit hash of s to Bob, who compares it to to the hash of each length s substring 6 in b. With probability at least 1 − 1/poly(n), the hash of s matches only one unique substring of b, and that is s, thus Bob has recovered a(i) = a(i−1) + s. If at any point a failure occurs, either one detected in Lemma 3.4 or if the hash of s does not have a unique match, we move on letting a(i) = a(i−1). First we argue that assuming no hashing failures or failures in Lemma 3.4, the protocol succeeds with t ≤ 5k. The argument follows that of Lemma 3.1 of [11]. We imagine that b is written on a long piece of paper, and we perform each edit operation to transform b into a by cutting the paper, rearranging pieces and inserting individual characters for insert and substitution operations. Each operation requires at most 3 cuts, so a consists of the concatenation of at most 3k substrings of b plus up to k newly inserted characters. In each phase of the algorithm, we either recover up to the end of one of the substrings, at least one of the inserted characters, or n/k characters. The first case can happen at most 3k times, the second and third cases can each happen at most k times, so at most 5k phases are required to recover a in its entirety. There are two ways that a phase can fail; either the hash of s can match with a substring of b that does not equal s, or Lemma 3.4 can fail. Union bounding over the t ≤ 10k phases, with probability at least 1 − 1/poly(n), none of the hashes mismatch. Lemma 3.4 can fail one of three ways: it can report an s which is too short, report an s that is too long, or it can fail to find an s at all. If it fails to find an s, we have case where a(i) = a(i−1), basically meaning we try again with fresh randomness. If s is too long, then assuming no hash mismatches, Bob will not find a substring of b that matches s's hash so we once again have a(i) = a(i−1). Finally if s is too short, a(i) > a(i−1) but we won't have completed one of the at most 3k substrings of b of which a is comprised. So long as Lemma 3.4 succeeds 5k times in at most 10k phases, the protocol succeeds. Since √ln n, by a Chernoff bound, each application of Lemma 3.4 succeeds with probability at least 1 − 2 we succeed at least 5k times in 10k attempts with probability at least 1− 2−k(√ln n−2) so our overall success probability is at least 1 − 2−Θ(k√log n) − 1/poly(n) as desired. Each phase uses O(log n) rounds totaling O(log n) bits of communication and takes O((n2/k) log n) time, thus the whole protocol takes O(k log n) rounds, uses O(k log n) bits of communication and takes O(n2 log n) time. Now we sketch the protocol for Lemma 3.4, with the details presented in Algorithm 2. In our protocol, Bob will represent all contiguous substrings of his document of length at most n/κ using a tree T . Each node in T represents a substring of b. The root of T corresponds to the empty string, and each node at depth r corresponds to a unique substring of length r. A node at depth r's parent is the node corresponds to its length r − 1 prefix. T is essentially an uncompressed suffix tree [9] formed from the reverse of each of the length n/κ substrings of b. We use Dr to refer to the set of nodes in T at depth r. Given a node u, Tu refers to the subtree rooted at u in T . We use T−r to refer to the tree above depth r. In other words T−r = T −∪u∈Dr Tu. Our protocol will consist of Θ(log n) phases. In the ith phase, we draw an O(1) bit hash function h, and Alice sends h(a:ℓ) to Bob. Bob then compares this hash to the depth ℓ nodes in T (the length ℓ substrings of b). Bob then responds with information to determine what ℓ to use in the next phase. After Θ(log n) rounds of this, we hope to gain enough information from these hashes for Bob to confidently determine the length of the largest prefix of a which is contained in b. The set of prefixes of a which are contained in b correspond to a path from the root in T . We are searching for a single node g in T , which is the last node in this path. Whenever h(a:ℓ) does not match the hash of a node u in T , we know that g is not in the subtree rooted at u. When the hash does match, then g is more likely to be in the subtree rooted at u, and less likely to be in the rest of T . This is essentially the kind of feedback used in noisy binary search in graphs [6]. If we 7 Algorithm 1 MultWeightsProtocol(a, I, t, T ): Alice inputs (a, I, t). Bob inputs (T, I, t). • Alice and Bob: t ← 1 and q1 ← 1. • Bob: w(u) ← 1 for all i ∈ t. M ← ∅. • For i = 1 to t: -- Bob: if ∃u ∈ T such that w(u) > w(T )/2: ∗ Bob: w(u) ← 0, M ← M ∪ {u} and η ← 0. ∗ Bob: send η to Alice. -- Bob: otherwise: ∗ Bob: ρ ← argminr max (w(T−r), maxu∈Dr w(Tu)). Sets o such that ρ ∈ Io. ∗ Bob: if o ≥ q1, q′1 ← min(o, q1 + 3). Otherwise, q′1 ← max(o, q1 − 3). ∗ Bob: ℓ′1 ← I ∗ Bob: if q′1 = o and ℓ′1 is not balanced with respect to w, η ← 2, we set either 2/2m straddle ρ, meaning that q′2 ← q′1 + 1 or q′2 − 1 so that ℓ′1 and ℓ′2 = I min(ℓ′1, ℓ′2) < ρ < max(ℓ′1, ℓ′2). 1/2m (the midpoint of Iq′ ) and η ← 1. 1,lIq′ q′ 2,lIq′ q′ 1 ∗ Bob: send η and q′j − qj for j ∈ [η] to Alice. -- Alice and Bob: for j ∈ [η]: qj ← q′j, mj ←(cid:6)Iqj/2(cid:7), ℓj ← Iqj,mj . -- Alice: for j ∈ [η], send h(a:ℓj ) to Bob. -- For j ∈ [η]: for u ∈ Dℓj : if h(a:ℓj ) = h(u), for all v ∈ Tu, w(v) ← w(v) · p and for all v ∈ T − Tu, ∗ Bob: ∗ Bob: if h(a:ℓj ) 6= h(u), for all v ∈ Tu, w(v) ← w(v) · (1 − p)2 and for all v ∈ T − Tu, w(v) ← w(v) · (1 − p). w(v) ← w(v) · p2. -- Alice and Bob: split I around the queried points. Specifically, for j ∈ [η] in descending order of qj, if Iqj > 1 then I ← I:qj−1 + Iqj,:mj−1 + Iqj,mj : + Iqj+1: • Bob: send to Alice a 2t-bit vector z indicating for each phase whether any nodes at depth ℓ1 or ℓ2 are in M . • Alice and Bob: construct I′ such that I′ = 1 and I′1 is the ordered list of unique depths of nodes in M . • Alice: return I′. • Bob: return I′ and M . were unconstrained in the amount of communication Bob sends to Alice to determine the next ℓ, and Bob could simply send Θ(log n) bits to exactly specify the optimum ℓ, then we could reduce directly to the algorithm of [6]. However, in order to achieve the lemma we must restrict ourselves to O(1) bits of communication per phase. We emphasize that this is where most of our technical contribution lies, as it requires new techniques and analysis to handle this restriction. Both Alice and Bob maintain a partitioning of the range [n] into intervals I1, . . . , It. Before the 8 Algorithm 2 Alice inputs a, n and κ. Bob inputs b, n and κ. • Bob: construct T1, the tree representing all contiguous substrings of b up to length n/κ. • Alice and Bob: δ ← 2−√ln n/3 and t1 ← 85 ln n + 63 ln(1/δ). • I1, M1 ← MultWeightsProtocol(a, [n], t1, T1) • Bob: construct T2, the tree representing the hierarchy of the nodes in M1. • Alice and Bob: t2 ← 82 ln t1 + 63 ln(1/δ). • I2, M2 ← MultWeightsProtocol(a, I1, t2, T2) • For r ∈ I2 (in decreasing order): -- Alice: send Θ(log t2 + log(1/δ))-bit hash h′(a:r) to Bob -- Bob: if ∃u ∈ M2 ∩ Dr such that h′(u) = h′(a:r), send 1 to Alice and return u -- Alice: if received 1, return r • Alice and Bob: return failure first phase, they just have one interval containing all of [n]. In each phase, Alice and Bob agree to query in the qth interval. Alice then chooses ℓ to be the midpoint of Iq. After transmitting the h(a:ℓ), the interval containing ℓ will be split in two around ℓ. Bob then tells Alice which interval to choose the next ℓ from, by transmitting O(1) bits specifying how much to add or subtract from q. We choose the size of hi so that the probability of two unequal strings having matching hash values is at most 1 − p = 1/3. For each node u ∈ T , Bob maintains a weight w(u). All the weights are initialized to 1, and Bob updates them in response to the hashes he receives from Alice. For each u ∈ Dℓ, if h(a:ℓ) = h(u), we multiply each of the weights in Tu by p and we multiply the weights of all other nodes in T by 1 − p. If h(a:ℓ) 6= h(u), we multiply each of the weights in Tu by (1 − p)2 and we multiply the weights of all other nodes in T by p2. Here we are using the one-sidedness of comparisons, in that if the hashes do not match then we know that the strings do not match with probability 1. As a result, we could instead zero the weights of the nodes in Tu when h(a:ℓ) 6= h(u), but doing so would not improve our asymptotic result and would complicate the analysis. Whenever a node's weight is at least half of the total tree weight, we zero its weight and add the node to a list M . We show that after Θ(log n) rounds, our goal g is likely to be in M . We then repeat this protocol with a new tree T2 consisting only of nodes in M . T2 is formed by taking the transitive closure of T , then removing all nodes not in M , then taking the transitive reduction of the result. In other words, in T2, u is a parent of v if u was v's most recent ancestor in M . Note that unlike T , T2 need not be a binary tree. When running the protocol on T2, we now have that I no longer consists of intervals, but is instead contiguous subsets of the node depths present in M , and when we select the midpoint of an element of I, we choose the median. We show that by running the protocol on T2 for Θ(log log n) rounds, g is likely to be in the new candidate list of M2 = Θ(log log n), so at this point, we directly determine which node in M2 is g by nodes M2. sending a Θ(√log n) bit hash for each node in M2. Now we argue that Algorithm 2 satisfies Lemma 3.4. First we note that all of the steps in MultWeightsProtocol are achievable, with the only non-trivial part being provided by the 9 following lemma. Lemma 3.5. In MultWeightsProtocol, Alice can construct I′ using z. Proof. Consider a node u ∈ Dr and its parent v. If r has not been queried in any phase, then w(u) = w(v). This is because any weight update performed by a query at a depth r′ 6= r will update w(u) and w(v) identically. If r′ > r then either w(u) and w(v) will be unchanged or they will both be multiplied by 1 − p. If r < r then either w(u) and w(v) will both be multiplied by p or they will both be set to 0. In order for u to be added to M , w(u) > w(T )/2. This is impossible if w(u) = w(v), therefore r must have been queried in at least one phase. Thus, every depth r that could be in I′ will be included in z so Alice can construct I′. We say that a depth r is queried in a phase i of Algorithm 1 if ℓ1 = r or ℓ2 = r in that phase. A query of depth r partitions the the tree into Dr + 1 components: T−r along with Tu for each u ∈ Dr. A query of depth r is balanced if each component has at most 3/4 of the total weight in the tree. In other words, max (w(T−r), maxu∈Dr w(Tu)) ≤ (3/4)w(T ). A query of depth r is informative if the component containing the target node g has total as most 3/4 of the total mass. Specifically, if g ∈ T−r then w(T−r) ≤ (3/4)w(T ) and if g ∈ Tu for u ∈ Dr, then w(Tu) ≤ (3/4)w(T ). A balanced query is guaranteed to be informative, but an informative query need not be balanced. We call phase i of Algorithm 1 informative if either an informative query is performed or if a node is added to M . Lemma 3.6. In MultWeightsProtocol, ρ = argminr max (w(T−r), maxu∈Dr w(Tu)) is guar- anteed to be a balanced query. Proof. If ρ is not balanced, then either w(T−ρ) > (3/4)w(T ) or there exists a u ∈ Dρ such that w(Tu) > (3/4)w(T ). Additionally, by the definition of ρ, if it is not balanced then no query is. Suppose w(T−ρ) > (3/4)w(T ). Let ρ′ be the smallest (least deep) query such that w(Tρ′ ) = w(Tρ). By the definition of ρ, there must exist a u′ ∈ Dρ′−1 for which w(Tu′) ≥ w(T−ρ) > (3/4)w(T ). Tu′ consists of u′ together with a subset of ∪v∈Dρ′ Tv. Since w(T−ρ′ ) > (3/4)w(T ), Pv∈Dρ′ w(Tv) < (1/4)w(T ). Furthermore, every node in the tree has weight at most w(T )/2, or it would have been zeroed in a previous step. Therefore, w(Tu′) ≤ w(T )/2 + (1/4)w(T ) = (3/4)w(T ), which is a contradiction so we cannot have that w(T−ρ) > (3/4)w(T ). The argument showing that there cannot exist a u ∈ Dρ such that w(Tu) > (3/4)w(T ) is essentially identical. Lemma 3.7. If g ∈ T , MultWeightsProtocol(a, I, t, T ) performs at least (2t − 8 log3/2 τ )/7 informative phases, where τ is the height of T . Proof. Let r∗ be the depth of g, and q∗ be the interval containing r∗. We introduce the potential function Φ = q1 − q∗ + α(log2 I∗q + log2 Iq∗+1), where α = 4/ log2(3/2). If q∗ is the final interval, then instead Φ = q1 − q∗ + α(log2 I∗q + log2 τ ). We argue that in each phase, either a node is added to M , an informative query is performed and Φ increases by at most 5, or Φ decreases by at least 2. split in two, and I∗q and Iq∗+1 are non-increasing. No phase can ever increase Φ by more than 5 since q′1 − q1 ≤ 3 and at most two intervals are If q′1 6= o then we have two cases: 1. ℓ′1 is in between ρ and r∗. In this case ℓ′1 is informative because ρ is balanced (by Lemma 3.6) and ℓ′1 is closer to r∗ than ρ so the component containing g formed by partitioning around ℓ′1 must have at most 3/4 of the total weight. 10 2. ρ is in between ℓ′1 and r∗ or r∗ is in between ℓ′1 and ρ. Since q′1 6= o, q′1 must be 3 steps closer to o than q1, which in either ordering means it must also be 3 steps closer to q∗. Thus q1− q∗ must decrease by at least 2 (not 3 because splitting an interval can increase the distance by 1). If q′1 = o, then we have a few cases: 1. ℓ′1 is balanced. In this case our query is guaranteed to be informative. 2. r∗ < min(ℓ′1, ℓ′2). min(ℓ′1, ℓ′2) is in between r∗ and ρ so it is guaranteed to be informative. 3. r∗ > max(ℓ′1, ℓ′2). max(ℓ′1, ℓ′2) is in between r∗ and ρ so it is guaranteed to be informative. 4. I∗q ≥ 2 and min(ℓ′1, ℓ′2) ≤ r∗ ≤ max(ℓ′1, ℓ′2). Either q′1 = q∗ or q′2 = q∗ so I∗q will shrink by a factor of at least 2/3. q1 − q∗ afterwards will be at most 2, thus in total Φ will decrease by at least α log2(3/2) − 2 = 2. 5. I∗q = 1 and min(ℓ′1, ℓ′2) = r∗. Either max(q′1, q′2) = q∗ + 1 so Iq∗+1 will shrink by a factor of at least 2/3. q1 − q∗ afterwards will be at most 2, thus in total Φ will decrease by at least α log2(3/2) − 2 = 2. 6. I∗q = 1 and max(ℓ′1, ℓ′2) = r∗. max(ℓ′1, ℓ′2) is guaranteed to be an informative query since ρ < max(ℓ′1, ℓ′2) so w(Tg) < (3/4)w(T ). Initially, Φ = 2α log2 τ since there is only one interval. Φ is also always non-negative. Thus, over t phases, if ι is our number of informative phases then and so ι ≥ (2t − 2α log2 τ )/7 = (2t − 8 log3/2 τ )/7. 2α log2 τ + 5ι − 2(t − ι) ≥ 0, Let Xi be w(g)/w(T ) at the beginning of phase i in MultWeightsProtocol. Let Yi = ln(Xi+1/Xi). We will use these random variables to bound the probability that at the end of MultWeightsProtocol, w(g) < w(T )/2 and thus g is never added to M . First we provide some bounds on them, whose proofs appear in Appendix B. Lemma 3.8. If no node is added to M in phase i, then −2 ln(cid:16) p other than g is added to M in phase i, then Yi ≥ ln 2. 1−p(cid:17) ≤ Yi ≤ 6 ln(cid:16) p 1−p(cid:17). If a node Lemma 3.9. If p ≥ 2/3, and g is not in M by the end of phase i, then E[Yi] ≥ 0. Additionally, if phase i is informative, then E[Yi] ≥ ln(4p/(2p2 + p + 1)). Using these bounds on the Yis, together with Lemma 3.7 we can apply a Chernoff bound to get the following lemma (whose proof also appears in Appendix B). Lemma 3.10. If p = 2/3, g ∈ T , and t ≥ 79 ln τ + 3 ln T + 63 ln(1/δ), where τ is the height of T , then MultWeightsProtocol(a, I, t, T ) will output an M which includes g with probability at least 1 − δ. Now we put all of these pieces together. 11 Proof of Lemma 3.4. We prove that Algorithm 2 achieves the lemma. First we argue correctness. The only step of MultWeightsProtocol where it is not immediate that Alice or Bob has the required information to perform the protocol is whether Bob can construct I′1, which we proved in Lemma 3.5. By Lemma 3.10 and our choice of t1 (since T1 ≤ n2), M1 will contain g with probability at least 1− δ. Since M1 ≤ t1, together with Lemma 3.10, our choice of t2, and a union bound we have that M2 will contain g with probability at least 1 − 2δ. With our choice of hash size for h′, we can make the probability of hash collisions at most δ/t2 ≤ δ/M2. Thus, by a union bound, with probability at least 1− 3δ there are no hash collisions and the Alice returns g and Bob returns g. Thus by our choice of δ, the protocol succeeds with probability at least 1 − 2−√ln n. Each phase of MultWeightsProtocol uses O(1) rounds of communication and transmits O(1) bits. At the end of MultWeightsProtocol there is a single message of size 2t, thus MultWeightsProtocol performs O(t) rounds of communication and O(t) bits of communica- tion. Thus, between our two applications of MultWeightsProtocol and the hashes transmitted at the end our rounds of communication are bounded by O(t1 + t2 + I2) = O(t1 + t2) = O(log n + log(1/δ)) = O(log n). Our bits of communication are bounded by O(t1 + t2(log t2 + log(1/δ))) = O(log n + log2(1/δ)) = O(log n). The computation bottleneck is the first application of MultWeightsProtocol. Each phase takes O(n) time compute all of the hash evaluations (using a rolling hash function) and O(T1) time to update all the weights and select the next interval to query, so the total computation time is O((n + T1)t1) = O((n2/κ) log n). 4 Sets of Sets Based Protocols Corollary 3.3 is aimed at minimizing the number of bits of communication, but it does so at the expense of both rounds of communication and computation time. In this section we develop a single round protocol that is much faster and still outperforms Theorem 3.1 in communication cost for most cases. Theorem 4.1. Directory reconciliation can be solved in one round using O(d log s + d log3 min(d, h) + d log h log min(d, h)) bits of communication and time with probability at least 2/3. O(nd log log h + nbd log2 min(d, h) + nbd log min(d, h) log log h) The protocol here is an adaptation of Theorem 3.7 of [14], using document exchange as a subroutine instead of set reconciliation. The basic idea is that we represent each document as a pair consisting of a hash of that document, together with the message that Theorem 2.2 (the best known one round document exchange protocol) would send to allow the other party to recover the document. For each of Θ(log d) different levels, we make a different version of this representation for each document, varying the bound k on the edit distance used in the document exchange protocol. 12 In the ith level, starting at i = 1, k = 2i. Then, we encode all of the document representations in level i into an IBLT of size Θ(d/2i). These IBLTs are the message from Alice to Bob. Bob constructs analogous representations and IBLTs. Bob is able to decode all of the level 1 representations corresponding to differing documents, since the IBLT is of size Θ(d). Bob consider all combinations of his documents and Alice's extracted representations. For each of these pairs, he attempts to perform his side of the document exchange protocol used in Theorem 2.2. Since the bound k Alice used at this level was 2, the document exchange protocol will succeed (with high probability) whenever he pairs one of his documents with Alice's representation of a document that differs by at most 2 edits. For those pairs differing in more than 2 edits, the protocol will generally fail, either reporting failure or by yielding an incorrect document, which he can detect using Alice's document's hash. He then generates representations for those documents he recovered from Alice, and removes them from the level 2 IBLT so that he can recover most of Alice's documents that have at most 4 edits, and so on, until he has recovered all of Alice's documents. The full details of the protocol and the proof of the theorem appear in Appendix C. If the only bound on h and s we have is that they are both O(n) (as they must be) then Theorem 4.1 uses O(d log n log d + d log3 d) bits of communication, which already generally out- performs our previous best one round protocol, Theorem 3.1, which uses O(d log n log(n/d)) bits of communication. The difference really shows when we have a tight bound on h, such as h = poly log n. In such a case Theorem 4.1 uses only O(d log n min(log d, log log n)) bits of communica- tion, outperforming Theorem 3.1 by at least a factor of Θ(log n/ log log n). This h regime is not an unnatural one, as it corresponds to the setting where our directory consists of a large number of small files. 4.1 Speeding Up The main weakness of Theorem 4.1 is the running time, which is Ω(nd), rather than a more desirable O(n). The original protocol for reconciling sets of sets on which this was based has a running time of O(n + poly(d)). The reason that Theorem 4.1 takes more time is that the document exchange protocols take time linear in the length of the documents to determine if protocol will succeed, while the underlying set reconciliation protocol used in [14] only takes time linear in the specified difference bound. This is a bottleneck because each document exchange message is compared to many documents to see if they can decode it, but each attempt takes linear time. In other words, if we can make a document exchange protocol that determines failure within time O(poly(k)), we can reduce the computation time of Theorem 4.1 to O(n + poly(d)). This holds even if Bob is allowed O(n + poly(k)) precomputation time before receiving Alice's message, since that would be a one time cost for each document. We develop such a document exchange protocol here, but it is primarily a proof of concept as it has an increased communication cost and so the resulting directory reconciliation protocol is very rarely superior to both Theorem 3.1 and Theorem 4.1 simultaneously. Further progress is necessary to yield an improved directory reconciliation protocol, but we believe that our approach here is a valuable starting point. Our document exchange protocol is a modification of Theorem 2.1. We sketch our changes here, and present the full details and proof in Appendix D. First, we limit ourselves to edit distance, rather than block edit distance, which means that rather than having to consider all Θ(n) possible blocks as matches, we only have to consider the k shifts of each corresponding block. For each of his possible blocks, of which there are k2 in the first level, 2k2 in the next and so forth, Bob precomputes the encoding of that block at that, and all lower levels. So for example the encoding of a block from the first level at the second level would be the combination of the encoding of the first half of the block and the second half of the block. For our error correcting code, we use IBLTs, which have the 13 advantage that they can combine two of these precomputed pieces efficiently. This will progress only down to the level where there are Θ(n/k2) blocks of size Θ(k2), at which point we transmit a direct encoding of the O(k) blocks of size Θ(k2), blowing up our communication to (k log n log(n/k) + k3). There are O(log(n/k)) levels, so the blocks from the first level require O(k2 log(n/k)) precomputed encodings and the bottom level requires O(n/k) precomputed encodings. Each encoding takes O(k) time to generate (once we have the lower level encodings and all of the hashes, which take O(n log(n/k))) so the total precomputation time takes roughly O(n log(n/k) + k3 log(n/k)). Once we have these precomputations, we can decode in roughly O(k2 log n) time, since at each level we just have to combine O(k) precomputed encodings of size O(k), and decode. This yields the following theorem. Theorem 4.2. There is a one round protocol for document exchange under edit distance using O((k log(n/k) log(n/δ) + k3)⌈logk log n⌉) bits of communication, which succeeds with probability at least 1 − 1/poly(k) if ∆e(a, b) ≤ k. Alice takes O(n log(n/k)) computation time, and Bob has an O(cid:0)n log(n/k) logn(n/δ) + k3 log(n/k) logn(n/δ)⌈logk log n⌉(cid:1) time precomputation step, before receiving Alice's message. After receiving Alice's message, Bob has an O(k2 log(n/k) logn(n/δ)⌈logk log n⌉) time failure check step. If the message passes the failure check, then the protocol will succeed with probability at least 1− δ (independent of ∆e(a, b)) after a final O(n⌈logk log n⌉) time step from Bob. Using this document exchange protocol as our subroutine instead of Theorem 2.2 in Theorem 4.1 yields the following directory reconciliation protocol. Theorem 4.3. Directory reconciliation with can be solved in one round using O(d log s + d log n log h log min(d, h) log log h + d min(d, h)2 log log h) bits of communication and O(n log h log min(d, h) + d3 log h log min(d, h) log log h + d2bd2 log n log log h) time with probability at least 3/5. This degrades our communication bound in Theorem 4.1 from O(d log n) to O(d log2 n + d3), but speeds it up from O(nd) to O(n + d4). The proof of this theorem is also in Appendix D. 4.2 Unknown d So far all of our protocols have assumed that we know d (or a good bound on it) in advance. Any of them can be extended to handle the case where d is unknown by the repeated doubling method. First we try the protocol with d = 1 and send a hash of Alice's directory along with it. If the protocol succeeds and the directory Bob recovers matches the hash, then we are done, otherwise we proceed to d = 2, 4, 8, ... until we eventually find the right value of d and succeed with good probability. This strategy will not increase any of our asymptotic communication costs and will only increase the computation times by at most a factor of log d, however all of our one round 14 protocols become Θ(log d) round protocols. For some applications, it is important to minimize the number of rounds of communication, so in this section we develop a protocol that allow for unknown/unbounded values of d while still using a constant number of rounds of communication. Our key techniques here are the CGK embedding [4] and set difference estimators [14]. The CGK embedding is a randomized mapping from edit distance space to Hamming space, such that with constant probability the Hamming distance between embedded strings will be Ω(k) and O(k2), where k was their original edit distance. Set difference estimators are O(log n) bit sketches that allow the computation of a constant factor approximation to the size of the difference between two sets, with constant probability. They can equivalently be used to estimate the Hamming distance between two strings. By combining these tools with Theorem 3.1 we get the following result. Theorem 4.4. Directory reconciliation with unknown d can be solved in 4 rounds using bits of communication and O(bd log n log s/ logbd +bd log n log max(bd, h) log h + d2 log n) time with probability at least 1 − 1/poly(n). O((sh +bd2) log n log max(bd, h) + d2 log n) This theorem is inspired by the multi-round approach to reconciling sets of sets in [14]. In the first round, we estimate the number of differing documents via set difference estimators. In the second round we perform set reconciliation on sets of hashes of the documents, to determine which among them differ. In the third round we exchange set difference estimators for the CGK embeddings of the differing documents, to determine which documents have close edit distance to which others, and what that edit distance is. In the final round we use that information to reconcile the differing documents by using Hamming distance sketches applied to the CGK embeddings used in the previous round. The fact that we use the same CGK embedding for reconciliation as for the estimate is what allows us to end up with only a final O(d2 log n) term. The full details and proof are presented in Appendix E. 5 Conclusion Directory reconciliation considers the reconciliation problem in a natural practical setting. While directory reconciliation is closely related to document exchange and document exchange with block edits variations, it has its own distinct features and challenges; also, while the problem is closely related to practical tools such as rsync, rsync works on a file-by-file basis that may be inefficient in some circumstances. Theoretically, we have found a document exchange scheme with O(k log n) bits of communication to handle k edits with block moves, at the expense of a number of rounds of interaction. The natural question is whether this result can be achieved with a single round. On the more practical side, we believe using the "set of sets" paradigm based on IBLTs may provide mechanisms that, besides being of theoretical interest, may also be useful in some real- world settings, where files may not be linked by file names but are otherwise closely related. References [1] rsync. https:// rsync.samba.org . 15 [2] Djamal Belazzougui and Qin Zhang. Edit distance: Sketching, streaming, and document exchange. In Foundations of Computer Science (FOCS), 2016 IEEE 57th Annual Symposium on, pages 51 -- 60. IEEE, 2016. [3] Michael Ben-Or and Avinatan Hassidim. The bayesian learner is optimal for noisy binary search (and pretty good for quantum as well). In Foundations of Computer Science, 2008. FOCS'08. IEEE 49th Annual IEEE Symposium on, pages 221 -- 230. IEEE, 2008. [4] Diptarka Chakraborty, Elazar Goldenberg, and Michal Kouck`y. Streaming algorithms for embedding and computing edit distance in the low distance regime. In Proceedings of the 48th Annual ACM SIGACT Symposium on Theory of Computing, pages 712 -- 725. ACM, 2016. [5] Graham Cormode, Mike Paterson, Suleyman Cenk Sahinalp, Uzi Vishkin, et al. Communi- cation complexity of document exchange. In Proceedings of the eleventh annual ACM-SIAM symposium on Discrete algorithms, pages 197 -- 206, 2000. [6] Ehsan Emamjomeh-Zadeh, David Kempe, and Vikrant Singhal. Deterministic and probabilis- In Proceedings of the forty-eighth annual ACM symposium on tic binary search in graphs. Theory of Computing, pages 519 -- 532. ACM, 2016. [7] David Eppstein and Michael Goodrich. Straggler identification in round-trip data streams via Newton's identities and invertible Bloom filters. IEEE Transactions on Knowledge and Data Engineering, 23(2):297 -- 306, 2011. [8] Michael Goodrich and Michael Mitzenmacher. Invertible Bloom lookup tables. In 49th Annual Allerton Conference on Communication, Control, and Computing, pages 792 -- 799, 2011. [9] Dan Gusfield. Algorithms on strings, trees and sequences: computer science and computational biology. Cambridge University Press, 1997. [10] Bernhard Haeupler. Optimal document exchange and new codes for small number of insertions and deletions. arXiv preprint arXiv:1804.03604, 2018. [11] Utku Irmak, Svilen Mihaylov, and Torsten Suel. Improved single-round protocols for remote file synchronization. In INFOCOM 2005. 24th Annual Joint Conference of the IEEE Computer and Communications Societies. Proceedings IEEE, volume 3, pages 1665 -- 1676. IEEE, 2005. [12] John Langford. Multiround rsync. 2001. [13] Yaron Minsky, Ari Trachtenberg, and Richard Zippel. Set reconciliation with nearly optimal communication complexity. IEEE Transactions on Information Theory, 49(9):2213 -- 2218, 2003. [14] Michael Mitzenmacher and Tom Morgan. Reconciling graphs and sets of sets. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 33 -- 47. ACM, 2018. [15] Ilan Newman. Private vs. common random bits in communication complexity. Information Processing Letters, 39(2):67 -- 71, 1991. [16] Noam Nisan. The communication complexity of threshold gates. Combinatorics, Paul Erdos is Eighty, 1:301 -- 315, 1993. [17] Alon Orlitsky. Interactive communication of balanced distributions and of correlated files. SIAM Journal on Discrete Mathematics, 6(4):548 -- 564, 1993. 16 [18] Ely Porat and Ohad Lipsky. Improved sketching of hamming distance with error correcting. In Annual Symposium on Combinatorial Pattern Matching, pages 173 -- 182. Springer, 2007. [19] Thomas Schwarz, Robert W Bowdidge, and Walter A Burkhard. Low cost comparisons of file copies. In Distributed Computing Systems, 1990. Proceedings., 10th International Conference on, pages 196 -- 202. IEEE, 1990. [20] David Starobinski, Ari Trachtenberg, and Sachin Agarwal. Efficient pda synchronization. IEEE Transactions on Mobile Computing, 2(1):40 -- 51, 2003. [21] Torsten Suel, Patrick Noel, and Dimitre Trendafilov. Improved file synchronization techniques for maintaining large replicated collections over slow networks. In Data Engineering, 2004. Proceedings. 20th International Conference on, pages 153 -- 164. IEEE, 2004. [22] Andre Trigdell and Paul Mackerras. The rsync algorithm. https:// rsync.samba.org/ tech report/ . A Reducing to Document Exchange with Block Edits We show here that directory reconciliation can be solved via a straightforward reduction to docu- ment exchange under edit distance with block moves. Theorem 3.1. Directory reconciliation can be solved in one round using O(d log n log(n/d)) bits of communication and O(n log(n/d)) time with probability at least 1 − 1/poly(n). Proof. First we describe the protocol, and then we will argue its correctness. Alice and Bob compute a Θ(log n) bit hash of each of their documents, then sort their hashes in O(s) time using radix sort. They then concatenate all of their documents into a single document, ordering them by the sorted order of their hashes. They choose a random Θ(log n) bit delineation string and insert it in between each pair of documents in the concatenation. They then engage in document exchange with their concatenated documents so that Bob recovers Alice's concatenated document. They use Theorem 2.1 with k = 2d. Bob then converts the concatenated document into a directory by splitting along the delineation strings, thus recovering Alice's directory. hash collisions, the documents will be ordered such that at most bd block moves are required to With probability at least 1 − 1/poly(n), no two of Alice and Bob's documents that are not equal will have equal hash values. Assuming this is the case, Theorem 2.1 will allow Bob to recover Alice's concatenated document with probability at least 1 − 1/n. This is because without order Alice's documents so that Alice and Bob's document orders correspond to the minimum edit distance matching between their documents. After making these block moves, the edit distance between Alice's and Bob's concatenated documents would be at most d. The optimal block edit distance between the original concatenated documents is therefore seen to be at most 2d, and thus Bob can recover Alice's concatenated document using the algorithm of Theorem 2.1 (for k = 2d) with probability at least 1 − 1/poly(n). With probability at least 1 − 1/poly(n) the delineation string will not appear in any of the documents, so splitting Alice's concatenated document using it will produce Alice's directory. The concatenated documents are of size O(n + s log(n)) = O(n) since the directories cannot have duplicate documents (since they are sets) so s ≤ n/ log n. Thus, by Theorem 2.1 the commu- nication cost is O(d log n log(n/d)). The running time is dominated by the O(n log(n/d)) used by Theorem 2.1 since it only takes O(n) time to construct the concatenated strings and then extract the directory. 17 B Missing Proofs for the Multi-Round Document Exchange Pro- tocol Here we providing the missing proofs from the lemmas used to prove that Algorithm 2 satisfies Lemma 3.4. Recall that Xi is w(g)/w(T ) at the beginning of phase i in MultWeightsProtocol, and Yi = ln(Xi+1/Xi). Lemma 3.8. If no node is added to M in phase i, then −2 ln(cid:16) p 1−p(cid:17) ≤ Yi ≤ 6 ln(cid:16) p 1−p(cid:17). If a node other than g is added to M in phase i, then Yi ≥ ln 2. Proof. We consider three cases, based on the value of η in phase i. First, let η = 0 and so no queries are performed and a single vertex v 6= g is added to M , such that w(v) > w(T )/2. In this case, as desired. Yi = ln(w(T )/(w(T ) − w(V ))) ≥ ln 2, Now let η = 1 so there is a single query performed in phase i. Let r be the query's depth. We Yi is maximized when there are no hash collisions. That is, h(a:r) = h(u) if and only if a:r = u. consider two subcases: g ∈ T−r and g ∈ Tv for v ∈ Dr. If g ∈ T−r, and there are no hash collisions, then / p2 w(g) p2Drw(g) w(T )! p2Drw(T−r) + p2Dr−2(1 − p)2(w(T ) − w(T−r)) (2p − 1)w(T−r)/w(T ) + (1 − p)2(cid:19) 1 − p(cid:19) . Yi = ln = ln(cid:18) ≤ 2 ln(cid:18) p (p3 − (1 − p)3)w(Tv)/w(T ) + (1 − p)(2p − 1)w(T−r)/w(T ) + (1 − p)3(cid:19) 1 − p(cid:19) . p3 Yi = ln(cid:18) ≤ 3 ln(cid:18) p If g ∈ Tv for v ∈ Dr and there are no hash collisions, then Yi is minimized when every single hash collides with h(a:r). h(a:r) = h(u) for all u ∈ Dr. If g ∈ T−r, and all hashes collide, then Finally we consider the case when g ∈ Tv for v ∈ Dr, and all hashes collide. Note that in this case we are still guaranteed that h(ar) = h(v) since ar = v. (1 − p)Drw(T ) Yi = ln = ln(cid:18) ≥ − ln(cid:18) p (1 − p)Drw(T−r) + p(1 − p)Dr−1(w(T ) − w(T−r))! p − (2p − 1)w(T−r)/w(T )(cid:19) 1 − p(cid:19) . 1 − p Yi = ln(cid:18) p − (2p − 1)w(T−r)/w(T )(cid:19) p ≥ 0. 18 Finally, if η = 2 then 2 queries are performed in phase i. By our previous arguments about one query, we immediately have that −2 ln(cid:18) p 1 − p(cid:19) ≤ Yi ≤ 6 ln(cid:18) p 1 − p(cid:19) . Lemma 3.9. If p ≥ 2/3, and g is not in M by the end of phase i, then E[Yi] ≥ 0. Additionally, if phase i is informative, then E[Yi] ≥ ln(4p/(2p2 + p + 1)). Proof. If η = 0 then by Lemma 3.8, Yi ≥ ln 2, so clearly E[Yi] ≥ 0. the value of the set of nodes u ∈ Dr such that h(u) 6= h(a:r). If η = 1, then phase i performs a single query at depth r. Let Ui be a random variable taking First, let g ∈ T−r. For each u ∈ Dr, Pr[h(u) 6= h(a:r)] ≥ p. Thus, E[Yi] = E[ln(Xi+1/Xi)] ≥ ln(1/E[Xi/Xi+1]) (Jensen's inequality) w(Tu) p2(1 − p)w(T ) p2(1 − p)w(T ) = ln 1/E" p2(1 − p)w(T−r) + (1 − p)3Pu∈Ui #! w(Tu) + p3Pu∈Dr\Ui  = ln w(Tu)(cid:3) + p3EhPu∈Dr\Ui w(Tu)i p2(1 − p)w(T−r) + (1 − p)3E(cid:2)Pu∈Ui ≥ ln(cid:18) p2(1 − p)w(T−r) + p(1 − p)3Pu∈Dr w(Tu) + p3(1 − p)Pu∈Dr w(Tu)(cid:19) p2(1 − p)w(T−r) + (p3(1 − p) + p(1 − p)3)(w(T ) − w(T−r))(cid:19) = ln(cid:18) = ln(cid:18) (1 − p)(2p − 1)w(T−r)/w(T ) + 1 − 2p(1 − p)(cid:19) p2(1 − p)w(T ) p2(1 − p)w(T ) p ≥ 0 (since w(T−r) ≤ w(T )), (1) (2) where the second inequality used linearity of expectations and then convexity. For informative queries, we have that w(T−r) ≤ (3/4)w(T ). Plugging this into Equation 2 we get4 E[Yi] ≥ ln(4p/(2p2 + p + 1)). 4We note that this bound approaches approaches 0 as p approaches 1, which is an unintuitive artifact of our analysis. However, since we choose p = 2/3, this is bounded away from 0. 19 Now we address the case when g ∈ Tv for v ∈ Dr. E[Yi] ≥ ln(1/E[Xi/Xi+1]) p3w(T ) #! = ln 1/E" p3w(Tv) + p(1 − p)w(T−r) + (1 − p)3Pu∈Ui w(Tu) + p3Pu∈Dr\(Ui∪{v}) w(Tu) = ln  w(Tu)(cid:3) + p3 EhPu∈Dr\(Ui∪{v}) w(Tu)i p3w(Tv) + p(1 − p)w(T−r) + (1 − p)3 E(cid:2)Pu∈Ui ≥ ln(cid:18) p3w(Tv) + p(1 − p)w(T−r) + (p3(1 − p) + p(1 − p)3)(w(T ) − w(Tv) − w(T−r))(cid:19) = ln(cid:18) (2p − 1)(1 − p(1 − p))w(Tv)/w(T ) + 2p(1 − p)2w(T−r)/w(T ) + (1 − p)(1 − 2p(1 − p))(cid:19) . Since p ≥ 2/3, (2p − 1)(1 − p(1 − p)) > 2p(1 − p)2. Thus, using only the constraint that w(Tv) + w(T−r) ≤ w(T ), Equation 3 is minimized when w(Tv) = w(T ) and w(T−r) = 0, which yields p3w(T ) (3) p3w(T ) p2 For informative queries, we also have the constraint that w(Tv) ≤ (3/4)w(T ), Equation 3 is minimized when w(Tv) = (3/4)w(T ) and w(T−r) = (1/4)w(T ). This gives us in which case E[Yi] ≥ 0. E[Yi] ≥ ln(4p2/(3p2 − p + 1)). Since p ≥ 2/3, ln(4p2/(3p2 − p + 1)) > ln(4p/(2p2 + p + 1)). Finally we consider cases where η = 2 and thus two queries are performed. Since E[Yi] ≥ 0 for one query, then by linearity of expectations E[Yi] ≥ 0 for two queries as well. Furthermore, if phase i is informative then at least one of the queries is informative so by linearity of expectations and our analysis of the second queries cases, E[Yi] ≥ ln(4p/(2p2 + p + 1)). Lemma 3.10. If p = 2/3, g ∈ T , and t ≥ 79 ln τ + 3 ln T + 63 ln(1/δ), where τ is the height of T , then MultWeightsProtocol(a, I, t, T ) will output an M which includes g with probability at least 1 − δ. Proof. In order for M to not include g, at no point in the protocol can w(g) > w(T )/2. In particular, after the final phase we must have w(g) ≤ w(T )/2. Since initially w(T ) = T and w(g) = 1, this means that Xt+1/X1 ≤ T/2. We will prove the lemma by showing that if g is never added to M , then Pr[Xt+1/X1 ≤ T/2] ≤ δ. Let Zi = 1/4 + Yi/(8α), where α = ln(p/(1 − p)). Let H ⊆ [t] be the set of phases in which a node is added to M . By Lemma 3.8, for i /∈ H, 0 ≤ Zi ≤ 1 and for i ∈ H, Zi ≥ 1/4 + ln(2)/(8α). By Lemma 3.9, E[Zi] ≥ 1/4 and if an informative query is performed in phase i, then E[Zi] ≥ 1/4+β/(8α), for β = ln(4p/(2p2 +p+1)). By Lemma 3.7, out of t queries, at least (2t−8 log3/2 τ )/7 of them are informative. Assuming t ≥ 32 log3/2 τ , µ = E Xi∈[t]\H Zi ≥ t(1 + β/(8α))/4 − H(1 + β/(2α))/4. 20 Putting these pieces together we have Yi ≤ ln(T/2)# 8α Zi ≤ ln(T/2) + tα Pr [Xt+1/X1 ≤ T/2] = Pr" tXi=1 # = Pr" tXi=1 ≤ Pr Xi∈[t]\H ≤ Pr Xi∈[t]\H Zi ≤ Zi ≤ (1 − ε) µ (where ε = 8α ln(T/2) + tα − H(ln 2 + 2α)  t(4α + β) + H(ln 16 − 4β) − 4 ln(T/2) t(8α + β) − H(8α + 4β) (4) ) For p = 2/3, ln 16 − 4β > 0 so with our assumption that t ≥ 8 ln(T/2)/(4α + β), the numerator of ε must be > 0, thus in order to have ε < 0 we must have H > t(8α + β)/(8α + 4β). Plugging this into Equation 4 we have ≤ e−ε2µ/2 (Chernoff bound, assuming ε ∈ [0, 1]) ≤ e− (t(4α+β)+8H(ln 2−β))2 ≤ e− t(4α+β)2 ≤ δ (assuming t ≥ ln(1/δ)(128α(8α + β)/(4α + β)2)). 128α(t(8α+β)−4H(2α+β)) (assuming t ≥ 8 ln(T/2)/(4α + β)) 128α(8α+β) (maximized at H = 0) Now let's address our assumption that ε ∈ [0, 1]. If ε > 1 then Pr Xi∈[t]\H Zi ≤ (1 − ε) µ ≤ Pr Xi∈[t]\H Zi < 0 = 0 < δ. Zi ≤ Pr Xi∈[t]\H ≤ Pr Xi∈[t]\H ≤ Pr Xi∈[t]\H ≤ Pr Xi∈[t]\H = 0 < δ. ln(T/2) + tα − H(ln 2 + 2α)  ln(T/2) + t(cid:16)α − (8α+β)(log 2+2α) 8α+4β 8α Zi ≤ 8α (cid:17)  4α+β(cid:16)α − (8α+β)(log 2+2α) 8α+4β 8α 1 + 8 Zi ≤ ln(T/2) Zi < 0 (plugging in p = 2/3) (cid:17)  Putting all of our assumptions about t together, we have t ≥ 32 log3/2 τ + 8 4α + β ln(T/2) + 128α(8α + β) (4α + β)2 ln(1/δ). 21 Plugging in p = 2/3, this is satisfied when as desired. t ≥ 79 ln τ + 3 ln T + 63 ln(1/δ) C Set of Sets Based Protocol Details Here we present the details of our protocol for directory reconciliation based on a protocol for reconciling set of sets of [14]. First we present a general protocol in which one can plug in any one round document exchange protocol, and then we go on to apply it with specific protocols. Let nj be the size of jth largest document in the union of Alice and Bob's directories. h ≥ n1 ≥ n2 ≥ . . . ≥ nm, for m ≤ 2s andPm Lemma C.1. Given a one-round document exchange protocol with time g(k, n′) = O(poly(k, n′)), communication cost f (k, n′) = O(poly(k, n′)), and success probability at least 1−1/(100k), directory reconciliation can be solved in one round using j=1 nj ≤ 2n. bits of communication and Od log s + d log log min(d, h) + O  min(bd,d/2i)Xj=1 log min(d,h)Xi=1 f (2i, nj) + (d/2i)g(2i, h) log min(d,h)Xi=1 (bd + min(bd, d/2i) − 2j)f (2i, nj) mXj=1 time with probability at least 2/3. Proof. We analyze the protocol given in Algorithm 3. Our proof is essentially identical to that of [14]. Going forward we will condition on the event that there are no collisions among the Θ(log(st)) bit hashes in the document encodings. There are at most 2s documents per round that can collide, so union bounding over the t rounds we have no collisions with probability at least 1 − 4s2t/poly(st) ≥ 1 − 1/30. Let us divide Alice's documents into groups according to how many edits they differ by under the minimum difference matching. Sj is the set of Alice's documents whose edit distance with its match is in [2j−1, 2j − 1]. First, observe that every one of Alice's differing documents is included in some Sj for j ≤ t. Second, observe that Sj ≤ d/2j−1 since the total number of edits is at most d. Consider the IBLT Ti. Let Yi be the event that IBLT Ti successfully decodes. Conditioned on Yi, when processing to match up the documents within Ti, in expectation Bob fails to recover at j=1Sj that he has not yet recovered. By Markov's inequality, most Bob recovers fewer than 9/10 of the Alice's documents in ∪i j=1Sj that he has not already decoded 10·2i . We use Xi to refer to the event that processing Ti results in Bob with probability at most recovering at least 9/10 of ∪i j=1Sj that he had not previously recovered, so we have argued that 100·2i of Alice's documents from ∪i 1 1 Pr[XiYi] ≥ 1 − 1 10 · 2i . 22 Algorithm 3 Cascading IBLTs of Document Exchange Protocols 1. For i = 1, . . . , t = log2 min(d, h), Alice creates a (document exchange message with k = Θ(2i), Θ(log(st)) bit hash) document encoding for each of her documents and inserts it into a Θ(d/2i) cell IBLT Ti. 2. If t = log2 h, Alice creates a Θ(d/h) cell IBLT T∗ and inserts a Θ(h) bit encoding of each of her documents into it. 3. Alice sends T1, . . . , Tt and T∗ to Bob. 4. Bob deletes (document exchange message with k = O(1), hash) encodings of each of his documents from T1, and then extracts all of the different document encodings from it. He uses the hashes of his extracted documents to recover DB, the set of his documents that differ from any of Alice's. 5. Bob tries performing the document exchange protocol using every combination of one Alice's extracted document encodings and one of his documents in DB, trying to recover Alice's documents. Each time the protocol succeeds, and the resulting document matches Alice's hash, he inserts the recovered document into the set DA. Going forward, he will recover more and more of Alice's documents and DA will be the set he has recovered so far. 6. For each i = 2, . . . , t, Bob performs the following procedure. He first deletes the level i document encoding of each of his documents from Ti, except for those in DB. He also deletes the level i document encoding of each document in DA from Ti. He then decodes Ti and extracts all of the different document encodings, which correspond exactly to Alice's differing documents that aren't yet in DA. He tries to to decode each of Alice's extracted document encodings with each of the documents in DB, adding Alice's documents that he recovers to DA. 7. If Bob received T∗, he deletes all of his documents from it. He also deletes each document in DA from it. He then decodes T∗ and adds all of the decoded documents to DA. 8. Bob deletes DB from his directory, and adds DA. Since there are at most 2d differing documents in T1, we can choose the IBLT's parameters so j=1Xj, the number of that Y1 occurs with probability at least 1 − 2 Alice's documents left to be recovered after Ti is processed is at most 10d . For i > 1, conditioned on ∩i−1 tXj=i+1 Sj + ≤ d/2j−1 + iXj=1 tXj=i+1 ≤ d/2i−1 + d/10i ≤ d/2i−1 + d/2i+2 = (9/4)(d/2i). Sj10j−i−1 iXj=1 iXj=1 5j−1 d10j−i−1/2j−1 23 Since Ti has Θ(d/2i) cells, we can choose the constant factors in the order notation so that Yi occurs with probability at least 1 − 2i long as all Xi and Yi occur. The probability of this is If t < log2 h, and therefore there is no T∗, Bob successfully recovers all of Alice's documents so 10d conditioned on ∩i−1 j=1Xj. j=1 Xji Pr[XtYt] Pr[XiYi] = Pr[Y1] i=1(Xi ∩ Yi)] Pr[∩t = Pr[Y1] Pr[X1Y1] . . . PrhYt ∩t−1 j=1 Xji tYi=1 10 · 2i(cid:19) PrhYi ∩i−1 tYi=2 tYi=1(cid:18)1 − 10d(cid:19) tYi=1(cid:18)1 − 10 · 2i(cid:19) tXi=1(cid:18) 2i 10d 2i = 1 + 1 ≥ 1 − ≥ 4/5. If t = log2 h, then the protocol will succeed so long as T∗ successfully decodes. T∗ has Θ(d/h) cells and if all Xi and Yi occur then there are at most (9/4)d/h elements to extract from T∗, so we can choose the constants such that T∗ decodes with probability at least 1/10. We have thus proved that by the end of the procedure, Bob recovers Alice's directory with probability at least 4/5 − 1/10 − 1/30 = 2/3. from the Ti is The time for Alice and Bob to construct their document encodings and insert or delete them O tXi=1 mXj=1 f (2i, nj) . The remaining time is what Bob takes to attempt to decode Alice's document encodings. When so the total processing time is at most processing Ti, Bob extracts O(min(bd, d/2i)) of Alice's document encodings, and compare each one against each of his O(bd) differing documents' encodings. Each document encoding has k = Θ(2i), (bd + min(bd, d/2i) − 2j)f (2i, nj) . O min(bd,d/2i)Xj=1 bdXℓ=1 Summing over i, we get The communication cost of transmitting T1, . . . , Tt and T∗ is min(bd,d/2i)Xj=1 f (2i, max(nj, nℓ)) = O O min(bd,d/2i)Xj=1 tXi=1 (d/2i) · (log(st) + g(2i, h)) + d! O tXi=1 (d/2i)g(2i, h)! . = O d log s + d log log min(d, h) + tXi=1 (bd + min(bd, d/2i) − 2j)f (2i, nj) . 24 As a first attempt, we combine this lemma with Theorem 2.1. Since Theorem 2.1 works under edit distance with block moves, this protocol has the advantage that it allows block moves within the files as edit operations, just as Theorem 3.1 and Corollary 3.3 do. Theorem C.2. Directory reconciliation can be solved in one round using O(d log s + d log2 h log min(d, h)) bits of communication and time with probability at least 2/3. O(nd log h + nbd log h log d) Proof. We use Lemma C.1 with Theorem 2.1 as our document exchange protocol, giving us f (k, n′) = n′ log n′ and g(k, n′) = k log n′ log(n′/k). Our communication bound is Od log s + d log log min(d, h) + log min(d,h)Xi=1 = Od log s + d log log min(d, h) + (d/2i)g(2i, h) d log h log(h/2i) log min(d,h)Xi=1 = O(d log s + d log2 h log min(d, h)). We bound the time in two pieces. First, O log min(d,h)Xi=1 mXj=1 Finally, f (2i, nj) = O = O (n log h log min(d, h)) . log min(d,h)Xi=1 mXj=1 nj log nj (bd + min(bd, d/2i) − 2j)f (2i, nj) O min(bd,d/2i)Xj=1 log min(d,h)Xi=1 = O (bd + min(bd, d/2i) − 2j)nj log nj min(bd,d/2i)Xj=1 log dXi=1 (2bd − 2j)nj log nj = O log(d/bd)Xi=1 bdXj=1 log dXi=log(d/bd) Xj=1 (bd + d/2i − 2j)nj log nj + 2bdn log h = O log(d/bd)Xi=1 log dXi=log(d/bd) (bd + d/2i)n log h + = O(n log h(d + bd log d)). d/2i 25 Now we instead use the state-of-the-art one round document exchange protocol Theorem 2.2 to achieve the following result. Theorem 4.1. Directory reconciliation can be solved in one round using O(d log s + d log3 min(d, h) + d log h log min(d, h)) bits of communication and time with probability at least 2/3. O(nd log log h + nbd log2 min(d, h) + nbd log min(d, h) log log h) Proof. We use Lemma C.1 with Theorem 2.2 as our document exchange protocol when our chosen k < hε. In this case f (k, n′) = n′(log k + log log n′) and g(k, n′) = k log n′ + k log2 k. When k ≥ hε we use Theorem 2.1 as in Theorem C.2. Our communication cost is Od log s + d log log min(d, h) + log min(d,h)Xi=1 = Od log s + d log log min(d, h) + (d/2i)g(2i, h) d(log h + i2) log min(d,h)Xi=1 = O(d log s + d log h log min(d, h) + d log3 min(d, h)). We bound the running time just as in Theorem C.2, but we consider two cases. First, if d < hε then Furthermore, mXj=1 mXj=1 nj(i + log log h) = O(cid:0)n log2 d + n log d log log h(cid:1) . O log min(d,h)Xi=1 f (2i, nj) = O log dXi=1 (bd + min(bd, d/2i) − 2j)f (2i, nj) O log min(d,h)Xi=1 = O log(d/bd)Xi=1 log dXi=log(d/bd) = O(nd log log h + nbd log d log log h + nbd log2 d). min(bd,d/2i)Xj=1 (bd + d/2i)n(i + log log h) + 2bdn(i + log log h) Now consider d ≥ hε. There are a several subcases here depending on the relative values of d/bd, d, hε and h, but they all yield the same bound. We only present here the case when hε ≤ d/bd ≤ min(d, h). O log min(d,h)Xi=1 mXj=1 nj log h log min(d,h)Xi=ε log h nj(i + log log h) + mXj=1 f (2i, nj) = O ε log hXi=1 mXj=1 = O(cid:0)n log2 h(cid:1) , 26 and (bd + min(bd, d/2i) − 2j)f (2i, nj) min(bd,d/2i)Xj=1 (bd + d/2i)n(i + log log h) + O log min(d,h)Xi=1 = O e log hXi=1 = O(nd log log h + nbd log2 h). Combining the cases we get a total time bound of log(d/bd)Xi=e log h (bd + d/2i)n log h + log min(d,h)Xi=log(d/bd) 2bdn log h O(nd log log h + nbd log2 min(d, h) + nbd log min(d, h) log log h). D Details of Faster Decoding Document Exchange Protocol Here we develop a protocol optimized for detecting whether it is ultimately going to fail in time o(n). We then combine this with Lemma C.1 to achieve a fast directory reconciliation protocol. Theorem 4.2. There is a one round protocol for document exchange under edit distance using O((k log(n/k) log(n/δ) + k3)⌈logk log n⌉) bits of communication, which succeeds with probability at least 1 − 1/poly(k) if ∆e(a, b) ≤ k. Alice takes O(n log(n/k)) computation time, and Bob has an O(cid:0)n log(n/k) logn(n/δ) + k3 log(n/k) logn(n/δ)⌈logk log n⌉(cid:1) time precomputation step, before receiving Alice's message. After receiving Alice's message, Bob has an O(k2 log(n/k) logn(n/δ)⌈logk log n⌉) time failure check step. If the message passes the failure check, then the protocol will succeed with probability at least 1− δ (independent of ∆e(a, b)) after a final O(n⌈logk log n⌉) time step from Bob. Proof. First we detail the protocol, except for some replication for probability amplification and some computational optimization, then prove its correctness afterwards. • Alice's step: 1. For i ∈ [⌈log2(n/k3)⌉], Alice divides her string into 2ik blocks ¯a1, ¯a2, . . . , ¯a2ik of length n/(2ik). For each j ∈ [2ik], she computes xi,j, a Θ(log(n/δ)) bit rolling hash of ¯aj = a(j−1)n/(2ik)+1,jn/(2ik). She creates Ti, a Θ(k)-cell IBLT. For j ∈ [2ik] she inserts the pair (j,xi,j ) as a key into Ti. 2. Alice creates a Θ(k)-cell IBLT T ∗, with both keys and values, which uses the same hash functions as T⌈log2(n/k3)⌉. She then divides her string into n/k2 blocks ¯a1, ¯a2, . . . , ¯ak2 of length k2, and for j ∈ [n/k2] she inserts into T ∗ the key (j,x⌈log2(n/k3)⌉,j) with the corresponding value ¯aj. 27 3. She sends T ∗ and all of the Tis to Bob. • Bob's precomputation: 1. For i ∈ [⌈log2(n/k3)⌉] and j′ ∈ [n − n/(2ik) + 1] Bob computes yi,j′, a Θ(log(n/δ)) bit rolling hash of bj′:j′+n/(2ik)−1. 2. For i ∈ [⌈log2(n/k3)⌉] and j ∈ [2ik], he creates a hash table Hi,j. 3. For i ∈ [⌈log2(n/k3)⌉], j ∈ [2ik], and m ∈ {−k,−k + 1, . . . , k}, let j′ = (j − 1)n/(2ik) + 1 + m. Bob inserts yi,j′ into Hi,j as a key, with m as its corresponding value. If a key was previously inserted into a table, pick between the values arbitrarily. 4. For i ∈ [⌈log2(n/k3)⌉], j ∈ [2ik], m ∈ {−k,−k + 1, . . . , k}, and ℓ ∈ {i, . . . ,⌈log2(n/k3)⌉}: Bob creates a Θ(k) cell IBLT Ti,j′,m,ℓ. Let j′ = (j − 1)n/(2ik) + 1 + m. He constructs Ti,j,m,ℓ so that if bj′:j′+n/(2ik)−1 = ¯aj, Ti,j,m,ℓ will equal ¯aj's contribution to Tℓ. This means that if he divides bj′:j′+n/(2ik)−1 into 2ℓ−i blocks ¯b1, . . . , ¯b2ℓ−i of size n/2ℓk, Ti,j,m,ℓ contains the pairs (2ℓ−i(j − 1) + ι,Θ(log(n/δ)) bit rolling hash of ¯bι), for ι ∈ [2ℓ−i]. • After Bob receives Alice's message: 1. Bob initializes an empty list L, which will consist of tuples indicating the parts of a that Bob has recovered, and what parts of b they match. 2. For ℓ ∈ [⌈log2(n/k3)⌉], for each (i, j, m) tuple in L, Bob subtracts Ti,j,m,ℓ from Tℓ. Bob then attempts to decode Tℓ. If it fails, he reports failure and terminates. Otherwise, if ℓ < ⌈log2(n/k3)⌉, then for each (j, xℓ,j) pair that Bob extracts from Ti, he checks if xℓ,j is in Hℓ,j, and if it is he extracts the corresponding value m and adds the tuple (ℓ, j, m) to L. (This is the end of the failure check phase of the protocol.) 3. For each (i, j, m) tuple in L, let j′ = (j − 1)n/(2ik) + 1 + m. Bob divides bj′:j′+n/(2ik)−1 into n/(k32i) blocks ¯b1, . . . , ¯bn/(k32i) of size k2. For ι ∈ [n/k32i], he deletes from T ∗ the key ((j − 1)n/(k32i) + ι,Θ(log(n/δ)) bit rolling hash of ¯bι) with value ¯bι. Bob then decodes T ∗. 4. Bob creates his output string a′ as follows. For each (i, j, m) tuple in L, Bob lets a′(j−1)n/(2ik)+1,jn/(2ik) = bj′:j′+n/(2ik)−1, where j′ = (j − 1)n/(2ik) + 1 + m. For each key (j, xi,j ) and value ¯aj that Bob extracts from T ∗, Bob lets a′(j−1)k2+1,jk2 = ¯aj. We now argue that if none of the hashes collide and none of the IBLTs fail, then our protocol succeeds (a′ = a). This protocol operates exactly as Theorem 2.1 (the IMS sketch of [11]) does except in four ways: it uses IBLTs for its systematic error correcting codes, it stops using hashes once blocks are size Θ(k2) instead of Θ(log n), it has a slightly different way of transmitting the encoded plain text in T ∗ at the bottom level, and Bob has a different mechanism for deleting what he has recovered so far from Alice's codes. We argue that these four changes still make the output consistent with that of Theorem 2.1. IBLTs (when used to represent a vector rather than a set by including the index of each item in the pair) do indeed fulfill the requisite criteria for a systematic error correcting code here. Stopping at blocks of size Θ(k2) will also not affect the result, since stopping at any level, so long as at that level we directly encode the blocks rather than just the hashes, will not affect correctness. The normal mechanism for Theorem 2.1 to encode the blocks at the bottom level (with IBLTs as codes) would be to make an IBLT independent of the Tis and insert the the blocks paired with their indices (j, ¯aj ) into T ∗ as keys, without values. Assuming no hash collisions, the same information 28 is present in T ∗ as we have constructed it, and assuming all of the IBLTs decode, that information will still be recovered and usable in the same way. What remains is to argue that the way Bob uses his precomputed data to decode Alice's codes is consistent with Theorem 2.1. Suppose that Bob did not precompute anything and was just executing Theorem 2.1 using only the first three of our differences. In this case, Bob's protocol after receiving Alice's message would be: 1. Bob initializes an empty list L, which will consist of tuples indicating the parts of a that Bob has recovered, and what parts of b they match. 2. For ℓ ∈ [⌈log2(n/k3)⌉ − 1]: • For each (i, j′, j) tuple in L, he divides bj′:j′+n/(2ik)−1 into 2ℓ−i blocks ¯b1, . . . , ¯b2ℓ−i of size n/2ℓk. For ι ∈ [n/2ℓk], he deletes the pair (2ℓ−i(j − 1) + ι,Θ(log(n/δ)) bit rolling hash of ¯bι) from Tℓ. • Bob attempts to decode Tℓ. If it fails, he reports failure and terminates. Otherwise, for each (j, xℓ,j) pair that Bob extracts from Ti, he checks if there exists a j′ for which the Θ(log(n/δ)) bit rolling hash of bj′:j′+n/(2ℓk)−1 is equal to xℓ,j. If such a j′ does exist, then he adds the tuple (ℓ, j′, j) to L. 3. For each (i, j′, j) tuple in L, Bob divides bj′:j′+n/(2ik)−1 into n/(k32i) blocks ¯b1, . . . , ¯bn/(k32i) of size k2. For ι ∈ [n/k32i], he deletes from T ∗ the key ((j − 1)n/(k32i) + ι,Θ(log(n/δ)) bit rolling hash of ¯bι) with value ¯bι. 4. Bob attempts to decode T ∗. If it fails, he reports failure and ends the protocol. 5. Bob creates his output string a′ as follows. For each (i, j′, j) tuple in L, Bob lets a′(j−1)n/(2ik)+1,jn/(2ik) = bj′:j′+n/(2ik)−1. For each key (j, xi,j ) and value ¯aj that Bob extracts from T ∗, Bob lets a′(j−1)k2+1,jk2 = ¯aj. There are two differences from our protocol here. The first is that Bob uses a precomputed hash table to determine if the hash xℓ,j matches the hash of a substring of b. The way our protocol does this, it only checks in the table for Bob's substrings within a distance k of Alice's substring. That is, xℓ,j is the hash of a(j−1)n/(2ℓk)+1:jn/(2ℓk), and Bob only checks his substrings with starting index in [(j − 1)n/(2ℓk) + 1− k, (j − 1)n/(2ℓk) + 1 + k]. This is valid, because our protocol only assumes k is a bound on the edit distance, not a bound on the edit distance with block moves, as is assumed in Theorem 2.1. As a result, it suffices to only look for matches of within these k indices of Alice's substring. The second difference is how we delete the known pieces of a from Tℓ. In the above version of Theorem 2.1, we iterate through each known piece and compute the hash of each of block in that piece and delete it from Tℓ. Equivalently, we could take all of those hashes and add them to a new IBLT T ′, then subtract T ′ from Tℓ. T ′ is exactly equal to the precomputed Ti,j,m,ℓ which our protocol subtracts from Tℓ, thus the two protocols are consistent. Now we consider the failure probability. Each of the Tis decodes with probability 1− 1/poly(k). We replicate the IBLTs Θ(⌈logk log n⌉) times, so that after union bounding over the O(⌈log(n/k3)⌉) IBLTs we attempt to decode, we still succeed with probability 1 − 1/poly(k). Since T ∗ uses the same keys and hash functions as T⌈log2(n/k3)⌉, if T⌈log2(n/k3)⌉ decodes then T ∗ will with probability 1. Thus, if all of the Tis succeed, then failure can only occur due to hash collision which occurs with probability at most δ since we are using Θ(log(n/δ)) bit hash functions and hashing a total of O(n log n) strings (O(n) per level, and O(log n) levels). 29 Alice's part of the protocol takes O(n⌈log(n/k3)⌉) = O(n log(n/k)) time. Each Ti takes O(k log(n/δ)⌈logk log n⌉) space after replication, and T ∗ takes O(k(log(n/δ)+k2)⌈logk log n⌉) space, so the total communication cost is O((k log(n/k) log(n/δ) + k3)⌈logk log n⌉). Computing the yi,j′s takes Bob O(n log(n/k) logn(n/δ)) time. Generating each Hi,j takes Bob O(k logn(n/δ)) time, so generating all of them takes O(n logn(n/δ)/k) time. Bob can compute the Ti,j,m,ℓs and their replications in O((n + k3 log(n/k)) logn(n/δ)⌈logk log n⌉) time. To achieve this, he first computes all of the Ti,j,m,is (note that here ℓ = i). Each one takes O(k logn(n/δ)) time since it takes O(k logn(n/δ)) time to initialize and then O(logn(n/δ)) time to insert the single item into the table. Now we observe that Ti,j,m,ℓ for ℓ > i is equal to the sum of Ti+1,2j−1,m,ℓ and Ti+1,2j,m,ℓ, thus once we have computed each Ti,j,m,i+t, we can compute a given Ti,j,m,i+t+1 in O(k) time by adding together two already computed IBLTs. Thus the total time to compute the Ti,j,m,ℓs is O(k logn(n/δ)) times how many of them there are, giving us a total precomputation time of O(n log(n/k) logn(n/δ) + ⌈logk log n⌉ ⌈log2(n/k3)⌉Xi=1 = On log(n/k) logn(n/δ) + ⌈logk log n⌉ = O(cid:0)n log(n/k) logn(n/δ) + k3 log(n/k) logn(n/δ)⌈logk log n⌉(cid:1) . ⌈log2(n/k3)⌉Xℓ=i 2ikXj=1 kXm=−k (⌈log2(n/k3)⌉ − i)2ik3 logn(n/δ) ⌈log2(n/k3)⌉Xi=1 O(k logn(n/δ)) Finally we examine Bob's computation time after he receives Alice's message. L = O(k) at all times, so the loop over ℓ takes O(k2 log(n/k) logn(n/δ)⌈logk log n⌉) time, which is the entire computation in the failure check phase. Bob's remaining two steps take O(n⌈logk log n⌉) time. Now with this document exchange protocol in hand, we get the following directory reconciliation result. Theorem 4.3. Directory reconciliation with can be solved in one round using O(d log s + d log n log h log min(d, h) log log h + d min(d, h)2 log log h) bits of communication and O(n log h log min(d, h) + d3 log h log min(d, h) log log h + d2bd2 log n log log h) time with probability at least 3/5. Proof. Basically, we plug Theorem 4.2 into Lemma C.1. We do all of Bob's precomputation steps once at the beginning of the protocol, and when trying to decode a document encoding if it fails by the end of the failure check step, we just stop there so for an appropriate choice of δ, we should only have perform an O(n) computation once for each of Bob's documents and once for each of Alice's documents that we recover. We choose δ = 1/poly(n) so that with at least 14/15, in none of Lemma C.1's O(d2 log d) attempts to decode a message, will the decoding fail after passing the failure check step. Our bounds are then Lemma C.1's with g(n′, k) = O((k log n′ log n + k3)⌈logk log n′⌉) and f (n′, k) = O(k2 log(n′/k) logn′ n⌈logk log n′⌉) with an additional O(n log h log min(d, h)) computation time for Alice's time to generate her document exchange messages, O(n log h log min(d, h) + d3 log h log min(d, h) log log h) 30 piece of the computation time is not included. Thus our computation time from Lemma C.1 is simply mXj=1 log min(d,h)Xi=1 f (2i, nj) O (bd + min(bd, d/2i) − 2j)f (2i, nj) min(bd,d/2i)Xj=1 bdXj=1 log dXi=log(d/bd) Xj=1 (bd + d/2i)22i log n log log nj + 2bd222i log n log log h log dXi=log(d/bd) (bd + d/2i)d2i log n log log h + 2bd22i log n log log nj d/2i O log min(d,h)Xi=1 = O log(d/bd)Xi=1 = O log(d/bd)Xi=1 = O(d2bd2 log n log log h). time for Bob to perform his precomputations, and O(d2 log h log log h) time for Bob to perform his recovery of Alice's documents that have passed their failure checks. Our communication bound is then Od log s + d log log min(d, h) + log min(d,h)Xi=1 = Od log s + d log log min(d, h) + (d/2i)g(2i, h) d(log h log n + 22i) log log h log min(d,h)Xi=1 = O(d log s + d log n log h log min(d, h) log log h + d min(d, h)2 log log h). We have already factored in the construction time for Alice and Bob's messages in Lemma C.1, so the Adding up all of our pieces, we get the desired computation time. E Details of Protocols for Unknown d Here we develop an efficient directory reconciliation protocol which uses only a constant number of rounds of communication for the case when we do not have a bound on d. First we describe the tools we need for it. The first is the CGK embedding of [4]. Recall that ∆e is the edit distance function and let ∆H be the Hamming distance function. Lemma E.1 (Theorem 4.1 of [4]). There is a mapping f : {0, 1}n × {0, 1}6n → {0, 1}3n with the following properties: 1. The mapping can be computed in O(n) time. 2. For every x ∈ {0, 1}n, given f (x, r) and r, x can be computed in O(n) time with probability at least 1 − exp(−Ω(n)) over r. 31 3. For every x, y ∈ {0, 1}n, ∆e(x, y)/2 ≤ ∆H(f (x, r), f (y, r)) ≤ 1300(∆e(x, y))2 with probability at least 2/3 over r. [4] uses this embedding to produce a document exchange protocol by combining it with the following Hamming distance sketch. Document exchange can then be performed by encoding each party's string using the same r, reconciling these encodings using the Hamming distance sketch, and then inverting the encoding. Lemma E.2 (Theorem 4.4 of [18]). Given x ∈ {0, 1}n and k ∈ [n], there is an algorithm that produces an O(k log n) sketch such sk(x) in time O(n log n). Given sk(x) and sk(y) for y ∈ {0, 1}n and ∆H(x, y) ≤ k, there is an algorithm taking time O(k log n) which returns all tuples (xi, yi) for which xi 6= yi with probability at least 1 − 1/n (over the random bits in the sketching algorithm). Using the Hamming sketch requires knowing an upperbound k on the Hamming distance be- tween the strings. we estimate this difference efficiently using set difference estimators, which if we interpret sets as binary vectors, can be used to estimate Hamming distance. In the language of Hamming distance, a set difference estimator is a data structure for estimating the Hamming distance between two binary strings. It implicitly maintains two strings x, y ∈ {0, 1}n and supports two operations: creation, merge and query. Creation takes in a single string x and makes an esti- mator D representing x and y = {0}n. Merge takes in a second set difference estimator D′, which implicitly maintains sets x′, y′ ∈ {0, 1}n and returns a new set difference estimator D′′ representing x∧x′ and y∧y′, where ∧ denotes the logical OR operation. Query returns an estimate for ∆H(x, y). Lemma E.3 (Theorem 3.1 of [14]). There is a set difference estimator requiring O(log(1/δ) log n) space with O(n log(1/δ) creation times, and O(log(1/δ)) merge and query times, which reports the size of the Hamming distance to within a constant factor with probability at least 1 − δ. We now combine these tools to develop a directory reconciliation protocol for unknown d, designed based on the multi-round set of sets reconciliation protocol of [14]. Lemma E.4. Directory reconciliation with unknown d can be solved in 4 rounds using bits of communication and O(bd log s⌈logbd(1/δ)⌉ +bd log h log2(bd/δ) + d2 log h⌈logh(bd/δ)⌉) O((sh + bd2) log2(bd/δ) + (bdh + d2) log h⌈logh(bd/δ)⌉) time with probability at least 1 − δ. Proof. First we detail the reconciliation protocol we use (except for some small amount of proba- bility amplification), and then we argue its correctness afterwards. 1. Bob computes a Θ(log(s/δ))-bit pairwise independent hash of his documents, creates a set difference estimator (with failure probability Θ(δ)) for his set of hashes, and sends it to Alice. 2. Alice computes a Θ(log(s/δ))-bit pairwise independent hash of her documents. She uses Bob's set difference estimator to estimate the size of the difference between their sets of hashes, which should be O(bd). Alice then inserts all of her document hashes into O(bd)-cell IBLT TA which she transmits to Bob. 32 and determines which of his child sets differ from Alice. For each of his differing documents, 3. Bob inserts all of his document hashes into an O(bd)-cell IBLT TB. Bob decodes (TA, TB), he creates Θ(log(bd/δ)) length Θ(h) CGK encodings of it, and constructs a set difference estimator (with failure probability Θ(δ/poly(bd))) for each of the encodings. For each of these documents, Bob creates a vector of its corresponding set difference estimators and inserts the vector into a list LB. He transmits TB and LB to Alice. 4. Alice decodes (TA, TB), and constructs LA, a list of vectors set difference estimators (each estimator within a vector again corresponding to a different CGK encoding) for each of her differing documents. For each vector of set difference estimators LA,i ∈ LA and each LB,j ∈ LB, Alice estimates the edit distance between the documents corresponding to i and j by merging LA,i and LB,j element-wise, and then taking the median of the estimates. Let bi be the index j of the LB,j with which LA,i yielded the smallest estimate, let ci be the index of the CGK embedding used in that estimate, and let di be that estimated difference. For each i, Alice transmits bi, ci, di, and Si, a Hamming distance sketch (with k = Θ(di), then 5. For each of the received tuples (bi, ci, di, Si) pairs, Bob recovers Alice's document i by creating replicated Θ(⌈logh(bd/δ)⌉) times) of the cith CGK encoding of Alice's document i. a Hamming sketch (with k = Θ(di) and Θ(⌈logh(bd/δ)⌉) replication) of the cith CGK encoding of his document bi and uses it to decode Si. Bob then applies the extracted differences to his CGK encoded document and inverts the CGK encoding to yield Alice's document i. Bob then recovers Alice's total directory by removing all documents corresponding to LB from his set and adding in Alice's documents that he has recovered. This protocol succeeds so long as none of the hashes collide, none of the set difference estimators fail, TA and TB together decode, none of the Hamming sketches fail, and for each pair of differing documents, the median Hamming distance between their CGK encodings is accurate (up to O(k2)). Union bounding over all O(s2) pairs of documents, none of the hashes collide with probability at least 1 − O(δ). The first set difference estimator succeeds with probability 1 − O(δ). (TA, TB) decodes with probability at least 1 − poly(bd). By replicating step 2 (and the corresponding part of step 3) Θ(⌈logbd(1/δ)⌉) times, we reduce the probability that TA and TB fails to decode to O(δ). There are O(bd2 log(bd/δ)) pairs of set difference estimators, each of which fails with probability O(δ/poly(bd)), so that they all succeed with probability at least 1−O(δ). For each of the O(bd2) pairs of documents compared, there are O(log(bd/δ)) CGK encodings, each of which fails with probability Hamming distance fails with probability O(δ/poly(bd)), thus by a union bound each pair's median O(1/h) before replication, so by replicating it Θ(⌈logh(bd/δ)⌉) times every pair of Hamming sketches CGK encoding succeeds with probability 1 − O(δ). Each Hamming sketch fails with probability will succeed with probability 1− O(δ). Putting it all together, for the right choice of constants, the protocol succeeds with probability at least 1 − δ. Computing the hashes takes O(n) time, and creating and transmitting the initial set dif- ference estimator takes O(log(1/δ)) time and O(log(1/δ) log s) communication, by Lemma E.3. at most 1/3. For each pair of documents, by a Chernoff bound, the CGK encoding with the median Constructing and decoding TA and TB takes, over O(⌈logbd(1/δ)⌉) replications, O(⌈logbd(1/δ)⌉s) time and O(⌈logbd(1/δ)⌉bd log s) bits of communication. Computing all of the CGK encodings, and then later decoding them, takes O(sh log(bd/δ)) time. By Lemma E.3, constructing LA and LB takes O(sh log2(bd/δ)) time and transmitting LB takes O(bd log h log2(bd/δ)) bits of communica- tion. Finding the bis, cis, and dis consists of O(bd2 log(bd/δ)) set difference merges and queries, which by Lemma E.3 take a total of O(bd2 log2(bd/δ)) time. Sending the bis, cis, and dis takes 33 tion. Adding up all of these terms, we get our desired bounds. O(bd log(bdh log(1/δ))) bits of communication. Computing and decoding the Sis takes O((bdh + d2) log h⌈logh(bd/δ)⌉) time and transmitting them takes O(d2 log h⌈logh(bd/δ)⌉) bits of communica- Plugging δ = 1/poly max(bd, h) into this lemma, then replicating the result Θ(log n/ log(1/δ)) times in parallel, we get our theorem. Theorem 4.4. Directory reconciliation with unknown d can be solved in 4 rounds using bits of communication and O(bd log n log s/ logbd +bd log n log max(bd, h) log h + d2 log n) time with probability at least 1 − 1/poly(n). O((sh +bd2) log n log max(bd, h) + d2 log n) 34
1012.4701
2
1012
2013-09-26T15:41:10
Vertex Cover Kernelization Revisited: Upper and Lower Bounds for a Refined Parameter
[ "cs.DS", "cs.CC" ]
An important result in the study of polynomial-time preprocessing shows that there is an algorithm which given an instance (G,k) of Vertex Cover outputs an equivalent instance (G',k') in polynomial time with the guarantee that G' has at most 2k' vertices (and thus O((k')^2) edges) with k' <= k. Using the terminology of parameterized complexity we say that k-Vertex Cover has a kernel with 2k vertices. There is complexity-theoretic evidence that both 2k vertices and Theta(k^2) edges are optimal for the kernel size. In this paper we consider the Vertex Cover problem with a different parameter, the size fvs(G) of a minimum feedback vertex set for G. This refined parameter is structurally smaller than the parameter k associated to the vertex covering number vc(G) since fvs(G) <= vc(G) and the difference can be arbitrarily large. We give a kernel for Vertex Cover with a number of vertices that is cubic in fvs(G): an instance (G,X,k) of Vertex Cover, where X is a feedback vertex set for G, can be transformed in polynomial time into an equivalent instance (G',X',k') such that |V(G')| <= 2k and |V(G')| <= O(|X'|^3). A similar result holds when the feedback vertex set X is not given along with the input. In sharp contrast we show that the Weighted Vertex Cover problem does not have a polynomial kernel when parameterized by the cardinality of a given vertex cover of the graph unless NP is in coNP/poly and the polynomial hierarchy collapses to the third level.
cs.DS
cs
Vertex Cover Kernelization Revisited: Upper and Lower Bounds for a Refined Parameter∗ Bart M. P. Jansen Utrecht University The Netherlands [email protected] Hans L. Bodlaender Utrecht University The Netherlands [email protected] Abstract An important result in the study of polynomial-time preprocessing shows that there is an algorithm which given an instance (G, k) of Vertex Cover outputs an equivalent instance (G(cid:48), k(cid:48)) in polynomial time with the guarantee that G(cid:48) has at most 2k(cid:48) vertices (and thus O((k(cid:48))2) edges) with k(cid:48) ≤ k. Using the terminology of parameterized complexity we say that k-Vertex Cover has a kernel with 2k vertices. There is complexity-theoretic evidence that both 2k vertices and Θ(k2) edges are optimal for the kernel size. In this paper we consider the Vertex Cover problem with a different parameter, the size fvs(G) of a minimum feedback vertex set for G. This refined parameter is structurally smaller than the parameter k associated to the vertex covering number vc(G) since fvs(G) ≤ vc(G) and the difference can be arbitrarily large. We give a kernel for Vertex Cover with a number of vertices that is cubic in fvs(G): an instance (G, X, k) of Vertex Cover, where X is a feedback vertex set for G, can be transformed in polynomial time into an equivalent instance (G(cid:48), X(cid:48), k(cid:48)) such that V (G(cid:48)) ≤ 2k and V (G(cid:48)) ∈ O(X(cid:48)3). A similar result holds when the feedback vertex set X is not given along with the input. In sharp contrast we show that the Weighted Vertex Cover problem does not have a polynomial kernel when parameterized by the cardinality of a given vertex cover of the graph unless NP ⊆ coNP/poly and the polynomial hierarchy collapses to the third level. 1 Introduction A vertex cover of an undirected graph G is a subset of the vertices that contains at least one endpoint of every edge. An instance of the Vertex Cover problem consists of a graph G and integer k, and asks whether G has a vertex cover of size at most k. Vertex Cover is one of the six classic NP-complete problems discussed by Garey and Johnson ∗A preliminary version of this work appeared in the proceedings of the 28th International Symposium on Theoretical Aspects of Computer Science (STACS 2011). This work was supported by the Nether- lands Organization for Scientific Research (NWO), project "KERNELS: Combinatorial Analysis of Data Reduction". 1 in their famous work on intractability [26, GT1], and has played an important role in the development of parameterized algorithms [18, 36, 19]. A parameterized problem is a language L ⊆ Σ∗×N, and such a problem is (strongly uniform) fixed parameter tractable (FPT) if there is an algorithm to decide membership of an instance (x, k) in f (k)xc time for some computable function f and constant c. Since Vertex Cover is such an elegant problem with a simple structure, it has proven to be an ideal testbed for new techniques in the context of parameterized complexity. The problem is also highly relevant from a practical point of view because of its role in bioinformatics [1] and other problem areas. In this work we suggest a "refined parameterization" for the Vertex Cover problem using the feedback vertex number fvs(G) as the parameter, i.e., the size of a smallest vertex set whose deletion turns G into a forest. We give a polynomial kernel for the unweighted version of Vertex Cover under this parameterization, and also supply a conditional superpolynomial lower bound on the kernel size for the variant of Vertex Cover where each vertex has a non-negative integral weight. But before we state our results we shall first survey the current state of the art for the parameterized analysis of Vertex Cover. There has been an impressive series of ever-faster parameterized algorithms to solve k-Vertex Cover1, which led to the current-best algorithm by Chen et al. that can decide whether a graph G has a vertex cover of size k in O(1.2738k + kn) time and polynomial space [10, 38, 9, 20]. Mishra et al. [34] studied the role of Konig deletion sets (vertex sets whose removal ensure that the size of a maximum matching in the remaining graph equals the vertex cover number of that graph) for the complexity of the Vertex Cover problem, and showed that Vertex Cover parameterized above the size of a maximum matching is fixed-parameter tractable by exhibiting a connection to Almost 2-SAT [40]. Gutin et al. [29] studied the parameterized complexity of various Vertex Cover-parameterizations above and below tight bounds which relate to the maximum degree of the graph and the matching size, obtaining FPT algorithms and hardness results. Raman et al. [39] gave improved algorithms for Vertex Cover parameterized above the size of a maximum matching: their algorithm decides in O∗(9(cid:96)) time whether a graph has a vertex cover of size m + (cid:96), where m is the size of a maximum matching. The Vertex Cover problem has also played an important role in the development of problem kernelization [28]. Kernelization is a concept that enables the formal mathe- matical analysis of data reduction through the framework of parameterized complexity. A kernelization algorithm (or kernel ) is a polynomial-time procedure that reduces an instance (x, k) of a parameterized decision problem to an equivalent instance (x(cid:48), k(cid:48)) such that x(cid:48), k(cid:48) ≤ f (k) for some computable function f , which is the size of the kernel. We also use the term kernel to refer to the reduced instance (x(cid:48), k(cid:48)). The k-Vertex Cover problem admits a kernel with 2k vertices and O(k2) edges, which can be obtained through crown reduction [11, 2, 12] or by applying a linear- programming theorem due to Nemhauser and Trotter [35, 9]. These kernelization al- gorithms have been a subject of repeated study and experimentation [1, 16, 7]. Very 1We use k-Vertex Cover to denote the parameterization by the target size k. 2 recently Soleimanfallah and Yeo [42] showed that for every constant c there exists a ker- nel with 2k − c vertices. This is mostly of theoretical interest however, since the running time of the kernelization algorithm is exponential in c. There is some complexity-theoretic evidence that the size bounds for the kernel can- not be improved. Since all reduction rules found to date are approximation-preserving [36], it appears that a kernel with (2 − )k vertices for any  > 0 would yield a polynomial- time approximation algorithm for Vertex Cover with a performance ratio 2−  which would disprove the Unique Games Conjecture [32]. A breakthrough result by Dell and Van Melkebeek [15] shows that there is no polynomial kernel which can be encoded into O(k2−) bits for any  > 0 unless NP ⊆ coNP/poly and the polynomial hierar- chy collapses to the third level [44], which is reason to believe that the current bound of O(k2) edges is tight up to ko(1) factors. This overview might suggest that there is little left to explore concerning kernelization for vertex cover, but this is far from true. The mentioned kernelization results use the requested size k of the vertex cover as the parameter. But there is no reason why we should not consider structurally smaller parameters, to see if we can preprocess instances of Vertex Cover such that their final size is bounded polynomially by such a smaller parameter, rather than by a function of the requested set size k. We study kernelization for the Vertex Cover problem using the feedback vertex number fvs(G) as the parameter. Since every vertex cover is also a feedback vertex set we find that fvs(G) ≤ vc(G) which shows that the feedback vertex number of a graph is a structurally smaller parameter than the vertex covering number: there are trees with arbitrarily large values of vc(G) for which fvs(G) = 0. Observe that for difficult instances of Vertex Cover we have k ∈ Θ(vc(G)) since the use of the 2-approximation algorithm immediately solves instances where k > 2 vc(G) or k < vc(G)/2. Therefore we call our parameter "refined" since it is structurally smaller than the standard parameter for the Vertex Cover problem. Observe that the parameterization by fvs(G) is not relevant for the setting of fixed-parameter algorithms, since it is dominated by various smaller parameters such as treewidth and the size of an odd cycle transversal, with respect to which Vertex Cover is still fixed-parameter tractable (see Section 5). Our Results. Our contribution is twofold: we present a polynomial kernel, and a kernel lower bound for a structural parameterization of a weighted variant. Upper bounds. Let us formally define the problem under consideration. fvs-Vertex Cover Instance: A simple undirected graph G, a feedback vertex set X ⊆ V (G) such that G − X is a forest, an integer k ≥ 0. Parameter: The size X of the feedback vertex set. Question: Does G have a vertex cover of size at most k? √ We prove that fvs-Vertex Cover has a kernel in which the number of vertices is bounded by min(2k, 2X + 28X2 + 56X3), which can be computed in O( nm + n5/3) time. The kernel size is at least as small as the current-best Vertex Cover kernel, but for graphs with small feedback vertex sets our bound can be expected to be significantly smaller. 3 We also consider the problem fvs-Independent Set which is similarly defined: the difference is that we now ask whether G has an independent set of the requested size, instead of a vertex cover. Throughout this work k will always represent the total size of the set we are looking for; depending on the context this is either a vertex cover or an independent set. An instance (G, X, k) of fvs-Vertex Cover is equivalent to an instance (G, X,V (G) − k) of fvs-Independent Set which has the same parameter value and therefore the two problems are equivalent from a parameterized complexity and kernelization standpoint. Lower bounds. We also consider the weighted version of Vertex Cover, where each vertex is assigned a positive integral weight value and we ask for the existence of a vertex cover of total weight at most k. In the preliminary version of this work that appeared at STACS 2011 we proved that fvs-Weighted Vertex Cover, where the parameter measures the cardinality of a given feedback vertex set, does not admit a polynomial kernel unless NP ⊆ coNP/poly. In this final version we present a stronger result: under the same assumption the weighted problem does not even admit a polynomial kernel parameterized by the cardinality of a given vertex cover. Our lower bound therefore applies to the following problem: vc-Weighted Vertex Cover Instance: A simple undirected graph G, a weight function w : V (G) → N+, a vertex cover X ⊆ V (G), an integer k ≥ 0. Parameter: The cardinality X of the vertex cover. Question: Is there a vertex cover C of G such that(cid:80) v∈C w(v) ≤ k? This lower bound parameterized by the cardinality of a given vertex cover is rather surprising, since Chleb´ık and Chleb´ıkov´a used a modified form of crown reductions to prove that Weighted Vertex Cover parameterized by the target weight k admits a linear-vertex kernel [11]. In our construction for the lower bound we use only two different vertex weights: the value one, and a larger but polynomially-bounded value. Hence the comparative difficulty of the weighted problem does not stem from a tricky encoding of weights, but rather because the presence of weights allow us to encode complicated behavior (the OR of a series of inputs of Vertex Cover) into a graph which has a relatively simple structure (a small vertex cover). Section 5 contains a further discussion of kernelization for weighted problems. Observe that vc-Weighted Vertex Cover lies in FPT because the parameter is an upper bound on the treewidth of the input graph. Related Work. The idea of studying parameterized problems using alternative parameters is not new (see, e.g., [36]), but was recently advocated by Fellows et al. [22, 23, 37] in the call to investigate the complexity ecology of parameters. They posed that inputs to computational problems are rarely arbitrary or random because these inputs are created by processes which are themselves computationally bounded. This suggests that inputs might inherit structure from the processes which create them, possibly in unknown or unforeseen ways, and that we should therefore consider the complexity of problems not only when parameterized by their own solution value, but by also by structural 4 properties of the input, and in general by the optimum solution value to any other optimization problem on the instance. The main idea behind this program is therefore to determine how different parameters affect the parameterized complexity of a problem. Some recent results in this direction include FPT algorithms for graph layout problems parameterized by the vertex cover number of the graph [24] and an algorithm to decide isomorphism on graphs of bounded feedback vertex number [33]. There are a handful of applications of this idea to give polynomial kernels using alternative parameters. Fellows et al. [23, 21] show that the problems Independent Set, Dominating Set and Hamiltonian Circuit admit linear-vertex kernels on graphs G when parameterized by the maximum number of leaves in any spanning tree of G. A superset of the current authors [6] obtained a polynomial kernel for Treewidth parameterized by fvs(G). Uhlmann and Weller [43] gave a polynomial kernel for Two-Layer Planarization parameterized by the feedback edge set number, which is a refined structural parameter for that problem since it is smaller than the natural parameter. Organization. We give some graph-theoretic preliminaries in Section 2. Section 3 contains the main content of this paper, and develops a cubic-vertex kernel for fvs- Vertex Cover. In Section 4 we prove the lower bound for the weighted version of the problem. 2 Preliminaries have NG(S) := (cid:83) v∈S NG(v) \ S, and NG[S] := (cid:83) In this work we only consider undirected, finite, simple graphs. For a graph G let V (G) be the vertex set and E(G) the edge set. We denote the independence number of G (i.e., the size of a maximum independent set) by α(G), the vertex covering number by vc(G) and the feedback vertex number by fvs(G). We will abbreviate maximum independent set as MIS, and feedback vertex set as FVS. For v ∈ V (G) we denote the open and closed neighborhoods of v by NG(v) and NG[v], respectively. For a set S ⊆ V (G) we v∈S NG[v]. The degree of a vertex v in graph G is denoted by degG(v). We write G(cid:48) ⊆ G if G(cid:48) is a subgraph of G. For X ⊆ V (G) we denote by G[X] the subgraph of G that is induced by the vertices in X. The graph G[V (G)\ X] obtained from G by deleting the vertices in X and their incident edges is denoted by G − X. A matching in a graph G is a set of edges M ⊆ E(G) such that no two distinct edges in M are incident on a common vertex. A matching is perfect if every vertex of the graph is incident on exactly one edge in the matching. A vertex of degree one is called a leaf. If v is a vertex in a tree and v is not a leaf, then it is an internal node of the tree. The leaf set of a graph G is the set of degree-1 vertices, denoted by Leaves(G) := {v ∈ V (G) degG(v) = 1}. P2 is the graph consisting of a path on two vertices. We use [n] as a shorthand for {1, 2, . . . , n}. Konig's Theorem ([41, Theorem 16.2]). For every bipartite graph G, the size of a minimum vertex cover equals the number of edges in a maximum matching. 5 Observation 1. Let F be a forest with a perfect matching M ⊆ E(F ). The following hold: (i) V (F ) = 2M and vc(F ) = α(F ) = M, since F is bipartite. (ii) Every vertex of F is adjacent to at most one leaf. (iii) If v is a leaf of F , then v has a unique neighbor u ∈ V (F ) and {u, v} ∈ M . Observation 2. If G(cid:48) is a vertex-induced subgraph of graph G then α(G) ≥ α(G(cid:48)). Observation 3. If v is a leaf in G then there is a MIS for G that contains v. 3 Cubic Kernel for FVS-Vertex Cover In this section we develop a cubic kernel for fvs-Vertex Cover. For the ease of presentation, we first develop a kernel for fvs-Independent Set. Using the corre- spondence between the two problems mentioned in the introduction, this kernel for fvs-Independent Set will immediately yield a kernel for fvs-Vertex Cover. From now on we therefore focus on fvs-Independent Set. We first show that a single application of the Nemhauser-Trotter decomposition theorem [35], used for kernel- ization of the vertex cover problem by Chen et al. [9], allows us to restrict our attention to instances of fvs-Vertex Cover where the forest G−X has a perfect matching. This will greatly simplify the analysis of the kernel size as compared to the extended abstract of this work [30] where we worked with arbitrary forests G − X. In Section 3.1 we will then introduce a set of reduction rules and prove they are correct. Afterwards we will analyze the structure of the resulting reduced instances, in Section 3.2. This analysis will focus on conflict structures. An important ingredient in the kernel size bound will be a purely graph-theoretic extremal argument, which is developed in Section 3.3, and which will show that many conflict structures exist in reduced instances. As the last step we discuss the running time of a possible implementation of the reduction rules, and tie all ingredients together into a kernelization algorithm in Section 3.4. So let us start by showing how to reduce to instances where the forest G − X has a perfect matching. For this purpose we re-state the Nemhauser-Trotter theorem here in terms of independent sets. Proposition 1 ([9, Proposition 2.1]). There is an O( nm)-time algorithm that, given a graph G with n vertices and m edges, constructs disjoint subsets C0, V0 ⊆ V (G) such that: √ 1. if I is a maximum independent set in G[V0] then I ∪ J is a maximum independent set in G, with J := V (G) \ (C0 ∪ V0), and 2. α(G[V0]) ≤ V0/2. 6 We will exploit the decomposition guaranteed by this proposition to show that after identifying a set of vertices which can be in any maximum independent set of G, there is a small (in terms of X) set I ⊆ V (G) \ X that we can add to X, such that the forest G − (X ∪ I) has a perfect matching. Lemma 1. Let (G, X, k) be an instance of fvs-Independent Set. In O( one can compute an equivalent instance (G(cid:48), X(cid:48), k(cid:48)) such that: nm) time √ 1. G(cid:48) − X(cid:48) has a perfect matching, 2. X(cid:48) ≤ 2X, and 3. k(cid:48) ≤ k. Proof. Given an instance (G, X, k) of fvs-Independent Set, use the algorithm of Proposition 1 to compute the two sets C0, V0 ⊆ V (G). Now set G(cid:48) := G[V0], let X := X ∩ V0, and k(cid:48) := k − (V (G) − V0 − C0). The proposition ensures that the in- stances (G, X, k) and (G(cid:48), X, k(cid:48)) are equivalent, and it is easy to see that G(cid:48) − X is a forest since it is a subgraph of G − X. The last property of the proposition ensures that α(G(cid:48)) ≤ V (G(cid:48))/2. Now, we compute a maximum matching M of the forest G(cid:48) − X, which can be done √ in O( nm) time using the Hopcroft-Karp algorithm. Note that V (G(cid:48)− X) = 2M+I where I is the set of vertices not covered by the matching. As G(cid:48) − X is a forest, and hence bipartite, a minimum vertex cover for G(cid:48) − X has size M (by Konig's Theorem) and maximum independent sets have size V (G(cid:48) − X) − M = M + I. Comparing α(G(cid:48)− X) = M+I with the upper bound of α(G(cid:48)− X) ≤ α(G(cid:48)) ≤ 1 2V (G(cid:48)) we get the following: α(G(cid:48) − X) ≤ V (G(cid:48))/2 M + I ≤ ( X + 2M + I)/2 I ≤ X. Thus, letting X(cid:48) := X ∪ I, we know that G(cid:48) − X(cid:48) is a forest, and that it has a perfect matching (namely M ). Clearly X(cid:48) ≤ 2 X ≤ 2X. We return the instance (G(cid:48), X(cid:48), k(cid:48)). The fact that the forest G−X of an instance of fvs-Independent Set has a perfect matching is so useful that it warrants its own name. Definition 1. An instance (G, X, k) of fvs-Independent Set is called clean if the forest G − X has a perfect matching. We will apply Lemma 1 once at the start of our kernelization, and work on the resulting clean instance of the problem. The reduction rules we apply to shrink the instance further maintain the fact that the forest has a perfect matching. 7 3.1 Reduction rules for clean instances Consider a clean instance (G, X, k) of fvs-Independent Set, which asks whether a graph G with the FVS X has an independent set of size k. Throughout this section F := G − X denotes the forest obtained by deleting the vertices in X, and recall that G − X has a perfect matching by the assumption that the instance is clean. To formulate our reduction rules we use the following notion. fine X :=(cid:8)Y ⊆ X(cid:12)(cid:12) Y is independent in G and 0 < Y ≤ 2(cid:9) as the collection of chunks Definition 2 (Chunks). Let (G, X, k) be an instance of fvs-Independent Set. De- of X. The chunks X corresponding to an instance are size-≤ 2 subsets of the feedback vertex set X, which could be part of an independent set in G. Our first two reduction rules get rid of chunks when we can effectively determine that there is a MIS which does not contain them. We get rid of a chunk by either deleting it (when it is a single vertex) or by adding an edge (if a chunk consists of two non-adjacent vertices). Observe that after adding the edge {u, v} for u, v ∈ X the pair {u, v} is no longer independent, and therefore no longer counts as a chunk. We rely on the fact that when given an independent subset X(cid:48) ⊆ X of the feedback vertices, we can efficiently compute a largest independent set I in G which satisfies I ∩ X = X(cid:48): since such a set intersects X exactly in X(cid:48), and since it cannot use any neighbors of X(cid:48) the maximum size is X(cid:48) + α(F − NG(X(cid:48))) and this is polynomial-time computable since F − NG(X(cid:48)) is a forest. The following notion allows us to assess which chunks might occur in a MIS of G. Definition 3. The number of conflicts ConfF (cid:48)(X(cid:48)) induced by a subset X(cid:48) ⊆ X on a subforest F (cid:48) ⊆ F ⊆ G is defined as ConfF (cid:48)(X(cid:48)) := α(F (cid:48)) − α(F (cid:48) − NG(X(cid:48))). This term ConfF (cid:48)(X(cid:48)) can be interpreted as follows. Choosing vertices from X(cid:48) in an independent set will prevent all their neighbors in the subforest F (cid:48) from being part of the same independent set; hence if we fix some choice of vertices in X(cid:48), then the number of vertices from F (cid:48) we can add to this set (while maintaining independence) might be smaller than the independence number of F (cid:48). The term ConfF (cid:48)(X(cid:48)) measures informally it is the price we pay in the forest F (cid:48) for the difference between the two: choosing the vertices X(cid:48) in the independent set (see Fig. 1). We can now state the first two reduction rules. Reduction Rule 1. If there is a vertex v ∈ X such that ConfF ({v}) ≥ X, then delete v from the graph G and from the set X. Reduction Rule 2. If there are distinct vertices u, v ∈ X with {u, v} (cid:54)∈ E(G) for which ConfF ({u, v}) ≥ X, then add the edge {u, v} to G. Since these two rules only affect the graph induced by X, they do not change the fact that forest F has a perfect matching. Correctness of the rules can be established from the following lemma. 8 (a) α(G − X) = 3. (b) ConfF ({u}) = 0. (c) ConfF ({u, w}) = 1. Figure 1: Illustration of the first three definitions. A clean instance (G, X, k) is shown in three different states, with X visualized in the bottom container and the forest F := G − X visualized in the top container. The perfect matching in F is indicated by thick edges. The chunks in this instance are X = {{u},{v},{w},{u, w}}. (a) MIS in F showing that α(F ) = 3. (b) The drawn independent set does not contain any neighbors of u and contains 3 = α(F ) vertices from F ; hence α(F − NG(u)) = α(F ) = 3, implying that ConfF ({u}) = 0. (c) Choosing vertices {u, w} in an independent set prevents us from adding three vertices from F to the independent set; we can add only two, without violating independence. The difference (3− 2 = 1) is the number of conflicts induced by the pair: ConfF ({u, w}) = 1. Lemma 2. If X(cid:48) ⊆ X is a subset of feedback vertices such that ConfF (X(cid:48)) ≥ X then there is a MIS for G that does not contain all vertices of X(cid:48). Proof. Assume that I ⊆ V (G) is an independent set containing all vertices of X(cid:48). We will prove that there is an independent set I(cid:48) which is disjoint from X(cid:48) with I(cid:48) ≥ I. Since ConfF (X(cid:48)) ≥ X it follows by definition that α(F ) − α(F − NG(X(cid:48))) ≥ X; since I cannot contain any neighbors of vertices in X(cid:48) we know that I∩V (F ) ≤ α(F −NG(X(cid:48))), and since V (G) = X ∪ V (F ) we have I ≤ X + α(F − NG(X(cid:48))) ≤ α(F ). Hence the maximum independent set for F , which does not contain any vertices of X(cid:48), is at least as large as I; this proves that for every independent set containing X(cid:48) there is another independent set which is at least as large and avoids the vertices of X(cid:48). Therefore there is a MIS for G avoiding at least one vertex of X(cid:48). The next rule is used to remove trees from the forest F when the tree does not interact with any of the chunks in X. Reduction Rule 3. If F contains a connected component T (which is a tree) such that for all chunks Y ∈ X it holds that ConfT (Y ) = 0, then delete T from graph G and decrease k by α(T ). Since the rule deletes an entire tree from the forest F , it ensures that the remainder of the forest will have a perfect matching. To prove the correctness of Rule 3 we need the following lemma. Lemma 3. Let T be a connected component of F and let XI ⊆ X be an indepen- If ConfT (XI ) > 0 then there is a set X(cid:48) ⊆ XI with X(cid:48) ≤ 2 such dent set in G. that ConfT (X(cid:48)) > 0. 9 Proof. Assume the conditions stated in the lemma hold. Recall that throughout this section we work on a clean instance, so let M be a perfect matching on T which exists since the forest F has a perfect matching. We will try to construct a MIS I for T that does not use any vertices in NG(XI ); this must then also be a MIS for T − NG(XI ) of the same size. By the assumption that ConfT (XI ) > 0 any independent set in T must use at least one vertex in NG(XI ) in order to be maximum, hence our construction procedure must fail somewhere; the place where it fails will provide us with a set X(cid:48) as required by the statement of the lemma. Construction of a MIS. It is easy to see that a MIS of a tree with a perfect matching contains exactly one vertex from each matching edge. We now start building our independent set I for T that avoids vertices in NG(XI ). To ensure I becomes a MIS for T , we need to add one endpoint of each edge in the matching M . If there is a vertex v in T such that NT (v) = {u} and NG(v) ∩ XI = ∅, then the edge {v, u} must be in the matching M (since M is a perfect matching and there are no other edges incident on v). Because we must choose one of {u, v} in a MIS for T , and by Observation 3 choosing a degree-1 vertex will never conflict with choices that are made later on, we can add v to our independent set I while respecting the invariant that no vertex in I is adjacent in G to a vertex in XI . Since we have then chosen one endpoint of the matching edge {u, v} in I, we can delete u, v and their incident edges to obtain a smaller graph T (cid:48) (which again contains a perfect submatching of M ) in which we continue the process. As long as there is a vertex with degree one in T (cid:48) that has no neighbors in XI then we take it into I, delete it and its neighbor, and continue. If this process ends with an empty graph, then by our starting observation the set I must be a MIS for T , and since it does not use any vertices adjacent to XI it must also be a MIS for T − NG(XI ); but this proves that α(T ) = α(T − NG(XI )) which means ConfT (XI ) = 0, which is a contradiction to the assumption at the start of the proof. So the process must end with a non-empty graph T (cid:48) ⊆ T such that vertices with degree one in T (cid:48) are adjacent in G to a vertex in XI and for which the matching M restricted to T (cid:48) is a perfect matching on T (cid:48). We use this subgraph T (cid:48) to obtain a set X(cid:48) as desired. Using the subgraph to prove the claim. Consider a vertex v0 in T (cid:48) such that degT (cid:48)(v0) = 1, and construct a path P = (v0, v1, . . . , v2p+1) by following edges of T (cid:48) that are alternatingly in and out of the matching M , until arriving at a degree-1 vertex whose only neighbor was already visited. Since T (cid:48) is acyclic, M restricted to T (cid:48) is a perfect matching on T (cid:48) and we start the process at a vertex of degree one, it is easy to verify that there is such a path P (there can be many; any arbitrary such path will suffice), that P contains an even number of vertices, that the first and last vertex on P have degree-1 in T (cid:48) and that the edges {v2i, v2i+1} must be in M for all 0 ≤ i ≤ p. Since we assumed that all degree-1 vertices in T (cid:48) are adjacent in G to XI , there exist vertices x1, x2 ∈ X such that v0 ∈ NG(x1) and v2p+1 ∈ NG(x2). We now claim that X(cid:48) := {x1, x2} satisfies the requirements of the statement of the lemma, i.e., that ConfT ({x1, x2}) > 0. This fact is witnessed by considering the path P in the original tree T . Any MIS for T which avoids NG({x1, x2}) must use one endpoint of the matched edge {v0, v1}, and since the choice of v0 is blocked because v0 is a neighbor 10 to x1, it must use v1. But path P shows that v1 is adjacent in T to v2, and hence we cannot choose v2 in the independent set. But since {v2, v3} is again a matched edge, we must use one of its endpoints; hence we must use v3. Repeating this argument shows that we must use vertex v2p+1 in a MIS for T if we cannot use v0; but the use of v2p+1 is also not possible if we exclude NG({x1, x2}). Hence we cannot make a MIS for T without using vertices in NG({x1, x2}) which proves that α(T ) > α(T − NG({x1, x2}). By the definition of conflicts this proves that ConfT (X(cid:48)) > 0 for X(cid:48) = {x1, x2}, which concludes the proof. Using this lemma we can prove the correctness of Rule 3. We remark that using a more involved argument based on a decomposition theorem describing independent sets in forests by Zito [45], it is possible to show that Lemma 3 holds even if F is a forest that does not admit a perfect matching. This argument can be found in an earlier version of this work [30, Lemma 4]. Lemma 4. Rule 3 is correct: chunks Y ∈ X it holds that ConfT (X(cid:48)) = 0, then α(G) = α(G − T ) + α(T ). if T is a connected component in F such that for all Proof. Assume the conditions in the statement of the lemma hold. It is trivial to see that α(G) ≤ α(G − T ) + α(T ). To establish the lemma we only need to prove that α(G) ≥ α(G − T ) + α(T ), which we will do by showing that any independent set IG−T in G − T can be transformed to an independent set of size at least IG−T + α(T ) in G. So consider such an independent set IG−T , and let XI := IG−T ∩ X be the set of vertices which belong to both IG−T and the feedback vertex set X. Suppose that α(T ) > α(T − NG(XI )). Then by Lemma 3 there is a subset Y ⊆ XI with Y ≤ 2 such that ConfT (Y ) > 0. Since XI is an independent set, such a subset Y would also be independent, and hence would be a chunk in X . But by the preconditions to this lemma such a chunk Y does not exist and therefore we have α(T ) = α(T − NG(XI )). Now we show how to transform IG−T into an independent set for G of the requested size. Let IT be a MIS in T − NG(XI ), which has size α(T − NG(XI )) = α(T ). It is easy to verify that IG−T ∪ IT is an independent set in G because vertices of T are only adjacent to vertices of G − T which are contained in X. Hence the set IG−T ∪ IT is independent in G and it has size IG−T + α(T ). Since this argument applies to any independent set IG−T in graph G − T it holds in particular for a MIS in G − T , which proves that α(G) ≥ α(G − T ) + α(T ). We introduce the concept of blockability for the statement of the last reduction rules. Definition 4. The pair x, y ∈ V (G) \ X is X-blockable if there is a chunk Y ∈ X such that {x, y} ⊆ NG(Y ). This can be interpreted as follows: any independent set in G containing the chunk Y cannot contain x nor y, so using the chunk Y in an independent set blocks both vertices of the pair x, y from being in the same independent set. It follows directly from the definition that if x, y is not X-blockable, then for any combination of u ∈ NG(x) ∩ X 11 (a) Rule 4: Shrinking unblockable degree-2 paths in trees. (k(cid:48) := k − 1) (b) Rule 5: Removing unblockable leaves in trees. (k(cid:48) := k − 2) Figure 2: Illustrations of two reduction rules. The original structure is shown on the left, and the image on the right shows the structure after the reduction. Feedback vertices X are drawn in the bottom container, whereas the forest G − X is visualized in the top container. and v ∈ NG(y) ∩ X we have u (cid:54)= v and {u, v} ∈ E(G) -- otherwise the singleton {u} would block x and y, or the pair {u, v} would be independent and would block x, y. See Fig. 2 for an illustration of the final two reduction rules, which are meant to reduce the sizes of the trees in the forest F . Whereas Rule 3 deletes a tree T from the forest F when we can derive that for every independent set in G − T we can obtain an independent set in G which is α(T ) vertices larger, these last reduction rules act locally within one tree, but according to the same principle. Instead of working on an entire connected component of F , they reduce subtrees T (cid:48) ⊆ F in situations where we can derive that every independent set in X can be augmented with α(T (cid:48)) vertices from T (cid:48). In Rule 4 we reduce the subtree on vertices {u, v} which has independence number one, and in Rule 5 we reduce the subtree on vertices {u, v, t, w} with independence number two. Connections between the vertices adjacent to the reduced subtree are made to enforce that removal of the subtree does not affect the types of interactions between the neighboring vertices. We will see later in the analysis of the kernel size that these last two rules are needed to relate the size of the forest in a remaining instance, to the number of chunks in the instance and thereby to the size of the feedback vertex set. Reduction Rule 4. If there are distinct vertices u, v ∈ V (G) \ X which are adjacent in G and are not X-blockable such that degF (u), degF (v) ≤ 2 then reduce the graph as follows: • Delete vertices u, v with their incident edges and decrease k by one. • If u has a neighbor t in F which is not v, make it adjacent to NG(v) ∩ X. • If v has a neighbor w in F which is not u, make it adjacent to NG(u) ∩ X. • If the vertices t, w exist then they are unique; add the edge {t, w} to the graph. It is not hard to see that this rule does not change the fact that F has a perfect if the edge {u, v} was contained in the perfect matching, then the match- matching: ing restricted to the remaining vertices is a perfect matching for the remaining graph. 12 If {u, v} was not contained in the perfect matching then u was matched to t and v was matched to w; we obtain a perfect matching for the reduced graph by matching t to w, using the edge that is added to the graph by the reduction rule. Lemma 5. Let (G, X, k) with F := G − X be an instance to which Rule 4 is applicable at vertices u, v, and let (G(cid:48), X, k − 1) be the instance resulting from the reduction. Then it holds that α(G) ≥ k ⇔ α(G(cid:48)) ≥ k − 1. Proof. Assume the conditions in the statement of the lemma hold. We prove the two directions separately. (⇒) Let IG be an independent set for graph G of size at least k. We show how to obtain an independent set IG(cid:48) for graph G(cid:48) of size at least IG− 1 ≥ k− 1. Observe that no independent set in G can contain both {u, v} since they are adjacent. If IG does not contain any of the vertices {u, v} then we show how to obtain I(cid:48) G which is at least as large and does contain one of {u, v}; so assume IG avoids u and v. Since the pair u, v is not X-blockable by the preconditions for the reduction rule, we know that there is at least one vertex among u, v for which no neighbor in X is chosen in IG. Assume without loss of generality (by symmetry) that this holds for u, such that NG(u)∩ X ∩ IG = ∅. Since v is not in IG by assumption, the only neighbor of u that can be in IG is its neighbor t G := IG ∪ {u} in F unequal to v (if such a t exists; see Fig. 2). If no such t exists then I(cid:48) G := (IG \ {t}) ∪ {u} is an equally large is a bigger independent set in G; otherwise I(cid:48) independent set. So using this replacement argument and symmetry, we may assume that IG is an independent set of size at least k for G that contains u but not v. We now claim that IG(cid:48) := IG\{u} is an independent set of size ≥ k−1 in G(cid:48). Since it is easy to see that IG(cid:48) has the desired size, it remains to show that it is an independent set in G(cid:48). To establish this we need to show that the transformation to G(cid:48) does not add any edges between vertices of IG(cid:48). This is ensured because all edges that are added by the transformation have at least one endpoint which is a neighbor of u: all added edges are either incident on w or a vertex in NG(u)∩ X. Hence for each added edge one endpoint z is adjacent to u, and since we assumed u ∈ IG this implies that z cannot be in IG(cid:48) since IG(cid:48) is a subset of the independent set IG in G and having adjacent vertices u and z in IG would violate independence. Therefore IG(cid:48) is indeed an independent set of the required size in G(cid:48). (⇐) Let IG(cid:48) be an independent set for graph G(cid:48) of size at least k − 1. We show how to obtain an independent set IG for graph G of size at least IG(cid:48) + 1 ≥ k. The structure of IG(cid:48) determines how to augment to a larger independent set IG. From the structure of the reverse transformation of G(cid:48) to G it follows that IG(cid:48) is an independent set in G; hence for each case we will only show that the new vertex we add to the set will not violate independence in graph G. We now do a case analysis based on whether or not the neighbors t of u and w of v are present. • If vertex t exists and t ∈ IG(cid:48), then define IG := IG(cid:48) ∪ {v}. To prove IG is an independent set in G we show that NG(v) ∩ IG(cid:48) = ∅ by consecutively proving that {u, w} ∩ IG(cid:48) = ∅ and NG(v) ∩ X ∩ IG(cid:48) = ∅, which together suffice to establish our claim because NG(v) = {u, w}∪(NG(v)∩X) (for as far as t exists). Since u (cid:54)∈ V (G(cid:48)) 13 we trivially have u (cid:54)∈ IG(cid:48), and because the edge {t, w} is added when forming G(cid:48) and t ∈ IG(cid:48) by the case distinction we have w (cid:54)∈ IG(cid:48). To see that NG(v)∩X∩IG(cid:48) = ∅ observe that NG(v) ∩ X ⊆ NG(cid:48)(t) by the construction of G(cid:48), and since t ∈ IG(cid:48) and IG(cid:48) is independent in G(cid:48) this proves the claim and the correctness of this case. • If vertex w exists and w ∈ IG(cid:48), then define IG := IG(cid:48) ∪ {u}. The correctness argument is symmetric to that of the previous case. • In the remaining case we know that {t, w}∩IG(cid:48) = ∅. There must be some z ∈ {u, v} such that NG(z) ∩ X ∩ IG(cid:48) = ∅; because if there is no such z then by combining one vertex from NG(u) ∩ X ∩ IG(cid:48) and one from NG(v) ∩ X ∩ IG(cid:48) gives a pair which proves that {u, v} is X-blockable in G, contradicting the precondition to the reduction rule. We now assign IG := IG(cid:48) ∪ {z}. Since NG(z) ∩ F ⊆ {t, u, v, w} and these vertices either do not exist in G(cid:48) or are not in IG(cid:48) by the case distinction, we know {t, u, v, w} ∩ IG(cid:48) = ∅. Since NG(z) ∩ X ∩ IG(cid:48) = ∅ by our choice of z this proves that the addition of z to the independent set does not violate independence, because NG(z) ⊆ (NG(z) ∩ X) ∪ {t, u, v, w}. Since the case distinction is exhaustive this establishes the claim in this direction, which concludes the proof. Reduction Rule 5. If there are distinct vertices t, u, v, w in V (G) \ X which satisfy degF (u) = degF (v) = 3, NF (t) = {u}, NF (w) = {v} and {u, v} ∈ E(G) such that none of the pairs {u, t}, {v, w}, {t, w} are X-blockable, then reduce as follows. Let {p} = NF (u) \ {t, v} and let {q} = NF (v) \ {w, u}. • Delete {t, u, v, w} and their incident edges from G and decrease k by two. • Make p adjacent to all vertices of NG(t) ∩ X. • Make q adjacent to all vertices of NG(w) ∩ X. Once again it is not difficult to see that the rule preserves the fact that F has a perfect matching: since t and w have degree one in F , they must be matched to u and v in a perfect matching; hence the rule effectively deletes the endpoints of two matching edges from the graph. Lemma 6. Let (G, X, k) with F := G − X be an instance to which Rule 5 is applicable at vertices t, u, v, w, and let (G(cid:48), X, k − 2) be the instance resulting from the reduction. Then it holds that α(G) ≥ k ⇔ α(G(cid:48)) ≥ k − 2. Proof. Assume the conditions in the statement of the lemma hold. We prove the two directions separately. (⇒) Let IG be an independent set for graph G of size at least k. We show how to obtain an independent set IG(cid:48) for graph G(cid:48) of size at least IG − 2 ≥ k − 2. We first show that without loss of generality we may assume that for one of the pairs {t, w},{t, v},{u, w} both vertices of the pair belong to IG. To see this, suppose that IG avoids at least one vertex in each pair. We then obtain an alternative independent set I(cid:48) which is at least as large, and contains both vertices of at least one pair. G 14 • If IG∩ X ∩ NG(t) = ∅ and IG∩ X ∩ NG(w) = ∅ then define I(cid:48) G := (IG\{u, v, t, w})∪ {t, w} which is easily seen to be an independent set. Since no independent set can contain three or more vertices from {u, v, t, w} (because of the edges {u, t} and {v, w}) we now have I(cid:48) G ≥ IG. • If IG ∩ X ∩ NG(t) (cid:54)= ∅ then we must have IG ∩ X ∩ NG(w) = ∅; for if both sets are non-empty, then taking one vertex from IG ∩ X ∩ NG(t) and one vertex from IG ∩ X ∩ NG(w) yields a pair which shows that {t, w} is X-blockable, which contradicts the preconditions to Rule 5. Using the same argument we must have that IG∩ X ∩ NG(u) = ∅, otherwise {t, u} is X-blockable. Set I(cid:48) G := (IG \{p, u, t, v, w})∪{u, w}. The neighborhood conditions show that no neighbors of u, w in X are contained in IG (and hence in IG(cid:48)), and because we explicitly delete any neighbors that u, w might have in F when forming I(cid:48) G is also an independent set in G. If IG∩ X ∩ NG(t) (cid:54)= ∅ as specified by the precondition for this case, then we cannot have t ∈ IG because then IG would not be independent. The edges {p, u} and {v, w} in G show that of the set {p, u, v, w} at most two vertices are in an independent set; hence in this situation IG contains at most two vertices from {p, u, t, v, w} and therefore we have I(cid:48) G we see that I(cid:48) G ≥ IG. • If IG∩X∩NG(w) (cid:54)= ∅ then we must have that IG∩X∩NG(t) = IG∩X∩NG(v) = ∅, G := (IG\{q, u, t, v, w})∪{t, v}. The correctness argument is symmetric and we set I(cid:48) to that of the previous case. The argument above shows that we may assume without loss of generality that for one of the pairs {t, w},{t, v},{u, w} the independent set IG contains both vertices of the pair. Using this assumption we show how to obtain an independent IG(cid:48) with IG(cid:48) ≥ IG − 2. • If t, w ∈ IG then define IG(cid:48) := IG \ {t, w}. Since t, w ∈ IG implies that u, v (cid:54)∈ IG we know that all vertices in IG(cid:48) still exist in G(cid:48). It remains to show that they form an independent set there. Because the reduction to G(cid:48) only adds edges incident on p and q, it suffices to show that for all edges incident on p or q which are added by the reduction there is at least one endpoint not in IG(cid:48). The transformation from G to G(cid:48) adds edges from NG(t) ∩ X to p, and edges from NG(w) ∩ X to q. But since t, w ∈ IG we know that the independent set IG contains no vertices of NG(t) ∩ X or NG(w) ∩ X, and hence the defined set IG(cid:48) is an independent set in G(cid:48). • If t, v ∈ IG then define IG(cid:48) := IG \ {t, v}. All vertices in IG(cid:48) must exist in G(cid:48) since u, w cannot be in IG because their neighbors t, v are in IG. The edges we add in the transformation to G(cid:48) do not violate independence: because t ∈ IG we have NG(t) ∩ IG = ∅, and similarly because v ∈ IG we have NG(v) ∩ IG = ∅ which in particular means q (cid:54)∈ IG. For all edges that we add, at least one endpoint is not in IG and therefore not in IG(cid:48); this proves that IG(cid:48) is an independent set in G(cid:48). • If u, w ∈ IG then define IG(cid:48) := IG \ {u, w}. The proof of correctness is symmetric to that for the previous case. 15 Since one of these cases must apply, the listing is exhaustive and it concludes the proof of this direction of the equivalence. (⇐) Let IG(cid:48) be an independent set for graph G(cid:48) of size at least k − 2. We show how to obtain an independent set IG for graph G of size at least IG(cid:48) + 2 ≥ k. The structure of IG(cid:48) determines how to augment to a larger independent set IG by adding two vertices to IG(cid:48). From the structure of the reverse transformation of G(cid:48) to G it follows that IG(cid:48) is an independent set in G; hence for each case we will only show that the new vertices we add to the set will not violate independence in graph G. • If NG(t) ∩ X ∩ IG(cid:48) = ∅ and NG(w) ∩ X ∩ IG(cid:48) = ∅ then assign IG := IG(cid:48) ∪ {t, w}. Since vertices t, w are clearly non-adjacent in G, and because the vertices in IG(cid:48) form an independent set in G (as the transformation to G does not add edges between vertices in IG(cid:48)) we now have that IG is an independent set in G of the required size. • If NG(t) ∩ X ∩ IG(cid:48) (cid:54)= ∅ then we must have NG(w) ∩ X ∩ IG(cid:48) = ∅, otherwise taking one vertex from NG(t) ∩ X ∩ IG(cid:48) and one from NG(w) ∩ X ∩ IG(cid:48) would give a pair which shows that {t, w} is X-blockable in the original graph G, which contradicts the preconditions for Rule 5. Similarly we must have NG(u) ∩ X ∩ IG(cid:48) = ∅ by the assumption that {u, t} is not X-blockable in G. Since vertex p is adjacent in G(cid:48) to all vertices of NG(t) ∩ X, we know that by independence of IG(cid:48) if NG(t) ∩ X ∩ IG(cid:48) (cid:54)= ∅ then p (cid:54)∈ IG(cid:48). We now set IG := IG(cid:48) ∪ {u, w} which must form an independent set in G because the established conditions show that none of the vertices of NG({u, w}) can be in IG(cid:48). It is easy to see that IG ≥ k in this case. • If NG(w)∩ X ∩ IG(cid:48) (cid:54)= ∅ then we must have NG(t)∩ X ∩ IG(cid:48) = NG(v)∩ X ∩ IG(cid:48) = ∅ by the non-blockability of {w, t} and {w, v}. We assign IG := IG(cid:48) ∪ {t, v}. The correctness proof is symmetric to that of the previous case. Since the case distinction is exhaustive this establishes the claim in this direction, which concludes the proof. 3.2 Structure of reduced instances When no reduction rules can be applied to an instance, we call it reduced. The main purpose of this section is to prove that in reduced clean instances, the number of vertices in the forest F is at most cubic in the size of the feedback vertex set. We sketch the main idea behind this analysis. The analysis is based on the idea of identifying conflict structures in the forest G−X. Informally, one may think of a conflict structure S as a subgraph of the forest F which bears witness to the fact that there is a chunk Y ∈ X such that an independent set in G which contains Y , contains less vertices from S than an optimal independent set in F . Hence this conflict structure shows that by choosing Y to be a part of an independent set, we pay for it inside the conflict structure S. Since we trigger a reduction rule once there is a chunk Y ∈ X which induces at least X conflicts (i.e., for which we have to 16 pay at least X), there cannot be too many conflict structures in a reduced instance. The following notion is important to make these statements precise. Definition 5. Define the number of active conflicts induced on the forest F by the chunks X as ActiveF (X ) :=(cid:80) Y ∈X ConfF (Y ). So the number of active conflicts is simply the number of conflicts induced on F summed over all chunks of the instance. For reduced instances, this value is cubic in X. Observation 4. Let (G, X, k) be a reduced instance. By Rule 1 every v ∈ X satisfies ConfF ({v}) < X, and by Rule 2 every pair of distinct non-adjacent vertices {u, v} ⊆ X satisfies ConfF ({u, v}) < X. Hence ActiveF (X ) ≤ X2 +(cid:0)X (cid:1)X. 2 The global argument to bound the kernel size is therefore to show that in a reduced instance with forest F , the number of conflict structures that can be found is linear in the size of the forest. Since the total number of conflicts that are induced by chunks X (the number of active conflicts) is bounded by O(X3), this will prove that the number of vertices in F is O(X3). The proof of the kernel size bound is organized as follows. In the remainder of this section we will formally define conflict structures, and prove that the number of active conflicts induced on the forest F grows linearly with the number of conflict structures contained in F . We give an extremal graph-theoretic result showing that any forest with a perfect matching contains linearly many conflict structures, in Section 3.3. As the final step we will combine these results with Observation 4 to give the kernel size bound in Section 3.4. Definition 6 (Conflict Structures). Let F be a forest with a perfect matching M . • A conflict structure of type A in F is a pair of distinct vertices {v1, v2} such that {v1, v2} ∈ M and degF (v1), degF (v2) ≤ 2. • A conflict structure of type B in F is a path on four vertices (v1, v2, v3, v4) such that v1 and v4 are leaves of F , and degF (v2) = degF (v3) = 3. Observe that in a conflict structure of type B, the edges {v1, v2} and {v3, v4} must be contained in the perfect matching M by Observation 1. Although conflict structures can be defined for arbitrary forests with a perfect matching, we are of course interested in the forests that occur in a reduced clean instance of fvs-Independent Set. To capture the interaction between chunks of such an instance and conflict structures in the forest, we need the following definition. Definition 7 (Hitting conflict structures). Let (G, X, k) be a clean instance of fvs- Independent Set, and consider the forest F := G − X with a perfect matching M . Let Y ∈ X be a chunk. • Y ∈ X hits a conflict structure {v1, v2} of type A in F if {v1, v2} ⊆ NG(Y ). 17 • Y ∈ X hits a conflict structure (v1, v2, v3, v4) of type B in F if one of the following holds: -- {v1, v2} ⊆ NG(Y ), or -- {v3, v4} ⊆ NG(Y ), or -- {v1, v4} ⊆ NG(Y ). The importance of reduction rules 4 and 5 now becomes clear. Observation 5. If (G, X, k) is a reduced clean instance of fvs-Independent Set and S is a conflict structure in a tree T of the forest F := G − X, then S is hit by some chunk of X : if a structure of type A is not hit this triggers Rule 4, and if a structure of type B is not hit this triggers Rule 5. The fact that each conflict structure is hit by at least one chunk in a reduced instance, allows us to relate the number of vertex-disjoint conflict structures to the number of active conflicts that must be induced by the chunks. Lemma 7. Let (G, X, k) be a reduced clean instance of fvs-Independent Set with forest F := G − X such that M is a perfect matching in F , and let S be a set of vertex-disjoint conflict structures in F . Then ActiveF (X ) ≥ S. Proof. Assume the conditions in the statement of the lemma hold. Consider some chunk Y ∈ X , and let SY be the structures in S which are hit by Y according to Definition 7. We will first show that ConfF (Y ) ≥ SY , and later we will show how this implies the lemma. So consider an arbitrary chunk Y ∈ X and the corresponding SY . To prove that ConfF (Y ) ≥ SY we prove that there is an induced subgraph F (cid:48) ⊆ F with F − NG(Y ) ⊆ F (cid:48) ⊆ F such that α(F ) − α(F (cid:48)) ≥ SY . Since α(F ) − NG(Y ) ≤ α(F (cid:48)) by Observation 2, this will show that ConfF (Y ) ≥ SY . To reason about the difference between the independence number of F and of the graph F (cid:48) that we construct, we will ensure that F (cid:48) has a perfect matching M(cid:48) and compare the size of M(cid:48) to M , since we know by Observation 1 that α(F (cid:48)) = M(cid:48) and α(F ) = M when M(cid:48), M are perfect matchings for forests F (cid:48), F respectively. Let us first show how to obtain F (cid:48) and M(cid:48) for a single arbitrary conflict structure S ∈ SY : 1. If S = {v1, v2} is a conflict structure of type A, then {v1, v2} ⊆ NG(Y ) by Defini- tion 7 since Y hits S, and edge {v1, v2} is contained in M by Definition 6. Now obtain F (cid:48) from F by deleting the vertices v1 and v2, and obtain M(cid:48) from M by deleting the edge {v1, v2}. 2. If S = (v1, v2, v3, v4) is a conflict structure of type B, then the edges {v1, v2} and {v3, v4} are contained in M by Observation 1. By Definition 7, using the fact that Y hits S, one of the following applies: • If {v1, v2} ∈ NG(Y ) then delete vertices v1, v2 from F and delete the edge between them from M . 18 • If {v3, v4} ∈ NG(Y ) then delete vertices v3, v4 from F and delete the edge between them from M . • If {v1, v4} ∈ NG(Y ) then delete vertices v1, v4 from F , delete the edges {v1, v2} and {v3, v4} from M and replace them by the edge {v2, v3}. Let F (cid:48) be the resulting graph, and M(cid:48) the resulting matching. Observe that in all cases the graph F (cid:48) is a vertex-induced subgraph of F , and has M(cid:48) as a perfect matching. Since the perfect matching M(cid:48) contains one fewer edge than M , we have α(F (cid:48)) = α(F ) − 1 by Observation 1. Now it is not difficult to see that rather than doing the above step for just a single conflict structure in SY , we can repeat this step for every conflict structure in the set. Since the conflict structures are vertex-disjoint, the changes we make for one operation do not affect the applicability of above-described operation for other conflict structures. Performing the update step for each conflict structure in SY results in a vertex-induced subgraph F (cid:48) ⊆ F with perfect matching M(cid:48) such that M − M(cid:48) = SY , which shows that ConfF (Y ) ≥ SY as argued before. We have shown that for every chunk Y ∈ X it holds that ConfF (Y ) ≥ SY , where SY is the set of conflict structures hit by Y . The lemma now follows from the definition of active conflicts as the sum of the conflict values over all chunks, using that all conflict structures in S are hit by at least one chunk (Observation 5). This concludes the proof. The previous lemma shows that if F has many conflict structures, then the number of active conflicts must be large, and therefore the size of the feedback vertex set must be large. The extremal argument of the next section makes it possible to turn this relation into a kernel size bound. 3.3 Packing conflict structures In this section we present an extremal result which shows that trees with a perfect matching contain linearly many conflict structures. Theorem 1. Let T be a tree with a perfect matching. There is a set S of mutually vertex-disjoint conflict structures in T with S ≥ V (T )/14. Proof. If T is the tree on two vertices then the statement follows trivially, since T contains exactly one conflict structure of type A (see Definition 6). In the remainder we therefore assume that T (cid:54)= K2 which implies that T has at least four vertices: the number of vertices must be even, since T has a perfect matching. We use a proof by construction which finds a set of conflict structures. The procedure grows a subtree T (cid:48) ⊆ T and set S incrementally, and during each augmentation step of the tree we enforce an incremental inequality which shows that the number of vertices of T which are contained in T (cid:48), is proportional to the number of conflict structures found so far in the subtree T (cid:48). This proof strategy is inspired by the method of "amortized analysis by keeping track of dead leaves" which is used in extremal graph theory [27]. 19 So the proof revolves around a subtree T (cid:48) ⊆ T that is grown by successively adding vertices to it. We use the following characteristics of the subgraph T (cid:48) in the analysis. The vertices Leaves(T (cid:48)) \ Leaves(T ) are the open branches of T (cid:48). The open branches are essentially the vertices on the boundary of the subgraph T (cid:48), where we will eventually "grow" the subtree T (cid:48) to make it larger, until it encompasses all of T . Observe that when we have grown the tree T (cid:48) until it equals T , then the number of open branches is 0 by definition. We use the letter O to denote the number of open branches of the current state of the subtree T (cid:48). While growing the subtree we construct a set S of vertex-disjoint conflict structures. We use C as an abbreviation for S. It turns out that certain vertices of the tree T play a special role in the amortized analysis that is implicit in the proof. We call these vertices spikes. Definition 8. A spike in tree T is a vertex v such that degT (v) = 3 and there is exactly one leaf of T adjacent to v. A vertex v ∈ V (T ) is a live spike with respect to the current subtree T (cid:48) if v is a spike in T and an open branch of T (cid:48). When an open branch vertex is a spike, this will allow us to find more conflict structures later on in the process, so that we may balance an increase in the number of vertices of the subtree T (cid:48) against an increase in the number of live spikes. Overall, this means that we may justify an increase in the number of vertices which are contained in T (cid:48) by increasing (a) the number of open branches, (b) the number of conflict structures which have been found, or (c) the number of live spikes. The number of live spikes in the subtree T (cid:48) is denoted by S, and the total number of vertices of T (cid:48) is denoted by N . The balancing process is captured by the following incremental inequality which we will satisfy while growing the subtree T (cid:48): 8∆O + 14∆C + ∆S ≥ ∆N. (1) The ∆ values in the incremental inequality refer to the changes in the values of O, C, S and N caused by augmenting the tree T (cid:48): if T (cid:48) has 5 open branches at a given moment, and we perform an augmentation after which it has 4 open branches then ∆O = −1 for that step. We define the augmentations to the tree T (cid:48) by adding vertices to it; it will be understood implicitly that the subtree T (cid:48) we are considering is the subtree of T induced by all the vertices which were added at some point in the process. We will show that the subtree T (cid:48) and the set S can be initialized and grown such that each augmentation satisfies this incremental inequality, until all vertices of T have been added to T (cid:48) and the two graphs coincide. At that stage we will have N = V (T ), O = 0 and S = 0, for if T (cid:48) = T then T (cid:48) contains exactly V (T ) vertices, and the set Leaves(T (cid:48)) \ Leaves(T ) is empty. By summing the incremental inequality over all augmentation steps we then find that the final state of the tree T (cid:48) satisfies 8O + 14C + S ≥ N which implies C ≥ N/14 = V (T )/14 since O = S = 0 for this final state. Since C measures the number of conflict structures in the set S we construct, this shows that the process finds a set of at least V (T )/14 mutually vertex-disjoint conflict structures. Hence to establish the theorem all that remains is to give the initialization 20 (a) Initial tree T . (b) (2, 0, 1, 4). (c) (−1, 1, 0, 1) (d) (0, 1,−1, 4) (e) (1, 0, 0, 2) (f) (−1, 1, 0, 1) (g) (0, 0, 1, 1) (h) (−1, 1,−1, 3) (i) Conflict structures. Figure 3: Illustrations of some augmentation operations. Edges in the perfect matching of T are drawn with thick lines. Vertices in V (T (cid:48)) ∩ V (T ) are visualized as shaded circles with thick borders. Unshaded vertices belong to V (T ) \ V (T (cid:48)). Each state of the subtree T (cid:48) is labeled with the vector (∆O, ∆C, ∆S, ∆N ) of the operation that yielded the state. (a) Tree T to which the theorem is applied. Vertices {c, e, h, o} are spikes of T . (b) Result of applying Operation 1 with v = a. Vertices d and e become open branches of T (cid:48), and since e is a spike, it becomes a live spike. (c) Applied Operation 4 to tree extending path (d, b), finding the conflict structure {d, b} of type A. Vertex d is lost as an open branch. (d) Applied Operation 3 to tree extending path (e, h), finding the conflict structure (f, e, h, i) of type B. Since spike e is no longer an open branch after the operation, the number of live spikes decreases. The number of open branches does not change, as k becomes an open branch to replace e. (e) Applied Operation 5 to the singleton path (k). (f) Applied Operation 4 to the path (j, g), adding a conflict structure {j, g} of type A. (g) Applied Operation 2 to vertex m, causing o to become a live spike. (h) Applied Operation 4 to the path (o, n, l). Vertex o is lost as an open branch and as a live spike vertex, which is compensated by finding the conflict structure {n, l} of type A. (i) The conflict structures found by the process. and augmentation operations for the subtree T (cid:48). Fig. 3 illustrates the construction process. We say that a vertex u ∈ NT (v)\V (T (cid:48)) is a neighbor of u outside T (cid:48), and a vertex u ∈ NT (v)∩ V (T (cid:48)) is a neighbor inside T (cid:48). The operations that augment the subtree T (cid:48) will maintain the following invariants: (i) For all conflict structures S ∈ S it holds that V (S) ⊆ V (T (cid:48)) \ (Leaves(T (cid:48)) \ Leaves(T )), i.e., the vertices we use in conflict structures are contained in T (cid:48) and are not open branches of T (cid:48). (ii) All vertices of T (cid:48) which have a neighbor outside T (cid:48) are leaves of T (cid:48), implying that 21 when V (T (cid:48)) ≥ 2 all vertices of T (cid:48) which have a neighbor outside T (cid:48) are open branches of T (cid:48). The first part of the invariant will ensure that the conflict structures we find are mutually vertex-disjoint. The second part of the invariant is important because it implies that if T (cid:48) has no open branch vertices, then T (cid:48) coincides with T . It is trivial to see that the invariants are initially satisfied for an empty tree T (cid:48) and empty set of conflict structures S. We will now describe the augmentation operations. Whenever we talk about the neighbors of a vertex v in this description, we mean v's neighbors in the graph T unless explicitly stated otherwise. Similarly, when we talk about a vertex being a leaf then we mean a leaf of the tree T , rather than T (cid:48). Initialization. The first operation we describe shows how to initialize the subtree T (cid:48). Recall from the beginning of the proof that we could assume V (T ) ≥ 4. Operation 1. Let v be a leaf of T and let u be its neighbor in the tree. Initialize T (cid:48) as the tree on vertex set NT [u]. Claim 1. Operation 1 satisfies the incremental inequality and maintains the invariants. Proof. For an empty tree we obviously have O = S = C = N = 0. Let us now consider how these values are affected by the tree initialization. Since T is connected and has at least four vertices, u has at least one neighbor other than v. We claim that all vertices NT (u) \ {v} are open branches of T (cid:48) after the initialization. By Observation 1 vertex v is the only leaf adjacent to u, and since T is a tree, the subtree induced by vertex set NT [u] has the vertices NT (u) as leaves. Therefore the vertices NT (u) \ {v} are contained in Leaves(T (cid:48)) \ Leaves(T ) and are open branches of T (cid:48) by definition, so ∆O = NT (u) − 1. The number of vertices added to the tree by the initialization is exactly ∆N = NT [u]. The number of live spikes cannot decrease by this operation (since it started at zero, and cannot become negative); hence ∆S ≥ 0. Since we do not add any conflict structures to S we find ∆C = 0. It is easy to see that this combination of values satisfies the incremental inequality since NT (u) − 1 ≥ 1. Since we do not add conflict structures, invariant (i) is trivially maintained. Invariant (ii) is maintained by adding all neighbors of u to the tree simultaneously. Observe that the initialization ensures that tree T (cid:48) has at least three vertices, which will be used later on. Augmentation. We will now describe the operations which are used to augment the tree once it is initialized. For each augmentation we prove that it satisfies the incremental inequality. After describing the remaining four operations, we prove that whenever the tree T (cid:48) does not yet encompass all of T , then some augmentation is applicable. When describing the augmentation steps of the subtree T (cid:48) we will use T (cid:48) a to refer to the status of the tree before the augmentation, and T (cid:48) b to refer to its status after the augmentation. When the intended meaning is clear from the context we will just write T (cid:48). Operation 2. If V (T (cid:48)) ≥ 3 and there is a vertex v0 ∈ V (T (cid:48)) with degT (v0) = 2 such that NT (v) \ V (T (cid:48)) contains a spike vertex v1, then add v1 to T (cid:48). 22 Claim 2. Operation 2 satisfies the incremental inequality and maintains the invariants. Proof. The number of vertices in T (cid:48) increases by exactly one. Since degT (v0) = 2, the vertex v0 is not a spike. Therefore the number of live spikes increases by one through this operation (∆S = 1) since the spike v1 becomes an open branch by this augmentation: v1 will be a leaf of T (cid:48), yet is not a leaf of T since degT (v1) = 3 by definition of a spike. The number of vertices increases by one (∆N = 1). The number of open branches does not change: vertex v0 is lost as an open branch, but instead v1 becomes an open branch (∆O = 0). Since the number of conflict structures does not change (∆C = 0) it is now trivial to see that these values satisfy the inequality. Since we do not add conflict structures we maintain invariant (i). Invariant (ii) is maintained because prior to the augmentation, vertex v1 is the only neighbor of v0 which is not yet contained in T (cid:48) which follows from the fact that v0 must have a parent in the tree T (cid:48) because V (T (cid:48)) ≥ 3, and the degree of v0 is only two. So the augmentation effectively adds all vertices NT [v0] to T (cid:48). The remaining augmentation operations grow the subtree by extending it over a path. Definition 9. A tree extending path is a path P = (v0, v1, . . . , vq) in T such that V (P )∩ V (T (cid:48)) = {v0} and v0 is an open branch vertex of T (cid:48). Operation 3. If V (T (cid:48)) ≥ 3 and there is a tree extending path P = (v0, v1) such that v0 and v1 are adjacent to leaves l0, l1 of T respectively with l0, l1 (cid:54)∈ V (T (cid:48)) and degT (v0) = degT (v1) = 3, then add the vertices NT [V (P )] to the tree T (cid:48), and add the conflict structure of type B containing (l0, v0, v1, l1) to S. Claim 3. Operation 3 satisfies the incremental inequality and maintains the invariants. The added conflict structure is disjoint from previously found structures. Proof. Before the operation, vertex v0 is already contained in T (cid:48) and has a unique neighbor p inside T (cid:48) since v0 is a leaf of the tree T (cid:48) which has at least two vertices. Observe that p cannot be a leaf of T (cid:48), since v0 is a leaf of T (cid:48) and V (T (cid:48)) ≥ 3. Hence the neighbors of v0 in T are exactly {p, l0, v0}. Similarly, the neighbors of v1 in T are exactly {q, l1, v0} for a vertex q (cid:54)∈ V (T (cid:48)) which is not a leaf of T . Therefore the vertices which are added to T (cid:48) by this operation, and which were not contained in T (cid:48) already, are exactly {l0, l1, v1, q} which shows that ∆N = 4. Now consider the effect of the augmentation on the number of live spike vertices. Vertex v0 is a live spike in T (cid:48) before the augmentation: it is an open branch vertex by definition of a tree extending path, and the degree and leaf requirements of Definition 8 are met. Vertex v0 becomes an internal vertex of T (cid:48) by adding its neighbors to the tree, and therefore it will no longer be a live spike after the augmentation. But no other live spikes can be lost by the augmentation, hence ∆S ≥ −1. Since we add a conflict structure in this operation, ∆C = 1. Let us finally consider the effect of this operation on the number of open branches. Clearly vertex v0 is no longer an open branch after the augmentation, and it was one before the augmentation. Vertices l0 and l1 are leaves of T and therefore do not become open 23 branch vertices. But the vertex q cannot be a leaf of T by Observation 1, and it will be a leaf of T (cid:48) after the augmentation. Hence the loss of v0 as an open branch is compensated by q becoming an open branch, and ∆O = 0. It is trivial to see that this combination of values satisfies the incremental inequality. Invariant (ii) is maintained by adding the closed neighborhood of a path to the tree T (cid:48), ensuring that afterwards no vertex on the path P can have neighbors outside T (cid:48). Adding NT [V (P )] to T (cid:48) ensures that after the augmentation, none of the vertices of (l0, v0, v1, l1) can be open branches of T (cid:48) while all those vertices are contained in T (cid:48), which shows how invariant (i) is maintained. By the same invariant, none of the vertices {l0, v0, v1, l1} are contained in conflict structures in S prior to the augmentation, since the involved vertices are not in T (cid:48) or open branches of T (cid:48). Hence the structure we add does not intersect any other structures in the set. Operation 4. If V (T (cid:48)) ≥ 3 and there is a tree extending path P = (v0, . . . , vq) for q ≤ 2 such that degT (vq−1), degT (vq) ≤ 2, and the edge between vq−1 and vq is contained in the perfect matching in T , then add the vertices NT [V (P )] to the tree T (cid:48), and add the conflict structure {vq−1, vq} to S. Claim 4. Operation 4 satisfies the incremental inequality and maintains the invariants. The added conflict structure is disjoint from previously found structures. Proof. Let p be the unique neighbor of v0 in T (cid:48) a, the subtree before the augmentation. a)∪{v0, . . . , vq}). Let Li for i ∈ {0, . . . , q} be defined as Li := (NT (vi)∩Leaves(T ))\(V (T (cid:48) By Observation 1 it follows that Li ≤ 1 for all i. Define Si for i ∈ {0, . . . , q} as Si := NT (vi) \ (V (T (cid:48) a) ∪ Leaves(T ) ∪ {v0, . . . , vq}). Refer to Fig. 4 for an illustration of these vertex sets, but note that the illustration does not show a path to which Operation 4 is applicable, as the illustration will also be used for the next operation. It follows from these definitions that the vertices added to T (cid:48) by the augmentation, i=0(Li ∪ Si) and that the sets i=0(Li +Si). We have ∆S ≥ −1 since the only vertex which might be a live spike before the augmentation, but no longer after the augmentation, is v0. The number of open branches is affected as i=0 Si turn into i=0 Si− 1. Since we add one conflict which were not already in T (cid:48), are exactly {v1, . . . , vq} ∪(cid:83)q involved in this expression are all vertex-disjoint. Hence ∆N = q +(cid:80)q follows: we lose the vertex v0 as an open branch, but the vertices in(cid:83)q open branches after the augmentation so ∆O ≥ (cid:83)q structure in this operation, we have ∆C = 1. 8∆O + 14∆C + ∆S ≥ 8( Si − 1) + 14 − 1 By bounds given above. i=0 q(cid:88) q(cid:88) ≥ q(cid:88) ≥ 8 i=0 Si + 5 q(cid:88) Si + i=0 i=0 = ∆N. Since(cid:80)q Simplifying. i=0 Li ≤ 3 and q ≤ 2. Li + q 24 (a) Tree T with sub- tree T (cid:48). (b) State tending T (cid:48) path (v0, v1, v2). after over ex- the Figure 4: Illustrations of the vertex sets which are involved in the proofs of Claim 4 and 5. On the left is a tree T with a perfect matching (visualized by thick edges), with a subtree T (cid:48) indicated by shaded vertices. Vertex v0 is an open branch vertex for this state of the subtree. When considering the tree extending path P = (v0, v1, v2) the corresponding vertex sets Si and Li that are defined in Claim 4 are as follows. L0 = {e}, L1 = ∅, L2 = {m}. S0 = {b, d}, S1 = {h}, S2 = {j, l}. The state of T (cid:48) after adding the i=0 Si i=0 Li are not vertices NT [V (P )] to the tree is shown on the right. Observe that all vertices (cid:83)2 have become open branches by the augmentation, and that the vertices(cid:83)2 open branches after augmentation. Invariant (ii) is maintained for the same reason as before, whereas (i) is maintained because we add the vertices involved in the conflict structure, and all their neighbors, to T (cid:48). Using this invariant it follows that the conflict structure we add must be disjoint from structures added to S earlier, since prior to the augmentation the vertices vq−1 and vq were (a) not part of T (cid:48), or (b) open branches of T (cid:48). Operation 5. If V (T (cid:48)) ≥ 3 and there is a tree extending path P = (v0, . . . , vq) for q ≤ 2 such that (a) degT (vq) ≥ 4 or (b) degT (vq) = 3 and vq is not adjacent to a leaf of T , then add the vertices NT [V (P )] to the tree T (cid:48). Claim 5. Operation 5 satisfies the incremental inequality. Proof. Let vertex p, sets Li and Si for i ∈ {0, 1, 2} be defined as in the proof of Claim 4. By exactly the same reasoning as in that claim, the same bounds for ∆N , ∆O and ∆S i=0 Li ≤ 3. Since we do not add conflict structures in this operation we obviously have ∆C = 0. Now observe that the precondition to the i=0 Si−1 hold for this augmentation and(cid:80)q augmentation ensures that Sq ≥ 2. We will use this with the bound ∆O ≥ (cid:83)q that was derived in Claim 4: By bounds given above. Rewriting. Since Sq ≥ 2. 8∆O + 14∆C + ∆S ≥ 8( Si − 1) + 14 · 0 − 1 Si + Si − 9 i=0 q(cid:88) q(cid:88) ≥ q(cid:88) ≥ 7 i=0 Si + 5 i=0 q(cid:88) i=0 25 ≥ q(cid:88) i=0 Si + q(cid:88) i=0 = ∆N. Li + q Since(cid:80)q i=0 Li ≤ 3 and q ≤ 2. The invariants are maintained for the same reason as for the previous operation. This concludes the description of the augmentation operations. For the remainder of the proof, it suffices to show that the given set of augmentation operations can grow any subtree T (cid:48) ⊆ T which is initialized by Operation 1 until it encompasses all of T , while respecting the incremental inequality. Since T (cid:48) contains at least three vertices after its initialization, invariant (ii) shows that if T (cid:48) (cid:54)= T then there is some open branch of T (cid:48), i.e., there is a vertex v ∈ Leaves(T (cid:48)) \ Leaves(T ). The fact that an initialized tree T (cid:48) has at least three vertices also implies that an open branch vertex v has exactly one neighbor u inside T (cid:48), and that this vertex u cannot be a leaf of T : v is a leaf of T (cid:48) by definition, and if u is a leaf of T then it is also a leaf of the subgraph T (cid:48) ⊆ T , so the leaves u and v of T (cid:48) would be adjacent; but then T (cid:48) has only two vertices in total. Using this information about open branch vertices, we now show that for every open branch vertex v there is some applicable augmentation operation near this vertex using a case distinction on the local structure around v. 1. If (a) degT (v0) ≥ 4 or (b) degT (v0) = 3 and v0 is not adjacent to a leaf of T , then Operation 5 is applicable to the tree extending path (v0). 2. If degT (v0) = 3 and v0 is adjacent to a leaf of T , then consider some neighbor v1 ∈ NT (v0) \ V (T (cid:48)) which is not a leaf of T . Since v0 has exactly one neighbor in T (cid:48) and is adjacent to exactly one leaf of T (by Observation 1), such a vertex exists. Now consider the maximal path P = (v0, v1, . . . , vq) obtained by starting with the edge {v0, v1} and following vertices which have degree two in T , until arriving at the first vertex vq which has degT (vq) (cid:54)= 2. If degT (v1) (cid:54)= 2 then this simply results in P = (v0, v1). Observe that by this definition, vertices v1, . . . , vq are not contained in T (cid:48). (a) If (a) degT (v1) ≥ 4 or (b) degT (v1) = 3 and v1 is not adjacent to a leaf of T , we find that Operation 5 is applicable to the tree extending path (v0, v1). (b) If v1 has degree three, then by the previous case it is adjacent to a leaf in T . Operation 3 is applicable to the tree extending path (v0, v1). Observe that the leaf of T adjacent to v0 cannot be contained in T (cid:48), as per the discussion above. (c) Since v1 has degree at least two in T by our choice of v1 as not being a leaf of T , in the remaining situations we have degT (v1) = 2 and therefore there exists some v2 on the path P we defined earlier. Now observe that T having a perfect matching implies that v2 cannot be adjacent to a leaf of T : by definition of this case, v0 is adjacent to a leaf of T . If v2 is also adjacent to a leaf, a perfect matching must match v0 and v2 to their adjacent leaves. But 26 then vertex v1 with neighbors v0 and v2 cannot be matched. Hence v2 is not adjacent to a leaf. i. If v2 has degree at most two in T , then Operation 4 is applicable to the tree extending path (v0, v1, v2). The edge {v1, v2} is contained in the perfect matching of T : vertex v0 can only be matched to its adjacent leaf, and since v1 has degree two the only remaining edge incident on it which can be in a matching is indeed {v1, v2}. ii. If v2 has degree at least three in T , then since we derived earlier that v2 is not adjacent to a leaf we find that Operation 5 is applicable to the tree extending path (v0, v1, v2). 3. If degT (v0) = 2, let v1 be the unique neighbor of v0 not contained in T (cid:48) which exists by definition of an open branch vertex. Consider the maximal path P = (v0, v1, . . . , vq) obtained by starting with the edge {v0, v1} and following degree-2 vertices until arriving at the first vertex vq which has degree unequal to two in T . (a) If (a) degT (v1) ≥ 4 or (b) degT (v1) = 3 and v1 is not adjacent to a leaf, then Operation 5 is applicable to the tree extending path (v0, v1). (b) If degT (v1) = 3 and v1 is adjacent to a leaf, then v1 is a spike vertex which shows that Operation 2 is applicable. (c) If degT (v1) = 1 then Operation 4 is applicable to the extending path (v0, v1). (d) In the remainder we therefore have degT (v1) = 2, which implies by the defi- nition of the path P we are considering that there is a vertex v2. i. If degT (v2) ≤ 2 then we claim Operation 4 is applicable. Since the degree of v1 in T is two, either the edge {v0, v1} or {v1, v2} is contained in the perfect matching, which shows that the mentioned operation can be applied to the path (v0, v1) or (v0, v1, v2) depending on which case holds. ii. In the remainder we therefore have degT (v2) ≥ 3. If v2 is adjacent to a leaf, then v2 must be matched to this leaf in the perfect matching which shows that v1 is matched to v0: hence Operation 4 is applicable to (v0, v1). iii. If v2 is not adjacent to a leaf, then since its degree is at least three we find that Operation 5 is applicable to the tree extending path (v0, v1, v2). Observe that this case distinction is exhaustive: no open branch vertex can have degree one in T , by definition. Because the case distinction is exhaustive we have shown that whenever T (cid:48) is not yet equal to T we can augment the tree T (cid:48) while respecting the incremental inequality. By the argument given above this proves that the resulting set of conflict structures S satisfies S ≥ V (T )/14, which concludes the proof of Theorem 1. We remark that by using a more detailed case analysis, one could prove better bounds for the number of conflict structures that can be found in a tree with a perfect matching. 27 An improvement in the bound immediately leads to a better provable upper bound on the kernel size. But since such an improvement does not actually decrease the size of reduced instances (it only affects what we can prove about the sizes of such instances -- it does not affect what any of the reduction rules do), and would not change the cubic dependency of the kernel size on the parameter, we have chosen not to pursue this bound further in the interest of space and readability. 3.4 The kernelization algorithm Using the packing argument from the previous section, we can finally prove an upper bound on the size of reduced instances. forest F := G − X. Then V (G) ≤ X + 14X(X +(cid:0)X (cid:1)). Lemma 8. Let (G, X, k) be a reduced clean instance of fvs-Independent Set with 2 Proof. Consider such a reduced instance. By definition of the instance being clean, the forest F has a perfect matching. By applying Theorem 1 to each tree in the for- est F , we find obtain a set S of vertex-disjoint conflict structures in F with S ≥ V (F )/14. By Lemma 7 this shows that ActiveF (X ) ≥ V (F )/14. On the other hand, Observation 4 gives the bound ActiveF (X ) ≤ X2 +(cid:0)X find that V (F ) ≤ 14(X2 +(cid:0)X that V (G) ≤ X + 14X(X +(cid:0)X (cid:1)X. We therefore (cid:1)X). Since V (G) = X + V (F ) we conclude (cid:1)). 2 2 2 The previous lemma gives a size bound for reduced instances. Before proving the existence of a kernel using this bound, let us consider how much time is needed to compute a reduced instance. Lemma 9. Given a clean instance (G, X, k) of fvs-Independent Set on n vertices we can exhaustively apply reduction rules 1 -- 5 in O(X2 · n) time to output an equivalent reduced instance (G(cid:48), X(cid:48), k(cid:48)). Proof. The crucial idea is to apply the reduction rules in a suitable order, to prevent re-triggering reduction rules which were already applied before. This will ensure that we need only a single pass over the instance to exhaustively reduce it, which improves the running time. Start by computing for each chunk Y ∈ X the value ConfF (Y ). Since we can precompute the value α(F ) once in linear-time, for each choice of Y we can com- pute ConfF (Y ) in O(V (F )) time by marking which vertices of F are adjacent to Y , finding a MIS among the vertices of F which are not marked, and comparing its size to the precomputed value. Now bucket-sort the chunks based on the number of con- flicts they induce; since the number of conflicts is at most V (F ) we can bucket-sort in V (F ) + X time. Then consider the chunks in decreasing value of the number of conflicts they induce and apply Rule 1 and Rule 2 where possible, using the current size of the feedback vertex set when testing for applicability. Observe that an application of Rule 1 might decrease the size of the feedback vertex set X, which could cause a rule 28 to become applicable for other chunks where it was not applicable before. By treating chunks in order of decreasing conflict value and testing for applicability of a rule when handling a chunk, we ensure that reduction rules do not become applicable to chunks we have already considered -- observe that the number of conflicts induced by a chunk does not change when applying Rule 1 or Rule 2 elsewhere, except when deleting a vertex involved in some chunk (which can be handled easily). Hence after doing one such pass over the instance in O(X · V (F )) ⊆ O(X2 · n) time, we end up with an equivalent instance (G1, X1, k1) to which Rule 1 and Rule 2 do not apply. As the next phase we will exhaustively apply Rule 4 and Rule 5. The crucial fact we use here is that an application of one of these two rules does not change the number of conflicts that is induced by any chunk Y ∈ X , which can be proven by arguments similar to those used to argue the correctness of the two reduction rules. Hence by applying Rule 4 and Rule 5 we do not change the fact that the instance is reduced with respect to Rule 1 and Rule 2. It is not hard to see that a forest F can contain at most O(V (F )) structures which satisfy the degree constraints of Rule 4 and Rule 5, which follows from the fact that F is acyclic and the relevant substructures are subgraphs of constant degree. We may identify all these structures in O(V (F )) time by using a suitable depth-first search; we omit the straight-forward details of such a procedure. For each substructure to which Rule 4 might be applied (an edge whose endpoints have degree at most two), or to which Rule 5 might be applied (four vertices on a path with degrees one, three, three, and one), we can test whether a rule is applicable in O(X2) time: the effort here lies in testing whether a pair of vertices u, v from F is X-blockable. Using an adjacency-matrix for X we can test for each vertex in NG(u) ∩ X whether it is adjacent to all vertices in NG(v) ∩ X; the pair is X-blockable if and only if this is false. Once we determine that a rule is applicable, we modify the graph as needed. This involves modifying constant-degree constant-size substructures in F , which have arbitrary adjacencies to X. Using an appropriate data-structure such as an adjacency- list, we may perform these local modifications in O(X) time. By applying Rule 4 we might trigger Rule 5, or vice versa. Luckily, we can only trigger a rule which was not applicable before in the immediate neighborhood of the previous structure which was reduced, and we can test whether this happens in constant time. Since each reduction rule decreases the number of vertices in F , we apply the rules at most V (F ) times. Each application can be performed in O(X2) time. By using a suitable depth-first search we can identify all structures which satisfy the degree constraints of the two rules in O(V (F )) time. In total we therefore find that from (G1, X1, k1) we may compute an equivalent instance (G2, X2, k2) which is reduced with respect to rules 1, 2, 4 and 5 in O(X2 · V (F )) time. As the final step, the algorithm needs to apply Rule 3. It is trivial to verify that this rule does not trigger any other reduction rules. We may apply this rule by computing for each chunk Y ∈ X , for each remaining tree T in the forest, the number of conflicts induced on T by Y in a manner similar as described before. Afterwards we delete trees for which no chunks induce a conflict. This phase is easily implemented to run in O(X · V (F )) time. We output the resulting instance (G3, X3, k3) of the problem, 29 which was found in O(X2 · n) time overall. Theorem 2. fvs-Independent Set has a kernel with a cubic number of vertices: √ there is an algorithm that transforms an instance (G, X, k) on n vertices and m edges into an equivalent instance (G(cid:48), X(cid:48), k(cid:48)) in O( nm + n5/3) time such that X(cid:48) ≤ 2X and V (G(cid:48)) ≤ 2X + 28X2 + 56X3. √ (cid:0)X2 2 (cid:1)). As the reduction rules do not increase the size of the feedback vertex set, we Proof. Given an input instance (G, X, k) of fvs-Independent Set, we first apply Lemma 1 to obtain an equivalent clean instance (G1, X1, k1) with X1 ≤ 2X in O( nm) time. To optimize the running time of the kernelization algorithm, we do not further process the instance if n ≤ X3, but simply output (G1, X1, k1) as the result of the procedure; this is suitably small since V (G1) ≤ V (G) ≤ X3 in this case. In the remainder we may therefore assume that n > X3, which implies X1 ≤ 2 · n1/3 as X1 ≤ 2X. We invoke Lemma 9 to obtain an equivalent reduced in- stance (G2, X2, k2) in O(X12 · V (G1)) ⊆ O(n2/3 · n) time. Since the reduction rules do not change the fact that the instance is clean, the reduced instance is also clean. By Lemma 8 the size of the resulting graph G2 is bounded by V (G2) ≤ X2+14X2(X2+ have X2 ≤ X1 ≤ 2X. We therefore obtain V (G2) ≤ 2X + 28X2 + 56X3 by plugging in the bound on X2 and evaluating the binomial expression. We output the instance (G2, X2, k2) as the result of the kernelization, or a trivial yes-instance if k2 ≤ 0. By the correctness of the reduction rules, this instance is equivalent to the input instance. The set X2 is a feedback vertex set for G2, since X1 is a FVS for G1 and the reduction rules preserve this. Observe that the original set X (or what is left of it in the final graph G2) might not constitute a FVS for G2, as edges may have been added between vertices which were added to the feedback vertex set in order to clean the instance. The running time of the procedure is O( nm + n5/3). √ Using the previous theorem we easily obtain a corollary about kernelization for Ver- tex Cover from its relationship to Independent Set. Corollary 1. fvs-Vertex Cover has a kernel with min(2k, 2X + 28X2 + 56X3) √ vertices which can be computed in O( nm + n5/3) time. Proof. Given an instance (G, X, k) of fvs-Vertex Cover we transform it into an in- stance (G, X,V (G) − k) of fvs-Independent Set, which is an equivalent instance because the complement of an independent set is a vertex cover. We apply the kernel- ization algorithm from Theorem 2 to (G, X,V (G) − k) to compute in O( nm + n5/3) time an equivalent instance (G(cid:48), X(cid:48),V (G(cid:48)) − k(cid:48)). By adjusting the target value we transform this back to an instance (G(cid:48), X(cid:48), k(cid:48)) of fvs-Vertex Cover and use it as the output, which shows that V (G(cid:48)) ≤ 2X + 28X2 + 56X3. Since the kernelization for fvs-Independent Set starts by applying the Nemhauser-Trotter decomposition which is known to yield a 2k-vertex kernel [9], the number of vertices in the resulting graph G(cid:48) is also bounded by 2k, where k is the size of the vertex cover that is asked for by the original input instance. √ 30 We remark that the Vertex Cover kernelization with respect to the parameter fvs(G) can be combined with any existing Vertex Cover kernel which reduces the graph by only deleting vertices. Since all existing Vertex Cover kernels (the Buss rule [7], crown reductions [11, 2, 12] and the Nemhauser-Trotter reduction [35, 9]) are of this type, our reduction rules can be combined with all of these. 4 No Polynomial Kernel for VC-Weighted Vertex Cover The goal of this section is to prove that vertex weights make it much harder to ker- nelize an instance of the vertex cover problem. To prove a kernelization lower bound for vc-Weighted Vertex Cover we use the recently introduced notion of cross- composition [5] which builds on earlier work by Bodlaender et al. [4], and Fortnow and Santhanam [25]. Definition 10 (Polynomial equivalence relation [5]). An equivalence relation R on Σ∗ is called a polynomial equivalence relation if the following two conditions hold: 1. There is an algorithm that given two strings x, y ∈ Σ∗ decides whether x and y belong to the same equivalence class in (x + y)O(1) time. 2. For any finite set S ⊆ Σ∗ the equivalence relation R partitions the elements of S into at most (maxx∈S x)O(1) classes. Definition 11 (Cross-composition [5]). Let L ⊆ Σ∗ be a set and let Q ⊆ Σ∗ × N be a parameterized problem. We say that L cross-composes into Q if there is a polynomial equivalence relation R and an algorithm which, given t strings x1, x2, . . . , xt belonging to the same equivalence class of R, computes an instance (x∗, k∗) ∈ Σ∗ × N in time polynomial in(cid:80)t i=1 xi such that: (x∗, k∗) ∈ Q ⇔ xi ∈ L for some 1 ≤ i ≤ t, 1. 2. k∗ is bounded by a polynomial in maxt i=1 xi + log t. Theorem 3 ([5]). If some set L ⊆ Σ∗ is NP-hard under Karp reductions and L cross- composes into the parameterized problem Q then there is no polynomial kernel for Q unless NP ⊆ coNP/poly. The NP-hard set which we will use for the cross-composition is the following restricted version of Independent Set: Independent Set on P2-Split Graphs Instance: A graph G, an independent set Y in G such that each component of G − Y is isomorphic to P2, and an integer k. Question: Does G have an independent set of size at least k? The following proposition will enable us to establish the NP-completeness of Indepen- dent Set on P2-Split Graphs. It is the reverse of the "folding rule" which was used for vertex cover kernelization by Chen et al. [9, Lemma 2.3]. 31 Proposition 2. Let G be a graph and let {u, v} ∈ E(G). Let G(cid:48) be the graph ob- tained from G by removing the edge {u, v}, adding two new vertices p1, p2 and the edges {u, p1},{p1, p2},{p2, v}. Then α(G(cid:48)) = α(G) + 1. Lemma 10. Independent Set on P2-Split Graphs is NP-complete. Proof. Membership in NP is trivial; we prove hardness by a reduction from the unre- stricted Independent Set problem [26, GT20]. Consider an instance (G, k) of In- dependent Set. Now obtain a graph G(cid:48) by replacing each edge {u, v} ∈ E(G) by a path on two new vertices whose endpoints are adjacent to u and v, respectively. If we let Y := V (G) be the set of original vertices in the graph G(cid:48) then using Proposition 2 it is not hard to see that instance (G(cid:48), Y, k + E(G)) is equivalent to (G, k), which concludes the proof. Similarly as for our positive result, it will be easier to reason about the negative result if we phrase it in terms of Independent Set instead of Vertex Cover. We therefore use the following problem as an intermediate step. vc-Weighted Independent Set Instance: A simple undirected graph G, a weight function w : V (G) → N+, a vertex cover X ⊆ V (G), an integer k ≥ 0. Parameter: The cardinality X of the vertex cover. Question: Is there an independent set C of G such that(cid:80) v∈C w(v) ≥ k? We can prove a kernelization lower bound for this problem using cross-composition. Theorem 4. vc-Weighted Independent Set does not admit a polynomial kernel unless NP ⊆ coNP/poly. Proof. By Theorem 3 and Lemma 10 it is sufficient to prove that Independent Set on P2-Split Graphs cross-composes into vc-Weighted Independent Set. We start by defining a suitable polynomial equivalence relationship R. Fix some reasonable encoding of instances of Independent Set on P2-Split Graphs into strings on an alphabet Σ. Now let two strings x, y ∈ Σ∗ be equivalent under R if (a) both strings do not encode a well-formed instance of Independent Set on P2-Split Graphs, or (b) the strings encode instances (G1, Y1, k1) and (G2, Y2, k2) such that V (G1) = V (G2), Y1 = Y2 It is not difficult to see that a set of strings which encodes instances and k1 = k2. on at most n vertices each, is partitioned into O(n3) equivalence classes. A reasonable encoding of input instances allows equivalence to be tested in polynomial time, and hence R is a polynomial equivalence relationship according to Definition 10. We now give an algorithm that receives t instances of Independent Set on P2- Split Graphs which are equivalent under R, and constructs an instance of vc-Weighted Independent Set with small parameter value that acts as the OR of the inputs. If the input instances are not well-formed, then we simply output a constant-sized no- instance. Using the properties of R we may therefore assume in the remainder that the input instances are (G1, Y1, k1), . . . , (Gt, Yt, kt) such that V (G1) = . . . = V (Gt) = n, 32 Y1 = . . . = Yt = r and k1 = . . . = kt = k. We may assume without loss of generality (by duplicating some instances if needed) that t is a power of two. We construct an instance (G(cid:48), w(cid:48), X(cid:48), k(cid:48)) of vc-Weighted Independent Set as follows. In each input graph Gi, the graph Gi−Yi contains n−r vertices and is a disjoint union of P2's by the definition of Independent Set on P2-Split Graphs. Let q := (n−r)/2 be the number of P2's in each graph Gi− Yi. For each i ∈ [t] label the vertices of the P2's in Gi − Yi by a1, b1, a2, b2, . . . , aq, bq such that {aj, bj} is an edge in Gi − Yi for j ∈ [q]; this implies that the only edges of Gi − Yi are those between the a- and b-vertices with the same number. Now construct the weighted graph (G(cid:48), w(cid:48)) as follows. 1. Initialize G(cid:48) as the disjoint union (cid:83)t i=1Yi of the independent sets of the input instances. Set the weight of all these vertices to one. 2. For j ∈ [q] add vertices a(cid:48) j, b(cid:48) j of weight one and the edge {a(cid:48) j, b(cid:48) j} to G(cid:48). Connect these vertices to the other vertices as follows. • For i ∈ [t], for each vertex v ∈ Yi and for each j ∈ [q] make v adjacent to a(cid:48) j (resp. b(cid:48) j) if and only if v is adjacent in Gi to aj (resp. bj). 3. For j ∈ [log t] add vertices s0 j to G(cid:48) of weight t(n + 1) each, and add the j , s1 edge {s0 j}. Connect these to the remainder of the graph as follows. j , s1 • For i ∈ [t] and j ∈ [log t], let b(i, j) ∈ {0, 1} be the value of the j-bit in the adjacent to all vertices of Yi binary expansion of number i. Make vertex sb(i,j) that were added to G(cid:48) in the first step. j j, b(cid:48) j, b(cid:48) := {a(cid:48) We set k(cid:48) j j ∈ [q]} ∪ {s0 := k + t(n + 1) log t. Define X(cid:48) This concludes the construction of the weighted graph (G(cid:48), w(cid:48)). Observe the impor- j j ∈ [q]}] is isomorphic to Gi since tant fact that for each i ∈ [t] the graph G(cid:48)[Yi ∪{a(cid:48) the vertices of Yi form an independent set in both graphs, the remaining vertices form a disjoint union of P2's in both graphs, and the connections between the vertices of Yi and the P2's are identical. j ∈ [log t]}. Since the only vertices of G(cid:48) − X(cid:48) are the vertices corresponding to the sets Yi of the input instances, and since we have not added any edges between these vertices, it follows that G(cid:48) − X(cid:48) is an independent set and therefore X(cid:48) is a vertex cover of size X(cid:48) = 2q + 2 log t ≤ 2n + 2 log t. Since the size of an input instance on n vertices is at least n bits in a reasonable encoding (under which Independent Set on P2-Split Graphs is NP-complete), it follows that X(cid:48) is bounded by a polynomial in the size of the largest input instance plus log t. We can therefore output the instance (G(cid:48), w(cid:48), X(cid:48), k(cid:48)) of vc-Weighted Independent Set, knowing that the parameter value X(cid:48) is suitably bounded. It remains to prove that this output instance is yes if and only if one of the input instances is yes. For the first direction, assume that (G(cid:48), w(cid:48), X(cid:48), k(cid:48)) is yes and let C ⊆ V (G(cid:48)) be an j} ∈ E(G(cid:48)) for j ∈ [log t], the independent set of total weight at least k(cid:48). Since {s0 independent set C contains at most one vertex of each pair s0 j . Since the only vertices j , s1 j j , s1 j , s1 33 j , s1 j, b(cid:48) j , s1 which have weight unequal to one are the s-vertices of weight t(n + 1), and since the number of vertices in G(cid:48) which are not s-vertices is at most t · n, it follows that if C j (j ∈ [log t]) then the weight of C is at does not contain one vertex of each pair s0 most t(n + 1)(log t − 1) + t · n ≤ t(n + 1) log t − t < k(cid:48). Hence by the assumption that C has weight at least k(cid:48) we know that C contains exactly one vertex of each pair s0 j , s1 j . Consider the number i∗ whose j-th bit is 1 if s0 j is in C, and whose j-th bit is 0 otherwise. For all instance numbers i (cid:54)= i∗ the binary representation of i disagrees with the binary representation of i∗ on at least one position j ∈ [log t], which implies by the construction of G(cid:48) that all vertices of Yi in G(cid:48) are adjacent to the vertex of s0 j which is contained in C. Since C is an independent set, this shows that C does not contain any vertices of Yi for all i (cid:54)= i∗. Since the weight of C is at least k + t(n + 1) log t and C contains exactly one vertex of each s-pair, this shows that the vertices of Yi∗ ∪ {a(cid:48) j j ∈ [q]} must contribute at least k to the weight of C. Since each vertex in this latter set has weight one, this shows that C ∩ (Yi∗ ∪ {a(cid:48) j j ∈ [q]}) ≥ k. But by construction of G(cid:48) we know that G(cid:48)[Yi∗ ∪ {a(cid:48) j j ∈ [q]}] is isomorphic to Gi∗ and therefore Gi∗ contains an independent set of size at least k, proving that input instance (Gi∗, Yi∗, ki∗) is yes. For the reverse direction, assume that (Gi∗, Yi∗, ki∗) is a yes-instance; we prove that the constructed instance contains an independent set of weight k(cid:48). Since G(cid:48)[Yi∗ ∪{a(cid:48) j j, b(cid:48) j ∈ [q]}] is isomorphic to Gi∗, this induced subgraph contains an independent set C of cardinality k and hence of weight k. Now consider the binary expansion of the number i∗. For j ∈ [log t] if the j-th bit of i∗ is 1, then vertex s0 j is not adjacent to any of the vertices in C and hence can be added to C without violating independence; if the bit is 0 then s1 j can be added. Since vertices sj for different values of j are not adjacent to each other, j to C in this fashion for j ∈ [log t] to obtain an we can add one vertex of each pair s0 independent set of weight k + t(n + 1) log t which proves that the output instance is yes. This concludes the proof that the constructed instance is equivalent to the OR of the input instances. Since the construction can be carried out in polynomial time this is a valid cross-composition, and by Theorem 3 this concludes the proof. j, b(cid:48) j, b(cid:48) j , s1 Corollary 2. vc-Weighted Vertex Cover does not admit a polynomial kernel unless NP ⊆ coNP/poly. to an instance (G, w, X, ((cid:80) Proof. Since an instance (G, w, X, k) of vc-Weighted Independent Set is equivalent v∈V (G) w(v))−k) of vc-Weighted Vertex Cover with the same parameter, the construction of Theorem 4 also shows that Independent Set on P2-Split Graphs cross-composes into vc-Weighted Vertex Cover which proves the claim. 5 Conclusion We have given a cubic kernel for the Vertex Cover and Independent Set problems using the parameter fvs(G). It would be very interesting to perform experiments with our new reduction rules to see whether they offer significant benefits over the existing 34 most(cid:0)X 2 (cid:1) +V (G)\ X·X +V (G)\ X− 1 edges, a reduced instance can be encoded in Vertex Cover kernel on real-world instances. This result is one of the first exam- ples of a polynomial kernel using a "refined" parameter which is structurally smaller than the standard parameterization. The kernel we have presented for fvs-Vertex Cover contains O(X3) vertices. Since a graph G with feedback vertex set X has at O(X4 log X) bits using an adjacency-list since an adjacency-list encoding of a graph takes O(log V (G) +E(G) log V (G)) bits. The results of Dell and Van Melkebeek [15] imply that it is unlikely that there exists a kernel which can be encoded in O(X2−) bits for any  > 0. It might be possible to improve the size of the kernel to a quadratic or even a linear number of vertices, by employing new reduction rules. The current reduc- tion rules can be seen as analogs of the traditional "high degree" rule for the Vertex Cover problem, and it would be interesting to see whether it is possible to find analogs of crown reduction rules when using fvs(G) as the parameter. Although we have assumed throughout the paper that a feedback vertex set is sup- plied with the input, we can drop this restriction by applying the known polynomial-time 2-approximation algorithm for FVS [3]. Observe that the reduction algorithm does not require that the supplied set X is a minimum feedback vertex set; the kernelization algorithm works if X is any feedback vertex set, and the size of the output instance depends on the size of the FVS that is supplied. Hence if we compute a 2-approximate FVS and use it in the kernelization algorithm, the bound on the number of vertices in the output instance is only a factor 8 worse than when running the kernelization using a minimum FVS. Weighted problems. This paper has focused on the decision version of the Vertex Cover problem, but the data reduction rules given here can also be translated to the optimization version to obtain the following result: given a graph G there is a polynomial-time algorithm that computes a graph G(cid:48) and a non-negative integer c such that vc(G) = vc(G(cid:48)) + c with V (G(cid:48)) ≤ 2 vc(G) and V (G(cid:48)) ∈ O(fvs(G)3); and a vertex cover S(cid:48) for G(cid:48) can be transformed back into a vertex cover of G of size S(cid:48) + c in polynomial time. In Section 4 we proved that the vc-Weighted Vertex Cover problem does not admit a polynomial kernel unless NP ⊆ coNP/poly. Of course this immediately implies a kernel lower bound for the weighted problem parameterized by the size of a feedback vertex set. After the preliminary version of this paper appeared (where we proved the lower bound for fvs-Weighted Vertex Cover), we have found several other weighted problems parameterized by the cardinality of a given vertex cover which are FPT but do not admit polynomial kernels unless NP ⊆ coNP/poly, including Weighted Feedback Vertex Set [5], Weighted Treewidth [6] and Weighted Odd Cycle Transversal [31]. It seems that for problems parameterized by the size of a given vertex cover, the presence of vertex weights forms an obstruction to the existence of polynomial kernels. This trend can be compared to the observation that for vertex- or edge subset problems under the natural parameterization, the presence of connectivity requirements often excludes a polynomial kernelization. For example, well-known connectivity problems without polynomial kernels include k-Path [4], k- Connected Vertex Cover [17] and k-Connected Feedback Vertex Set [14] 35 (assuming NP (cid:54)⊆ coNP/poly). Uncovering further properties of problems which are strongly correlated to the existence of polynomial kernels seems like an interesting area of further research. Other parameterizations. The approach of studying Vertex Cover parame- terized by fvs(G) fits into the broad context of "parameterizing away from triviality" [36, 8], since the parameter fvs(G) measures how many vertex-deletions are needed to reduce G to a forest in which Vertex Cover can be solved in polynomial time. As there is a wide variety of restricted graph classes for which Vertex Cover is in P , this opens up a multitude of possibilities for non-standard parameterizations. As observed by Cai [8], for every graph class G which is closed under vertex deletion and for which the Vertex Cover problem is in P , the Vertex Cover problem is in FPT when parameterized by the size of a set X such that G − X ∈ G, assuming that X is given as part of the input. Such problems can be solved in O∗(2X) time by enumerating all independent subsets X(cid:48) ⊆ X and computing α(G − X − NG(X(cid:48))), which can be done in polynomial time since G− X − NG(X(cid:48)) ∈ G. The independence number of G is the max- imum of X(cid:48) + α(G− X − NG(X(cid:48))) over all independent subsets X(cid:48). In the recent paper on cross-composition [5], a superset of the authors showed that whenever G contains all cliques the resulting parameterized problem does not have a polynomial kernel unless NP ⊆ coNP/poly. This implies that for classes such as claw-free graphs, interval graphs and various other types of perfect graphs, Vertex Cover parameterized by the size of a given deletion set to the class is in FPT, but does not admit a polynomial kernel unless NP ⊆ coNP/poly. Further research may try to find more general graph classes G such that Vertex Cover admits a polynomial kernel parameterized by deletion distance to G. Since relevant candidate classes cannot contain arbitrarily large cliques and must admit polynomial-time algorithms for solving Vertex Cover, bipartite graphs might be an interesting subject for further study. One might also consider the Vertex Cover problem parameterized by the size of a given set X such that Treewidth(G − X) ≤ i. The classic Vertex Cover kernelizations can be interpreted as the case i = 0, whereas this paper supplies the result for i = 1. It was recently proven that the positive results cannot extend further in this direction: Cygan et al. [13] showed that the case i = 2 does not admit a polynomial kernel unless NP ⊆ coNP/poly. Acknowledgments. We are grateful to the anonymous referees, whose suggestions significantly improved the exposition of our results and decreased the running time of the kernelization procedure. References [1] F. N. Abu-Khzam, R. L. Collins, M. R. Fellows, M. A. Langston, W. H. Suters, and C. T. Symons. Kernelization algorithms for the vertex cover problem: Theory and experiments. In Proc. 6th ALENEX/ANALC, pages 62 -- 69, 2004. 36 [2] F. N. Abu-Khzam, M. R. Fellows, M. A. Langston, and W. H. Suters. Crown structures for vertex cover kernelization. Theory Comput. Syst., 41(3):411 -- 430, 2007. doi:10.1007/s00224-007-1328-0. [3] V. Bafna, P. Berman, and T. Fujito. A 2-approximation algorithm for the undirected feedback vertex set problem. SIAM Journal on Discrete Mathematics, 12(3):289 -- 297, 1999. doi:10.1137/S0895480196305124. [4] H. L. Bodlaender, R. G. Downey, M. R. Fellows, and D. Hermelin. On problems without polynomial kernels. J. Comput. Syst. Sci., 75(8):423 -- 434, 2009. doi: 10.1016/j.jcss.2009.04.001. [5] H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch. Cross-composition: A new In Proc. 28th STACS, pages 165 -- 176, technique for kernelization lower bounds. 2011. doi:10.4230/LIPIcs.STACS.2011.165. [6] H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch. Preprocessing for treewidth: A combinatorial analysis through kernelization. In Proc. 38th ICALP, pages 437 -- 448, 2011. doi:10.1007/978-3-642-22006-7_37. [7] J. F. Buss and J. Goldsmith. Nondeterminism within P. SIAM J. Comput., 22(3):560 -- 572, 1993. doi:10.1137/0222038. [8] L. Cai. Parameterized complexity of vertex colouring. Discrete Appl. Math., 127(3):415 -- 429, 2003. doi:10.1016/S0166-218X(02)00242-1. [9] J. Chen, I. A. Kanj, and W. Jia. Vertex cover: Further observations and further improvements. J. Algorithms, 41(2):280 -- 301, 2001. doi:10.1006/jagm.2001.1186. [10] J. Chen, I. A. Kanj, and G. Xia. Improved upper bounds for vertex cover. Theor. Comput. Sci., 411(40-42):3736 -- 3756, 2010. doi:10.1016/j.tcs.2010.06.026. [11] M. Chleb´ık and J. Chleb´ıkov´a. Crown reductions for the minimum weighted vertex cover problem. Discrete Appl. Math., 156(3):292 -- 312, 2008. doi:10.1016/j.dam. 2007.03.026. [12] B. Chor, M. Fellows, and D. W. Juedes. Linear kernels in linear time, or how In Proc. 30th WG, pages 257 -- 269, 2004. doi: to save k colors in O(n2) steps. 10.1007/978-3-540-30559-0_22. [13] M. Cygan, D. Lokshtanov, M. Pilipczuk, M. Pilipczuk, and S. Saurabh. On the hardness of losing width. In Proc. 6th IPEC, pages 159 -- 168, 2011. doi:10.1007/ 978-3-642-28050-4_13. [14] M. Cygan, M. Pilipczuk, M. Pilipczuk, and J. O. Wojtaszczyk. Kernelization hard- In Proc. 36th WG, pages ness of connectivity problems in 2-degenerate graphs. 147 -- 158, 2010. doi:10.1007/978-3-642-16926-7_15. 37 [15] H. Dell and D. van Melkebeek. Satisfiability allows no nontrivial sparsification unless the polynomial-time hierarchy collapses. In Proc. 42nd STOC, pages 251 -- 260, 2010. doi:10.1145/1806689.1806725. [16] J. D´ıaz, J. Petit, and D. M. Thilikos. Kernels for the vertex cover problem on the preferred attachment model. In Proc. 5th WEA, pages 231 -- 240, 2006. doi: 10.1007/11764298_21. [17] M. Dom, D. Lokshtanov, and S. Saurabh. Incompressibility through colors and IDs. In Proc. 36th ICALP, pages 378 -- 389, 2009. doi:10.1007/978-3-642-02927-1_32. [18] R. Downey and M. R. Fellows. Parameterized Complexity. Monographs in Computer Science. Springer, New York, 1999. [19] R. G. Downey, M. R. Fellows, and M. A. Langston, editors. The Computer doi: Journal: Special Issue on Parameterized Complexity, volume 51, 2008. 10.1093/comjnl/bxm111. [20] R. G. Downey, M. R. Fellows, and U. Stege. Parameterized complexity: A frame- work for systematically confronting computational intractability. In DIMACS Series in Discrete Mathematics and Theoretical Computer Science, pages 49 -- 99, 1997. [21] V. Estivill-Castro, M. Fellows, M. Langston, and F. Rosamond. FPT is P-time extremal structure I. In Proc. 1st ACiD, pages 1 -- 41, 2005. [22] M. R. Fellows. Towards fully multivariate algorithmics: Some new results and directions in parameter ecology. In Proc. 20th IWOCA, pages 2 -- 10, 2009. doi: 10.1007/978-3-642-10217-2_2. [23] M. R. Fellows, D. Lokshtanov, N. Misra, M. Mnich, F. A. Rosamond, and S. Saurabh. The complexity ecology of parameters: An illustration using bounded max leaf number. Theory Comput. Syst., 45(4):822 -- 848, 2009. doi:10.1007/ s00224-009-9167-9. [24] M. R. Fellows, D. Lokshtanov, N. Misra, F. A. Rosamond, and S. Saurabh. Graph layout problems parameterized by vertex cover. In Proc. 19th ISAAC, pages 294 -- 305, 2008. doi:10.1007/978-3-540-92182-0_28. [25] L. Fortnow and R. Santhanam. Infeasibility of instance compression and succinct PCPs for NP. J. Comput. Syst. Sci., 77(1):91 -- 106, 2011. doi:10.1016/j.jcss. 2010.06.007. [26] 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. [27] J. R. Griggs, D. Kleitman, and A. Shastri. Spanning trees with many leaves in cubic graphs. J. Graph Theory, 13:669 -- 695, 1989. doi:10.1002/jgt.3190130604. 38 [28] J. Guo and R. Niedermeier. Invitation to data reduction and problem kernelization. SIGACT News, 38(1):31 -- 45, 2007. doi:10.1145/1233481.1233493. [29] G. Gutin, E. J. Kim, M. Lampis, and V. Mitsou. Vertex cover problem parame- terized above and below tight bounds. Theory Comput. Syst., 48(2):402 -- 410, 2011. doi:10.1007/s00224-010-9262-y. [30] B. M. P. Jansen and H. L. Bodlaender. Vertex cover kernelization revisited: Upper and lower bounds for a refined parameter. In Proc. 28th STACS, pages 177 -- 188, 2011. doi:10.4230/LIPIcs.STACS.2011.177. [31] B. M. P. Jansen and S. Kratsch. On polynomial kernels for structural param- In Proc. 6th IPEC, pages 132 -- 144, 2011. eterizations of odd cycle transversal. doi:10.1007/978-3-642-28050-4_11. [32] S. Khot and O. Regev. Vertex cover might be hard to approximate to within 2 − . J. Comput. Syst. Sci., 74(3):335 -- 349, 2008. doi:10.1016/j.jcss.2007.06.019. [33] S. Kratsch and P. Schweitzer. vertex set number. 978-3-642-13731-0_9. In Proc. 12th SWAT, pages 81 -- 92, 2010. Isomorphism for graphs of bounded feedback doi:10.1007/ [34] S. Mishra, V. Raman, S. Saurabh, S. Sikdar, and C. R. Subramanian. The complex- ity of Konig subgraph problems and above-guarantee vertex cover. Algorithmica, 61(4):857 -- 881, 2011. doi:10.1007/s00453-010-9412-2. [35] G. Nemhauser and L. Trotter. Vertex packings: structural properties and algo- rithms. Math. Program., 8:232 -- 248, 1975. doi:10.1007/BF01580444. [36] R. Niedermeier. Invitation to Fixed-Parameter Algorithms. Oxford University Press, 2006. [37] R. Niedermeier. Reflections on multivariate algorithmics and problem parameter- ization. In Proc. 27th STACS, pages 17 -- 32, 2010. doi:10.4230/LIPIcs.STACS. 2010.2495. [38] R. Niedermeier and P. Rossmanith. On efficient fixed-parameter algorithms doi:10.1016/ J. Algorithms, 47(2):63 -- 77, 2003. for weighted vertex cover. S0196-6774(03)00005-1. [39] V. Raman, M. S. Ramanujan, and S. Saurabh. Paths, flowers and vertex cover. In Proc. 19th ESA, pages 382 -- 393, 2011. doi:10.1007/978-3-642-23719-5_33. [40] I. Razgon and B. O'Sullivan. Almost 2-SAT is fixed-parameter tractable. J. Comput. Syst. Sci., 75(8):435 -- 450, 2009. doi:10.1016/j.jcss.2009.04.002. [41] A. Schrijver. Combinatorial Optimization. Polyhedra and Efficiency. Springer, Berlin, 2003. 39 [42] A. Soleimanfallah and A. Yeo. A kernel of order 2k − c for vertex cover. Discrete Math., 311(10-11):892 -- 895, 2011. doi:10.1016/j.disc.2011.02.014. [43] J. Uhlmann and M. Weller. Two-layer planarization parameterized by feedback edge set. In Proc. 7th TAMC, pages 431 -- 442, 2010. doi:10.1007/978-3-642-13562-0_ 39. [44] C.-K. Yap. Some consequences of non-uniform conditions on uniform classes. Theor. Comput. Sci., 26:287 -- 300, 1983. doi:10.1016/0304-3975(83)90020-8. [45] J. Zito. The structure and maximum number of maximum independent sets in trees. J. Graph Theory, 15(2):207 -- 221, 1991. doi:http://dx.doi.org/10.1002/ jgt.3190150208. 40
1904.11601
1
1904
2019-04-25T21:45:29
Tight Approximation Algorithms for Bichromatic Graph Diameter and Related Problems
[ "cs.DS" ]
Some of the most fundamental and well-studied graph parameters are the Diameter (the largest shortest paths distance) and Radius (the smallest distance for which a "center" node can reach all other nodes). The natural and important $ST$-variant considers two subsets $S$ and $T$ of the vertex set and lets the $ST$-diameter be the maximum distance between a node in $S$ and a node in $T$, and the $ST$-radius be the minimum distance for a node of $S$ to reach all nodes of $T$. The bichromatic variant is the special case in which $S$ and $T$ partition the vertex set. In this paper we present a comprehensive study of the approximability of $ST$ and Bichromatic Diameter, Radius, and Eccentricities, and variants, in graphs with and without directions and weights. We give the first nontrivial approximation algorithms for most of these problems, including time/accuracy trade-off upper and lower bounds. We show that nearly all of our obtained bounds are tight under the Strong Exponential Time Hypothesis (SETH), or the related Hitting Set Hypothesis. For instance, for Bichromatic Diameter in undirected weighted graphs with $m$ edges, we present an $\tilde{O}(m^{3/2})$ time $5/3$-approximation algorithm, and show that under SETH, neither the running time, nor the approximation factor can be significantly improved while keeping the other unchanged.
cs.DS
cs
Tight Approximation Algorithms for Bichromatic Graph Diameter and Related Problems Mina Dalirrooyfard ∗ Virginia Vassilevska Williams † Nikhil Vyas ‡ Nicole Wein § MIT MIT MIT MIT Abstract Some of the most fundamental and well-studied graph parameters are the Diameter (the largest short- est paths distance) and Radius (the smallest distance for which a "center" node can reach all other nodes). The natural and important ST -variant considers two subsets S and T of the vertex set and lets the ST - diameter be the maximum distance between a node in S and a node in T , and the ST -radius be the minimum distance for a node of S to reach all nodes of T . The bichromatic variant is the special case in which S and T partition the vertex set. In this paper we present a comprehensive study of the approximability of ST and Bichromatic Di- ameter, Radius, and Eccentricities, and variants, in graphs with and without directions and weights. We give the first nontrivial approximation algorithms for most of these problems, including time/accuracy trade-off upper and lower bounds. We show that nearly all of our obtained bounds are tight under the Strong Exponential Time Hypothesis (SETH), or the related Hitting Set Hypothesis. For instance, for Bichromatic Diameter in undirected weighted graphs with m edges, we present an O(m3/2) time 1 5/3-approximation algorithm, and show that under SETH, neither the running time, nor the approximation factor can be significantly improved while keeping the other unchanged. 1 Introduction A fundamental and very well studied problem in algorithms is the Diameter of a graph, where the output is the largest (shortest path) distance over all pairs of vertices. Over the years many different algorithms have been developed for the problem, both in theory (e.g. [3, 20, 23, 8, 4]) and in practice (e.g. [10, 24, 19]). A very natural variant is the so called ST -Diameter problem [4]: given a graph and two subsets S and T of its vertex set, determine the largest distance between a vertex of S and a vertex of T . In the Subset version of ST -Diameter, we have S = T . Bichromatic Diameter is the version of ST -Diameter for which S and T partition the vertex set. Besides Diameter, the Radius (the smallest distance for which a "center" node can reach all other nodes) and Eccentricities (the largest distance out of every vertex) problems are also very well studied, and analogous ST , Subset, and Bichromatic versions are easy to define. All of these parameters are simple to compute by computing all pairwise distances in the graph, i.e. by solving All-Pairs Shortest Paths (APSP). In sparse n-node graphs, where the number of edges m is O(n), ∗[email protected], Supported by an Akamai Presidential Fellowship and NSF Grant. †[email protected], Supported by an NSF CAREER Award, NSF Grants CCF-1417238, CCF-1528078 and CCF-1514339, a BSF Grant BSF:2012338 and a Sloan Research Fellowship. ‡[email protected], Supported by an Akamai Presidential Fellowship and NSF Grant CCF-1552651. §[email protected], Supported by an NSF Graduate Fellowship and NSF Grant CCF-1514339 1 O notation hides polylogarithmic factors. 1 APSP still needs Ω(n2) time, as this is the size of the output, whereas it is apriori unclear whether this much time is needed for computing the Diameter, Radius and Eccentricities or their ST and bichromatic variants, as the output is small. A related extremely well-studied problem in computational geometry is Bichromatic Diameter on point sets (commonly known as Bichromatic Farthest Pair), where one seeks to determine the farthest pair of points in a given set of points in space (see e.g. [28, 12, 27, 2, 16]). Another related problem is the Subset version of spanners (e.g. [18, 11]), as well as the ST version of spanners (e.g. [9, 17]). Furthermore, the ST , Subset, and Bichromatic versions of many problems have been of great interest; for instance Steiner Tree, Subset TSP, and a number of problems in computational geometry such as Bichromatic Matching (e.g. [15]) and Bichromatic Line Segment Intersection (e.g. [7]). There are several known approximation algorithms for the standard version of Diameter, most of which have been developed in the last 6 years. Trivially, running Dijkstra's algorithm from an arbitrary vertex gives a simple O(m) time 2-approximation algorithm for directed and weighted graphs. Non-trivial algorithms achieve an improved approximation factor with an increased runtime: Building on Aingworth et al. [3], Roditty and Vassilevska W. [23] showed for instance that an "almost" 1.5 approximation for Diameter can be computed in O(m√n) time in m-edge n-vertex directed weighted graphs -- the approximation factor is 1.5 if the Diameter is divisible by 3, and there is a slight additive error otherwise. Chechik et al. [8] gave a true 1.5 approximation at the expense of increasing the runtime to O(mn2/3), and Cairo, Grossi and Rizzi [5] generalized the approach giving an O(mn1/(k+1)) time, "almost" 2 − 1/2k approximation algorithm for all k ≥ 1 which works only in undirected graphs. In STOC'18, Backurs et al. [4] gave the first non-trivial approximation algorithms for ST -Diameter: an O(m3/2) time 2-approximation and an O(m) time 3-approximation. They also showed that these algorithms cannot be improved significantly, unless the Strong Exponential Time Hypothesis (SETH) fails. Backurs et al. did not provide algorithms for ST -Eccentricities or ST -Radius, and they did not study the natural Subset and Bichromatic versions. They also only focused on undirected graphs. We study the following natural and fundamental questions: How well can ST -Eccentricities and ST -Radius be approximated? Are any interesting approximation algorithms possible for directed graphs for any of the ST -variants? Does the approximability of the problems change when one turns to the Subset versions in which S = T , or the Bichromatic versions in which S and T are required to partition the vertex set? 1.1 Our Results We present a comprehensive study of the approximability of the ST , Subset and Bichromatic variants of the Diameter, Radius and Eccentricities problems in graphs, both with and without directions and weights. We obtain the first non-trivial approximation algorithms for most of these problems, including time/accuracy trade-off upper and lower bounds. We show that nearly all of our approximation algorithms are tight under SETH (or under the related Hitting Set Hypothesis for Radius). Additionally, we study a parameterized version of these problems. Our results are summarized in Tables 1-4. All our algorithms in m-edge, n-node graphs, run in O(m3/2) time or in O(m√n) time when a small additive error is allowed. For sparse graphs the m3/2 runtime beats the fastest APSP algorithms [6, 22, 21] as they run in O(mn) time. The m√n time of the algorithms that allow small additive error beat the APSP algorithms for every graph sparsity. 2with high probability means with probability at least 1 − 1/nc for all constants c. 2 Upper Bounds Lower Bounds Problem Runtime Comments Runtime O(m + n log n) unweighted, tight Diameter Radius O(m + n log n) O(m√n) O(m3/2) O(mB) O(m√n) O(m3/2) O(mB) Approx. almost 2 almost 5/3 5/3 unweighted, nearly tight m weighted, tight almost 3/2 unweighted, tight* almost 2 almost 5/3 unweighted unweighted, nearly tight* 5/3 weighted, tight* almost 3/2 unweighted, tight* m1+o(1) k−1 −o(1) k " m2−o(1) m2−o(1) " m2−o(1) m1+o(1) k−1 −o(1) k " m2−o(1) Approx. 2 − δ 2 − 1 2k−1 − δ " 3/2 − δ 5/3 − δ " 3/2 − δ 3 − δ 3 − 2/k − δ " 5/3 − δ Eccentricities O(m + n log n) O(m√n) O(m3/2) O(mB) 3 almost 2 2 weighted, tight unweighted, nearly tight m weighted, tight almost 5/3 unweighted, tight* Table 1: Bichromatic undirected results. All of our parameterized algorithms and near-linear time algo- rithms, except for directed Subset Radius and Eccentricities, are deterministic. The rest are randomized and work with high probability2. Our lower bounds for Diameter and Eccentricities are under SETH and our lower bounds for Radius are under the Hitting Set (HS) Hypothesis, defined later. All of our lower bounds hold even for unweighted graphs. The trade-off lower bounds in terms of k hold for any integer k ≥ 2. δ is any constant > 0. B and B′ are parameters defined in our parameterized algorithms. The lower bound constructions for the parameterized algorithms have B = O(1) * Multiplicative approximation factor is tight, but not runtime. Upper Bounds Lower Bounds Approx. Comments Problem Diameter Radius Eccentricities Runtime O(m3/2) O(mB′) N/A N/A 2 almost 3/2 N/A N/A m2−o(1) weighted, tight* unweighted, tight* m2−o(1) m2−o(1) weighted, tight Runtime Approx. 2 − δ 3/2 − δ any finite weighted, tight m2−o(1) any finite Table 2: Bichromatic directed results. See caption of Table 1. Bichromatic Diameter and Radius. Our first contribution is an algorithm with the same running time as the 2-approximation ST -Diameter algorithm of [4], achieving a better, 5/3 approximation for Bichromatic Diameter. In other words, when S and T partition the vertex set of the graph, ST -Diameter can be ap- proximated much better! Moreover, we show that under SETH, neither the runtime nor the approximation factor of our algorithm can be improved. The result is summarized in Theorem 1.1 below, and proven in Theorems 3.2 and 7.1. Theorem 1.1. There is a randomized O(m3/2) time algorithm, that given an undirected graph G = (V, E) 3 Problem Runtime Approx. Comments Runtime Upper Bounds Lower Bounds weighted, tight unweighted, nearly tight m m1+o(1) k−1 −o(1) k weighted, tight " weighted Approx. 3 − δ 3 − 2/k − δ " Diameter[4] Radius Eccentricities O(m + n log n) O(m√n) O(m3/2) O(m + n log n) O(m√n) O(m3/2) O(m + n log n) O(m√n) O(m3/2) 3 almost 2 2 3 2 3 almost 2 2 almost 2 unweighted, nearly tight* weighted, tight* weighted, tight unweighted, nearly tight m weighted, tight " m2−o(1) " 2 − δ " m1+o(1) k−1 −o(1) k 3 − δ [4] 3 − 2/k − ǫ [4] " Table 3: ST undirected results. See caption of Table 1. Upper Bounds Lower Bounds Problem Diameter Radius Eccentricities 2 Runtime Approx. O(m) O(m) O(m/δ) O(m/δ) 2 + δ 2 + δ 2 Comments weighted, directed, tight weighted, undirected, tight weighted, directed, tight up to an additive δ weighted, directed, tight up to an additive δ m2−o(1) m2−o(1) m2−o(1) Runtime Approx. 2 − δ 2 − δ " 2 − δ " Table 4: Subset results. See caption of Table 1. with nonnegative integer edge weights and S ⊆ V, T = V \ S, can output an estimate D′ such that 3DST /5 ≤ D′ ≤ DST with high probability, where DST is the ST -Diameter of G. Moreover, if there is an O(m3/2−ε) time 5/3-approximation algorithm for some ε > 0, or if there is an O(m2−ε) time (5/3 − ε)-approximation algorithm for the problem, then SETH is false. We also obtain an O(m√n) time algorithm that achieves an "almost" 5/3-approximation: the guarantee for unweighted graphs is 3DST /5 − 6/5 ≤ D′ ≤ DST . We also obtain a near-linear time algorithm for weighted graphs that returns an estimate D′ with DST /2 − W/2 ≤ D′ ≤ DST where W is the minimum weight of a S × T edge. Using our general theorem 7.1, we get that this result is also essentially tight, as a (2 − ε)-approximation for ε > 0 running in near-linear time would refute SETH. To obtain our improvements for Bichromatic Diameter over the known ST -Diameter algorithms, we crucially exploit the basic fact that as S, T partition V any path that starts from a vertex s ∈ S and ends in a vertex t ∈ T must cross a (u, v) edge such that u ∈ S, v ∈ T . While this fact is clear, it not at all obvious how one might try to exploit it. We explain our technique in more detail for the bichromatic diameter problem, and similar ideas are used for our algorithms for the other problems. Let s∗ ∈ S and t∗ ∈ T be end-points of an ST -Diameter path. Similarly to prior Diameter algorithms, our goal is to run Dijkstra's algorithm from some s ∈ S which is close to s∗, and hence far from t∗, or from some t ∈ T which is close to t∗ and hence far from s∗ (by 4 the triangle inequality). Our 5/3-approximation algorithms are a delicate combination of two themes: (1) randomly sample nodes in S and nodes in T -- similarly to prior works, the sampling works well if there are many nodes of S that are close to s∗, or if there are many nodes of T that are close to t∗. If (1) is not good enough, in theme (2) we show that we can find a node w ∈ S close to t∗ for which we can "catch" an S × T edge (s, t) on the shortest w → t∗ path, such that t is close to t∗. Theme (2) is our new contribution. Because of theme (2), our algorithms are more complicated than the ST -Diameter algorithms, but run in asymptotically the same time, and achieve a better approximation guarantee. In order to better separate the ideas in our algorithms, we explain them in several steps, where Theme (1) can be seen in the first steps and Theme (2) appears towards the last steps. Following a similar approach to our Bichromatic Diameter algorithms, we develop similar algorithms for Bichromatic Radius. First, we give a simple near-linear time almost 2-approximation algorithm, and then we adapt the 5/3-approximation for Bichromatic Diameter to also give a 5/3-approximation for Bichromatic Radius. Moreover, we show that any better approximation factor requires essentially quadratic time, under the Hitting Set (HS) Hypothesis of [1] (see also [13]). Theorem 1.2. There is a randomized O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S ⊆ V, T = V \ S, can output an estimate R′ such that RST ≤ R′ ≤ 5RST /3 with high probability, where RST is the ST -Radius of G. Moreover, if there is a 5/3 − ε approximation algorithm running in O(m2−δ) time for any ε, δ > 0, then the HS Hypothesis is false. Similarly to the Bichromatic Diameter algorithm, if one is satisfied with a slight additive error, one can improve the runtime to O(m√n). ST -Eccentricities and ST -Radius. Prior work only considered ST -Diameter but did not consider the more general ST -Eccentricities problem in which one wants to approximate for every s ∈ S, εST (s) := maxt∈T d(s, t). Here we show that one can achieve exactly the same approximation factors for ST -Eccentricities as for ST -Diameter. Since any conditional lower bound for ST -Diameter also applies for the ST -Eccentricities problem, the algorithms we obtain are conditionally optimal, similarly to the ST -Diameter algorithms in [4]. Interestingly, we show that the same conditional lower bounds apply for Bichromatic Eccentricities (Proposition 6), and therefore our ST -Eccentricities algorithms are optimal even for the Bichromatic case. Theorem 1.3. There is a randomized O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S, T ⊆ V , can output for every s ∈ S, an estimate ε′(s) such that εST (s)/2 ≤ ε′(s) ≤ εST (s) with high probability. Moreover, if there is a 2 − ε approximation algorithm running in O(m2−δ) time for any ε, δ > 0 or a 2-approximation algorithm running in O(m3/2−ε) time for ε > 0, even for the Bichromatic case when T = V \ S, then SETH is false. Again, as before, one can improve the runtime to O(m√n) with a slight additive error, and there is a simple near-linear time 3-approximation algorithm which is tight under SETH, similar to the one in [4] for ST -Diameter. A simple argument shows that these algorithms imply algorithms with the same running time and approximation factor for ST -Radius. Bichromatic and ST Problems in Directed Graphs. Using simple reductions we first show that there can be no O(m2−ε) time (for ε > 0) algorithms that achieve any finite approximation for ST -Diameter or ST -Eccentricities (under SETH), or ST -Radius (under HS). Interestingly, the same holds for Bichromatic Eccentricities (under SETH, Proposition 7) and Bichromatic Radius (under HS, Proposition 8), but not 5 Bichromatic Diameter! Surprisingly, unlike those two problems, Bichromatic Diameter does admit a finite, in fact 2-approximation algorithm running in subquadratic time, and this algorithm is conditionally optimal: Theorem 1.4. There is a randomized O(m3/2) time algorithm, that given a directed graph G = (V, E) with nonnegative integer edge weights and S ⊆ V, T = V \ S, can output an estimate D′ such that DST /2 ≤ D′ ≤ DST with high probability, where DST is the ST -Diameter of G. Moreover, if there is an O(m2−ε) time 2− δ-approximation algorithm for the problem for some ε, δ > 0, then SETH is false. The previously known techniques for approximating Diameter in directed graphs fail here. The main issue is that the prior techniques were general enough that they also gave algorithms for Eccentricities and Radius as a byproduct. In the Bichromatic case, however, there is a genuine difference between Diameter and Radius, as we noted above, and new techniques are needed. Here again it turns out that combining theme (2) with a delicate argument is sufficient to get conditionally tight algorithms under SETH. Subset Versions. Recall that Subset Diameter, Radius, and Eccentricities are the versions of the corre- sponding ST problems with the constraint that S = T . Interestingly, Subset Diameter, Radius, and Ec- centricities all exhibit the same sharp threshold behavior. For all three problems, there are near-linear time algorithms that achieve a 2 (or almost 2) approximation, as well as conditional lower bounds that show that there is no 2 − δ approximation in m2−o(1) time. Parameterized Algorithms. We consider the Bichromatic Diameter, Radius, and Eccentricities problems parameterized by the size of the boundary between the S and T sets. If S′ is the set of vertices in S that have a neighbor in T , and T ′ is the set of vertices in T that have a neighbor in S, then the boundary B is whichever of S′ or T ′ is smaller in size. Our lower bound constructions already have small boundary so they rule out algorithms even for graphs with small boundary. However, interestingly we obtain near-linear time algorithms for graphs with small boundary that achieve better multiplicative approximation factors than the optimal non-parameterized algorithms. This is not a contradiction because our parameterized algorithms have a constant additive error, while the apparently contradictory lower bounds do not tolerate additive error. 2 Preliminaries Given a graph G = (V, E) (directed or undirected, weighted or unweighted), let d(u, v) denote the distance from u ∈ V to v ∈ V . For a subset X ⊆ V and v ∈ V , define d(v, X) := minx∈X d(v, x). Similarly d(X, v) := minx∈X d(x, v). Unless otherwise stated, m denotes the number of edges and n the number of vertices of the underlying graph. Without loss of generality, we can assume that all undirected graphs are connected, and all directed graphs are weakly connected, so that m ≥ n − 1. and the Radius R(G) of G is minv∈V ε(v). The Eccentricity ε(v) of a vertex v ∈ V is maxu∈V d(v, u). The Diameter D(G) of G is maxv∈V ε(v), Given S, T ⊆ V , we define analogous parameters as follows. The ST -Eccentricity εST (v) of v ∈ S is The above parameters are called Bichromatic Eccentricities, Diameter, and Radius if S and T form a maxu∈T d(v, u). The ST -Diameter DST (G) is maxv∈S εST (v), and the ST -Radius RST (G) is minv∈S εST (v). partition of V , i.e. T = V \ S. with subscript S instead of ST . The above parameters are called Subset Eccentricities, Diameter, and Radius if S = T and are notated 6 2.1 Preliminaries for algorithms Lemma 2.1. Let G = (V, E) be a (possibly directed and weighted graph) and let W ⊆ V . Let g ≥ Ω(ln n) be an integer. Let S ⊆ W be a random subset of c(W/g) ln n vertices for some constant c > 1. For every v ∈ V , let W (v) be the set of vertices x ∈ W for which d(v, x) < d(v, S). Then with probability at least 1 − 1/nc−1, for every v ∈ V , W (v) ≤ g, and moreover, if one takes the closest g vertices of W to v, they will contain W (v). Proof. For each v ∈ V , imagine sorting the nodes x ∈ W according to d(v, x). Define Qv to be the first g nodes in this sorted order - those are the nodes of W closest to v (in the v → x direction). We pick S randomly by selecting each vertex of W with probability (c ln n)/g. The probability that a particular q ∈ Qv is not in S is 1−(c ln n)/g, and the probability that no q ∈ Qv is in S is (1−(c ln n)/g)g ≤ 1/nc. By a union bound, with probability at least 1 − 1/nc−1, for every v ∈ V , we have that Qv ∩ S 6= ∅. Now, for each particular v, say that w(v) is a node in Qv ∩ S. Since all nodes x ∈ W with d(v, x) < d(v, w(v)) must be in Qv, and since d(v, w(v)) ≥ d(v, S), we must have that W (v) ⊆ Qv. Hence, with probability at least 1 − 1/nc−1, for every v ∈ V , W (v) ≤ g and W (v) ⊆ Qv. Lemma 2.2. Let G = (V, E) be a (possibly directed and weighted) graph. Let M, W ⊆ V and let S ⊆ W be a random subset of c(n/g) ln n vertices for some large enough constant c and some integer g ≥ 1. Then, for any D > 0 and for any w ∈ M with d(w, S) > D, if one takes the closest g vertices of W to w, they will contain all nodes of W at distance < D from w, with high probability. (cid:3) Proof. Let Q be the closest g vertices of W to w. By Lemma 2.1, with high probability Q contains all nodes of W at distance < d(w, S) from w, and hence Q contains all nodes of W at distance < D from w, with high probability. (cid:3) We sometimes sample edges instead of vertices, so analogous lemmas to Lemmas 2.1 and 2.2 hold when the sample is from a set of edges. Here is the analogue of Lemma 2.2. The other lemma is similar. Lemma 2.3. Let G = (V, E) be a (possibly directed and weighted graph) and let M, W ⊆ V . Let E′ ⊆ E be a random subset of c(E/g) ln n edges for some large enough constant c and some integer g ≥ 1. Let Q be the endpoints of edges in E′ that are in W . Then, for any D > 0, and for any w with d(w, S) > D, if one takes the closest g edges of E′ to w wrt the distance from their W endpoints, they will contain all edges of E′ whose W endpoints are at distance < D from w, with high probability. 2.2 Preliminaries for lower bounds The Strong Exponential Time Hypothesis (SETH) asserts that on a Word-RAM with O(log n) bit words, there is no (2 − ε)n time (possibly randomized) algorithm for some constant ε > 0 that can de- termine whether a given CNF-Formula with n variables and O(n) clauses is satisfiable. (This version of SETH is equivalent to the original formulation by Impagliazzo, Paturi and Zane [14].) By a result of Williams [26], the following Orthogonal Vectors (OV) Problem requires n2−o(1)poly (d) time (on a word- RAM with O(log n) bit words), unless SETH fails: given two sets U, V ⊆ {0, 1}d with U = V = n and d = ω(log n), determine whether there are u ∈ U, v ∈ V with u · v = 0. Given an arbitrary instance of OV with d = O(1) (while respecting d = ω(log n), e.g. d = Θ(log2 n)), consider the following graph representation, which we call the OV-graph: the vertex set consists of a node for every u ∈ U , for every v ∈ V and for every coordinate c ∈ [d] = C, and there is an edge (x ∈ U ∪V, c ∈ C) if and only if x[c] = 1. OV is then equivalent to the question of whether there exist u ∈ U, v ∈ V such 7 that d(u, v) > 2. In fact, it is equivalent to distinguishing whether for every u ∈ U, v ∈ V , d(u, v) = 2 (no OV-solution), or there is some u ∈ U, v ∈ V such that d(u, v) ≥ 4 (OV-solution). In other words, if we set S = U, T = V , the ST -Diameter of the OV-graph is 2 if and only if there is no OV-solution and at least 4 otherwise. Because the OV graph has m = O(n), under SETH, any (2 − δ)-approximation algorithm for ST -Diameter requires m2−o(1). A related problem to OV is the Hitting Set (HS) problem [1, 13, 25]: given two sets U, V ⊆ {0, 1}d with U = V = n and d = ω(log n), determine whether there is u ∈ U such that for all v ∈ V , u · v 6= 0. A common hypothesis is that (on the word-RAM) HS requires n2−o(1) time. If we form the OV-graph on the HS instance input, then the HS problem becomes equivalent to de- termining whether there is some u ∈ U such that for all v ∈ V , d(u, v) ≤ 2. In other words, if we set S = U, T = V , the ST -Radius of the OV-graph is 2 if and only if there is a HS-solution and at least 4 otherwise. Thus, under the HS hypothesis, any (2 − δ)-approximation algorithm for ST -Radius requires m2−o(1). Additionally for our constructions we assume that if there is a HS solution u′ then for all c ∈ C, d(u′, c) ≤ 3. This is because for every coordinate index i there must be v ∈ V with v[i] = 1 as otherwise we can just delete the ith bit from all vectors. Let k ≥ 2 be an integer. Then, a generalization of the OV problem is k-OV: given k sets U1, . . . , Uk ⊆ i=1 ui[c] = 0? It is known that, under SETH, when {0, 1}d, are there u1 ∈ U1, . . . , uk ∈ Uk so that Pd d = ω(log n), there is no nk−o(1) time algorithm for k-OV (in the word RAM model) [26]. c=1 Qk Similar to the OV-graph, Backurs et al. [4] define a graph for k-OV which we will refer to as the k- OV-graph. We do not explicitly define the k-OV-graph here; instead we list its properties in the following theorem. Theorem 2.1 ([4]). Let k ≥ 2. Given a k-OV instance consisting of sets W0, W1, . . . , Wk−1 ⊆ {0, 1}d, each of size n, we can in O(knk−1dk−1) time construct an unweighted, undirected graph with O(nk−1 + knk−2dk−1) vertices and O(knk−1dk−1) edges that satisfies the following properties. 1. The graph consists of k + 1 layers of vertices L0, L1, L2, . . . , Lk. The number of nodes in the sets is L0 = Lk = nk−1 and L1,L2, . . . ,Lk−1 ≤ nk−2dk−1. 2. L0 consists of all tuples (a0, a1, . . . , ak−2) where for each i, ai ∈ Wi. Similarly, Lk consists of all tuples (b1, b2, . . . , bk−1) where for each i, bi ∈ Wi. 3. If the k-OV instance has no solution, then d(u, v) = k for all u ∈ L0 and v ∈ Lk. 4. If the k-OV instance has a solution a0, a1, . . . , ak−1 where for each i, ai ∈ Wi then if α = (a0, . . . ak−2) ∈ L0 and β = (a1, . . . , ak−1) ∈ Lk, then d(α, β) ≥ 3k − 2. 5. For all i from 1 to k − 1, for all v ∈ Li there exists a vertex in Li−1 adjacent to v and a vertex in Li+1 adjacent to v. 2.3 Organization In Section 3 we present our algorithms for Bichromatic Diameter, Eccentricities, and Radius. In Sec- tion 4 we present our algorithms for ST -Eccentricities and Radius. In Section 5 we present our algorithms for Subset Diameter, Eccentricities, and Radius. In Section 6 we present our parameterized algorithms for Bichromatic Diameter, Radius, and Eccentricities. In Section 7 we present all of our conditional lower bounds. 8 3 Algorithms for Undirected Bichromatic Diameter, Eccentricities and Ra- dius 3.1 Undirected Bichromatic Diameter We begin with a simple near-linear time algorithm. Proposition 1. There is an O(m + n log n) time algorithm, that given an undirected graph G = (V, E) and S ⊆ V, T = V \ S, can output an estimate D′ such that DST (G)/2 − W/2 ≤ D′ ≤ DST , where W is the minimum weight of an edge in S × T . Proof. Let (s, t) be a minimum weight edge of G with s ∈ S and t ∈ T . Run Dijkstra's algorithm from s and from t. Let D′ = max{maxt′∈T d(s, t′), maxs′∈S d(s′, t)}. Let s∗ ∈ S, t∗ ∈ T be endpoints of an ST -Diameter path, i.e. d(s∗, t∗) = DST . Then, suppose that maxt′∈T d(s, t′) < DST /2 − W/2. In particular, d(s, t∗) < DST /2 − W/2, and hence d(s, s∗) > DST /2 + W/2 by the triangle inequality. Also by the triangle inequality, DST /2 + W/2 < d(s, t) + d(t, s∗) ≤ w(s, t) + max s′∈S d(s′, t). Hence, D′ > DST /2 − W/2, where W is the minimum weight of an edge in S × T . (cid:3) Now we turn to our 5/3-approximation algorithms. Our first theorem is for unweighted graphs. Later on, we modify the algorithm in this theorem to obtain an algorithm for weighted graphs as well, and at the same time remove the small additive error that appears in the theorem below. Theorem 3.1. There is an O(m√n) time algorithm, that given an unweighted undirected graph G = (V, E) and S ⊆ V, T = V \ S, can output an estimate D′ such that 3DST (G)/5 ≤ D′ ≤ DST (G) if DST (G) is divisible by 5, and otherwise 3DST (G)/5 − 6/5 ≤ D′ ≤ DST (G). Proof. Let D = DST (G) and let us assume that D is divisible by 5. If D is not divisible by 5, the estimate we return will have a small additive error. For clarity of presentation, we omit the analysis of the case where D is not divisible by 5. However, we include such analyses in our proofs for Bichromatic Radius (Theorem 3.4) and ST -Eccentricities (Theorem 4.1) and the analysis for Diameter is analogous. D. The algorithm does not know D, but we will use it in the analysis. Suppose the (bichromatic) ST -Diameter endpoints are s∗ ∈ S and t∗ ∈ T and that the ST -Diameter is (Algorithm Step 1): The algorithm first samples Z ⊆ S of size c√n ln n uniformly at random. For every z ∈ Z, run BFS, and let D1 = maxz∈Z,t∈T d(z, t). (Analysis Step 1): If for some s′ ∈ Z we have that d(s∗, s′) ≤ 2D/5, then D1 ≥ d(s′, t∗) ≥ D − d(s∗, s′) ≥ 3D/5. (Algorithm Step 2): Now, sample a set X from T of size C√n ln n uniformly at random for large enough constant C. For every t ∈ X, run BFS and find the closest node s(t) of S to t. Run BFS from every s(t). Let D2 = maxt∈X,t′∈T d(s(t), t′). (Analysis Step 2): If s∗ is at distance ≤ D/5 from some node t of X, then d(s∗, s(t)) ≤ 2D/5 (since s(t) is closer to t than s∗), and so D2 ≥ d(s(t), t∗) ≥ 3D/5. If neither D1, nor D2 are good approximations, it must be that d(s∗, X) > D/5 and d(s∗, Z) > 2D/5. Consider the nodes M of S that are at distance > 2D/5 from Z, then the node w ∈ M that is furthest If neither D1, nor D2 was a good approximation, s∗ ∈ M and since from X among all nodes of M . 9 d(s∗, X) > D/5, we must have that d(w, X) > D/5 (and also d(w, Z) > 2D/5). In the next step we will look for such a w. maxs∈Sw,t∈T d(s, t). t(s). Let D4 := maxs∈Sw,s′∈S d(s′, t(s)). and d(s, Z) > 2Ds/5. Let w = arg max Ds and D′ = max Ds. (Algorithm Step 3): For each s ∈ S define Ds to be the biggest integer which satisfies d(s, X) > Ds/5 (Analysis Step 3): By Lemma 2.2 we have that whp, the number of nodes of T at distance ≤ D′/5 from w and the number of nodes of S at distance ≤ 2D′/5 from w are both ≤ √n. Also if neither D1, nor D2 are good approximations, it must be that d(s∗, X) > D/5 and d(s∗, Z) > 2D/5 and hence D′ ≥ D. (Algorithm Step 4): Run BFS from w. Take all nodes of S at distance ≤ 2D′/5 from w, call these Sw, and run BFS from them. Whp, Sw ≤ √n, so that this BFS run takes O(m√n) time. Let D3 := For every s ∈ Sw, let t(s) be the closest node of T to s (breaking ties arbitrarily). Run BFS from each (Analysis Step 4): If D3 ≥ 3D/5 or D4 ≥ 3D/5, we are done, so let us assume that D3, D4 < 3D/5. Since D3 < 3D/5, and since D3 ≥ d(w, t∗), it must be that d(w, t∗) < 3D/5. Let Pwt∗ be the shortest w to t∗ path. Consider the node b on Pwt∗ for which d(w, b) = 2D/5. If b ∈ S, then since D′ ≥ D, b ∈ Sw and hence we ran BFS from t(b). But since d(b, t∗) = d(w, t∗) − 2D/5 < D/5, and d(b, t(b)) ≤ d(b, t∗) we have that d(t(b), t∗) ≤ 2D/5 and hence D4 ≥ d(s∗, t(b)) ≥ D− d(t(b), t∗) ≥ 3D/5. Thus, if D4 < 3D/5, it must be that b ∈ T . (Algorithm Step 5): Take all nodes of T at distance ≤ D′/5 from w, call these Tw and run BFS from them. Since d(w, X) > D′/5, whp Tw ≤ √n, so this step runs in O(m√n) time. Let D5 = (Analysis Step 5): If D5 ≥ 3D/5, we would be done, so assume that D5 < 3D/5. Let a be the node on the shortest w to t∗ path Pwt∗ with d(w, a) = D/5. Suppose that a ∈ T . Since D′ ≥ D, a ∈ Tw and we ran BFS from it. However, also d(a, t∗) = d(w, t∗) − d(w, a) < 3D/5 − D/5 = 2D/5, and hence D5 ≥ d(a, s∗) ≥ d(t∗, s∗) − d(t∗, a) ≥ D − 2D/5 = 3D/5. Since D5 < 3D/5, it must be that a ∈ S. Now, since a ∈ S and b ∈ T , somewhere on the a to b shortest path Pab, there must be an edge (s′, t′) with s′ ∈ S, t′ ∈ T . Since s′ is before b, d(w, s′) ≤ 2D/5 ≤ 2D′/5, and hence s′ ∈ Sw. Thus we ran BFS from t(s′). Since s′ has an edge to t′ ∈ T , d(s′, t(s′)) ≤ d(s′, t′) = 1. Also, since d(w, s′) ≥ d(w, a) = D/5 and d(w, t∗) ≤ 3D/5 − 1, d(s′, t∗) ≤ 2D/5 − 1. Thus, D4 ≥ d(t(s′), s∗) ≥ d(s∗, t∗) − d(t(s′), t∗) ≥ D − d(t(s′), s′) − d(s′, t∗) ≥ D − 1 − 2D/5 + 1 = 3D/5. maxt∈Tw,s∈S d(t, s). Hence if we set D′′ = max{D1, D2, D3, D4, D5}, we get that 3D/5 ≤ D′′ ≤ D. (cid:3) We now modify the algorithm for unweighted graphs, both making the algorithm work for weighted graphs and removing the additive error, at the expense of increasing the runtime to O(m3/2). Theorem 3.2. There is an O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S ⊆ V, T = V \S, can output an estimate D′ such that 3DST (G)/5 ≤ D′ ≤ DST . Proof. Suppose as before the (bichromatic) ST -Diameter endpoints are s∗ ∈ S and t∗ ∈ T and that the ST -Diameter is D. (Algorithm Modified Step 1): The algorithm here samples E′ ⊆ E of size c√m ln n uniformly at random, for large enough c. Let Z be the endpoints of edges in E′ that are in S. For every z ∈ Z, run Dijkstra's algorithm, and let D1 = maxz∈Z,t∈T d(z, t). (Analysis Step 1): If for some s′ ∈ Z we have that d(s∗, s′) ≤ 2D/5, then D1 ≥ d(s′, t∗) ≥ D − d(s∗, s′) ≥ 3D/5. Let us then assume that d(s∗, Z) > 2D/5. 10 (Algorithm Modified Step 2): Let X be the endpoints of edges in E′ that are in T . For every t ∈ X, run Dijkstra's algorithm and find the closest node s(t) of S to t. Run Dijkstra's algorithm from every s(t). Let D2 = maxt∈X,t′∈T d(s(t), t′). (Analysis Step 2): If s∗ is at distance ≤ D/5 from some node t of X, then d(s∗, s(t)) ≤ 2D/5 (since s(t) is closer to t than s∗), and so D2 ≥ d(s(t), t∗) ≥ 3D/5. Let us then assume that d(s∗, X) > D/5. As before, if we consider the nodes M of S that are at distance > 2D/5 from Z, then the node w ∈ M that is furthest from X among all nodes of M , would have both d(w, Z) > 2D/5 and d(w, X) > D/5, as s∗ is in M and satisfies d(s∗, X) > D/5. We will find a node w with these properties in the next step. (Algorithm Unmodified Step 3): Perform exactly the same Step 3 as before, finding the largest integer that d(w, t∗), D3, D4 < 3D/5. node b′ after it on Pwt∗ has d(w, b′) > 2D/5. well. This search also takes O(m3/2) time. Let D4 := maxs∈Sw∩S,s′∈S d(s′, t(s)). D′ such that there is some node w ∈ S with d(w, Z) > 2D′/5 and d(w, X) > D′/5. (Analysis Step 3): Let w ∈ S be the node we found such that d(w, X) > D′/5, d(w, Z) > 2D′/5. By Lemma 2.3 we have that whp, the number of edges (s, g) where s ∈ S, g ∈ V and d(w, s) ≤ 2D′/5 and the number of edges (t, g′) where t ∈ T, g′ ∈ V and d(w, t) ≤ D′/5 is at most √m. Also, if D1, D2 < 3D/5, then D′ ≥ D, so that we also have that the number of edges (s, b) where s ∈ S and d(w, s) ≤ 2D/5 and the number of edges (t, b′) where t ∈ T and d(w, t) ≤ D/5 is at most √m, whp. (Algorithm Modified Step 4): Run Dijkstra's algorithm from w. Take all edges incident to nodes of S at dist ≤ 2D′/5 from w. Call these edges ES and their endpoints Sw. Run Dijkstra's algorithm from both of their end points. Whp, ES ≤ √m and so Sw ≤ 2√m, so that this Dijkstra run takes O(m3/2) time. Let D3 := maxt∈Sw ∩T,s∈S d(s, t). For every s ∈ Sw ∩ S, determine a closest node t(s) ∈ T to s, and run Dijkstra's algorithm from t(s) as (Analysis Step 4): If d(w, t∗) ≥ 3D/5, or D3 ≥ 3D/5 or D4 ≥ 3D/5, we are done, so let us assume Now consider the node b on the shortest w to t∗ path Pwt∗ for which d(w, b) ≤ 2D/5, but such that the Suppose that b ∈ S. Then since D′ ≥ D, we have d(w, b) ≤ 2D′/5 and hence (b, b′) ∈ ES. Let us consider d(b′, t∗) = d(w, t∗) − d(b′, w). Since d(w, t∗) < 3D/5 and d(b′, w) > 2D/5, d(b′, t∗) < D/5. If b′ ∈ T , then since we ran Dijkstra's algorithm from b′, we got D3 ≥ D − D/5 = 4D/5. If b′ ∈ S, then we ran Dijkstra's algorithm from t(b′) and d(t(b′), t∗) ≤ d(t(b′), b′)+d(b′, t∗) ≤ 2d(b′, t∗) < 2D/5, and hence D4 ≥ d(t(b), s∗) ≥ D − 2D/5 = 3D/5. Thus if neither d(w, t∗), D3, nor D4 are good approximations, then b ∈ T . (Algorithm Modified Step 5): Take all edges incident to nodes of T at dist ≤ D′/5 from w. Call these edges ET and their endpoints that are in T , Tw. Run Dijkstra's algorithm from all nodes in Tw. Since d(w, X) > D′/5, whp Tw ≤ 2√m, so this step runs in O(m3/2) time. Let D5 = maxt∈Tw,s∈S d(t, s). (Analysis Step 5): If D5 ≥ 3D/5, we would be done, so assume that D5 < 3D/5. Let a be the node on Pwt∗ with d(w, a) ≤ D/5 but so that the node a′ after a on Pwt∗ has d(w, a′) > D/5. Suppose that a′ ∈ T . Since D′ ≥ D, (a, a′) ∈ ET , a′ ∈ Tw and we ran Dijkstra's algorithm from a′. However, also d(a′, t∗) = d(w, t∗)−d(w, a′) < 3D/5−D/5 = 2D/5, and hence D5 ≥ d(a, s∗) ≥ d(t∗, s∗)−d(t∗, a′) ≥ D − 2D/5 = 3D/5. Since D5 < 3D/5, it must be that a′ ∈ S. Now, since a′ ∈ S and b ∈ T , somewhere on the a′ to b shortest path Pab, there must be an edge (s′, t′) with s′ ∈ S, t′ ∈ T . However, since s′ is before b, we have that d(w, s′) ≤ d(w, b) ≤ 2D/5 ≤ 2D′/5. Thus, (s′, t′) ∈ ES and we ran Dijkstra's algorithm from t′. However, d(t′, t∗) = d(w, t∗) − d(w, t′) ≤ d(w, t∗) − d(w, a′) < 3D/5 − D/5 = 2D/5, and hence D3 ≥ d(t′, s∗) ≥ d(s∗, t∗) − d(t′, t∗) > 3D/5. Hence if we set D′′ = max{d(w, t∗), D1, D2, D3, D4, D5}, we get that 3D/5 ≤ D′′ ≤ D. (cid:3) 11 3.2 Undirected Bichromatic Radius We begin with a simple near-linear time algorithm that achieves almost a 2-approximation. Theorem 3.3. Let G = (V, E) be an undirected graph with nonnegative edge weights w. Let S ⊆ V, T = V \ S. There is an O(m + n log n) time algorithm that outputs an estimate R′ such that RST ≤ R′ ≤ 2RST + mins∈S,t∈T,(s,t)∈E w(s, t). If G is unweighted, the algorithm runs in O(m + n) time and RST ≤ R′ ≤ 2RST + 1. Proof. The algorithm is as follows. Let (s, t) ∈ E be the smallest weight edge among those with s ∈ S, t ∈ T . Run Dijkstra's algorithm from s and output R′ = maxt′∈T d(s, t′). Clearly RST ≤ R′. Let s∗ ∈ S be the true ST -center. Then for all t′ ∈ T , d(s, t′) ≤ d(s, s∗) + RST . For unweighted graphs, w(s, t) = 1 and we can run BFS instead of Dijkstra's algorithm. We now present a O(m√n) algorithm for Bichromatic Radius, similar in spirit to our Bichromatic On the other hand, d(s, s∗) ≤ w(s, t) + d(t, s∗) ≤ w(s, t) + RST , and hence R′ ≤ w(s, t) + 2RST . (cid:3) ST ≤ 5RST /3 + 1. ST such that RST ≤ R′ Diameter algorithm. Theorem 3.4. There is an O(m√n) time algorithm, that given an undirected unweighted graph G = (V, E) and S ⊆ V, T = V \ S, can output estimates R′ ST ≤ 5RST /3 + 5/3. If RST is divisible by 3, RST ≤ R′ Proof. Let s∗ ∈ S be the ST -center of G and let R = RST be the ST -Radius. s ∈ S1, run BFS and find t(s) ∈ T which is closest to s. Let T2 = {t(s) s ∈ S1}. s(t) ∈ S which is closest to t. Let S2 = {s(t) t ∈ T1}. node maximizing d(w, T1 ∪ T2). (Algorithm Step 1): The algorithm samples S1 ⊆ S of size c√n ln n uniformly at random. For every Then sample T1 ⊆ T of size c√n ln n uniformly at random. For every t ∈ T1, run BFS and find Let s0 ∈ S be the node minimizing maxt∈T1∪T2 d(s0, t). Let R1 = maxt∈T d(s0, t). Let w ∈ T be the (Analysis Step 1): We know that maxt∈T1∪T2 d(s∗, t) ≤ R, and hence maxt∈T1∪T2 d(s0, t) ≤ R. Suppose that for every t ∈ T , d(t, T1 ∪ T2) ≤ 2R/3. Then, d(s0, t) ≤ R + 2R/3 = 5R/3 and hence R1 ≤ 5R/3 and s0 would be a good approximate center. Thus, we can assume that there exists some t with d(t, T1 ∪ T2) > 2R/3, and in particular, d(w, T1 ∪ T2) > 2R/3. Moreover, suppose that there is some s ∈ S1 such that d(w, s) ≤ R/3. Then, d(w, t(s)) ≤ d(w, s) + d(s, t(s)) ≤ 2d(w, s) ≤ 2R/3, contradicting the fact that d(w, T1 ∪ T2) > 2R/3. Thus, we must have that d(w, S1) > R/3. Now, since T1 is random of size c√n ln n, by Lemma 2.2, the number of nodes of T at distance ≤ 2R/3 from w is at most √n, whp. Similarly, since S1 is random of size c√n ln n, by Lemma 2.2, the number of nodes of S at distance ≤ R/3 from w is at most √n, whp. (Algorithm Step 2): Run BFS from w. Take the closest √n nodes Tw of T at distance from w. Run BFS from all t ∈ Tw, and find s(t) ∈ S closest to t. Run BFS from each s(t). (Analysis Step 2): Since Tw ≤ √n, the runtime of this step is O(m√n). Since w ∈ T , we know that d(w, s∗) ≤ R. Now consider the node b on the shortest w to s∗ path Pws∗ for which d(w, b) ≤ 2R/3, but such that the node b′ after it on Pwt∗ has d(w, b′) > 2R/3. Since the graph is unweighted, we get that d(w, b) = ⌊2R/3⌋ ≥ 2R/3 − 2/3. Let us consider d(b, s∗) = d(w, s∗) − d(w, b). Since d(w, s∗) ≤ R and d(w, b) ≥ 2R/3 − 2/3, d(b, s∗) ≤ R/3 + 2/3. Let R2 := mint′∈Tw maxt∈T d(s(t′), t). 12 R/3. We have that d(w, a) = ⌊R/3⌋ ≥ R/3 − 2/3. argument, we ran BFS from a. Suppose that b ∈ T . By our previous argument, as d(w, b) ≤ 2R/3, b must be in Tw. Then we ran BFS from s(b) and d(s(b), s∗) ≤ d(s(b), b) + d(b, s∗) ≤ 2d(b, s∗) ≤ 2R/3 + 4/3, and hence R2 ≤ 2R/3 + R + 4/3 = 5R/3 + 4/3. Thus if R2 is not a good approximation, then b ∈ S. (Algorithm Step 3): Take the √n closest nodes of S to w. Call these Sw. Run BFS from every s ∈ Sw. Set R3 := mins∈Sw maxt∈T d(s, t). (Analysis Step 3): Since Sw ≤ √n, the runtime of this step is O(m√n). Let a be the node on Pws∗ with d(w, a) ≤ R/3 but so that the node a′ after a on Pws∗ has d(w, a′) > Suppose that a ∈ S. As d(w, a) ≤ R/3 and a is among the closest √n nodes to w by our previous However, also d(a, s∗) = d(w, s∗) − d(w, a) ≤ R − R/3 + 2/3 = 2R/3 + 2/3, and hence R3 ≤ 2R/3 + R + 2/3 = 5R/3 + 2/3. If R3 is not a good approximation, it must be that a ∈ T . Now, since a ∈ T and b ∈ S, somewhere on the a to b shortest path Pab, there must be an edge (t′, s′) with s′ ∈ S, t′ ∈ T . However, since t′ is before b, we have that d(w, t′) ≤ d(w, b) ≤ 2R/3. Thus, t′ ∈ Tw and we ran BFS from s(t′). However, d(t′, s(t′)) ≤ d(t′, s′) = 1, and hence d(s(t′), s∗) ≤ d(s(t′), t′) + d(t′, s∗) ≤ 1 + d(w, s∗)− d(w, t′) ≤ 1 + R − d(w, a) = 2R/3 + 5/3. Hence for every t ∈ T , d(s(t′), t) ≤ 5R/3 + 5/3. If R is divisible by 3, the only source of additive error is the +1 from using the edge (t′, s(t′)) instead of (t′, s′). Hence if we set R′ = min{R1, R2, R3}, we have R ≤ R′ ≤ 5R/3 + 5/3. If R is divisible by 3, (cid:3) R ≤ R′ ≤ 5R/3 + 1. We now use edge sampling to remove the additive error and make the algorithm work for weighted graphs as well, at the expense of increasing the runtime to O(m3/2). Theorem 3.5. There is an O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S ⊆ V, T = V \ S, can output estimates R′ ST such that RST ≤ R′ ST ≤ 5RST /3. Proof. Let s∗ ∈ S be the ST -center of G and let R = RST be the ST -Radius. (Algorithm Step 1): We sample c√m ln n edges E′ ⊆ E uniformly at random. Let S1 be the endpoints that are in S and let T1 be the endpoints in T . For every s ∈ S1, run Dijkstra and find t(s) ∈ T which is closest to s. Let T2 = {t(s) s ∈ S1}. Let w ∈ T be the node maximizing d(w, T1 ∪ T2). For every t ∈ T1, run Dijkstra and find s(t) ∈ S which is closest to t. Let S2 = {s(t) t ∈ T1}. Let s0 ∈ S be the node minimizing maxt∈T1∪T2 d(s0, t). Run Dijkstra from s0. Let R1 = maxt∈T d(s0, t). (Analysis Step 1): The algorithm runs in O(m3/2) time. We know that maxt∈T1∪T2 d(s∗, t) ≤ R, and hence maxt∈T1∪T2 d(s0, t) ≤ R. Suppose that for every t ∈ T , d(t, T1 ∪ T2) ≤ 2R/3. Then, d(s0, t) ≤ R + 2R/3 = 5R/3 and hence R1 ≤ 5R/3 and s0 would be a good approximate center. Thus, we can assume that there exists some t with d(t, T1 ∪ T2) > 2R/3, and in particular, d(w, T1 ∪ T2) > 2R/3. Moreover, suppose that there is some s ∈ S1 such that d(w, s) ≤ R/3. Then, d(w, t(s)) ≤ d(w, s) + d(s, t(s)) ≤ 2d(w, s) ≤ 2R/3, contradicting the fact that d(w, T1 ∪ T2) > 2R/3. Thus, we must have that d(w, S1) > R/3. Now, since E′ is random of size c√m ln n, by Lemma 2.3, the number of edges (t, g) where t ∈ T, g ∈ V and d(w, t) ≤ 2R/3 is at most √m, whp. Similarly, the number of edges (s, g) where s ∈ S, g ∈ V and d(s, w) ≤ R/3 is at most √m, whp. 13 (Algorithm Step 2): Run Dijkstra from w. Consider the edges (t, b) with t ∈ T sorted in nondecreasing order according to d(w, t). Let ET be the first √m edges in this sorted order. Run Dijkstra from both endpoints of each edge in ET . Call Tw those endpoints that are in T and S1 w those in S. Let R2 := mins∈S 1 w maxt∈T d(s, t). Let R3 := mint∈Tw maxt′∈T d(s(t), t′). For every t ∈ Tw, determine a closest node s(t) ∈ T to t, and run Dijkstra's algorithm from s(t) as well. (Analysis Step 2): Since ET ≤ √m, the runtime of this step is O(m3/2). If R2 ≤ 5R/3 or R3 ≤ 5R/3, we are done. So let us assume that R2, R3 > 5R/3. Also, since w ∈ T , we know that d(w, s∗) ≤ R. Now consider the node b on the shortest w to s∗ path Pws∗ for which d(w, b) ≤ 2R/3, but such that the node b′ after it on Pws∗ has d(w, b′) > 2R/3. Suppose that b ∈ T . Then since d(w, b) ≤ 2R/3 and since by the previous argument the edges from T nodes at distance 2R/3 from w is at most √m, (b, b′) must be among the edges in ET . We thus run Dijkstra's from both b and b′. Let us consider d(b′, s∗) = d(w, s∗) − d(w, b′). Since d(w, s∗) ≤ R and d(w, b′) > 2R/3, d(b′, s∗) < R/3. If b′ ∈ S, then since we ran Dijkstra's algorithm from b′, we got R2 ≤ 4R/3. If b′ ∈ T , then we ran Dijkstra's algorithm from s(b′) and d(s(b′), s∗) ≤ d(s(b′), b′) + d(b′, s∗) ≤ 2d(b′, s∗) < 2R/3, and hence R3 ≤ 2R/3 + R = 5R/3. Thus if neither R2, nor R3 are good approximations, then b ∈ S. (Algorithm Step 3): Consider the edges (s, b) with s ∈ S sorted in nondecreasing order according to d(w, s). Let ES be the first √m edges in this sorted order. Run Dijkstra from both endpoints of each edge in ES . Call S2 w those endpoints that are in S. Let R4 := mins∈S 2 (Analysis Step 3): As ES = √m, Sw ≤ 2√m, so this step runs in O(m3/2) time. If R4 ≤ 5R/3, we would be done, so assume that R4 > 5R/3. Let a be the node on Pws∗ with d(w, a) ≤ R/3 but so that the node a′ after a on Pws∗ has d(w, a′) > R/3. Suppose that a′ ∈ S. Then since d(w, a) ≤ R/3, (a, a′) ∈ ES, a′ ∈ S2 w and we ran Dijkstra's algorithm from a′. However, also d(a′, s∗) = d(w, s∗) − d(w, a′) < R − R/3 = 2R/3, and hence R4 ≤ 2R/3 + R = 5R/3. Since R4 > 5R/3, it must be that a′ ∈ T . Now, since a′ ∈ T and b ∈ S, somewhere on the a′ to b shortest path Pab, there must be an edge (t′, s′) with s′ ∈ S, t′ ∈ T . However, since t′ is before b, we have that d(w, t′) ≤ d(w, b) ≤ 2R/3. Thus, (t′, s′) ∈ ET and we ran Dijkstra's algorithm from s′. However, d(s′, s∗) = d(w, s∗) − d(w, s′) ≤ d(w, s∗) − d(w, a′) < R − R/3 = 2R/3, and hence R2 ≤ R + 2R/3 = 5R/3. w maxt∈T d(s, t). Hence if we set R′ = min{R1, R2, R3, R4}, we have R ≤ R′ ≤ 5R/3 (cid:3) 3.3 Undirected Bichromatic Eccentricities. In the next section we will give approximation algorithms for ST -Eccentricities in undirected graphs which imply algorithms for bichromatic Eccentricities in undirected graphs with same guarantees. We reproduce them here for convenience. Proposition 2. There is an O(m + n log n) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S ⊆ V, T = V \ S, can output an estimate ε′ ST (v) for each node v ∈ S such that εST (v)/3 ≤ ε′ Theorem 3.6. There is an O(m√n) time algorithm, that given an unweighted graph G = (V, E) and S ⊆ V, T = V \S, can output an estimate ε′ ST (v) ≤ εST (v). If εST (v) is divisible by 2, εST (v)/2 − 2 ≤ ε′ ST (v) for each v ∈ S such that εST (v)/2−5/2 ≤ ε′ ST (v) ≤ εST (v). ST (v) ≤ εST (v). 14 ST (v) ≤ εST (v). Theorem 3.7. There is an O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S ⊆ V, T = V \ S, can output estimates ε′ ST (v) for each v ∈ S, such that εST (v)/2 ≤ ε′ 3.4 Directed Bichromatic Diameter Theorem 3.8. There is an O(m3/2) time algorithm, that given a directed graph G = (V, E) with nonneg- ative integer weights and S ⊆ V, T = V \ S, can output an estimate D′ such that DST (G)/2 ≤ D′ ≤ DST (G). Proof. Suppose the (bichromatic) ST -Diameter endpoints are s∗ ∈ S and t∗ ∈ T and that the ST -Diameter is D. The algorithm does not know D, but we will use it in the analysis. (Algorithm Step 1): The algorithm first samples E′ ⊆ E of size c√m ln m for large enough c uniformly at random from the edges which go from S to T . Let R be the set of S nodes incident to these edges. Define D1 = maxu∈R,t∈T d(u, t). (Analysis Step 1): If there exists an s ∈ R with d(s∗, s) ≤ D/2 then we are done as by triangle inequality D1 ≥ d(s, t∗) ≥ d(s∗, t∗) − d(s∗, s) ≥ D/2. (Algorithm Step 2): Let w be the vertex in S which maximizes d(w, R). Defining the distance to an edge (u, v) to be distance to u we find the √m closest edges to w which cross from S to T . Let P be the set of T nodes incident to these edges. Let D2 = maxs∈S,v∈P d(s, v) and D3 = maxt∈T d(w, t). Our estimate is D′ = max(D1, D2, D3). (Analysis Step 2): Note that all 3 estimates are underestimates so we will just bound D′ from below. Suppose D3 ≥ D/2 then we are already done. So we can assume that d(w, t∗) < D/2. Let (s, t) be the first edge going from S to T in the shortest path from w to t∗. If D1 < D/2 then by Lemma 2.3, this edge is among the √m closest edges to w. Hence D2 ≥ d(s∗, t) ≥ d(s∗, t∗) − d(t, t∗) ≥ D − d(t, t∗) ≥ D − d(w, t∗) ≥ D/2 (cid:3) 4 Algorithms for ST -Eccentricities and Radius All of the algorithms in this section are for undirected graphs; we later prove that the directed versions of these problems do not admit truly subquadratic algorithms with any finite approximation factor. We do not give algorithms for ST -Diameter, as tight algorithms were already given in [4]. 4.1 ST -Eccentricities We begin with a near-linear time 3-approximation algorithm. ST (v) ≤ εST (v). Proposition 3. There is an O(m + n log n) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S, T ⊆ V , can output an estimate ε′ ST (v) for each node v ∈ S such that εST (v)/3 ≤ ε′ Proof. The algorithm is as follows. Pick an arbitrary node t ∈ T and run Dijkstra's algorithm from it. Let t′ be a node in T maximizing d(t′, t), and run Dijkstra's algorithm from t′. For each v ∈ S, output ε′ ST (v) = max{d(v, t), d(v, t′)}. ST (v) ≤ εST (v). Now suppose that v′ ∈ T is the farthest node from v in T . So we have εST (v) = d(v, v′) ≤ d(v, t) + d(t, v′) ≤ d(v, t) + d(t, t′) ≤ d(v, t) + d(t, v) + d(v, t′) ≤ 3ε′ ST (v), where the first and third inequalities are from triangle inequality and the second inequality is from the definition of t′. (cid:3) Clearly ε′ 15 ST (v) ≤ εST (v). ST (v) = maxt∈TX d(v, t). ST (v) = d(v, w). ST (v) for each v ∈ S such that εST (v)/2−5/2 ≤ ε′ Now we turn to our 2-approximation algorithms. Our first theorem is for unweighted graphs. Later on, we modify the algorithm in this theorem to obtain an algorithm for weighted graphs as well, and at the same time remove the small additive error that appears in the theorem below. Theorem 4.1. There is an O(m√n) time algorithm, that given an undirected unweighted graph G = (V, E) and S, T ⊆ V , can output an estimate ε′ ST (v) ≤ εST (v). If εST (v) is divisible by 2, εST (v)/2 − 2 ≤ ε′ Proof. For each v ∈ S, let v′ be the farthest node from v, i.e. d(v, v′) = εST (v). x ∈ X, run BFS and find t(x) ∈ T which is closest to x (if x ∈ T , t(x) = x). Let TX = {t(x)x ∈ X}. (Algorithm Step 1): The algorithm samples X ⊂ V of size c√n ln n uniformly at random. For every Run BFS from each node t ∈ TX . For each v ∈ S let ε(1) Let w ∈ T be the node maximizing d(w, TX ). (Analysis Step 1): This step of the algorithm runs in O(m√n). Suppose there is some node t ∈ TX such that d(v′, t) ≤ εST (v)/2. Then d(v, t) ≥ d(v, v′) − d(v′, t) ≥ εST (v)/2, and so ε(1) ST (v) is a good approximation for v. Thus we can assume that d(v′, TX ) > εST (v)/2, and so d(w, TX ) > εST (v)/2. Now since X is random of size c√n ln n, by Lemma 2.2, the number of nodes of T at distance ≤ εST (v)/2 from w is at most √n whp. Moreover, suppose that there is some node x ∈ X such that d(w, x) ≤ εST (v)/4. Then d(w, t(x)) ≤ d(w, x) + d(x, t(x)) ≤ 2d(w, x) ≤ εST (v)/2, contradicting the fact that d(w, TX ) > εST (v)/2. Thus, we must have that d(w, X) > εST (v)/4. Now, since X is random of size c√n ln n, by Lemma 2.2, the number of nodes at distance ≤ εST (v)/4 from w is at most √n whp. (Algorithm Step 2): Run BFS from w. For each v ∈ S, let ε(2) Take the closest √n nodes of V \ T to w. Call these Y . Run BFS from all y ∈ Y , and let e(y) = ST (v) = maxy∈Y e(y) − d(v, y). (Analysis Step 2): If d(v, w) ≥ εST (v)/2, then ε(2) ST (v) is a good estimate. So assume that d(v, w) ≤ ⌈εST /2⌉ − 1 ≤ εST /2 − 1/2. Now consider the node a on the shortest w to v path Pwv for which d(w, a) ≤ εST (v)/4, but such that the node a′ after it on Pwv has d(w, a′) > εST (v)/4. Since the graph is unweighted, we get that d(w, a) = ⌊εST (v)/4⌋ ≥ εST (v)/4 − 3/4. If a ∈ V \ T , then by the previous argument since d(a, w) ≤ εST (v)/4, a ∈ Y and we run BFS from a. Since e(a) ≥ d(a, v′) ≥ d(v, v′) − d(a, v) and d(a, v) = d(w, v) − d(a, w), we have e(a) ≥ 3εST (v)/4 − 1/4. So e(a) − d(v, a) ≥ εST (v)/2 − 1/2. Moreover, if a′ is the farthest node from a in T , then εST (v) ≥ d(v, a′) ≥ d(a, a′) − d(v, a) = e(a) − d(v, a), and hence ε(3) maxt∈T d(y, t). Let ε(3) ST (v) is a good estimate. So assume that a ∈ T . (Algorithm Step 3): Take the closest √n nodes of T to w. Call these Tw. Run BFS from all t ∈ Tw ST (v) = and find y(t) ∈ V \ T . Run BFS from each y(t), and let e(y(t)) = maxt′∈T d(y(t), t′). Let ε(4) maxt∈Tw e(y(t)) − d(v, y(t)). (Analysis Step 3): Consider the node b on Pwv for which d(w, b) ≤ 3εST (v)/8, but such that the node b′ after it on Pwv has d(w, b′) > 3εST (v)/8. Since the graph is unweighted, we get that d(w, b) = ⌊3εST (v)/8⌋ ≥ 3εST (v)/8 − 7/8. If b ∈ T , then since d(w, b) ≤ εST (v)/2, by previous argument b ∈ Tw and we run BFS from b. Since d(v, b) = d(w, v)− d(w, b) ≤ εST (v)/8 + 3/8, we have that d(v, y(b)) ≤ d(v, b) + d(b, y(b)) ≤ 2d(v, b) ≤ εST (v)/4 + 3/4. Similar to the previous step, we get that e(y(b)) − d(v, y(b)) ≥ d(y(b), v′)− d(v, y(b)) ≥ 16 d(v, v′) − 2d(v, y(b)) ≥ εST (v)/2 − 3/2. By considering the farthest node from y(b) in T , we can show that e(y(b)) − d(v, y(b)) ≤ εST (v) and hence ε(4) ST (v) is not a good approximate, it must be that b ∈ V \ T . Now, since a ∈ T and b ∈ V \ T , somewhere on the a to b shortest path Pab, there must be an edge (t′, y′) with t′ ∈ T and y′ ∈ V \ T . However, since t′ is on Pwv, we have d(w, t′) ≤ d(v, w) < εST (v)/2. Thus, t′ ∈ Tw and we run BFS from y(t′). However, d(t′, y(t′)) ≤ d(t′, y′) = 1, and hence d(y(t′), v) ≤ d(y(t′), t′) + d(t′, v) ≤ 1 + d(w, v) − d(w, t′) ≤ 1 + εST (v)/2 − 1/2− d(w, a) ≤ εST (v)/4 + 5/4. So we ST (v) is a good approximate. So if ε(4) get that e(y(t′)) − d(y(t′), v) ≥ d(y(t′), v′) − d(y(t′), v) ≥ d(v, v′) − 2d(y(t′), v) ≥ εST (v)/2 − 5/2 Moreover, if y′ is the farthest node y(t′) in T , then εST (v) ≥ d(v, y′) ≥ d(y′, y(t′)) − d(v, y(t′)) = ST (v)}, ST (v) = max{ε(1) e(y(t′)) − d(v, y(t′)). Hence if for each v ∈ S we set ε′ we have εST (v)/2 − 5/2 ≤ ε′ ST (v) ≤ εST (v). ST (v), ε(3) ST (v), ε(4) ST (v), ε(2) (cid:3) We now use edge sampling to remove the additive error from the above algorithm and make the algorithm work for weighted graphs as well, at the expense of increasing the runtime to O(m3/2). ST (v) ≤ εST (v). Theorem 4.2. There is an O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S, T ⊆ V , can output estimates ε′ ST (v) for each v ∈ S, such that εST (v)/2 ≤ ε′ Proof. For each v ∈ S, let v′ be the farthest node from v, i.e. d(v, v′) = εST (v). (Algorithm Step 1): We sample c√m ln n edges E′ ⊆ E uniformly at random. Run Dijkstra from both endpoints of edges in E′ (we call these vertices V (E′)), and for each endpoint x, find t(x) ∈ T which is closest to x. Let TE′ = {t(x)x ∈ V (E′)}. Run Dijkstra from each node in TE′, and for each v ∈ S, let ε(1) ST (v) = d(v, TE′ ). Let w ∈ T be the node maximizing d(w, TE′ ). (Analysis Step 1): Since V (E′) = O(√m) = TE′, this step takes O(m3/2) time. Suppose there is some node t ∈ TE′ such that d(v′, t) ≤ εST (v)/2. Then d(v, t) ≥ d(v, v′)− d(v′, t) ≥ εST (v)/2, and so ε(1) ST (v) is a good approximation for εST (v). Thus we can assume that d(v′, TE′) > εST (v)/2, and so d(w, TE′ ) > εST (v)/2. Now since E′ is random of size c√m ln n, by Lemma 2.3, the number of edges (t, g) where t ∈ T, g ∈ V and d(w, t) ≤ εST (v)/2 is at most √m, whp. Moreover, suppose that there is some edge (x, b) ∈ E′ such that d(w, x) ≤ εST (v)/4. Then d(w, t(x)) ≤ d(w, x) + d(x, t(x)) ≤ 2d(w, x) ≤ εST (v)/2, contradicting the fact that d(w, TE′) > εST (v)/2. Thus, we must have that d(w, V (E′)) > εST (v)/4. Now, since E′ is random of size c√n ln n, by Lemma 2.3, the number of edges (x, g) ∈ E′ where g ∈ V (Algorithm Step 2): Run Dijkstra from w. For each v ∈ S, let ε(2) Consider the edges (y, b) sorted in nondecreasing order according to d(w, y). Let E′′ be the first √m edges in this sorted order. Let Y be the endpoints of edges in E′′ that are in V \ T . Run Dijkstra from each node in Y and let e(y) = maxt∈T d(y, t). Let ε(3) such that d(w, x) ≤ εST (v)/4 is at most √m, whp. (Analysis Step 2): Since Y = O(√m), this step takes O(m3/2) time. If d(v, w) ≥ εST (v)/2, then ε(2) Now consider the node a on the shortest w to v path Pwv for which d(w, a) ≤ εST (v)/4, but such that ST (v) is a good approximation. So assume that d(v, w) < εST (v)/2. ST (v) = maxy∈Y e(y) − d(v, y). ST (v) = d(v, w). the node a′ after it on Pwv has d(w, a′) > εST (v)/4. 17 We thus run Dijkstra from a′. (Analysis Step 3): has d(w, b′) > 3εST (v)/8. ST (v) is a good approximation. Since d(w, a) ≤ εST (v)/4, by the previous argument the number of edges from the nodes at distance εST (v)/4 from w is at most √m, and so (a, a′) must be among the edges in E′′. Suppose that a′ ∈ V \ T . Let us consider d(a′, v) = d(w, v) − d(w, a′). Since d(w, a′) > εST (v)/4 and d(w, v) < εST (v)/2, d(a′, v) < εST (v)/4. Thus e(a′) ≥ d(a′, v′) ≥ d(v, v′) − d(a′, v) > 3εST (v)/4. So e(a′) − d(a′, v) > εST (v)/2. Now if a′′ is the farthest node from a′ in T , then εST (v) ≥ d(v, a′′) ≥ d(a′, a′′) − d(v, a′) = e(a′) − d(v, a′), and hence ε(3) So we assume that a′ ∈ T . (Algorithm Step 3): Consider the edges (t, b) with t ∈ T sorted in nondecreasing order according to d(w, t). Let ET be the first √m edges in this sorted order. Run Dijkstra from both endpoints of each edge in ET (call these nodes V (ET )), and find y(x) ∈ V \ T closest to x, for each x ∈ V (ET ). Run Dijkstra from each y(x), and let e(y(x)) = maxt∈T d(y(x), t). Let ε(4) ST (v) = maxx∈V (E T ) e(y(x)) − d(v, y(x)). Consider the node b on Pwv for which d(w, b) ≤ 3εST (v)/8, but such that the node b′ after it on Pwv Suppose that b′ ∈ T , then since d(w, b) ≤ εST (v)/2, by the previous argument (b, b′) ∈ ET and we run Dijkstra from y(b′). Let us consider d(y(b′), v) ≤ d(v, b′) + d(b′, y(b′)) ≤ 2d(v, b′). Since d(v, b′) = d(v, w) − d(w, b′) < εST (v)/8, d(y(b′), v) < εST (v)/4. Similar as in the previous step, we get that εST (v) ≥ e(y(b′)) − d(y(b′), v) and also e(y(b′)) − d(y(b′), v) ≥ d(y(b′), v′) − d(y(b′), v) ≥ d(v, v′) − 2d(y(b′), v) > εST (v)/2, thus ε(4) ST (v) is not a good approximation, it must be that b′ ∈ V \ T . Now, since a′ ∈ T and b′ ∈ V \ T , somewhere on the a′ to b′ shortest path Pa′b′ , there must be an edge (t, x) with t ∈ T and x ∈ V \ T . However, since t is on Pwv, we have d(w, t) ≤ d(v, w) < εST (v)/2. Thus, (t, x) ∈ ET and we run Dijkstra from x. Let us consider y(x). Since x ∈ V \ T , y(x) = x. Moreover since x is after a′ on Pa′b′, d(w, x) ≥ d(w, a′) > εST (v)/4, and thus d(x, v) = d(v, w) − d(w, x) < εST (v)/4. So e(y(x)) − d(y(x), v) = e(x) − d(x, v) ≥ d(x, v′) − d(x, v) ≥ d(v, v′) − 2d(x, v) > εST (v)/2. ST (v), ε(3) ε′ ST (v) ≤ εST (v). 4.2 ST -Radius ST (v) is a good approximation. So if ε(4) ST (v)}, we have εST (v)/2 ≤ Hence if for each v ∈ S we set ε′ ST (v) = max{ε(1) ST (v), ε(2) ST (v), ε(4) (cid:3) A simple argument shows that given any approximation algorithm for ST -Eccentricities, one obtains an approximation algorithm for ST -Radius with the same approximation factor. First, run the ST -Eccentricities algorithm and let v be the vertex with the smallest estimated Eccentricity ǫ′(v). Then run Dijkstra's algo- rithm from v and report ǫST (v) as the ST -Radius estimate R′. Let R be the true ST -Radius of the graph and let c be the true ST -center. If α is the approximation ratio for the ST -Eccentricities algorithm then ǫST (v) ≤ αǫ′(v) ≤ αǫST (v) and ǫST (c) ≤ αǫ′(c) ≤ αǫST (c). By choice of v, ǫ′(v) ≤ ǫ′(c). Thus, αR = αǫST (c) ≥ αǫ′(c) ≥ αǫ′(v) ≥ ǫST (v) = R′. Clearly R′ ≥ R, so R ≤ R′ ≤ αR. Thus, we get the following theorems from our algorithms for ST -Eccentricities. Theorem 4.3. There is an O(m + n log n) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S, T ⊆ V , can output an estimate R′ such that RST /3 ≤ R′ ≤ RST . Theorem 4.4. There is an O(m√n) time algorithm, that given an undirected unweighted graph G = (V, E) and S, T ⊆ V , can output an estimate R′ such that RST /2 − 5/2 ≤ R′ ≤ RST . 18 Theorem 4.5. There is an O(m3/2) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer edge weights and S, T ⊆ V , can output estimates R′ such that RST /2 ≤ R′ ≤ RST . 5 Algorithms for Subset Diameter, Eccentricities, and Radius We obtain 2-approximations for Subset Diameter in directed graphs and Subset Radius in undirected graphs simply by running Dijkstra's algorithm from an arbitrary vertex s ∈ S. We obtain an almost 2- approximation in almost linear time for directed Subset Eccentricities (and thus directed Subset Radius) by a slight modification of an algorithm for (non-Subset) Eccentricities in directed graphs from [4]. Proposition 4 (Directed Subset Diameter). There is an O(m) time algorithm, that given a directed graph G = (V, E) with nonnegative integer weights and S ⊆ V , outputs an estimate D′ such that DS/2 ≤ D′ ≤ DS. Proof. Run Dijkstra's algorithm both "forward" and "backward" from s to obtain D1 = maxs′∈S d(s, s′) and D2 = maxs′∈S d(s′, s). Return D′ = max{D1, D2}. Let s∗, t∗ ∈ S be the true endpoints of the Subset Diameter. Then, by the triangle inequality DS ≤ d(s∗, s) + d(s, t∗). Then since d(s∗, s) ≤ D2 and d(s, t∗) ≤ D1, DS ≤ D1 + D2. Thus, DS/2 ≤ max{D1, D2} ≤ DS. Proposition 5 (Undirected Subset Radius). There is an O(m) time algorithm, that given an undirected graph G = (V, E) with nonnegative integer weights and S ⊆ V , outputs an estimate R′ such that RS/2 ≤ D′ ≤ RS. Proof. Run Dijkstra's algorithm from s and return R′ = maxs′∈S d(s, s′). (cid:3) Let c∗ ∈ S be the true center. Then since d(c∗, s′) ≤ RS for all s′ ∈ S, the triangle inequality implies that for all s′, d(s, s′) ≤ 2RS. Thus, RS ≤ R′ ≤ 2RS. Theorem 5.1 (Directed Subset Eccentricities). Suppose that we are given a directed graph G = (V, E) with nonnegative integer weights. For any 1 > τ > 0 we can in O(m/τ ) time output for all v ∈ S an estimate ε′(v) such that 1−τ (cid:3) 2 εS(v) ≤ ε′(v) ≤ εS(v). Proof. The algorithm proceeds in iterations and maintains a set U of nodes for which we still do not have a good Eccentricity estimate. In each iteration either we get a good estimate for many new vertices and hence remove them from U , or we remove all vertices from U that have large Eccentricities, and for the remaining nodes in U we have a better upper bound on their Eccentricities. After a small number of iterations we have a good estimate for all vertices of the graph. Initially U = S and we will end with U ≤ O(1). When U ≤ O(1) we can evaluate εS(v) for all v ∈ U in the total time of O(m). Also we maintain a value D that upper bounds the largest Eccentricity of a vertex in U . That is, εS(v) ≤ D for all v ∈ U . Initially we set D = nC for some large enough constant C > 0 (we assume that the set S is strongly connected). The algorithm proceeds in phases. Each phase takes O(m) time and either U decreases by a factor of at least 2 or D decreases by a factor of at least 1/(1− τ ). After O(log(n)/τ ) phases either U ≤ O(1) or D < 1. For a subset U ⊆ V of vertices and a vertex x ∈ V we define a set Ux ⊆ S to contain those Ux = U/2 vertices from U that are closest to x (according to distance d(·, x)). The ties are broken by taking the vertex with the smaller id. Given a subset U ⊆ V of vertices and a threshold D, a phase proceeds as follows. • We sample a set A ⊆ U of O(log n) random vertices from the set U . By Lemma 2.1, with high probability for all x ∈ V we have A ∩ Ux 6= ∅. 19 • Let w be the vertex in S that maximizes d(A, w). We can find it by constructing a vertex y adjacent to every vertex in A and running Dijkstra's algorithm from y. • We consider two cases. 2 D. For all x ∈ U \ Uw we have 1−τ 2 D. This gives us that 1−τ 2 εS(x) ≤ 1−τ 2 D ≤ εS (x) ≤ D and we assign the 2 D = ε′(x) ≤ εS(x) for all x ∈ U \ Uw. Case d(U \ Uw, w) ≥ 1−τ estimate ε′(x) = 1−τ We update U to be Uw. This decreases the size of U by a factor of 2 as required. Case d(U \ Uw, w) < 1−τ 2 D. Set U ′ = U . For every vertex v ∈ U evaluate rv := maxx∈A d(v, x). We can evaluate these quantities by running Dijkstra's algorithm from every vertex in A and following the incoming edges. If rv ≥ 1−τ 2 D and remove v from U ′. Similarly as in the previous case we have 1−τ 2 εS(v) ≤ ε′(v) ≤ εS(v) for all v ∈ U \ U ′. Below we will show that for every v ∈ U ′ we have εS(v) ≤ (1 − τ )D. Thus we can update U = U ′ and decrease the threshold D to (1 − τ )D as required. 2 D, then assign the estimate ε′(v) = 1−τ Correctness We have to show that, if there exists v ∈ U ′ such that εS(v) > (1 − τ )D, then we will end up in the first case (this is the contrapositive of the claim in the second case). Since v ∈ U ′ we must have that d(v, x) ≤ 1−τ 2 D for all x ∈ A. Since εS(v) > (1 − τ )D, we must have that there exists v′ ∈ S such that d(v, v′) > (1 − τ )D. By the triangle inequality we get that d(x, v′) > 1−τ 2 D for every x ∈ A. By choice of w, we have d(A, w) > 1−τ 2 D and we will end up in the first case. 2 D. Since A ∩ Uw 6= ∅, we have d(U \ Uw, w) ≥ 1−τ The guarantee on the approximation factor follows from the description. (cid:3) Directed Subset Radius Using the argument from Section 4.2, we obtain an algorithm for Directed Subset Radius from our algorithm for Directed Subset Eccentricities. Theorem 5.2 (Directed Subset Radius). Suppose that we are given a directed graph G = (V, E) with nonnegative integer weights. For any 1 > τ > 0 we can in O(m/τ ) time output an estimate R′ such that RS ≤ R′ ≤ 2 1−τ RS. 6 Parameterized Algorithms for Bichromatic Diameter, Radius, and Eccen- tricities In this section we give algorithms for Bichromatic Diameter, Radius, and Eccentricities with runtimes parameterized by the size of the boundary B. Let S′ be the set of vertices in S that have a neighbor in T and let T ′ be the set of vertices in T that have a neighbor in S. Let B be whichever of S′ or T ′ is smaller in size. 6.1 Undirected Parameterized Bichromatic Diameter Theorem 6.1. There is an O(mB) time algorithm, that given an unweighted undirected graph G = (V, E) and S ⊆ V, T = V \ S, outputs an estimate D′ such that 2DST (G)/3 − 1 ≤ D′ ≤ DST (G). Proof. (Algorithm): For all v ∈ T , we let εST (v) = maxs∈S d(s, v) (εST (v) is already defined for v ∈ S). Suppose without loss of generality that B ⊆ S (a symmetric argument works for B ⊆ T ). For every vertex v ∈ B, run BFS from v, let vT be an arbitrary neighbor of v such that vT ∈ T , and run BFS from vT . Let D1 be the largest S − T distance found. That is, D1 = maxv∈B max{εST (v), εST (vT )}. Let s ∈ S be the farthest vertex from B. That is, s is the vertex in S that maximizes d(s, B). Then, we run BFS from s and let D2 = εST (s). Return D′ = max{D1, D2}. 20 (Analysis): Let s∗ ∈ S, t∗ ∈ T be the true endpoints of the Bichromatic Diameter and let D denote DST (G). If s∗ is of distance at most D/3 + 1 from some vertex v ∈ B then by the triangle inequality d(v, t∗) ≥ 2D/3− 1 so D1 ≥ 2D/3− 1 and we are done. If t∗ is of distance at most D/3 from some vertex v ∈ B then by the triangle inequality d(vT , s∗) ≥ 2D/3 − 1 so D1 ≥ 2D/3 − 1 and we are done. Now, if we are not already done, s∗ is of distance at least D/3 + 1 from every vertex in B, so s is also of distance at least D/3 + 1 from every vertex in B. Additionally, t∗ is of distance at least D/3 from every vertex in B. We observe that the shortest path between s and t∗ must contain a vertex in B. Thus, d(s, t∗) = minv∈B d(s, v) + d(v, t∗) ≤ (D/3 + 1) + (D/3) = 2D/3 + 1. Thus, D2 ≥ 2D/3 + 1 and we (cid:3) are done. 6.2 Undirected Parameterized Bichromatic Radius Theorem 6.2. There is an O(mB) time algorithm that, given an unweighted undirected graph G = (V, E) and S ⊆ V, T = V \ S, returns an estimate R′ such that RST G ≤ R′ ≤ 3RST (G)/2 + 3. Proof. (Algorithm): If B ⊆ S, we run BFS from all v ∈ B and let R1 be the minimum Eccentricity found; that is, R1 = minv∈B εST (v). If B ⊆ T , for every v ∈ B, we let vS be an arbitrary neighbor of v such that vS ∈ S, and run BFS from vS. In this case we let R1 = minv∈B εST (vS). Let U be the set of vertices that we have run BFS from so far. Then, let s ∈ S be the vertex that is closest to all vertices in U ; that is, let s be the vertex that minimizes maxv∈U d(s, v). Run BFS from s and let R2 = εST (s). Return min{R1, R2}. (Analysis): Let c∗ ∈ S be the true center and let R denote RST (G); that is, εST (c∗) = R. If there exists a vertex v ∈ U such that d(c∗, v) ≤ R/2, then since U ⊆ S and by the triangle inequality, εST (v) ≤ 3R/2 If we are not done by the previous step, c∗ must be of distance at least R/2 from every vertex in U , and thus of distance at least R/2 − 1 from every vertex in B. We observe that the shortest path between s and any vertex in T must contain a vertex in B. Thus, every vertex in T must be of distance at most R/2 + 1 from some vertex in B, and thus of distance at most R/2 + 2 from some vertex in U . and we are done. Since for all v ∈ T , d(c∗, v) ≤ R, the triangle inequality implies that for all v ∈ U , d(c∗, v) ≤ R + 1. Therefore, by choice of s, for all v ∈ U , d(s, v) ≤ R + 1. We claim that εST (s) ≤ 3R/2. Consider an arbitrary vertex t ∈ T . Let u be a vertex in U such that d(u, t) ≤ R/2 + 2; such a u exists by the previous paragraph. Then, d(s, u) + d(u, t) ≤ (R + 1) + (R/2 + 2) = 3R/2 + 3. Thus, εST (s) ≤ 3R/2 + 3. (cid:3) 6.3 Undirected Parameterized Bichromatic Eccentricities Theorem 6.3. There is an O(mB) time algorithm that, given an unweighted undirected graph G = (V, E) and S ⊆ V, T = V \S, returns for every v ∈ S an estimate ε′(v) such that 3εST (v)/5−1 ≤ ε′(v) ≤ εST (v). Proof. (Algorithm): Suppose B ⊆ S. For every vertex u ∈ B, we run BFS from u, let u′ be the vertex in T that maximizes d(u, u′), and run BFS from u′. Then for every vertex u ∈ B we let uT be an arbitrary neighbor of u such that uT ∈ T and run BFS from uT . Then, let t ∈ T be the farthest vertex from B; that is, t is the vertex in T that maximizes d(B, t). Let T ′′ be the set of vertices in T that we have run BFS from. For every vertex v ∈ S, we return the estimate ε′(v) = maxt′′∈T ′′ d(v, t′′). We use a similar algorithm for when B ⊆ T : For every vertex u ∈ B, we run BFS from u, let u′ be the vertex in T that maximizes d(u, u′), and run BFS from u′. Then, let t ∈ T be the farthest vertex from B; that is, t is the vertex in T that maximizes minu∈B d(u, t). Let T ′′ be the set of vertices in T that we we have run BFS from. For every vertex v ∈ S, we return the estimate ε′(v) = maxt′′∈T ′′ d(v, t′′). 21 (Analysis): Suppose B ⊆ S. If there exists a vertex in u ∈ B such that d(v, u) ≥ 3εST (v)/5, then d(v, uT ) ≥ 3εST (v)/5 − 1 so we are done. On the other hand, suppose B ⊆ T . If there exists a vertex in u ∈ B such that d(v, uT ) ≥ 3εST (v)/5 − 1, then we are done. Otherwise, v is of distance at most 3εST (v)/5 from every vertex in B. Thus, regardless of whether B ⊆ S or T , if we are not already done, v is of distance at most 3εST (v)/5 from every vertex in B. Then, since every path from v to any vertex in T must contain a vertex in B, there must exist a vertex in T that is of distance at least 2εST (v)/5 from every vertex in B. In particular, t must be of distance at least 2εST (v)/5 from every vertex in B. Let v′ be the true farthest vertex from v; that is, d(v, v′) = εST (v). If there exists a vertex in u ∈ B such that d(v, u) ≤ εST (v)/5, then by the triangle inequality d(u, v′) ≥ 4εST (v)/5, so d(u, u′) ≥ 4εST (v)/5. Applying the triangle inequality again, d(v, u′) ≥ 3εST (v)/5, so we are done. Otherwise, every vertex u ∈ B is of distance at least εST (v)/5 from v. We claim that if we are not already done, d(v, t) ≥ 3εST (v)/5. We observe that every path from v to t must contain a vertex in B. Let u ∈ B be a vertex on the shortest path from v to t. Then, d(v, t) = d(v, u) + d(u, t) ≥ εST (v)/5 + 2εST (v)/5 = 3εST (v)/5. 6.4 Directed Parameterized Bichromatic Diameter (cid:3) For Bichromatic Diameter in undirected graphs, we assumed that only one of S′ or T ′ was small (i.e. we set B to be the smaller of the two); however for directed graphs we impose that both S′ and T ′ are small, by defining a new parameter B′ = S′ ∪ T ′. Theorem 6.4. There is an O(mB′) time algorithm that, given an unweighted directed graph G = (V, E) and S ⊆ V, T = V \ S, returns an estimate D′ such that 2DST (G)/3 ≤ D′ ≤ DST (G). Proof. (Algorithm): For all v ∈ T , we let εST (v) denote maxs∈S d(s, v) (εST (v) is already defined for v ∈ S). Run forward BFS from every vertex in S′ and run backward BFS from every vertex in T ′. Let D1 be the largest S → T distance found. That is, D1 = maxv∈B′ εST (v). Let s ∈ S be the farthest vertex from B′. That is, s is the vertex in S that maximizes d(s, B′). Then, we run BFS from s and let D2 = εST (s). Return max{D1, D2}. (Analysis): Let s∗ ∈ S and t∗ ∈ T be the true Bichromatic Diameter endpoints and let D denote If there exists a vertex s′ ∈ S′ such that d(s∗, s′) ≤ D/3, then by the triangle inequality, DST (G). d(s′, t∗) ≥ 2D/3 so D1 ≥ 2D/3 and we are done. Similarly, if there exists a vertex t′ ∈ T ′ such that d(t′, t∗) ≤ D/3, then by the triangle inequality, d(s∗, t′) ≥ 2D/3 so D1 ≥ 2D/3 and we are done. Suppose we are not done. Then, for every vertex s′ ∈ S′, d(s∗, s′) > D/3 and for every vertex t′ ∈ T ′, d(t′, t∗) > D/3. By choice of s, for all s′ ∈ S′, d(s, s′) > D/3. We observe that every path from s to t∗ must contain an edge from a vertex in S′ to a vertex in T ′. Let (s′′ ∈ S′, t′′ ∈ T ′) be an edge on the shortest path from s to t∗. Then, d(s, t∗) = d(s, s′′) + d(s′′, t′′) + d(t′′, t∗) > D/3 + 1 + D/3 = 2D/3 + 1, so D2 ≥ 2D/3 + 1. (cid:3) 7 Conditional Lower Bounds 7.1 Bichromatic Diameter, Eccentricities, and Radius Undirected Bichromatic Diameter The following theorem implies that our algorithms for undirected Bichromatic Diameter from Theorem 3.2 and Proposition 1 are tight under SETH. 22 Theorem 7.1. Under SETH, for every k ≥ 2, every algorithm that can distinguish between Bichromatic Diameter 2k − 1 and 4k − 3 in undirected unweighted graphs requires m1+1/(k−1)−o(1) time. In particular setting k = 2 and 3 in Theorem 7.1 implies that our m3/2 time 5/3-approximation algo- rithm from Theorem 3.2 is tight in approximation factor and runtime, respectively. Furthermore, setting k to be arbitrarily large implies that our O(m) time almost 2-approximation algorithm from Proposition 1 is tight under SETH. Theorem 7.1 follows from the following lemma. Lemma 7.1. Let k ≥ 2 be any integer. Given a k-OV instance, we can in O(knk−1dk−1) time construct an unweighted, undirected graph with O(knk−1 + knk−2dk−1) vertices and O(knk−1dk−1) edges that satisfies the following two properties. 1. If the k-OV instance has no solution, then for all pairs of vertices u ∈ S and v ∈ T we have d(u, v) ≤ 2k − 1. 2. If the k-OV instance has a solution, then there exists a pair of vertices u ∈ S and v ∈ T such that d(u, v) ≥ 4k − 3. Proof. Construction of the graph. We begin with the k-OV-graph from Theorem 2.1. Additionally, we add k − 1 new layers of vertices Lk+1, . . . , L2k−1, where each new layer contains nk−1 vertices and is connected to the previous layer by a matching. That is, each new layer contains one vertex for every tuple (a1, . . . , ak−1) where ai ∈ Wi for all i, and each (a1, . . . , ak−1) ∈ Lj is connected to its counterpart (a1, . . . , ak−1) ∈ Lj−1 by an edge, for all j. We let S = L0 and we let T contain the rest of the vertices in the graph. Correctness of the construction. Case 1: The k-OV instance has no solution. By property 3 of Theorem 2.1 for all u ∈ S and v ∈ Lk, d(u, v) = k. Then, since Lk, . . . , L2k−1 form a series of matchings, for all u ∈ S and v ∈ Lk+1 ∪ ··· ∪ L2k−1, d(u, v) ≤ 2k − 1. Furthermore, property 5 of Theorem 2.1 implies that for all u ∈ S and v ∈ L1 ∪ ··· ∪ Lk−1, d(u, v) ≤ 2k − 1. Thus, we have shown that for all u ∈ S and v ∈ T we have d(u, v) ≤ 2k − 1. Case 2: The k-OV instance has a solution. Let (a0, a1, . . . , ak−1) be a solution to the k-OV instance where ai ∈ Wi for all i. We claim that d((a0, . . . , ak−2) ∈ S, (a1, . . . , ak−1) ∈ L2k−1)) ≥ 4k − 3. Since Lk, . . . , L2k−1 form a series of matchings, every path from (a0, . . . , ak−2) ∈ S to (a1, . . . , ak−1) ∈ L2k−1 contains the vertex (a1, . . . , ak−1) ∈ Lk. By property 4 of Theorem 2.1, d((a0, . . . , ak−2) ∈ S, (a1, . . . , ak−1) ∈ Lk) ≥ 3k − 2. Thus, d((a0, . . . , ak−2) ∈ S, (a1, . . . , ak−1) ∈ L2k−1)) ≥ 4k − 3. (cid:3) Undirected Bichromatic Eccentricities The following proposition implies that our algorithms for undi- rected Bichromatic Eccentricities from Theorem 3.7 and Proposition 2 are tight under SETH. Proposition 6. Under SETH, for every k ≥ 2, every algorithm that can distinguish between Bichromatic Eccentricities k and 3k − 2 in undirected unweighted graphs requires m1+1/(k−1)−o(1) time. In particular setting k = 2 and 3 in Theorem 6 implies that our m3/2 time 2-approximation algorithm from Theorem 3.7 is tight under SETH in approximation factor and runtime, respectively. Furthermore, setting k to be arbitrarily large implies that our O(m) time almost 3-approximation algorithm from Propo- sition 2 is tight under SETH. Proposition 6 follows from the following lemma. 23 Lemma 7.2. Let k ≥ 2 be any integer. Given a k-OV instance, we can in O(knk−1dk−1) time construct an unweighted, undirected graph with O(knk−1 + knk−2dk−1) vertices and O(knk−1dk−1) edges that satisfies the following two properties. Let S0 be a particular subset of S. 1. If the k-OV instance has no solution, then for all vertices v ∈ S0 we have εST (v) ≤ k. 2. If the k-OV instance has a solution, then there exists a vertex v ∈ S0 such that εST (v) ≥ 3k − 2. Proof. We begin with the k-OV-graph from Theorem 2.1. Let T = Lk and let S contain the rest of the vertices in the graph. Let S0 = L0. (cid:3) If the k-OV instance has no solution then by property 3 of Theorem 2.1 for all u ∈ L0 and v ∈ T , Suppose the k-OV instance has a solution (a0, . . . , ak−1). Then by property 4 of Theorem 2.1, d((a0, . . . , ak−2) ∈ d(u, v) = k. Thus, for all u ∈ L0, εST (u) = k. L0, (a1, . . . , ak−1) ∈ T ) ≥ 3k − 2, so εST (a0, . . . , ak−2) ≥ 3k − 2. Undirected Bichromatic Radius The following theorem implies that our O(m3/2) time 5/3-approximation algorithm for undirected Bichromatic Radius from Theorem 3.5 is tight in approximation factor under the HS hypothesis. Theorem 7.2. Under the HS hypothesis, any algorithm for Bichromatic Radius that achieves a (5/3 − δ)- approximation factor for δ > 0 in m-edge undirected unweighted graphs requires m2−o(1) time. Proof. Given an instance U, V ⊆ {0, 1}d of OV, let G(U, V ) be its OV-graph. Create G′ which has the same vertex set as G(U, V ) except instead of having a vertex for every v ∈ V it has two copies v1 ∈ V1 and v2 ∈ V2. The edges for G′ are: for u ∈ U, c ∈ C, we add (u, c) as an edge iff u[c] = 1. For v ∈ V, c ∈ C, we add (c, v1) as an edge iff v[c] = 1. For each v ∈ V we add an edge (v1, v2). Set S = U and T = V1 ∪ V2 ∪ C. The number of edges in the graph is O(nd). Suppose that there is no HS solution, then for all u ∈ U there is some v ∈ V so that u · v = 0 and hence d(u, v2) ≥ 5. If there is an HS solution u ∈ U , then for all t ∈ T , d(u, t) ≤ 3. Directed Bichromatic Diameter The following theorem implies that our m3/2 2-approximation algo- rithm for directed Bichromatic Diameter from Theorem 3.8 has a tight approximation factor under SETH. Theorem 7.3. Under SETH, any algorithm for directed Bichromatic Diameter that achieves a (2 − δ)- approximation factor for δ > 0 in m-edge graphs requires m2−o(1) time. (cid:3) Proof. We will show that under SETH, for any positive integer ℓ, distinguishing between Bichromatic Di- ameter ℓ + 1 and 2ℓ + 1 requires m2−o(1) time. Given an instance U, V ⊆ {0, 1}d of OV, let G(U, V ) be its OV-graph. Create G′ which has the same vertex set as G(U, V ) except instead of having one vertex for every v ∈ V it has ℓ copies vi ∈ Vi for 1 ≤ i ≤ ℓ. It also has ℓ − 2 additional vertices: P = {p1, p2, . . . , pℓ−2}. The edges of G′ are: for u ∈ U, c ∈ C, we add (u, c) as an edge iff u[c] = 1, and for c ∈ C, v ∈ V , we add (c, v1) as an edge iff v[c] = 1. We add a matching going from Vi to Vi+1 where edges join the nodes which are copies of each other. For each c ∈ C, we add an edge (c, p1). We add a path from p1 to pℓ−2. For each u ∈ U , we add an edge (pℓ−2, u). Set S = U, T = C ∪ P ∪ V1 ∪ V2 . . . Vℓ. The number of edges in the graph is O(nd). Consider any u ∈ U . By construction, d(u, z) ≤ ℓ + 1 for z ∈ C ∪ P . Suppose that there is no OV solution, then for all u ∈ U, v ∈ V , u · v 6= 0 and hence d(u, vi) ≤ ℓ + 1. If there is an OV solution u ∈ U, v ∈ V , then, d(u, vℓ) ≥ 2ℓ + 1 as the only path is through P . (cid:3) 24 Directed Bichromatic Eccentricities Proposition 7. Under SETH, any algorithm for Bichromatic Eccentricities that achieves a finite approxi- mation factor in m-edge directed graphs requires m2−o(1) time. Proof. Given an instance U, V ⊆ {0, 1}d of OV, let G(U, V ) be its OV-graph. Now, direct the edges from U to C and from C to V and set S = U ∪ C, T = V . Notice this is an instance of Bichromatic Eccentricities. Now, for every u ∈ U, v ∈ V , if u · v 6= 0, d(u, v) = 2 and if u · v = 0, d(u, v) = ∞ as there is no path from u to v. Thus, if there is an OV pair, then the ST -Eccentricity for every u ∈ U ⊆ S is ∞, and otherwise it is 2. Any finite approximation to the ST -Eccentricities can distinguish between ∞ and 2, and thus can solve OV. (Notice, we do not even need the Eccentricities of nodes in C.) Thus, there can be no m2−ε time algorithm for ε > 0 that achieves a finite approximation factor if SETH holds. (cid:3) Directed Bichromatic Radius Proposition 8. Under the HS hypothesis, any algorithm for Bichromatic Radius that achieves a finite ap- proximation factor in m-edge directed graphs requires m2−o(1) time. Proof. The proof is similar to that for Bichromatic Eccentricities. Given an instance U, V ⊆ {0, 1}d of HS, let G(U, V ) be its OV-graph. Now, direct the edges from U to C and from C to V , and add an extra node z so that for every u ∈ U there is a directed edge (u, z). Set S = U ∪ C, T = V ∪ {z}. First, if the ST -Radius is finite, the ST -center (the node achieving the Radius) must be in U , since no node in C can reach z, by construction. The distance d(u, z) is 1 for all u ∈ U . For every u ∈ U, v ∈ V , if u · v 6= 0, d(u, v) = 2 and if u · v = 0, d(u, v) = ∞ as there is no path from u to v. Thus, if there is a HS solution, then the ST -Radius is 2, and otherwise it is ∞. Any finite approximation to the ST -Radius can distinguish between ∞ and 2, and thus can solve HS. Thus, there can be no m2−ε time algorithm for ε > 0 that achieves a finite approximation factor if the HS hypothesis holds. (cid:3) 7.2 ST -Diameter, Eccentricities, and Radius Undirected ST -Diameter and Eccentricities For undirected graphs, Backurs et al. [4] give a time- accuracy trade-off lower bound for ST -Diameter that immediately extends to ST -Eccentricities (since any Eccentricities algorithm gives a Diameter algorithm with the same running time and accuracy by taking the maximum of Eccentricities). The following theorem shows that our algorithms for ST -Eccentricities from Theorem 4.2 and Proposi- tion 3 are tight under SETH. Theorem 7.4 ([4]). Under SETH, for every k ≥ 2, every algorithm for ST -Diameter (and thus ST - Eccentricities) that achieves a ((4k − 3)/(2k − 1) − δ)-approximation for δ > 0 in undirected unweighted graphs requires m1+1/(k−1)−o(1) time. In particular, setting k = 2 and 3 in Theorem 7.4 shows that our m3/2 time 2-approximation algorithm for ST -Eccentricities from Theorem 4.2 is tight under SETH, in terms of both approximation factor and runtime. Furthermore, setting k to be arbitrarily large implies that our O(m) time 3-approximation algorithm for ST -Eccentricities from Proposition 3 is tight under SETH. Undirected ST -Radius The following proposition shows that our O(m3/2) time 2-approximation algo- rithm for undirected ST -Radius from Theorem 4.5 has a tight approximation factor under the HS hypothesis. Proposition 9. Under the HS hypothesis, any algorithm for ST -Radius that achieves a (2−δ)-approximation for δ > 0 in m-edge undirected graphs requires m2−o(1) time. 25 Proof. Given an instance U, V ∈ {0, 1}d of HS, let G be the OV-graph defined on this instance. Let S = U and T = V . Suppose that there is a node u ∈ U which is not orthogonal to any node in V . Then for each v ∈ V , d(u, v) = 2 by using the coordinate node on which both u and v are 1. So in this case the ST -Radius is 2. Suppose on the other hand that no such node in U exists, so that for each node u ∈ U, there is a node v ∈ V such that u · v = 0. Then d(u, v) ≥ 4. Since S = U , the ST -Radius is at least 4 in this case. So any (2 − δ)-approximation algorithm can distinguish between ST -Radius 2 and 4, and thus solve HS. Therefore, there can be no m2−ǫ time algorithm for ǫ > 0 that achieves a (2 − δ)-approximation factor (cid:3) if HS hypothesis holds. Directed ST -Diameter Proposition 10. Under SETH, any algorithm for ST -Diameter that achieves a finite approximation factor in m-edge directed graphs requires m2−o(1) time. Proof. Given an instance U, V ⊆ {0, 1}d of OV, let G(U, V ) be its OV-graph. Now, direct the edges from U to C and from C to V and set S = U , T = V . Now, for every u ∈ U, v ∈ V , if u · v 6= 0, d(u, v) = 2 and if u · v = 0, d(u, v) = ∞ as there is no path from u to v. Thus, if there is an OV pair, then the ST -Diameter is ∞, and otherwise it is 2. Any finite approximation to the ST -Diameter can distinguish between ∞ and 2, and thus can solve OV. Thus, there can be no m2−ε time algorithm for ε > 0 that achieves a finite approximation factor if SETH holds. (cid:3) Directed ST -Eccentricities and Radius Propositions 7 and 8 immediately carry over to Directed ST - Eccentricities and ST -Radius since the Bichromatic version is a special case of the ST version. We state the results here for convenience. Proposition 11. Under SETH, any algorithm for ST -Eccentricities that achieves a finite approximation factor in m-edge directed graphs requires m2−o(1) time. Proposition 12. Under the HS hypothesis, any algorithm for ST -Radius that achieves a finite approximation factor in m-edge directed graphs requires m2−o(1) time. 7.3 Subset Diameter, Eccentricities, and Radius Subset Diameter and Eccentricities The following proposition implies that our O(m) time 2-approximation algorithm for Subset Diameter from Proposition 4 is tight under SETH, and that our near-linear time almost 2-approximation algorithm for Subset Eccentricities from Theorem 5.1 is essentially tight under SETH. Proposition 13. Under SETH, any algorithm for Subset Diameter (and thus Subset Eccentricities) that achieves a (2 − δ)-approximation factor for δ > 0 in m-edge directed graphs requires m2−o(1) time. Proof. Given an instance U, V ∈ {0, 1}d of OV, we begin with the OV-graph defined on this instance. We add a vertex u adjacent to every vertex in U and a vertex v adjacent to every vertex in V . Let S = U ∪ V . If there is no OV solution, every pair of vertices s ∈ U , s′ ∈ V d(s, s′) = 2. Also, every pair of vertices s, s′ ∈ U or s, s′ ∈ V has d(s, s′) = 2 due to the addition of the vertices u and v. On the other hand, if there is an OV solution, in the original OV-graph there exists s ∈ U , s′ ∈ V such that d(s, s′) = 4. We note that the addition of the vertices u and v does not change this fact. (cid:3) 26 Subset Radius The following proposition implies that our O(m) time 2-approximation algorithm for Subset Radius from Proposition 5 is tight under the HS hypothesis. Proposition 14. Under the HS hypothesis, any algorithm for Subset Radius that achieves a (2 − δ)- approximation factor for δ > 0 in m-edge undirected graphs requires m2−o(1) time. Proof. Given an instance U, V ∈ {0, 1}d of HS, we begin with the OV-graph U ∪ C ∪ V defined on this instance. Then we add a vertex u adjacent to every vertex in U and a vertex v adjacent to u. Let S = U ∪ V ∪ {v}. If there is no HS solution, then in the original OV-graph, for all s ∈ U , there exists some s′ ∈ V such that d(s, s′) ≥ 4. We note that the addition of the vertices u and v does not change this fact. Furthermore, for all vertices s ∈ V , d(v, s) = 4. Thus, the Subset Radius is at least 4. On the other hand, if there is a HS solution, then there exists a vertex s ∈ U such that for all vertices s′ ∈ V , d(s, s′) = 2. Also, d(s, v) = 2. Thus, the Subset Radius is 2. 7.4 Parameterized Bichromatic Diameter, Eccentricities, and Radius (cid:3) In this section we show that modifications of our lower bound constructions show that our algorithms parameterized by the boundary size B for Bichromatic Diameter, Eccentricities, and Radius are condition- ally tight. Recall that for undirected graphs, S′ is the set of vertices in S that have a neighbor in T , T ′ is the set of vertices in T that have a neighbor in S, and B is whichever of S′ or T ′ is smaller in size. Since these our parameterized algorithms for undirected graphs have additive error, instead of showing that e.g. distin- guishing between values 2 and 3 is hard, we will give results of the form "for all ℓ, distinguishing between e.g. 2ℓ and 3ℓ is hard". This proves that even algorithms with constant additive error cannot achieve a better multiplicative approximation factor than e.g. 3/2. Undirected Parameterized Bichromatic Diameter The following theorem implies that the multiplicative factor in our O(mB) time almost 3/2-approximation algorithm for undirected Bichromatic Diameter from Theorem 6.1 is tight under SETH for B = ω(log n). Theorem 7.5. For any integer ℓ > 0, under SETH any algorithm for Bichromatic Diameter in undirected unweighted graphs that distinguishes between Bichromatic Diameter 4ℓ and 6ℓ requires m2−o(1) time, even for graphs with B = d = O(1). Proof. Construction Given an instance U, V ∈ {0, 1}d of OV, we begin with the OV-graph U , C, V defined on this instance. We add a new set U ′ of n vertices, one vertex for each vector in U , and connect each vertex in U to its corresponding vertex in U ′ to form a matching. Symmetrically, we add a new set V ′ of n vertices, one vertex for each vector in V , and connect each vertex in V to its corresponding vertex in V ′ to form a matching. Then we subdivide each of the edges in the graph into a path of length ℓ. Let T contain C ∪ V ∪ V ′ as well as the vertices on the subdivision paths from C to V and from V to V ′. Let S be the remaining vertices, that is, S contains U , U ′, the vertices that subdivide the edges between U and U ′, and the vertices that subdivide the edges between U and C. Analysis We note that T ′ = C and C = d so B = d = O(1). If the OV instance has no solution then for every pair of vertices u ∈ U , v ∈ V , d(u, v) = 2ℓ. Every vertex in S is at most distance ℓ from some vertex in U and every vertex in T is at most distance ℓ from some vertex in V so the Bichromatic Diameter is at most 4ℓ. 27 Suppose the OV instance has a solution u ∈ U , v ∈ V . We know that d(u, v) ≥ 4ℓ. Let u′ be the vertex in U ′ that is matched to u and let v′ be the vertex in V ′ that is matched to v. We claim that d(u′, v′) ≥ 6ℓ. Since U, U ′ and V, V ′ form matchings the only paths between u′ and v′ contain u and v. Thus, d(u′, v′) = d(u′, u) + d(u, v) + d(v, v′) ≥ 6ℓ. (cid:3) Undirected Parameterized Bichromatic Eccentricities The following proposition implies that the mul- tiplicative factor in our O(mB) time almost 5/3-approximation algorithm for undirected Bichromatic Eccentricities from Theorem 6.3 is tight under SETH for B = ω(log n). Proposition 15. For any integer ℓ > 0, under SETH any algorithm for Bichromatic Eccentricities in undi- rected unweighted graphs that distinguishes for all vertices v between εST (v) = 3ℓ and εST (v) = 5ℓ requires m2−o(1) time, even for graphs with B = d = O(1). Proof. Construction Given an instance U, V ∈ {0, 1}d of OV, we begin with the OV-graph U , C, V defined on this instance. We add a new set V ′ of n vertices, one vertex for each vector in V , and connect each vertex in V to its corresponding vertex in V ′ to form a matching. Then we subdivide each of the edges in the graph into a path of length ℓ. Let S contain U , C, and the vertices that subdivide the edges between U and C. Let T contain the remaining vertices. Analysis We note that S′ = C and C = d so B = d = O(1). is of distance at most ℓ from some vertex in T so for all vertices u ∈ U , εST (u) ≤ 3ℓ. d(u, v′) ≥ 5ℓ so εST (v) ≥ 5ℓ. If there is no OV solution, then for all pairs of vertices u ∈ U , v ∈ V , d(u, v) = 2ℓ. Every vertex in T If there is an OV solution u ∈ U , v ∈ V , d(u, v) ≥ 4ℓ. Let v′ ∈ V ′ be the vertex matching to v. Then, (cid:3) Undirected Parameterized Bichromatic Radius The following theorem implies that the multiplicative factor in our O(mB) time almost 3/2-approximation algorithm for undirected Bichromatic Radius from Theorem 6.2 is tight under the HS hypothesis for B = ω(log n). Theorem 7.6. For any integer ℓ > 0, under the HS hypothesis any algorithm for Bichromatic Radius in undirected unweighted graphs that distinguishes between Bichromatic Radius 4ℓ and 6ℓ requires m2−o(1) time, even for graphs with B = d = O(1). Proof. 1, U1, C1, V1, V ′ 1 , and U ′ 2, U2, C2, V2, V ′ Construction Given an instance U, V ∈ {0, 1}d of HS, we begin with two copies of the construction from Theorem 7.5, U ′ 1 with its corresponding vertex in U ′ 2. Analysis We note that T ′ = C1 ∪ C2 and C1 = C2 = d so B = 2d = O(1). C1, V1, V ′ 1. It will be convenient to imagine that the graph is layered from left to right as V ′ 2. We then merge each vertex in U ′ 2, V2, C2, U2, U ′ 1, U1, 1. Since any path u to a vertex in V ′ If there is no HS solution, then for all u1 ∈ U1, there exists some v1 ∈ V1 such that d(u1, v1) ≥ 4ℓ and for all u2 ∈ U2, there exists some v2 ∈ V2 such that d(u2, v2) ≥ 4ℓ. Let u be any vertex in S that lies in U ′ 1 or to the right of U ′ 2 such that d(u, v) ≥ 6ℓ. Symmetrically, if u is a vertex in S that lies to the left of U ′ 1 such that d(u, v) ≥ 6ℓ. Thus, the Bichromatic Radius is at least 6ℓ. v ∈ V1, d(u, v) = 2ℓ. Let u′ be the vertex in U ′ On the other hand, if there is a HS solution, then there exists a vertex u ∈ U1 such that for all vertices 1 matched to u and let u′′ be the vertex in U2 matched to u′. 2 contains a vertex in U2, there exists v ∈ V ′ 1, there exists v ∈ V ′ 28 Then, for all vertices v ∈ V2, d(u′′, v) = 2ℓ. Thus, for all vertices v ∈ V1 ∪ V2, d(u′, v) = 3ℓ, so for all vertices v ∈ T , d(u′, v) ≤ 4ℓ. Thus, the Bichromatic Radius is at most 4ℓ. Directed Parameterized Bichromatic Diameter Recall that for directed graphs, S′ is the set of vertices in S with an outgoing edge to a vertex in T , T ′ is the set of vertices in T with an incoming edge from a vertex in S, and B′ = S′ ∪ T ′. We will show that the construction from Theorem 7.5 can be made to have small B′ (i.e. small S′ and T ′), with a slight additive cost to the Diameter values. The construction will remain undirected. (cid:3) The following proposition implies that the multiplicative factor in our O(mB′) time almost 3/2- approximation algorithm for Directed Bichromatic Diameter from Theorem 6.4 is tight under SETH for B′ = ω(log n). Proposition 16. For any integer ℓ > 0, under SETH any algorithm for Bichromatic Diameter in directed unweighted graphs that distinguishes between Bichromatic Diameter 4ℓ + 1 and 6ℓ + 1 requires m2−o(1) time, even for graphs with B = d = O(1). Proof. Construction We begin with the construction from Theorem 7.5. We replace each vertex c ∈ C by a pair of vertices c1, c2 and let (c1, c2) be an edge. Let C1 and C2 be the set of all c1's and c2's respectively. That is, C1 and C2 form a matching. For every edge originally between u ∈ U and c ∈ C, we replace it with the undirected edge (u, c1) and for every edge originally between c ∈ C and v ∈ V , we replace it with the undirected edge (c2, v). Analysis The correctness follows from the analysis of Theorem 7.5. Here, we get 4ℓ+1 and 6ℓ+1 instead of 4ℓ and 6ℓ due to the addition of the matching between C1 and C2. (cid:3) Acknowledgements The authors would like to thank Arturs Backurs for discussions during the early stages of this work. References [1] Amir Abboud, Virginia Vassilevska Williams, and Joshua R. Wang. Approximation and fixed param- eter subquadratic algorithms for radius and diameter in sparse graphs. In Proceedings of the Twenty- Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2016, Arlington, VA, USA, January 10-12, 2016, pages 377 -- 391, 2016. [2] Pankaj K. Agarwal, Herbert Edelsbrunner, Otfried Schwarzkopf, and Emo Welzl. Euclidean minimum spanning trees and bichromatic closest pairs. Discrete Comput. Geom., 6(1):407 -- 422, December 1991. [3] D. Aingworth, C. Chekuri, P. Indyk, and R. Motwani. Fast estimation of diameter and shortest paths (without matrix multiplication). SIAM Journal on Computing, 28(4):1167 -- 1181, 1999. [4] Arturs Backurs, Liam Roditty, Gilad Segal, Virginia Vassilevska Williams, and Nicole Wein. Towards tight approximation bounds for graph diameter and eccentricities. In Proceedings of STOC'18, page to appear, 2018. [5] Massimo Cairo, Roberto Grossi, and Romeo Rizzi. New bounds for approximating extremal distances in undirected graphs. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Dis- crete Algorithms, SODA 2016, Arlington, VA, USA, January 10-12, 2016, pages 363 -- 376, 2016. 29 [6] T. M. Chan. More algorithms for all-pairs shortest paths in weighted graphs. In Proc. STOC, pages 590 -- 598, 2007. [7] Bernard Chazelle, Herbert Edelsbrunner, Leonidas J Guibas, and Micha Sharir. Algorithms for bichro- matic line-segment problems and polyhedral terrains. Algorithmica, 11(2):116 -- 132, 1994. [8] Shiri Chechik, Daniel H. Larkin, Liam Roditty, Grant Schoenebeck, Robert Endre Tarjan, and Virginia Vassilevska Williams. Better approximation algorithms for the graph diameter. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1041 -- 1052, 2014. [9] Don Coppersmith and Michael Elkin. Sparse sourcewise and pairwise distance preservers. SIAM Journal on Discrete Mathematics, 20(2):463 -- 501, 2006. [10] Pierluigi Crescenzi, Roberto Grossi, Leonardo Lanzi, and Andrea Marino. On computing the diameter of real-world directed (weighted) graphs. In Ralf Klasing, editor, Experimental Algorithms: 11th International Symposium, SEA 2012, Bordeaux, France, June 7-9, 2012. Proceedings, pages 99 -- 110, Berlin, Heidelberg, 2012. Springer Berlin Heidelberg. [11] Marek Cygan, Fabrizio Grandoni, and Telikepalli Kavitha. On pairwise spanners. arXiv preprint arXiv:1301.1999, 2013. [12] Adrian Dumitrescu and Sumanta Guha. Extreme distances in multicolored point sets. J. Graph Algo- rithms and Applications, 8(1):27 -- 38, 2004. [13] Jiawei Gao, Russell Impagliazzo, Antonina Kolokolova, and R. Ryan Williams. Completeness for first-order properties on sparse structures with algorithmic applications. In Proceedings of the Twenty- Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 2162 -- 2181, 2017. [14] R. Impagliazzo and R. Paturi. On the complexity of k-sat. J. Comput. Syst. Sci., 62(2):367 -- 375, 2001. [15] Piotr Indyk. A near linear time constant factor approximation for euclidean bichromatic matching (cost). In SODA, volume 7, pages 39 -- 42, 2007. [16] Naoki Katoh and Kazuo Iwano. Finding k farthest pairs and k closest/farthest bichromatic pairs for In Proceedings of the Eighth Annual Symposium on Computational Geometry, points in the plane. SCG '92, pages 320 -- 329, 1992. [17] Telikepalli Kavitha. New pairwise spanners. Theory of Computing Systems, 61(4):1011 -- 1036, 2017. [18] Philip N Klein. A subset spanner for planar graphs, with application to subset tsp. In Proceedings of the thirty-eighth annual ACM symposium on Theory of computing, pages 749 -- 756. ACM, 2006. [19] Cl´emence Magnien, Matthieu Latapy, and Michel Habib. Fast computation of empirically tight bounds for the diameter of massive graphs. J. Exp. Algorithmics, 13:10:1.10 -- 10:1.9, February 2009. [20] David Peleg, Liam Roditty, and Elad Tal. Distributed algorithms for network diameter and girth. In Automata, Languages, and Programming: 39th International Colloquium, ICALP 2012, Warwick, UK, July 9-13, 2012, Proceedings, Part II, pages 660 -- 672, 2012. 30 [21] S. Pettie. A new approach to all-pairs shortest paths on real-weighted graphs. Theor. Comput. Sci., 312(1):47 -- 74, 2004. [22] Seth Pettie and Vijaya Ramachandran. A shortest path algorithm for real-weighted undirected graphs. SIAM J. Comput., 34(6):1398 -- 1431, 2005. [23] Liam Roditty and Virginia Vassilevska Williams. Fast approximation algorithms for the diameter and radius of sparse graphs. In Proceedings of the 45th annual ACM symposium on Symposium on theory of computing, STOC '13, pages 515 -- 524, New York, NY, USA, 2013. ACM. [24] Frank W. Takes and Walter A. Kosters. Determining the diameter of small world networks. In Proceed- ings of the 20th ACM International Conference on Information and Knowledge Management, CIKM '11, pages 1191 -- 1196, 2011. [25] Virginia Vassilevska Williams. Hardness of easy problems: Basing hardness on popular conjectures such as the strong exponential time hypothesis (invited talk). In 10th International Symposium on Parameterized and Exact Computation, IPEC 2015, September 16-18, 2015, Patras, Greece, pages 17 -- 29, 2015. [26] R. Williams. A new algorithm for optimal 2-constraint satisfaction and its implications. Theor. Comput. Sci., 348(2 -- 3):357 -- 365, 2005. [27] Ryan Williams. On the difference between closest, furthest, and orthogonal pairs: Nearly-linear vs barely-subquadratic complexity. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '18, pages 1207 -- 1215, 2018. [28] A. Yao. On constructing minimum spanning trees in k-dimensional spaces and related problems. SIAM Journal on Computing, 11(4):721 -- 736, 1982. 31
1206.5336
3
1206
2013-07-13T15:45:44
Near-Optimal Online Multiselection in Internal and External Memory
[ "cs.DS" ]
We introduce an online version of the multiselection problem, in which q selection queries are requested on an unsorted array of n elements. We provide the first online algorithm that is 1-competitive with Kaligosi et al. [ICALP 2005] in terms of comparison complexity. Our algorithm also supports online search queries efficiently. We then extend our algorithm to the dynamic setting, while retaining online functionality, by supporting arbitrary insertions and deletions on the array. Assuming that the insertion of an element is immediately preceded by a search for that element, we show that our dynamic online algorithm performs an optimal number of comparisons, up to lower order terms and an additive O(n) term. For the external memory model, we describe the first online multiselection algorithm that is O(1)-competitive. This result improves upon the work of Sibeyn [Journal of Algorithms 2006] when q > m, where m is the number of blocks that can be stored in main memory. We also extend it to support searches, insertions, and deletions of elements efficiently.
cs.DS
cs
Near-Optimal Online Multiselection in Internal and External Memory Departamento de Ciencias de la Computaci´on (DCC) J´er´emy Barbay∗ Universidad de Chile [email protected] Ankur Gupta† Department of Computer Science and Software Engineering Butler University [email protected] S. Srinivasa Rao‡ School of Computer Science and Engineering Seoul National University [email protected] Jon Sorenson† Department of Computer Science and Software Engineering Butler University [email protected] Abstract We introduce an online version of the multiselection problem, in which q selection queries are requested on an unsorted array of n elements. We provide the first online algorithm that is 1- competitive with Kaligosi et al.[ICALP 2005] in terms of comparison complexity. Our algorithm also supports online search queries efficiently. We then extend our algorithm to the dynamic setting, while retaining online functionality, by supporting arbitrary insertions and deletions on the array. Assuming that the insertion of an element is immediately preceded by a search for that element, we show that our dynamic online algorithm performs an optimal number of comparisons, up to lower order terms and an additive O(n) term. For the external memory model, we describe the first online multiselection algorithm that is O(1)-competitive. This result improves upon the work of Sibeyn [Journal of Algorithms 2006] when q > m, where m is the number of blocks that can be stored in main memory. We also extend it to support searches, insertions, and deletions of elements efficiently. ∗Supported by Project Regular Fondecyt number 1120054. †Supported in part by the Butler Holcomb Awards grant. ‡Supported by Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Education, Science and Technology (Grant number 2012-0008241). 1 1 Introduction The multiselection problem asks for the elements of rank Q = q1, q2, . . . , qq on an unsorted array A drawn from an ordered universe of elements. We define B(Sq) as the information-theoretic lower bound on the number of comparisons needed to answer q queries, where Sq = si denotes the queries ordered by rank. We define ∆i = si+1 − si, where s0 = 0 and sq+1 = n. Then, q q log (∆i!) = Xi=0 ∆i log n ∆i − O(n).1 Xi=0 B(Sq) = log n! − Several papers have analyzed this problem carefully. Dobkin and Munro [DM81] gave a de- terministic bound using 3B(Sq) + O(n) comparisons. Prodinger [Pro95] proved the expected com- parisons with random pivoting is 2B(Sq) ln 2 + O(n). Most recently, Kaligosi et al. [KMMS05] showed a randomized algorithm taking B(Sq) + O(n) expected comparisons, along with a deter- ministic algorithm taking B(Sq) + o(B(Sq) + O(n) comparisons. Jim´enez and Mart´ınez [JM10] later improved the number of comparisons in the expected case to B(Sq) + n + o(n). Most recently, Car- dinal et al. [CFJ+09] generalized the problem to a partial order production, of which multiselection is a special case. Cardinal et al. use the multiselection algorithm as a subroutine after an initial preprocessing phase. Kaligosi et al. [KMMS05] provide an elegant result in the deterministic case based on tying the number of comparisons required for merging two sorted sequences to the information content of those sequences. This simple observation drives an approach where manipulating these runs to both find pivots that are "good enough" and partition with near-optimal comparisons. The weakness of the approaches in internal memory is that they must know all of the queries a priori. In external memory, Sibeyn [Sib06] solves multiselection using n + nq/m1−ǫ I/Os, where ǫ is any positive constant. The first term comes form creating a static index structure using n I/Os, and the reminder comes from the q searches in that index. In addition, his results also require the condition that log N = O(B). When q = m, Sibeyn's multiselection algorithm requires O(nmǫ) I/Os, whereas the optimum is Θ(n) I/Os. In fact his bounds are ω(Bm(Sq)), for any q ≥ m, where Bm(Sq)) is the lower bound on the number of I/Os required (see Section D.1 for the definition). 1.1 Our Results For the multiselection problem in internal memory, we describe the first online algorithm that insert, and delete operations, of which q′ are search, supports a set Q of q selection, search, insert, and delete, using B(Sq) + o(B(Sq) + O(n + q′ log n) comparisons.2 Thus our algorithm is 1-competitive with the offline algorithm of Kaligosi et al. [KMMS05] in terms of comparison complexity. We also show a randomized result achieving 1-competitive behavior with respect to Kaligosi et al. [KMMS05], while only using O((log(n))O(1)) sampled elements instead of O(n3/4). For the external memory model, we describe an online multiselection algorithm that supports a set Q of q selection queries on an unsorted array stored on disk in n blocks, using O(Bm(Sq))+O(n) I/Os, where Bm(Sq) is a lower bound on the number of I/Os required to support the given queries. This result improves upon the work of Sibeyn [Journal of Algorithms 2006] when q > m, where m 1We use the notation logb the base e logarithm of b. a to refer to the base b logarithm of a. By default, we let b = 2. We also define ln b as 2For the dynamic result, we assume that the insertion of an element is immediately preceded by a search for that element. In that case, we show that our dynamic online algorithm performs an optimal number of comparisons, up to lower order terms and an additive O(n) term. 2 is the number of blocks that can be stored in main memory. We also extend it to support insertions and deletions of elements using O(Bm(Sq)) + O(n + q logB N ) I/Os. 1.2 Preliminaries Given an unsorted array A of length n, the median is the element x of A such that exactly ⌈n/2⌉ elements in A are greater than or equal to x. It is well-known that the median can be computed in O(n) time, and many [Hoa61, BFP+73, SPP76] have analyzed the exact constants involved. The best known result is due to Dor and Zwick [DZ99] to obtain 2.942 + o(n) time. In the external memory model, the computer is abstracted to consist of two memory levels: the internal memory of size M , and the (unbounded) disk memory, which operates by reading and writing data in blocks of size B. We refer to the number of items of the input by N . For convenience, we define n = N/B and m = M/B as the number of blocks of input and memory, respectively. We make the reasonable assumption that 1 ≤ B ≤ M/2. In this model, we assume that each I/O read or write is charged one unit of time, and that an internal memory operation is charged no units of time. To achieve the optimal sorting bound of SortIO(N ) = Θ(n logm n) in this setting, it is necessary to make the tall cache assumption [BF03]: M = Ω(B1+ǫ), for some constant ǫ > 0, and we will make this assumption for the remainder of the paper. 2 A Simple Online Algorithm Let A be an input array of n unsorted items. We describe a simple version of our algorithm for handling selection and search queries on array A. We say that an element in array A at position i is a pivot if A[1 . . . i − 1] < A[i] ≤ A[i + 1 . . . n]. where B[i] = 1 if and only if it is a pivot. Bit Vector. Throughout all the algorithms in the paper, we maintain a bitvector B of length n Preprocessing. Create a bitvector B and set each bit to 0. Find the minimum and maximum elements in array A, swap them into A[1] and A[n] respectively, and set B[1] = B[n] := 1. Selection. We define the operation A.select(s) to refer to the selection query s, which returns A[s] if A were sorted. To compute this result, if B[s] = 1 then return A[s] and we are done. If B[s] = 0, find a < s, b > s, such that B[a] = B[b] = 1 but B[a + 1 . . . b − 1] are all 0. Perform quickselect [Hoa61] on A[a + 1 . . . b − 1], marking pivots found along the way in B. This gives us A[s], with B[s] = 1, as desired. Search. We define the operation A.search(p) returns the position j, which satisfies p = A[j] if A were sorted; if p 6∈ A, then j is the number of items in A smaller than p.3 Perform a binary search on A as if A were sorted. Let i be the location in A we find from the search; if along the way we discovered endpoints for the subarray we are searching that were out of order, stop the search and let i be the midpoint. If A[i] = p and B[i] = 1 return i and we are done. Otherwise, we have just identified the unsorted interval in A that contains p if it is present. Perform a selection query on this interval; choose which side of a pivot on which to recurse based on the value of p (instead of an array position as would be done in a normal selection query). As above, we mark pivots in B as we go; at the end of the recursion we will discover the needed value j. As queries arrive, our algorithm performs the same steps that quicksort would perform, although not necessarily in the same order. If we receive enough queries, we will, over time, perform a quicksort on array A. This also means that our recursive subproblems mimic those from quicksort. 3The search operation is essentially the same as rank on the set of elements stored in the array A. We call it search to avoid confusion with the rank operation defined on bitvectors in Section 5. 3 We have assumed, up to this point, that the last item in an interval is used as the pivot, and a simple linear-time partition algorithm is used. We explore using different pivot and partitioning strategies to obtain various complexity results for online selection and searching. As an easy consequence of more a more precise analysis to follow, we show that the time to perform q select and search queries on an array of n items is O(n log q + q log n). Now, we define terminology for this alternate analysis. 2.1 Terminology For now we assume all queries are selection queries, since search queries are selection queries with a binary search preprocessing phase taking O(log n) comparisons. We explicitly bound the binary search cost in our remaining results. Query and Pivot Sets. Let Q denote a sequence of q selection queries, ordered by time of arrival. Let St = {si} denote the first t queries from Q, sorted by position. We also include s0 = 1 and st+1 = n in St for convenience of notation, since the minimum and maximum are found during preprocessing. Let Pt = {pi} denote the set of k pivots found by the algorithm when processing St, again sorted by position. Note that p1 = 1, pk = n, B[pi] = 1 for all i, and St ⊆ Pt. Pivot Tree, Recursion Depth, and Intervals. The pivots chosen by the algorithm form a binary tree structure, defined as the pivot tree T of the algorithm over time.4 Pivot pi is the parent of pivot pj if, after pi was used to partition an interval, pj was the pivot used to partition either the right or left half of that interval. The root pivot is the pivot used to partition A[2..n− 1] due to preprocessing. The recursion depth, d(pi), of a pivot pi is the length of the path in the pivot tree from pi to the root pivot. All leaves in the pivot tree are also selection queries, but it may be the case that a query is not a leaf. Each pivot was used to partition an interval in A. Let I(pi) denote the interval partitioned by pi (which may be empty), and let I(pi) denote its length. Intervals form a binary tree induced by their pivots. If pi is an ancestor of pj then I(pj) ⊂ I(pi). The recursion depth of an array element is the recursion depth of the smallest interval containing that element, which in turn is the recursion depth of its pivot. := si+1 − si and similarly the pivot gap ∆Pt Gaps and Entropy. Define the query gap ∆St := i pi+1 − pi. Observe that each pivot gap is contained in a smallest interval I(p). One endpoint of this gap is the pivot p of interval I(p), and the other matches one of the endpoints of interval I(p). By telescoping we have Pi ∆St We will analyze the complexity of our algorithms based on the number of element comparisons. The lower bound on the number of comparisons required to answer the selection queries in St is obtained by taking the number of comparisons to sort the entire array, and then subtracting the comparisons needed to sort the query gaps. We use B(St) to denote this lower bound. i =Pj ∆Pt j = n − 1. i B(St) := t Xi=0(cid:16)∆St i (cid:17) log(cid:16)n/(cid:16)∆St i (cid:17)(cid:17) − O(n). Note that B(Sq) ≤ n log q: this upper bound is met when the queries are evenly spaced over the input array A. We can show that the simple algorithm performs O(B(Sq) + q log n) for a sequence Q 4Intuitively, a pivot tree corresponds to a recursion tree, since each node represents one recursive call made during the quickselect algorithm [Hoa61]. 4 of q select and search queries on an array of n elements. We will also make use of the following fact in the paper. Fact 1. For all ǫ > 0, there exists a constant cǫ such that for all x ≥ 4, log log log x < ǫ log x + cǫ. Proof. Since limx→∞(log log log x)/(log x) = 0, there exists a kǫ such that for all x ≥ kǫ, we know that (log log log x)/(log x) < ǫ. Also, we know that in the interval [4, kǫ], the continuous function log log log x − ǫ log x is bounded. Let cǫ = log log log kǫ − 2ǫ, which is a constant. 3 A Lemma on Sorting Entropy Pivot Selection Methods. We say that a pivot selection method is good for the constant c with 1/2 ≤ c < 1 if, for all pairs of pivots pi and pj where pi is an ancestor of pj in the pivot tree, then I(pj) ≤ I(pi) · cd(pj )−d(pi)+O(1). Note that if the median is always chosen as the pivot, we have c = 1/2 and the O(1) term is in fact zero. The pivot selection method of Kaligosi et al. [KMMS05, Lemma 8] is good with c = 15/16. Lemma 1. If the pivot selection method is good as defined above, then B(Pt) = B(St) + O(n). Proof. We sketch the proof and defer the full details to Appendix B. Consider any two consecutive selection queries s and s′, and let ∆ = s′ − s be the gap between them. Let P∆ = (pl, pl+1, . . . , pr) be the pivots in this gap, where pl = s and pr = s′. The lemma follows from the claim that B(P∆) = O(∆), since B(Pt) − B(St) =  k ∆Pt j Xj=0 i − log ∆St t ∆St i n log n − Xi=0 Xi=0 B(P∆St t ) = i = = log ∆Pt j   − n log n − log ∆Pt j k t ∆Pt j Xj=0 O(cid:16)∆St Xi=0 i (cid:17) = O(n). ∆St i log ∆St i ! t Xi=0 We now sketch the proof of our claim, which proves the lemma. There must be a unique pivot pm in P∆ of minimal recursion depth. We split the gap ∆ at pm. We define For brevity, we define Dl =Pm−1 i=0 ∆i and Dr =Pr−1 We consider the proof on the right-hand side Dr, and proof for Dl is similar. Since we use a good pivot selection method, we can bound the total information content of the right-hand side by O(Dr). This leads to the claim, and the proof follows. Details of this proof are in Appendix B. i=m ∆i, giving ∆ = Dl + Dr. Theorem 1 (Online Multiselection). Given an array of n elements, on which we have performed a sequence Q of q online selection and search queries, of which q′ are search, we provide • a randomized online algorithm that performs the queries using B(Sq)+ O(n + q′ log n) expected number of comparisons, and • a deterministic online algorithm that performs the queries using at most 4B(Sq) + O(n + q′ log n) comparisons. 5 Proof. For the randomized algorithm, we use the randomized pivot selection algorithm of Kaligosi et al. [KMMS05, Section 3, Lemma 2].) This algorithm gives a good pivot selection method with c = 1/2 + o(1), and the time to choose the pivot is O(∆3/4) on an interval of length ∆, which is subsumed in the O(n) term in the running time. Each element in an interval participates in one comparison per partition operation. Thus, the total number of comparisons is expected to be the sum of the recursion depths of all elements in the array. This total is easily shown to be B(Pq), and by Lemma 1, the proof is complete. In Appendix A, we describe how to get a good pivot selection method with just 6(log n)3(log ∆)2 samples, instead of O(∆3/4). For the deterministic algorithm, we use the median of each interval as the pivot; the median- finding algorithm of Dor and Zwick [DZ99] gives this to us in under 3∆ comparisons. We add another comparison for the partitioning, to give a count of comparisons per array element of four times the recursion depth. This is at most 4B(Pq), which is no more than 4B(Sq) + O(n) from Lemma 1, and the result follows. 4 Optimal Online Multiselection In this section we prove the following theorem. Theorem 2 (Optimal Online Multiselection). Given an unsorted array A of n elements, we provide a deterministic algorithm that supports a sequence Q of q online selection and search queries, of which q′ are search, using B(Sq)(1 + o(1)) + O(n + q′ log n) comparisons in the worst case. Note that our bounds match those of the offline algorithm of Kaligosi et al. [KMMS05] when q′ = 0 (i.e., there are no search queries). In other words, we provide the first 1-competitive online multiselection algorithm. We explain our proof with three main steps. We first explain our algorithm and how it is different from the algorithm in [KMMS05]. We then bound the number of comparisons from merging by B(Sq)(1+o(1))+O(n), and then we bound the number of comparisons from pivot finding and partitioning by o(B(Sq)) + O(n). 4.1 Algorithm Description and Modifications We briefly describe the deterministic algorithm from Kaligosi et al. [KMMS05]. They begin by creating runs, which are sorted sequences from A of length roughly ℓ = log(B/n). Then, they compute the median m of the median of these sequences and partition the runs based on m. After partitioning, they recurse on the two sets of runs, sending select queries to the appropriate side of the recursion. To maintain the invariant on run length on the recursions, they merge short like-sized runs optimally until all but ℓ of the runs are again of length between ℓ and 2ℓ. We make the following modifications to the deterministic algorithm of Kaligosi et al. [KMMS05]: • The queries are processed online, that is, one at a time, from Q without knowing which queries will follow. To do this, we maintain the bitvector B as described above. • We admit search queries in addition to selection queries; in the analysis we treat them as selection queries, paying O(q′ log n) comparisons to account for binary search. • Since we don't know all of Q at the start, we cannot know the value of B(Sq) in advance. Therefore, we cannot preset a value for ℓ as in Kaligosi et al. [KMMS05]. Instead, we set ℓ locally in an interval I(p) to 1 + ⌊lg(d(p) + 1)⌋. Thus, ℓ starts at 1 at the root of the pivot tree T , and since we use only good pivots, d(p) = O(lg n). (Also, ℓ = log log n + O(1) in the worst case.) We keep track of the recursion depth of pivots, from which it is easy to compute 6 the recursion depth of an interval. Also observe that ℓ can increase by at most one when moving down one recursion level during a selection. • We use a second bitvector R to identify the endpoints of runs within each interval that has not yet been partitioned. The algorithm to perform a selection query is as follows: • As described earlier in this paper, we use bitvector B to identify the interval from which to begin processing. The minimum and maximum are found in preprocessing. • If the current interval has length less than 4ℓ2, we sort the interval to complete the query (setting all elements as pivots). The cost for this case is bounded by Lemma 5. • As is done in [KMMS05], we compute the value of ℓ for the current interval, merge runs so that there is at most one of each length < ℓ, and then use medians of those runs to compute a median-of-medians to use as a pivot. We then partition each run using binary search. We can borrow much of the analysis done in [KMMS05]. We cannot use their work wholesale, because we don't know B in advance. For this reason, we cannot define ℓ as they have, and their algorithm depends heavily on its use. To finish the proof of our theorem, we show how to modify their techniques to handle this complication. 4.2 Merging Kaligosi et al. [KMMS05, Lemmas 5 -- 10] count the comparisons resulting from merging. Lemmas 5, 6, and 7 do not depend on the value of ℓ and so we can use them in our analysis. Lemma 8 shows that the median-of-medians built on runs is a good pivot selection method. Although the proof clearly uses the value of ℓ, its validity does not depend on how large ℓ is; only that there are at least 4ℓ2 items in the interval, which also holds for our algorithm. Lemmas 9 and 10 together will bound the number of comparisons by B(Sq)(1 + o(1)) + O(n) if we can prove Lemma 2, which bounds the information content of runs in intervals that are not yet partitioned. Lemma 2. Let a run r be a sorted sequence of elements from A in a gap ∆Pt length. Then, i , where r is its k Xi=0 Xr∈∆Pt i r lg r = o(B(St)) + O(n). Proof. In a gap of size ∆, ℓ = O(log d) where d the recursion depth of the elements in the gap. we use a good pivot selection method, we know that the recursion depth of every element in This givesPr∈∆ r log r ≤ ∆ log(2l) = O(∆ log log d), since each run has size at most 2ℓ. Because the gap is O(log(n/∆)). Thus, Pk r log r ≤ Pi ∆i log log log(n/∆i). Recall that B(St) = B(Pt) + O(n) =Pi ∆i log(n/∆i) + O(n). Using Fact 1, the proof is complete. i=0Pr∈∆Pt i 4.3 Pivot Finding and Partitioning Now we prove that the cost of computing medians and performing partition requires at most o(B(Sq)) + O(n) comparisons. The algorithm computes the median m of medians of each run at a node v in the pivot tree T . Then, it partitions each run based on m. We bound the number of comparisons at each node v with more than 4ℓ2 elements in Lemmas 3 and 4. We bound the comparison cost for all nodes with fewer elements in Lemma 5. 7 Terminology. Let d be the current depth of the pivot tree T (defined in Section 2.1), and let the root of T have depth d = 0. In tree T , each node v is associated with some interval I(pv) corresponding to some pivot pv. We define ∆v = I(pv) as the number of elements at node v in T . Recall that ℓ = 1 + ⌊log(d + 1)⌋. Let a run be a sorted sequence of elements from A. We define a short run as a run of length less than ℓ. Let βn be the number of comparisons required to compute the exact median for n elements, where β is a constant less than three [DZ99]. Let rs v be the number of short runs at node v, and let rl v be the number of long runs. Lemma 3. The number of comparisons required to find the median m of medians and partition all runs at m for any node v in the pivot tree T is at most β(ℓ− 1) + ℓ log ℓ + β(∆v/ℓ) + (∆v/ℓ) log(2ℓ) comparisons. Proof. We compute the cost (in comparisons) for computing the median of medians. For the rs v ≤ ℓ − 1 short runs, we need at most β(ℓ − 1) comparisons per node. For the rl v ≤ ∆v/ℓ long runs, we need at most β(∆v/ℓ). Now we compute the cost for partitioning each run based on m. We perform binary search on i=1 log i ≤ ℓ log ℓ comparisons per node. For long each run. For short runs, this requires at most Pℓ−1 runs, we need at most (∆v/ℓ) log(2ℓ) comparisons per node. Since our value of ℓ changes at each level of the recursion tree, we will sum the above costs by level. The overall cost in comparisons at level d is at most 2dβℓ + 2dℓ log ℓ + (n/ℓ)β + (n/ℓ) log(2ℓ). We can now prove the following lemma. Lemma 4. The number of comparisons required to find the median of medians and partition over all nodes v in the pivot tree T with at least 4ℓ2 elements is at most o(B(St)) + O(n). Proof. For all levels of the pivot tree up to level ℓ′ ≤ log(B(Pt)/n), the cost is at most log(B(Pt)/n) Xd=1 2dℓ(β + log ℓ) + (n/ℓ)(β + log(2ℓ)). Since ℓ = ⌊log(d+1)⌋+1, the first term of the summation is bounded by (B(Pt)/n) log log(B(Pt)/n) = o(B(Pt)). The second term is easily upper-bounded by n log(B(Pt)/n)(log log log(B(Pt)/n)/ log log(B(Pt)/n)) = o(B(Pt)). Using Lemma 1, the above two bounds are o(B(St)) + O(n). For each level ℓ′ with log(B(Pt)/n) < ℓ′ ≤ log log n + O(1), we need to bound the remaining cost. It is easy to bound each node v's cost by o(∆v), but this is not sufficient -- though we have shown that the total number of comparisons for merging is B(St) + O(n), the number of elements in nodes with ∆v ≥ 4ℓ2 could be ω(B(St)). We bound the overall cost as follows, using the result of Lemma 3. Since node v has ∆v > 4ℓ2 elements, we can rewrite the bounds as O(∆v/ℓ log(2ℓ)). Recall that ℓ = log d + O(1) = log(O(log(n/∆v))) = log log(n/∆v) + O(1), since we use a good pivot selection method. Summing over all nodes, we get Pv (∆v/ℓ) log(2ℓ) ≤ Pv ∆v log(2ℓ) = o (B(Pt)) + O(n), using Fact 1 and recalling that B(Pt) =Pv ∆v log(n/∆v). Finally, using Lemma 1, we arrive at the claimed bound for queries. 8 Now we show that the comparison cost for all nodes v where ∆v ≤ 4ℓ2 is at most o(B(St))+O(n). Lemma 5. For nodes v in the pivot tree T where ∆v ≤ 4ℓ2, the total cost in comparisons for all operations is at most o(B(St)) + O(n). Proof. We observe that nodes with no more than 4ℓ2 elements do not incur any cost in comparisons for median finding and partitioning, unless there is (at least) one associated query within the node. Hence, we focus on nodes with at least one query. Let z = (log log n)2 log log log n + O(1). We sort the elements of any node v with ∆v ≤ 4ℓ2 elements using O(z) comparisons, since ℓ ≤ log log n + O(1). We set each element as a pivot. The total comparison cost over all such nodes is no more than O(tz), where t is the number of queries we have answered so far. If t < n/z, then the above cost is O(n). Otherwise, t ≥ n/z. Then, we know that B(Pt) ≥ (n/z) log(n/z), by Jensen's inequality. (In words, this represents the sort cost of n/z adjacent queries.) Thus, tz ∈ o(B(Pt)). Using Lemma 1, we know that B(Pt) = B(St) + O(n), thus proving the lemma. 5 Optimal Online Dynamic Multiselection In this section, we extend our results for the case of the static array by allowing insertions and deletions of elements in the array, while supporting the selection queries. Recall that we are originally given the unsorted list A. For supporting insert and delete efficiently, we maintain the newly inserted elements in a separate data structure, and mark the deleted elements in A. These insert and delete operations are occasionally merged to make the array up-to-date. Let A′ denote the current array with length n′. We want to support the following two additional operations: • insert(a), which inserts a into A′, and; • delete(i), which deletes the ith (sorted) entry from A′. 5.1 Preliminaries Our solution uses the dynamic bitvector data structure of Hon et al. [HSS03]. This structure supports the following set of operations on a dynamic bitvector V. The rank b(i) operation tells the number of b bits up to the ith position in V. The select b(i) operation gives the position in V of the ith b bit. The insert b(i) operation inserts the bit b in the ith position. The delete(i) operation deletes the bit located in the ith position. The flip(i) operation flips the bit in the ith position. Note that one can determine the ith bit of V by computing rank 1(i) − rank 1(i − 1). (For convenience, we assume that rank b(−1) = 0.) The result of Hon et al. [HSS03, Theorem 1] can be re-stated as follows, for the case of maintaining a dynamic bit vector (the result of [HSS03] is stated for a more general case). Lemma 6 ([HSS03]). Given a bitvector V of length n, there exists a data structure that takes n + o(n) bits and supports rank b and select b in O(logt n) time, and insert , delete and flip in O(t) time, for any parameter t such that (log n)O(1) ≤ t ≤ n. The data structure assumes access to a precomputed table of size nǫ, for any fixed ǫ > 0. The elements in the array A swapped during the queries and insert and delete operations, to create new pivots, and the positions of these pivots are maintained as before using the bitvector B. In addition, we also maintain two bitvectors, each of length n′: (i) an insert bitvector I such that I[i] = 1 if and only if A′[i] is newly inserted, and (ii) a delete bitvector D such that if D[i] = 1, the 9 ith element in A has been deleted. If a newly inserted item is deleted, it is removed from I directly. Both I and D are implemented as instances of the data structure of Lemma 6. We maintain the values of the newly inserted elements in a balanced binary search tree T . The inorder traversal of the nodes of T corresponds to the increasing order of their positions in array A′. We support the following operations on this tree are: (i) given an index i, return the element corresponding to the ith node in the inorder traversal of T , and (ii) insert/delete an element at a given inorder position. By maintaining the subtree sizes of the nodes in T , these operations can be performed in O(log n) time without having to perform any comparisons between the elements. Our preprocessing steps are the same as in the static case. In addition, the bitvectors I and D are each initialized to the bitvector of n 0s. The tree T is initially empty. In addition, after performing A insert and delete operations, we merge all the elements in T with the array A, modify the bitvector B appropriately, and reset the bitvectors I and D (with all zeroes). This increases the amortized cost of the insert and delete operations by O(1), without requiring any additional comparisons. 5.2 Dynamic Online Multiselection We now describe how to support A′.insert (a), A′.delete(i), A′.select (i), and A′.search(a) operations. A′.insert(a). First, we search for the appropriate unsorted interval [ℓ, r] containing a using a binary search on the original (unsorted) array A. Now perform A.search(a) on interval [ℓ, r] (choosing which subinterval to expand based on the insertion key a) until a's exact position j in A is determined. The original array A must have chosen as pivots the elements immediately to its left and right (positions j − 1 and j in array A); hence, one never needs to consider newly-inserted pivots when choosing subintervals. Insert a in sorted order in T among at position I.select 1(j) among all the newly-inserted elements. Calculate j′ = I.select 0(j), and set a's position to j′′ = j′ − D.rank 1(j′). Finally, we update our bitvectors by performing I.insert 1(j′′) and D.insert 0(j′′). Note that, apart from the search operation, all other operations in the insertion procedure do not perform any comparisons between the elements. A′.delete(i). First compute i′ = D.select 0(i). If i′ is newly-inserted (i.e., I[i′] = 1), then remove the node (element) with inorder number I.rank 1(i′) from T . Then perform I.delete(i′) and D.delete(i′). If instead i′ is an older entry, simply perform D.flip(i′). In other words, we mark the position i′ in A as deleted even though the corresponding element may not be in its proper place.5 If I[i] = 1, return the element corresponding to the node with inorder number A′.select(i). I.rank 1(i) in T . Otherwise, compute i′ = I.rank 0(i) − D.rank 1(i), and return A.select(i′)). A′.search(a). First, we search for the appropriate unsorted interval [ℓ, r] containing a using a binary search on the original (unsorted) array A. Then, perform A.search(a) on interval [ℓ, r] until a's exact position j is found. If a appears in array A (which we discover through search), we need to now check whether it has been deleted. We compute j′ = I.select 0(j) and j′′ = j′ − D.rank 1(j′). If D[j′] = 0, return j′′. Otherwise, it is possible that the item has been newly-inserted. Compute p = I.rank 1(j′), which is the number of newly-inserted elements that are less than or equal to a. If T [p] = a, then return j′′; otherwise, return failure. 5If a user wants to delete an item with value a, one could simply search for it first to discover its rank, and then delete it using this function. 10 We show that the above algorithm achieves the following performance (in Appendix C). Theorem 3 (Optimal Online Dynamic Multiselection). Given a dynamic array A′ of n original elements, there exists a dynamic online data structure that can support q = O(n) select, search, insert, and delete operations, of which q′ are search, insert, and delete, we provide a deterministic online algorithm that uses at most B(Sq)(1 + o(1)) + O(n + q′ log n) comparisons. 6 External Online Multiselection Suppose we are given an unsorted array A of length N stored in n = N/B blocks in the external memory. Recall that sorting A in the external memory model requires SortIO(N ) = Θ(n logm n) I/Os. The techniques we use in main memory are not immediately applicable to the external mem- ory model. In the extreme case where we have q = N queries, the internal memory solution would require O(n log2(n/m)) I/Os. This compares poorly to the optimal O(n logm n) I/Os performed by the optimal mergesort algorithm for external memory. As in the case of internal memory, the lower bound on the number of I/Os required to perform a given set of selection queries can be obtained by subtracting the number of I/Os required to sort the elements between the 'query gaps' from the sorting bound. More specifically, let St = {si} be the first t queries from a query set Q, sorted by position, and for 1 ≤ i ≤ t, let ∆St := si+1 − si be the query gaps, as defined in Section 2.1. Then the lower bound on the number of I/Os required to support the queries in St is given by i Bm(St) := n logm n − t Xi=0(cid:16)∆St i /B(cid:17) logm(cid:16)∆St i /B(cid:17) − O(n), where we assume that logm(cid:16)∆St i /B(cid:17) = 0 when ∆St i < mB = M in the above definition. 6.1 Algorithm Achieving O(Bm(Sq)) + O(n) I/Os We now show that our lower bound is asymptotically tight, by describing an O(1)-competitive algorithm. We assume that log N = log n + log B = O(B) -- which allows us to store a pointer to a block of the input using a constant number of blocks. This constraint is a reasonable assumption in practice, and is similar to the word-size assumption transdichotomous word RAM model [FW93]. In addition, the algorithm of Sibeyn [Sib06] only works under this assumption, though this is not explicitly mentioned. We obtain the following result for the external memory model. Theorem 4. Given an unsorted array A occupying n blocks in external memory, we provide a deterministic algorithm that supports a sequence Q of q online selection queries using O(Bm(Sq)) + O(n) I/Os under the condition that log N = O(B). Proof. Our algorithm uses the same approach as the internal memory algorithm, except that it chooses d − 1 pivots at once using Lemma 9. Hence, each node v of the pivot tree T containing ∆v It subdivides its ∆v elements into d partitions. Using elements has a branching factor of d. Lemma 10, we know this requires 2δv + d I/Os, where δv = ∆v/B. We choose d = m/2, which satisfies the constraints for Lemmas 9 -- 10. We also maintain the bitvector V of length N , as described before. For each A.select(i) query, we access position V[i]. If V[i] = 1, return A[i], else scan left and right from the ith position to find the endpoints of this interval Ii using Ii/B I/Os. The analysis follows directly from the internal algorithm. We extend this result to also support search, insert, and delete operations in Appendix D. 11 References [BF03] G. Brodal and R. Fagerberg. On the limits of cache-obliviousness. In Proceedings of the ACM Symposium on Theory of Computing, pages -- , 2003. [BFP+73] Manuel Blum, Robert W. Floyd, Vaughan R. Pratt, Ronald L. Rivest, and Robert En- dre Tarjan. Time bounds for selection. J. Comput. Syst. Sci., 7(4):448 -- 461, 1973. [CFJ+09] [DM81] [DZ99] [FW93] Jean Cardinal, Samuel Fiorini, Gwenael Joret, Raphael M. Jungers, and J. Ian Munro. An efficient algorithm for partial order production. In Proceedings of the 41st annual ACM symposium on Theory of computing, STOC '09, pages 93 -- 100, New York, NY, USA, 2009. ACM. David P. Dobkin and J. Ian Munro. Optimal time minimal space selection algorithms. J. ACM, 28(3):454 -- 461, 1981. Dorit Dor and Uri Zwick. Selecting the median. SIAM J. Comput., 28(5):1722 -- 1758, 1999. Michael L. Fredman and Dan E. Willard. Surpassing the information theoretic bound with fusion trees. J. Comput. Syst. Sci., 47(3):424 -- 436, 1993. [Hoa61] C. A. R. Hoare. Algorithm 65: find. Commun. ACM, 4(7):321 -- 322, 1961. [HSS03] Wing-Kai Hon, Kunihiko Sadakane, and Wing-Kin Sung. Succinct data structures for searchable partial sums. In Proceedings of the International Symposium on Algorithms and Computation, pages 505 -- 516, 2003. [JM10] Rosa M. Jim´enez and Conrado Mart´ınez. Interval sorting. In Proceedings of the In- ternational Colloquium on Automata, Languages, and Programming, pages 238 -- 249, 2010. [KMMS05] Kanela Kaligosi, Kurt Mehlhorn, J. Ian Munro, and Peter Sanders. Towards optimal multiple selection. In ICALP, pages 103 -- 114, 2005. [MP80] [Pro95] J. Ian Munro and Mike Paterson. Selection and sorting with limited storage. Theor. Comput. Sci., 12:315 -- 323, 1980. Helmut Prodinger. Multiple quickselect - hoare's find algorithm for several elements. Inf. Process. Lett., 56(3):123 -- 129, 1995. [Sib06] Jop F. Sibeyn. External selection. J. Algorithms, 58(2):104 -- 117, 2006. [SPP76] Arnold Schonhage, Mike Paterson, and Nicholas Pippenger. Finding the median. J. Comput. Syst. Sci., 13(2):184 -- 199, 1976. 12 A Randomized Algorithm Our pivot-choosing method is simple and randomized. We choose 2m elements at random from an interval of size ∆, sort them (or use a median-finding algorithm) to find the median, and use that for our pivot. We wish to set values of m and t such that two events happen: • At least 2t elements are chosen in an interval of size 2∆/ log ∆ about the median of the interval. • Between m − t and m + t elements are chosen less than the median. • Between m − t and m + t elements are chosen larger than the median. If we can show that all events happen with probability 1 − O(1/n2), then we end up with the median of our 2m elements being a pivot at position 1/2(1 + O(1/ log ∆)), which is a good pivot. Note that the last two events are mirror images of one another, and so have the same probability of occurring. First Event. This is the simpler of the two to estimate. A randomly chosen element fails If we to land in the middle interval with probability 1 − 2/ log ∆ = exp[−2/ log ∆(1 + o(1))]. choose at least (1.1) log ∆ log n elements, all fail to land in this middle interval with probability (1 − 2/ log ∆)(1.1) log ∆ log n = exp[−(2.2) log n(1 + o(1))] = O(1/n2). Since we need 2t elements in the interval, it suffices for 2m ≥ (2.2)t log ∆ log n, or m ≥ (1.1)t log ∆ log n. Second (and third) Event. We need a bound on the sum of the first k binomial coefficients. The following bound and proof are attributed to Lovasz: Lemma 7. Let 0 ≤ k < m and define c :=(cid:0) 2m Xi=0(cid:18)2m k+1(cid:1)/(cid:0)2m i (cid:19) < m(cid:1). Then c 2 · 22m. k Proof. Write k + 1 = m − t. Define A := B := By the definition of c we have m−t−1 Xi=0 (cid:18)2m i (cid:19) Xi=m−t(cid:18)2m i (cid:19) m and, because the growth rate of one binomial coefficient to the next slows as we approach (cid:0)2m m(cid:1), we have (cid:18) 2m m − t(cid:19) = c(cid:18)2m m(cid:19) (cid:18) 2m m − t − 1(cid:19) < c(cid:18) 2m m − 1(cid:19) (cid:18) 2m m − t − j(cid:19) < c(cid:18) 2m m − j(cid:19) and thus for 0 ≤ j ≤ m − t. 13 Thus it follows that the sum of any t consecutive binomial coefficients is less than c times the sum of the next t coefficients as long as we stay on the left-hand side of Pascal's triangle. Thus A < cB + c2B + c3B + ··· < c 1−c B. We also have A + B ≤ 22m−1. Combining these we have A < Solving for A completes the proof. We then bound c 1 − c B ≤ c c − 1(cid:0)22m−1 − A(cid:1) . This can be derived from Stirling's formula and Taylor series estimates for the exponential and logarithm functions. We then obtain that Lemma 8. Let 0 ≤ t < m. Then (cid:0) 2m m−t(cid:1) m(cid:1) ≤ e−t2/(m+t). (cid:0)2m m−t−1 Xi=0 (cid:18)2m i (cid:19) < 22m−1 · e−t2/(m+t). Since choosing an element from an interval at random and observing if it falls before or after the median is an event of probability 1/2, the event of choosing 2m elements and having less than m − t fall below the median occurs with probability at most Xi=0 (cid:18)2m i (cid:19). By our lemma above, this is bounded by (1/2) exp[−t2/(m + t)]. Thus, the probability there are between m−t and m+t elements below the median is at least 1−exp[−t2/(m+t)] by the symmetry of Pascal's triangle. To obtain 1− O(1/n2) we need t2/(m + t) > 2 log n, or t ≥ √2m log n(1 + o(1). Using our lower bound for m in terms of t above, we conclude that m = 6(log n)3(log ∆)2 and 2−2m m−t−1 t = 4(log n)2 log ∆ meet our needs. Theorem 5. Given a list of elements of length ∆ < n, with ∆ at least 6(log n)3(log ∆)2, with probability at least 1 − O(1/n2), if we sample 6(log n)3(log ∆)2 of the ∆ elements uniformly at random, then median of the sample falls in position ∆/2 ± ∆/ log ∆ in the original list. B Proof of Lemma 1 (Entropy Lemma) Proof. Consider any two consecutive selection queries s and s′, and let ∆ = s′ − s be the gap between them. Let P∆ = (pl, pl+1, . . . , pr) be the pivots in this gap, where pl = s and pr = s′. The lemma follows from the claim that B(P∆) = O(∆), since j   − n log n − B(Pt) − B(St) =  i ! Xi=0 log ∆Pt log ∆St ∆Pt j ∆St i k k t Xj=0 i − log ∆St t ∆St i n log n − Xi=0 Xi=0 B(P∆St t i t ∆Pt j Xj=0 O(cid:16)∆St Xi=0 ) = = = log ∆Pt j i (cid:17) = O(n). 14 We now proceed to prove our claim. There must be a unique pivot in P∆ of minimal recursion depth. Any pair of pivots with the same recursion depth must have a common ancestor, and this ancestor must lie between the pair. This ancestor is in P∆ and it has smaller recursion depth than the pair. Let pm denote the pivot of minimum depth. (Note that pm = s or pm = s′ are possible.) As before, define the gaps ∆i = pi+1 − pi for l ≤ i < r. We split the gap ∆ at pm. We address the right side first, and the argument for the left side is similar. The sequence d(pm), d(pm+1), . . . , d(pr−1) must be strictly increasing. Otherwise, one of these pivots must be a leaf in the pivot tree, and hence a query, which is a contradiction. Now consider I(pm+1). This interval must have pm as its left endpoint, due to its smaller recursion depth. Its right endpoint must have recursion depth shallower than pm+1, and hence it contains all pivots up to and including pr. This means I(pi) ⊂ I(pm+1) for m + 1 < i < r, ∆i = pi+1 − pi < I(pi) for m + 1 < i < r, and it means that ∆ ≤ I(pm−1) + I(pm+1). For brevity, we define Dl = Pm−1 i=m ∆i, giving ∆ = Dl + Dr, and further Dl ≤ I(pm−1), Dr ≤ I(pm+1). Let us also define αi := Dr/∆i for m ≤ i < r. We have i=0 ∆i and Dr = Pr−1 Dr log Dr − r−1 Xi=m ∆i log ∆i = r−1 Xi=m ∆i log(Dr/∆i) = Dr (log αi)/αi. r−1 Xi=m This quantity can be bounded from above with a lower bound on αi. Write Dr = b · I(pm+1) for a constant b with 0 < b ≤ 1. So we have αi = Dr/∆i > Dr/I(pi) = bI(pm+1)/I(pi). Since we are using a good pivot selection method, we get the bound I(pi) ≤ I(pm+1) · cd(pi)−d(pm+1)+O(1). Plugging in gives us αi > b · c−d(pi)+d(pm+1)+O(1) ≥ b · cm+1−i+O(1). The last inequality used the fact that the recursion depths must be strictly increasing. Then log αi αi ≤ r−1 Xi=m r−1−m Xj=0 log(bcj+O(1)) bcj+O(1) = O(1). And thus Dr log Dr − A similar argument on the left side gives Dl log Dl − r−1 Xi=m m−1 Xi=0 ∆i log ∆i = O(Dr). ∆i log ∆i = O(Dl). Finally, ∆ log ∆ − Dr log Dr − Dl log Dl = O(∆), and the proof is complete. C Proof of Theorem 3 Let A′ denote the current array of length n′, after a sequence of queries and insertions. Let Q be the sequence of q selection operations performed (either directly or indirectly through other operations) 15 on A′, ordered by time of arrival. Let Sq be the queries of Q, ordered by position. We now analyze the number of comparisons performed by a sequence of queries and insert and delete operations. We consider the case when the number of insert and delete operations is less than n. In other If q′ is the number of words, we are between two rebuildings of our dynamic data structure. search, insert, and delete operations in the sequence, then we perform O(q′ log n′) comparisons to perform the required searches. Note that our algorithm does not perform any comparisons for delete(i) operations, until some other query is in the same interval as i. The deleted element will participate in the other costs (merging, pivot-finding, and partitioning) for these other queries, but its contribution can be bounded by O(log n), which we have as a credit. Since a delete operation does not perform any additional comparisons beyond those needed to perform a search, we assume that all the updates are insertions in the rest of this section. Since each inserted element becomes a pivot immediately, it does not contribute to the comparison cost of any other select operation. Also, note that in the algorithm of Theorem 2, no pivot is part of a run and hence cannot effect the choice of any future pivot. Since Q is essentially a set of q selection queries, we can bound its total comparison cost for selection queries by Theorem 2, which gives a bound of B(Sq)(1 + o(1)) + O(n). This proves the theorem. D External Online Multiselection Suppose we are given an unsorted array A of length N stored in n = N/B blocks in the external memory. Recall that sorting A in the external memory model requires SortIO(N ) = Θ(n logm n) I/Os. The techniques we use in main memory are not immediately applicable to the external mem- ory model. In the extreme case where we have q = N queries, the internal memory solution would require O(n log2(n/m)) I/Os. This compares poorly to the optimal O(n logm n) I/Os performed by the optimal mergesort algorithm for external memory. D.1 A Lower Bound for Multiselect in External Memory As in the case of internal memory, the lower bound on the number of I/Os required to perform a given set of selection queries can be obtained by subtracting the number of I/Os required to sort the elements between the 'query gaps' from the sorting bound. More specifically, let St = {si} be the first t queries from a query set Q, sorted by position, and for 1 ≤ i ≤ t, let ∆St := si+1 − si be the query gaps, as defined in Section 2.1. Then the lower bound on the number of I/Os required to support the queries in St is given by i Bm(St) := n logm n − t Xi=0(cid:16)∆St i /B(cid:17) logm(cid:16)∆St i /B(cid:17) − O(n), where we assume that logm(cid:16)∆St i /B(cid:17) = 0 when ∆St i < mB = M in the above definition. D.2 Partitioning in External Memory The main difference between our algorithms for internal and external memory is the partitioning procedure. In the internal memory algorithm, we partition the values according to a single pivot, recursing on the half that contains the answer. oIn the external memory algorithm, we modify this binary partition to a d-way partition, for some d = Θ(m), by finding a sample of d "roughly 16 equidistant elements." The next two lemmas describe how to find such a sample, and then partition the range of values into d + 1 subranges with respect to the sample. Lemma 9. Given an unsorted array A containing N elements in external memory and an integer parameter d < M/ log N , one can compute a sample of size d from A using n = N/B I/Os, such that the rank of the jth value in this sample is within [j(N/d) − d, (j + log(N/d) − 1)N/d]. Proof. Given an unordered sequence of N elements (stored in a read-only memory) and an addi- tional working space of size S = Ω((log N )2), Munro and Paterson [MP80] showed how to compute a "reasonably well-spaced sample" of size s ≤ S/ log N , in a single sequential scan over the se- quence. This well-spaced sample has the property that the rank of the jth element of the sample among the initial sequence of elements is between (jN/s) − 1 and (j + log(N/s) − 1)N/s. The algorithm only reads the input sequence from left to right, and it does not perform any random accesses to the sequence. Note that we have access to an unbounded working space in the external memory at the cost of additional I/Os. If M = o((log N )2), we can use the space on the disk as temporary working space. Hence, it is easy to see that this algorithm can be translated to the external memory model with S = max{M, (log N )2}, which gives the result stated. Lemma 10. Given an unsorted array A occupying n pages of external memory and d < M/(2B) sample elements stored in main memory, there is an algorithm to partition A by those values in 2n + d I/Os. Proof. The algorithm scans the data, keeping one input block and d + 1 output blocks in main memory. An output block is written to external memory when it is full, or when the scan is complete. The algorithm performs n I/O to read the input, and at most n + d + 1 I/Os to write the output into d + 1 partitions. D.3 Algorithm Achieving O(Bm(Sq)) + O(n) I/Os We now show that our lower bound is asymptotically tight, by describing an O(1)-competitive algorithm. We assume that log N = log n + log B = O(B) -- which allows us to store a pointer to a block of the input using a constant number of blocks. This constraint is a reasonable assumption in practice, and is similar to the word-size assumption transdichotomous word RAM model [FW93]. In addition, the algorithm of Sibeyn [Sib06] only works under this assumption, though this is not explicitly mentioned. Theorem 6. Given an unsorted array A occupying n blocks in external memory, we provide a deterministic algorithm that supports a sequence Q of q online selection queries using O(Bm(Sq)) + O(n) I/Os under the condition that log N = O(B). Proof. Our algorithm uses the same approach as the internal memory algorithm, except that it chooses d − 1 pivots at once using Lemma 9. Hence, each node v of the pivot tree T containing ∆v elements has a branching factor of d. It subdivides its ∆v elements into d partitions. Using Lemma 10, we know this requires 2δv + d I/Os, where δv = ∆v/B. We choose d = m/2, which satisfies the constraints for Lemmas 9 -- 10. We also maintain the bitvector V of length N , as described before. For each A.select(i) query, we access position V[i]. If V[i] = 1, return A[i], else scan left and right from the ith position to find the endpoints of this interval Ii using Ii/B I/Os. The analysis follows directly from the internal algorithm. To add searches, we cannot afford to spend log n time performing binary search on the blocks of B. To handle this case, we build a B-tree T maintaining all pivots from A. (During preprocessing, 17 we insert A[1] and A[n] into T .) The B-tree T will be used to support search queries in O(logB N ) I/Os instead of O(log N ) I/Os. We modify the proof of Theorem 6 to obtain the following: Corollary 1. Given an unsorted array A occupying n blocks in external memory, we provide a deterministic algorithm that supports a sequence Q of q online selection and search queries using O(Bm(Sq)) + O(min{qm, N} logB N ) + O(n) I/Os under the condition that log N = O(B). Combining the ideas from Corollary 1 and Theorem 3, we can dynamize the above algorithm. Corollary 2. Given an unsorted array A occupying n blocks in external memory, we provide a deter- ministic algorithm that supports a sequence Q of q online select, search, insert, and deleteoperations using O(Bm(Sq)) + O(min{qm, N} logB N ) + O(n) I/Os under the condition that log N = O(B). 18
1507.04299
1
1507
2015-07-15T17:02:20
Tight Lower Bounds for Data-Dependent Locality-Sensitive Hashing
[ "cs.DS", "cs.CC", "cs.CG" ]
We prove a tight lower bound for the exponent $\rho$ for data-dependent Locality-Sensitive Hashing schemes, recently used to design efficient solutions for the $c$-approximate nearest neighbor search. In particular, our lower bound matches the bound of $\rho\le \frac{1}{2c-1}+o(1)$ for the $\ell_1$ space, obtained via the recent algorithm from [Andoni-Razenshteyn, STOC'15]. In recent years it emerged that data-dependent hashing is strictly superior to the classical Locality-Sensitive Hashing, when the hash function is data-independent. In the latter setting, the best exponent has been already known: for the $\ell_1$ space, the tight bound is $\rho=1/c$, with the upper bound from [Indyk-Motwani, STOC'98] and the matching lower bound from [O'Donnell-Wu-Zhou, ITCS'11]. We prove that, even if the hashing is data-dependent, it must hold that $\rho\ge \frac{1}{2c-1}-o(1)$. To prove the result, we need to formalize the exact notion of data-dependent hashing that also captures the complexity of the hash functions (in addition to their collision properties). Without restricting such complexity, we would allow for obviously infeasible solutions such as the Voronoi diagram of a dataset. To preclude such solutions, we require our hash functions to be succinct. This condition is satisfied by all the known algorithmic results.
cs.DS
cs
Tight Lower Bounds for Data-Dependent Locality-Sensitive Hashing Alexandr Andoni∗ Columbia University Ilya Razenshteyn CSAIL MIT July 16, 2015 Abstract We prove a tight lower bound for the exponent ρ for data-dependent Locality- Sensitive Hashing schemes, recently used to design efficient solutions for the c-approximate nearest neighbor search. In particular, our lower bound matches the bound of ρ ≤ 2c−1 +o(1) for the ℓ1 space, obtained via the recent algorithm from [Andoni-Razenshteyn, STOC’15]. 1 In recent years it emerged that data-dependent hashing is strictly superior to the classical Locality-Sensitive Hashing, when the hash function is data-independent. In the latter setting, the best exponent has been already known: for the ℓ1 space, the tight bound is ρ = 1/c, with the upper bound from [Indyk-Motwani, STOC’98] and the matching lower bound from [O’Donnell-Wu-Zhou, ITCS’11]. 1 We prove that, even if the hashing is data-dependent, it must hold that ρ ≥ 2c−1−o(1). To prove the result, we need to formalize the exact notion of data-dependent hashing that also captures the complexity of the hash functions (in addition to their collision properties). Without restricting such complexity, we would allow for obvi- ously infeasible solutions such as the Voronoi diagram of a dataset. To preclude such solutions, we require our hash functions to be succinct. This condition is satisfied by all the known algorithmic results. 5 1 0 2 l u J 5 1 ] S D . s c [ 1 v 9 9 2 4 0 . 7 0 5 1 : v i X r a ∗Work done in part while the author was at the Simons Institute for the Theory of Computing, Berkeley University. 1 Introduction We study lower bounds for the high-dimensional nearest neighbor search problem, which is a problem of major importance in several areas, such as databases, data mining, information retrieval, computer vision, computational geometry, signal processing, etc. This problem suffers from the “curse of dimensionality” phenomenon: either space or query time are exponential in the dimension d. To escape this curse, researchers proposed approximation algorithms for the problem. In the (c, r)-approximate near neighbor problem, the data structure may return any data point whose distance from the query is at most cr, for an approximation factor c > 1 (provided that there exists a data point within distance r from the query). Many approximation algorithms are known for this problem: e.g., see surveys [Sam06, AI08, And09, WSSJ14]. An influential algorithmic technique for the approximate near neighbor search (ANN) is the Locality Sensitive Hashing (LSH) [IM98, HPIM12]. The main idea is to hash the points so that the probability of collision is much higher for points that are close to each other (at distance ≤ r) than for those which are far apart (at distance > cr). Given such hash functions, one can retrieve near neighbors by hashing the query point and retrieving elements stored in buckets containing that point. If the probability of collision is at least p1 for the close points and at most p2 for the far points, the algorithm solves the (c, r)-ANN using essentially O(n1+ρ/p1) extra space and O(dnρ/p1) query time, where ρ = log(1/p1) log(1/p2) [HPIM12]. The value of the exponent ρ thus determines the “quality” of the LSH families used. Consequently, a lot of work focused on understanding the best possible value ρ for LSH, including the sequence of upper bounds [IM98, DIIM04, AI06] and lower bounds [MNP07, OWZ11]. Overall, they established the precise bounds for the best value of ρ: for ℓ1 the tight bound is ρ = 1 cp ± o(1). Surprisingly, it turns out there exist more efficient ANN data structures, which step out- side the LSH framework. Specifically, [AINR14, AR15] design algorithms using the concept c ± o(1). In general, for ℓp, where 1 ≤ p ≤ 2, the tight bound is ρ = 1 of data-dependent hashing, which is a randomized hash family that itself adapts to the actual given dataset. In particular, the result of [AR15] obtains an exponent ρ = 1 2cp−1 + o(1) for the ℓp space, thus improving upon the best possible LSH exponent essentially by a factor of 2 for both ℓ1 and ℓ2 spaces. Our result. Here we prove that the exponent ρ = 1 2cp−1 from [AR15] is essentially optimal even for data-dependent hashing, and cannot be improved upon. Stating the precise theorem requires introducing the precise model for the lower bound, which we accomplish below. For now, we state our main theorem informally: 1 Theorem 1.1 (Main, informal). Any data-dependent hashing scheme for ℓ1 that achieves probabilities p1 and p2 must satisfy ρ = log 1/p1 log 1/p2 ≥ 1 2c − 1 − o(1), as long as the description complexity of the hash functions is sufficiently small. An immediate consequence is that ρ ≥ 1 2cp−1 − o(1) for all ℓp with 1 ≤ p ≤ 2, using the embedding from [LLR95]. 1.1 Lower Bound Model To state the precise theorem, we need to formally describe what is data-dependent hashing. First, we state the definition of (data-independent) LSH, as well as define LSH for a fixed dataset P . Definition 1.2 (Locality-Sensitive Hashing). We say that a hash family H over {0, 1}d is (r1, r2, p1, p2)-sensitive, if for every u, v ∈ {0, 1}d one has: • if ku − vk1 ≤ r1, then Pr • if ku − vk1 > r2, then Pr We now refine the notion of data-independent LSH, where we require the distribution to [h(u) = h(v)] ≥ p1; [h(u) = h(v)] ≤ p2. h∼H h∼H work only for a particular dataset P . Definition 1.3 (LSH for a dataset P ). A hash family H over {0, 1}d is said to be (r1, r2, p1, p2)- sensitive for a dataset P ⊆ {0, 1}d, if: • for every v ∈ {0, 1}d and every u ∈ P with ku − vk1 ≤ r1 one has Pr h∼H [h(u) = h(v)] ≥ p1; • Pr h∼H u,v∼P [h(u) = h(v) and ku − vk1 > r2] ≤ p2. Note that the second definition is less stringent than the first one: in fact, if all the points in a dataset are at distance more than r2 from each other, then an LSH family H is also LSH for P , but not necessarily vice versa! Furthermore, in the second definition, we require the second property to hold only on average (in contrast to every point as in the first definition). This aspect means that, while Definition 1.3 is certainly necessary for an ANN data structure, it is not obviously sufficient. Indeed, the algorithm from [AR15] requires 2 proving additional properties of their partitioning scheme, and in particular analyzes triples of points. Since here we focus on lower bounds, this aspect will not be important. We are now ready to introduce data-dependent hashing. Intuitively, a data-dependent hashing scheme is one where we Data-dependent hashing. can pick the family H as a function of P , and thus be sensitive for P . An obvious solution would hence be to choose H to consist of a single hash function h which is just the Voronoi diagram of the dataset P : it will be (r, cr, 1, 0)-sensitive for P and hence ρ = 0. However this does not yield a good data strcture for ANN since evaluating such a hash function on a query point q is as hard as the original problem! Hence, ideally, our lower bound model would require that the hash function is compu- tationally efficient to evaluate. We do not know how to formulate such a condition which would not make the question as hard as circuit lower bounds or high cell-probe lower bounds, which would be well beyond the scope of this paper. Instead, we introduce a condition on the hash family that can be roughly summarized as “hash functions from the family are succinct”. For a precise definition and discussion see below. For now, let us point out that all the known algorithmic results satisfy this condition. Finally, we are ready to state the main result formally. Theorem 1.4 (Main theorem, full). Fix the approximation c > 1 to be a constant. Suppose the dataset P lives in the Hamming space {0, 1}d, where the dataset size n = P is such that d = ω(log n) as n tends to infinity. There exist distance thresholds r and (c − o(1))r with the following property. Suppose there exist T hash functions {hi}1≤i≤T over {0, 1}d such that for every n-point dataset P there exists a distribution HP over hi’s such that the corresponding hash family is (r, (c − o(1))r, p1, p2)-sensitive for P , where 0 < p1, p2 < 0.99. For any such data-dependent scheme it must either hold that ρ = log 1/p1 log 1/p2 ≥ 1 2c−1 − o(1) or that log T p1 ≥ n1−o(1). Interpreting Theorem 1.4 Let us explain the conditions and the conclusions of Theo- rem 1.4 in more detail. We start by interpreting the conclusions. As explained above, the bound ρ = log 1/p1 log 1/p2 ≥ 2c−1 −o(1) for any scheme that 1 1 2c−1 − o(1) directly implies the lower bound on the query time n is based on data-dependent hashing. The second bound log T p1 ≥ n1−o(1) is a little bit more mysterious. Let us now explain what it means precisely. The quantity log T can be interpreted as the description complexity of a hash function sampled from the family. At the same time, if we use a family with collision probability p1 for close points, we need at least 1/p1 hash tables to achieve constant 3 probability of success. Since in each hash table we evaluate at least one hash function, the quantity log T can be interpreted as the lower bound for the total space occupied by hash p1 functions we evaluate during each query. In all known constructions of (data-independent or data-dependent) LSH families [IM98, DIIM04, AI06, TT07, AINR14, AR15] the evaluation time of a single hash function is comparable to the space it occupies (for discussion regarding why is it true for [AR15], see Appendix A), thus, under this assumption, we can not achieve query time n1−Ω(1), unless ρ ≥ 1 2c−1 − o(1). On the other hand, we can achieve ρ = 0 by considering a data-dependent hash family that consists only of the Voronoi diagram of a dataset (trivially, p1 = 1 and p2 = 0 for this case), thus the conclusion log T p1 ≥ n1−o(1) can not be omitted in general1. Note that the “Voronoi diagram family” is very slow to evaluate: to locate a point we need to solve an instance of exact Nearest Neighbor Search, that is unlikely to be possible to do in strongly sublinear time. Thus, this family satisfies the above assumption “evaluation time is comparable to the space”. We now turn to interpreting the conditions. We require that d = ω(log n)2. We conjecture that this requirement is necessary and for d = O(log n) there is an LSH family that gives a better value of ρ (the improvement, of course, would depend on the hidden constant in the expression d = O(log n)). Moreover, if one steps outside the pure data-dependent LSH framework, in a recent paper [BDGL15] an improved data structure for ANN for the case d = O(log n) is presented, which achieves an improvement similar to what we conjectured above. 1.2 Techniques and Related Work There are two components to our lower bound, i.e., Theorem 1.4. The first component is a lower bound for data-independent LSH for a random dataset. We show that in this case, we must have ρ ≥ 1 2c−1 − o(1). This is in contrast to the lower bound of [OWZ11], who achieve a higher lower bound but for the case when the (far) points are correlated. Our lower bound is closer in spirit to [MNP07], who also consider the case when the far points are random uncorrelated. In fact, this component is a strengthening of the lower bound from [MNP07], and is based crucially on an inequality proved there. We mention that, in [Dub10], Dubiner has also considered the setting of a random dataset for a related problem—finding the closest pair in a given dataset P . Dubiner sets up a certain related “bucketing” model, in which he conjectures the lower bound, which would imply a 1For the Voronoi diagram, log T ≥ n, since to specify it, one needs at least n bits. 2When ANN for the general dimension d is being solved, one usually first performs some form of the dimensionality reduction [JL84, KOR00, DG03]. Since at this stage we do not want distances to be distorted by a factor more than 1 + o(1), the target dimension is precisely ω(log n). So, the assumption d = ω(log n) in Theorem 1.4 in some sense captures a truly high-dimensional case. 4 2c−1 lower bound for data-independent LSH for a random set. Dubiner verifies the ρ ≥ 1 conjecture computationally and claims it is proved in a different manuscript.3 2c2−1 − o(1) follows from a recent work [AIK+15]. We also point out that, for the ℓ2 case, the optimal data-independent lower bound ρ ≥ 1 In fact, it shows almost exact trade-off between p1 and p2 (not only the lower bound on ρ = log(1/p1) log(1/p2)). Unfortunately, the techniques there are really tailored to the Euclidean case (in particular, a powerful isoperi- metric inequality of Feige and Schechtman is used [FS02]) and it is unclear how to extend it to ℓ1, as well as, more generally, to ℓp for 1 ≤ p < 2. Our second component focuses on the data-dependent aspect of the lower bound. In particular, we prove that if there exists a data-dependent hashing scheme for a random dataset with a better ρ, then in fact there is also a data-independent such hashing scheme. To accomplish this, we consider the “empirical” average p1 and p2 for a random dataset, and prove it is close to the average p1 and p2, for which we can deduce a lower bound from the first component. In terms of related work, we also must mention the papers of [PTW08, PTW10], who prove cell-probe lower bounds for the same problem of ANN. In particular, their work utilizes the lower bound of [MNP07] as well. Their results are however incomparable to our results: while their results are unconditional, our model allows us to prove a much higher lower bound, in particular matching the best algorithms. 2 Data-independent Lower Bound In this section we prove the first component of Theorem 1.4. Overall we show a lower bound of ρ ≥ 1 2c−1 + o(1) for data-independent hash families for random datasets. Our proof is a strengthening of [MNP07]. The final statement appears as Corollary 2.7. In the second component, we will use a somewhat stronger statement, Lemma 2.6). For u ∈ {0, 1}d and non-negative integer k define a random variable Wk(u) distributed over {0, 1}d to be the resulting point of the standard random walk of length k that starts in u (at each step we flip a random coordinate). We build on the following inequality from [MNP07] that is proved using Fourier analysis on {0, 1}d. Lemma 2.1 ([MNP07]). For every hash function h : {0, 1}d → Z and every odd positive 3This manuscript does not appear to be available at the moment of writing of the present paper. 5 integer k one has: Pr u∼{0,1}d v∼Wk(u) [h(u) = h(u)] ≤ Pr u,v∼{0,1}d [h(u) = h(u)] exp(2k/d)−1 exp(2k/d)+1 . The above inequality can be thought of as a lower bound on ρ already. In particular, the left-hand-side quantity is probability of collision of a point and a point generated via a random walk of length k from it. The right-hand side corresponds to collision of random independent points, which are usually at distance d/2. One already obtain a lower bound on ρ by considering k = d/2c. To strengthen the lower bound of [MNP07], we analyze carefully the distance between the endpoints of a random walk in the hypercube. In particular the next (somewhat folklore) lemmas show that this distance is somewhat smaller than the (trivial) upper bound of k. Denote Xk the distance kWk(u) − uk1. Note that the distribution of Xk does not depend on a particular starting point u. Lemma 2.2. For every k one has E[Xk] = d 2 · 1 −(cid:18)1 − 2 d(cid:19)k! . Proof. We have that E[Xk Xk−1 = t] = Pr[Xk = t − 1] · (t − 1) + Pr[Xk = t + 1] · (t + 1) t d(cid:19) · (t + 1) =(cid:18)1 − 2 d(cid:19) · t + 1. = t d · (t − 1) +(cid:18)1 − d(cid:19) · E[Xk−1] + 1. 2 Thus, E[Xk] =(cid:18)1 − Since E[X0] = 0, we obtain that E[Xk] = k−1Xi=0(cid:18)1 − 2 d(cid:19)i = d 2 · 1 −(cid:18)1 − 2 d(cid:19)k! . We can now prove that the value of Xk indeed concentrates well around the expectation, using concentration inequalities. 6 Lemma 2.3. For every k and every t > 0 one has PrhXk ≥ E[Xk] + t · √ki ≤ e−t2/4. Proof. For t ≥ 1 define Yt to be the index of the coordinate that got flipped at time t. Obviously, we have that Xk is a (deterministic) function of Y1, . . . Yk. Furthermore, changing one Yt changes Xk by at most 2. Hence we can apply the McDiarmid’s inequality to Xk = f (Y1, . . . Yk): Theorem 2.4 (McDiarmid’s inequality). Let Y1, . . . Yk be independent random variables and X = f (Y1, . . . Yk) such that changing variable Yt only changes the value by at most ct. Then we have that Hence we obtain that Pr[X ≥ E [X] + ε] ≤ exp − Pk Pr [Xk ≥ E[Xk] + ε] ≤ exp − ε2 i=1 c2 i! . ε2 4k! . Substituting ε = t · √k, we get the result. Note that choosing k ≈ d c−1 will mean that distance Xk = kWk(u) − uk1 is now around d/2c, i.e., we can actually use random walks longer than the ones considered in Indeed, from Lemma 2.2 and Lemma 2.3 one can immediately conclude the [MNP07]. 2 · ln c following corollary. Corollary 2.5. Let c > 1 be a fixed constant. Suppose that γ = γ(d) > 0 is such that γ = o(1) as d → ∞. Then, there exists α = α(d) such that c − 1 − oc,γ(1) 2c# ≤ 2−γ·d. 1 2 · ln Pr"Xα·d > that satisfies the following: α(d) = c d We are now ready to prove the main lemma of this section, which will be used in the later section on data-dependent hashing. We need to introduce two more definitions. We define “average p1” as: ζ(c, d, α, h) := Pr u∼{0,1}d v∼Wα·d(u) "h(u) = h(v)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)ku − vk1 ≤ d 2c# 7 for c > 1, positive integer d, α > 0 and a hash function h : {0, 1}d → Z. Similarly, we define the “average p2” as η(d, β, h) := Pr u,v∼{0,1}d(cid:20)h(u) = h(v),ku − vk1 >(cid:18)1 for positive integer d, β > 0 and a hash function h : {0, 1}d → Z. Lemma 2.6. Let c > 1 be a fixed constant. Suppose that γ = γ(d) > 0 is such that γ = o(1) as d → ∞. Then, there exist α = α(d), β = β(d) and ρ = ρ(d) such that: 2 − β(cid:19) · d(cid:21) α = 1 2 · ln β = oγ(1), c c − 1 − oc,γ(1), ρ = 1 2c − 1 − oc,γ(1) as d → ∞ such that, for every d and every hash function h : {0, 1}d → Z, one has ζ(c, d, α, h) ≤ η(d, β, h)ρ + 2−γ·d. Proof. We use Lemma 2.5 to choose α = 1 and . 2 2 · ln c c−1 + oc,γ(1) such that α · d is an odd integer 2c# < d 2−γ·d (1) Pr"Xα·d ≥ We can choose β = oγ(1) so that u,v∼{0,1}d(cid:20)ku − vk <(cid:18)1 2 − β(cid:19) · d(cid:21) < Pr 2−γ·d 2 . (This follows from the standard Chernoff-type bounds.) Now we apply Lemma 2.1 and get Pr u∼{0,1}d v∼Wα·d(u) [h(u) = h(v)] ≤ Pr u,v∼{0,1}d [h(u) = h(v)]ρ , where ρ = exp(2α) − 1 exp(2α) + 1 = 1 2c − 1 − oc,γ(1). Finally, we combine (3), (1) and (2), and get the desired inequality. (2) (3) The following corollary shows how the above lemma implies a lower bound on data- 8 independent LSH. Corollary 2.7. For every c > 1 and γ = γ(d) > 0 such that γ = o(1) there exists β = β(d) > 0 with β = oγ(1) such that if H is a data-independent (d/(2c), (1/2 − β)d, p1, p2)-sensitive family, then 1 2c−1 −oc,γ(1) 2 + 2−γ·d. p1 ≤ p Proof. We observe that for every α, β > 0: h∼H • p1 ≤ E • p2 ≥ E h∼H [ζ(c, d, α, h)]; [η(d, β, h)]. Now we apply Lemma 2.6 together with the following application of Jensen’s inequality: E h∼H [η(d, β, h)ρ] ≤ E h∼H [η(d, β, h)]ρ , since 0 < ρ ≤ 1. 3 Data-Dependent Hashing We now prove the second component of the main Theorem 1.4 proof. In particular we show that a very good data-dependent hashing scheme would refute Lemma 2.6 from the previous section. 3.1 Empirical Probabilities of Collision For a particular dataset P , we will be interested in empirical probabilities p1, p2 — i.e., the equivalents of ζ, µ for a given set P — defined as follows. Let 0 < δ(d) < 1/3 be some function. Let P be a random set of points from {0, 1}d of size 2δ(d)·d. The empirical versions of ζ and η with respect to P are: u∼P bζ(c, d, α, h, P ) := Pr bη(d, β, h, P ) := Pr v∼Wα·d(u) "h(u) = h(v)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)ku − vk1 ≤ u,v∼P(cid:20)h(u) = h(v),ku − vk1 >(cid:18)1 2c# 2 − β(cid:19) · d(cid:21) . d We now what to prove that, for a random dataset P , the empirical ζ, µ are close to the true averages. For this we will need the following auxiliary lemma. 9 Lemma 3.1. Let M be an n × n symmetric matrix with entries from [0; 1] and average ε. Let M ′ be a principal nδ × nδ submatrix of M sampled uniformly with replacement. Then, for every θ > 0, the probability that the maximum of the average over M ′ and θ does not lie in [1/2; 2] · max{ε, θ} is at most nδ · 2−Ω(θnδ). Proof. We need the following version of Bernstein’s inequality. Lemma 3.2. Suppose that X1, . . . , Xn are i.i.d. random variables that are distributed over [0; 1]. Suppose that E[Xi] = ε. Then, for every 0 < θ < 1, one has Pr"max( 1 n nXi=1 Xi, θ) ∈(cid:20) 1 2 ; 2(cid:21) · max{ε, θ}# ≥ 1 − 2−Ω(θn). We just apply Lemma 3.2 and take union bound over the rows of M ′. The following two lemmas are immediate corollaries of Lemma 3.2 and Lemma 3.1, re- spectively. Lemma 3.3. For every c > 1, α > 0, positive integer d, θ > 0 and a hash function h : {0, 1}d → Z, one has Pr P hmax{bζ(c, d, α, h, P ), θ} ∈ [1/2; 2] · max{ζ(c, d, α, h), θ}i ≥ 1 − 2−Ω(θ·2δ(d)·d). Lemma 3.4. For every β > 0, positive integer d, θ > 0 and a hash function h : {0, 1}d → Z, one has Pr P [max{bη(d, β, h, P ), θ} ∈ [1/2; 2] · max{η(d, β, h), θ}] ≥ 1 − 2δ(d)·d · 2−Ω(θ·2δ(d)·d). 3.2 Proof of Theorem 1.4 We are finally ready to complete the proof of the main result, Theorem 1.4. Let us first assume that p1 = o(1) and then show how to handle the general case. Suppose that n = P = 2δ·d. By the assumption of Theorem 1.4, δ = o(1). Let {h1, h2, . . . , hT} be a set of hash functions. We can assume that log T p1 ≤ n1−Ω(1), since otherwise we are done. Let us fix γ = γ(d) > 0 such that γ = o(1) and 2−γd ≪ pω(1) . We can do this, since if p1 = 2−Ω(d), then 1/p1 = nω(1), and the desired statement is true. Then, by Lemma 2.6, there is α = α(d) and β = β(d) = oγ(1) such that for every 1 ≤ i ≤ T 1 ζ(c, d, α, hi) ≤ η(d, β, hi) 1 2c−1 −oc,γ(1) + 2−γd. (4) 10 Let us choose θ > 0 such that T · 2δ·d ≪ 2θ·2δ·d and θ ≪ p1. We can do it since, by the above assumption, log T p1 ≤ n1−Ω(1) = 2δ·d(1−Ω(1)). Then, from Lemma 3.3 and Lemma 3.4 we get that, with high probability over the choice of P , one has for every 1 ≤ i ≤ T : • max{bζ(c, d, α, hi), θ} ∈ [1/2; 2] · max{ζ(c, d, α, hi), θ}; • max{bη(d, β, hi), θ} ∈ [1/2; 2] · max{η(d, β, hi), θ}. Suppose these conditions hold and assume there exist a distribution D over [T ] such that the corresponding hash family is (d/2c, (1/2 − β(d))d, p1, p2)-sensitive for P . Then, p1 ≤ E i∼D [bζ(c, d, α, hi)] ≤ E i∼D [max{bζ(c, d, α, hi), θ}] ≤ 2 · E i∼D [max{ζ(c, d, α, hi), θ}] ≤ 2 · E i∼D [ζ(c, d, α, hi)] + θ. Similarly, p2 ≥ E i∼D [bη(d, β, hi)] ≥ E i∼D [max{bη(d, β, hi), θ}] − θ ≥ 1 2 · E i∼D Averaging (4) and applying Jensen’s inequality, we have [max{η(d, β, hi), θ}] − θ ≥ [η(d, β, hi)] − θ. 1 2 · E i∼D E i∼D [ζ(c, d, α, hi)] ≤ E i∼D [η(d, β, hi)] 1 2c−1 −o(1) + 2−γ(d)·d. Thus, substituting (5) and (6) into (7) p1 − θ 2 ≤ (2(p2 + θ)) 1 2c−1 −o(1) + 2−γd, (5) (6) (7) which proves the theorem, since θ ≪ p1, 2−γd ≪ pω(1) Now let us deal with the case p1 = Ω(1). This can be reduced to the case p1 = o(1) by choosing a slowly-growing super constant k and replacing the set of T functions with the set of T k tuples of length k. This replaces p1 and p2 with pk 2, respectively. In the same time, we choose k so that T ′ = T k still satisfy the hypothesis of the theorem. Then, we just apply the above proof. , and p1 = o(1). 1 and pk 1 11 References [AI06] Alexandr Andoni and Piotr Indyk. Near-optimal hashing algorithms for approximate nearest neighbor in high dimensions. In Proceedings of the 47th Annual IEEE Sympo- sium on Foundations of Computer Science (FOCS ’2006), pages 459–468, 2006. [AI08] Alexandr Andoni and Piotr Indyk. Near-optimal hashing algorithms for approximate nearest neighbor in high dimensions. Communications of the ACM, 51(1):117–122, 2008. [AIK+15] Alexandr Andoni, Piotr Indyk, Michael Kapralov, Thijs Laarhoven, Ilya Razenshteyn, and Ludwig Schmidt. Practical and optimal LSH for angular distance. Manuscript, 2015. [AINR14] Alexandr Andoni, Piotr Indyk, Huy L. Nguyen, and Ilya Razenshteyn. Beyond locality- sensitive hashing. In Proceedings of the 25th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’2014), pages 1018–1028, 2014. [And09] Alexandr Andoni. Nearest Neighbor Search: the Old, the New, and the Impossible. PhD thesis, Massachusetts Institute of Technology, 2009. [AR15] Alexandr Andoni and Ilya Razenshteyn. Optimal data-dependent hashing for approxi- mate near neighbors. In Proceedings of the ACM Symposium on the Theory of Comput- ing (STOC ’15), 2015. [BDGL15] Anja Becker, Léo Ducas, Nicolas Gama, and Thijs Laarhoven. New directions in nearest neighbor searching with applications to lattice sieving. Manuscript, 2015. [DG03] Sanjoy Dasgupta and Anupam Gupta. An elementary proof of a theorem of Johnson and Lindenstrauss. Random Structures and Algorithms, 22(1):60–65, 2003. [DIIM04] Mayur Datar, Nicole Immorlica, Piotr Indyk, and Vahab S. Mirrokni. Locality-sensitive hashing scheme based on p-stable distributions. In Proceedings of the 20th ACM Sym- posium on Computational Geometry (SoCG ’2004), pages 253–262, 2004. [Dub10] Moshe Dubiner. Bucketing coding and information theory for the statistical high- IEEE Transactions on Information Theory, dimensional nearest-neighbor problem. 56(8):4166–4179, 2010. [FS02] Uriel Feige and Gideon Schechtman. On the optimality of the random hyperplane rounding technique for MAX CUT. Random Structures and Algorithms, 20(3):403–440, 2002. [HPIM12] Sariel Har-Peled, Piotr Indyk, and Rajeev Motwani. Approximate nearest neighbor: towards removing the curse of dimensionality. Theory of Computing, 8(1):321–350, 2012. [IM98] [JL84] Piotr Indyk and Rajeev Motwani. Approximate nearest neighbors: towards removing the curse of dimensionality. In Proceedings of the 30th ACM Symposium on the Theory of Computing (STOC ’1998), pages 604–613, 1998. William B. Johnson and Joram Lindenstrauss. Extensions of Lipschitz mappings into a Hilbert space. In Conference in modern analysis and probability (New Haven, Con- necticut, 1982), volume 26 of Contemporary Mathematics, pages 189–206. 1984. 12 [KOR00] Eyal Kushilevitz, Rafail Ostrovky, and Yuval Rabani. Efficient search for approximate nearest neighbor in high dimensional spaces. SIAM Journal on Computing, 30(2):457– 474, 2000. [LLR95] Nathan Linial, Eran London, and Yuri Rabinovich. The geometry of graphs and some of its algorithmic applications. Combinatorica, 15(2):215–245, 1995. [MNP07] Rajeev Motwani, Assaf Naor, and Rina Panigrahy. Lower bounds on locality sensitive hashing. SIAM Journal on Discrete Mathematics, 21(4):930–935, 2007. [OWZ11] Ryan O’Donnell, Yi Wu, and Yuan Zhou. Optimal lower bounds for locality sensitive hashing (except when q is tiny). In Proceedings of Innovations in Computer Science (ICS ’2011), pages 275–283, 2011. [PTW08] Rina Panigrahy, Kunal Talwar, and Udi Wieder. A geometric approach to lower bounds for approximate near-neighbor search and partial match. In Proceedings of the 49th Annual IEEE Symposium on Foundations of Computer Science (FOCS ’2008), pages 414–423, 2008. [PTW10] Rina Panigrahy, Kunal Talwar, and Udi Wieder. Lower bounds on near neighbor search via metric expansion. In Proceedings of the 51st Annual IEEE Symposium on Founda- tions of Computer Science (FOCS ’2010), pages 805–814, 2010. [Sam06] Hannan Samet. Foundations of Multidimensional and Metric Data Structures. Elsevier, 2006. [TT07] Kengo Terasawa and Yuzuru Tanaka. Spherical LSH for approximate nearest neighbor search on unit hypersphere. In Algorithms and Data Structures, 10th International Workshop, WADS 2007, Halifax, Canada, August 15-17, 2007, Proceedings, pages 27– 38, 2007. [WSSJ14] Jingdong Wang, Heng Tao Shen, Jingkuan Song, and Jianqiu Ji. Hashing for similarity search: A survey. CoRR, abs/1408.2927, 2014. A Upper Bounds Are in the Model In this section, we show how the data-dependent hash family from [AR15] fits into the model of the lower bound from Section 1.1. 1 Let us briefly recall the hash family construction from [AR15]. For simplicity, assume that all points and queries lie on a sphere of radius R ≫ cr. First, consider a data-independent hash family from [AINR14, AR15], called Spherical LSH. It gives a good exponent ρ ≤ 2c2−1 + o(1) for distance thresholds r vs √2R (the latter corresponds to a typical distance between a pair of points from the sphere). The main challenge that arises is how to handle distance thresholds r vs cr, where the latter may be much smaller than √2R. Here comes the main insight of [AR15]. 13 We would like to process the dataset so that the distance between a typical pair of data points is around √2R, so to apply Spherical LSH. To accomplish this, we remove all the clusters of radius (√2 − ε)R that contain lots of points (think of ε > 0 being barely sub- constant). We will treat these clusters separately, and will focus on the remainder of the pointset for now. So for the remainder of the pointset, we just apply the Spherical LSH to it. This scheme turns out to satisfy the definition of the data-dependent hash family for the remaining points and for distance thresholds r vs. cr; in particular, the hash function is sensitive for the remaining set only! The intuition is that, for any potential query point, there is only a small number of data points within distance (√2 − ε)R — otherwise, they would have formed yet another cluster, which we would have removed — and the larger distances are handled well by the Spherical LSH. Thus, for a typical pair of data points, Spherical LSH is sensitive for P (see Definition 1.3). How does [AR15] deal with the clusters? The main observation is that one can enclose such a cluster in a ball of radius (1−Ω(ε2))R, which intuitively makes our problem a little bit simpler (after we reduce the radius enough times, the problem becomes trivial). To answer a query, we query every cluster, as well as one part of the remainder (partitioned by the Spherical LSH). This can be shown to work overall, in particular, we can control the overall branching and depth of the recursion (see [AR15] for the details). For both the clusters, as well as the parts obtained from the Spherical LSH, the algorithm recurses on the obtained point subsets. The overall partitioning scheme from [AR15] can be seen as a tree, where the root corresponds to the whole dataset, and every node either corresponds to a cluster or to an application of the Spherical LSH. One nuance is that, in different parts of the tree the Spherical LSH partitioning obtains different p1, p2 (depending on R). Nonetheless, each time it holds that p1 ≥ pρ 2c2−1 + o(1). Hence, a node terminates as a leaf once its accumulated p2 (product of p2’s of “Spherical LSH” nodes along the path from the root) drops below 1/n. 2 for ρ ≤ 1 We now want to argue that the above algorithm can be recast in the framework of data- dependent hashing as per Definition 1.3. We consider a subtree of the overall tree that contains the root and is defined as follows. Fix a parameter l = n−o(1) (it is essentially the target p2 of the partition). We perform DFS of the tree and cut the tree at any “Spherical LSH” node where the cumulative p2 drops below l. This subtree gives a partial partition of the dataset P as follows: for “Spherical LSH” nodes we just apply the corresponding partition, and for cluster nodes we “carve” them in the random order. It turns out that if we choose l = n−o(1) carefully, the partition will satisfy Definition 1.3 and the preconditions of Theorem 1.4. In particular, the description complexity of the resulting hash function is no(1). 14 Let us emphasize that, while Definition 1.3 is certainly necessary for an ANN data struc- ture based on data-dependent hashing, it is not sufficient. In fact, [AR15] prove additional properties of the above partitioning scheme, essentially because the “p2 property” is “on average” one (thus, we end up having to understand how this partitioning scheme treats triples of points). 15
1505.01460
1
1505
2015-05-06T19:02:34
Maximum Matching in Turnstile Streams
[ "cs.DS" ]
We consider the unweighted bipartite maximum matching problem in the one-pass turnstile streaming model where the input stream consists of edge insertions and deletions. In the insertion-only model, a one-pass $2$-approximation streaming algorithm can be easily obtained with space $O(n \log n)$, where $n$ denotes the number of vertices of the input graph. We show that no such result is possible if edge deletions are allowed, even if space $O(n^{3/2-\delta})$ is granted, for every $\delta > 0$. Specifically, for every $0 \le \epsilon \le 1$, we show that in the one-pass turnstile streaming model, in order to compute a $O(n^{\epsilon})$-approximation, space $\Omega(n^{3/2 - 4\epsilon})$ is required for constant error randomized algorithms, and, up to logarithmic factors, space $O( n^{2-2\epsilon} )$ is sufficient. Our lower bound result is proved in the simultaneous message model of communication and may be of independent interest.
cs.DS
cs
Maximum Matching in Turnstile Streams Christian Konrad Reykjavik University, Reykjavik, Iceland, [email protected] 5 1 0 2 y a M 6 ] S D . s c [ 1 v 0 6 4 1 0 . 5 0 5 1 : v i X r a Abstract. We consider the unweighted bipartite maximum matching problem in the one-pass turnstile streaming model where the input stream consists of edge insertions and deletions. In the insertion-only model, a one-pass 2-approximation streaming algorithm can be easily obtained with space O(n log n), where n denotes the number of vertices of the input graph. We show that no such result is possible if edge deletions are allowed, even if space O(n3/2−δ) is granted, for every δ > 0. Specifically, for every 0 ≤  ≤ 1, we show that in the one-pass turnstile streaming model, in order to compute a O(n)-approximation, space Ω(n3/2−4) is required for constant error randomized algorithms, and, up to logarithmic factors, space O(n2−2) is sufficient. Our lower bound result is proved in the simultaneous message model of communication and may be of independent interest. 1 Introduction Massive graphs are usually dynamic objects that evolve over time in structure and size. For example, the Internet graph changes as webpages are created or deleted, the structure of social network graphs changes as friendships are established or ended, and graph databases change in size when data items are inserted or deleted. Dynamic graph algorithms can cope with evolving graphs of moderate sizes. They receive a sequence of updates, such as edge insertions or deletions, and maintain valid solutions at any moment. However, when considering massive graphs, these algorithms are often less suited as they assume random access to the input graph, an assumption that can hardly be guaranteed in this context. Consequently, research has been carried out on dynamic graph streaming algorithms that can handle both edge insertions and deletions. Dynamic Graph Streams. A data streaming algorithm processes an input stream X = X1, . . . , Xn sequentially item by item from left to right in passes while using a memory whose size is sublinear in the size of the input [25]. Graph streams have been studied for almost two decades. However, until recently, all graph streams considered in the literature were insertion- only, i.e., they process streams consisting of sequences of edge insertions. In 2012, Ahn, Guha and McGregor [2] initiated the study of dynamic graph streaming algorithms that process streams consisting of both edge insertions and deletions. Since then, it has been shown that a vari- ety of problems for which space-efficient streaming algorithms in the insertion-only model are known, such as testing connectivity and bipartiteness, computing spanning trees, computing cut-preserving sparsifiers and spectral sparsifiers, can similarly be solved well in small space in the dynamic model [2,3,20,19]. An exception is the maximum matching problem which, as we will detail later, is probably the most studied graph problem in streaming settings. In the insertion-only model, a 2-approximation algorithm for this problem can easily be obtained in one pass with O(n log n) space, where n is the number of vertices in the input graph. Even in the sliding-window model1, which can be seen as a model located between the insertion-only model and the dynamic model, the problem can be solved well [8]. The status of the problem 1 In the sliding-window model, an algorithm receives a potentially infinite insertion-only stream, however, only a fixed number of most recent edges are considered by the algorithm. Edges are seen as deleted when they are no longer contained in the most recent window of time. in the dynamic model has been open so far, and, in fact, the existence of sublinear space one- pass dynamic streaming algorithms for the maximum matching problem was one of the open problems collected at the Bertinoro 2014 workshop on sublinear algorithms 2. Results on dynamic matching algorithms [6,5] show that even when the sequence of graph updates contains deletions, then large matchings can be maintained without too many recon- figurations. These results may give reasons for hope that constant or poly-logarithmic approxi- mations could be achieved in the one-pass dynamic streaming model. We, however, show that if there is such an algorithm, then it uses a huge amount of space. Summary of Our Results. In this paper, we present a one-pass dynamic streaming al- gorithm for maximum bipartite matching and a space lower bound for streaming algorithms in the turnstile model, a slightly more general model than the dynamic model (see Section 2 for a discussion), the latter constituting the main contribution of this paper. We show that in one pass, an O(n)-approximation can be computed in space O(n2−2) (Theorem 4), and space Ω(n3/2−4) is necessary for such an approximation (Corollary 1). Lower Bound via Communication Complexity. Many space lower bounds in the insertion-only model are proved in the one-way communication model. In the one-way model, party one sends a message to party two who, upon reception, sends a message to party three. This process continues until the last party receives a message and outputs the result. A recent result by Li, Nguyen and Woodruff [22] shows that space lower bounds for turnstile streaming algorithms can be proved in the more restrictive simultaneous model of communication (SIM model). In this model, the participating parties simultaneously each send a single message to a third party, denoted the referee, who computes the output of the protocol as a function of the received messages. A lower bound on the size of the largest message of the protocol is then a lower bound on the space requirements of a turnstile one-pass streaming algorithm. Our paper is the first that uses this connection in the context of graph problems. A starting point for our lower bound result is a work of Goel, Kapralov and Khanna [13], and a follow-up work by Kapralov [17]. In [13], via a one-way two-party communication lower bound, it is shown that in the insertion-only model, every algorithm that computes a (3/2 − )-approximation, for  > 0, requires Ω(n1+ 1 log log n ) space. This lower bound has then been strengthened in [17] to hold for (e/(e − 1) − )-approximation algorithms. Both lower bound constructions heavily rely on Ruzsa-Szemer´edi graphs. A graph G is an (r, s)-Ruzsa-Szemer´edi graph (in short: RS-graph), if its edge set can be partitioned into r disjoint induced matchings each of size at least s. The main argument of [13] can be summarized as follows: Suppose that the first party holds a relatively dense Ruzsa-Szemer´edi graph G1. The second party holds a graph G2 whose edges render one particular induced matching M ⊆ E(G1) of the first party indispensable for every large matching in the graph G1 ∪ G2, while all other induced matchings are rendered redundant. Note that as M is an induced matching, there are no alternative edges in G1 different from M that interconnect the vertices that are matched by M . As the first party is not aware which of its induced matchings is required, and as the communication budget is restricted, only few edges of M on average will be sent to the second party. Hence, the expected size of the output matching is bounded. When implementing the previous idea in the SIM setting, the following issues have to be addressed: Firstly, the number of parties in the simultaneous message protocol needs to be at least as large as the desired bound on the approximation factor. The trivial protocol where every party sends a maximum matching of its subgraph, and the referee outputs the largest received matching, shows that the approximation factor cannot be larger than the number of parties, even 2 See also http://sublinear.info/64 2 when message sizes are as small as O(n). Hence, proving hardness for polynomial approximation factors requires a polynomial number of participating parties. On the other hand, the number of parties can neither be chosen too large: If the input graph is equally split among p parties, for a large p, then the subgraphs of the parties are of size O(n2/p). Thus, with messages of size O(n2/p), all subgraphs can be sent to the referee who then computes and outputs an optimal solution. Hence, the larger the number of parties, the weaker a bound on the message sizes can be achieved. Secondly, there is no "second party" as in the one-way setting whose edges could render one particular matching of every other party indispensable. Instead, a construction is required so that every party both has the function of party one (one of its induced matchings is indispensable for every large matching) and of party two (some of its edges render many of the induced matchings of other parties redundant). This suggests that the RS-graphs of the parties have to overlap in many vertices. While arbitrary RS-graphs with good properties can be employed for the lower bounds of [13] and [17], we need RS-graphs with simple structure in order to coordinate the overlaps between the parties. We show that both concerns can be handled. In Section 3, we present a carefully designed input distribution where each party holds a highly symmetrical RS-graph. The RS-graph of a party overlaps almost everywhere with the RS-graphs of other parties, except in one small induced matching. This matching, however, cannot be distinguished by the party, and hence, as in the one-way setting, the referee will not receive many edges of this matching. Upper Bound. Our upper bound result is achieved by an implementation of a simple matching algorithm in the dynamic streaming model: For an integer k, pick a random subset A(cid:48) ⊆ A of size k of one bipartition of the bipartite input graph G = (A, B, E); for each a ∈ A(cid:48), store arbitrary min{k, deg(a)} incident edges, where deg(a) denotes the degree of a in the input graph; output a maximum matching in the graph induced by the stored edges. We prove that this algorithm has an approximation factor of n/k. In order to collect k incident edges of a given vertex in the dynamic streaming model, we employ the l0-samplers of Jowhari, Saglam, Tardos [16], which have previously been used for dynamic graph streaming algorithms [2]. By chosing k = Θ(n1−), this construction leads to a O(n)-approximation algorithm with space O(n2−2). While this algorithm in itself is rather simple and standard, it shows that non-trivial approximation ratios for maximum bipartite matching in the dynamic streaming model are possible with sublinear space. Our upper and lower bounds show that in order to compute a n-approximation, space O(n2−2) is sufficient and space Ω(n3/2−4) is required. Improving on either side is left as an open problem. Further Related Work. Matching problems are probably the most studied graph problem in the streaming model [12,23,9,10,1,2,21,26,13,17,14,8,7,19,24,18,11]. Closest to our work are the already mentioned lower bounds [13] and [17]. Their arguments are combinatorial and so are the arguments in this paper. Note that lower bounds for matching problems in communication settings have also been obtained via information complexity in [14,15]. In the dynamic streaming model, Ahn, Guha, and McGregor [2] provide a multi-pass algo- rithm with O(n1+1/p poly −1) space, O(p · −2 · log −1) passes, and approximation factor 1 +  for the weighted maximum matching problem, for a parameter p. This is the only result on matchings known in the dynamic streaming setting. Recent Related Work. Assadi et. al. [4] independently and concurrently to this work essentially resolve the questions asked in this paper. Using the same techniques (l0-sampling for the upper bound, simultaneous communication complexity and Rusza-Szemer´edi graphs for the lower bound), they show that there is a O(n)-approximation dynamic streaming algorithm for maximum matching which uses O(n2−3) space. Furthermore, they prove that this is essentially 3 tight for turnstile algorithms: Any such algorithm in the turnstile model requires space at least n2−3−o(1). Outline. We start our presentation with a section on preliminaries. Then, in Section 3, we present our hard input distribution which is then used in Section 4 in order to prove our lower bound in the SIM model. Finally, we conclude with our upper bound in Section 5. 2 Preliminaries For an integer a ≥ 1, we write [a] for {1, . . . , a}. We use the notation O(), which equals the standard O() notation where all poly-logarithmic factors are ignored. Simultaneous Communication Complexity. Let G = (A, B, E) denote a simple bipartite graph, and, for an integer P ≥ 2, let G1, . . . , GP be edge-disjoint subgraphs of G. In the simultaneous message complexity setting, for p ∈ [P ], party p is given Gp, and sends a single message µp of limited size to a third party denoted the referee. Upon reception of all messages, the referee outputs a matching M in G. Note that the participating parties cannot communicate with each other, but they have access to an infinite number of shared random coin flips which can be used to synchronize their messages. We say that an algorithm/protocol is a constant error algorithm/protocol if it errs with probability at most , for 0 ≤  < 1/2. We also assume that a algorithm/protocol never outputs edges that do not exist in the input graph. Turnstile streams. For a bipartite graph G = (A, B, E), let X = X1, X2, . . . be the input stream with Xi ∈ E × {+1,−1}, where +1 indicates that an edge is inserted, and −1 indicates that an edge is deleted. Edges could potentially be inserted multiple times, or be removed before they have been inserted, as long as once the stream has been fully processed, the multiplicity of an edge is in {−c,−c + 1, . . . , c − 1, c}, for some integer c. The reduction of [22] and hence our lower bound holds for algorithms that can handle this type of dynamic streams, also known as turnstile streams. Such algorithms may for instance abort if negative edge multiplicities are encountered, or they output a solution among the edges with non-zero multiplicity. In [22] it is shown that every turnstile algorithm can be seen as an algorithm that solely computes a linear sketch of the input stream. As linear sketches can be implemented in the SIM model, lower bounds in the SIM model are lower bounds on the sketching complexity of problems, which in turn imply lower bounds for turnstile algorithms. We stress that our lower bound holds for linear sketches. Note that all known dynamic graph algorithms3 solely compute linear sketches (e.g. [2,3,20,19]). This gives reasons to conjecture that also all dynamic algorithms can be seen as linear sketches, and, as a consequence, our lower bound not only holds for turnstile algorithms but for all dynamic algorithms. . 3 Hard Input Distribution In this section, we construct our hard input distribution. First, we describe the construction of the distribution from a global point of view in Subsection 3.1. Restricted to the input graph Gp of any party p ∈ [P ], the distribution of Gp can be described by a different construction which is simpler and more suitable for our purposes. This will be discussed in Subsection 3.2. 3.1. Hard Input Distribution: Global View Denote by P the number of parties of the simultaneous message protocol. Let k, Q be integers so that P ≤ k ≤ n P , and Q = o(P ). The precise values of k and Q will be determined later. First, we define a bipartite graph G(cid:48) = (A, B, E) on O(n) vertices with A = B = [(Q + P )k] from which we obtain our hard input 3 Some of those algorithms couldn't handle arbitrary turnstile streams as they rely on the fact that all edge multiplicities are in {0, 1}. 4 distribution. For 1 ≤ i ≤ Q + P , let Ai = [1 + (i − 1)k, ik] and let Bi = [1 + (i − 1)k, ik]. The edge set E is a collection of matchings as follows: E = i,j ∪ M p i,j∈[Q],p∈[P ] i∈{Q+1,...,Q+P},j∈[Q] (Mi,j ∪ Mj,i) ∪ i∈{Q+1,...,Q+P} Mi,i, (cid:91) (cid:91) (cid:91) where Mi,j is a perfect matching between Ai and Bj, and M 1 i,j are P edge-disjoint perfect matchings between Ai and Bj. Note that as we required that k ≥ P , the edge-disjoint matchings M 1 i,j, . . . , M P i,j can be constructed4. From G(cid:48), we construct the input graphs of the different parties as follows: i,j, . . . , M P p = (A, B, E(cid:48) i,j for i, j ∈ [Q], p consists of the matchings M p the matching MQ+p,Q+p and the matchings MQ+p,j and Mj,Q+p for j ∈ [Q]. 1. For every p ∈ [P ], let G(cid:48) p) where E(cid:48) 2. For every p ∈ [P ], for every matching M of G(cid:48) p, pick a subset of edges of size k/2 from M uniformly at random and replace M by this subset. 3. Pick random permutations πA, πB : [Q+P ] → [Q+P ]. Permute the vertex IDs of the graphs p, for 1 ≤ p ≤ P , so that if πA(i) = j then Ai receives the IDs of Aj as follows: The vertices G(cid:48) a1 = 1 + k(i − 1), a2 = 2 + k(i − 1), . . . , ak = ki receive new IDs so that after the change of IDs, we have a1 = 1 + k(j − 1), a2 = 2 + k(j − 1), . . . , ak = kj. The same procedure is carried out with vertices Bi and permutation πB. Denote by Gp the graph G(cid:48) p once half of the edges have been removed and the vertex IDs have been permuted. Let G be the union of the graphs Gp. The structure of G(cid:48) and a subgraph G(cid:48) p is illustrated in Figure 1. AQ+1 AQ+P A1 AQ AQ+p A1 AQ G(cid:48) p ⊆ Gp G(cid:48) B1 BQ BQ+1 BQ+P B1 BQ BQ+p Fig. 1. Left: Graph G(cid:48). A vertex corresponds to a group of k vertices. Each edge indicates a perfect matching between the respective vertex groups. The bold edges correspond to the matchings MQ+p,Q+p, for 1 ≤ p ≤ P , i,j, for 1 ≤ i, j ≤ Q, 1 ≤ p ≤ P , and the dotted edges correspond to the solid edges correspond to matchings M p matchings MQ+p,i, Mi,Q+p, for 1 ≤ i ≤ Q and 1 ≤ p ≤ P . Right: Subgraph G(cid:48) p ⊆ G. Properties of the input graphs. Graph G(cid:48) has a perfect matching of size (Q + P )k which consists of a perfect matching between vertices A1, . . . , AQ and B1, . . . , BQ, and the matchings MQ+p,Q+p for 1 ≤ p ≤ P . As by Step 2 of the construction of the hard instances, we remove half of the edges of every matching, a maximum matching in graph G is of size at least (Q+P )k . Note that while there are many possibilities to match the vertex groups A1, . . . , AQ and B1, . . . , BQ, in every large matching, many vertices of AQ+i are matched to vertices BQ+i using edges from the matching MQ+i,Q+i. For some p ∈ [P ], consider now the graph G(cid:48) p from which the graph Gp is constructed. G(cid:48) p consists of perfect matchings between the vertex groups Ai and Bj for every i, j ∈ [Q] ∪ {p}. In graph Gp, besides the fact that only half of the edges of every matching are kept, the vertex IDs are permuted. We will argue that due to the permuted vertices, given Gp, it is difficult to determine which of the matchings corresponds to the matching MQ+p,Q+p in G(cid:48). Therefore, if the referee is able to output edges from the matching MQ+p,Q+p, then many edges from every matching have to be included into the message µp sent by party p. 2 3.2. Hard Input Distribution: Local View. From the perspective of an individual party, by symmetry of the previous construction, the distribution from which the graph Gp is chosen can also be described as follows: 4 For instance, define G(cid:48) so that G(cid:48)Ai∪Bi is a P -regular bipartite graph. It is well-known (and easy to see via Hall's theorem) that any P -regular bipartite graph is the union of P edge-disjoint perfect matchings. 5 1. Pick IA, IB ⊆ [Q + P ] so that IA = IB = Q + 1 uniformly at random. 2. For every i ∈ IA and j ∈ IB, introduce a matching of size k/2 between Ai and Bj chosen uniformly at random from all possible matching between Ai and Bj of size k/2. (cid:16) 2k (cid:17)(Q+1)2 (cid:1) (Q+P )! party p. Moreover, the input distribution is uniform. Gp can be seen as a ((Q + 1)2, k/2)-Ruzsa-Szemer´edi graph or as a (Q + 1, k(Q + 1)/2)-Ruzsa- Szemer´edi graph. Let Gp denote the possible input graphs of party p. We prove now a lower bound on Gp. Lemma 1. There are at least Gp >(cid:0)Q+P There are (cid:0)Q+P of k/2 edges from k potential edges. Hence, there are(cid:0)Q+P below by(cid:0)Q+P (cid:1) choices for IA. Consider one particular choice of IA. Then, there are (Q+P )! (cid:1) (Q+P )! input graphs for each party. Using a bound on the central binomial coefficient, this term can be bounded from (cid:117)(cid:116) Proof. The vertex groups IA and IB are each of cardinality Q+1 and chosen from the set [Q+P ]. (P−1)! possibilities to pair those with Q + 1 vertex groups of the B nodes. Each matching is a subset possible input graphs for every (cid:17)(Q+1)2 (cid:1) (Q+P )! (P−1)! (cid:0) k (cid:1)(Q+1)2 Q+1 (P−1)! Q+1 Q+1 1 2 k k+1 (cid:16) 2k k+1 Q+1 (P−1)! . The matching in Gp that corresponds to the matching between AQ+p and BQ+p in G(cid:48) p will play an important role in our argument. In the previous construction, every introduced matching in Gp plays the role of matching MQ+p,Q+p in G(cid:48) p with equal probability. In the following, we will denote by Mp the matching in Gp that corresponds to the matching MQ+p,Q+p in G(cid:48) p. 4 Simultaneous Message Complexity Lower Bound We prove now that no communication protocol with limited maximal message size performs well on the input distribution described in Section 3. First, we focus on deterministic protocols, and we prove a lower bound on the expected approximation ratio (over all possible input graphs) of any deterministic protocol (Theorem 1). Then, via an application of Yao's lemma, we obtain our result for randomized constant error protocols (Theorem 2). Our lower bound for dynamic one-pass streaming algorithms, Corollary 1, is then obtained as a corollary of Theorem 2 and the reduction of [22]. Lower Bound For Deterministic Protocols. Consider a deterministic protocol that runs on a hard instance graph G and uses messages of length at most s. As the protocol is deterministic, for every party p ∈ [P ], there exists a function mp that maps the input graph Gp of party p to a message µp. As the maximum message length is limited by s, there are 2s different possible messages. Our parameters Q, k will be chosen so that s is much smaller than the number of input graphs Gp for party p, as stated in Lemma 1. Consequently, many input graphs are mapped to the same message. Consider now a message µp and denote by µ−1 Mp ∩(cid:84) p , since all outputted edges have to be contained in the input graph. the set of graphs Gp that are mapped by mp to message µp. Upon reception of µp, the referee can only output edges that are contained in every graph of µ−1 Let N denote the matching outputted by the referee, and let Np = N ∩ Mp denote the outputted edges from matching Mp. Furthermore, for a given message µp, denote by Gµp := In the following, we will bound the quantity ENp from above (Lemma 2). By linearity of expectation, this allows us to argue about the expected number of edges of the matchings ∪pNp outputted by the referee. We can hence argue about the expected size of the outputted matching, which in turn implies a lower bound on the approximation guarantee of the protocol (Theorem 1). Gp∈µ−1 Gp. p p 6 Lemma 2. For every party p ∈ [P ], we have ENp = O (cid:16)√ sk Q (cid:17) . Proof. Let Γ denote the set of potential messages from party p to the referee. As the maximum Gp message length is bounded by s, we have Γ ≤ 2s. Let V = k2s be a parameter which splits the set Γ into two parts as follows. Denote by Γ≥ ⊆ Γ the set of messages µp so that µ−1 p ≥ V , and let Γ< = Γ \ Γ≥. In the following, for a message µp ∈ Γ , we denote by P [µp] the probability P [µp] < 2sVGp , since there are at most 2sV µp∈Γ< input graphs that are mapped to messages in Γ<. We hence obtain: that message µp is sent by party p. Note that(cid:80) (cid:88) (cid:33) EGµp ENp ≤ (cid:88) ≤ (cid:88) P [µp] EGµp = (cid:32)µ−1 µp∈Γ≥ µp∈Γ + p 2s µp∈Γ≥ (cid:0)P [µp] EGµp(cid:1) + (cid:88) (P [µp]) k (cid:0)P [µp] EGµp(cid:1) (cid:88) µp∈Γ< µp∈Γ< 2sV Gp k = max{EGµp : µp ∈ Γ≥} + 1, < max{EGµp : µp ∈ Γ≥} + (cid:17) (cid:16)√ sk Q where we used the definition of V for the last equality. In Lemma 3, we prove that ∀µp ∈ Γ≥ : EGµp = O (cid:117)(cid:116) . This then implies the result. Lemma 3. Suppose µp is so that µ−1 p ≥ V = Proof. Remember that every graph Gp ∈ µ−1 Mp is a randomly chosen one of those. We define Gp k2s . Then, EGµp = O consists of (Q + 1)2 edge-disjoint matchings, and (cid:16)√ (cid:17) sk Q p . Il = {(i, j) ∈ [Q + P ] × [Q + P ] : GµpAi∪Bj contains a matching of size l}. We prove first that if Il is large, then µ−1 Claim. Let l = o(k). Then, Il ≥ x ⇒ µ−1 Proof. Every graph of µ−1 contains l edges of x (fixed) matchings. The remaining edges and remaining matchings can be arbitrarily chosen. Then, by a similar argument as in the proof of Lemma 1, we obtain (P−1)! ( 3 is small. p <(cid:0)Q+P (cid:1) (Q+P )! 4 )lx(cid:16) 2k√ (cid:17)(Q+1)2 Q+1 k p p . (cid:19)(Q+1)2−x p ≤ µ−1 Q + 1 − x (cid:19) (Q + P − x)! (cid:18)Q + P − x (cid:18) k − l (cid:19)x(cid:18) k (cid:19) (Q + P )! (cid:18) 2k√ (cid:18)Q + P (cid:19)(Q+1)2 2 k − l (cid:1) < ( 3 (cid:1), and the bound (cid:0)k−l (cid:1) = (cid:0)k−l 4 )l(cid:0) k (P − 1)! (P − 1)! Q + 1 )lx 3 4 < k ( 1 , 1 2 k 1 2 k 1 2 k 1 2 k (cid:1) (remember: l = o(k)) which where we used (cid:0) k−l 1 2 k−l follows from Lemma 7 (see Appendix). Then, we can bound: Note that by assumption, we have µ−1 (cid:0)Q+1 (cid:1) · k + (1 − Il (cid:0)Q+1 (cid:1) )l < (cid:0)Q+1 EGµp ≤ Il p ≥ V . Let l, x be two integers so that: (cid:19)(Q+1)2 (cid:18) 2k√ (cid:19) (Q + P )! (cid:18)Q + P (cid:1) · k + l. Il = V. )lx ( 2 2 2 Q + 1 (P − 1)! k 3 4 7 (cid:117)(cid:116) (1) (2) x ≤ 1 l (cid:16)(cid:0)Q+P Q+1 (cid:1) (Q+P )! (P−1)! log Then, by the previous claim, we obtain Il < x. Solving Equality 2 for variable x, and further bounding it yields: (cid:19) − log V . (3) Remember that V was chosen as V = Gp k2s , and hence log V ≥ (Q + 1)2(k − log(k + 1)) + log k) + log (Q + 1)2(k − 1 2 (cid:18)(cid:18)Q + P (cid:19) (cid:18) (cid:19) (Q + P )! (cid:17) − s − log(k). Using this bound in Inequality 3 yields (cid:19) (P − 1)! Q + 1 (cid:18) (cid:0)(Q + 1)2(log(k + 1)) + s(cid:1) . (Q + 1)2(log(k + 1) − 1 2 log k) + s − log k x ≤ 1 l ≤ 1 l Now, using Il ≤ x and the previous inequality on x, we continue simplifying Inequality 1 as follows: EGµ ≤ ··· < Il (Q + 1)2 · k + l ≤ (Q + 1)2(log(k + 1)) + s l(Q + 1)2 + l), l(Q + 1)2 + l = O( l(Q + 1)2 sk sk + l ≤ log(k + 1)k · k + l sk O( √ sk Q ). since s = ω((Q + 1)2 log(k + 1)). We optimize by choosing l = √ Q , and we conclude EGµ = (cid:117)(cid:116) Theorem 1. For any P ≤ √ n, let Pdet be a P -party deterministic simultaneous message protocol for maximum matching where all messages are of size at most s. Then, Pdet has an 2Qk +(cid:80)P groups (cid:83) vertex in (cid:83) Proof. For every matching M(cid:48) in the input graph G, the size of M(cid:48) can be bounded by M(cid:48) ≤ p=1 M(cid:48) ∩ Mp, since at most 2Qk edges can be matched to the vertices of the vertex i∈[Q] Ai ∪ Bi, and the edges of matchings Mp are the only ones not incident to any i∈[Q] Ai ∪ Bi. Hence, by linearity of expectation, and the application of Lemma 2, expected approximation factor of Ω (cid:18)(cid:0) P n (cid:1) 1 (cid:19) . s 4 we obtain: P(cid:88) p=1 (cid:32)√ (cid:33) sk Q EN ≤ 2Qk + ENp ≤ 2Qk + P · O . (4) A maximum matching in G is of size at least k(Q+P ) mation factor: 2 . We hence obtain the expected approxi- where the first inequality follows from Jensen's inequality, and the third equality uses Q = o(P ). The previous expression is maximized for Q = , and we obtain an approximation E 1 2 k(Q + P ) N ≥ 1 2 k(Q + P ) EN (cid:32) = Ω √ √ P Q k k + P √ = Ω Q2 (cid:33) √ (Q + P )Q k √ Q2 s k + P √ , (5) (cid:32) (cid:33)  = Ω √ k√ Q s , } (cid:17)  k(Q + P ) (cid:16) Qk + P · √ (cid:32) (cid:33) min{ P Q (cid:16) P (cid:17)1/2 = Ω sk Q s √ s√ k 8 (cid:19) (cid:18) P 1 4 1 2 k 1 4 factor of Ω . In turn, this expression is maximized when k is as large as possible, that is, k = n/P (remember that the possible range for k is P ≤ k ≤ n/P ). We hence conclude that (cid:117)(cid:116) the approximation factor is Ω((cid:0) P n (cid:1) 1 4 ). s s Lower Bound for Randomized Protocols. Last, in Theorem 2 (proof in appendix), we extend our determinstic lower bound to randomized ones. Theorem 2. For any P ≤ √ n, let Prand be a P -party randomized simultaneous message (cid:18)(cid:0) P n (cid:1) 1 4 (cid:19) s . protocol for maximum matching with error at most  < 1/2, and all messages are of size at most s. Then, Prand has an approximation factor of Ω Our lower bound for one-pass turnstile algorithms now follows from the reduction given in [22] and the application of Theorem 2 for P = Corollary 1. For every 0 ≤  ≤ 1, every randomized constant error turnstile one-pass stream- ing algorithm for maximum bipartite matching with approximation ratio n uses space Ω 2−4(cid:17) (cid:16) n. n 3 . √ 5 Upper Bound Algorithm 1 Bipartite Matching algorithm Require: G = (A, B, E) {Bipartite input graph} 1: A(cid:48) ← subset of A of size k chosen uniformly at random 2: ∀a ∈ A(cid:48) : E(cid:48)[a] ← arbitrary subset of incident edges of a of size min{k, degG(a)} 3: return maximum matching in(cid:83) a∈A(cid:48) E(cid:48)[a] In this section, we first present a simple randomized algorithm for bipartite matching. Then, we will discuss implementations of this algorithm as a simultaneous message protocol and as a dynamic one-pass streaming algorithm. Bipartite Matching Algorithm. Consider Algorithm 1. First, a subset A(cid:48) ⊆ A consisting of k vertices is chosen uniformly at random. Then, for each vertex a ∈ A(cid:48), the algorithm picks arbitrary k incident edges. Finally, a maximum matching among the retained edges is computed and returned. Clearly, the algorithm stores at most k2 edges. The proof of the next lemma concerning the approximation ratio of Algorithm 1 is deferred to the appendix. Lemma 4. Let G = (A, B, E) be a bipartite graph with A + B = n. Then, Algorithm 1 has an expected approximation ratio of n k . let E(cid:48) =(cid:83) Notations. In the proof of Lemma 4, we use the following additional notation. Let G = (A, B, E) be a bipartite graph. For a set of edges E(cid:48) ⊆ E, we denote by A(E(cid:48)) the subset of A vertices a for which there exists at least one edge in E(cid:48) incident to a. The set B(E(cid:48)) is defined similarly. Proof. Let M denote the output of the algorithm, let M∗ be a maximum matching in G, and a∈A(cid:48) E(cid:48)[a]. Let A(cid:48)∗ = A(cid:48) ∩ A(M∗). As A(cid:48) has been chosen uniformly at random, we have EA(cid:48)∗ = kA(M∗) . We will prove now that the algorithm can match all vertices in A(cid:48)∗. This then implies the result, as M ≥ A(cid:48)∗, and M ≤ EM∗ EM∗ A(cid:48)∗ = M∗A kA(M∗) = ≤ n/k, A k A 9 To this end, we construct a matching M(cid:48) that matches all vertices of A(cid:48)∗. Let A(cid:48)∗ where we used A(M∗) = M∗. that for every a ∈ A(cid:48)∗ by M1 ⊆ M∗ the subset of optimal edges incident to the vertices A(cid:48)∗ 1 ⊆ A(cid:48)∗ so 1 , the incident edge of a in M∗ has been retained by the algorithm. Denote 2 = A(cid:48)∗ \ A(cid:48)∗ 1 . 1 . Then, let A(cid:48)∗ Consider now the graph G on vertices A(cid:48)∗ {e ∈ E(cid:48) : e = (a, b) with a ∈ A(cid:48)∗ 2 and B \ B(M1) and edges 2 and b ∈ B \ B(M1)}. Note that as for every vertex a ∈ A(cid:48)∗ 2 , its optimal incident edge has not been retained, k different edges have been retained (which also implies that the degree of a in G is at least k). Therefore, the degree of every a ∈ G is at least k −B(M1) = k −M1. Furthermore, note that 2 = k − A(cid:48)∗ A(cid:48)∗ 1 = k − M1. Thus, by Hall's marriage theorem, there exists a matching M2 in G matching all vertices A(cid:48)∗ We set M(cid:48) = M1∪M2 and all vertices of A(cid:48)∗ are matched. We obtain M(cid:48) = M1+M2 = k, (cid:117)(cid:116) 2 , and hence, M2 = k − M1. and the result follows. Implementation of Algorithm 1 as a Simultaneous Message Protocol. Algorithm 1 can be im- plemented in the simultaneous message model as follows. Using shared random coins, the P parties agree on the subset A(cid:48) ⊆ A. Then, for every a ∈ A(cid:48), every party chooses arbitrary min{degGi(a), k} edges incident to a and sends them to the referee. The referee computes a maximum matching in the graph induced by all received edges. As the referee receives a su- perset of the edges as described in Algorithm 1, the same approximation factor as in Lemma 4 holds. We hence obtain the following theorem: Theorem 3. For every P ≥ 1, there is a randomized P -party simultaneous message protocol for maximum matching with expected approximation factor nα and all messages are of size O(n2−2α). Implementation of Algorithm 1 as a Dynamic Streaming Algorithm. We employ the technique of l0 sampling in our algorithm [16]. For a turnstile stream that describes a vector x, a l0-sampler samples uniformly at random from the non-zero coordinates of x. Similar to Ahn, Guha, and McGregor [2], we employ the l0-sampler by Jowhari et al. [16]. Their result can be summarized as follows: Lemma 5 ([16]). There exists a turnstile streaming algorithm that performs l0-sampling using space O(log2 n log δ−1) with error probability at most δ. In order to implement Algorithm 1 in the dynamic streaming setting, for every a ∈ A(cid:48), we use enough l0-samplers on the sub-stream of incident edges of a in order to guarantee that with large enough probability, at least min{k, degG(a)} different incident edges of a are sampled. It can be seen that, for a large enough constant c, c· k log n samplers are enough, with probability 1 − 1 nΘ(c) . We make use of the following lemma whose proof is deferred to the appendix. Lemma 6. Let S be a finite set, k an integer, and c a large enough constant. When sampling c · k log n times from S, then with probability 1 − 1 of S have been sampled. nΘ(c) , at least min{k,S} different elements This allows us to conclude with the main theorem of this section. Theorem 4. There exists a one-pass randomized dynamic streaming algorithm for maximum bipartite matching with expected approximation ratio nα using space O(n2−2α). 10 References 1. Ahn, K.J., Guha, S.: Linear programming in the semi-streaming model with application to the maximum matching problem. pp. 526 -- 538. ICALP (2011) 2. Ahn, K.J., Guha, S., McGregor, A.: Analyzing graph structure via linear measurements. pp. 459 -- 467. SODA (2012) 3. Ahn, K.J., Guha, S., McGregor, A.: Spectral sparsification in dynamic graph streams. In: AP- PROX/RANDOM. pp. 1 -- 10 (2013) 4. Assadi, S., Khanna, S., Li, Y., Yaroslavtsev, G.: Tight bounds for linear sketches of approximate matchings. Manuscript (May 2015) 5. Bosek, B., Leniowski, D., Sankowski, P., Zych, A.: Online bipartite matching in offline time. pp. 384 -- 393. FOCS (2014) 6. Chaudhuri, K., Daskalakis, C., Kleinberg, R.D., Lin, H.: Online bipartite perfect matching with augmenta- tions. pp. 1044 -- 1052. INFOCOM (2009) 7. Crouch, M., Stubbs, D.S.: Improved streaming algorithms for weighted matching, via unweighted matching. In: APPROX/RANDOM. pp. 96 -- 104 (2014) 8. Crouch, M.S., McGregor, A., Stubbs, D.: Dynamic graphs in the sliding-window model. In: ESA. pp. 337 -- 348 (2013) 9. Eggert, S., Kliemann, L., Munstermann, P., Srivastav, A.: Bipartite matching in the semi-streaming model. Algorithmica 63(1-2), 490 -- 508 (2012) 10. Epstein, L., Levin, A., Mestre, J., Segev, D.: Improved approximation guarantees for weighted matching in the semi-streaming model. pp. 347 -- 358. STACS (2010) 11. Esfandiari, H., Hajiaghayi, M.T., Liaghat, V., Monemizadeh, M., Onak, K.: Streaming algorithms for esti- mating the matching size in planar graphs and beyond. SODA (2015) 12. Feigenbaum, J., Kannan, S., McGregor, A., Suri, S., Zhang, J.: On graph problems in a semi-streaming model. Theor. Comput. Sci. 348(2), 207 -- 216 (2005) 13. Goel, A., Kapralov, M., Khanna, S.: On the communication and streaming complexity of maximum bipartite matching. pp. 468 -- 485. SODA (2012) 14. Guruswami, V., Onak, K.: Superlinear lower bounds for multipass graph processing. In: CCC. pp. 287 -- 298 (2013) 15. Huang, Z., Radunovic, B., Vojnovic, M., Zhang, Q.: Communication complexity of approximate matching in distributed graphs. STACS (2015) 16. Jowhari, H., Saglam, M., Tardos, G.: Tight bounds for Lp samplers, finding duplicates in streams, and related problems. PODS, New York, NY, USA (2011) 17. Kapralov, M.: Better bounds for matchings in the streaming model. SODA (2013) 18. Kapralov, M., Khanna, S., Sudan, M.: Approximating matching size from random streams. pp. 734 -- 751. SODA (2014) 19. Kapralov, M., Lee, Y.T., Musco, C., Musco, C., Sidford, A.: Single pass spectral sparsification in dynamic streams. In: FOCS. pp. 561 -- 570 (2014) 20. Kapralov, M., Woodruff, D.: Spanners and sparsifiers in dynamic streams. In: PODC. pp. 272 -- 281. PODC '14, ACM, New York, NY, USA (2014) 21. Konrad, C., Magniez, F., Mathieu, C.: Maximum matching in semi-streaming with few passes. AP- PROX/RANDOM (2012) 22. Li, Y., Nguyen, H.L., Woodruff, D.P.: Turnstile streaming algorithms might as well be linear sketches. pp. 174 -- 183. STOC, New York, NY, USA (2014) 23. McGregor, A.: Finding graph matchings in data streams. pp. 170 -- 181. APPROX/RANDOM (2005) 24. McGregor, A.: Graph stream algorithms: A survey. SIGMOD Rec. 43(1) (2014) 25. Muthukrishnan, S.: Data streams: Algorithms and applications. Now Publishers Inc (2005) 26. Zelke, M.: Weighted matching in the semi-streaming model. Algorithmica 62(1-2), 1 -- 20 (2012) 11 A Auxiliary Lemma Lemma 7. For positive integers a, b, c so that c ≤ a − b, the following holds: (cid:19) (cid:18)a − b c (cid:18)a (cid:19) c ≤ · (a − c)b (a − b)b . Proof. (cid:18)a − b (cid:19) c B Missing Proofs (a − b)! (a − b − c)!c! = ≤ a! (a − c)!c! · (a − c)b (a − b)b = (cid:19) (cid:18)a c · (a − c)b (a − b)b . (cid:117)(cid:116) B.1 Missing Proof of Theorem 2 Theorem 2. For any P ≤ √ (cid:18)(cid:0) P n (cid:1) 1 4 (cid:19) n, let Prand be a P -party randomized simultaneous message protocol for maximum matching with error at most , and all messages are of size at most s. s . ing with error probability at most  < 1/2 and approximation factor α. Then, by Yao's lemma, Then, Prand has an approximation factor of Ω Proof. Let Prand be a P -party randomized simultaneous message protocol for maximum match- there exists a deterministic protocol Pdet with approximation ratio α, distributional error , Consider the input distribution as described in Section 3, let G denote all possible input graphs, and for a graph G ∈ G, denote by NG the matching outputted by Pdet. Furthermore, let G ⊆ G denote those inputs on which Pdet errs. have for every G ∈ G \ G: NG ≥ k(Q+P ) A maximum matching in G is of size at least k(Q+P ) . As the approximation factor is α, we and messages of length at most s. . Hence, 2 2α EG∈GNG = (1 − ) · EG∈GNG +  · EG∈G\GNG ≥ (1 − ) k(Q + P ) 2α . From Equation 4 from the proof of Theorem 1, we obtain EG∈GNG ≤ 2Qk + P · O hence (cid:32)√ (cid:33) , and (cid:17) sk Q (cid:16)√  .  k(Q + P ) Qk + P · √ sk Q (1 − ) k(Q + P ) 2α ≤ 2Qk + P · O sk Q , implying α = Ω Note that this term coincides with the term in Inequality 5 of the proof of Theorem 1. Optimizing (cid:117)(cid:116) similarly (k = n/P, Q = 4 . (cid:16) P √ s√ k (cid:17) 1 2 ), we obtain α = Ω(cid:0) P n (cid:1) 1 s B.2 Missing Proof of Lemma 6 Lemma 6. Let S be a finite set, k an integer, and c a large enough constant. When sampling c · k log n times from S, then with probability 1 − 1 of S have been sampled. nΘ(c) , at least min{k,S} different elements 12 1 Proof. We consider the following cases: 1. Suppose that S = k. Then, we have an instance of the coupon collector's problem. The expected number of times an item s ∈ S is sampled is 1 k · c · k log n = c log n. Then, by a Chernoff bound, the probability that s is not sampled is nΘ(c) , and using the union bound, the probability that there exists at least one element from S that has not been sampled is nΘ(c) . 2. Suppose that S < k. This case is clearly easier than the case S = k, as fewer elements have to be sampled (only S instead of k) and the sampling probability for an element is higher. Therefore, the error probability is smaller than in Case 1. 3. Suppose now that S > k. This case is also easier than the case S = k, since the same total number of different samples is required, and the domain from which the samples are chosen from is larger (S instead of k). Therefore, the error probability is also smaller than in Case 1. (cid:117)(cid:116) 1 13
1606.05031
1
1606
2016-06-16T02:55:39
Scalable Partial Least Squares Regression on Grammar-Compressed Data Matrices
[ "cs.DS" ]
With massive high-dimensional data now commonplace in research and industry, there is a strong and growing demand for more scalable computational techniques for data analysis and knowledge discovery. Key to turning these data into knowledge is the ability to learn statistical models with high interpretability. Current methods for learning statistical models either produce models that are not interpretable or have prohibitive computational costs when applied to massive data. In this paper we address this need by presenting a scalable algorithm for partial least squares regression (PLS), which we call compression-based PLS (cPLS), to learn predictive linear models with a high interpretability from massive high-dimensional data. We propose a novel grammar-compressed representation of data matrices that supports fast row and column access while the data matrix is in a compressed form. The original data matrix is grammar-compressed and then the linear model in PLS is learned on the compressed data matrix, which results in a significant reduction in working space, greatly improving scalability. We experimentally test cPLS on its ability to learn linear models for classification, regression and feature extraction with various massive high-dimensional data, and show that cPLS performs superiorly in terms of prediction accuracy, computational efficiency, and interpretability.
cs.DS
cs
Scalable Partial Least Squares Regression on Grammar-Compressed Data Matrices 6 1 0 2 n u J 6 1 ] S D . s c [ 1 v 1 3 0 5 0 . 6 0 6 1 : v i X r a Yasuo Tabei Japan Science and Technology Agency, Japan [email protected] Yoshihiro Yamanishi Kyushu University, Japan [email protected] u.ac.jp ABSTRACT With massive high-dimensional data now commonplace in research and industry, there is a strong and growing de- mand for more scalable computational techniques for data analysis and knowledge discovery. Key to turning these data into knowledge is the ability to learn statistical models with high interpretability. Current methods for learning statisti- cal models either produce models that are not interpretable or have prohibitive computational costs when applied to massive data. In this paper we address this need by pre- senting a scalable algorithm for partial least squares regres- sion (PLS), which we call compression-based PLS (cPLS), to learn predictive linear models with a high interpretability from massive high-dimensional data. We propose a novel grammar-compressed representation of data matrices that supports fast row and column access while the data matrix is in a compressed form. The original data matrix is grammar- compressed and then the linear model in PLS is learned on the compressed data matrix, which results in a significant reduction in working space, greatly improving scalability. We experimentally test cPLS on its ability to learn linear models for classification, regression and feature extraction with various massive high-dimensional data, and show that cPLS performs superiorly in terms of prediction accuracy, computational efficiency, and interpretability. 1. INTRODUCTION Massive data are now abundant throughout research and industry, in areas such as biology, chemistry, economics, dig- ital libraries and data management systems. In most of these fields, extracting meaningful knowledge from a vast amount of data is now the key challenge. For example, to remain competitive, e-commerce companies need to constantly ana- lyze huge data of user reviews and purchasing histories [24]. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full cita- tion on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or re- publish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. KDD '16, August 13-17, 2016, San Francisco, CA, USA c(cid:13) 2016 ACM. ISBN 978-1-4503-4232-2/16/08. . . $15.00 DOI: http://dx.doi.org/10.1145/2939672.2939864 Hiroto Saigo Kyushu University, Japan [email protected] Simon J. Puglisi University of Helsinki, Finland [email protected] In biology, detection of functional interactions of compounds and proteins is an important part in genomic drug discov- ery [29, 7] and requires analysis of a huge number of chem- ical compounds [3] and proteins coded in fully sequenced genomes [4]. There is thus a strong and growing demand for developing new, more powerful methods to make better use of massive data and to discover meaningful knowledge on a large scale. Learning statistical models from data is an attractive ap- proach for making use of massive high-dimensional data. However, due to high runtime and memory costs, learning of statistical models from massive data -- especially models that have high interpretability -- remains a challenge. Partial least squares regression (PLS) is a linear statistical model with latent features behind high-dimensional data [26, 35, 36] that greedily finds the latent features by optimiz- ing the objective function under the orthogonal constraint. PLS is suitable for data mining, because extracted latent features in PLS provide a low-dimensional feature represen- tation of the original data, making it easier for practitioners to interpret the results. From a technical viewpoint, the optimization algorithm in PLS depends only on elementary matrix calculations of addition and multiplication. Thus, PLS is more attractive than other machine learning meth- ods that are based on computationally burdensome mathe- matical programming and complex optimization solvers. In fact, PLS is the most common chemoinformatics method in pharmaceutical research. However, applying PLS to massive high-dimensional data is problematic. While the memory for the optimization algo- rithm in PLS depends only on the size of the corresponding data matrix, storing all high-dimensional feature vectors in the data matrix consumes a huge amount of memory, which limits large-scale applications of PLS in practice. One can use lossy compression (e.g., PCA [14, 9] and b-bit minwise hashing [12, 20]) to compactly represent data matrices and then learn linear models on the compact data matrices [21]. However, although these lossy compression-based methods effectively reduce memory usage [21, 30], their drawback is that they cannot extract informative features from the learned models, because the original data matrices cannot be recovered from the compressed ones. Grammar compression [2, 27, 16] is a method of lossless compression (i.e., the original data can be completely re- Table 1: Summary of scalable learning methods of linear models. Approach Compression Type # of parameters Interpretability Optimization PCA-SL [14, 9] Orthogonal rotation bMH-SL [21] SGD [33, 8] Hashing Sampling Lossy Lossy - cPLS (this study) Grammar compression Lossless 2 3 1 1 Limited Unable Limited High Stable Stable Unstable Stable covered from grammar-compressed data) that also has a wide variety of applications in string processing, such as pattern matching [37], edit-distance computation [13], and q-gram mining [1]. Grammar compression builds a small context-free grammar that generates only the input data and is very effective at compressing sequences that contain many repeats. In addition, the set of grammar rules has a convenient representation as a forest of small binary trees, which enables us to implement various string operations without decompression. To date, grammar compression has been applied only to string (or sequence) data; however, as we will see, there remains high potential for application to other data representations. A fingerprint (or bit vector) is a powerful representation of natural language texts [23], bio-molecules [32], and images [11]. Grammar compression is expected to be effective for compressing a set of finger- prints as well, because fingerprints belonging to the same class share many identical features. Contribution. In this paper, we present a new scalable learning algorithm for PLS, which we call lossless compression- based PLS (cPLS), to learn highly-interpretable predictive linear models from massive high-dimensional data. A key idea is to convert high-dimensional data with fingerprint rep- resentations into a set of sequences and then build grammar rules for representing the sequences in order to compactly store data matrices in memory. To achieve this, we propose a novel grammar-compressed representation of a data ma- trix capable of supporting row and column access while the data matrix is in a compressed format. The original data matrix is grammar-compressed, and then a linear model is learned on the compressed data matrix, which allows us to significantly reduce working space. cPLS has the following desirable properties: 1. Scalability: cPLS is applicable to massive high-dimensional data. 2. Prediction Accuracy: cPLS can achieve high predic- tion accuracies for both classification and regression. 3. Usability: cPLS has only one hyper parameter, which enhances the usability of cPLS. 4. Interpretability: Unlike lossy compression-based meth- ods, cPLS can extract features reflecting the correlation structure between data and class labels/response vari- ables. We experimentally test cPLS on its ability to learn linear models for classification, regression and feature extraction with various massive high-dimensional data, and show that cPLS performs superiorly in terms of prediction accuracy, computational efficiency, and interpretability. 2. LITERATURE REVIEW Several efficient algorithms have been proposed for learn- ing linear models on a large scale. We now briefly review the state of the art, which is also summarized in Table 1. Principal component analysis (PCA) [14] is a widely used machine learning tool, and is a method of lossy compression, i.e., the original data cannot be recovered from compressed data. There have been many attempts to extend PCA [31, 28] and present a scalable PCA in distributed settings for an- alyzing big data [9]. For classification and regression tasks, a data matrix is compressed by PCA, and linear models are learned on the compressed data matrix by a supervised learning method (SL), which is referred to as PCA-SL. De- spite these attempts, PCA and its variants do not look at the correlation structure between data and output variables (i.e., class labels/response variables), which results in not only the inability of feature extractions in PCA but also the inaccurate predictions by PCA-SL. Li et al. [21] proposed a compact representation of finger- prints for learning linear models by applying b-bit minwise hashing (bMH). A d-dimensional fingerprint is conceptually equivalent to the set si ⊂ {1, ..., d} that contains element i if and only if the i-th bit in the fingerprint is 1. Li et al.'s method works as follows. We first pick h random permuta- tions πi, i = 1, .., h, each of which maps [1, d] to [1, d]. We then apply a random permutation π on a set si, compute the minimum element as min(π(si)), and take as a hash value its lowest b bits. Repeating this process h times generates h hash values of b bits each. Expanding these h values into a (2b × h)-dimensional fingerprint with exactly h 1's builds a compact representation of the original fingerprint. Linear models are learned on the compact fingerprints by SL, which is referred to as bMH-SL. Although bMH-SL is applicable to large-scale learning of linear models, bMH is a method of lossy compression and cannot extract features from linear models learned by SL. Other hashing-based ap- proaches have been proposed such as Count-Min sketch [5], Vowpal Wabbit [34], and Hash-SVM [25]. However, like bMH-SL, these algorithms cannot extract features, which is a serious problem in practical applications. Stochastic gradient descent (SGD) [8, 33] is a computa- tionally efficient algorithm for learning linear models on a large-scale. SGD samples ν feature vectors from an input dataset and computes the gradient vector from the sampled feature vectors. The weight vector in linear models is up- dated using the gradient vector and the learning rate µ, and this process is repeated until convergence. Unfortunately however, learning linear models using SGD is numerically unstable, resulting in low prediction accuracy. This is be- cause SGD has three parameters (ν, µ, and C) that must be optimized if high classification accuracy is to be attained. Online learning is a specific version of SGD that loads an input dataset from the beginning and updates the weight vector in a linear model for each feature vector. AdaGrad [8] is an efficient online learning that automatically tunes pa- rameters of ν and µ in SGD. Although online learning is space-efficient (owing to its online nature), it is also numer- ically unstable. Even worse, AdaGrad is applicable only new non-terminal. Each iteration of the algorithm consists of the following two steps: (i) find the most frequent pair of symbols in the current sequence, and then (ii) replace the most frequent pair with a new non-terminal symbol, gener- ating a new grammar rule and a new (and possibly much shorter) sequence. Steps (i) and (ii) are then applied to the new sequence and iterated until no pair of adjacent symbols appears twice. Apart from the dictionary D that stores the rules as they are generated, Re-Pair maintains a hash table and a pri- ority queue that together allow the most frequent pair to be found in each iteration. The hash table, denoted by H, holds the frequency of each pair of adjacent symbols ab in the current sequence, i.e., H : ab → N. The priority queue stores the symbol pairs keyed on frequency and allows the most frequent symbol to be found in step (i). In step (ii), a new grammar rule Z1 → ab is generated where ab is the most frequent symbol pair and Z1 is a new non-terminal not appearing in a sequence. The rule is stored in the dictionary D. Every occurrence of ab in the sequence is then replaced by Z1, generating a new, shorter sequence. This replacement will cause the frequency of some symbol pairs to change, so the hash table and priority queue are then suitably updated. Let sc denote a sequence generated at c-th iteration in the Re-Pair algorithm. For input sequence s in Figure 1, the most frequent pair of symbols is 12. Thus, we generate rule Z1 → 12 to be added to the dictionary D and replace all the occurrences of 12 by non-terminal Z1 in s. After four iterations, the current sequence s4 has no repeated pairs, and thus the algorithm stops. Dictionary D has four grammar rules that correspond to a forest of two small trees. As described by Larsson and Moffat [19], Re-Pair can be implemented to run in linear time in the length of the input sequence, but it requires the use of several heavyweight data structures to track and replace symbol pairs. The overhead of these data structures (at least 128 bits per position) pre- vents the algorithm from being applied to long sequences, such as the large data matrices. Another problem that arises when applying Re-Pair to long sequences is the memory required for storing the hash table: a considerable number of symbol pairs appear twice in a long sequence, and the hash table stores something for each of them, consuming large amounts of memory. In the next section, we present scalable Re-Pair algorithms that achieve both space-efficiency and fast compression time on large data matrices. Specifically, our algorithms need only constant working space. 4. OUR GRAMMAR-COMPRESSED DATA MATRIX Our goal is to obtain a compressed representation of a data matrix X of n rows and d columns. Let xi denote the ith row of the matrix represented as a fingerprint (i.e. binary vector). An alternative view of a row that will be useful to us is as a sequence of integers si = (p1, p2, ..., pm), p1 < p2 < ··· < pm, where pi ∈ si if and only if xi[pi] = 1. In other words the sequence si indicates the positions of the 1 bits in xi. In what follows we will deal with a differentially encoded form of si in which the difference for every pair of adjacent elements in si is stored, i.e., si = (p1, p2, ..., pm) is encoded as sgi = (p1, p2 − p1, p3 − p2, ..., pm − pm−1). This differ- Figure 1: Illustration of grammar compression. to differentiable loss functions, which limits its applicability to simple linear models, e.g., SVM and logistic regression, making the learned model difficult to interpret. Despite the importance of scalable learning of interpretable linear models, no previous work has been able to achieve high prediction accuracy for classification/regression tasks and high interpretability of the learned models. We present a scalable learning algorithm that meets both these demands and is made possible by learning linear models on grammar- compressed data in the framework of PLS. Details of the proposed method are presented in the next section. 3. GRAMMAR COMPRESSION Given a sequence of integers S, a grammar-compressor generates a context-free grammar (CFG) that generates S and only S. The grammar consists of a set of rules1. Each rule is of the form Zi → ab. Symbols that appear on the left- hand side of any rule are called non-terminals. The remain- ing symbols are called terminals, all of which are present in Informally, a rule Zi → ab indicates the input sequence. that on the way to recovering the original sequence from its grammar-compressed representation, occurrences of the symbol Zi should be replaced by the symbol pair ab (the resulting sequence may then be subject to yet more replace- ments). A data structure storing a set of grammar rules is called a dictionary and is denoted by D. Given a non- terminal, the dictionary supports access to the symbol pair on the right-hand of the corresponding grammar rule, i.e., D[Zi] returns ab for rule Zi → ab. The original sequence can be recovered from the compressed sequence and D. The set of grammar rules in D can be represented as a forest of (pos- sibly small) binary trees called grammar trees, where each node and its left/right children correspond to a grammar rule. See Figure 1 for an illustration. The size of a grammar is measured as the number of rules plus the size of compressed sequence. The problem of finding the minimal grammar producing a given string is known to be NP-complete [2], but several approximation algorithms exist that produce grammars that are small in practice (see, e.g., [27, 19, 16]). Among these is the simple and elegant Re-Pair [19] algorithm, which we review next. 3.1 Re-Pair Algorithm The Re-Pair grammar compression algorithm by Larsson and Moffat [19] builds a grammar by repeatedly replacing the most frequent symbol pair in an integer sequence with a 1In this paper we assume without loss of generality that the grammar is in Chomsky Normal Form. (i) Input sequence (ii) Compressed sequence and dictionary . The dictionary corresponds to a forest of grammar trees. ential encoding tends to increase the number of repeated symbol pairs, which allows the sequences sgi to be more ef- fectively compressed by the Re-Pair algorithm. A grammar compressor captures the underlying correlation structure of data matrices: by building the same grammar rules for the same (sequences of) integers, it effectively compresses data matrices with many repeated integers. 4.1 Re-Pair Algorithms in Constant Space We now present two ideas to make Re-Pair scalable with- out seriously deteriorating its compression performance. Our first idea is to modify the Re-Pair algorithm to identify top- k frequent symbol pairs in all rows sc gi in step (i) and replace all the occurrences of the top-k symbol pairs in all rows sc gi in step (ii), generating new k grammar rules and new rows sc+1 . This new replacement process improves scalability by gi reducing the number of iterations required by roughly a fac- tor of k. Since we cannot replace both frequent symbol pairs ab and bc in triples abc in step (ii), we replace the first appearing symbol pair ab, preferentially. However, such preferential replacement can generate a replacement of a pair only once and can add redundant rules to a dictionary, adversely af- fecting compression performance. To overcome this prob- lem, we replace the first and second appearances of each fre- quent pair at the same time and replace the next successive appearance of the frequent pair as usual, which guarantees generating grammar rules that appear at least twice. Our second idea is to reduce the memory of the hash table by removing infrequent symbol pairs. Since our modified Re-Pair algorithm can work storing compressed sequences sc gi at each iteration c in a secondary storage device, the hash table consumes most of the memory in execution. Our modified Re-Pair generates grammar rules from only top-k frequent symbol pairs in the hash table, which means only frequent symbol pairs are expected to contribute to the com- pression. Thus, we remove infrequent symbol pairs from the hash table by leveraging the idea behind stream mining tech- niques originally proposed in [15, 6, 22] for finding frequent items in data stream. Our method is a counter-based al- gorithm that computes the frequency of each symbol pair and removes infrequent ones from the hash table at each in- terval in step (i). We present two Re-Pair algorithms using lossy counting and frequency counting for removing infre- quent symbol pairs from the hash table. We shall refer to the Re-Pair algorithms using lossy counting and frequency counting as Lossy-Re-Pair and Freq-Re-Pair, respectively. 4.2 Lossy-Re-Pair The basic idea of lossy counting is to divide a sequence of symbols into intervals of fixed length and keep symbol pairs in successive intervals in accordance with their appearance frequencies in a hash table. Thus, if a symbol pair has ap- peared h times in the previous intervals, it is going to be kept in the next h successive intervals. Let us suppose a sequence of integers made by concate- nating all rows sgi of X and let N be the length of the sequence. We divide the sequence into intervals of fixed- length (cid:96). Thus, the number of intervals is N/(cid:96). We use hash table H for counting the appearance frequency of each symbol pair in the sequence. If symbol pair ab has count H(ab), it is ensured that ab is kept in hash table H until the next H(ab)-th interval. If symbol pair ab first appears in the q-th interval, H(ab) is initialized as qN/(cid:96) + 1, which en- sures that ab is kept until at least the next interval, i.e., the (qN/(cid:96) + 1)-th interval. Algorithm 1 shows the pseudo-code of lossy counting. The estimated number of symbol pairs in the hash table is O((cid:96)) [22], resulting in O((cid:96) log (cid:96)) bits consumed by the hash table. N = N + 1 if H(ab) (cid:54)= 0 then Algorithm 1 Lossy counting. H: hash table, N : length of an input string at a time point, (cid:96): length of each interval. Note that lossy counting can be used in step (i) in the Re- Pair algorithm. 1: Initialize N = 0 and ∆ = 0 2: function LossyCounting(a, b) 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: H(ab) = ∆ + 1 (cid:96) (cid:99) (cid:54)= ∆ then ∆ = (cid:98) N (cid:96) (cid:99) for each symbol pair ab in H do if H(ab) < ∆ then H(ab) = H(ab) + 1 Remove ab from H else if (cid:98) N 4.3 Freq-Re-Pair The basic idea of frequency counting is to place a limit, v, on the maximum number of symbol pairs in hash table H and then keep only the most frequent v symbol pairs in H. Such frequently appearing symbol pairs are candidates to be replaced by new non-terminals, which generates a small number of rules. The hash table counts the appearance frequency for each symbol pair in step (i) of the Re-Pair algorithm. When the number of symbol pairs in the hash table reaches v, Freq- Re-Pair removes the bottom  percent of symbol pairs with respect to frequency. We call  the vacancy rate. Algo- rithm 2 shows the pseudo-code of frequency counting. The space consumption of the hash table is O(v log v) bits. Algorithm 2 Frequency counting. H: hash table, H: number of symbol pairs in H, v: the maximum number of symbol pairs in H, : vacancy rate. Note that frequency counting can be used in step (i) in the Re-Pair algorithm. 1: function FrequencyCounting(a, b) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: while v(1 − /100) < H do H(a(cid:48)b(cid:48)) = H(a(cid:48)b(cid:48)) − 1 if H(a(cid:48)b(cid:48)) = 0 then H(ab) = H(ab) + 1 if H ≥ v then for each symbol pair a(cid:48)b(cid:48) in H do Remove a(cid:48)b(cid:48) from H if H(ab) (cid:54)= 0 then else H(ab) = 1 5. DIRECT ACCESS TO ROW AND COL- UMN In this section, we present algorithms for directly accessing rows and columns of a grammar-compressed data matrix, which is essential for us to be able to apply PLS on the compressed matrix in order to learn linear regression models. 5.1 Access to Row Accessing the i-th row corresponds to recovering the orig- inal si from grammar-compressed sc gi. We compute this op- eration by traversing the grammar trees. For recovering the i-th row si, we start traversing the grammar tree having a node of the q-th symbol sc gi[q] as a root for each q from 1 gi. Leaves encountered in the traversal must have inte- to sc gers in sequence sgi, which allows us to recover sgi via tree traversals, starting from the nodes with non-terminal sc gi[q] for each q ∈ [1,sc gi]. We recover the original i-th row si from sgi by cumulatively adding integers in sgi from 1 to sgi, i.e, si[1] = sgi[1], si[2] = sgi[2] + si[1],...,si[sgi] = sgi[sgi] + si[sgi − 1]. 5.2 Access to Column Accessing the j-th column of a grammar-compressed data matrix requires us to obtain a set of row identifiers R such that xij = 1 for i ∈ [1, n], i.e., R = {i ∈ [1, n]; xij = 1}. (cid:124) from This operation enables us to compute the transpose X X in compressed format, which is used in the optimization algorithm of PLS. P [Zi] stores a summation of terminal symbols as inte- gers at the leaves under the node corresponding to terminal symbol Zi in a grammar tree. For example, in Figure 1, P [Z1] = 3, P [Z2] = 6, P [Z3] = 8 and P [Z4] = 4. P can be implemented as an array that is randomly accessed from a given non-terminal symbol. We shall refer to P as the weight array. The size of P depends only on the grammar size. gi[1]] + P [sc gi[2]] +··· + P [sc The j-th column is accessed to check whether or not xij = gi, for each i ∈ [1, n]. We effi- 1 in compressed sequence sc ciently solve this problem on grammar-compressed data ma- trix by using the weight array P . Let uq store the summa- tion of weights from the first symbol sc gi[1] to the q-th symbol gi[q], i.e., uq = P [sc sc gi[q]], and let u0 = 0. If uq is not less than j, the grammar tree with the node corresponding to a symbol sc gi[q] as a root can encode j at a leaf. Thus, we traverse the tree in depth-first or- der from the node corresponding to symbol sc gi[q] as follows. Suppose Z = sc gi[q] and u = uq−1. Let Z(cid:96) (resptively Zr) be a (respectively b) of Z → ab in D. (i) if j < u, we go down to the left child in the tree; (ii) otherwise, i.e., j ≥ u, we add P [Z(cid:96)] to u and go down to the right child. We continue the traversal until we reach a leaf. If s = j at a leaf, this should be xij = 1 at row i; thus we add i to solution set R. Algorithm 3 shows the pseudo-code for column access. 6. CPLS In this section we present our cPLS algorithm for learn- ing PLS on grammar-compressed data matrices. We first review the PLS algorithm on uncompressed data matrices. NIPALS [35] is the conventional algorithm for learning PLS and requires the deflation of the data matrix involved. We thus present a non-deflation PLS algorithm for learning PLS on compressed data matrices. 6.1 NIPALS Let us assume a collection of n data samples and their out- put variables (x1, y1), (x2, y2), ..., (xn, yn) where yi ∈ (cid:60). The i=1 yi = output variables are assumed to be centralized as(cid:80)n gi[q]] for i in 1..n do u0 = 0 for q in 1..sc gi do uq = uq−1 + P [Sc if j ≤ uq then Algorithm 3 Access to the j-th column on grammar- compressed data matrix. R: solution set of row identifiers i at column j s.t. xij = 1. 1: function AccessColumn(j) 2: 3: 4: 5: 6: 7: 8: 1: function Recursion(i,j,Z,u) 2: 3: 4: 5: 6: 7: 8: 9: 10: Set Zl (resp. Zr) as a (resp. b) of Z → ab in D if u + P [Zl] > j then Recursion(i,j,Zr,u + P [Zl]) (cid:46) Go to right child Recursion(i, j, sc break if Z is a terminal symbol then Recursion(i,j,Zl,u) if u + Z = j then (cid:46) Go to left child gi[q], uq−1) Add i to R return else 0. Denote by y ∈ (cid:60)n the vector of all the training output variables, i.e., y = (y1, y2, ..., yn) (cid:124) . The regression function of PLS is represented by the fol- lowing special form, f (x) = αiw (cid:124) i x, m(cid:88) (cid:26) 1 i = j i=1 0 i (cid:54)= j where the wi are weight vectors reducing the dimensionality of x; they satisfy the following orthogonality condition: (cid:124) (cid:124) i X w Xwj = . (1) We have two kinds of variables wi and αi to be optimized. Denote by W ∈ (cid:60)d×m the weight matrix i-th column of which is weight vector wi, i.e., W = (w1, w2, ..., wm). Let α ∈ (cid:60)m be a vector whose i-th element is αi, i.e., α = (cid:124) (α1, α2, ..., αm) . Typically, W is first optimized and then α is determined by minimizing the least squares error without regularization, y − XWα2 2. min α (2) By computing the derivative of equation (2) with respect to α and setting it to zero, α is obtained as follows: (cid:124) α = (W (cid:124) X XW) (cid:124) −1W (cid:124) X y. (3) The weight vectors are determined by the following greedy algorithm. The first vector w1 is obtained by maximizing the squared covariance between the mapped feature Xw and the output variable y as follows: w1 = argmaxw cov2(Xw, y), subject to w Xw. The (cid:124) problem can be analytically solved as w1 = X Xw = 1, where cov(Xw, y) = y y. (cid:124) X (cid:124) (cid:124) For the i-th weight vector, the same optimization problem is solved with additional constraints to maintain orthogonal- ity, cov2(Xw, y), wi = argmax (4) wj = 0, j = 1, ..., i − 1. subject to w The optimal solution of this problem cannot be obtained an- alytically, but NIPALS solves it indirectly. Let us define the Xw = 1, w (cid:124) X (cid:124) X (cid:124) X (cid:124) (cid:124) w i-th latent vector as ti = Xwi. The optimal latent vectors ti are obtained first and the corresponding wi is obtained later. NIPALS performs the deflation of design matrix X to ensure the orthogonality between latent components ti as (cid:124) follows, X = X − tit i X. Then, the optimal solution has the (cid:124) form, wi = X Due to the deflation, X = X− tit (cid:124) i X, NIPALS completely destroys the structure of X. Thus, it cannot be used for learning PLS on grammar-compressed data matrices. 6.2 cPLS Algorithm y. (cid:124) We present a non-deflation PLS algorithm for learning PLS on grammar-compressed data matrices. Our main idea here is to avoid deflation by leveraging the connection be- tween NIPALS [35] and the Lanczos method [18] which was originally proposed for recursive fitting of residuals without changing the structure of a data matrix. We define residual ri+1 = (ri − (y ti−1)ti−1) that is ini- tialized as r1 = y. The i-th weight vector is updated as wi = (ri−1 − (y (cid:124) ti−1)ti−1), which means wi can be computed X without deflating the original data matrix X. The i-th la- tent vector is computed as ti = Xwi and is orthogonalized by applying the Gram-Schmidt orthogonalization to the i-th la- tent vector ti and previous latent vectors t1,t2,...,ti−1 as fol- (cid:124) lows, ti = (I−Ti−1T i−1)Xwi, where Ti−1 = (t1, t2, ..., ti−1) ∈ (cid:60)n×(i−1). The non-deflation PLS algorithm updates the residual ri instead of deflating X, thus enabling us to learn PLS on grammar-compressed data matrices. (cid:124) cPLS is the non-deflation PLS algorithm that learns PLS on grammar-compressed data matrices. The input data ma- trix is grammar-compressed and then the PLS is learned on the compressed data matrix by the non-deflation PLS al- gorithm. Our grammar-compressed data matrix supports row and column accesses directly on the compressed format for computing matrix calculations of addition and multi- plication, which enables us to learn PLS by using the non- deflation PLS algorithm. Let XG be the grammar-compressed data matrix of X. Algorithm 4 shows the pseudo-code of cPLS. Since our grammar-compression is lossless, the cPLS algorithm on grammar-compressed data matrices learns the same model as the non-deflation PLS algorithm on uncom- pressed data matrices and so achieves the same prediction accuracy. Algorithm 4 The cPLS algorithm. XG: the grammar- compressed data matrix of X. 1: r1 = y 2: for i = 1, ..., m do 3: 4: 5: 6: 7: 8: 9: 10: Compute the coefficients α using equation (3). (cid:124) wi = X Gri if i = 1 then t1 = XGwi (cid:124) ti = (I − Ti−1T i−1)XGwi else ti = ti/ti2 ri+1 = ri − (y (cid:46) access to column (cid:46) access to row (cid:46) access to row (cid:124) ti)ti We perform feature extraction after line 3 at each iter- ation in Algorithm 4. The features corresponding to the top-u largest weights wi are extracted. Due to the orthogo- nality condition (1), the extracted features give users a novel insight for analyzing data, which is shown in Section 7. The cPLS algorithm has three kinds of variables to be optimized: wi, ri, and ti. The memory for wm is O(md) and the memory for tm and ri is O(mn). Thus, the total memory for the variables in cPLS is O(m min(n, d)) highly depending on parameter m. The parameter m controls the amount of fitting of the model to the training data and is typically chosen to optimize the cross validation error. Since the cPLS algorithm learns the model parameters efficiently, m can be set to a small value, which results in overall space- efficiency. 7. EXPERIMENTS In this section, we demonstrate the effectiveness of cPLS with massive datasets. We used five datasets, as shown in Table 2. "Book-review" consists of 12,886,488 book reviews in English from Amazon [24]. We eliminated stop-words from the reviews and then represented them as 9,253,464 dimensional fingerprints, where each dimension of the finger- print represents the presence or absence of a word. "Com- pound" is a dataset of 42,682 chemical compounds that are represented as labeled graphs. We enumerated all the sub- graphs of at most 10 vertices from the chemical graphs by using gSpan [38] and then converted each chemical graph into a 52,099 dimensional fingerprint, where each dimension of the fingerprint represents the presence or absence of a chemical substructure. "Webspam" is a dataset of 16,609,143 fingerprints of 350,000 dimensions2. "CP-interaction" is a dataset of 216,121,626 compound-protein pairs, where each compound-protein pair is represented as a 3,621,623 dimen- sional fingerprint and 300,202 compound-protein pairs are interacting pairs according to the STITCH database [17]. We used the above four datasets for testing the binary classi- fication ability. "CP-intensity" consists of 1,329,100 compound- protein pairs represented as 682,475 dimensional fingerprints, where the information about compound-protein interaction intensity was obtained from several chemical databases (e.g., ChEMBL, BindingDB and PDSP Ki). The intensity was observed by IC50 (half maximal (50%) inhibitory concen- tration). We used the "CP-intensity" dataset for testing the regression ability. The number of all the nonzero dimensions in each dataset is summarized in the #nonzero column in Table 2, and the size for storing fingerprints in memory by using 32bits for each element is written in the memory col- umn in Table 2. We implemented all the methods by C++ and performed all the experiments on one core of a quad-core Intel Xeon CPU E5-2680 (2.8GHz). We stopped the execu- tion of each method if it had not finished within 24hours in the experiments. In the experiments, cPLS did not use a secondary storage device for compression, i.e., cPLS com- pressed data matrices by loading all data in memory. 7.1 Compression Ability and Scalability First, we investigated the influence on compression perfor- mance of the top-k parameter in our Re-Pair algorithms. For this setting, we used the Lossy-Re-Pair algorithm, where pa- rameter (cid:96) is set to the total length of all rows in an input data matrix in order to keep all the symbols in the hash table. We examined k = {1× 104, 2.5× 104, 5× 104, 7.5× 104, 10× 104} for the Book-review, Compound and Webspam datasets and examined k = {1× 105, 2.5× 105, 5× 105, 7.5× 105, 10× 105} for the CP-interaction and CP-intensity datasets. 2The dataset is downloadable from http://www.csie.ntu. edu.tw/cjlin/libsvmtools/datasets/binary.html. Table 2: Summary of datasets. Dataset Book-review Compound Webspam CP-interaction CP-intensity Label type binary binary binary binary real Number Dimension 9,253,464 52,099,292 16,609,143 3,621,623 682,475 12,886,488 42,682 350,000 216,121,626 1,329,100 #nonzeros Memory (mega bytes) 698,794,696 2,665 3,489 914,667,811 4,977 1,304,697,446 125,243 32,831,736,508 28,865,055,991 110,111 Book-review Compound Webspam CP-interaction CP-intensity Figure 2: Compression size in mega bytes (MB) and compression time in seconds (sec) for various top-k Figure 2 shows compression size and compression time for various top-k. We observed a trade-off between com- pressed size and compression time for all the datasets. The smaller the compressed size, the larger the compression time for larger values of k. In particular, significantly faster com- pression time was possible at the cost of only slightly worse compression. For example, Lossy-Re-Pair took 57,290 sec- onds to compress the Book-review dataset and its size was 1,498 mega bytes (MB) for k=10000. When k=100000, com- pression time dropped to 20,004 seconds (less than half), while compressed size increased negligibly to 1,502MB. The same trends for the Book-review dataset were ob- served in the other datasets, which suggests that in prac- tice a large value of k can be chosen for fast compression, without adversely affecting compression performance. No- tably, we observed our compression method to be particu- larly effective for the larger datasets: CP-interaction and CP-intensity. The original sizes of CP-interaction and CP- intensity were 125GB and 110GB, respectively, while the compressed sizes of CP-interaction and CP-intensity were at most 5GB and at 535MB, respectively. Our compression method thus achieved compression rates of 4% and less than 1% for CP-interaction and CP-intensity, respectively. Such significant reductions in data size enable the PLS algorithm to scale to massive data. Next, we evaluated the performance of Lossy-Re-Pair and Freq-Re-Pair, where parameters (cid:96)={1MB, 10MB, 100MB, 1000MB} were examined for Lossy-Re-Pair, and parameters v ={1MB, 10MB, 100MB, 1000MB} and  = {30} were ex- amined for Freq-Re-Pair. Table 3 shows the compressed size, compression time and the working space used for the hash table in Lossy-Re-Pair and Freq-Re-Pair. We observed that both Lossy-Re-Pair and Freq-Re-Pair achieved high com- pression rates using small working space. Such efficiency is crucial when the goal is to compress huge data matrices that exceed the size of RAM; our Re-Pair algorithm can compress data matrices stored in external memory (disk). For compressing the CP-interaction dataset, Lossy-Re-Pair and Freq-Re-Pair consumed 16GB and 13GB, respectively, achieving a compressed size of 5GB. We observed the same tendency for the other datasets (See Table 3). 7.2 Prediction Accuracy We evaluated the classification and regression capabilities of cPLS, PCA-SL, bMH-SL and SGD. Following the previ- ous works [39, 21], we randomly selected 20% of samples for testing and used the remaining 80% of samples for training. cPLS has one parameter m, so we selected the best param- eter value among m = {10, 20, ..., 100} that achieved the highest accuracy for each dataset. The PCA phase of PCA- SL has one parameter deciding the number of principal com- ponents m, which was chosen from m = {10, 25, 50, 75, 100} whose maximum value of 100 is the same as that of cPLS's parameter m. Linear models were learned with LIBLIN- EAR [10], one of the most efficient implementations of lin- ear classifiers, on PCA's compact feature vectors, where the hinge loss of linear SVM for classification and the squared er- ror loss for regression were used with L2-regularization. The learning process of PCA-SL [14, 9] has one parameter C for L2-regularization, which was chosen from C = {10−5, 10−4, ..., 105}. For PCA-SL [14, 9], we examined all possible com- binations of two parameters (m and C) and selected the best combination achieving the highest accuracy for each dataset. The hashing process of bMH-SL [21] has two parameters (the number of hashing values h and the length of bits b), so we examined all possible combinations of h = {10, 30, 100} and b = {8, 16}. As in PCA-SL, linear models were learned with LIBLINEAR [10] on bMH's compact feature vectors, where the hinge loss of linear SVM for classification and the squared error loss for regression were used with L2- regularization. The learning process of bMH-SL [21] has one parameter C for L2-regularization, which was chosen from C = {10−5, 10−4, ..., 105}. For bMH-SL, we exam- ined all possible combinations of three parameters (h, b, and C) and selected the best combination achieving the highest accuracy for each dataset. We implemented SGD on the basis of the AdaGrad algorithm [8] using the lo- gistic loss for classification and the squared error loss for regression with L2-regularization. SGD [8] has one param- eter C for L2-regularization, which was also chosen from C = {10−5, 10−4, ..., 105}. We measured the prediction ac- curacy by the area under the ROC curve (AUC) for classifi- cation and Pearson correlation coefficient (PCC) for regres- sion. Note that AUC and PCC return 1 for perfect inference in classification/regression, while AUC returns 0.5 for ran- dom inference and PCC returns 0 for random inference. We report the best test accuracy under the above experimental settings for each method below. (cid:724)(cid:724)(cid:724)(cid:724)(cid:724)Top−kCompression Size (MB)2e+044e+046e+048e+041e+05100012001400160018002000Compression Time (sec)2000030000400005000060000Compression Size (MB)Compression Time (sec)(cid:724)(cid:724)(cid:724)(cid:724)(cid:724)Top−kCompression Size (MB)2e+044e+046e+048e+041e+0502004006008001000Compression Time (sec)10000150002000025000Compression Size (MB)Compression Time (sec)(cid:724)(cid:724)(cid:724)(cid:724)(cid:724)Top−kCompression Size (MB)2e+044e+046e+048e+041e+05600800100012001400Compression Time (sec)100001500020000250003000035000Compression Size (MB)Compression Time (sec)(cid:724)(cid:724)(cid:724)(cid:724)Top−kCompression Size (MB)2e+054e+056e+058e+051e+0646004800500052005400Compression Time (sec)50000600007000080000Compression Size (MB)Compression Time (sec)(cid:724)(cid:724)(cid:724)(cid:724)(cid:724)Top−kCompression Size (MB)2e+054e+056e+058e+051e+0602004006008001000Compression Time (sec)6600680070007200740076007800Compression Size (MB)Compression Time (sec) Table 3: Compression size in mega bytes (MB), compression time in seconds (sec), and working space for hash table (MB) for varying parameter (cid:96) in Lossy-Re-Pair and v in Freq-Re-Pair for each dataset. compression size (MB) compression time (sec) working space (MB) Lossy-RePair (cid:96)(MB) Freq-RePair v(MB) Book-review 1 1836 9904 1113 10 1685 12654 1931 100 1502 19125 7988 1 1000 2021 1501 2956 20004 8603 292 Compound 10 1816 2355 616 100 1680 3165 3856 1000 1501 21256 6724 Lossy-RePair (cid:96)(MB) Freq-RePair v(MB) compression size (MB) compression time (sec) working space (MB) 1 1288 5096 1113 10 859 7053 1926 100 825 7787 5030 1 1000 825 7946 5030 Webspam 1523 1362 292 10 1302 1587 616 100 825 8111 3535 1000 825 8207 3535 compression size (MB) compression time (sec) working space (MB) Lossy-RePair (cid:96)(MB) Freq-RePair v(MB) 1 1427 6953 1112 10 948 10585 1923 100 940 10584 7075 1000 940 10964 7075 1 2328 2125 292 10 2089 2799 616 100 1050 7712 3856 1000 940 11519 5539 Lossy-RePair (cid:96)(MB) Freq-RePair v(MB) CP-interaction compression size (MB) compression time (sec) working space (MB) 10 - 24hours - 100 5199 55919 9914 1000 5139 44853 16650 10000 5036 43756 16635 616 CP-intensity 10 20307 24565 100 9529 39647 3856 1000 5136 47230 13796 10000 5136 48653 13796 compression size (MB) compression time (sec) working space (MB) Lossy-RePair (cid:96)(MB) Freq-RePair v(MB) 10 558 8103 1936 100 543 6479 3552 1000 540 6494 3722 10000 535 6657 3738 10 588 5423 616 100 535 5848 2477 1000 535 5859 2477 10000 535 5923 2477 Table 4: Results of cPLS, PCA-SL, bMH-SL and SGD for various datasets. Dspace: the working space for storing data matrix (MB), Ospace: the working space for optimization algorithm and Ltime: learning time (sec). Data Book-review Compound Webspam CP-interaction CP-intensity Data Book-review Compound Webspam CP-interaction CP-intensity m 100 20 60 40 60 m/C 100/1 25/0.1 50/1 - 100/0.1 Dspace(MB) Ospace(MB) Ltime(sec) AUC/PCC cPLS 1288 786 890 4367 472 15082 7955 7736 53885 10683 PCA-SL 21628 1089 4171 35880 33969 0.96 0.83 0.99 0.77 0.67 Dspace(MB) Ospace(MB) Ltime(sec) AUC/PCC 14747 12 200 - 1521 110 1 2 - 11 bMH-SL 6820 6 129 >24hours 42 0.70 0.65 0.99 - 0.11 Data b/h/C Dspace(MB) Ospace(MB) Ltime(sec) AUC/PCC Book-review 100/16/0.01 Compound Webspam CP-interaction CP-intensity 30/16/10 30/16/10 30/16/0.1 100/16/0.1 2457 2 20 12366 253 110 1 2 1854 11 SGD 1033 1 2 10054 45 0.95 0.62 0.99 0.77 0.54 Data Book-review Compound Webspam CP-interaction CP-intensity C 10 10 10 1 0.1 Dspace(MB) Ospace(MB) Ltime(sec) AUC/PCC - - - - - 1694 9539 3041 663 124 57 83 85 3163 280 0.96 0.82 0.99 0.75 0.04 Figure 3: Extracted features for the top 10 latent components in the application of cPLS to the Compound dataset. Each column represents the highly weighted features (chemical substructures) of a latent component. Table 4 shows the prediction accuracy, working space and training time of cPLS, PCA-SL, bMH-SL, and SGD. The working space for the storing data matrix and the working space needed for optimizations were separately evaluated. While PCA-SL and bMH-SL significantly reduced the work- ing space for storing data matrices, the classification and regression accuracies were low. Since PCA-SL and bMH-SL compress data matrices without looking at the correlation structure between data and output variables for compressing data matrices, high classification and regression accuracies were difficult to achieve. SGD significantly reduced the working space, since it did not store data matrices in memory. Classification and re- gression accuracies of SGD were not high, because of the in- stability of the optimization algorithm. In addition, SGD is applicable only to simple linear models, making the learned model difficult to interpret. Our proposed cPLS outperformed the other methods (PCA- SL, bMH-SL, and SGD) in terms of AUC and PCC and sig- nificantly reduced the working space. The results showed cPLS's efficiency for learning PLS on compressed data ma- trices while looking at the correlation structure between data and output variables. Such a useful property enables us to extract informative features from the learned model. 7.3 Interpretability Figure 3 shows the top-10 highly-weighted features that were extracted for each component in the application of cPLS to the Compound dataset, where one feature corre- sponds to a compound chemical substructure. It was ob- served that structurally similar chemical substructures were extracted together as important features in the same com- ponent, and the extracted chemical substructures differed between components. This observation corresponds to a unique property of cPLS. Analysing large-scale compound structure data is of importance in pharmaceutical applica- tions, especially for rational drug design. For example, the extracted chemical substructures are beneficial for users who want to identify important chemical fragments involved in therapeutic drug activities or adverse drug reactions. 8. CONCLUSIONS AND FUTURE WORK We presented a scalable algorithm for learning interpretable linear models -- called cPLS -- which is applicable to large- scale regression and classification tasks. Our method has the following appealing properties: 1. Scalability: cPLS is applicable to large numbers of high-dimensional fingerprints (see Sections 7.1 and 7.2). 2. Prediction Accuracy: The optimization of cPLS is numerically stable, which enables us to achieve high prediction accuracies (see Section 7.2). 3. Usability: cPLS has only one hyperparameter to be tuned in cross-validation experiments (see Section 6.2). 4. Interpretability: Unlike lossy compression-based meth- ods, cPLS can extract informative features reflecting the correlation structure between data and class la- bels (or response variables), which makes the learned models easily interpretable (see Section 7.3). In this study, we applied our proposed grammar compres- sion algorithm to scaling up PLS, but in principle it can be used for scaling up other machine learning methods or data mining techniques. An important direction for future work is therefore the development of scalable learning methods and data mining techniques based on grammar-compression techniques. Such extensions will open the door for machine learning and data mining methods to be applied in various large-scale data problems in research and industry. 9. ACKNOWLEDGMENTS This work was supported by MEXT/JSPS Kakenhi (24700140, 25700004 and 25700029), the JST PRESTO program, the Program to Disseminate Tenure Tracking System, MEXT and Kyushu University Interdisciplinary Programs in Edu- cation and Projects in Research Development, and the Academy of Finland via grant 294143. (cid:1)(cid:2)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:7)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:3)(cid:2)(cid:1)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:3)(cid:2)(cid:3)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:7)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:1)(cid:2)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:8)(cid:1)(cid:1)(cid:2)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:7)(cid:1)(cid:2)(cid:1)(cid:3)(cid:1)(cid:2)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:2)(cid:1)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:1)(cid:2)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:1)(cid:2)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:1)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:1)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:1)(cid:2)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)Component1Component2Component3Component4Component5Component6Component7Component8Component9Component10(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:2)(cid:1)(cid:3)(cid:3)(cid:2)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:2)(cid:1)(cid:3)(cid:3)(cid:2)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:1)(cid:2)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:1)(cid:3)(cid:3)(cid:1)(cid:1)(cid:3)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:2)(cid:1)(cid:1)(cid:1)(cid:2)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:2)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:1)(cid:2)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:2)(cid:1)(cid:1)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:3)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:3)(cid:2)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:7)(cid:1)(cid:2)(cid:1)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:2)(cid:2)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:1)(cid:2)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:8)(cid:1)(cid:1)(cid:2)(cid:1)(cid:3)(cid:1)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:1)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:1)(cid:1)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:2)(cid:1)(cid:1)(cid:2)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:7)(cid:1)(cid:2)(cid:1)(cid:2)(cid:2)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:8)(cid:1)(cid:1)(cid:2)(cid:2)(cid:1)(cid:1)(cid:1)(cid:1)(cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8) 10. REFERENCES [1] P. Bille, P. H. Cording, and I. L. Gortz. Compact q-gram profiling of compressed strings. In CPM, pages 62 -- 73, 2013. [2] M Charikar, E. Lehman, D. Liu, R. Panigrahy, M. Prabhakaran, A. Sahai, and A. Shelat. The smallest grammar problem. IEEE Transactions on Information Theory, 51:2554 -- 2576, 2005. [3] B. Chen, D. Wild, and R. Guha. PubChem as a source of polypharmacology. JCIM, 49:2044 -- 2055, 2009. [4] The Uniprot Consortium. The universal protein resource (uniprot) in 2010. NAR, 38:D142 -- D148, 2010. [5] G. Cormode and Muthukrishnan S. An improved data stream summary: the count-min sketch and its applications. Journal of Algorithms, 55:58 -- 75, 2005. [6] D. Demaine, A. L´opez-Ortiz, and I. Munro. Frequency estimation of internet packet streams with limited space. In ESA, pages 348 -- 360, 2002. [7] C.M. Dobson. Chemical space and biology. Nature, 432(7019):824 -- 828, 2004. [8] J. Duchi, E. Hazan, and Y. Singer. Adaptive subgradient methods for online learning and stochastic optimization. JMLR, 12:2121 -- 2159, 2011. [9] T. Elgamal, M. Yabandeh, A. Aboulnaga, W. Mustafa, and M. Hefeeda. sPCA: Scalable principal component analysis for big data on distributed platforms. In SIGMOD, 2015. [10] R. Fan, K. W. Chang, C. J. Hsieh, X. R. Wang, and C. J. Lin. LIBLINEAR: A library for large linear classification. JMLR, pages 1871 -- 1874, 2008. [11] D. A. Forsyth and J. Ponce. Computer Vision: A Modern Approach. Prentice Hall Professional Technical Reference, 2002. [12] A. Gionis, P. Indyk, and R. Motwani. Similarity search in high dimensions via hashing. In VLDB, 1999. [13] D. Hermelin, D. H. Landau, and O. Weimann. A unified algorithm for accelerating edit-distance computation via text-compression. In STACS, pages 529 -- 540, 2009. [14] I. T. Jolliffe. Principal Component Analysis. Springer, 1986. [15] R. Karp, S. Shenker, and C. Papadimitriou. A simple algorithm for finding frequent elements in sets and bags. TODS, 28:51 -- 55, 2003. [16] J. C. Kieffer, E. Yang, G. J. Nelson, and P. C. Cosman. Universal lossless compression via multilevel pattern matching. IEEE Transactions on Information Theory, 46(4):1227 -- 1245, 2000. [17] M. Kuhn, D. Szklarczyk, A. Franceschini, M. Campillos, C. von Mering, L.J. Jensen, A. Beyer, and P. Bork. STITCH 2: An interaction network database for small molecules and proteins. NAR, 38(suppl 1):D552 -- D556, 2010. [18] C. Lanczos. An iteration method for the solution of the eigen value problem of linear differential and integral operators. Journal of Research of the National Bureau of Standards, 45:255 -- 282, 1950. [19] J. Larsson and A. Moffat. Offline dictionary-based compression. In DCC, pages 296 -- 305, 1999. [20] P. Li and A. C. Konig. b-bit minwise hashing. In WWW, pages 671 -- 680, 2010. [21] P. Li, A. Shrivastava, J. L. Moore, and A. C. Konig. Hashing algorithms for large-scale learning. In NIPS, pages 2672 -- 2680, 2011. [22] G. Manku and R. Motwani. Approximate frequency counts over data stream. In VLDB, volume 5, pages 346 -- 357, 2002. [23] C. D. Manning and H. Schutze. Foundations of Statistical Natural Language Processing. The MIT Press, 1999. [24] J. McAuley and J. Leskovec. Hidden factors and hidden topics: understanding rating dimensions with review text. In RecSys, 2013. [25] Y. Mu, G. Hua, W. Fan, and S. Chang. Hash-SVM: Scalable kernel machines for large-scale visual classification. In CVPR, pages 979 -- 986, 2014. [26] R. Rosipal and N. Kramer. Overview and recent advances in partial least squares. In Subspace, Latent Structure and Feature Selection, LNCS, pages 34 -- 51. Springer, 2006. [27] W. Rytter. Application of Lempel-Ziv factorization to the approximation of grammar-based compression. TCS, 302(1 -- 3):211 -- 222, 2003. [28] B. Scholkopf, A. Smola, and K. R. Muller. Nonlinear component analysis as a kernel eigenvalue problem. Neural Computation, 10:1299 -- 1319, 1998. [29] B. Stockwell. Chemical genetics: Ligand-based discovery of gene function. Nature Reviews Genetics, 1:116 -- 125, 2000. [30] Y. Tabei and Y. Yamanishi. Scalable prediction of compound-protein interactions using minwise-hashing. BMC Systems Biology, 7:S3, 2013. [31] M. E. Tipping and C. M. Bishop. Mixtures of probabilistic principal component analysers. Neural Computation, 11:443 -- 482, 1999. [32] R. Todeschini and V. Consonni. Handbook of Molecular Descriptors. Wiley-VCH, 2002. [33] Y. Tsuruoka, J. Tsujii, and S. Ananiadou. Stochastic gradient descent training for l1-regularized log-linear models with cumulative penalty. In ACL and AFNLP, pages 477 -- 485, 2009. [34] K. Weinberger, A. Dasgupta, J. Langford, A. Smola, and J. Attenberg. Feature hashing for large scale multitask learning. In ICML, pages 1113 -- 1120, 2009. [35] H. Wold. Path models with latent variables: The NIPALS approach. In Quantitative Sociology: International Perspectives on Mathematical and Statistical Model Building, pages 307 -- 357. Academic Press, 1975. [36] S. Wold, M. Sjostrom, and L. Eriksson. PLS-regression: a basic tool of chemometrics. Chemometrics and Intelligent Laboratory Systems, 58:109 -- 130, 2001. [37] T. Yamamoto, H. Bannai, S. Inenaga, and M. Takeda. Faster subsequence and don't-care pattern maching on compressed texts. In CPM, pages 309 -- 322, 2011. [38] X. Yan and J. Han. gSpan: graph-based substructure pattern mining. In ICDM, pages 721 -- 724, 2002. [39] H.F. Yu, C.J. Hsieh, K.W. Chang, and C.J. Lin. Large linear classification when data cannot fit in memory. In KDD, pages 833 -- 842, 2010.
1301.5293
2
1301
2013-04-24T16:51:25
Approximately counting semismooth integers
[ "cs.DS", "math.NT" ]
An integer $n$ is $(y,z)$-semismooth if $n=pm$ where $m$ is an integer with all prime divisors $\le y$ and $p$ is 1 or a prime $\le z$. arge quantities of semismooth integers are utilized in modern integer factoring algorithms, such as the number field sieve, that incorporate the so-called large prime variant. Thus, it is useful for factoring practitioners to be able to estimate the value of $\Psi(x,y,z)$, the number of $(y,z)$-semismooth integers up to $x$, so that they can better set algorithm parameters and minimize running times, which could be weeks or months on a cluster supercomputer. In this paper, we explore several algorithms to approximate $\Psi(x,y,z)$ using a generalization of Buchstab's identity with numeric integration.
cs.DS
cs
APPROXIMATELY COUNTING SEMISMOOTH INTEGERS ERIC BACH AND JONATHAN SORENSON Abstract. An integer n is (y, z)-semismooth if n = pm where m is an integer with all prime divisors ≤ y and p is 1 or a prime ≤ z. Large quantities of semismooth integers are utilized in modern integer factoring algorithms, such as the number field sieve, that incorporate the so-called large prime variant. Thus, it is useful for factoring practitioners to be able to estimate the value of Ψ(x, y, z), the number of (y, z)-semismooth integers up to x, so that they can better set algorithm parameters and minimize running times, which could be weeks or months on a cluster supercomputer. In this paper, we explore sev- eral algorithms to approximate Ψ(x, y, z) using a generalization of Buchstab's identity with numeric integration. 1. Introduction The security of the public-key cryptosystem RSA [18, 22] is based on the practical difficulty of integer factoring. The fastest current general-purpose integer factoring algorithm is the number field sieve [9, 17], which in its basic form makes use of smooth numbers, integers with only small prime divisors. This has inspired research into algorithms to ap- proximately count smooth numbers [5, 6, 15, 20, 24, 26, 27]. However, most imple- mentations of the number field sieve make use of the so-called large prime variant [9, §6.1.4]. So we want, in fact, to count smooth integers that admit at most one slightly larger prime divisor, or semismooth numbers. (See, for example, the details on the factorization of a 768-bit RSA modulus [16] where smoothness bounds are discussed near the end of §2.2.) The principal contribution of this paper is twofold: (1) We present data showing that the key to estimating Ψ(x, y, z) accurately is an algorithm to estimate Ψ(x, y) accurately, and (2) We present head-to-head comparisons of five algorithms for estimating Ψ(x, y, z). Previous work was done by Bach and Peralta [3] and generalized by Zhang and Ekkelkamp [10, 29]; we discuss this below. This paper is organized as follows. We begin with some definitions, and briefly discuss computing exact counts of semismooth integers. We then give our main theoretical result, a generalized Buchstab identity, which together with numerical integration, is the basis of all our algorithms. We then present five different algo- rithms in some detail, two based on the Dickman ρ function and three based on the saddle point methods of Hildebrand and Tenenbaum [14], along with empirical results for each algorithm. As one might expect, we discover a tradeoff in algorithm Date: 24 April 2013. 1 2 ERIC BACH AND JONATHAN SORENSON Table 1. Exact Values of Ψ(x, y, z), x = 240 y 22 24 26 28 210 212 214 216 218 220 z = 214 z = 212 z = 210 503392 170906 58916 36766896 15111450 6132454 678707129 1326493628 323105012 3157707079 6694272918 11837179134 7138986245 21494669620 39400743040 z = 220 z = 218 13597105 4513650 508848834 213965871 8298713253 4603776946 30059136386 45290571262 89501569374 123782024151 - 30641713551 68600140477 111769092210 160884758713 215725604647 - 80324574755 145583683889 214469637137 286977146180 - - 155283653287 241316058768 329068435579 - - - 248857736183 349745847766 - - - - - - - - 354983289990 z = 216 1500366 88920834 2499496319 19296840890 61719198990 choice between speed and accuracy. We follow this up with an elaboration on some numerical details. 2. Definitions Let P (n) denote the largest prime divisor of the positive integer n, with P (1) = 1. An integer n is y-smooth if P (n) ≤ y, and Ψ(x, y) counts the integers n ≤ x that are y-smooth. An integer n is (y, z)-semismooth if we can write n = mp where m is y-smooth and p ≤ z is a prime or 1. Ψ(x, y, z) counts the integers n ≤ x that are (y, z)- semismooth. (Generalizations to more than one exceptional prime have been de- fined by Zhang and Ekkelkamp [10, 29].) Observe that Ψ(x, y, y) = Ψ(x, y), the function Ψ(x, y, x) counts integers whose second-largest prime divisor is bounded by y, and Ψ(x, 1, z) = min{π(x), π(z)}, where π(x) is the number of primes up to x. Our basic unit of work is the floating point operation. Along with the four basic arithmetic operations (+,−,×,÷) we include square roots, logarithms, and expo- nentials, since their complexity is close to that of multiplication (see for example [7]). 3. Exact Counts Using a prime number sieve, such as the sieve of Eratosthenes, we can completely factor all integers up to x in O(x log log x) arithmetic operations, and thereby com- pute exact values of Ψ(x, y, z). Of course this is not a practical approach for large x, but it is useful for evaluating the accuracy of approximation algorithms, which is what we do here. So we wrote a program to do this, based on a segmented sieve of Eratosthenes (see [25] for prime number sieve references), and we ran our program up to x = 1099511627776 = 240. Our results for this largest value for x appear in Table 1, which took just over 100 CPU hours to compute. APPROXIMATELY COUNTING SEMISMOOTH INTEGERS 3 Table 2. x · σ(u, v)/Ψ(x, y, z), x = 240 z = 216 z = 214 z = 212 z = 210 7.0984e-14 1.2946e-12 2.1963e-11 3.4242e-10 4.8536e-09 6.2227e-08 0.0042182 0.26627 0.64392 0.75636 z = 218 z = 220 0.007326 0.2956 0.66898 0.80963 0.84863 - - - - 0.012701 0.32972 0.68836 0.82644 0.87886 0.89495 - - - 0.021657 0.36872 0.70731 0.83778 0.89096 0.9169 0.92275 - - 0.035951 0.41167 0.72686 0.84679 0.89979 0.92614 0.93539 0.93769 - 0.058 0.4585 0.74754 0.85628 0.90729 0.93196 0.9421 0.94722 0.95043 y 22 24 26 28 210 212 - 214 - 216 - 218 - 220 - y 22 24 26 28 210 212 - 214 - 216 - 218 - 220 - Table 3. E(x, y, z)/Ψ(x, y, z), x = 240 z = 216 z = 214 z = 212 z = 210 1.6195e-13 2.9202e-12 4.8929e-11 7.5256e-10 1.0508e-08 1.325e-07 0.0063754 0.34328 0.76655 0.87052 z = 218 z = 220 0.010979 0.37895 0.79204 0.91765 0.94459 - - - - 0.018858 0.42001 0.81087 0.93094 0.96506 0.97446 - - - 0.031834 0.46628 0.82903 0.93899 0.97334 0.98537 0.98694 - - 0.052265 0.51656 0.84748 0.94491 0.97836 0.98863 0.99092 0.99154 - 0.0833 0.57018 0.86587 0.95185 0.98148 0.99038 0.99305 0.99516 0.99766 4. A Generalized Buchstab Identity We have the following version of Buchstab's identity (see for example [28, p. 365]): (1) Ψ(x, y) = Ψ(x, 2) + X2<p≤y Ψ(x/p, p), which is obtained by summing over the largest prime divisor of y-smooth integers n ≤ x. Using this same idea gives us the following: Ψ(x, y, z) = Ψ(x, y) + Xy<p≤z (2) Ψ(x/p, y). As one can see, the identity is obtained by summing over the largest prime divisor. 5. Approximate Counts As mentioned in the Introduction, there are many algorithms to estimate values of Ψ(x, y). We could choose one of them, compute a list of primes up to z, and then apply (2) to approximate Ψ(x, y, z). We found that this does, in fact, give fairly accurate estimates, but the resulting algorithms are quite slow since roughly O(z/ log z) evaluations of Ψ(x/p, y) (one for each p, y < p ≤ z) are needed. 4 ERIC BACH AND JONATHAN SORENSON Our approach, then, is to replace the sum in (2) with an integral, and then use numeric integration to evaluate it [8, §7.2]; we used Simpson's rule. We found that in practice, the relative error introduced by replacing the sum with an integral that was then estimated, was less than the relative error introduced by the approximation algorithms for Ψ(x, y). Let us define li(x) := R x 2 dt/ log t, and let e(x) := π(x) − li(x). By the prime number theorem, e(x) = x/ exp[Ω(√log x)]; if we assume the Riemann Hypothesis, e(x) = O(√x log x) [23]. We have the following (see [4, §2.7]): Lemma 1. Let f be a continuously differentiable function on an open interval containing [2, z], and let 2 ≤ y ≤ z. Then dt f (p) = Z z y f (t) log t Xy<p≤z +f (z)e(z) − f (y)e(y) −Z z y e(t)f ′(t)dt. Of course we cannot apply this lemma to Ψ(x, y) directly, so we use an estimate instead. Define ρ(u) as the unique continuous solution to ρ(u) = 1 ρ(u − 1) + uρ′(u) = 0 (0 ≤ u ≤ 1) (u > 1). Note that ρ ∈ C1 for u > 1. Hildebrand [12] proved that for ǫ > 0 we have (3) Ψ(x, y) = xρ(u)(cid:18)1 + Oǫ(cid:18) log(u + 1) log y (cid:19)(cid:19) , uniformly on the set defined by 1 ≤ u ≤ exp((log y)3/5−ǫ) and y ≥ 2. Here, u := u(x, y) = log x/ log y. Theorem 1. Given 2 ≤ y ≤ z ≤ x, let ǫ > 0, and assume that 1 ≤ log(x/z)/ log y ≤ log x/ log y ≤ exp((log y)3/5−ǫ). Then (4) Ψ(x, y, z) = (cid:18)Ψ(x, y) +Z z dt(cid:19) (1 + o(1)). Ψ(x/t, y) y log t For asymptotic notation, we are assuming y is large. Proof. Define f (t) := (x/t)ρ(log(x/t)/ log y). By (3) we have f (p) = Ψ(x/p, y)(1 + o(1)) for all primes y < p ≤ z. f is differentiable and continuous, with f ′(t) ∼ −f (t)/t (for large y). It is then straightforward to show that e(t)f ′(t) = o(f (t)/ log t). Also since f is decreasing we can show e(z)f (z) − e(y)f (y) = o(π(z) − π(y))f (z) + O(e(y)f (y)) and then (π(z)−π(y))f (z) ≤ Py<p≤z f (p) and e(y)f (y) = o(Ψ(x, y)). In the case when u is large, we make use of Lemma 8.1 and (61) from [28, §5.4]. We then apply Lemma 1 and use (2), and finally substitute Ψ(x/t, y) back in for f (t) to complete the proof. (cid:3) It would be nice to have some function g(y, z) where (5) Ψ(x, y, z) ≈ Ψ(x, y) · g(y, z) APPROXIMATELY COUNTING SEMISMOOTH INTEGERS 5 Table 4. HT (x, y, z)/Ψ(x, y, z), x = 240 z = 210 1.0969 1.0592 1.0414 1.0194 1.0024 y 22 24 26 28 210 212 - 214 - 216 - 218 - 220 - z = 212 1.0712 1.039 1.0281 1.0165 1.0104 1.0043 - - - - z = 214 1.0641 1.031 1.0205 1.0135 1.0101 1.0104 1.0046 - - - z = 216 1.067 1.0353 1.024 1.0127 1.01 1.01 1.0084 1.0101 - - z = 218 1.0728 1.0507 1.0566 1.0296 1.0112 1.0078 1.0115 1.016 1.0142 - z = 220 1.0833 1.0829 1.1582 1.1338 1.0437 1.0107 1.0143 1.017 1.0116 1.0083 if this is possible. Rewriting (2) we have (6) Ψ(x, y, z) = Ψ(x, y) · 1 + Xy<p≤z Ψ(x/p, y) Ψ(x, y)   . A very crude estimate of Ψ(x/p, y)/Ψ(x, y) ≈ 1/p leads to (7) Ψ(x, y, z) ≈ Ψ(x, y) · (1 + log(log z/ log y))) . In practice, this is too crude to be useful. However, this estimate can certainly be improved using, for example, Theorem 11 from [28, §5.5]. This is a possible direction for future work. 5.1. The Method of Bach and Peralta. The first algorithm to try would be to use the estimate Ψ(x, y) ≈ xρ(u) from (3) and plug it into Theorem 1. This, in fact, is simply another way to derive the algorithm of Bach and Peralta [3]. They define u := log x/ log y, v := log x/ log z and (8) σ(u, v) := ρ(u) +Z u v (ρ(u − u/w)/w)dw. They then prove that for fixed u, v and x → ∞, (9) Ψ(x, y, z) ≈ xσ(u, v). We can use (2) to obtain the same approximation, as follows: Ψ(x, y, z) ≈ Ψ(x, y) +Z z y (Ψ(x/t, y)/ log t)dt ≈ x · ρ(log x/ log y) +Z z y (x/t log t)ρ(log(x/t)/ log y)dt = x ·(cid:18)ρ(u) +Z u = x · σ(u, v). v (ρ(u − u/w)/w)dw(cid:19) We adapted code written by Peralta to compute values of the Dickman ρ function (accurate to roughly 8 decimal digits) to compute σ. Bach and Peralta discuss methods to compute both ρ and σ in some detail in [3]. We present the results 6 ERIC BACH AND JONATHAN SORENSON from this algorithm in Table 2. As for all our algorithms, we show the ratio of what the algorithm produces as an estimate divided by the actual values we computed earlier. The closer we are to 1 the better the estimates. This algorithm is fast, but the results are not as good as we might desire. As one might expect, they are about as good as what was found for estimating counts of smooth numbers using (3) in [15]. 5.2. Ekkelkamp's Improvement. Ekkelkamp [10] pointed out that σ(u, v) could be made more accurate by adding a quantity which, in our notation, is log x (cid:20)ρ(u − 1) +Z u (1 − γ)x w − 1 This can be derived by using the better approximation v ρ(u − u/w − 1) dw(cid:21) . Ψ(x, y) ≈ xρ(u) + (1 − γ)x log x ρ(u − 1), due to Ramaswami [21, Theorem 1]. To get her formula, substitute w = 1/λ in the integral; note that we need the first term inside the brackets, since our definition of semismoothness differs from hers. (Our "large prime" can be 1.) This correc- tion does not require much additional effort; essentially just one more numerical integration. Let E(x, y, z) denote this approximation. Our experiments with this indicate that the additional term enhances accuracy significantly when y and z are large. This is roughly the bottom corner of Table 2. However, the accuracy still drops off dramatically for smaller values of y. See Table 3. 5.3. A Saddlepoint Method. Our third algorithm is based on Algorithm HT for estimating Ψ(x, y) presented in [15]. Define ζ(s, y) := Yp≤y (1 − p−s)−1; φ(s, y) := log ζ(s, y); φk(s, y) := dk dsk φ(s, y) (k ≥ 1). The functions φk can be expressed as sums over primes. Indeed, we have φ(s, y) = −Xp≤y φ1(s, y) = −Xp≤y φ2(s, y) = Xp≤y log(1 − p−s); log p ps − 1 ps(log p)2 (ps − 1)2 . ; Thus, with a list of primes up to y, the quantities ζ(s, y), φ1(s, y), and φ2(s, y) can be computed in O(y/ log y) floating point operations. Define HT (x, y, s) := xsζ(s, y) sp2πφ2(s, y) , APPROXIMATELY COUNTING SEMISMOOTH INTEGERS 7 Table 5. HTf (x, y, z)/Ψ(x, y, z), x = 240 y 22 24 26 28 210 212 - 214 - 216 - 218 - 220 - z = 212 z = 210 1.0712 1.0969 1.039 1.0592 1.0281 1.0414 1.0194 1.0165 0.99773 1.0069 1.0152 - - - - z = 214 1.0641 1.031 1.0205 1.0135 1.007 1.0186 1.0177 - - - z = 216 1.067 1.0353 1.024 1.0127 1.0073 1.0171 1.0186 1.021 - - z = 218 1.0728 1.0507 1.0566 1.0296 1.0088 1.0141 1.0203 1.0247 1.021 - z = 220 1.0833 1.0829 1.1582 1.1338 1.0413 1.0164 1.0222 1.0246 1.0172 1.013 and let α be the unique solution to φ1(α, y)+log x = 0. Hildebrand and Tenenbaum proved the following [13]: Theorem 2. (10) Ψ(x, y) = HT (x, y, α) ·(cid:18)1 + O(cid:18) 1 u + (log y) y (cid:19)(cid:19) uniformly for 2 ≤ y ≤ x. This gives us Algorithm HT [15]: (1) Find the primes up to y. (2) Compute an approximation α′ to α using binary search and Newton's method. Make sure that α − α′ = O(1/(u log x)). (3) Output HT (x, y, α′). Write HT (x, y) for the value output in the last step. The running time is O(cid:16) y log log x log y + y log log y(cid:17) floating point operations. We simply plugged Algorithm HT into Theorem 1 to estimate Ψ(x, y, z) using the saddle point method as follows: (11) HT (x, y, z) := HT (x, y) +Z z y (HT (x/t, y)/ log t)dt. In Table 4 we give the results for this algorithm, which are quite good. The method is, however, a bit slow. Using the summation algorithms described in [2], we can lower the exponent of y in the running time from 1 to 2/3. We give some details for this in §6.3. We did not implement this improvement, however, because it would not change the computed results, and the method of the section below is faster. 5.4. Assuming Riemann's Hypothesis. This is the same as Algorithm HT, only sums over primes (ζ, φ1, φ2) above roughly √y are estimated using the prime num- ber theorem plus the Riemann Hypothesis [24, 23]. It is much faster than Algorithm HT and nearly as accurate; its running time is roughly √y. Let HTf (x, y) denote the estimate this algorithm computes for Ψ(x, y), and HTf (x, y, z) the estimate after using HTf (x, y) with Theorem 1. We present our results in Table 5. We recommend this method. 8 ERIC BACH AND JONATHAN SORENSON Table 6. S(x, y, z)/Ψ(x, y, z), x = 240 y 22 24 26 28 210 212 - 214 - 216 - 218 - 220 - z = 212 0 0 z = 214 0 0 z = 210 0 0 0.57462 0.60753 0.64352 0.68488 0.7388 0.90295 0.90963 0.91195 0.91382 0.92929 1.0201 0.94404 0.93337 0.92495 0.9175 z = 220 0 2.3032 0.82405 z = 218 0 0 z = 216 0 0 0.9108 0.93201 0.93348 0.90717 0.89212 0.87883 0.87083 - 0.90403 0.87455 0.85967 0.84873 0.88064 0.85461 0.83658 - - 0.85917 0.82827 - - - - - - - 0.83353 5.5. Suzuki's Algorithm. In successive papers, Suzuki [26, 27] develops a very fast algorithm, with cost O(√log x log y) operations, using the saddle point method to estimate Ψ(x, y). This is based on good approximations for α and the prime sums ζ, φ1, φ2 using the prime number theorem. For u > 1, let ξ be the positive solution to the equation eξ = 1 + uξ, or equiva- lently, ξ = log(1 + uξ). This last equation implies that ξ ≈ log(u log u), and can be used iteratively to evaluate ξ. (See §6.2 for more information on this point.) Let γ = 0.57721... be Euler's constant. We now define (12) and (13) αs := 1 − ξ log y S(x, y) := 0 t−1(et−1)dt xαseγ+R ξ αsp2πu(1 + (log x)/y) . Suzuki proves the following [27, Theorem 1.1]: Theorem 3. Let ǫ ≤ 1/2. If (log log x)5/3−ǫ < log y < e−1(1 − ǫ) log x, then (14) Ψ(x, y) = S(x, y)(1 + o(1)). Suzuki proposed using the midpoint method to evaluate the integral R ξ 0 t−1(et − 1)dt. We used its Maclaurin series Pn≥1 ξn/(n· n!) [1, formulas 5.1.10 and 5.1.40]. We write S(x, y, z) for the function to estimate Ψ(x, y, z) using S(x, y) to estimate Ψ(x, y) in Theorem 1. Our results are presented in Table 6. We found the algorithm to be extremely fast, but not accurate for small y, which is not surprising given the approximations used. Earlier, in [26], Suzuki discussed HT(x, y, αs) as an approximation to Ψ(x, y). Although this is faster than Algorithm HT by a factor of log log x, it is not as accurate, and so we chose not to test its use. 5.6. Speed. Below we give timing results for the algorithms presented above. This is the total time it took to compute the estimates given in the tables in this section. APPROXIMATELY COUNTING SEMISMOOTH INTEGERS 9 Algorithm Suzuki Bach and Peralta Ekkelkamp HTf HT Time in Seconds 0.09 0.40 0.78 1.90 20.0 We used the Gnu g++ compiler on a unix server with an intel CPU. We elaborate on some details from the algorithms presented above. 6. Numerical Details 6.1. Estimates for α. In this subsection, we give more information about the function α(x, y), defined implicitly by the equation φ1(α, y) + log x = 0 (here 2 ≤ y ≤ x). In particular we will prove that (15) 1 2 log x ≤ α ≤ 2. We prove the lower bound first. From the prime number sum for φ1, we see that for s > 0, So α, the solution to φ1(α, y) + log x = 0, is lower bounded by the solution β to −φ1 ≥ log 2 2s − 1 . Solving, we get log 2 2β − 1 = log x. log(1 + (log 2)/(log x)) 1 , ≥ α ≥ β = log 2 the last inequality holding whenever x ≥ 2. Next we show the upper bound. Let ζ denote the Riemann zeta function. By examining their Dirichlet series, we can see that −φ1(s, y) ≤ −ζ ′/ζ(s). Both sides are decreasing smooth functions of s on (0,∞). It follows that α is upper bounded by the solution to ζ ′(s)/ζ(s) = log 2, which is less than 2. 2 log x More precise information can be found in [13]. In particular, log(1 + y/ log x) (cid:26)1 + O(cid:18) log log(1 + y) holds uniformly for x ≥ y ≥ 2, with the explicit lower bound log y log y α = (cid:19)(cid:27) log(1 + y/(5 log x)) . α ≥ log y The strength of this is similar to (15) if y is fixed and x → ∞. 6.2. Computing ξ. Here we discuss some numerical methods for solving eξ = 1 + uξ, when u > 1. Let f (x) = x − log(1 + ux). Then f is convex on (0,∞) with a minimum at x = 1 − 1/u. This gives the lower bound ξ ≥ 1 − 1/u. To get an upper bound, we observe that ex > 1 + x + x2/2, so ξ is no larger than the positive solution to 1 + ξ + ξ2/2 = 1 + uξ, which is 2(u− 1). Using binary search between these bounds, we can get ⌊ξ⌋ plus d bits of its fraction, with O(log u + d) evaluations of f . 10 ERIC BACH AND JONATHAN SORENSON Starting from the defining equation and taking logarithms, we get ξ = log(uξ + 1). Suzuki [26, Lemma 2.2] proves that this iteration, starting from log u, is linearly convergent to ξ. (Here u > e is fixed.) In practice, we can use the Newton iteration ξ := ξ − (ξ − log(1 + uξ))(1 + uξ) , 1 + u(ξ − 1) starting with the upper bound 2(u− 1). By convexity, the iterates decrease toward the root. We tested values of u from 2 to 1000, and for these u, about 5 iterations were enough to get machine accuracy (about 15D). (Note that when x is large, f (x) ∼ x, so even if we start with a large upper bound, the second iterate will be much closer to the root.) Newton iteration does not work well when u is close to 1, for the following reason. Suppose that u = 1 + ǫ. Then, we have ǫ + O(ǫ2) < ξ < 2ǫ, making ξ − log(1 + uξ) vanish to first order in ǫ. Thus, when computing this factor, we will lose precision due to cancellation. If special function software is available, ξ can be expressed using the Lambert W function. For example, in the notation of a well known computer algebra system of Canadian origin, ξ = −1/u − LambertW(−1,−e−1/u/u). (The argument −1 indicates which branch should be used.) 6.3. ATM Summation. The purpose of the next two subsections is to justify the remark made earlier that the cost of evaluating the formula HT can be lowered to y2/3+o(1). Here, the "o(1)" term includes factors of order log x, so we are implicitly assuming that x is not outrageously large. If f is a function defined on the positive integers, it is multiplicative if f (mn) = f (m)f (n). This is a stronger requirement than is usual in number theory, where m and n need only be coprime. The concept of an additive function is defined similarly; we require f (mn) = f (m) + f (n). We will call f an ATM function (additive times multiplicative) if f = gh, where g is additive and h is multiplicative. The paper [2] gave an algorithm that evaluates the prime sum Pp≤y f (p), with f an ATM function, in y2/3+o(1) steps. This generalized a previously known result, also explained in [2], in which f could be multiplicative. We now explain how these summation algorithms can be used to evaluate φ1 and log ζ. The basic idea is to approximate each of these by a "small" number of ATM or multiplicative prime sums. With log ζ in hand, we can exponentiate to get ζ. We first assume s > 0. Let us consider φ1 first. By summing geometric series, we see that −φ1 = Xp≤y log p ps − 1 = Xk≥1Xp≤y log p pks . Note that each inner sum involves an ATM function. We will restrict the outer sum to 1 ≤ k ≤ N , and choose N to make the truncation error, small. Xk≥N +1Xp≤y log p pks . APPROXIMATELY COUNTING SEMISMOOTH INTEGERS 11 If we interchange the order of summation, allow all p ≥ 2, and sum geometric series, we can express the truncation error as Xp≥2 log p pN s(ps − 1) . Using the globally convergent Maclaurin series for ps, we see that 1/(ps − 1) ≤ 1/(s log p). If we plug this in, the log p factors cancel and we get the upper bound 1 s Xp≥2 1 pN s ≤ 1 s (cid:18) 1 2N s +Z ∞ 2 dt tN s(cid:19) ≤ 3 s2N s , provided that N s ≥ 2. For us, s ≥ 1/(2 log x), and with this additional assumption we get [truncation error] ≤ 6 log x 2N s . Thus, to achieve truncation error less than 2−d, we can use N = Θ((log x)(log log x+ d)). Similarly, we can use log ζ(s, y) = −Xp≤y log(1 − p−s) = Xk≥1 1 k Xp≤y 1 pks . Now each inner sum involves a multiplicative function. If we use only the inner sums with k ≤ N , a similar analysis shows that choosing N = Θ((log x)(log log x + d)) will keep the truncation error below 2−d. 6.4. Numerical Differentiation. In this subsection, we explain how to evaluate φ2(s, y) = Xp≤y log2 p · ps (ps − 1)2 , for use in Algorithm HT. There is no obvious way to reduce this to the kind of sums treated in [2], so we will approximate it by a difference. Using balanced numerical differentiation [8, p. 297], we have h2 6 φ1(s + h, y) − φ1(s − h, y) φ2(s, y) = + ǫ, ǫ = 2h φ4(η, y) for some η ∈ [s − h, s + h]. Let us determine how much precision will be necessary to deliver d bits of φ2(s, y) accurately, when we use this formula. After differentiating the sum for φ2 twice, we see that φ4(s, y) = Xp≤y ps log2 p (ps − 1)2 × (p2s + 4ps + 1) log2 p (ps − 1)2 . Observing that (t2 + 4t + 1)/(t − 1)2 is decreasing for t > 1, we get the estimate h2 6 φ4(s, y) ≤ 6 h2 log2 y (cid:18) 22s + 4 · 2s + 1 (2s − 1)2 (cid:19) φ2(s, y). If 0 ≤ s ≤ 2, the factor in parentheses is bounded by 15/s2. (Numerically, anyway.) So, if we could use exact arithmetic, numerical differentiation would give us [relative error] ≤ 5 2 h2 log2 y s2 ≤ 10h2 log2 x log2 y. 12 ERIC BACH AND JONATHAN SORENSON However, we don't have exact arithmetic, so we must also analyze the loss of precision due to cancellation. For this, we use an ad hoc theory. When h is small, the number of bits lost, when using the balanced difference formula to compute φ′ 1(s), is about − log2(cid:12)(cid:12)(cid:12)(cid:12) φ1(s + h) − φ1(s − h) φ1(s) , (cid:12)(cid:12)(cid:12)(cid:12) since dividing by h causes no loss of precision. Note that this is a centered version of the usual relative error formula. Since φ1(s + h)− φ1(s − h) ∼ 2hφ′ 1(s), we must bound the logarithmic derivative of φ1, or, what is the same thing, relate φ2 = φ′ 1 to φ1. In our case, we require a lower bound for φ2. Then since t/(t − 1) is decreasing on (1,∞), φ2(s, y) = Xp≤y log p ps log p ps − 1 ps − 1 × log p ≥ −φ1(s, y) log 2. ≥ Xp≤y log p (ps − 1) Therefore, φ1(s + h, y) − φ1(s − h, y) ∼ 2hφ2(s, y) ≥ −φ1(s, y) · 2h log 2, as h → 0, Let us now translate these results into practical advice. Suppose our goal is to obtain φ2 to d bits of precision, in the sense of relative error. By the exact arithmetic formula, we should choose h ≤ 2−d/2/(√10 log2 x). Then we need to use log2 h−1 + O(1) guard bits in our computation. Put more crudely, unless x is very large, doubling the working precision should be enough, if we select h properly. The following example indicates that the theory above is roughly correct. Sup- pose we want 10 digits of φ2, for x = 106, y = 103, and s = 1/(2 log x) = 0.03619... . Our recipe allows us to take h = 10−7. With 17 digit arithmetic, we obtained numerical derivative = 127790.77386350000 summation for φ2 = 127790.77386041727 which agree to 11 figures. 7. Conclusion and Future Work In summary, we recommend the estimate HTf (x, y, z) of §5.4 for approximating Ψ(x, y, z). We feel it gives high accuracy while retaining sufficient speed to be very practical. For future work, we hope to generalize our results to 2 or more large primes. We also hope to further examine estimates of the form of (5). 8. Acknowledgments We want to thank the referees, whose comments helped improve this paper. Abstract presented at the AMS-MAA Joint Mathematics Meetings, January 2012, Boston MA, and at the CMS Summer Meeting, June 2013, Halifax Nova Scotia. Supported in part by grants from the Holcomb Awards Committee, NSF (CCF- 635355), and ARO (W911NF-09-1-0439). APPROXIMATELY COUNTING SEMISMOOTH INTEGERS 13 References [1] M. Abramowitz and I. A. Stegun. Handbook of Mathematical Functions. Dover, 1970. [2] E. Bach. Sums over primes. In A. M. Ernvall-Hytonen, M. Jutila, J. Karhumaki, and A. Lep- isto, editors, Proceedings of Conference on Algorithmic Number Theory 2007, number 46 in Turku Centre for Computer Science, pages 40–44, 2007. [3] E. Bach and R. Peralta. Asymptotic semismoothness probabilities. Math. Comp., 65(216):1701–1715, 1996. [4] E. Bach and J. O. Shallit. Algorithmic Number Theory, volume 1. MIT Press, 1996. [5] D. J. Bernstein. Bounding smooth integers. In J. P. Buhler, editor, Third International Algo- rithmic Number Theory Symposium, pages 128–130, Portland, Oregon, June 1998. Springer. LNCS 1423. [6] D. J. Bernstein. Arbitrarily tight bounds on the distribution of smooth integers. In Bennett, Berndt, Boston, Diamond, Hildebrand, and Philipp, editors, Proceedings of the Millennial Conference on Number Theory, volume 1, pages 49–66. A. K. Peters, 2002. [7] R. P. Brent. Multiple precision zero-finding methods and the complexity of elementary func- tion evaluation. In J. F. Traub, editor, Analytic Computational Complexity, pages 151–176. Academic Press, 1976. [8] S. D. Conte and C. W. D. Boor. Elementary Numerical Analysis: An Algorithmic Approach. McGraw-Hill Higher Education, 3rd edition, 1980. [9] R. Crandall and C. Pomerance. Prime Numbers, a Computational Perspective. Springer, 2001. [10] W. H. Ekkelkamp. The role of semismooth numbers in factoring large numbers. In A.-M. Ernvall-Hytonen, M. Jutila, J. Karhumaki, and A. Lepisto, editors, Proceedings of Conference on Algorithmic Number Theory 2007, number 46 in TUCS General Publication, pages 40–44. Turku Centre for Computer Science, 2007. [11] A. Granville. Smooth numbers: computational number theory and beyond. In Algorithmic lattices, number fields, curves and cryptography, volume 44 of Math. Sci. number theory: Res. Inst. Publ., pages 267–323. Cambridge Univ. Press, Cambridge, 2008. [12] A. Hildebrand. On the number of positive integers ≤ x and free of prime factors > y. Journal of Number Theory, 22:289–307, 1986. [13] A. Hildebrand and G. Tenenbaum. On integers free of large prime factors. Trans. AMS, 296(1):265–290, 1986. [14] A. Hildebrand and G. Tenenbaum. Integers without large prime factors. Journal de Th´eorie des Nombres de Bordeaux, 5:411–484, 1993. [15] S. Hunter and J. P. Sorenson. Approximating the number of integers free of large prime factors. Mathematics of Computation, 66(220):1729–1741, 1997. [16] T. Kleinjung, K. Aoki, J. Franke, A. K. Lenstra, E. Thom´e, P. Gaudry, P. L. Montgomery, D. A. Osvik, H. T. Riele, A. Timofeev, P. Zimmermann, and et al. Factorization of a 768-bit rsa modulus. http://eprint.iacr.org/2010/006.pdf, 2010. [17] A. K. Lenstra and H. W. L. Jr., editors. The Development of the Number Field Sieve, volume 1554 of Lecture Notes in Mathematics. Springer-Verlag, Berlin and Heidelberg, Germany, 1993. [18] A. J. Menezes, P. C. van Oorschot, and S. A. Vanstone. Handbook of Applied Cryptography. CRC Press, Boca Raton, 1997. [19] P. Moree. Nicolaas Govert de Bruijn, the enchanter of friable integers. Indag. Math., 2013. to appear; available from arxiv.org:1212.1579. 14 ERIC BACH AND JONATHAN SORENSON [20] S. Parsell and J. P. Sorenson. Fast bounds on the distribution of smooth numbers. In F. Hess, S. Pauli, and M. Pohst, editors, Proceedings of the 7th International Symposium on Algo- rithmic Number Theory (ANTS-VII), pages 168–181, Berlin, Germany, July 2006. Springer. LNCS 4076, ISBN 3-540-36075-1. [21] V. Ramaswami. The number of positive integers ≤ x and free of prime divisors xc, and a problem of S. S. Pillai. Duke Mathematics Journal, 16(1):99–109, 1949. [22] R. Rivest, A. Shamir, and L. Adleman. A method for obtaining digital signatures and public- key cryptosystems. Communications of the ACM, 21(2):120–126, 1978. [23] L. Schoenfeld. Sharper bounds for the Chebyshev functions θ(x) and ψ(x). II. Mathematics of Computation, 30(134):337–360, 1976. [24] J. P. Sorenson. A fast algorithm for approximately counting smooth numbers. In W. Bosma, editor, Proceedings of the Fourth International Algorithmic Number Theory Symposium (ANTS IV), pages 539–549, Leiden, The Netherlands, 2000. LNCS 1838. [25] J. P. Sorenson. The pseudosquares prime sieve. In F. Hess, S. Pauli, and M. Pohst, editors, Proceedings of the 7th International Symposium on Algorithmic Number Theory (ANTS- VII), pages 193–207, Berlin, Germany, July 2006. Springer. LNCS 4076, ISBN 3-540-36075-1. [26] K. Suzuki. An estimate for the number of integers without large prime factors. Mathematics of Computation, 73:1013–1022, 2004. MR 2031422 (2005a:11142). [27] K. Suzuki. Approximating the number of integers without large prime factors. Mathematics of Computation, 75:1015–1024, 2006. [28] G. Tenenbaum. Introduction to Analytic and Probabilistic Number Theory, volume 46 of Cambridge Studies in Advanced Mathematics. Cambridge University Press, english edition, 1995. [29] C. Zhang. An extension of the Dickman function and its application. PhD thesis, Purdue University, 2002. Computer Sciences Department, University of Wisconsin-Madison E-mail address: [email protected] Computer Science and Software Engineering Department, Butler University E-mail address: [email protected]
1504.03026
2
1504
2015-06-14T07:02:20
Analysis of a Classical Matrix Preconditioning Algorithm
[ "cs.DS", "math.NA", "math.NA" ]
We study a classical iterative algorithm for balancing matrices in the $L_\infty$ norm via a scaling transformation. This algorithm, which goes back to Osborne and Parlett \& Reinsch in the 1960s, is implemented as a standard preconditioner in many numerical linear algebra packages. Surprisingly, despite its widespread use over several decades, no bounds were known on its rate of convergence. In this paper we prove that, for any irreducible $n\times n$ (real or complex) input matrix~$A$, a natural variant of the algorithm converges in $O(n^3\log(n\rho/\varepsilon))$ elementary balancing operations, where $\rho$ measures the initial imbalance of~$A$ and $\varepsilon$ is the target imbalance of the output matrix. (The imbalance of~$A$ is $\max_i |\log(a_i^{\text{out}}/a_i^{\text{in}})|$, where $a_i^{\text{out}},a_i^{\text{in}}$ are the maximum entries in magnitude in the $i$th row and column respectively.) This bound is tight up to the $\log n$ factor. A balancing operation scales the $i$th row and column so that their maximum entries are equal, and requires $O(m/n)$ arithmetic operations on average, where $m$ is the number of non-zero elements in~$A$. Thus the running time of the iterative algorithm is $\tilde{O}(n^2m)$. This is the first time bound of any kind on any variant of the Osborne-Parlett-Reinsch algorithm. We also prove a conjecture of Chen that characterizes those matrices for which the limit of the balancing process is independent of the order in which balancing operations are performed.
cs.DS
cs
ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR ABSTRACT. We study a classical iterative algorithm for balancing matrices in the L∞ norm via a scaling transformation. This algorithm, which goes back to Osborne and Parlett & Reinsch in the 1960s, is implemented as a standard preconditioner in many numerical linear algebra packages. Surprisingly, despite its widespread use over several decades, no bounds were known on its rate of convergence. In this paper we prove that, for any irreducible n × n (real or complex) input matrix A, a natural variant of the algorithm converges in O(n3 log(nρ/ε)) elementary balancing operations, where ρ measures the initial imbalance of A and ε is the target imbalance of the output matrix. (The imbalance of A is maxi log(aout i are the maximum entries in magnitude in the ith row and column respectively.) This bound is tight up to the log n factor. A balancing operation scales the ith row and column so that their maximum entries are equal, and requires O(m/n) arithmetic operations on average, where m is the number of non-zero elements in A. Thus the running time of the iterative algorithm is (cid:101)O(n2m). This is the first time bound of any kind on any variant of the Osborne-Parlett-Reinsch algorithm. We also prove a conjecture of Chen that characterizes those matrices for which the limit of the balancing process is independent of the order in which balancing operations are performed. , ain i /ain i ), where aout i 1. INTRODUCTION 1.1. Background and discussion of results. In numerical linear algebra, it is standard practice to precon- dition an n × n real or complex matrix A by performing a similarity transform D−1AD for some diagonal scaling matrix D, prior to performing other computations on A such as computing its eigenvalues. The goal is that D−1AD should be balanced, in the sense that the norm of the ith row is equal to the norm of the ith column, for all i. The point here is that standard linear algebra algorithms tend to be numerically unstable for unbalanced matrices. Diagonal scaling achieves balance without affecting the eigenvalues of A. (Pre- conditioning typically also involves a separate process of row and column permutations which we ignore here.) This idea goes back to Osborne in 1960 [14], who suggested an iterative algorithm for finding a D that balances A in the L2 norm, and proved that it converges in the limit; he also proposed using the analogous iteration in the L∞ norm. Parlett and Reinsch generalized the algorithm to other norms [15]. Neither of these papers gave any bound on the convergence time of the algorithm (in any norm). In the decades since then, this algorithm has been implemented as standard in almost all numerical linear algebra software, including EISPACK, LAPACK and MATLAB. For further background see, e.g., [20, 12]. Surprisingly, despite its widespread use in practice, no bounds are known on the running time of any variant of this iterative balancing algorithm. Our goal in this paper is to initiate a quantitative study of the Osborne-Parlett-Reinsch algorithm. We emphasize that our motivation is to understand an existing method which has emerged as the leading choice of practitioners, rather than to devise a new competitor in the asymptotic regime; however, the bounds we obtain show that even asymptotically this method is not far off the theoretically best (and much more complex) algorithms. (See the Related Work section for a discussion.) LJS was supported in part by NSF grants 1038578 and 1319745 and by the Simons Institute for the Theory of Computing, where most of this work was performed. AS was supported in part by NSF grants 1016896 and 1420934. Addresses: Caltech, Engineering and Applied Science MC305-16, Pasadena CA 91125, USA, [email protected]; Computer Science Division, Soda Hall, University of California, Berkeley CA 94720 -- 1776, USA, [email protected]. 2 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR i (cid:113) ), where aout , ain i i (cid:113) aout i /ain column i of A by ri =(cid:112)(cid:107)ai·(cid:107)/(cid:107)a·i(cid:107), and each entry in row i by r−1 The iterative algorithm is very easy to describe, and involves repeated execution of a simple local balancing operation. Let (cid:107) · (cid:107) be a norm. For an index i ∈ [n], let (cid:107)ai·(cid:107) and (cid:107)a·i(cid:107) denote the norms of the ith row and ith column of A respectively. To avoid technicalities, we make the standard assumption that A is irreducible (see below), which ensures these norms are always nonzero; otherwise, earlier (and faster) stages of the preconditioning decompose A into irreducible components. A balancing operation at i scales each entry in (thus leaving aii unchanged). Note that this operation corresponds to the diagonal transformation D−1AD, where D = diag(1, . . . , ri, . . . , 1). The iterative algorithm simply performs the following step repeatedly:1 Pick an index i and perform a balancing operation at i. We focus in this paper on the case of balancing in the L∞ norm, where the goal is to find D so that in D−1AD the largest entry (in magnitude) in the ith row is equal to the largest entry in the ith column, for all i. We refer to such a matrix as balanced. The scaling factor in the algorithm is then just ri = i , where i = maxj aji are the maximum elements in the ith row and column respectively. i = maxj aij and ain aout This version of the algorithm is particularly simple to implement, which makes it an attractive alternative to (say) the L2 version. Since the algorithm depends only on the magnitudes of the aij, and multiplies them only by positive reals, we will simplify from now on by assuming that all entries aij are non-negative, keeping in mind that the balancing operations are actually performed on the original matrix A.2 It is instructive to view this procedure in terms of the directed weighted graph GA, in which there is an edge (i, j) of weight aij if aij > 0 (and no edge if aij = 0). Irreducibility of A corresponds to GA being strongly connected. The above balancing operation scales all incoming (respectively, outgoing) edge weights at i are respectively the maximum outgoing vertex i by ri = and incoming weights at i. At first sight (taking logarithms of the edge weights) this process resembles a diffusion on GA; however, the fact that the scaling at each step depends on the maximum incoming/outgoing edge weight is a nonlinearity that makes the process much harder to analyze. Clearly any fixed point of the above iteration must be a balanced matrix A, i.e., aout i for all i; in other words, in the weighted graph GA, the maximum incoming edge weight is equal to the maximum outgoing edge weight at every vertex. Note that the product of the edge weights along any cycle in GA is an invariant It is thus natural to call two matrices equivalent if they agree on all these invariants. of the algorithm. The fact that the algorithm always converges asymptotically to a balanced matrix was proved, surprisingly recently, by Chen [2]3; in particular this implies the existence of a balanced matrix in each equivalence class. Chen also conjectured that a worst-case input (in terms of rate of convergence) is one in which GA is simply a directed cycle; in this case each vertex has only one incoming and one outgoing edge, so the balancing operation is linear and convergence is easily seen to occur within Θ(n3) operations. (The Θ here hides factors that depend on the maximum imbalance in the input matrix and the desired bound on how close the output matrix is to being balanced.) In most cases the process seems to converge much faster, but the problem of analyzing the convergence rate in general graphs, or even in any strongly connected graph other than a directed cycle, has remained open until now. For example, even the case of two directed cycles that share a common vertex is quite non-trivial and has proved resistant to standard arguments. The first difficulty one faces in analyzing convergence rates is that the balanced matrix to which the algorithm converges is in general not uniquely defined, but may depend on the sequence of indices i selected. (See Figure 1 for a simple example that illustrates this phenomenon.) Our first result proves a conjecture of Chen [2], which characterizes all cases in which the balancing problem has a unique solution. For a balanced (respectively, r−1 i = ain aout i /ain i 1The algorithm in [14, 15] operates on the indices in a fixed cyclic order. For ease of analysis we pick indices randomly. We conjecture that this change makes little difference to the rate of convergence. 2It is sometimes also assumed that the diagonal entries of A are replaced by zeros before the balancing process, since balancing never alters them. This replacement may of course change the problem since (e.g.) a diagonally dominant matrix is already  0 2 0 0 8 0 2 0 0 1 0 2 0 0 8 0  ; A =  0 4 0 0 4 0 2 0 0 1 0 4 0 0 4 0  ;  0 4 0 0 4 0 1 0 0 2 0 4 0 0 4 0 3  ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM B1 = B2 = FIGURE 1. Example of a non-UB matrix A. The balanced matrix B1 results from A by balancing at indices 1,4, while B2 results by balancing at indices 2,4. matrix B = {bij} and any real w > 0, let Gw B denote the subgraph of GB consisting of those edges of magnitude at least w, with isolated vertices removed. (A vertex with a self-loop is not considered isolated.) Theorem 1. A balanced matrix B is the unique balanced matrix in its equivalence class if and only if Gw B is strongly connected for all w. Note that this result gives an implicit criterion for whether a given input matrix A can be uniquely balanced: namely, that it is equivalent to a balanced matrix B with the above property. We say that such matrices A satisfy the Unique Balance (UB) condition. In an earlier version of the present paper [17], we focused on the UB case and showed that a certain variant of the Osborne-Parlett-Reinsch algorithm converges in O(n3 log n) balancing operations on any UB input matrix A. In this paper we extend that analysis to all input matrices, for a slightly different variant of the algorithm. (The term "variant" here refers only to the order in which balancing operations are performed.) i > ain To describe this variant, we need the notion of "raising" and "lowering" operations, which are one-sided versions of the standard balancing operation. A raising operation at i performs a standard balancing oper- ation at i if aout i and does nothing otherwise; similarly, a lowering operation at i performs a standard balancing operation at i if aout i and does nothing otherwise. Our variant of the algorithm will perform a sequence of random raising operations followed by a sequence of random lowering operations; equivalently, it can be viewed as the standard algorithm (with a random index order) in which some of the balancing operations are censored according to a very simple condition. i < ain To specify the algorithm precisely, we also need a measure of how far a matrix is from balanced. We i ), and say that A is ε-balanced if its imbalance is at thus define the imbalance of A as maxi log(aout most ε. The target balance parameter ε > 0 is provided to the algorithm as an additional input. We also i ) ≤ ε (or need one-sided versions of these definitions: namely, A is ε-raising-balanced if maxi log(aout i ) ≤ ε (or lowering-balanced if raising-balanced if ε = 0), and ε-lowering-balanced if maxi log(ain ε = 0). Plainly A is ε-balanced iff it is both ε-raising-balanced and ε-lowering-balanced. i /ain i /ain i /aout We note that even the asymptotic convergence of this variant of the algorithm is not immediately clear, and does not follow from Chen's proof [2] or from our proof in Appendix A. The reason is that those proofs assume that the sequence of balancing operations is fair, in the sense that each index i appears arbitrarily often. In the two-phase version, fairness cannot be guaranteed since some balancing operations are censored. Instead, convergence of the two-phase algorithm is an immediate consequence of the following theorem. Theorem 2. For any input matrix A, any fair sequence of raising (resp., lowering) operations converges to a unique raising-balanced (resp., lowering-balanced) matrix, independent of the order of the operations. balanced in L∞. We do not assume such a replacement has been made; our analysis of the balancing algorithm applies whether or not diagonal entries are zero. 3To make the current paper self-contained, we present in Appendix A an alternative proof of convergence that uses combinatorial rather than topological techniques and is closer to the methodology developed in this paper. 4 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR Algorithm 1: 2PhaseBalance(A, ε) Input: An n × n matrix A with (unknown) imbalance ρ; and a target ε > 0. Output: A matrix equivalent to A that is ε-balanced with high probability. //Raising Phase// //Lowering Phase// 1 Compute ρ in time O(n2) 2 Repeat T = O(n3 log(ρ/ε)) times 3 4 Repeat T = O(n3 log(ρ/ε)) times 5 6 Output the resulting matrix Pick an index i u.a.r. and apply a raising operation at i Pick an index i u.a.r. and apply a lowering operation at i Correctness of the two-phase algorithm follows because it is easy to see that the lowering phase cannot increase the raising imbalance of A (see Proposition 4). The value T is chosen to guarantee that A is ε- raising-balanced (resp., ε-lowering-balanced) at the end of a phase w.h.p.; hence, at the conclusion of both phases A will indeed be ε-balanced w.h.p. Theorem 2 is actually a somewhat surprising result: even when A is not UB (so that the balanced matrix to which the original version of the algorithm converges depends on the sequence of operations performed), if we perform only raising (or only lowering) operations we are guaranteed a unique limit. It is this fact that will allow us to obtain an analysis of the rate of convergence. We are now able to state the main result of the paper, which bounds the rate of convergence of the above algorithm. Theorem 3. On input (A, ε), where A is an arbitrary irreducible non-negative matrix with imbalance ρ, the above two-phase L∞ balancing algorithm performs O(n3 log(nρ/ε)) balancing operations and outputs a matrix equivalent to A that is ε-balanced w.h.p.4 This is the first time bound (except on the cycle) for any variant of the Osborne-Parlett-Reinsch algorithm (under any norm). Moreover, the bound on the convergence rate is actually tight up to a factor O(log n), in view of the Ω(n3) lower bound we mentioned earlier for the cycle. Indeed, Theorem 3 implies that the cycle is a worst case input for the algorithm (up to the log n factor), as conjectured by Chen [2]. Remark. Throughout the paper, we quantify the rate of convergence of the algorithm in terms of the number of balancing operations performed. Since each balancing operation (raising or lowering) involves finding a maximum element in one row and column and then scaling the row and column, it can be performed on average in O(m/n) arithmetic operations, where m is the number of edges in GA (i.e., the number of non-zero entries in A). Thus, in terms of arithmetic operations, the (average) running time of the algorithm is O(n2m log n). We close this section with a brief outline of our approach to analyzing the algorithm. As we have observed above, it suffices to analyze only the raising phase; by symmetry, an identical analysis applies to the lowering phase5. The first key observation is that the uniqueness of the limit in the raising phase allows us to assign a well-defined height to every vertex in GA; the height of a vertex measures the "amount of raising" that needs to be performed at that vertex in order to reach the unique raising-balanced configuration. Each raising operation can then be viewed as smoothing these heights locally. In a diffusion process this naturally leads to an associated Laplacian potential function consisting of the sum of squares of local height differences, whose convergence is captured by the eigenvalues of the heat kernel operator. Attempts to conduct a similar analysis here fail. One serious problem is that a balancing operation at vertex i depends only on the incoming and 4We use the phrase "with high probability (w.h.p.)" to mean with probability tending to 1 as n → ∞. 5It is an interesting open question whether the introduction of phases in the Osborne-Parlett-Reinsch algorithm leads to more rapid convergence in practice. ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 5 outgoing edges of maximum weight, but has side effects on all other edges incident at i. Another problem is that there are, essentially, "levels" within the graph: roughly speaking, vertices that lie in the "lower" levels of the graph cannot reliably converge toward (raising) balance until the vertices in the "higher" levels have converged. While phenomena similar to this can arise in diffusion processes, in our nonlinear setting standard tools such as eigenvalues are lacking to capture them. The chief technical challenge in our analysis is to relate the local height changes achieved by raising oper- ations to an improvement in a global potential function (the sum of the heights), thus ensuring significant progress (in expectation) over time. The details of our analysis ensure an expected improvement that is a factor Ω(n3) of the current value of the potential function in each step, thus leading to global convergence in O(n3) raising operations. To establish the above local-global connection, we need a two-dimensional representation of the current state of the algorithm, which records not only the height of a vertex but also its level; unlike the heights, which change over time, the level of a vertex is fixed. This two-dimensional representation leads naturally to the notion of the momentum of a vertex, which measures how far a vertex currently is from its true level. Momentum is a key ingredient in relating local improvements to the global potential function. 1.2. Related work. As mentioned above, the idea of iterative diagonal balancing was introduced by Os- borne [14] in 1960, who was motivated by the observation that minimizing the Frobenius norm of A is equivalent to balancing A in the L2 norm. Osborne formulated an L2 version of the above iterative algo- rithm and proved that it converges in the limit (but with no rate bound); he also proposed the L∞ algorithm discussed in this paper but left the question of convergence open. Convergence was first proved by Chen [2] almost 40 years later. Parlett and Reinsch [15] generalized Osborne's algorithm to other norms (without proving convergence) and discussed a number of practical implementation issues for preconditioning. For the L1 version of the Osborne-Parlett-Reinsch algorithm, convergence was proved by Grad [6], uniqueness of the balanced matrix by Hartfiel [7], and a characterization of it by Eaves et al. [4], but again no bounds on the running time of L1 balancing were given. Despite the scarcity of theoretical support, these algorithms are implemented as standard in many numerical linear algebra packages and experience shows them to be both useful and fast. A sequence of two papers offers an alternative, and substantially more complex, non-iterative algorithm for matrix balancing in the L∞ norm. Schneider and Schneider [16] gave an O(n4)-time algorithm based on finding maximum mean-weight cycles in a graph; the running time was improved to O(nm + n2 log n) using Fibonnaci heaps and other techniques by Young, Tarjan and Orlin [21]. This is asymptotically faster than the (cid:101)O(n2m) worst case running time we establish for the iterative algorithm; and for some graphs (e.g., the cycle) it is faster than the actual running time of the iterative algorithm. However the iterative method has been favored in practice. This may be justified by the empirical distribution of inputs. Moreover, it is definitely driven by the fact that the iterative method offers steady partial progress, and so can deliver, without being run to completion, a matrix that is sufficiently balanced for the subsequent linear algebra computation. In practice indeed the method is usually run for far fewer iterations than are needed in the worst case. Our purpose in this paper is to provide the first theoretical understanding of the widely used iterative methods, rather than to derive new theoretical bounds for the underlying problem. In other work on matrix balancing, Kalantari et al. [10] considered balancing in the L1 norm, and provided the first polynomial time algorithm by reduction to convex programming: (cid:101)O(n4) via the ellipsoid method. Diagonal scaling has also been used to minimize matrix norms without regard to balancing. For example, Strom [19] considers the problem of finding diagonal scaling matrices to minimize the max and Frobenius norms of the matrix. In particular, for the max norm he proves that (when A is irreducible) the optimal di- agonal scaling matrix is obtained from the principal eigenvector. Chen and Demmel [3] show that a suitable notion of weighted balancing can be used to minimize the 2-norm, and discuss Krylov-based algorithms 6 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR that work efficiently on sparse matrices. Boyd et al. [1] formulate the problem of minimizing the Frobenius norm as a generalized eigenvalue problem. A different notion of matrix balancing is often known as Sinkhorn balancing after Sinkhorn [18], who pro- posed a natural iterative algorithm analogous to that of Osborne-Parlett-Reinsch. The goal here is to find a scaling matrix D such that D−1AD has prescribed row and column sums. A polynomial time algorithm for this problem was given by Kalantari and Khachian [9], while the convergence rate of Sinkhorn's it- erative algorithm was studied by several authors [5, 8, 13, 11]. In particular Linial, Samorodnitsky and Wigderson [13] gave strongly polynomial bounds (after a non-Sinkhorn preprocessing step) and derived a surprising approximation scheme for the permanent of a non-negative matrix. 2. PRELIMINARIES i = maxj αij and αin and ain i . i i = maxj αji, a balancing operation at i then consists of adding (αout In this section we introduce some terminology and notation that we will use throughout the paper. We begin with an equivalent reformulation of the Osborne-Parlett-Reinsch balancing algorithm from the Introduction. Let A be an irreducible n× n matrix. As described in the Introduction, the algorithm operates by iteratively picking an index i and geometrically averaging the maximum entries (in magnitude) aout It is convenient to switch to arithmetic averages by setting αij = log aij (so that 0 entries of A become −∞). i − Letting αout αin i )/2 to the ith column and subtracting the same quantity from the ith row. (In the actual implementation of the algorithm, this corresponds to the multiplicative diagonal transformation D = diag(1, . . . , ri, . . . , 1) applied to the original matrix A. However, for the rest of the paper we will assume that the algorithm operates additively on the logarithms of the matrix entries and ignore the details of this trivial translation.) We re-use the notation Gα from the Introduction to denote the digraph with edges (i, j) such that αij > −∞. (The passage from roman to greek letters will always resolve this abuse of notation.) Irreducibility of A again corresponds to Gα being strongly connected. We shall regard α as a real-valued function defined only on the edges of Gα, and call it a graph function. Note that if balancing operations change the graph function α to α(cid:48) we always have Gα = Gα(cid:48). For the remainder of the paper, we use letters u, v etc. rather than i, j to denote vertices as our focus will be on the graph Gα rather than on the matrix A. v . The We say that a graph function α is balanced if αout imbalance of α is ρ := maxv ρv, and α is ε-balanced if ρ ≤ ε. (These definitions are equivalent to those in the Introduction in terms of the matrix entries aij.) A balancing operation is available at v iff ρv > 0. As indicated in the Introduction, we analyze a slightly modified version of the basic Osborne-Parlett-Reinsch algorithm, which has two phases and performs only certain balancing operations (raising or lowering) during v } be the raising and lowering imbalances, a phase. Let ρR v }, since one of ρR respectively, at v. Note that ρv = ρR v must be zero. A raising operation at v performs a standard balancing operation at v if ρR v > 0 and does nothing otherwise; similarly, a lowering operation at v performs a standard balancing operation at v if ρL v > 0 and does nothing otherwise. Such an operation is said to raise (resp., lower) v by an amount ρR v /2); note that a raising operation at v reduces its raising imbalance to zero unless the maximum outgoing edge from v is a self-loop, in which case the raising imbalance is reduced by a factor of 2. The raising imbalance of α is v . We say that α is ε-raising-balanced ρR := maxv ρR if ρR ≤ ε, and ε-lowering-balanced if ρL ≤ ε. Clearly α is ε-balanced iff it is both ε-raising-balanced and ε-lowering-balanced. α the subgraph of Gα consisting of edges (u, v) such that αuv ≥ w, with isolated For any real w, denote by Gw vertices removed. (A vertex with a self-loop is not considered isolated.) Let α, γ be two graph functions on the same graph G. We say that α, γ are equivalent, α ∼ γ, if their sums (cid:96)=1(αv(cid:96),v(cid:96)+1 − γv(cid:96),v(cid:96)+1) = 0 for all cycles (v1, . . . , vk), where around all cycles of G are equal, i.e., if(cid:80)k v for all v. For each v, define ρv = αout v } and ρL v + ρL v = max{0, αin v = max{ρR v −αout v , ρL v , and the lowering imbalance of α is ρL := maxv ρL v = max{0, αout v −αin v , ρL v /2 (resp., ρL v = αin v − αin vk+1 = v1. ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 7 It is convenient for our analysis to introduce a generalization of the standard local balancing operation at a vertex. Let α be a graph function. For any x ∈ R and S ⊆ [n], denote by α + xS ("α shifted by x at the set S") the graph function given by (α + xS)uv = αuv + x· (IS(u)− IS(v)), where IS is the indicator function for membership in S. Thus the balancing operation at v is equivalent to shifting by (αin v )/2 at the set {v}. It is readily seen that two graph functions are equivalent iff there is a sequence of shifts converting one to the other. Note that, like balancing operations, shifts of α do not change Gα. v − αout 3. THE UNIQUE BALANCE PROPERTY As shown by Chen (and reproved with a different argument in the present paper -- see Appendix A), balanc- ing operations do not cycle; Chen argued this topologically while we show that there is an order on graph functions such that nontrivial balancing operations are strictly lowering in the order. However, neither the topological nor the order-theoretic argument yields useful quantitative information on the rate of conver- gence. One reason for this, but not the only reason, is that the limit point of the process is not in general uniquely determined by the input matrix A (see Figure 1 for a simple example). For a broad class of inputs, however, a unique limit does exist. The characterization of this class was conjectured by Chen [2] and is our first result. This was already stated as Theorem 1 in the Introduction; we restate it here in slightly different notation. Theorem 1. A balanced graph function β is the unique balanced graph function in its equivalence class if β is strongly connected for all w. and only if Gw Proof of ⇒: Let β be balanced. Suppose Gw β is not strongly connected, and that w is the largest value for β has no sources or sinks, and hence must contain which this is the case. Note that since β is balanced, Gw at least one source strongly connected component (scc) S and one sink scc T , both of which are non-trivial (i.e., contain at least two vertices or one self-loop). Moreover, by maximality of w, the weights of external β are all exactly w. Choose vertices s ∈ S and t ∈ T , and consider a directed edges (between scc's) in Gw simple path P from s to t in Gβ. (Such a path exists because Gβ is strongly connected.) Let ε > 0 be smaller than the gap between any two distinct values of β. Then in Gβ+εT , the length of P is ε less than it is in Gβ. Now apply balancing operations in any order to the graph function β + εT (which is equivalent to β), to balance it (in the limit). We claim that no balancing operation will ever be applied at any vertex inside a non-trivial scc of Gw β , and hence at either s or t. To see this, note that such a balancing operation can only occur if the weight of some external edge incident on the scc reaches a value larger than w. But in β + εT no external edge has weight larger than w (this was true in β and the shift at T has increased the weight only of edges leaving T , but to a value less than w), so balancing operations at the vertices outside the scc's cannot increase the weight of edges above w. Hence in the limiting (and hence balanced) graph function, the length of the path P from s to t will remain ε less than it is in β. (The length of a path can be altered only by a balancing operation at one of its endpoints.) Hence this limiting graph function is different from β. Proof of ⇐: Let α ∼ β be distinct balanced graph functions. We show that there is a w such that neither β nor Gw Gw α (the supremum is achieved as the graph is finite), and Let w be the largest value such that Gw β cannot be strongly connected because if suppose w.l.o.g. there is an edge (u, v) in Gw it were, consider any cycle in Gw β which includes (u, v). The weight of this cycle is larger in Gβ than in Gα because all weights larger than w in the cycle are identical in both functions, and in Gβ all remaining weights equal w, while in Gα all are at most w and at least one is strictly less than w. Hence α (cid:54)∼ β, which is a contradiction. Likewise, if there is an edge in Gw α ⊂ Gw Gw α is not strongly connected. This leaves only the case β , and V be the set of vertices β . Let U be the set of vertices from which u can be reached in Gw α − Gw β then Gw α is strongly connected. β (cid:54)= Gw β − Gw α . Then Gw 8 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR β . As shown in the previous paragraph, these sets are disjoint. Each set must contain reachable from v in Gw β contains no sources or sinks). These scc's (call a non-trivial scc (because β is balanced and therefore Gw them U(cid:48) and V (cid:48)) must also be strongly connected in Gw α ; in fact, we argue that α equals β on the edges of β within each scc. For, consider any cycle using edges of Gw β in the scc. The cycle may contain edges Gw heavier than w (which are identical in α and β), and some edges that are equal to w in β and ≤ w in α. But then since α ∼ β, these edges must also equal w in α. So α and β are identical on the edges of Gw β in the α ⊂ Gw scc. Now, if Gw β , this path also lies in Gw α is strongly connected, then it contains a path from V (cid:48) to U(cid:48). Then since Gw β . Contradiction. 2 In light of Theorem 1, we say that a graph function α has the Unique Balance (UB) property if there is a balanced β ∼ α such that Gw β is strongly connected for all w. By the convergence theorem (see Appendix A), on any input matrix with the UB property the original Osborne-Parlett-Reinsch balancing algorithm will converge to a unique balanced matrix. In an earlier version of the present paper [17], we analyzed the rate of convergence of (a suitable variant of) the algorithm in the UB case, and derived the same bound as we now obtain for general matrices in Theorem 3. In the remainder of this paper, we turn our attention to the general case and leave Theorem 1 as an interesting structural result. 4. CONVERGENCE OF THE TWO-PHASE ALGORITHM The goal of this section is to prove that the two-phase variant of the iterative balancing algorithm described in the Introduction converges and outputs a ε-balanced graph function. Note that convergence does not follow from the general convergence proof given in Appendix A, since the sequence of balancing operations in this case is not "fair" in the sense that every vertex is guaranteed to appear arbitrarily often. Convergence of the two-phase variant follows immediately from Theorem 2 stated in the Introduction, which we restate here in graph function terms. Theorem 2. For any initial graph function α, any fair sequence of raising (resp., lowering) operations converges to a unique raising-balanced graph function αR (resp., lowering-balanced graph function αL), independent of the order of the operations. To deduce that the output of the two-phase algorithm is indeed ε-balanced, we need the following additional simple observation. Proposition 4. A lowering operation cannot increase any raising imbalance ρR operation cannot increase any lowering imbalance ρL v . v . Symmetrically, a raising Proof. We give the proof only for lowering operations; the proof for raising operations is symmetrical. Consider a lowering operation at vertex v, and assume that it has a non-zero effect, i.e., ρL v > 0. Lowering v (to zero unless the maximum incoming edge at v is a self-loop in which case the reduction at v reduces ρL is to ρL v at zero. The only other imbalances that can be affected are at neighbors of v. Lowering at v decreases edge weights αuv, which cannot increase ρR u . Similarly, lowering at v increases edge weights αvw, which again cannot increase ρR v /2) and keeps ρR w. 2 It is now easy to see that the two-phase algorithm terminates with an ε-balanced graph function. By The- orem 2 each of the two phases terminates with the appropriate balance condition. At the end of the raising phase the function is ε-raising balanced, and by Proposition 4 it remains so throughout the lowering phase. At the end of the lowering phase the resulting graph function is both ε-raising balanced and ε-lowering balanced, and hence ε-balanced as required. The remainder of this section is devoted to proving Theorem 2. We focus on raising operations; the proof for lowering operations follows by a symmetrical argument. ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 9 We introduce the following notation. Fix the initial graph function α and a particular fair infinite sequence of raising operations. Let α = α(0), α(1), . . . , α(t), . . . be the resulting sequence of graph functions obtained. Also, for each t ≥ 0 let the raising vector r(t) = (rv(t)) record the cumulative amount by which each vertex has been raised. I.e., r(0) = 0 and, if the tth raising operation is at vertex v, then rv(t) = rv(t − 1) + ρR v /2 and ru(t) = ru(t − 1) for all u (cid:54)= v. Note that the vector r(t) completely specifies6 α(t) via the relation (1) Lemma 5. The sequence r(t) is increasing and bounded above, and hence converges to a limit vector r∗ as t → ∞. αuv(t) = αuv(0) + rv(t) − ru(t). Now define the function Φ(t) =(cid:80) Proof. The fact that r(t) is increasing is immediate from its definition. To see that it is bounded, observe first that the graph function α(t) is bounded above and below for all t; indeed, it is immediately clear from the definition of balancing that maxu,v αuv(t) cannot increase with t, while the less obvious fact that αuv(t) is bounded below follows from Lemma 17 in Appendix A. Φ(t + 1) − Φ(t) ≤ −ρR v /2, we conclude from (2) that rv(t) is also bounded. (u,v)∈E,u(cid:54)=v Nuv(t)!αuv(t), where Nuv(t) is the number of edges (u(cid:48), v(cid:48)) of weight αu(cid:48)v(cid:48)(t) ≤ αuv(t). We claim that, if the tth raising operation is at vertex v, the change in Φ is bounded by (2) Since by the observations in the previous paragraph Φ(t) is always bounded, and the increase in rv(t) is exactly ρR To prove (2), represent each edge (u, v) by a particle on the real line at position αuv(t). We will view [t, t+1] as a continuous time interval, during which each particle (u, v) moves at constant speed from αuv(t) to αuv(t + 1). We now compute the rate of change of Φ under a raising operation at vertex v (assuming that v > 0 so that the raising operation is non-trivial; otherwise, Φ does not change). The only particles that ρR move are (u, v) and (v, w) as u, w range over neighbors of v; each particle (u, v) moves a distance ρR v /2 to the right, and each (v, w) moves the same distance to the left. Let ¯u, ¯w be such that α¯uv = max(u,v) αuv(t) v = αv ¯w(t)− α¯uv(t). The rate of change of Φ(t(cid:48)) for t(cid:48) in the interval and αv ¯w = max(v,w) αvw(t), so that ρR [t, t + 1) is given by v /2. ∂Φ(t(cid:48)) ∂t(cid:48) (cid:16)(cid:88) (cid:16) (u,v) = ρR v 2 ≤ ρR v 2 ≤ − ρR v 2 . Nuv(t(cid:48))! − (cid:88) (v,w) (cid:17) Nvw(t(cid:48))! (Nv ¯w(t(cid:48)) − 1)(Nv ¯w(t(cid:48)) − 1)! − Nv ¯w(t(cid:48))! (cid:17) The negative term in the second line arises from the contribution of the particle (v, ¯w), whose edge remains heaviest throughout. The positive term arises because there are at most Nv ¯w(t(cid:48)) − 1 particles to the left of (v, ¯w), each of which contributes at most (Nv ¯w(t(cid:48)) − 1)!. As the particles move and pass other particles, the coefficients Nuv(t(cid:48)) change. However, observe that the above calculation is valid at all times t(cid:48) ∈ [t, t + 1), since it relies only on the fact that (v, ¯w) is the rightmost moving particle. Hence we deduce the bound (2) claimed earlier, which completes the proof. 2 It follows immediately from Lemma 5 and equation (1) that α(t) also converges to a limit α∗, and by con- tinuity and fairness α∗ must be raising-balanced. It remains to show that α∗ is independent of the sequence of raising operations. For this we require the following monotonicity property of raising operations. 6However, the converse is not quite true: given α(t) we can deduce r(t) only up to an additive constant. 10 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR Lemma 6. Let r, s be raising vectors obtained from a common initial graph function α via different se- quences of raising operations. Suppose that r ≤ s, and let r(cid:48), s(cid:48) be the new raising vectors obtained from r, s after one additional raising operation at a common vertex v. Then r(cid:48) ≤ s(cid:48). Proof. Clearly we have r(cid:48) of the raising operation at v, we have (using equation (1)) u for all u (cid:54)= v, so we need only show that r(cid:48) u = ru ≤ su = s(cid:48) v. By definition v ≤ s(cid:48) r(cid:48) v = rv + ρR v 2 1 2 max(cid:8)0, max max(cid:8)2rv, max w:v→w w:v→w = rv + = 1 2 (αuv + rv − ru)(cid:9) (αvw + rw − rv) − max u:u→v (ru − αuv)(cid:9). (αvw + rw) + min u:u→v (Here, and subsequently, we use the notation u → v to indicate that there is an edge (u, v) in Gα.) Since the right-hand side here is monotonically increasing in all entries of r, and r ≤ s, we conclude that r(cid:48) v as required. 2 Lemma 7. For any initial graph function α and sequence of raising vectors r(1), r(2), . . . , r(t), . . . ob- tained from a fair sequence of raising operations, the limit r∗ = limt→∞ r(t) exists and depends only on α, not on the sequence of raising operations. v ≤ s(cid:48) Proof. Consider some fair sequence of raising operations starting from α, and let α(t), r(t) be the cor- responding sequences of graph functions and raising vectors respectively. By Lemma 5, the limits α∗ = limt→∞ α(t) and r∗ = limt→∞ r(t) exist and α∗ is raising-balanced. Now consider a second sequence of raising operations also starting from α, and let s(t) be the corresponding sequence of raising vectors. Again, by Lemma 5, the limit s∗ = limt→∞ s(t) exists. Suppose we apply this second sequence of raising operations, starting on the one hand from α and on the other hand from α∗. The resulting raising vectors (with respect to α) are respectively s∗ and r∗ (the latter because α∗ is already raising-balanced). Applying Lemma 6 to compare the raising vectors at each step of this process yields s∗ ≤ r∗. But by symmetry we must also have r∗ ≤ s∗, and hence r∗ = s∗. This completes the proof. 2 Since the graph function α∗ is completely determined by the raising vector r∗, Lemma 7, and its symmetric counterpart for lowering operations, proves Theorem 2, which was the main goal of this section. Figure 2 shows an example of a graph function and its associated unique corresponding raising- and lowering- balanced functions. 5. RATE OF CONVERGENCE In this section we will prove the main result of the paper, Theorem 3 from the Introduction, which gives a tight bound on the rate of convergence of the iterative balancing algorithm. We restate the result here for convenience. Theorem 3. On input (A, ε), where A is an arbitrary irreducible non-negative matrix with imbalance ρ, the above two-phase L∞ balancing algorithm performs O(n3 log(nρ/ε)) balancing operations and outputs a matrix equivalent to A that is ε-balanced w.h.p. We give here a brief, high-level outline of our analysis. First note that, by Proposition 4 in the previous section, it suffices to analyze each phase of the algorithm separately. Accordingly, we will analyze only the raising phase, showing that it achieves an ε-raising-balanced graph function w.h.p. after O(n3 log(ρ/ε)) ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 11 FIGURE 2. Example showing convergence of raising and lowering operations. (i) A graph function α. (ii) The raising-balanced graph function αR obtained in the limit from α by raising operations; numbers in square brackets at the vertices show the limiting raising vector r∗. (iii) The balanced graph function (αR)L obtained in the limit by applying low- ering operations to αR, together with its associated lowering vector. (This is the unique balanced graph function to which the two-phase algorithm "converges" if both phases are run to convergence.) Figures (iv) and (v) show the graph functions αL and (αL)R respec- tively (and their associated lowering/raising vectors), obtained by reversing the order of the raising and lowering phases. Note that the balanced graph functions (αR)L (in (iii)) and (αL)R (in (v)) are not the same; while both versions (raising-lowering and lowering- raising) converge to a unique balanced graph function, these limits are not equal. The graph function α is not UB. raising operations. By symmetry the same bound holds for the lowering phase: simply observe that lowering on the graph Gα is equivalent to raising on the transpose graph GT α. In the Introduction we already discussed some of the difficulties which prevent us from analyzing the dy- namics of the algorithm by tracking a scalar quantity at each vertex, as would be the case for the analogous but much simpler heat-kernel dynamics. A key ingredient in our solution to the problem is to introduce a two-dimensional representation of the graph function α, together with an associated potential function that will enable our analysis of the raising phase. One coordinate (the vertical coordinate) in this representation, called the "height" of a vertex, is based on the unique raising vector r∗ whose existence is guaranteed by Lemma 7 of the previous section; the second (horizontal) coordinate is the "level" of the vertex, as alluded to in the Introduction. This representation, which is specified in detail in Section 5.1, will be instrumental in obtaining upper and lower bounds relating the (global) potential function to the local imbalances (which govern the effect of a single raising operation); these bounds are derived in Sections 5.2 and 5.3 respectively. Finally, in Section 5.4 we conclude the proof of Theorem 3. abfced34314554[0][0][3][3 ][1][0]12-12-12-abfced34334454[1][2][1][1 ][0][1]12-abfced71007654abfced354[ ][ ][ ][ ][0][0]-13-13-233-233-233-133-133-13-16-16(i)(ii)(iv)(v)(iii)abfced33454[3 ][0][0][0][3]12-312-312-312-[2 ]12-12-(iv) 12 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR 5.1. A two-dimensional representation. Throughout this and the next two subsections, we focus exclu- sively on the raising phase. As we observed above, exactly the same rate of convergence will apply to the lowering phase. Recall from Lemma 7 that, for any initial graph function α, the limiting raising vector r∗, which records the asymptotic total amount of raising performed at each vertex by any infinite fair sequence of raising operations, is uniquely defined and specifies a unique raising balanced graph function αR. We may therefore use r∗ to define a height function yv := −r∗ v, i.e., −yv is the amount of raising that remains to be performed at vertex v in order to reach the raising- balanced graph function αR. (Note that, throughout, all heights are non-positive and converge monotonically to zero. This convention turns out to be convenient in our analysis.) The heights are related to α and αR by (3) uv − αuv = yu − yv, αR which is just a restatement of equation (1). In addition to the heights yv, we will need to introduce a second coordinate xv defined by (4) xv := max u:u→v αR uv. We refer to xv as the level of vertex v. Note that (intuitively at least), lower level vertices can only reliably be close to raising-balanced after higher level ones are close, so the levels capture one of the distinguish- ing features of the problem. The two-dimensional representation (xv, yv) of vertices v will be key to the remainder of our argument. Figure 3 shows the two-dimensional representation of the graph function in Figure 2(i). The horizontal coordinates can be read off from the maximum incoming edges at each vertex in Figure 2(ii), and the vertical coordinates from the square brackets in the same figure. FIGURE 3. Two-dimensional representation of the graph function α shown in Figure 2(i). We will measure progress of the raising phase by means of the global potential function Ψ = −(cid:80) yv, which is the total amount of raising that remains to be done to reach αR. In order to relate Ψ to the local imbalances ρR v , it will be convenient to introduce a closely related global quantity h, which is just the difference between the maximum and minimum heights. That is, setting ymin = minu yu and ymax = maxu yu, we define h := ymax − ymin. abdfceyv=0yv=−1yv=−312-yv=−3xv=312-xv=5xv=4 ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 13 (As we shall see shortly (Corollary 11), it is always the case that ymax = 0 so in fact h = −ymin.) Note that Ψ and h differ by at most a factor of n, namely: (5) Ψ ≥ h ≥ 1 n Ψ. The key ingredients in our analysis are the following two bounds relating h to the local imbalances ρR v . Proposition 8. For any graph function α, we have ρR/2 ≤ h. Proposition 9. For any graph function α, we have h ≤ (n − 1)(cid:80) v . v ρR Proposition 8 confirms that, to ensure ε-raising-balance, it suffices to achieve Ψ ≤ ε/2. The much more subtle Proposition 9 implies that Ψ decreases at each step by an expected (1 − Ω( 1 n3 )) factor. To see this implication, note that the expected decrease in Ψ in one raising operation is 1 v , and apply 2n Proposition 9 and equation (5). In the next two subsections we prove Propositions 8 and 9 respectively. (cid:80) v ρR 5.2. Proof of Proposition 8. The proposition will follow almost immediately from the following straight- forward lemma relating heights to local imbalances. Since we are dealing exclusively with the raising phase, in this and the next two subsections we will write ρv, ρ in place of ρR Lemma 10. Let α be a graph function and v a vertex with ρv > 0. Then there exist edges (u, v) and (v, w) in Gα such that v , ρR to simplify notation. (6) yv + ρv 2 ≤ yu + yw 2 . Proof. Let u, w be vertices such that αuv = αin outgoing edges of maximum weight at v). Note that ρv = αvw − αuv. To prove (6) we let u(cid:48) be a vertex such that the edge (u(cid:48), v) achieves the maximum in (4), i.e., αR and write v and αvw = αout (i.e., (u, v) and (v, w) are incoming and u(cid:48)v = xv, v yv + ρv 2 u(cid:48)v + ρv 2 αvw − αuv = yu(cid:48) + αu(cid:48)v − αR = yu(cid:48) + αu(cid:48)v − αR ≤ yu(cid:48) − αR u(cid:48)v + αvw + αu(cid:48)v 2 (7) where in the first line we used equation (3) and in the last line the fact that αu(cid:48)v ≤ αuv. Now two further applications of equation (3) give u(cid:48)v + 2 , αvw = yw − yv + αR vw; αu(cid:48)v = yv − yu(cid:48) + αR u(cid:48)v. Plugging these into (7) yields ≤ yu(cid:48) − αR yv + u(cid:48)v + ρv 2 yw − yu(cid:48) + αR vw + αR u(cid:48)v 2 = yu(cid:48) + yw 2 + vw − αR αR u(cid:48)v 2 ≤ yu(cid:48) + yw 2 , where the last inequality follows from the facts that αR is raising balanced and αR incoming edges at u. This completes the proof. 2 u(cid:48)v is maximal among Before proving Proposition 8, we pause to observe a consequence of Lemma 10: Corollary 11. ymax = 0. 14 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR 2 ≤ Proof. A raising operation applied at some vertex v increases yv to yv + ρv ymax. Therefore ymax can never increase during the raising phase. Choose a vertex u so that yu = ymax u = 0. Thus ymax = yu = −r∗ initially. Then u can never rise, and so r∗ 2 . By Lemma 10 this is ≤ yu+yw u = 0. 2 We conclude this subsection by proving Proposition 8. Proof of Proposition 8. Let v be any vertex with raising imbalance ρv > 0. By Lemma 10 we have Together with the fact that, by definition, h ≥ 0, this completes the proof. 2 ≤ yu + yw − yv ≤ ymax − ymin = h. ρv 2 2 5.3. Proof of Proposition 9. The reverse inequality, Proposition 9, is considerably more delicate. It will make crucial use of the two-dimensional representation introduced earlier, as well as one additional concept which we call "momentum," whose role will emerge shortly. The momentum of a vertex v is defined by (8) {αuv − xv}, mv := max u:u→v where xv is the level of v as defined above. One key property of momentum is that it can be upper bounded at a vertex in terms of the sum of the momentum and the local imbalance at the predecessors of the vertex in the graph. (The form of this bound is complicated by a dependence on the levels of the vertices; see part (i) of Lemma 12.) The second key property of momentum is that, along any edge, height can increase only at a rate bounded by momentum and local imbalance. (Again there are additional terms complicating the dependence; see part (ii) of Lemma 12.) Putting these two properties together will show that, if the height difference between some two vertices v ρv must be large, which is exactly the in the graph is substantial, then the aggregate local imbalance(cid:80) (i) For any vertex v, mv ≤ max(cid:8)0, maxu:u→v,yu<yv (mu + ρu + xu − xv)(cid:9). content of Proposition 9. Lemma 12. The momentum satisfies the following inequalities: (ii) For any edge (u, v) in Gα, yv ≤ yu + mu + ρu + xu − αR uv. Proof. Both parts rely on the following elementary observation. For any edge (u, v), by the definition of ρu we have (9) αu(cid:48)u + ρu = mu + ρu + xu, αuv ≤ max u(cid:48):u(cid:48)→u where we have used the definition of momentum (8). For part (i), we thus have mv = max u:u→v {mu + ρu + xu − xv}. {αuv − xv} ≤ max u:u→v Now note that if yu ≥ yv we have, recalling equations (3, 4), αuv − xv = yv − yu + αR (10) This justifies the restriction on the right-hand side of (i) to maximization over u s.t. yu < yv. This completes the proof of (i). For part (ii), apply equations (3, 9) to deduce uv − xv ≤ 0. yv = yu + αuv − αR uv ≤ yu + mu + ρu + xu − αR uv, as required. 2 ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 15 To complete the proof of Proposition 9, we need to translate Lemma 12, which gives local bounds on the increase of momentum and height between adjacent vertices, into global bounds in Gα, as specified in Lemma 13 below. The key to this translation will be to apply part (ii) of Lemma 12 to a carefully chosen sequence of edges, for each of which the extra term xu − αR uv in the lemma is non-positive and which together span the heights in the graph; these edges will be identified in Lemma 14 below. For a vertex v, let Sv denote the set of vertices whose height is strictly smaller than v, i.e., Sv = {u : yu < yv}. Also, let ρ(Sv) =(cid:80) u∈Sv ρu. Finally, define (11) This definition has the consequences that zv ≥ 0 and zv := max{xu : yu ≤ yv} − xv. (12) [yu ≤ yv] ⇒ [xu + zu ≤ xv + zv]. We are now ready to state our global bounds. Lemma 13. For any vertex v, the following two bounds hold: (i) mv ≤ ρ(Sv) + zv; (ii) yv − ymin ≤ Sv · ρ(Sv). Proof. Both parts (i) and (ii) are proved by induction on vertices v in order of height. We begin with part (i), which will be used in the proof of part (ii). Part (i). We use induction on the height yv of v. If yv = minu yu, the statement is true since mv ≤ 0 (this follows from part (i) of Lemma 12) and the right-hand side is non-negative. Assuming yv > minu yu, and beginning with part (i) of Lemma 12, we may write mv ≤ max(cid:8)0, max ≤ max(cid:8)0, max ≤ max(cid:8)0, max u:u→v,yu<yv u:u→v,yu<yv u:u→v,yu<yv {mu + ρu + xu − xv}(cid:9) {ρ(Su) + zu + ρu + xu − xv}(cid:9) {ρ(Sv) + zu + xu − xv}(cid:9), where in the second line we applied induction to bound mu since yu < yv, and in the third line we used the fact that u ∈ Sv \ Su to deduce that ρ(Su) + ρu ≤ ρ(Sv). To complete the proof we need only apply Eqn. (12) to conclude that for all u in the last maximization, xu + zu ≤ xv + zv. Part (ii). Again we use induction on the height of v. The base case is yv = ymin, in which case the statement holds trivially. Now let v be any vertex with ymin < yv, and suppose part (ii) is established for all u with yu < yv. Let U be the subset of {u : yu < yv} having xu = xU , where xU = max{xu : yu < yv}. Of course U (cid:54)= ∅, and zu = 0 for all u ∈ U. We require the following additional fact: Lemma 14. There is a vertex u(cid:48) ∈ U having an edge (u(cid:48), v(cid:48)) where v(cid:48) /∈ U, αR u(cid:48)v(cid:48) ≥ xU , yv(cid:48) ≥ yv. 16 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR We defer the proof of Lemma 14 to the end of the subsection and continue with the proof of Lemma 13(ii). Applying part (ii) of Lemma 12 to the edge (u(cid:48), v(cid:48)) provided by Lemma 14, we have yv ≤ yv(cid:48) ≤ yu(cid:48) + mu(cid:48) + ρu(cid:48) + xu(cid:48) − αR u(cid:48)v(cid:48) ≤ yu(cid:48) + mu(cid:48) + ρu(cid:48) ≤ yu(cid:48) + ρ(Su(cid:48)) + zu(cid:48) + ρu(cid:48) = yu(cid:48) + ρ(Su(cid:48)) + ρu(cid:48) ≤ ymin + Su(cid:48)ρ(Su(cid:48)) + ρ(Su(cid:48)) + ρu(cid:48) ≤ ymin + Svρ(Sv). u(cid:48)v(cid:48) ≥ xU ; in the third line we have In the second line here we have used the guarantee of Lemma 14 that αR used part (i) of the current lemma; in the fourth line we have used the fact noted earlier that zu(cid:48) = 0 for any u(cid:48) ∈ U; in the fifth line we have used the inductive hypothesis applied to yu(cid:48) (which is strictly less than yv); and in the last line we have used the fact that u(cid:48) ∈ Sv \ Su(cid:48). This completes the inductive proof of part (ii) of the lemma. 2 Our main goal in this subsection, Proposition 9, now follows trivially from Lemma 13. Proof of Proposition 9. By part (ii) of Lemma 13 we have, for any vertex v, yv − ymin ≤ (n− 1)(cid:80) u ρu. 2 It remains only for us to supply the missing proof of Lemma 14. uw = xU . vu = xU . 2 uw ≥ xU}. u > 0 and then ρL Proof of Lemma 14. The proof will follow from two claims. Claim (i): Every vertex u ∈ U has an outgoing edge (u, w) with αR To state the second claim, define the graph G(cid:48) formed by the set of edges {(u, w) : u ∈ U, αR Claim (ii): There is an edge (u, w) ∈ G(cid:48) such that w /∈ U. Claim (ii) implies the lemma because (u, w) ∈ G(cid:48) implies αR uw ≥ xU ; this last implies also that xw ≥ xU ; and then w cannot have yw < yv as it would then be in U. Proof of Claim (i): Since u ∈ U, we know that yu < 0 and hence some raising must eventually be performed u = 0. But once this happens, the same argument as in the proof at u, i.e., eventually ρR u = 0 at all future times, and hence in αR (at the conclusion of the raising of Proposition 4 shows that ρL phase) we must have ρR u = 0. Thus if (u, w) is a maximum outgoing edge at u in αR, we have u = ρL uw = maxv αR αR Proof of Claim (ii): By Claim (i), every u ∈ U has an outgoing edge in G(cid:48). Suppose for contradiction that w ∈ U for all edges of G(cid:48). Then in G(cid:48) there is a sink scc on vertices U(cid:48) ⊆ U. (U(cid:48) may be as small as a single vertex with a self-loop.) Let δ0 = − maxu(cid:48)∈U(cid:48) yu(cid:48). Note that δ0 > 0. Also, let δ1 = min{αR is empty let δ1 = ∞. Finally, select 0 < δ < min{δ0, δ1}. Now fix any infinite fair sequence of raising operations, and consider the first operation in the sequence that increases any yu, u ∈ U(cid:48), to a value larger than −δ. (This is well defined as all yu, u ∈ U(cid:48) increase monotonically to zero.) Let u(cid:48) be the vertex raised by this operation, and let α be the graph function immediately after the operation and y the height function corresponding to α. By construction there is an edge (t, u(cid:48)) in G(cid:48), with t ∈ U(cid:48). Applying equation (3) to the edge (t, u(cid:48)), we see that (13) where the first inequality is because the edge is in G(cid:48), and the second inequality is by choice of u(cid:48). (Note that equality can hold here only if t = u(cid:48).) tu(cid:48) + yu(cid:48) − yt ≥ xU + yu(cid:48) − yt ≥ xU , rr(cid:48) − αR ss(cid:48) : αR rr(cid:48) − αR ss(cid:48) > 0}; if this set αtu(cid:48) = αR ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 17 Now let (u(cid:48), w) be a maximum (in α) outgoing edge at u(cid:48). Since a nontrivial raising operation has just been performed at u(cid:48), it must be the case that w (cid:54)= u(cid:48). (Raising preserves the order of weights among outgoing edges in α. If a self-loop is a maximal outgoing edge from u(cid:48) in α then it was also maximal before raising. But then there could have been no nontrivial raising at u(cid:48).) Also, since we have just raised at u(cid:48), ρL u(cid:48) = 0, so αu(cid:48)w ≥ αtu(cid:48). Combining with (13) we have (14) Applying equation (3) to the edge (u(cid:48), w) we get αu(cid:48)w ≥ xU . u(cid:48)w = αu(cid:48)w + yu(cid:48) − yw ≥ αu(cid:48)w + yu(cid:48) ≥ αu(cid:48)w − δ ≥ xU − δ, αR where the first inequality is because heights are nonpositive, the second is by the choice of u(cid:48), and the third u(cid:48)w ≥ xU . Hence the edge (u(cid:48), w) belongs is by equation (14). But since δ < δ1 this in fact implies that αR to G(cid:48), and since U(cid:48) is a sink scc it must be the case that w ∈ U(cid:48). But this implies that αR u(cid:48)w ≤ xw = xU , and therefore in fact that αR u(cid:48)w = xU ; and also, by choice of u(cid:48), that yw < yu(cid:48). Hence u(cid:48)w − yu(cid:48) + yw = xU − yu(cid:48) + yw < xU , αu(cid:48)w = αR which in light of (14) gives us the desired contradiction. This completes the proof of Claim (ii) and therefore the lemma. 2 5.4. Proof of Theorem 3. We are now finally in a position to prove our main result, Theorem 3. Proof of Theorem 3. It suffices to show that, with high probability, O(n3 log(ρn/ε)) raising operations suffice to achieve an ε-raising-balanced graph function. As we observed at the beginning of the section, by symmetry the same holds for the lowering phase, and hence the output of the algorithm will be ε-balanced w.h.p. To analyze the raising phase, we index all quantities by t, the number of raising operations that have so far been performed. Thus in particular yv(t) is the height of vertex v after t raising operations. We also introduce v yv(t). Note that Ψ(t) ≥ 0 and that Ψ(t) decreases monotonically to 0 as t → ∞. Moreover, by Proposition 8 we have the potential function Ψ(t) = −(cid:80) Ψ(t) = −(cid:88) v yv(t) ≥ h(t) ≥ ρR(t)/2. Hence in order to achieve raising imbalance at most ε after t raising steps it suffices to ensure that Ψ(t) ≤ ε/2. Since a raising operation at vertex v increases yv by ρR operation is v /2, the expected decrease in Ψ(t) in one raising E[Ψ(t) − Ψ(t + 1)] = 1 2n v (t) ≥ ρR h(t) 2n(n − 1) = −ymin(t) 2n(n − 1) ≥ 1 2n3 Ψ(t), (cid:88) v where in the first inequality we have used Proposition 9, in the next step Corollary 11, and in the last inequality the fact that ymin is less than the average of the yv. Iterating for t steps yields E[Ψ(t)] ≤(cid:16) (cid:17)t 1 − 1 2n3 Ψ(0). To get an upper bound on Ψ(0), we observe that Ψ(0) = −(cid:88) (cid:88) yv(0) ≤ −nymin(0) = nh(0) ≤ n(n − 1) v (0) ≤ n3ρR(0) ≤ n3ρ, ρR v v LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR 18 where we have again used Corollary 11 and Proposition 9. (Recall that ρ = max{ρR(0), ρL(0)} is the imbalance of the original matrix.) Hence, for any δ ∈ (0, 1), after t = 6n3 ln(2ρn/εδ) raising operations we have By Markov's inequality this implies that Ψ(t) ≤ ε/2 with probability at least 1 − δ. To obtain the result w.h.p., it suffices to take δ = o(1). 2 E[Ψ(t)] ≤ εδ/2. 6. OPEN PROBLEMS We close the paper with some remarks and open problems. 1. The introduction of raising and lowering phases into the Osborne-Parlett-Reinsch algorithm is trivial from an implementation perspective (the effect being simply to censor some of the balancing operations), but seemingly crucial to our analysis. If balancing operations of both types are interleaved, we no longer have a reliable measure of progress. It would be interesting to modify the analysis so as to handle an arbitrary sequence of balancing operations, and on the other hand to investigate whether the introduction of phases actually improves the rate of convergence (both in theory and in practice). Similarly, it would be interesting to investigate the effect of choosing a random sequence of indices at which to perform balancing, rather than a deterministic sequence as in the original algorithm. 2. Recall that, without raising and lowering phases, the balanced matrix to which the algorithm converges is not unique (except, by definition, in the UB case). It would be interesting to investigate the geometric structure of the set of fixed points, which apparently can be rather complicated. 3. As we have seen, our (cid:101)O(n3) bound on the worst case convergence time is essentially optimal. While this goes some way towards explaining the excellent performance of the algorithm in practice, more work needs to be done to explain its empirical dominance over algorithms with faster worst-case asymptotic running times. In particular, can one identify features of "typical" matrices that lead to much faster convergence? 4. We have analyzed only the L∞ variant of the Osborne-Parlett-Reinsch algorithm. It would be interesting to analyze the algorithm for other norms Lp, in particular L2 and L1. (In the latter case, the problem corre- sponds to finding a circulation -- in the sense of network flows -- that is equivalent to the initial assignment of flows to the edges of the graph.) 7. ACKNOWLEDGEMENTS We thank Tzu-Yi Chen and Jim Demmel for introducing us to this problem and for several helpful pointers, Martin Dyer for useful discussions, and Yuval Rabani for help in the early stages of this work which led to the proof of Theorem 1. We also thank anonymous referees of an earlier version for suggestions that improved the presentation of the paper. REFERENCES [1] S. Boyd, L. El Ghaoui, E. Feron, and V. Balakrishnan. Linear Matrix Inequalities in System and Control Theory. SIAM Studies in Applied Mathematics Vol. 15, 1994. [2] T.-Y. Chen. Balancing sparse matrices for computing eigenvalues. Master's thesis, UC Berkeley, May 1998. [3] T.-Y. Chen and J. Demmel. Balancing sparse matrices for computing eigenvalues. Linear Algebra and its Applications, 309:261 -- 287, 2000. [4] B. C. Eaves, A. J. Hoffman, U. G. Rothblum, and H. Schneider. Line-sum-symmetric scalings of square non-negative matrices. Math. Programm. Study, 25:124 -- 141, 1985. [5] J. Franklin and J. Lorenz. On the scaling of multidimensional matrices. Linear and Multilinear Algebra, 23:717 -- 735, 1989. [6] J. Grad. Matrix balancing. The Computer Journal, 14:280 -- 284, 1971. [7] D. J. Hartfiel. Concerning diagonal similarity of irreducible matrices. Proceedings of the American Mathematical Society, 30:419 -- 425, 1971. ANALYSIS OF A CLASSICAL MATRIX PRECONDITIONING ALGORITHM 19 [8] B. Kalantari and L. Khachiyan. On the rate of convergence of deterministic and randomized RAS matrix scaling algorithms. Operations Research Letters, 14:237 -- 244, 1993. [9] B. Kalantari and L. Khachiyan. On the complexity of nonnegative matrix scaling. Linear Algebra and its Applications, 240:87 -- 104, 1996. [10] B. Kalantari, L. Khachiyan, and A. Shokoufandeh. On the complexity of matrix balancing. SIAM Journal on Matrix Analysis and Applications, 18:450 -- 463, 1997. [11] B. Kalantari, I. Lari, F. Ricca, and B. Simeone. On the complexity of general matrix scaling and entropy minimization via the RAS algorithm. Mathematical Programming, 112(2):371 -- 401, 2008. [12] D. Kressner. Numerical Methods for General and Structured Eigenvalue Problems. Springer, 2005. [13] N. Linial, A. Samorodnitsky, and A. Wigderson. A deterministic strongly polynomial algorithm for matrix scaling and ap- proximate permanents. Combinatorica, 20:531 -- 544, 2000. [14] E. E. Osborne. On pre-conditioning of matrices. Journal of the ACM, 7(4):338 -- 345, 1960. [15] B. N. Parlett and C. Reinsch. Balancing a matrix for calculation of eigenvalues and eigenvectors. Numerische Mathematik, 13:293 -- 304, 1969. [16] H. Schneider and M. H. Schneider. Max-balancing weighted directed graphs and matrix scaling. Mathematics of Operations Research, 16(1):208 -- 222, 1991. [17] L. J. Schulman and A. Sinclair. Analysis of a classical matrix preconditioning algorithm. Proceedings of the 47th Annual ACM Symposium on Theory of Computing (STOC), 2015. [18] R. Sinkhorn. A relationship between arbitrary positive matrices and doubly stochastic matrices. Annals of Mathematical Statistics, 35:876 -- 879, 1979. [19] T. Strom. Minimization of norms and logarithmic norms by diagonal similarities. Computing, 10:1 -- 7, 1972. [20] L. N. Trefethen and M. Embree. Spectra and Pseudospectra: The Behavior of Nonnormal Matrices and Operators. Princeton University Press, 2005. [21] N. Young, R. E. Tarjan, and J. B. Orlin. Faster parametric shortest path and minimum balance algorithms. Networks, 21:205 -- 221, 1991. APPENDIX A. PROOF OF CONVERGENCE In this section we present an alternative proof of convergence of the original Osborne-Parlett-Reinsch L∞ balancing algorithm. As remarked earlier this was first proved by Chen [2] using a compactness argument. In the interests of making the present paper self-contained, we give here an alternative proof that is more combinatorial in nature. For this proof only, we explicitly allow more general sequences of balancing operations, subject only to the "fairness" constraint that every index i appears infinitely often. (Clearly, the random sequence discussed in the main text has this property with probability 1.) Note, however, that this proof does not apply to the two-phase version of the algorithm which we analyze in this paper because the sequence of balancing operations in that version is not fair. We prove convergence of the two-phase version in Section 4. Theorem 15. Consider the Osborne-Parlett-Reinsch L∞ balancing algorithm applied to any irreducible (real or complex) input matrix A, and assume that balancing operations are performed infinitely often at all indices i. Then the algorithm converges, i.e., if A(t) is the sequence of matrices after each step of the algorithm, then there exists a balanced matrix B equivalent to A such that A(t) → B as t → ∞. Proof. We work in the framework of Section 2, representing A as a graph Gα with an associated graph function α, where αuv = log auv (and edges (u, v) with auv = 0 are omitted). We let αin v denote v }. the maximum incoming and outgoing edge weights at vertex v in Gα; we also set αmax v , αout The key ingredient in the proof is the following partial order on graph functions defined on a common strongly-connected graph G. For two such graph functions α, γ, we say that α < γ if, for the largest weight w such that Gw Now, if a decreasing sequence α(t) of graph functions in this order has the property that all values α(t) uv in the functions are bounded below by a common value b, it is clear that the sequence has a limit. The convergence of the iterative balancing algorithm will therefore follow from the next two lemmas. Call a balancing operation at i non-trivial if αin v , so that the operation actually changes the weights. By definition α is balanced iff no non-trivial balancing operation is available. v and αout v = max{αin v (cid:54)= αout α (cid:54)= Gw γ , we have Gw α ⊂ Gw γ . 20 LEONARD J. SCHULMAN AND ALISTAIR SINCLAIR Lemma 16. Non-trivial balancing operations are strictly decreasing in the above order on graph functions. v < αmax v Proof. Let α be the current graph function, and let v be a vertex at which a non-trivial balancing operation is v /2, performed. Let ¯α denote the new graph function after the operation. We have ¯αmax and ¯αmax . The balancing operation affects only edges incident at v. Before the balancing, at least one of those edges belongs to Gαmax . After the balancing, none of those edges belong to Gαmax ¯α differ is w = αmax , and ¯α ⊂ Gαmax Gαmax Lemma 17. Given any graph function α, there is a b > −∞ such that no sequence of balancing operations can create an edge of weight less than b. α . Thus the largest value of w for which Gw , while none belong to Gw α for any w > αmax v = αmax v −¯αin v − ¯αout α and Gw v α v v v v v α . 2 Proof. A balancing operation at vertex v reduces αmax , so no such operation can increase the maximum edge value above its original value in Gα, say m1. Let w1 be the least average weight of any cycle in Gα; note that w1 remains invariant under any sequence of balancing operations. Consider the value of any edge (u, v) under any graph function α(cid:48) that is reached by balancing operations from α. Let (u, v) belong to uv + ((cid:96) − 1)m1)/(cid:96) ≥ w2 ≥ w1, so some (simple) cycle of average weight w2 and length (cid:96). Then (α(cid:48) uv ≥ w1 − ((cid:96) − 1)(m1 − w1) ≥ w1 − (n − 1)(m1 − w1). This completes the proof of the lemma and the α(cid:48) theorem. 2 v
1207.2341
1
1207
2012-07-10T13:32:12
I/O-Efficient Dynamic Planar Range Skyline Queries
[ "cs.DS" ]
We present the first fully dynamic worst case I/O-efficient data structures that support planar orthogonal \textit{3-sided range skyline reporting queries} in $\bigO (\log_{2B^\epsilon} n + \frac{t}{B^{1-\epsilon}})$ I/Os and updates in $\bigO (\log_{2B^\epsilon} n)$ I/Os, using $\bigO (\frac{n}{B^{1-\epsilon}})$ blocks of space, for $n$ input planar points, $t$ reported points, and parameter $0 \leq \epsilon \leq 1$. We obtain the result by extending Sundar's priority queues with attrition to support the operations \textsc{DeleteMin} and \textsc{CatenateAndAttrite} in $\bigO (1)$ worst case I/Os, and in $\bigO(1/B)$ amortized I/Os given that a constant number of blocks is already loaded in main memory. Finally, we show that any pointer-based static data structure that supports \textit{dominated maxima reporting queries}, namely the difficult special case of 4-sided skyline queries, in $\bigO(\log^{\bigO(1)}n +t)$ worst case time must occupy $\Omega(n \frac{\log n}{\log \log n})$ space, by adapting a similar lower bounding argument for planar 4-sided range reporting queries.
cs.DS
cs
I/O-Efficient Dynamic Planar Range Skyline Queries Casper Kejlberg-Rasmussen MADALGO∗ Department of Computer Science Aarhus University, Denmark [email protected] Konstantinos Tsakalidis Computer Engineering and Informatics Department University of Patras, Greece [email protected] Kostas Tsichlas Computer Science Department Aristotle University of Thessaloniki, Greece [email protected] Abstract We present the first fully dynamic worst case I/O-efficient data structures that support planar orthogonal 3-sided range skyline reporting queries in O(log2B n+ t B1− ) I/Os and updates in O(log2B n) I/Os, using B1− ) blocks of space, for n input planar points, t reported points, and parameter 0 ≤  ≤ 1. We obtain O( n the result by extending Sundar's priority queues with attrition to support the operations DeleteMin and CatenateAndAttrite in O(1) worst case I/Os, and in O(1/B) amortized I/Os given that a constant number of blocks is already loaded in main memory. Finally, we show that any pointer-based static data structure that supports dominated maxima reporting queries, namely the difficult special case of 4-sided skyline queries, in O(logO(1) n+t) worst case time must occupy Ω(n log n log log n ) space, by adapting a similar lower bounding argument for planar 4-sided range reporting queries. 1 Introduction We study the problem of maintaining a set of planar points in external memory subject to insertions and deletions of points in order to support planar orthogonal 3-sided range skyline reporting queries efficiently in the worst case. For two points p, q ∈ Rd, we say that p dominates q, if and only if all the coordinates of p are greater than those of q. The skyline of a pointset P consists of the maximal points of P , which are the points in P that are not dominated by any other point in P . Planar 3-sided range skyline reporting queries that report the maximal points among the points that lie Skyline computation has been receiving increasing attention in the field of databases since the introduction of the skyline operator for SQL [3]. Skyline points correspond to the"interesting" entries of a relational database as they are optimal simultaneously over all attributes. The considered variant of planar skyline queries adds the capability of reporting the interesting entries among those input entries whose attribute values belong to a given 3-sided range. Databases used in practical applications usually process massive amounts of data in dynamic environments, where the data can be modified by update operations. Therefore we analyze our algorithms in the I/O model [1], which is commonly used to capture the complexity of massive data computation. It assumes that the input data resides in the disk (external memory) divided in blocks of B consecutive words, and that computation occurs for free in the internal memory of size M words. An I/O-operation (I/O) reads a block of data from the disk into the internal memory, or writes a block of data ∗Center for Massive Data Algorithmics - a Center of the Danish National Research Foundation 1 to the disk. Time complexity is expressed in number of I/Os, and space complexity in the number of blocks that the input data occupies on the disk. log log n + t) worst case time, and updates in O(log n) and O( log n Previous Results Different approaches have been proposed for maintaining the d-dimensional skyline in external memory under update operations, assuming for example offline updates over data streams [19, 13], only online deletions [20], online average case updates [16], arbitrary online updates [8] and online updates over moving input points [9]. The efficiency of all previous approaches is measured experimentally in terms of disk usage over average case data. However, even for the planar case, no I/O-efficient structure exists that supports both arbitrary insertions and deletions in sublinear worst case I/Os. Regarding internal memory, Brodal and Tsakalidis [4] present two linear space dynamic data structures that support 3-sided range skyline reporting queries in O(log n + t) and O( log n log log n ) worst case time in the pointer machine and the RAM model, respectively, where n is the input size and t is the output size. They also present an O(n log n) space dynamic pointer-based data structure that supports 4-sided range skyline reporting queries in O(log2 n + t) worst case time and updates in O(log2 n) worst case time. Adapting these structures to the I/O model attains O(log n + t) query I/Os, which is undesired since O(1) I/Os are spent per reported point. computes the skyline of a static d-dimensional pointset in O( n adapting the internal memory algorithms of [12, 2] to external memory. O( n for the planar case. There exist two O(n log n) and O(n log n planar 4-sided range skyline reporting queries in O(log n + t) and O( log n pointer machine and the RAM, respectively [10, 7]. B ) worst case I/Os, for d ≥ 3, by n B ) I/Os can be achieved log log n ) space static data structures that support log log n + t) worst case time, for the Regarding the static variant of the problem, Sheng and Tao [17] obtain an I/O-efficient algorithm that B log M B O(1) B B logd−2 M B n In Section 4 we present our main result, namely I/O-efficient dynamic data structures that support 3- B1− ) worst case I/Os and updates in O(log2B n) worst B1− ) blocks, for a parameter 0 ≤  ≤ 1. These are the first fully dynamic skyline data Our Results In Section 3 we present the basic building block of the structures for dynamic planar range skyline reporting queries that we present in Section 4. That is pointer-based I/O-efficient catenable priority queues with attrition (I/O-CPQAs) that support the operations DeleteMin and CatenateAndAttrite in O(1/B) amortized I/Os and in O(1) worst case I/Os, using O( n−m B ) disk blocks, after n calls to Catenate- AndAttrite and m calls to DeleteMin. The result is obtained by modifying appropriately a proposed implementation for priority queues with attrition of Sundar [18]. sided range skyline reporting queries in O(log2B n+ t case I/Os, using O( n structures for external memory that support all operations in polylogarithmic worst case time. The results are obtained by following the approach of Overmars and van Leeuwen [14] for planar skyline maintainance and utilizing confluently persistent I/O-CPQAs (implemented with functional catenable deques [11]). Applying the same methodology to internal memory pointer-based CPQAs yields alternative implementations for dynamic 3-sided reporting in the pointer machine in the same bounds as in [4]. Finally, in Section 5 we prove that any pointer-based static data structure that supports reporting the maximal points among the points that are dominated by a given query point in O(log O(1) n) worst case time must occupy Ω(n log n log log n ) space, by adapting the similar lower bounding argument of Chazelle [5] for planar 4-sided range reporting queries to the considered dominated skyline reporting queries. These queries are termed as dominating minima reporting queries. The symmetric case of dominated maxima reporting queries is equivalent and comprises a special case of rectangular visibilty queries [15] and 4-sided range skyline reporting queries [4, 10]. The result shows that the space usage of the pointer-based structures in [15, 4, 10] is optimal within a O(log log n) factor, for the attained query time. 2 Preliminaries Priority Queues with Attrition Sundar [18] introduces pointer-based priority queues with attrition (PQAs) that support the following operations in O(1) worst case time on a set of elements drawn from a total 2 order: DeleteMin deletes and returns the minimum element from the PQA, and InsertAndAttrite(e) inserts element e into the PQA and removes all elements larger than e from the PQA. PQAs use space linear to the number of inserted elements minus the number of elements removed by DeleteMin. Functional Catenable Deques A dynamic data structure is persistent when it maintains its previous It is fully persistent when it permits accessing and versions as update operations are performed on it. updating the previous versions. In turn, it is called confluently persistent when it is fully persistent, and moreover it allows for two versions to be combined into a new version, by use of an update operation that merges the two versions. In this case, the versions form a directed acyclic version graph. A catenable deque is a list that stores a set of elements from a total order, and supports the operations Push and Inject that insert an element to the head and tail of the list respectively, Pop and Eject that remove the element from the head and tail of the list respectively, and Catenate that concatenates two lists into one. Kaplan and Tarjan [11] present purely functional catenable deques that are confluently persistent and support the above operations in O(1) worst case time. Searching Lower Bound in the Pointer Machine In the pointer machine model a data structure that stores a data set S and supports range reporting queries for a query set Q, can be modelled as a directed graph G of bounded out-degree. In particular, every node in G may be assigned an element of S or may contain some other useful information. For a query range Qi ∈ Q, the algorithm navigates over the edges of G in order to locate all nodes that contain the answer to the query. The algorithm may also traverse other nodes. The time complexity of reporting the output of Qi is at least equal to the number of nodes accessed in graph G for Qi. To prove a lower bound we need to construct hard instances with particular properties, as discussed by Chazelle and Liu [5, 6]. In particular, they define the graph G to be (α, ω)-effective, if a query is supported in α(t + ω) time, where t is the output size, α is a multiplicative factor for the output size (α = O(1) for our purposes) and ω is the additive factor. They also define a query set Q to be (m, ω)- favorable for a data set S, if S ∩ Qi ≥ ω,∀Qi ∈ Q and S ∩ Qi1 ∩ ··· ∩ Qim = O(1),∀i1 < i2 ··· < im. Intuitively, the first part of this property requires that the size of the output is large enough (at least ω) so that it dominates the additive factor of ω in the time complexity. The second part requires that the query outputs have minimum overlap, in order to force G to be large without many nodes containing the output of many queries. The following lemma exploits these properties to provide a lower bound on the minimum size of G. Lemma 2.1. [6, Lemma 2.3] For an (m, ω)-favorable graph G for the data set S, and for an (α, ω)-effective set of queries Q, G contains Ω(Qω/m) nodes, for constant α and for any large enough ω. 3 I/O-Efficient Catenable Priority Queues with Attrition In this Section, we present I/O-efficient catenable priority queues with attrition (I/O-CPQAs) that store a set of elements from a total order in external memory, and support the following operations: FindMin(Q) returns the minimum element in I/O-CPQA Q. DeleteMin(Q) removes the minimum element e from I/O-CPQA Q and returns element e and the new I/O-CPQA Q(cid:48) = Q\{e}. CatenateAndAttrite(Q1, Q2) concatenates I/O-CPQA Q2 to the end of I/O-CPQA Q1, removes all elements in Q1 that are larger than the minimum element in Q2, and returns a new I/O-CPQA 1 = {e ∈ Q1e < min(Q2)} ∪ Q2. We say that the removed elements have been attrited. Q(cid:48) InsertAndAttrite(Q, e) inserts element e at the end of Q and attrites all elements in Q that are larger than the value of e. 3 All operations take O(1) worst case I/Os and O(1/b) amortized I/Os, given that a constant number of blocks is already loaded into main memory, for a parameter 1 ≤ b ≤ B. To achieve the result, we modify an implementation for the PQAs of Sundar [18]. An I/O-CPQA Q consists of kQ +2 deques of records, called the clean deque C(Q), the buffer deque B(Q) and the dirty deques D1(Q), . . . , DkQ (Q), where kQ ≥ 0. A record r = (l, p) consists of a buffer l of [b, 4b] elements of strictly increasing value and a pointer p to an I/O-CPQA. The ordering of r is; first all elements of l and then all elements of the I/O-CPQA pointed to by p. We define the queue order of Q to be C(Q), B(Q) and D1(Q), . . . , DkQ(Q). A record is simple when its pointer p is null. The clean deque and the buffer deque only contains simple records. See Figure 1 for an overview of the structure. DkQ−1(Q) DkQ(Q) D1(Q) C(Q) B(Q) . . . . . . . . . . . . . . . . . . Figure 1: A I/O CPQA Q consists of kQ +2 deques of records; C(Q), B(Q), D1(Q), . . . , DkQ (Q). The records in C(Q) and B(Q) are simple, the records of D1(Q), . . . , DkQ(Q) may contain pointers to other I/O CPQA's. Gray recordsare always loaded in memory. Given a record r = (l, p) the minimum and maximum elements in the buffers of r, are denoted by min(r) = min(l) and max(r) = max(l), respectively. They appear respectively first and last in the queue order of l, since the buffer of r is sorted by value. Henceforth, we do not distinguish between an element and its value. Given a deque q the first and the last record is denoted by first(q) and last(q), respectively. Also rest(q) denotes all records of the deque q excluding the record first(q). Similarly, front(q) denotes all records for the deque q excluding the record last(q). The size r of a record r is defined to be the number of elements in its buffer. The size q of a deque q is defined to be the number of records it contains. The size Q of the I/O-CPQA Q is defined to be the number of elements that Q contains. For an I/O-CPQA Q we denote by first(Q) and last(Q), the first and last of the records in C(Q), B(Q), D1(Q), . . . , DkQ (Q) that exists, respectively. By middle(Q) we denote all records in Q and the records in the I/O-CPQAs pointed by Q, except for records first(Q) and last(Q) and the I/O-CPQAs they point to. We call an I/O-CPQA Q large if Q ≥ b and small otherwise. The minimum value of all elements stored in the I/O-CPQA Q is denote by min(Q). For an I/O-CPQA Q we maintain the following invariants: I.1) For every record r = (l, p) where pointer p points to I/O-CPQA Q(cid:48), max(l) < min(Q(cid:48)) holds. I.2) In all deques of Q, where record r1 = (l1, p1) precedes record r2 = (l2, p2), max(l1) < min(l2) holds. I.3) For the deques C(Q), B(Q) and D1(Q), max(last(C(Q))) < min(first(B(Q))) < min(first(D1(Q))) holds. I.4) Element min(first(D1(Q))) has the minimum value among all the elements in the dirty deques D1(Q), . . . , Dk(Q). I.5) All records in the deques C(Q) and B(Q) are simple. I.6) C(Q) ≥(cid:80)kQ i=1 Di(Q) + kQ − 1. I.7) first(C(Q)) < b holds, if and only if Q < b holds. I.8) last(DkQ(Q)) < b holds, if and only if record last(DkQ(Q)) is simple. In this case r ∈ [b, 5b] holds. of invariant I.6 for I/O-CPQA Q, when the operation increases or decreases ∆(Q) = C(Q)−(cid:80)kQ From Invariants I.2, I.3 and I.4, we have that the minimum element min(Q) stored in the I/O-CPQA Q is element min(first(C(Q))). We say that an operation improves or aggravates by a parameter c the inequality i=1 Di(Q)− kQ + 1 by c, respectively. To argue about the O(1/b) amortized I/O bounds we define the following potential 4 functions for large and small I/O-CPQAs. defined as In particular, for large I/O-CPQAs Q, the potential Φ(Q) is Φ(Q) = ΦF (first(Q)) + middle(Q) + ΦL(last(Q)), where ΦF (x) =  3 − x 2x b , b ≤ x < 2b 2b ≤ x < 3b 1, b − 5, 3b ≤ x ≤ 4b (cid:26) and ΦL(x) = 0, 0 ≤ x < 4b b − 12, 4b ≤ x ≤ 5b 3x For small I/O-CPQAs Q, the potential Φ(Q) is defined as 3Q b Φ(Q) = The total potential ΦT is defined as ΦT = (cid:88) Q (cid:88) Qb≤Q Φ(Q) + 1, where the first sum is over all I/O-CPQAs Q and the second sum is only over all large I/O-CPQAs Q. 3.1 Operations In the following, we describe the algorithms that implement the operations supported by the I/O-CPQA Q. The operations call the auxiliary operation Bias(Q), which will be described last, that improves the inequality of invariant I.6 for Q by at least 1. All operations take O(1) worst case I/Os. We also show that every operation takes O(1/b) amortized I/Os, where 1 ≤ b ≤ B. FindMin(Q) returns the value min(first(C(Q))). DeleteMin(Q) removes element e = min(first(C(Q))) from record (l, p) = first(C(Q)). After the removal, if l < b and Q ≥ b hold, we do the following. If b ≤ first(rest(C(Q))) ≤ 2b, then we merge first(C(Q)) with first(rest(C(Q))) into one record which is the new first record. Else if 2b < first(rest(C(Q))) ≤ 3b then we take b elements out of first(rest(C(Q))) and put them into first(C(Q)). Else we have that 3b < first(rest(C(Q))), and as a result we take 2b elements out of first(rest(C(Q))) and put them into first(C(Q)). If the inequality for Q is aggravated by 1 we call Bias(Q) once. Finally, element e is returned. Amortization: Only if the size of first(C(Q)) becomes first(C(Q)) = b − 1 do we incur any I/Os. In this case r = first(Q) has a potential of ΦF (r) = 2, and since we increase the number of elements in r by b to 2b elements, the potential of r will then only be ΦF (r) = 1. Thus, the total potential decreases by 1, which also pays for any I/Os including those incurred if Bias(Q) is invoked. 1) and Bias(Q2). 1 be the non-attrited elements of l1. We perform the prepend as follows. If l(cid:48) 1 into l2. Else, we take 2b − l(cid:48) concatenates Q2 to the end of Q1 and removes the elements from Q1 with CatenateAndAttrite(Q1, Q2) value larger than min(Q2). To do so, it creates a new I/O-CPQA Q(cid:48) 1 by modifying Q1 and Q2, and by calling Bias(Q(cid:48) If Q1 < b, then Q1 is only one record (l1,·), and so we prepend it into the first record (l2,·) = first(Q2) 1 + l2 ≤ 4b, then of Q2. Let l(cid:48) we prepend l(cid:48) 1 the new first record of Q2. 1 into l2, then the potential ΦS(l1) pays for the increase in potential Amortization: If we simply prepend l(cid:48) of ΦF (first(C(Q2))). Else, we take 2b−l(cid:48) 1 become the new first record of Q2 of size 2b. Thus, ΦF (2b) = 1 and the potential drops by 1, which is enough to pay for the I/Os used to flush the old first record of C(Q2) to disk. If Q2 < b, then Q2 only consists of one record. We have two cases, depending on how much of Q1 is attrited by Q2. Let r1 be the second last record for Q1 and let r2 = last(Q1) be the last record. If e attrites all of 1 elements out of l2, and these elements along with l(cid:48) 1 elements out of l2, and make them along with l(cid:48) 5 r1, then we just pick the appropriate case among (1 -- 4) below. Else if e attrites partially r1, but not all of it, then we delete r2 and we merge r1 and Q2 into the new last record of Q1, which cannot be larger than 5b. Otherwise if e attrites partially r2, but not all of it, then we simply append the single record of Q2 into r2, which will be the new last record of Q1 and it cannot be larger than 5b. Amortization: If e attrites all of r1, then we release at least 1 in potential, so all costs in any of the cases (1 -- 4) are paid for. If e attrites partially r1, then the new record cannot contain more than 5b elements, and thus any increase in potential is paid for by the potential of Q2. Thus, the I/O cost is covered by the decrease of 1 in potential, caused by r1. If e attrites partially r2, any increase in potential is paid for by the potential of Q2. We have now dealt with the case where Q1 is a small queue, so in the following we assume that Q1 is large. Let e = min(Q2). 1) If e ≤ min(first(C(Q1))), we discard I/O-CPQA Q1 and set Q(cid:48) 2) Else if e ≤ max(last(C(Q1))), we remove the simple record (l,·) = first(C(Q2)) from C(Q2), we set 1) = (l, p), where p points to Q2, if it exists. This aggravates the 1) once. 3) Else if e ≤ min(first(B(Q1))) or e ≤ min(first(D1(Q1))) holds, we remove the simple record (l,·) = 1) = (l, p), and make p point to Q2, if it exists. If e ≤ min(first(B(Q1))), 1) = ∅. This aggravates the inequality for Q2 by at most 1, and aggravates the inequality first(C(Q2)) from C(Q2), set D1(Q(cid:48) we set B(Q(cid:48) for Q1 by at most 1. Thus, we call Bias(Q2) once and Bias(Q(cid:48) 1) = −1. Thus, we call Bias(Q2) once and Bias(Q(cid:48) 1 = Q2. 1) = ∅, B(Q(cid:48) C(Q(cid:48) inequality for Q2 by at most 1, and gives ∆(Q(cid:48) 1) = C(Q1) and D1(Q(cid:48) 1) once. 4) Else, let (l1,·) = last(DkQ1 ). We remove (l2,·) = first(C(Q2)) from C(Q2). If l1 < b, then remove the record (l1,·) from DkQ1 . Let l(cid:48) 1 be the non-attrited elements under attrition by e = min(l2). If l(cid:48) 1 + l2 ≤ 4b, then we prepend l(cid:48) 1 into l2 of record r2 = (l2, p2), where p2 points to Q2. Otherwise. we make a new simple record r1 with l(cid:48) 1 and 2b elements taken out of r2 = (l2, p2). Finally, we put the resulting one or two records r1 and r2 into a new deque DkQ1 +1(Q1). This aggravates the inequality for Q2 by at most 1, and the inequality for Q1 by at most 2. Thus, we call Bias(Q2) once and Bias(Q(cid:48) 1) twice. Amortization: In all the cases (1 -- 4) both Q1 and Q2 are large, hence when we concatenate them we decrease the potential by at least 1, as the number of large I/O-CPQA's decrease by one which is enough to pay for any Bias operations. InsertAndAttrite(Q, e) inserts an element e into I/O-CPQA Q and attrites the elements in Q with value larger than e. This is a special case of operation CatenateAndAttrite(Q1,Q2), where Q1 = Q and Q2 is an I/O-CPQA that only contains one record with the single element e. Amortization: Since creating a new I/O-CPQA with only one element and calling CatenateAndAttrite only costs O(1/b) I/Os amortized, the operation InsertAndAttrite also costs O(1/b) I/Os amortized. C(Q) . . . D1(Q) . . . C(Q(cid:48)) . . . B(Q(cid:48)) . . . D1(Q(cid:48)) . . . DkQ(cid:48) (Q(cid:48)) . . . . . . Figure 2: In the case of Bias(Q), where B(Q) = ∅ and kQ = 1, we need to follow the pointer p of (l, p) = first(D1(Q)) that may point to an I/O-CPQA Q(cid:48). If so, we merge it into Q, taking into account attrition of Q(cid:48) by e = min(first(D1(Q))). 6 improves the inequality in I.6 for Q by at least 1. Bias(Q) Amortization: Since all I/Os incurred by Bias(Q) are already paid for by the operation that called Bias(Q), we only need to argue that the potential of Q does not increase due to the changes that Bias(Q) makes to Q. 1) B(Q) > 0: We remove the first record first(B(Q)) = (l1,·) from B(Q) and let (l2, p2) = first(D1(Q)). Let l(cid:48) 1) 0 ≤ l(cid:48) 1 be the non-attrited elements of l1 under attrition from e = min(l2). 1 < b: If l2 ≤ 2b, then we just prepend l(cid:48) append them to l(cid:48) 1. 1 < 2b: If l2 ≤ 2b, and if furthermore l(cid:48) 1 + l2 > 3b holds, so we take 2b elements out of l(cid:48) 2) b ≤ l(cid:48) Else l(cid:48) rest in l2. Else l2 > 2b holds, so we take b elements out of l2 and put them into l(cid:48) 1. 1 onto l2. Else, we take b elements out of l2 and 1 + l2 ≤ 3b holds, then we merge l(cid:48) 1 and l2 and put them into l(cid:48) 1 and l2. 1, leaving the 1 onto l2, we insert l(cid:48) 1 < l1, we set B(Q) = ∅. Else, we did prepend l(cid:48) If we did not prepend l(cid:48) 1 along with any elements taken out of l2 at the end of C(Q) instead. If l(cid:48) 1 onto l2, and then we just recursively call Bias. Since B(Q) = 0 we will not end up in this case again. As a result, in all cases the inequality of Q is improved by 1. Amortization: If l1 = first(Q), then after calling Bias we ensure that 2b ≤ first(Q) ≤ 3b, and so the that potential of Q does not increase. 2) B(Q) = 0: When B(Q) = 0 holds, we have two cases depending on the number of dirty queues, namely cases kQ > 1 and kQ = 1. 1) kQ > 1: Let e = min(first(DkQ(Q))). If e ≤ min(last(DkQ−1(Q))) holds, we remove the record last(DkQ−1(Q)) from DkQ−1(Q). This improves the inequality of Q by 1. Else, if min(last(DkQ−1(Q))) < e ≤ max(last(DkQ−1(Q))) holds, we remove record r1 = (l1, p1) = last(DkQ−1(Q)) from DkQ−1(Q) and let r2 = (l2, p2) = first(DkQ(Q)). We delete any elements in l1 that are attrited by e, and let l(cid:48) 1) 0 ≤ l(cid:48) 2) If b ≤ l(cid:48) 1 < b: If l2 ≤ 2b, then we just prepend l(cid:48) 1 < 2b: If l2 ≤ 2b and l(cid:48) so we take 2b elements out of l(cid:48) Else l2 > 2b, so we take b elements out of l2 and put them into l(cid:48) 1. 1 onto l2. Otherwise, we take b elements out of l2 1 + l2 > 3b holds, 1 + l2 ≤ 3b, then we merge l(cid:48) 1 and l2 and put them into l(cid:48) and append them to l(cid:48) 1. 1 denote the non-attrited elements. 1 and l2. Else, l(cid:48) 1, leaving the rest in l2. If r1 still exists, we insert it in the front of DkQ(Q). Finally, we concatenate DkQ−1(Q) and DkQ(Q) into one deque. This improves the inequality of Q by at least 1. Else max(last(DkQ−1(Q))) < e holds, and we just concatenate the deques DkQ−1(Q) and DkQ (Q), which improves the inequality for Q by 1. Amortization: If not all of l1 is attrited then we ensure that its record r1 has size between 2b and 3b. Thus, if r1 = first(Q) holds, we will not have increased the potential of Q. In the cases where all or none of l1 is attrited, the potential of Q can only be decreased by at least 0. 2) kQ = 1: In this case Q contains only deques C(Q) and D1(Q). We remove the record r = (l, p) = first(D1(Q)) and insert l into a new record at the end of C(Q). This improves the inequality of Q by at least 1. If r is not simple, let r's pointer p point to I/O-CPQA Q(cid:48). We restore I.5 for Q by merging I/O-CPQAs Q and Q(cid:48) into one I/O-CPQA. See Figure 2 for this case of operation Bias. In particular, let e = min(first(D1(Q))), we now proceed as follows: If e ≤ min(Q(cid:48)), we discard Q(cid:48). The inequality for Q remains unaffected. Else, if min(first(C(Q(cid:48)))) < e ≤ max(last(C(Q(cid:48))), we set B(Q) = C(Q(cid:48)) and discard the rest of Q(cid:48). The inequality for Q remains unaffected. 7 Else if max(last(C(Q(cid:48))) < e ≤ min(first(D1(Q(cid:48)))), we concatenate the deque C(Q(cid:48)) at the end of C(Q). If moreover min(first(B(Q(cid:48)))) < e holds, we set B(Q) = B(Q(cid:48)). Finally, we discard the rest of Q(cid:48). This improves the inequality for Q by C(Q(cid:48)). Else min(first(D1(Q(cid:48)))) < e holds. We concatenate the deque C(Q(cid:48)) at the end of C(Q), we set B(Q) = B(Q(cid:48)), we set D1(Q(cid:48)), . . . , DkQ(cid:48) (Q(cid:48)) as the first kQ(cid:48) dirty queues of Q and we set D1(Q) as the last dirty queue of Q. This improves the inequality for Q by ∆(Q(cid:48)) ≥ 0, since Q(cid:48) satisfied I.6 before the operation. If r = first(Q) and l ≤ 2b, then we remove r and run Bias recursively. Let r(cid:48) = (l(cid:48), p(cid:48)) = first(Q). If l + l(cid:48) > 3b, then we take the 2b first elements out and make them the new first record of C(Q). Else we merge l into l(cid:48), so that r is removed and r(cid:48) is now first(Q). Amortization: Since first(Q) is either untouched or left with 2b to 3b elements, in which case its potential is 1, and since all other changes decrease the potential by at least 0, we have that Bias does not increase the potential of Q. Theorem 3.1. A set of (cid:96) I/O-CPQA's can be maintained supporting the operations FindMin, DeleteMin, CatenateAndAttrite and InsertAndAttrite in O(1/b) I/Os amortized and O(1) worst case I/Os per operation. The space usage is O( n−m ) blocks after calling CatenateAndAttrite and InsertAndAt- trite n times and DeleteMin m times, respectively. We require that M ≥ (cid:96)b for 1 ≤ b ≤ B, where M is the main memory size and B is the block size. b Proof. The correctness follows by closely noticing that we maintain invariants I.1 -- I.8, and from those we have that DeleteMin(Q) and FindMin(Q) always returns the minimum element of Q. The worst case I/O bound of O(1) is trivial as every operation only touches O(1) records. Although Bias is recursive, we notice that in the case where B(Q) > 0, Bias only calls itself after making B(Q) = 0, so it will not end up in this case again. Similarly, if B(Q) = 0 and kQ > 1 there might also be a recursive call to Bias. However, before the call at least b elements have been taken out of Q, and thus the following recursive call to Bias will ensure at least b more are taken out. This is enough to stop the recursion, which will have depth at most 3. The O(1/b) amortized I/O bounds, follows from the potential analysis made throughout the description of each operation. 3.2 Concatenating a Sequence of I/O-CPQAs We describe how to CatenateAndAttrite I/O-CPQAs Q1, Q2, . . . , Q(cid:96) into a single I/O-CPQA in O(1) (cid:80)kQ worst case I/Os, given that DeleteMin is not called in the sequence of operations. We moreover im- In particular, we say that I/O-CPQA Q is in state x ∈ Z, if C(Q) = pose two more assumptions. i=1 Di(Q) + kQ − 1 + x holds. Positive x implies that Bias(Q) will be called after the inequality for Q is aggravated by x + 1. Negative x implies that Bias(Q) need to be called x operations times in order to restore inequality for Q. So, we moreover assume that I/O-CPQAs Qi, i ∈ [1, (cid:96)] are at state at least +2, unless Qi contains only one record in which case it may be in state +1. We call a record r = (l, p) in an I/O-CPQA Qi critical, if r is accessed at some time during the sequence of operations. In particular, the criti- cal records for Qi are first(C(Qi)), first(rest(C(Qi))), last(C(Qi)), first(B(Qi)), first(D1(Qi)), last(DkQi (Qi)), (Qi))) if it exists. Otherwise, record last(DkQi−1(Qi)) is critical. So, we moreover assume and last(front(DkQi that the critical records for I/O-CPQAs Qi, i ∈ [1, (cid:96)] are loaded into memory. The algorithm considers I/O-CPQAs Qi in decreasing index i (from right to left). It sets Qi = Q(cid:96) and constructs the temporary I/O-CPQA Qi−1 by calling CatenateAndAttrite(Qi−1,Qi). This yields the final I/O-CPQA Q1. Lemma 3.1. I/O-CPQAs Qi, i ∈ [1, (cid:96)] can be CatenateAndAttrited into a single I/O-CPQA without any access to external memory, provided that: 1. Qi is in state at least +2, unless it contains only one record, in which case its state is at least +1, 8 2. all critical records of all Qi reside in main memory. Proof. To avoid any I/Os during the sequence of CatenateAndAttrites, we ensure that Bias is not called, and that the critical records are sufficient, and thus no more records need to be loaded into memory. To avoid calling Bias we prove by induction the invariant that the temporary I/O-CPQAs Qi, i ∈ [1, (cid:96)] constructed during the sequence are in state at least +1. Let the invariant hold of Qi+1 and let Qi be constructed by CatenateAndAttrite(Qi,Qi+1). If Qi contains at most two records, which both reside in dequeue C(Qi), we only need to access record first(C(Qi+1)) and the at most two records of Qi. The invariant holds for Qi, since it holds inductively for Qi+1 and the new records were added at C(Qi+1). As a result, the inequality of I.6 for Qi+1 can only be improved. If Qi+1 consists of only one record, then either one of the following cases apply or we follow the steps described in operation CatenateAndAttrite. In the second case, there is no aggravation for the inequality of 6 and only critical records are used. In the following, we can safely assume that Qi has at least three records and its state is at least +2. We parse the cases of the CatenateAndAttrite algorithm assumming that e = min(Qi+1). Case 1 The invariant holds trivially since Qi is discarded and no change happens to Qi = Qi+1. Bias is not called. Cases 2,3 The algorithm checks whether the first two records of C(Qi) are attrited by e. If this is the case, we continue as denoted at the start of this proof. Otherwise, case 2 of CatenateAndAttrite is applied as is. Qi+1 is in state 0 after the concatenation and Qi is in state +1. Thus the invariant holds, and Bias is not. Note that all changes take place at the critical records of Qi and Qi+1. Case 4 The algorithm works exactly as in case 4 of CatenateAndAttrite, with the following exception. At the end, Qi will be in state 0, since we added the deque DkQi+1 +1 with a new record and the inequality of I.6 is aggrevated by 2. To restore the invariant we apply case 2(1) of Bias. This step requires access to records last(DkQi−1) and first(DkQi ). These records are both critical, since the former corresponds to last(DkQi+1 ) and the latter to firstC(Qi+1). In addition, Bias(Qi+1) need not be called, since by the invariant, Qi+1 was in state +1 before the removal of firstC(Qi+1). In this way, we improve the inequality for Qi by 1 and invariant holds. 4 Dynamic Planar Range Skyline Reporting In this Section we present dynamic I/O-efficient data structures that support 3-sided planar orthogonal range skyline reporting queries. 3-Sided Skyline Reporting We describe how to utilize I/O-CPQAs in order to obtain dynamic data structures that support 3-sided range skyline reporting queries and arbitrary insertions and deletions of points, by modifying the approach of [14] for the pointer machine model. In particular, let P be a set of n points in the plane, sorted by x-coordinate. To access the points, we store their x-coordinates in an (a, 2a)- tree T with branching parameter a ≥ 2 and leaf parameter k ≥ 1. In particular, every node has degree within [a, 2a] and every leaf contains at most k consecutive by x-coordinate input points. Every internal node u of T is associated with an I/O-CPQA whose non-attrited elements correspond to the maximal points among the points stored in the subtree of u. Moreover, u contains a representative block with the critical records of condition 2 in Lemma 3.1 for the I/O-CPQAs associated with its children nodes. To construct the structure, we proceed in a bottom up manner. First, we compute the maximal points among the points contained in every leaf of T . In particular for every leaf, we initialize an I/O-CPQA Q. We consider the points (px, py) stored in the block in increasing x-coordinate, and call InsertAndAt- trite(Q,−py). In this way, a point p in the block that is dominated by another point q in the block, is inserted before q in Q and has value −py > −qy. Therefore, the dominated points in the block correspond to the attrited elements in Q. 9 We construct the I/O-CPQA for an internal node u of T by concatenating the already constructed I/O-CPQAs Qi at its children nodes ui of u, for i ∈ [1, a] in Section 3. Then we call Bias to the resulting I/O-CPQA appropriately many times in order to satisfy condition 1 in Lemma 3.1. The procedure ends when the I/O-CPQA is constructed for the root of T . Notice that the order of concatenations follows implicitly the structure of the tree T . To insert (resp. delete) a point p = (px, py) to the structure, we first insert (resp. delete) px to T . This identifies the leaf with the I/O-CPQA that contains p. We discard all I/O-CPQAs from the leaf to the root of T , and recompute them in a bottom up manner, as described above. To report the skyline among the points that lie within a given 3-sided query rectangle [x(cid:96), xr]× [yb, +∞), it is necessary to obtain the maximal points in a subtree of a node u of T by querying the I/O-CPQA stored in u. Notice, however, that computing the I/O-CPQA of an internal node of T modifies the I/O-CPQAs of its children nodes. Therefore, we can only report the skyline of all points stored in T , by calling DeleteMin at the I/O-CPQA stored in the root of T . The rest of the I/O-CPQAs in T are not queriable in this way, since the corresponding nodes do not contain the version of their I/O-CPQA, before it is modified by the construction of the I/O-CPQA for their parent nodes. For this reason we render the involved I/O-CPQAs confluently persistent, by implementing their clean, buffer and dirty deques as purely functional catenable deques [11]. In fact, T encodes implicity the directed acyclic version graph of the confluently persistent I/O- CPQAs, by associating every node of T with the version of the I/O-CPQA at the time of its construction. Every internal node of T stores a representative block with the critical records for the versions of the I/O- CPQAs associated with its children nodes. Finally, the update operation discards the I/O-CPQA of a node in T , by performing in reverse the operations on the purely functional catenable deques involved in the construction of the I/O-CPQA (undo operation). With the above modification it suffices for the query operation to identify the two paths p(cid:96), pr from the root to the leaves of T that contain the x-successor point of x(cid:96) and the x-predecessor point of xr, respectively. Let R be the children nodes of the nodes on the paths p(cid:96) and pr that do not belong to the paths themselves, and also lie within the query x-range. The subtrees of R divide the query x-range into disjoint x-ranges. We consider the nodes of R from left to right. In particular, for every non-leaf node in p(cid:96) ∪ pr, we load into memory the representative blocks of the versions of the I/O-CPQAs in its children nodes that belong to R. We call CatenateAndAttrite on the loaded I/O-CPQAs and on the resulting I/O-CPQAs for every node in p(cid:96) ∪ pr, as decribed in Section 3. The non-attrited elements in the resulting auxiliary I/O-CPQA correspond to the skyline of the points in the query x-range, that are not stored in the leaves of p(cid:96) and pr. To report the output points of the query in increasing x-coordinate, we first report the maximal points within the query range among the points stored in the leaf of p(cid:96). Then we call DeleteMin to the auxiliary I/O- CPQA that returns the maximal points in increasing x-coordinate, and thus also in decreasing y-coordinate, and thus we terminate the reporting as soon as a skyline point with y-coordinate smaller than yb is returned. If the reporting has not terminated, we also report the rest of the maximal points within the query range that are contained in the leaf of pr. Theorem 4.1. There exist I/O-efficient dynamic data structures that store a set of n planar points and support reporting the t skyline points within a given 3-sided orthogonal range unbounded by the positive y-dimension in O(log2B n + t/B1−) worst case I/Os, and updates in O(log2B n) worst case I/Os, us- ing O(n/B1−) disk blocks, for a parameter 0 ≤  ≤ 1. Proof. We set the buffer size parameter b of the I/O-CPQAs equal to the leaf parameter k of T , and we set the parameters a = 2B and k = B1− for 0 ≤  ≤ 1. In this way, for a node of T , the representative blocks for all of its children nodes can be loaded into memory in O(1) I/Os. Since every operation supported by an I/O-CPQA involves a O(1) number of deque operations, I/O-CPQAs can be made confluently persistent without deteriorating their I/O and space complexity. Moreover, the undo operation takes O(1) worst case I/Os, since the purely functional catenable deques are worst case efficient. B1− ) = O(log2B n) worst case I/Os. Lemma 3.1 takes O(1) I/Os to construct the temporary I/O-CPQAs for every node in the search paths, since they satisfy both of its conditions. Moreover, by Theorem 3.1, it takes O( log2B n B1− ) I/Os to catenate them together. Thus, the construction of the auxiliary query I/O-CPQA takes O(log2B n) worst case I/Os Therefore by Theorem 3.1, an update operation takes O(log2B n 10 in total. Moreover, it takes O(1 + t/B1−) worst case I/Os to report the output points. There are O( n internal nodes in T , and every internal node contains O(1) blocks. B1− ) 4-Sided Skyline Reporting Dynamic I/O-efficient data structures for 4-sided range skyline reporting queries can be obtained by following the approach of Overmars and Wood for dynamic rectangular visibility queries [15]. In particular, 4-sided range skyline reporting queries are supported in O( log a log 2B + t/B1−) worst case I/Os, using O( n B1− loga n) blocks, by employing our structure for 3-sided range skyline reporting as a secondary structure on a dynamic range tree with branching parameter a, built over the y-dimension. Updates are supported in O( log a log 2B ) worst case I/Os, since the secondary structures can be split or merged in O(log2B n) worst case I/Os. Remark 4.1. In the pointer machine, the above constructions attains the same complexities as the existing structures for dynamic 3-sided and 4-sided range maxima reporting [4], by setting the buffer size, branching and leaf parameter to O(1). a log2 n log2 n 5 Lower Bound for Dominating Minima Reporting Let S be a set of n points in R2. Let Q = {Qi} be a set of m orthogonal 2-sided query ranges Qi ∈ R2. Range Qi is the subspace of R2 that dominates a given point qi ∈ R2 in the positive x- and y- direction (the "upper-right" quadrant defined by qi). Let Si = S ∩ Qi be the set of all points in S that lie in the range Qi. A dominating minima reporting query Qi contains the points min(Si) ∈ Si that do not dominate any other point in Si. In this section we prove that any pointer-based data structure that supports dominating minima queries in O(log O(1) n + t) time, must use superlinear space. This separates the problem from the easier problem of supporting dominating maxima queries and the more general 3-sided range skyline reporting queries. The same trade-off also holds for the symmetric dominated maxima reporting queries that are the simplest special case of 4-sided range skyline reporting queries that demands superlinear space. Moreover, the lower bound holds trivially for the I/O model, if no address arithmetic is being used. In particular, for a query time of O( logO(1) n log n log log n ) blocks of space. In the following, we prove the lower bound for the dominating minima reporting queries. B ) the data structure must definitely use Ω( n + t B B Henceforth, we use the terminology presented in Section 2. Without loss of generality, we assume that n = ωλ, since this restriction generates a countably infinite number of inputs and thus the lower bound is general. In our case, ω = logγ n holds for some γ 0, m = 2 and λ = . Let ρω(i) be the integer obtained by writing 0 ≤ i < n using λ digits in base ω, by first reversing the digits and then taking their complement with respect to ω. In particular, if i = i(ω) . . . i(ω) 1+γ log log n log n λ−1 holds, then i(ω) 1 0 (cid:106) (cid:107) ρω(i) = (ω − i(ω) λ−1 − 1)(ω − i(ω) λ−2 − 1) . . . (ω − i(ω) 1 − 1)(ω − i(ω) 0 − 1) j where i(ω) Figure 3 shows an example with ω = 4, λ = 2. is the j-th digit of number i in base ω. We define the points of S to be the set {(i, ρω(i))0 ≤ i < n}. To define the query set Q, we encode the set of points {ρω(i)0 ≤ i < n} in a full trie structure of depth λ. Recall that n = ωλ. Notice that the trie structure is implicit and it is used only for presentation purposes. Input points correspond to the leaves of the trie and their y value is their label at the edges of the trie. Let v be an internal node at depth d (namely, v has d ancestors), whose prefix v0, v1, . . . , vd−1 corresponds to the path from v to the root r of the trie. We take all points in its subtree and sort them by y. From this sorted list we construct groups of size ω by always picking each ωλ−d−1-th element starting from the smallest non-picked element. Each such group corresponds to the output of each query. See Figure 3 for an example. In this case, we say that the query is associated to node v. A node of with depth d has n ωd points in its subtree and thus it defines at most ωd−1 queries. Thus, the n 11 Figure 3: An example for ω = 4 and λ = 2. Two examples of queries are shown, out of the 8 possible queries with different output. Connecting lines represent points whose L1 distance is ωk, 1 ≤ k ≤ λ. All 8 possible queries can be generated by translating the blue lines horizontally so that the answers of all 4 queries are disjoint. Similarly for the red lines with the exception that we translate them vertically. total number of queries is: λ−1(cid:88) d=0 Q = ωd n ωd+1 = λ−1(cid:88) d=0 n ω = λn ω This means that the total number of queries is Q = λn ω = log n 1 1 + γ log log n logγ n n = n logγ−1 n(1 + γ log log n) The following lemma states that Q is appropriate for our purposes. Lemma 5.1. Q is (2, logγ n)-favorable. Proof. First we prove that we can construct the queries so that they have output size ω = logγ n. Assume that we take a group of ω consecutive points in the sorted order of points with respect to the y-coordinate at the subtree of node v at depth d. These have common prefix of length d. Let the y-coordinates of these points be ρω(i1), ρω(i2), . . . , ρω(iω) in increasing order, where ρω(ij) − ρω(ij−1) = ωλ−d−1, 1 < j ≤ ω. This means that these numbers differ only at the λ − d − 1-th digit. This is because they have a common prefix of length d since all points lie in the subtree of v. At the same time they have a common suffix of length λ − d − 1 because of the property that ρω(ij) − ρω(ij−1) = ωλ−d−1, 1 < j ≤ ω which comes as a result from the way we chose these points. By inversing the procedure to construct these y-coordinates, the corresponding x-coordinates ij, 1 ≤ j ≤ ω are determined. By complementing we take the increasing sequence ¯ρω(iω), . . . , ¯ρω(i2), ¯ρω(i1), where ¯ρω(ij) = ωλ−ρω(ij)−1 and ¯ρω(ij−1)− ¯ρω(ij) = ωλ−d−1, 1 < j ≤ ω. By reversing the digits we finally get the increasing sequence of x-coordinates iω, . . . , i2, i1, since the numbers differ at only one digit. Thus, the group of ω points are decreasing as the x-coordinates increase, and as a result a query q whose horizontal line is just below ρω(i1) and the vertical line just to the left of ρω(iω) will certainly contain this set of points in the query. In addition, there cannot be any other points between this sequence and the horizontal or vertical lines defining query q. This is because all points in the subtree of v have been sorted with respect to y, while the horizontal line is positioned just below ρω(i1), so that no other element lies in between. In the same manner, no points to the left of ρω(iω) exist, when positioning the vertical line of q appropriately. Thus, for each query q ∈ Q, it holds that S ∩ q = ω = logγ n. 12 1023456789101112131415213456789101112131415 It is enough to prove that for any two query ranges p, q ∈ Q, S ∩ q ∩ p ≤ 1 holds. Assume that p and q are associated to nodes v and u, respectively, and that their subtrees are disjoint. That is, u is not a proper ancestor or descendant of v. In this case, p and q share no common point, since each point is used only once in the trie. For the other case, assume without loss of generality that u is a proper ancestor of v (u (cid:54)= v). By the discussion in the previous paragraph, each query contains ω numbers that differ at one and only one digit. Since u is a proper ancestor of v, the corresponding digits will be different for the queries defined in u and for the queries defined in v. This implies that there can be at most one common point between these sequences, since the digit that changes for one query range is always set to a particular value for the other query range. The lemma follows. Lemma 5.1 allows us to apply Lemma 2.1, and thus the query time of O(logγ n + t), for output size t, . The following theorem summarizes the result of this n log n log log n can only be achieved at a space cost of Ω section. (cid:16) (cid:17) (cid:16) (cid:17) Theorem 5.1. The dominating minima reporting problem can be solved with Ω space, if the query is supported in O(logγ n + t) time, where t is the size of the answer to the query and parameter γ = O(1). log log n n logn 6 Conclusion We presented the first dynamic I/O-efficient data structures for 3-sided planar orthogonal range skyline reporting queries with worst case polylogarithmic update and query complexity. We also showed that the space usage of the existing structures for 4-sided range skyline reporting in pointer machine is optimal within doubly logarithmic factors. It remains open to devise a dynamic I/O-efficient data structure that supports reporting all m planar skyline points in O(m/B) worst case I/Os and updatess in O(logB n) worst case I/Os. It seems that the hardness for reporting the skyline in optimal time is derived from the fact that the problem is dynamic. The dynamic indexability model of Yi [21] may be useful to prove a lower bound towards the direction of rendering our structure for 3-sided range skyline reporting I/O-optimal, as defined by Papadias et al.[16]. Finally it remains open to obtain a O( n B logB n) space dynamic I/O-efficient data structures for 4-sided range skyline reporting with O(log2 B n) worst case query and update I/Os, regardless of the I/O-complexity per reported point. 13 References [1] Alok Aggarwal and S. Vitter, Jeffrey. The input/output complexity of sorting and related problems. Commun. ACM, 31(9):1116 -- 1127, 1988. [2] Jon Louis Bentley. Multidimensional divide-and-conquer. Commun. ACM, 23(4):214 -- 229, April 1980. [3] Stephan Borzsonyi, Donald Kossmann, and Konrad Stocker. The skyline operator. In ICDE, pages 421 -- 430, 2001. [4] Gerth Brodal and Konstantinos Tsakalidis. Dynamic planar range maxima queries. In Luca Aceto, Monika Henzinger, and Jir Sgall, editors, Automata, Languages and Programming, volume 6755 of Lecture Notes in Computer Science, pages 256 -- 267. Springer Berlin / Heidelberg, 2011. 10.1007/978-3- 642-22006-7 22. [5] Bernard Chazelle. Lower bounds for orthogonal range searching: I. the reporting case. J. ACM, 37(2):200 -- 212, April 1990. [6] Bernard Chazelle and Ding Liu. Lower bounds for intersection searching and fractional cascading in ¡ce:title¿Special higher dimension. Journal of Computer and System Sciences, 68(2):269 -- 284, 2004. Issue on STOC 2001¡/ce:title¿. [7] Ananda Das, Prosenjit Gupta, Anil Kalavagattu, Jatin Agarwal, Kannan Srinathan, and Kishore Kotha- palli. Range aggregate maximal points in the plane. In Md. Rahman and Shin-ichi Nakano, editors, WALCOM: Algorithms and Computation, volume 7157 of Lecture Notes in Computer Science, pages 52 -- 63. Springer Berlin / Heidelberg, 2012. 10.1007/978-3-642-28076-4 8. [8] Yu-Ling Hsueh, Roger Zimmermann, and Wei-Shinn Ku. Efficient updates for continuous skyline com- putations. In DEXA, pages 419 -- 433, 2008. [9] Zhiyong Huang, Hua Lu, Beng Chin Ooi, and Anthony K. H. Tung. Continuous skyline queries for moving objects. IEEE Trans. Knowl. Data Eng., 18(12):1645 -- 1658, 2006. [10] Anil Kishore Kalavagattu, Ananda Swarup Das, Kishore Kothapalli, and Kannan Srinathan. On finding skyline points for range queries in plane. In CCCG, 2011. [11] Haim Kaplan and Robert E. Tarjan. Purely functional, real-time deques with catenation. J. ACM, 46(5):577 -- 603, September 1999. [12] H. T. Kung, Fabrizio Luccio, and Franco P. Preparata. On finding the maxima of a set of vectors. J. ACM, 22(4):469 -- 476, 1975. [13] Michael D. Morse, Jignesh M. Patel, and William I. Grosky. Efficient continuous skyline computation. Inf. Sci., 177(17):3411 -- 3437, 2007. [14] Mark H. Overmars and Jan van Leeuwen. Maintenance of configurations in the plane. Journal of Computer and System Sciences, 23(2):166 -- 204, 1981. [15] Mark H. Overmars and Derick Wood. On rectangular visibility. J. Algorithms, 9(3):372 -- 390, September 1988. [16] Dimitris Papadias, Yufei Tao, Greg Fu, and Bernhard Seeger. Progressive skyline computation in database systems. ACM Trans. Database Syst., 30(1):41 -- 82, 2005. [17] Cheng Sheng and Yufei Tao. On finding skylines in external memory. In Proceedings of the thirtieth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems, PODS '11, pages 107 -- 116, New York, NY, USA, 2011. ACM. 14 [18] Rajamani Sundar. Worst-case data structures for the priority queue with attrition. Inf. Process. Lett., 31:69 -- 75, April 1989. [19] Yufei Tao and Dimitris Papadias. Maintaining sliding window skylines on data streams. IEEE Trans. on Knowl. and Data Eng., 18(3):377 -- 391, 2006. [20] Ping Wu, Divyakant Agrawal, Omer Egecioglu, and Amr El Abbadi. Deltasky: Optimal maintenance of skyline deletions without exclusive dominance region generation. In ICDE, pages 486 -- 495, 2007. [21] Ke Yi. Dynamic indexability and lower bounds for dynamic one-dimensional range query indexes. In Pro- ceedings of the twenty-eighth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems, PODS '09, pages 187 -- 196, New York, NY, USA, 2009. ACM. 15
1910.04974
1
1910
2019-10-11T05:17:46
A Quality Metric for Symmetric Graph Drawings
[ "cs.DS", "cs.CG" ]
Symmetry is an important aesthetic criteria in graph drawing and network visualisation. Symmetric graph drawings aim to faithfully represent automorphisms of graphs as geometric symmetries in a drawing. In this paper, we design and implement a framework for quality metrics that measure symmetry, that is, how faithfully a drawing of a graph displays automorphisms as geometric symmetries. The quality metrics are based on geometry (i.e. Euclidean distance) as well as mathematical group theory (i.e. orbits of automorphisms). More specifically, we define two varieties of symmetry quality metrics: (1) for displaying a single automorphism as a symmetry (axial or rotational) and (2) for displaying a group of automorphisms (cyclic or dihedral). We also present algorithms to compute the symmetric quality metrics in O(n log n) time for rotational symmetry and axial symmetry. We validate our symmetry quality metrics using deformation experiments. We then use the metrics to evaluate a number of established graph drawing layouts to compare how faithfully they display automorphisms of a graph as geometric symmetries.
cs.DS
cs
A Quality Metric for Symmetric Graph Drawings Amyra Meidiana* University of Sydney Seok-Hee Hong† University of Sydney Peter Eades‡ University of Sydney Daniel Keim§ University of Konstanz 9 1 0 2 t c O 1 1 ] S D . s c [ 1 v 4 7 9 4 0 . 0 1 9 1 : v i X r a ABSTRACT Symmetry is an important aesthetic criteria in graph drawing and network visualisation. Symmetric graph drawings aim to faithfully represent automorphisms of graphs as geometric symmetries in a drawing. In this paper, we design and implement a framework for quality metrics that measure symmetry, that is, how faithfully a drawing of a graph displays automorphisms as geometric symmetries. The quality metrics are based on geometry (i.e. Euclidean distance) as well as mathematical group theory (i.e. orbits of automorphisms). More specifically, we define two varieties of symmetry quality metrics: (1) for displaying a single automorphism as a symmetry (axial or rotational) and (2) for displaying a group of automorphisms (cyclic or dihedral). We also present algorithms to compute the symmetric quality metrics in O(nlogn) time for rotational symmetry and axial symmetry. We validate our symmetry quality metrics using deformation experiments. We then use the metrics to evaluate a number of established graph drawing layouts to compare how faithfully they display automorphisms of a graph as geometric symmetries. Index Terms: Human-centered computing [Visualization]: Visual- ization design and evaluation methods 1 INTRODUCTION Graph drawing aims to construct a visually-informative drawing of an abstract graph in the plane. Symmetry is one of the most important aesthetic criteria that represent the structure and properties of a graph visually [3]. Symmetric graph drawings aim to faithfully represent automorphisms of graphs as geometric symmetries in the drawing. Also, a symmetric drawing of a graph enables an understanding of the entire graph to be built up from that of a smaller subgraph. Symmetric drawings of a graph G are clearly related to the automorphisms of G, and algorithms for constructing symmetric drawings have two steps: Step 1. Find the "appropriate" automorphisms, and Step 2. Draw the graph displaying these automorphisms as symmetries. The problem of determining whether a graph has a nontrivial automorphism is automorphism complete [19]. However, the prob- lem of determining whether a graph has a nontrivial geometric automorphism is NP-complete [23]. Linear time algorithms to con- struct symmetric drawings for restricted classes of graphs exists (e.g. trees [21], outerplanar graphs [22], series-parallel digraphs [15]), and planar graphs [12 -- 14,16]. For general graphs, heuristics [7,18] and exact algorithms are available [1, 5]. *e-mail: [email protected] †e-mail: [email protected] ‡e-mail: [email protected] §e-mail: [email protected] It is important to ensure that a symmetric graph drawing accu- rately represent the automorphisms of the underlying graph to the greatest extent possible. However, existing symmetry detection and quality metrics for graph drawings do not focus on this comparison between detected geometric symmetry in a graph drawing and the automorphisms of the graph. In this paper, we design and implement a framework for quality metrics for graph drawings that measure symmetry, that is, how faithfully a drawing of a graph displays automorphisms as geometric symmetries. The quality metrics are based on geometry (i.e., Eu- clidean distance) as well as mathematical group theory (i.e., orbits of automorphisms). More specifically, we present the following contributions: 1. We design and implement a framework for a quality metric for symmetric graph drawing, which measures the symmetry quality of a drawing of a graph based on the comparison be- tween the symmetry of the drawing and the automorphism of the graph. We define two varieties of the symmetry quality metrics, one to measure how well a graph drawing displays a single automorphism as a symmetry (rotational or axial) and one to measure how well a graph drawing displays a group of automorphism simultaneously (cyclic or dihedral groups). 2. We present algorithms to compute the symmetry quality met- rics in O(nlogn) time for rotational and axial symmetry and O(knlogn) for automorphism groups, where n is the number of vertices in the graph and k is the size of the automorphism group. 3. We validate the single automorphism detection version of the symmetry quality metrics through deformation experiments of graph drawings, showing that the scores computed by our metric decrease when the drawings are distorted further from exact symmetry. 4. We validate the automorphism group detection version of the symmetry quality metrics through comparing drawings dis- playing different groups of automorphisms, showing that our metric effectively captures the difference in symmetry quality between drawings that display different numbers of automor- phisms as symmetries. 5. We use our metric to compare a number of established graph drawing layouts to compare how faithfully they display auto- morphisms of a graph as geometric symmetries. We confirm the effectiveness of the concentric circles layout in displaying a graph's automorphisms as symmetries. 2 RELATED WORKS 2.1 Symmetries and geometric automorphisms An automorphism of a graph is a permutation of the vertices that preserves the adjacency of each vertex. Suppose that a permutation group A acts on a set V . We say that φ ∈ A fixes v ∈ V if φ (v) = v; if φ fixes v for every φ ∈ A then A fixes v. If V(cid:48) ⊆ V and φ (v(cid:48)) ∈ V(cid:48) for all v(cid:48) ∈ V(cid:48) then φ fixes V(cid:48) (setwise). A subset V(cid:48) of V is an orbit of A if, for each u,v ∈ V(cid:48), there is φ ∈ A such that φ (u) = v, and V(cid:48) does not contain a nonempty subset with this property. It is important to use a rigorous model, introduced by Eades and Lin [9], for the intuitive concept of symmetry display. The symmetries of a set of points in the plane (such as a two dimensional graph drawing) form a group called the symmetry group of the set. A symmetry σ of a drawing D of a graph G induces an automorphism of G, in that the restriction of σ to the points representing vertices of G is an automorphism of G. A drawing D of a graph G displays an automorphism φ of G if there is symmetry σ of D which induces φ. The symmetry group of a graph drawing induces an automorphism group of the graph. An automorphism group A of a graph G is a geometric automorphism group if there is a drawing of G which displays every element of A. A non-trivial symmetry of a finite set of points in the plane is either a rotation about a point or a reflection about a line. A ge- ometric automorphism is a rotational automorphism (respectively relectional/axial automorphism) if it is induced by a rotation (respec- tively reflection). Eades and Lin [9] showed that that a nontrivial geometric automorphism group is one of three kinds: 1. a group of size 2 generated by an axial automorphism; 2. a cyclic group of size k generated by a rotational automor- phism; 3. a dihedral group of size 2k generated by a rotational automorphism of order k and an axial automorphism. 2.2 Symmetric Graph Drawing In general, determining whether a graph can be drawn symmetrically in two dimensions is NP-complete [19]. Exact algorithms based on Branch and Cut [5] and group theory [1] are available. Linear-time algorithms are available for symmetric drawings of limited classes of graphs, such as trees [21], outerplanar graphs [22], and series-parallel digraphs [15]. Linear-time algorithms have also been presented for maximally symmetric drawings of tricon- nected [16], biconnected [12], oneconnected [13], and disconnected planar graphs [14]. For a survey on symmetric drawings of graphs in two dimensions, see [8]. 2.3 Graph Drawing Symmetry Quality Metrics Purchase [24] defined a metric measuring the symmetry of a graph drawing by checking, for each pair of vertices, whether there is a symmetric subgraph around the pair, calculating a weighted sym- metry value of the symmetric subgraph if it exists, and adding the weighted symmetry value of all symmetric subgraphs. However, this metric has a best runtime of O(n5) and only considers axial symmetry. Klapaukh et al [17] defined a metric which detects rotational, axial, and translational symmetry in a node-link graph drawing, using methods adapted from computer vision. Taking as input an image of a drawing of a graph, this method detects symmetries by converting edges detected in the image into line vectors and then computing the symmetry quality for each line and each pair of lines, giving the runtime as O(m2) time in the number of edges, with the worst case of O(n4) time in the number of vertices for dense graphs. 2.4 Geometric Symmetry Detection Optimal algorithms for exact symmetry detection for two- dimensional point sets and polygons run in O(nlogn) time for detecting rotational or axial symmetry in two-dimensional point sets [2, 25]. These algorithms work by sorting the points by their angle around and distance from a centroid, then finding a palin- dromic sequence of angles and distances (for axial symmetry) or a subsequence that is repeated within the full sequence (for rotational symmetry). However, these algorithms only give a binary answer to whether a point set displays a symmetry and are not suitable to quantify the approximate symmetry of a point set. Zabrodsky et al [27] introduces the symmetry distance method, providing another method to quantify the approximate symmetry of a geometric object. This method takes as input a point set P and a symmetry σ to be checked and computes a symmetric point set Pσ realizing the input symmetry. This is done through a "folding" transform method that "folds" points in the same orbit, averages their positions, and "unfolds" them into a symmetric configuration. This method minimizes the Euclidean distance between each point in P and its image in Pσ , and the symmetry distance is given as the average of these Euclidean distances for every point in P. 3 SYMMETRY QUALITY METRIC FRAMEWORK We propose a new quality metric for graph visualization, the symme- try quality metric, for measuring how well the drawing of a graph displays selected geometric automorphisms of the underlying graph. Our metric is a faithfulness metric comparing the geometric symme- try detected in a drawing of a graph with the graph's automorphisms, the ground truth information, unlike existing metrics which only attempts to detect symmetry from the drawing. Figure 1 summarizes the framework used for our proposed metric. Figure 1: Framework for the symmetry quality metric. Let G be a graph and φ be a automorphism of G. It is important that φ be a geometric automorphism of G, as otherwise it is impossible to display it as a symmetry of a drawing of G [9]. The framework computes the symmetry quality score using the following steps: Framework: Symmetry Quality Metric Step 1: Apply a layout algorithm to G to obtain a graph drawing D, which provides geometric positions for each vertex in G. Step 2: Detect a geometric symmetry of D, obtaining symmetry σ. Step 3: Compare σ to φ to compute the symmetry quality metric. 3.1 Symmetry Quality Metric for a Single Automor- phism Given a drawing of a graph with an exact symmetry, a geometric symmetry detection algorithm can be used to detect a symmetry of the drawing, which induces an automorphism of the graph, and this result can be compared to the input automorphism. However, in practice, automatic graph layout algorithms may produce drawings that are not perfectly symmetric. We therefore define a refinement that uses approximate symmetry detection to quantify how far the drawing is from an exact symmetry that displays an input automor- phism. The approximate symmetry of a point set P can be defined as a Euclidean distance between it and a symmetric point set Pσ . In this refinement of our metric, for each orbit of φ, we compute the Euclidean distance needed to transform the position of its points in D to perfect symmetry, and use this distance to compute the symmetry quality. We define two different formulas to compute the symmetry quality metric, SQ, given the number of symmetric orbits and the Euclidean distance to exact symmetry for the asymmetric orbits. The first formula gives equal weight to the proportion of symmetric orbits and the average Euclidean distance to perfect symmetry of asymmetric orbits: (cid:33) (cid:32)Osym SQ1 = 1 2 O + 1 Oasym O ∑ k=1 sd(ok) (1) where O, Osym, and Oasym are the sets of all orbits of φ, orbits that are displayed symmetrically in D, and orbits that are displayed asymmetrically in D respectively; ok,, k = 1,2, ...,O are the orbits of φ; and sd(ok) denotes the Euclidean distance from the positions of points belonging to orbit ok in D to exact symmetry. The second formula defines possible ranges of values for a drawing based on the number of orbits that are drawn as symmetric and is computed as: (cid:40)1 SQ2 = O −(cid:16) 1+Osym (cid:17) 1− ∑o∈Oasym sd(o) if Osym = O otherwise (2) The fraction 1+Osym O (cid:16) (cid:17) 1− ∑o∈Oasym sd(o) limits the range of metric values based on the number of orbits displayed as symmetries in the drawing, while the sum penalizes the results based on the Euclidean distance from exact symmetry. 3.2 Symmetry Quality Metric for Automorphism Groups Another refinement of the metric is to take as input an automorphism group, to detect the extent to which multiple automorphisms are simultaneously displayed in a drawing of a graph. Our metric is able to take as input dihedral groups, which contain both rotational and reflectional automorphisms. To compute the group symmetry quality SQG, we consider a weighted sum based on the maximum orbit size of each orbit set. Given A as the automorphism group to be checked, we define weight w as: w = ∑ φ∈A K(φ ) (3) where K(φ ) is the size of the largest orbit of an automorphism φ ∈ A. For reflectional automorphisms, the value of K(φ ) is always 2, while for rotational automorphisms, the value of K(φ ) is the order of the rotation. Given this weight w, the group symmetry quality score SQG is computed using the formula: (cid:40)(cid:0) 1 w ∑φ∈A K(φ )× SQ(φ )(cid:1)× 1 (cid:0)1 + 1 w ∑φ∈A K(φ )× SQ(φ )(cid:1)× 1 2 2 SQG = if Asym = 0 otherwise (4) where Asym is the subset of A containing automorphisms that are displayed as exact symmetries in the drawing D and SQ(φ ) is the score computed by the SQ metric with φ as the input automorphism. SQ(φ ) can be computed with either SQ1 (Equation 1) or SQ2 (Equa- tion 2). The usage of the weight and the multiplier K(φ ) for each orbit is meant to give preference to drawings that display higher orders of symmetry, i.e. possessing more symmetries. Thus, a drawing that is symmetric but only of a lower order of symmetry will score lower than a symmetric drawing displaying a higher order of symmetry. Furthermore, adding 1 to the sum when at least an automorphism is realized as a symmetry ensures that every symmetric drawing will obtain a higher score than every asymmetric drawing. 4 ALGORITHMS FOR THE SYMMETRY QUALITY METRIC We present algorithms used to compute our metrics. Section 4.1 and 4.2 provide algorithms for detecting exact and approximate symmetries respectively within the framework of our metric, Section 4.3 presents the algorithm to compute the SQ version of our metric, and Section 4.4 presents the algorithm to compute the SQG version of our metric 4.1 Exact Symmetry Detection While exact symmetry detection for two-dimensional point sets and polygons can be run in O(nlogn) time, node-link drawings of graphs are often not simple polygons, which necessitates a modification to the approach. With symmetric graph drawings, it is possible to detect an automorphism of the graph by detecting the geometric symmetry of the vertex point set of the drawing and checking the adjacency of the vertices. The following describes the algorithm: Algorithm 1: Algo-ExactSym Input: Graph G, drawing D of G Output: true or false 1. Sort the vertex point set of D according to their angle around and distance from the centroid. 2. Detect the geometric symmetry of the point set. If no sym- metry is detected, return false, otherwise obtain the geometric symmetry σ. 3. For each orbit ok in σ, compare the adjacency of the vertices included in ok. If all of the vertices do not share the same pattern of adjacency, return false. 4. Return true if for every orbit, all the vertices share the same adjacency pattern. Algo-ExactSym runs in O(nlogn + m) time. Exact symmetry detection algorithms (both rotational and axial) for two-dimensional point sets, run in worst case O(nlogn) time [25]. As each vertex only appears in one orbit, the total running time of the symmetry detection step is of O(nlogn) time in the number of vertices. Step 3 takes linear time in the degree of the vertices, i.e. linear in the number of edges, putting the time complexity of the algorithm as O(nlogn + m) time, with n as the number of vertices and m as the number of edges. Recently, De Luca et al [20] presented a method to detect axial, rotational, and translational symmetries in graph drawings using a machine learning approach. However, this approach is a classifica- tion approach which only returns whether a drawing contains certain symmetries and with an 8% misclassification rate. 4.2 Approximate Symmetry Detection The previous approach is limited by the nature of the exact symmetry detection algorithm, which either returns a positive answer for an exact symmetry or a negative answer otherwise and does not quantify how far a negative answer is to exact symmetry. There is therefore a need for a method that is able to compare the approximate symmetry of a drawing to the automorphism of the underlying graph. Given an algorithm that computes the approximate symmetry of a point set, we can use it to determine whether each input orbit of automorphism is displayed as a geometric symmetry in the drawing of the graph. For our implementation, we use the symmetry distance approach of Zabrodsky et al [27] and we compute sd as mentioned in the formulas of SQ1 and SQ2 as below: Algorithm 2: Algo-ApproxSym Input: Graph G, drawing D of G, automorphism φ of G Output: sd 1. Normalize the points in the vertex point set P of drawing D such that all of the points lie within the unit circle centered on the centroid of the point set. 2. For each orbit ok in an automorphism φ: (a) Take the subset Pk of P, containing points corresponding to vertices contained in ok. (b) Compute the symmetric configuration Pσ closest to Pk. (c) For every vertex v included in ok, compute the Euclidean distance between its position in D and its image in Pσ , average the values, and divide by 2 to obtain the average distance d. (d) Subtract d from 1 to obtain the value sd. The distance computed by the symmetry distance approach is dependent on the area taken by the drawing D. To normalize this distance, we scale the point set such that the whole drawing fits in a unit circle, which limits the maximum possible distance to 2. We then divide the average distance d by 2 and subtract the result from 1 in order to get a score where 1 corresponds to exact symmetry and lower values corresponds to drawings that are further from exact symmetry. In theory, only orbits where the average distance d is 0 should be considered symmetric. However, computers work with floating point precision numbers rather than real numbers, leading to unavoidable round-off errors. To account for this, we define a threshold ε such that orbits with d less than ε are considered to be symmetric. Algo-AproxSym runs in O(nlogn). Given a center of rotation, the symmetry distance approach computes approximate rotational symmetry in O(nlogn) time due to the need to sort the points around the center. When the points are already sorted, the method takes O(n) time. With axial symmetry, given an axis of symmetry and the orbits, the symmetry distance approach takes O(n) time to compute the symmetric image of each orbit and then compute the distance of each point to its image in the symmetric configuration. 4.3 Algorithm for Computing SQ We present an algorithm to compute the SQ metrics for symmetry detection with a single automorphism as the input. We take a single set of orbits denoting one automorphism of a graph and compute how faithfully a drawing of the graph depicts this particular automorphism as a symmetry. Given a drawing D of a graph G and an automorphism φ of G, the metric is computed as follows: Algorithm 3: Algo-SQ Input: Graph G, drawing D of G, automorphism φ of G Output: SQ metric score 1. For each orbit ok in φ: (a) Compute the symmetry distance-based score sd using Algo− ApproxSym (b) Add ok to the set Osym if the value of sd is less than or equal to a threshold ε, or add it to the set Oasym otherwise 2. Compute the symmetry quality using eitherSQ1 or SQ2. Using Algo− ApproxSym, given a center or axis of symmetry, the sd values can be computed in O(nlogn) time in the number of vertices. When this information is not given, we select the center or axis of symmetry in the following way: • For rotational symmetries, we compute the centroids for each orbit (the point itself in the case of fixed points) and select one that is the closest to all other centres (i.e. geometric median). In the case of ties, we compute the sd of each orbit and select the one with the largest sd score. After initially sorting the points in O(nlogn) time, computing the geometric median can be done with two O(n)-time sweeps along the x- and y-axes and computing the sd scores when needed takes O(n) time , keeping the runtime at O(nlogn) time. • For axial symmetries, we compute the best line of symmetry us- ing Singular Value Decomposition (SVD) as a pre-processing step, as proposed by Zabrodsky et al [26]. While SVD runs in O(n3) in the size of the input matrices, in our case the ma- trix is of a fixed size 2× 2 as we only consider drawings in 2 dimensions, keeping the runtime complexity of the metric computation at O(nlogn) time in the number of vertices. Therefore, Algo-SQ runs in O(nlogn) time. 4.4 Algorithm for Computing SQG The SQG metric takes as input multiple automorphisms of a graph that can be displayed simultaneously in the same drawing and returns a symmetry quality metric score that measures how faithfully the drawing displays all the automorphisms at once. Given a drawing D of a graph G and a group of automorphisms A of G, the metric is computed using the following steps: Algorithm 4: Algo-SQG Input: Graph G, drawing D of G, group of automorphisms A of G Output: SQG metric score 1. For each automorphism φ in A, compute SQ(φ ) using Algo− SQ. 2. Compute the weighted sum of SQ(φ ) for all automorphisms in A, where the scores are weighted by the maximum orbit size of each automorphism. 3. Compute the SQG using Equation 4. The computation of each SQ score for each automorphism runs in O(nlogn) time. With k as the number of automorphisms in the input group, the SQG computation as a whole runs in O(knlogn) time. 5 EXPERIMENT 1: SQ METRIC VALIDATION EXPERIMENTS 5.1 Experiment Design To validate the SQ version of our metric, we perform experiments where we take a symmetric drawing of a graph and deform it in a way that breaks the symmetry. We expect that not only will our metric effectively capture the distortion from perfect symmetry induced by the deformations, but also that it will perform better than existing approximate symmetry detection approaches which only rely on Euclidean distance, here represented as sd. We formulate the following hypotheses: • Hypothesis 1: The symmetry quality scores SQ1 and SQ2 will both decrease as the drawing D of G is further deformed. • Hypothesis 2: The symmetry quality scores SQ1 and SQ2 will reflect the extent of distortion from perfect symmetry more effectively than sd. We performed five sets of experiments each to validate our metric on rotational and axial symmetry. For each experiment, we perform the following steps: 1. For a symmetric graph G, select φ, one of its geometric auto- morphisms. 2. Create a drawing D of G that displays φ as an exact symmetry. 3. Select a subset of vertices of G and perturb their position by taking them further from their initial position. Repeat until a desired number of perturbation steps is reached. We used a mix of well-known symmetric graphs from graph theory literature and newly-generated symmetric graphs. The graphs we generated for validation experiments with rotational symmetry (titled in the format c[order]x[#o f orbits]) were generated as follows. First, we decide on the order of rotational symmetry k and the number of orbits m, then define a graph G with k × m vertices and initially zero edges. We then connect each of the m sets of k vertices into m distinct cycles of length k, and, except for the "innermost" cycle, we connect them to previous cycles with a number of edges between k and 2k such that the graph possesses the order of symmetry desired. With graphs generated for axial symmetry, we first determine the orbits, including fixed points, create edges between vertices not in the same orbit, then "mirror" the edges by adding edges between the points which share orbits with the endpoint of the created edges. 5.2 Rotational Symmetry Experiments Step 0 Step 3 Figure 3: Symmetry quality metrics for the experiment in Figure 2. Both SQ1 and SQ2 captures the effect of the perturbations better than sd which is only based on Euclidean distance, with SQ2 capturing the effects of further perturbations better. Figure 2 shows an example of the validation experiment for detect- ing rotational symmetries. In this example, we take the Coxeter graph [6], which possesses an automorphism that can be depicted as a rotational symmetry of order 7 with 4 orbits. Step 0 shows the initial drawing of the graph, where all four orbits of order 7 rotation are displayed in the drawing. In step 3, one orbit has been perturbed, in step 7, two more orbits have been perturbed, and in step 10, all orbits have had two each of their vertices perturbed. Figure 3 shows the plot of the SQ metrics computed for the experiment displayed in Figure 2. We plot the SQ metrics computed by both of our formulas, SQ1 and SQ2 together with the sd score computed solely using the Euclidean distance as comparison. It can be seen that not only both SQ1 and SQ2 scores decrease as the perturbation steps progress, supporting Hypothesis 1, they also decrease at a faster rate than sd. While sd only decreases to around 0.6 at the final step, SQ1 decreases to around 0.3 and SQ2 to less than 0.1. These scores more accurately reflects the state of the drawing at Step 10 in Figure 2, which is visibly far from perfect symmetry, and thus supporting Hypothesis 2. 5.3 Axial Symmetry Experiments Step 0 Step 3 Step 7 Step 10 Step 7 Step 10 Figure 2: Validation experiments detecting rotational symmetry (order 7) on Coxeter graph. Each subsequent perturbation destroys a new orbit or further perturbs an already destroyed one. Figure 4: Validation experiment detecting axial symmetry on Heawood graph. • Hypothesis 3: The symmetry quality scores SQG1 and SQG2 will be higher for a drawing Di that displays as symmetries a larger subset of the automorphism group or an automorphism with a larger order than a drawing D j displaying as symmetries a smaller subset of the automorphism group or an automor- phism with a smaller order. • Hypothesis 4: The symmetry quality scores SQG1 and SQG2 will decrease as a drawing D is further deformed. For these experiments, we start by selecting a symmetric graph G and a geometric automorphism group A. We then create drawings of G displaying different subsets of A as symmetries. In addition, we also perform deformation experiments similar to that described in Section 5, where we perform steps of deformation that gradually de- stroys more orbits and/or brings perturbed vertices further from their initial positions. We perform six sets of experiments with drawings displaying the input automorphism groups as exact symmetries and four sets of experiments with drawing deformations. 6.2 Cyclic Group Experiments Figure 6 shows an example of the validation experiment for the automorphism group testing version of the metric, using a graph we created called c12x3 with a rotational automorphism of order 12 and 3 orbits. In this experiment, the input automorphisms are cyclic groups of order 12, 6, 4, 3, 2. In accordance, we created a set of drawings where the largest order of rotational symmetry displayed in each drawing correspond to one of the cyclic group orders in the input. Figure 9(a) shows the SQG metrics computed for the experiment displayed in Figure 6. The largest order of rotational symmetry displayed by each drawing is lower than the previous drawing - the first drawing, D1, displays rotational symmetry of order 12, while the last drawing, D5, only displays rotational symmetry of order 2. It can be seen that both SQG1 and SQG2 computes lower scores for drawing where the largest order of symmetry displayed is smaller, in line with Hypothesis 3. 6.3 Dihedral Group Experiments Figure 7 displays two more sets of validation experiments, where the input automorphisms are dihedral groups of order 10, 5, and 2 on the dodecahedral graph and dihedral groups of order 6, 3, and 2 on the cuboctahedral graph. In both examples, we start with a drawing displaying the highest order of symmetry by drawing each orbit on concentric circles. For subsequent drawings, we rotate a number of vertices in each orbit such that the drawing only shows a lower order of symmetry. Figures 9(b) and (c) shows the SQG scores computed for the validation experiments in Figure 7. It can be seen that for both sets of experiments, the scores computed by both SQG1 and SQG2 again decrease with drawings displaying lower orders of symmetry while still staying above 0.5, supporting Hypothesis 3. 6.4 Automorphism Group with Perturbations Experi- ments Figure 8 show an example of one automorphism group detection validation experiment with perturbations of the drawing. We start with drawings shown in Figure 6, in this case taking D1 and D2, then perform deformation steps by selecting an orbit, selecting a vertex from the orbit, and randomly perturbing its position such that the orbit is no longer displayed as symmetric in the drawing. Here, we show three steps of perturbation for each drawing. Figure 9(d) shows the SQG metrics computed on the drawings. It can be seen that for each set, the computed values gradually decrease as more orbits are perturbed, supporting Hypothesis 4. Figure 5: Symmetry quality scores for the validation experiment de- tecting axial symmetry on Heawood graph. SQ2 decrease at a faster rate on latter perturbation steps than SQ1 Figure 4 shows an example of a validation experiment for using the SQ metric with an axial automorphism as input. We use the Heawood graph in this example and draw a layout that displays one of its automorphisms as an axial symmetry, with the y-axis as the axis of symmetry. Each subsequent drawing in Figure 4 destroys at least one more orbit compared to the previous drawing. Figure 5 shows the SQ metrics computed for each perturbation step for the experiment depicted in Figure 4. Similar to the case seen in Figure 3, both SQ1 and SQ2 decrease as the perturbation steps continue and both obtain lower scores than sd on the perturbed drawings, further supporting Hypotheses 1 and 2. Similar patterns can be seen in all other experiments, validating Hypotheses 1 and 2. 5.4 Discussion and Summary In all validation experiments, SQ1 and SQ2 decrease steadily with the number of perturbation steps, while also capturing the changes in quality better than sd. Another point of note is that SQ2 consistently decreases at a faster pace than SQ1, such as can be seen in Figure 3, denoting that it can be more effective at capturing the changes in the quality of the symmetry of the drawings. Furthermore, in cases such as in Figure 5, we see that on the later half of the perturbation steps, the scores computed by the SQ1 formula does not differ much from sd, while SQ2 continues to decrease to a low score of below 0.1 for step 10 where five out of seven orbits have been perturbed. This further shows that SQ2 is better at capturing distortions from perfect symmetry. In summary, our experiments have supported Hypotheses 1 and 2, validating the effectiveness of our metric to measure the quality of symmetry in graph drawings with respect to one selected graph automorphism and demonstrates its better effectiveness in measur- ing deviations from perfect symmetry compared to the Euclidean distance-based-only sd, as well as showing that SQ2 captures the changes in quality more effectively than SQ1. 6 EXPERIMENT 2: SQG METRIC VALIDATION EXPERI- MENTS 6.1 Experiment Design To validate the SQG version of our metric, we compare drawings that show different subsets of an automorphism group and compare the value of the metric computed on each drawing. We expect that our metric will score a drawing higher the more automorphisms from the input automorphism group it displays as symmetries, or if it displays an automorphism with a higher order. Furthermore, as with the SQ version, we expect our metric to effec- tively reflect the degree of approximate symmetry of a drawing and score asymmetric drawings that are closer to exact symmetry higher. We formulate the following hypotheses: D1 D2 D3 D4 D5 Figure 6: Validation experiment with rotational symmetries of orders 12, 6, 4, 3, and 2. D1 Dodecahedral graph D2 D3 D1 Cuboctahedral graph D2 D3 Figure 7: Validation experiments with dihedral symmetry of orders 10, 5, and 2 on the dodecahedral graph and dihedral symmetry groups of orders 6, 3, and 2 on the cuboctahedral graph. 6.5 Discussion and Summary For the experiments with dihedral groups, we can see in Figures 9(b) and (c) that the SQG metrics for the drawing of the dodecahedral graph displaying dihedral symmetry of order 2 are lower than that of the drawing of the cuboctahedral graph displaying dihedral symme- try of order 2. This is due to the difference in the maximum order of automorphism in the input, which is 10 for the dodecahedral graph and 6 for the cuboctahedral graph. Due to the SQ metrics for each automorphism being weighted depending on the sizes of their orbits when computing SQG, this causes the dihedral symmetry of order 2 to have less relative weight in the dodecahedral graph case than the cuboctahedral graph case. Therefore, this experiment supports the usage of the weightings in our SQG formula (Equation 4). The results with perturbation experiments, such as with the ex- ample in Figure 8, show that not only that the computed scores decrease when the drawing is deformed such that fewer orbits are displayed symmetrically, but also that the metric computes lower scores when the deformed drawing is closer to a symmetric drawing that displays a lower order of symmetry. This can be seen in the difference in the scores computed for C12D1 and C6D1, where the drawings were perturbed from a symmetric drawing whose largest rotational symmetry is of order 12 and 6 respectively, in Figure 9(d) to the scores obtained for D4 and D5, showing rotational symmetries of order 3 and 2 respectively, in Figure 9(a). In summary, our experiments have supported Hypotheses 3 and 4, validating the effectiveness of the SQG metric in capturing the difference in quality of drawings displaying different subsets of an automorphism group of a graph, as well as in capturing the difference in quality when such drawings are perturbed to produce asymmetric drawings. 7 EXPERIMENT 3: LAYOUT COMPARISON EXPERIMENTS 7.1 Experiment Design After validating the usage of the SQG metric to compute a quan- titative score measuring how well a drawing displays a group of automorphisms of a graph, we conduct experiments comparing a number of different graph layout algorithms. We select the following automatic layouts to be compared: Fruchterman-Reingold (FR) [10], Stress Majorization [11], Pivot MDS [4], spectral, and Tutte. We also produce drawings using the Concentric Circles layout [1], where we create concentric circles according to the number of orbits of a selected automorphism, assign each orbit to a circle, and place the vertices belonging to the orbit in a regular convex polygon position around the circle. We perform the experiments using the following steps: 1. We select a symmetric graph G and draw it using all of the selected layout algorithms. 2. We define a group of automorphisms A of G as the input. 3. We compute the SQG metrics for the drawings produced by each layout algorithm with A as the input automorphism group. In Step 1, we generate one drawing each using each layout algo- rithm, except for FR, where we generate five drawings per graph, each time starting from a random initial layout. This is due to the non-deterministic nature of FR, compared to the other selected lay- out algorithms. We then average the SQG metrics computed for all the FR-generated drawings to obtain a value that can be compared to those computed for other layout algorithms. Based on how the Concentric Circles layout places vertices in regular convex polygon positions along concentric circles, we expect that this layout will perform well in displaying automorphisms as geometric symmetry. We also expect that the Tutte layout, due to being designed to display planar graphs, will perform well in dis- playing planar automorphisms, which are automorphisms that can be displayed in planar graph drawings. We formulate the following hypothesis for this experiment: • Hypothesis 5: The Concentric Circle layout will always at- tain SQG metrics of 1 and Tutte will always display planar automorphisms when the graph has planar automorphisms. 7.2 Layout Comparison Results Figure 11 shows an example of the layout comparison experiment using the dodecahedral graph. In this experiment, we use the SQG C12D1 c12x3 (rotational order 12) C12D2 C12D3 C6D1 c12x3 (rotational order 6) C6D2 C6D3 Figure 8: Validation experiments with rotational symmetry of orders 12, 6, 4, 3, and 2 on a synthetic symmetric graph. Here, we start with drawings as defined in Figure 6 and destroy another orbit of symmetry in each steps. (a) c12x3 (rotational symmetry group detection) (b) dodecahedral graph (c) cuboctahedral graph (d) c12x3 (with perturbation) Figure 9: Symmetry quality metrics computed for (a) c12x3 (Fig. 6, (b) dodecahedral graph (Fig. 7, (c) cuboctahedral graph (Fig. 7, (d) c12x3 (with perturbations) (Fig. 8 metric with the input dihedral groups of order 10, 5, and 2. Figure 12 displays the symmetry quality scores computed for this exper- iment. Concentric Circles obtains a metric score of 1, supporting Hypothesis 5. Stress Majorization also obtains a metric score of 1, and behind the two, Tutte obtains the third highest metric score. A similar result is shown in the examples using the tesseract graph in Figures 13 and 14, where we take as input dihedral groups of order 8, 4, and 2. Concentric Circles and Stress Majorization again obtains SQG values of 1, with Tutte the third highest. Figure 15 shows another example of the layout comparison ex- periment, taking as input dihedral group of order 5 on the Petersen graph. Figure 16 shows the SQG1 and SQG2 computed for this experiment. Although the automorphism is not planar, Tutte obtains SQG of one, the same as Concentric Circles, while all other layouts obtain SQG of lower than 0.3. 7.3 Discussion and Summary The results for layout comparisons, as summarized in the averages over nine graphs shown in Figure 10, show that the Concentric Cir- cles, Tutte, and Stress Majorization layouts obtains the top 3 values for the SQG metric. The results for Concentric Circles supports Hypothesis 5. The results for the Tutte layout may arise from the nature of the layout algorithm, where given a set of vertices forming the outer face fixed as a regular convex polygon, all other vertices are placed at the barycenter of its neighbors. This results in a unique embedding that minimizes a linear system of equations, which could lead to its ability to capture automorphisms of the graph as symmetries. However, as the layout is designed for planar graphs, the results favor planar automorphisms. This causes it to score lower on examples such as the dodecahedral graph in Figure 11, where it displays a dihedral automorphism of order 5, compared to Stress Majorization which displays the (non-planar) dihedral automorphism of order 10. With Stress Majorization, it has been shown that it is possible to obtain symmetric layouts with low stress starting from the Concen- tric Circles layout [9]. Unlike force-directed layouts such as FR, the set of minima for stress-based layouts is more limited, increasing the chances of producing a symmetric layout, which can explain its superior performance compared to FR. In summary, our experiments have supported hypothesis 5 by showing that the concentric circles layout always obtains a score of 1 on SQG and that Tutte layout is always able to display the highest order of planar automorphism when a graph possesses planar automorphisms. We also observe that Stress Majorization performs better at displaying graph automorphisms as symmetries compared to the remaining tested layouts: FR, Pivot MDS, and Spectral. 8 CONCLUSION We have introduced a new quality metric to measure how faithfully a graph drawing visualizes the graph's automorphisms as symmetries, based on both Euclidean distance and mathematical group theory. The metrics, SQ and SQG, are suited to detect symmetries corre- sponding to rotational, reflectional, and dihedral automorphisms. We defined algorithms to compute the metrics, running in O(nlogn) time for the SQ version taking as input a single auto- morphism and in O(knlogn) time for the SQG version taking as input an automorphism group, with n as the number of vertices and k as the size of the automorphism group. Experiments have validated the effectiveness of both SQ and SQG in capturing the extent to which the drawing's symmetries reflect the automorphisms of the graph. We demonstrated the effectiveness of SQ in reflecting the extent of distortion of a drawing from exact symmetry, and the effectiveness of SQG in reflecting the difference in quality between drawings displaying different automorphism groups of a graph. We have also compared layout algorithms using our metric, and in the process, confirm the effectiveness of the concentric circles layout in displaying a graph's automorphisms as symmetries and similarly for the Tutte layout for planar automorphisms. Future work may include extending the metric to graph drawings in three dimensions. Figure 10: Average SQG metrics computed for all nine layout compari- son graphs. Concentric Circles, Tutte, and Stress Majorization obtain the three highest scores. Figure 12: SQG metrics computed for the layout comparison exper- iment with the dodecahedral graph (Figure 11). Concentric Circles and Stress Majorization obtain scores of 1, while Tutte, which displays a planar automorphism of a lower order, obtains lower scores than the two. Stress Maj. Pivot MDS Stress Maj. Pivot MDS Spectral FR Spectral FR Tutte Concentric Circles Tutte Concentric Circles Figure 11: Layout comparison experiment with the dodecahedral graph, detecting dihedral symmetries of order 10, 5, and 2. Among automatic layouts, Stress Majorization realizes all of the input auto- morphisms, while Tutte displays the largest planar automorphism as dihedral symmetry of order 5. Figure 13: Layout comparison experiment with the tesseract graph, detecting dihedral symmetries of order 8, 4, and 2. Similar to the dodecahedral graph in Figure 11, Stress Majorization displays the highest order of automorphism (order 8) while Tutte realizes the high- est order of planar automorphism with dihedral symmetry of order 4. Figure 14: SQG metrics computed for the layout comparison exper- iment with the tesseract graph (Figure 13). Concentric Circles and Stress Majorization, displaying the highest order of automorphism, obtains scores of 1. Figure 16: SQG metrics computed for the layout comparison exper- iment with the Petersen graph (Figure 15). Concentric Circles and Tutte obtain scores of 1, while all other layouts obtain scores of less than 0.3. Stress Maj. Pivot MDS Spectral FR Tutte Concentric Circles Figure 15: Layout comparison experiment with the Petersen graph, with input dihedral group of order 5. Aside from concentric circles, Tutte is the only layout that perfectly displays the automorphism group as symmetries. REFERENCES [1] D. Abelson, S.-H. Hong, and D. E. Taylor. Geometric automorphism groups of graphs. Discrete Applied Mathematics, 155(17):2211 -- 2226, 2007. [2] H. Alt, K. Mehlhorn, H. Wagener, and E. Welzl. Congruence, similar- ity, and symmetries of geometric objects. Discrete & Computational Geometry, 3(3):237 -- 256, 1988. [3] G. D. Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph drawing: algorithms for the visualization of graphs. Prentice Hall PTR, 1998. [4] U. Brandes and C. Pich. Eigensolver methods for progressive multidi- mensional scaling of large data. In International Symposium on Graph Drawing, pp. 42 -- 53. Springer, 2006. [5] C. Buchheim and M. Junger. Detecting symmetries by branch & cut. Mathematical programming, 98(1-3):369 -- 384, 2003. [6] H. Coxeter. My graph. Proceedings of the London Mathematical Society, 3(1):117 -- 136, 1983. [7] H. De Fraysseix. An heuristic for graph symmetry detection. In International Symposium on Graph Drawing, pp. 276 -- 285. Springer, 1999. [8] P. Eades and S. Hong. Detection and display of symmetries. Handbook of Graph Drawing and Visualisation. CRC Press, Boca Raton, FL, to appear, 2013. [9] P. Eades and X. Lin. Spring algorithms and symmetry. Theoretical Computer Science, 240(2):379 -- 405, 2000. [10] T. M. J. Fruchterman and E. M. Reingold. Graph drawing by force- directed placement. Software: Practice and Experience, 21(11):1129 -- 1164, 1991. doi: 10.1002/spe.4380211102 [11] E. R. Gansner, Y. Koren, and S. North. Graph drawing by stress In J. Pach, ed., International Symposium on Graph majorization. Drawing, pp. 239 -- 250. Springer Berlin Heidelberg, 2004. [12] S.-H. Hong and P. Eades. Symmetric layout of disconnected graphs. In International Symposium on Algorithms and Computation, pp. 405 -- 414. Springer, 2003. [13] S.-H. Hong and P. Eades. Drawing planar graphs symmetrically, ii: Biconnected planar graphs. Algorithmica, 42(2):159 -- 197, 2005. [14] S.-H. Hong and P. Eades. Drawing planar graphs symmetrically, iii: Oneconnected planar graphs. Algorithmica, 44(1):67 -- 100, 2006. [15] S.-H. Hong, P. Eades, and S.-H. Lee. Drawing series parallel digraphs symmetrically. Computational Geometry, 17(3-4):165 -- 188, 2000. [16] S.-H. Hong, B. McKay, and P. Eades. A linear time algorithm for con- structing maximally symmetric straight line drawings of triconnected planar graphs. Discrete & Computational Geometry, 36(2):283 -- 311, 2006. [17] R. Klapaukh, S. Marshall, and D. Pearce. A symmetry metric for graphs and line diagrams. In P. Chapman, G. Stapleton, A. Moktefi, S. Perez-Kriz, and F. Bellucci, eds., Diagrammatic Representation and Inference, pp. 739 -- 742. Springer International Publishing, Cham, 2018. [18] R. J. Lipton, S. C. North, and J. S. Sandberg. A method for drawing graphs. In Proceedings of the first annual symposium on Computational geometry, pp. 153 -- 160. ACM, 1985. [19] A. Lubiw. Some np-complete problems similar to graph isomorphism. SIAM Journal on Computing, 10(1):11 -- 21, 1981. [20] F. D. Luca, M. I. Hossain, and S. G. Kobourov. Symmetry detection and classification in drawings of graphs. CoRR, abs/1907.01004, 2019. [21] J. Manning and M. J. Atallah. Fast detection and display of symmetry in trees. Congressus Numerantium, 64:159 -- 169, 1988. [22] J. Manning and M. J. Atallah. Fast detection and display of symmetry in outerplanar graphs. Discrete Applied Mathematics, 39(1):13 -- 35, 1992. [23] J. B. Manning. Geometric Symmetry in Graphs. PhD thesis, West Lafayette, IN, USA, 1991. UMI Order No. GAX91-16430. [24] H. C. Purchase. Metrics for graph drawing aesthetics. Journal of Visual Languages & Computing, 13(5):501 -- 516, 2002. [25] J. D. Wolter, T. C. Woo, and R. A. Volz. Optimal algorithms for symmetry detection in two and three dimensions. The Visual Computer, 1(1):37 -- 48, 1985. [26] H. Zabrodsky and D. Avnir. Continuous symmetry measures. 4. chi- rality. Journal of the American Chemical Society, 117(1):462 -- 473, 1995. [27] H. Zabrodsky, S. Peleg, and D. Avnir. Symmetry as a continuous feature. IEEE Transactions on Pattern Analysis & Machine Intelligence, (12):1154 -- 1166, 1995.
1204.5083
1
1204
2012-04-23T15:22:43
Smart Sort: Design and Analysis of a Fast, Efficient and Robust Comparison Based Internal Sort Algorithm
[ "cs.DS" ]
Smart Sort algorithm is a "smart" fusion of heap construction procedures (of Heap sort algorithm) into the conventional "Partition" function (of Quick sort algorithm) resulting in a robust version of Quick sort algorithm. We have also performed empirical analysis of average case behavior of our proposed algorithm along with the necessary theoretical analysis for best and worst cases. Its performance was checked against some standard probability distributions, both uniform and non-uniform, like Binomial, Poisson, Discrete & Continuous Uniform, Exponential, and Standard Normal. The analysis exhibited the desired robustness coupled with excellent performance of our algorithm. Although this paper assumes the static partition ratios, its dynamic version is expected to yield still better results.
cs.DS
cs
Smart Sort: Design and Analysis of a Fast, Efficient and Robust Comparison Based Internal Sort Algorithm Niraj Kumar Singh1 and Soubhik Chakraborty2* 1Department of Computer Science & Engineering, B.I.T. Mesra, Ranchi-835215, India 2Department of Applied Mathematics, B.I.T. Mesra, Ranchi-835215, India *email address of the corresponding author: [email protected] (S. Chakraborty) Abstract: Smart Sort algorithm is a “smart” fusion of heap construction procedures (of Heap sort algorithm) into the conventional “Partition” function (of Quick sort algorithm) resulting in a robust version of Quick sort algorithm. We have also performed empirical analysis of average case behavior of our proposed algorithm along with the necessary theoretical analysis for best and worst cases. Its performance was checked against some standard probability distributions, both uniform and non-uniform, like Binomial, Poisson, Discrete & Continuous Uniform, Exponential, and Standard Normal. The analysis exhibited the desired robustness coupled with excellent performance of our algorithm. Although this paper assumes the static partition ratios, its dynamic version is expected to yield still better results. Keywords: Sorting, empirical analysis, statistical bound, empirical O, mathematical bound 1 Introduction The present paper is aimed towards design and analysis of a fast, efficient and robust comparison based hybrid sorting algorithm targeting the universal data set. Here we have proposed a sorting algorithm named ‘Smart Sort’ which is a robust improvement over the popular Quick sort algorithm. Among the standard sorting algorithms, in the average case (as per mathematical analysis), both the Quick sort and Heap sort are excellent performers. These algorithms exhibit the O (nlog2n) operation counts for both the operations comparison and assignments. Although excellent for average inputs, the performance of Quick sort degrades to quadratic operation counts for certain data sets, apart from the very well known sorted / almost sorted data sequences. Presence of such patterns has resulted in questioning the robustness of even the average case performance of Quick sort algorithm [12]. A careful analysis of experimental data as contained in [12] and [13] revealed an interesting complementary nature of quick and heap sort algorithms. The quick sort was found to be excellent on continuous data sets, whereas heap sort worked superbly well with the discrete data set. It seems that the productive features of these two standard algorithms if combined together may yield an optimal result. The most natural implication of this fact is to achieve a better hybrid methodology through their proper fusion. With the knowledge of complementary behaviors of these two standard algorithms the next important question in this respect was – ‘how to achieve such a fusion?’ Natural suggestions include (a) Obtain the balanced partitions entirely through the recursive application of heap functions; (b) Achieve the partitions through embedding the heap properties into the partition function (of Quick sort) appropr iately. The first choice was exercised by Singh & Chakraborty in [11]. Here in this paper , we are interested in the second alternative and this is achieved by embedding the heap data structures, both max and min, to achieve a balanced partitioning and hence a robust version of Quick sort algorithm. Although advanced techniques are available for complexity analysis of algorithms (see [10], [8], [5], and [6]), they often fall flat when it comes to average case analysis This can happen because for a complex code it is difficult to judge which operation is pivotal before applying mathematical expectation and also because the probability distribution over which expectation is taken need not be realistic over the problem domain [1]. Smart Sort yields Ω (nlog2n) best case count, which is same as that of quick and heap sorts. Although the worst case count of this 2n), the empirical result revealed its conservativeness. The careful embedding of heap routines algorithm is O (nlog2 is an attempt towards avoiding too much random accesses of which heap sort suffers. Also the divide & conquer nature of Smart sort makes it compatible to parallel processing which gives it an edge over the rival heap sort algorithm. Average complexity is explained best by the weight based statistical bounds and their empirical estimates, called empirical O. Smart sort algorithm has average complexity Yavg(n) = Oemp(nlog2n) which is found to be robust in comparison to Quick sort which lacks this robustness [12]. In our analysis the time of an operation is taken as its weight. The statistical bound estimate is obtained by running computer experiments. A computer experiment is nothing but a series of runs of a code for various inputs. 2. The Algorithm: Smart Sort The Smart Sort algorithm is based on the divide and conquer paradigm. Function “Smart_Partition” is the key sub- routine for this algorithm. The key feature of this procedure is that it performs the “smart” fusion of heap construction procedures (of Heap sort) into the conventional “Partition” function (of Quick sort algorithm) to achieve a reasonably balanced partitioning of the list about the chosen pivot element. The ‘Partition’ function used as a sub procedure in ‘Smart_Partition’ is the standard partitioning function such as one suggested by Hoare [7] (even a minor modification would do). It should be kept in mind that such a ‘Partition’ function should assumes the first item of the list as the pivot element as this particular choice has the relevance with our algorithm. The functions ‘Build_Max_Heap’, ‘Build_Min_Heap’, ‘Adjust_Max_Heap’, and ‘Adjust_Min_Heap’ are the standard heap construction procedures (as suggested by Floyd [4]) which are used as sub-procedures with in the ‘Smart_Partition’ function. Although an ideal site around which the partition is supposed to be done is the middle position of the list, we have sacrificed this choice at some places. The tradeoffs between the permissible degree of skewness while partitioning the list and heap building costs play an important role in harnessing the true potential of Smart sort algorithm. The idea is to allow the skewness upto certain degree, and to retain the calls to make the partitions essentially of two equal sizes till the time the partition ratio deviates beyond a predefined limit from the desired ideal position (‘Mid’ in our case). Here the partition ratio is defined as the ratio of lengths of the segments A [Low, J-1] and A [J + 1, High]. The proper selection of Real constants T1 and T2 are crucial to an efficient implementation of this algorithm. As far as the correctness issue is concerned these variables must lie with in the range, 0 ≤ [T1, T2] ≤ 0.5. The proposed algorithm is written in a hypothetical language having peculiar resemblance with the much known “C” language. Main_Procedure ( ) {/* A [ ] is the array of elements to be sorted, ‘Low’ is the position of leftmost element in this list, initialized to 1, and ‘High’ is the right most element of this list and is initialize to n (the number of elements present in the data set) */ Smart_Sort (A, Low, High) } Smart_Sort (Real A [ ], Integer Low, Integer High) { Integer Mid, J, Range Real T1, T2 Mid = (Low + High) /2 Range = (High – Low) + 1 IF (Low ≥ High) THEN RETURN J = Smart_Partition (A, Low, High) IF ( (J ≤ Low + T1*Range ) OR ( J ≥ High – T2*Range ) ) THEN Smart_Sort (A, Low, Mid - 1) Smart_Sort (A, Mid+2, High) ELSE Smart_Sort (A, Low, J-1) Smart_Sort (A, J+1, High) } /* end of function Smart_Sort */ Smart_Partition (Real A [ ], Integer Low, Integer High) { Integer J, Mid, Max, Min, Range Real T1, T2 Mid = (Low + High) / 2 Range = (High – Low) + 1 J = Partition (Real A [ ], Integer Low, Integer High) IF (J ≤ Low + T1*Range) THEN { Max = Build_Max_Heap (A, J+1, Mid) Min = Build_Min_Heap (A, Mid+1, High) IF (Max > Min) THEN { Exchange (A [J+1], A [Mid+1]) WHILE (TRUE) { Max = Adjust_Max_Heap (A, J+1, Mid) Min = Adjust_Min_Heap (A, Mid+1, High) IF (Max > Min) THEN Exchange (A [J+1], A [Mid+1]) ELSE Break } } Exchange (A [J+1], A [Mid]) // significant when first element is chosen as pivot } IF (J ≥ High – T2*Range) THEN { Max = Build_Max_Heap (A, Low, Mid) Min = Build_Min_Heap (A, Mid+1, J-1) IF (Max > Min) THEN { Exchange (A [Low], A [Mid+1]) WHILE (TRUE) { Max = Adjust_Max_Heap (A, Low, Mid) Min = Adjust_Min_Heap (A, Mid+1, J-1) IF (Max > Min) THEN Exchange (A [Low], A [Mid+1]) ELSE Break } } Exchange (A [Low], A [Mid]) // significant when first element is chosen as pivot } RETURN (J) } /* end of the function Smart_Partition */ 2.1 Description of Smart Sort Upon execution the procedure ‘Partition’ returns the index J of element about which the partitioning is supposed to be done. Depending upon the nature (in terms of size ratio) of these two partitions either it is considered to be a reasonably balanced one and no further action (in order to make it even more balanced) is required or this partitioned list is again subjected to further action so as to achieve a better partition through possibly the repetitive application of heap (max/min) procedures. In the first case, the two partitions are A [Low, J-1] and A [J + 1, High], with property that each element in left partition is less than or equal to the pivot element A[J] and each element in the right half is greater than the pivot element. Where as in the later case, upon the termination of ‘Smart_Partition’ we achieve the sub lists A [Low, Mid - 1] and A [Mid + 2, High]. These partitions obey: MAX {A [Low, Mid]} ≤ MIN {A [Mid + 1, High]}. 3. Theoretical Analysis of Smart Sort: Worst and Best Cases The overall running time of Smart_Sort procedure (in terms of number of comparisons as well as assignments) can be expressed through the recurrence relation: T(n) = 2T(n/2) + f(n), where f(n) is the time incurred in partitioning the list into two reasonably balanced halves. The worst case recurrence is: T worst (n) = 2T (n/2) + O (n + nlog2n), 2n), whereas the best case recurrence is: T best (n) = 2T (n/2) + θ which upon solving yielded T worst (n) = O (nlog2 (n), which upon solving yielded a running time of O (nlog2n). With reference to the discussion carried out in previous section, the existence of conservativeness in this worst case bound cannot be ruled out. 4. Average Case Analysis Using Statistical Bound Estimate or Empirical O This section includes the empirical results performed over Smart Sort algorithm. Average case analysis was done by directly working on program run time to estimate the weight based statistical bound over a finite range by running computer experiments [9] [3]. This estimate is called empirical O [2] [14] [1]. Here time of an operation is taken as its weight. Weighing permits collective consideration of all operations into a conceptual bound which we call a statistical bound in order to distinguish it from the count based mathematical bounds that are operation specific. The credibility of empirical O depends on the design and analysis of our special computer experiment in which time was the response. A detailed discussion can be found in [2]. The observed mean times (in sec) of 100 trials were noted in table (1). Average case analysis was carried out for the thresholds T1=T2=0.01. System Specification: All the computer experiments were carried out using PENTIUM 1600 MHZ processor and 512 MB RAM. Table 1: Observed mean times in second for Smart Sort algorithm Poisson, λ=1 Discrete Continuous Uniform, [0- Uniform, 1] K=1000 0.014 0.0128 0.0207 0.0248 0.0427 0.036 0.0636 0.0495 0.0764 0.0583 0.07864 0.0981 0.11794 0.08566 0.0986 0.13158 0.0122 0.0159 0.0289 0.0377 0.0473 0.05722 0.067 0.08288 Array Size N 10000 20000 30000 40000 50000 60000 70000 80000 Binomial, m=1000, p=0.5 0.0121 0.0157 0.0209 0.0296 0.0368 0.04476 0.0528 0.06644 Exponential, mean=1 0.149 0.025 0.0494 0.0567 0.0748 0.10024 0.10702 0.12214 Standard Normal, μ=0, σ=1 0.0148 0.0297 0.0426 0.0565 0.0697 0.08322 0.09792 0.1083 0.08106 0.10324 0.11656 0.1352 0.1413 0.14696 0.13282 0.14078 0.1244 0.12192 90000 100000 0.0706 0.08182 4.1 Average Case Complexity for Binomial distribution inputs The binomial distribution inputs were taken with parameters m and p, where m=1000 and p=0.5 are fixed. The empirical result is shown in fig (1). Experimental result as shown in fig (1) is suggesting a step function that is trying to get close to O(nlogn) complexity. So we can safely conclude that Yavg(n) = Oemp(nlog2n). The subscript “emp” implies an empirical and hence subjective bound-estimate [11]. Fig (1): Plot for Binomial distribution data 4.2 Average Case Complexity for Poisson distribution inputs Experimental results as shown in fig (2) is supporting O(nlog2n) complexity for Poisson distribution inputs. So we can write Yavg(n) = Oemp(nlog2n). The input is obtained by putting the value of constant λ =1. Fig (2): Plot for Poisson distribution data 4.3 Average Case Complexity for Discrete Uniform distribution inputs Experimental result as shown in fig (3) is supporting O(nlog2n) complexity for Discrete Uniform Distribution inputs. Looking at the result we are comfortable with the expression Yavg(n) = Oemp(nlog2n). The parameter k is fixed to k=1000. Fig (3): Plot for Discrete Uniform data 4.4 Average Case Complexity for Continuous Uniform distribution Inputs Experimental results as shown in fig (4) is supporting O(nlog2n) complexity for Continuous Uniform distribution inputs. So we can again write Yavg(n) = Oemp(nlog2n). The Continuous Uniform Distribution inputs are taken with parameter mean θ, where θ=1. Fig (4): Plot for Continuous Uniform data 4.5 Average Case Complexity for Exponential distribution Inputs Experimental results as shown in fig (5) is fairly supporting O(nlog2n) complexity for Exponential distribution inputs. So we can safely put Yavg(n) = Oemp(nlog2n). The Exponential distribution inputs are taken with parameter mean θ, where θ = 1 is fixed. Fig (5): Plot for Exponential data 4.6 Average Case Complexity for Standard Normal distribution inputs Experimental results as shown in fig (6) is supporting O(nlog2n) complexity for Standard Normal distribution inputs. So we conclude with Yavg(n) = Oemp(nlog2n). The parameters taken are mean (μ) & std. deviation (σ), where μ = 0 and σ =1. Fig (6): Plot for Standard Normal data Remark: Empirical O is an estimate and not itself a bound. The term inside it gives the leading term in the empirical model fitted by the statistician to explain and predict time complexity. In this case, since it is obtained by working directly on time, it is estimating a statistical bound. 5. Conclusion & Future Works The experimental results revealed that among the six standard probability distributions examined in this paper, all were supporting the Oemp(nlog2n) complexity. It guarantees the time bound performance even for the most unfavorable combinations of data, and hence satisfies the robustness criteria. Although the results have been calculated for static partition ratios, we are very sure of the fact that a dynamic choice of such ratios would result in still better performance. And hence we are leaving this task as a rewarding future work. The true potential of an algorithm cannot be realized completely until is subjected to the parameterized complexity analysis, and hence we enlist this task as a related future work. 6. References 1. Chakraborty, S., Modi, D. N., Panigrahi, S.: Will the Weight-based Statistical Bounds Revolutionize the IT?, International Journal of Computational Cognition, Vol. 7(3), 2009, 16-22. 2. Chakraborty, S., Sourabh, S. K.: A Computer Experiment Oriented Approach to Algorithmic Complexity, Lambert Academic Publishing, (2010) 3. Fang, K. T., Li, R., Sudjianto, A.: Design and Modeling of Computer Experiments Chapman and Hall (2006) 4. Floyd R. W.: Algorithms 245 (TREESORT), Communications of the ACM,7:701, 1964. 5. Graham, R.L., Knuth, D.E., and Patashnik, O. Concrete Mathematics: A Foundation for Computer Science, 2nd ed. Addison-Wesley, Reading, MA, 1994. 6. Green, D.H., and Knuth, D.E. Mathematics for Analysis of Algorithms, 2nd ed. Birkhauser, Boston, 1982. 7. Hoare, C. A. R.: Quicksort. Computer Journal, 5(1):10-15, 1962. 8. Purdom, P. W., Jr., and Brown, C. The Analysis of Algorithms. Holt, Rinehart and Winston, New York,1985. 9. Sacks, J., Weltch, W., Mitchel, T., Wynn, H.: Design and Analysis of Computer Experiments, Statistical Science 4 (4) (1989) 10. Sedgewick, R., and Flajolet, P. An Introduction to the Analysis of Algorithms. Addison-Wesley, Reading, MA, 1996. 11. Singh, N. K., Chakraborty, S.: Partition Sort and its Empirical Analysis, CIIT-2011, CCIS 250, pp. 340-346, 2011. © Springer-Verlag Heidelberg 2011. 12. Sourabh, S.K., Chakraborty, S.: How robust is quicksort average complexity? arXiv:0811.4376v1 [cs.DS] , Advances in Mathematical Sciences Jour. (to appear) 13. Sourabh, S.K., Chakraborty, S.: Empirical Study on the Robustness of Average Complexity & Parameterized Complexity Measure for Heapsort Algorithm, International Journal of Computational Cognition, Vol. 7, No. 4, (December 2009). 14. Sourabh, S.K., Chakraborty, S.: On why an algorithmic time complexity measure can be system invariant rather than system independent, Applied Mathematics and Computation, Vol. 190, issue 1, 195--204 (2007) .
1910.08889
1
1910
2019-10-20T04:05:25
Planted Models for $k$-way Edge and Vertex Expansion
[ "cs.DS" ]
Graph partitioning problems are a central topic of study in algorithms and complexity theory. Edge expansion and vertex expansion, two popular graph partitioning objectives, seek a $2$-partition of the vertex set of the graph that minimizes the considered objective. However, for many natural applications, one might require a graph to be partitioned into $k$ parts, for some $k \geq 2$. For a $k$-partition $S_1, \ldots, S_k$ of the vertex set of a graph $G = (V,E)$, the $k$-way edge expansion (resp. vertex expansion) of $\{S_1, \ldots, S_k\}$ is defined as $\max_{i \in [k]} \Phi(S_i)$, and the balanced $k$-way edge expansion (resp. vertex expansion) of $G$ is defined as \[ \min_{ \{S_1, \ldots, S_k\} \in \mathcal{P}_k} \max_{i \in [k]} \Phi(S_i) \, , \] where $\mathcal{P}_k$ is the set of all balanced $k$-partitions of $V$ (i.e each part of a $k$-partition in $\mathcal{P}_k$ should have cardinality $|V|/k$), and $\Phi(S)$ denotes the edge expansion (resp. vertex expansion) of $S \subset V$. We study a natural planted model for graphs where the vertex set of a graph has a $k$-partition $S_1, \ldots, S_k$ such that the graph induced on each $S_i$ has large expansion, but each $S_i$ has small edge expansion (resp. vertex expansion) in the graph. We give bi-criteria approximation algorithms for computing the balanced $k$-way edge expansion (resp. vertex expansion) of instances in this planted model.
cs.DS
cs
Planted Models for k-way Edge and Vertex Expansion Anand Louis ∗ Rakesh Venkat† Indian Institute of Science Indian Institute of Technology, Hyderabad Bangalore, India. Hyderabad, India Abstract Graph partitioning problems are a central topic of study in algorithms and complexity theory. Edge expansion and vertex expansion, two popular graph partitioning objectives, seek a 2- partition of the vertex set of the graph that minimizes the considered objective. However, for many natural applications, one might require a graph to be partitioned into k parts, for some k > 2. For a k-partition S1, . . . , Sk of the vertex set of a graph G = (V, E), the k-way edge expansion (resp. vertex expansion) of {S1, . . . , Sk} is defined as maxi∈[k] Φ(Si), and the balanced k-way edge expansion (resp. vertex expansion) of G is defined as min {S1,...,Sk}∈Pk max i∈[k] Φ(Si) , where Pk is the set of all balanced k-partitions of V (i.e each part of a k-partition in Pk should have cardinality V /k), and Φ(S) denotes the edge expansion (resp. vertex expansion) of S ⊂ V . We study a natural planted model for graphs where the vertex set of a graph has a k-partition S1, . . . , Sk such that the graph induced on each Si has large expansion, but each Si has small edge expansion (resp. vertex expansion) in the graph. We give bi-criteria approximation algorithms for computing the balanced k-way edge expansion (resp. vertex expansion) of instances in this planted model. 9 1 0 2 t c O 0 2 ] S D . s c [ 1 v 9 8 8 8 0 . 0 1 9 1 : v i X r a ∗E-mail: †E-mail:[email protected] [email protected] 1 1 Introduction The complexity of computing various graph expansion parameters are central open problems in theoretical computer science, and in spite of many decades of intensive research, they are yet to be fully understood [AM85, Alo86, LR99, ARV09, FHL08, RS10]. A central problem in the study of graph partitioning is that of computing the sparsest edge cut in a graph. For a graph G = (V, E), we define the edge expansion of a set S of vertices, denoted by φ(S) as φ(S) def = E(S, V \ S) SV \ S V , (1.1) def = {{u, v} ∈ Eu ∈ S, v ∈ V \ S}. The edge expansion of the graph G is defined = minS⊂V φ(S). Related to this is the notion of the vertex expansion of a graph. For a graph where E(S, V \ S) as φG G = (V, E), we define the vertex expansion of a set S of vertices, denoted by φV(S) as def φV(S) def = N (S) ∪ N (V \ S) SV \ S V , (1.2) def def = {v ∈ V \ S∃u ∈ S such that {u, v} ∈ E}. The vertex expansion of the graph G is where N (S) = minS⊂V φV(S). A few other related notions of vertex expansion have been studied defined as φV G in the literature, we discuss them in Section 1.4. We also give a brief description of related works in Section 1.4. Graph k-partitioning. The vertex expansion and edge expansion objectives seek a 2-partition of the vertex set of the graph. However, for many natural applications, one might require a graph to be partitioned into k parts, for some k > 2. Let us use Φ to denote either φ (edge expansion) or φV (vertex expansion). For a k-partition S1, . . . , Sk of the vertex set, the k-way edge/vertex expansion of {S1, . . . , Sk} is defined as Φk (S1, . . . , Sk) def = max i∈[k] Φ(Si) , and the k-way edge/vertex expansion of G is defined as Φk G def = min {S1,...,Sk}∈Pk Φk (S1, . . . , Sk) , where Pk is the set of all k-partitions of the vertex set. Optimizing these objective function is useful when one seeks a k-partition where each part has small expansion. The edge expansion version of this objective has been studied in [LRTV12, LM14, LGT14], etc., and the vertex expansion version of this objective has been studied in [CLTZ18]; see Section 1.4 for a brief summary of the related work. For many NP-hard optimization problems, simple heuristics work very well in practice, for e.g. SAT [BP99], sparsest cut [KK95, KK98], etc. One possible explanation for this phenomenon could be that instances arising in practice have some inherent structure that makes them "easy". Studying natural random/semi-random families of instances, and instances with planted solutions has been a fruitful approach towards understanding the structure of easy instances, and in modelling instances arising in practice, especially for graph partitioning problems [McS01, MMV12, MMV14, LV18] (see 2 Section 1.4 for a brief survey). Moreover, studying semi-random and planted instances of a problem can be used to better understand what aspects of a problem make it "hard". Therefore, in an effort to better understand the complexity of graph k-partitioning problems, we study the k-way edge and vertex expansion of a natural planted model of instances. We give bi-criteria approximation algorithms for instances from these models. 1.1 k-way planted models for expansion problems We study the following model of instances. Definition 1.1 (k-Part-edge). An instance of k-Part-edge(n, k, ε, λ, d, r) is generated as follows. 1. Let V be a set of n vertices. Partition V into k sets {S1, S2, . . . Sk}, with St = n/k for every t ∈ [k]. For each t ∈ [k], add edges between arbitrarily chosen pairs of vertices in St to form an arbitrary roughly d-regular (formally, the degree of each vertex should lie in [d, rd]) graph of spectral gap (defined as the second smallest eigenvalue of the normalized Laplacian matrix of the graph, see Section 2.1 for definition) at least λ. 2. For all i, j ∈ [k], add edges between arbitrarily chosen pairs of vertices in Si × Sj such that φG(Si) 6 εrd ∀i ∈ [k]. 3. (Monotone Adversary) For each t ∈ [k], add edges between any number of arbitrarily chosen pairs of vertices within St. Output the resulting graph G. Analogously, we define the vertex expansion model. Definition 1.2 (k-Part-vertex). An instance of k-Part-vertex(n, k, ε, λ, d, r) is generated as follows. 1. Let V be a set of n vertices. Partition V into k sets {S1, S2, . . . Sk}, with St = n/k for every t ∈ [k]. For each t ∈ [k], add edges between arbitrarily chosen pairs of vertices in St to form an arbitrary roughly d-regular (formally, the degree of each vertex should lie in [d, rd]) graph of spectral gap (defined as the second smallest eigenvalue of the normalized Laplacian matrix of the graph, see Section 2.1 for definition) at least λ. 2. For each t ∈ [k], partition St into Tt and St \ Tt such that Tt 6 εn/k. Add edges between any number of arbitrarily chosen pairs of vertices in ∪i∈[k]Ti. 3. (Monotone Adversary) For each t ∈ [k], add edges between any number of arbitrarily chosen pairs of vertices within St. Output the resulting graph G. The only difference between k-Part-edge and k-Part-vertex is in the expansion of the sets. In In step 2 of Definition 1.2, the step 2 of Definition 1.1, we ensured that φ(Si) 6 εrd ∀i ∈ [k]1. definition ensures that φV(Si) 6 εk ∀i ∈ [k]. 1Since φ(S) measures the weight of edges leaving S (see (1.1)), it is often more useful to compare edge expansion to some quantity related to the degrees of the vertices inside S. Therefore, in step 2 of Definition 1.1, we require φ(Si) 6 εrd ∀i ∈ [k], instead of φ(Si) 6 ε ∀i ∈ [k]. 3 Both these models can be viewed as the generalization to k-partitioning of models studied in the literature for 2-partitioning problems for edge expansion [MMV12], etc. and vertex expansion [LV18], etc. These kinds of models can be used to model communities in networks, where k is the number of communities. The intra-community connections are typically stronger than the inter-community connections. This can be modelled by requiring Si to have large expansion (see Theorem 1.3 and Theorem 1.4 for how large a λ is needed compared to ε). Our work for k > 2 can be used to study more general models of communities than the case of k = 2. 1.2 Our Results We give bi-criteria approximation algorithms for the instances generated from the k-Part-edge and k-Part-vertex models. We define OPT as follows OPT def = min {P1,...,Pk}∈ ePk Φk (P1, . . . , Pk) , where Φ is φ for k-Part-edge, and φV for k-Part-vertex, and ePk is the set of all balanced k-partitions for each {P1, . . . , Pk} ∈ ePk, we have Pi = n/k ∀i ∈ [k]. We note that in of the vertex-set, i.e. k-Part-edge, OPT 6 εrd, and in k-Part-vertex, OPT 6 εk. Theorem 1.3. There exist universal constants c1, c2 ∈ R+ satisfying the following: there exists a polynomial-time algorithm that takes as input a graph from the class k-Part-edge(n, k, ε, λ, d, r) with ε 6 λ/(800kr3), and outputs k disjoint sets of vertices W1, . . . , Wk ⊆ V , that for each i ∈ [k] satisfy: 1. Wi > c1n/k, 2. φ(Wi) 6 c2kOPT. Theorem 1.4. There exist universal constants c1, c2 ∈ R+ satisfying the following: there exists a polynomial-time algorithm that takes as input a graph from the class k-Part-vertex(n, k, ε, λ, d, r) with ε 6 λ/(800kr3), and outputs k disjoint sets of vertices W1, . . . , Wk ⊆ V , that for each i ∈ [k] satisfy: 1. Wi > c1n/k, 2. φV(Wi) 6 c2kOPT. Note when k = O (1), Theorem 1.3 and Theorem 1.4 guarantee constant factor bi-criteria approximation algorithms. The currently best known approximation guarantees for general in- stances (i.e. worst case approximation guarantees) of k-way edge expansion problems are of the the currently best known approximation guarantees for general instances (i.e. worst case approx- form O(cid:0)OPT√log nf1(k)(cid:1) or O(cid:16)√OPTf2(k)(cid:17) where f1(k), f2(k) are some functions of k, and imation guarantees) of k-way vertex expansion problems are of the form O(cid:0)OPT√log nf3(k)(cid:1) or O(cid:16)√OPTf4(k, d)(cid:17) where f3(k) is some functions of k and f4 is some function of k and the maximum vertex degree d. We survey these results in Section 1.4. Note that our bi-criteria approximation guarantees in Theorem 1.3 and Theorem 1.4 are multiplicative approximation guarantees and are independent of n. The above theorem shows that it is possible to produce k disjoint subsets, each of size Ω(n/k), each with expansion a factor k away from that of the planted partition. While this may not form a 4 partition of the vertex set, it is not difficult to show that with a loss of a factor of k, we can indeed get a true partition. This idea of moving from disjoint sets to a partition is well-known, and has been used before in other works (for e.g., [LGT14]). Corollary 1.5. There exist universal constants c1, c2 ∈ R+ satisfying the following: there exists a polynomial-time algorithm that takes as input a graph from k-Part-edge(n, k, ε, λ, d, r) (resp. k- Part-vertex(n, k, ε, λ, d, r)) with ε 6 λ/800kcr3, and outputs a k-partition P = {P1, . . . , Pk} of V such that: 1. For each i ∈ [k], Pi > c1n/k, 2. For each i ∈ [k], φ(Pi) 6 c2k2OPT (resp. φV(Pi) 6 c2k2OPT). We note that the above result approximates the k-way expansion of the best balanced partition in G. The proofs of the above results are given in Section 3. 1.3 Proof Overview For proving Theorem 1.3 and Theorem 1.4 we use an SDP relaxation (see Section 2.2) similar to the one used by [LM14, MMV16], etc. For the case when k = 2, [MMV12, LV18] used slightly different SDP constraints, and showed that when S1 and S2 contain large edge expanders, the set of SDP solution vectors {ui : i ∈ V } contain two sets L1, L2 such that L1 ,L2 = Ω(n), L1 and L2 have small diameter, and the distance between L1 and L2 is Ω(1). The core of our analysis can be viewed as proving an analogue of this for k > 2 (Proposition 3.4), however, this requires some new ideas. For i ∈ [k], let µi denote the mean of the vectors corresponding to the vertices in Si. We use the expansion within Si's together with the SDP constraints to show that for i, j ∈ [k], i 6= j, each µi must have Ω(n/k) vertices sufficiently close to it, and that µi and µj must be sufficiently far apart. This can be used to show the existance of k such sets L1, . . . , Lk, such that for each i ∈ [k], Li has sufficiently small diameter and Li is sufficiently far from Lj ∀j 6= i. The proof of our structure theorem is similar in spirit to the proof of structure theorem of [PSZ17], but our final guarantees are very different, we discuss their work in more detail in Section 1.4. If we can compute k such sets L1, . . . , Lk, then using standard techniques, we can recover k sets having small expansion. In the case of k = 2, one could just guess a vertex from each these sets, and compute the two sets satisfying our requirements using standard techniques. For k > 2, guessing a vertex from each of the balls around µi would also suffice to compute sets L1, . . . , Lk satisfying our requirements. However, doing this naively would take time O(nk). To obtain an algorithm for this task whose running time is O (poly(n, k)), we use a simple greedy algorithm (Algorithm 1) to iteratively compute the sets Li such that Li has sufficiently small diameter and is sufficiently far from Lj for all j < i. To ensure that this approach works, one has to ensure that at the start of iteration i + 1, the set of SDP vectors for the vertices in V \ ∪i j=iLi has at least k − i clusters each of size Ω(n/k) and having small diameter. We use our structural result to prove that this invariant holds in all iterations of the algorithm. 1.4 Related Work [LV18] studied the 2-way vertex-expansion in k-Part-vertex for k = 2, and gave a constant factor bi-criteria approximation algorithm. Our proofs and results can be viewed as generalizing their result to k > 2. They also studied a stronger semi-random model, and gave an algorithm for exact 5 [MMV12] studied the 2-way edge-expansion recovery (i.e. a 1-approximation algorithm) w.h.p. in a model similar to k-Part-edge for k = 2, and gave a constant factor bi-criteria approximation algorithm. Our proofs and results can be viewed as generalizing their result to k > 2. k-partitioning problems. The minimum k-cut problem asks to find a k-partition of the vertex set which cuts the least number of edges; [SV95, NR01, RS08] all gave 2-approximation algorithms for this problem. A number of works have investigated k-way partitioning in the context of edge expansion. Bansal et al. [BFK+11] studied the problem of computing a k-partitioning S1, . . . , Sk of the vertex set such that Si = n/k for each i ∈ [k], which minimizes maxi∈[k] E(Si, V \ Si). They give an algorithm which outputs a k-partition of the vertex set T1, . . . , Tk such that Ti 6 (2 + ε)n/k, and maxi∈[k] E(Ti, V \ Ti) 6 connections between graph partitioning problems and graph eigenvalues. Let 0 = λ1 6 λ2 6 . . . 6 λn denote the eigenvalues of the normalized Laplacian matrix of the graph. Typically, a different but related notion of edge expansion is used, which is defined as follows. O(cid:0)√log n log k(cid:1) OPT, where OPT denotes the cost of the optimal solution. There are also many φ′(S) def = E(S, V \ S) min{vol(S), vol (V \ S)} , where vol(S) is defined as the sum of the degrees of the vertices in S. [LRTV11] gave an algorithm to find a k-partition which cuts at most O(cid:0)√λk log k(cid:1) fraction of the edges. [LGT14, LRTV12] showed that for any k non-empty disjoint subsets S1, . . . , Sk ⊂ V , maxi∈[k] φ′(Si) = Ω(λk). [LGT14] (see also [LRTV12, LM14]) gave an algorithm to find a (1− ε)k partition S1, . . . , S(1−ε)k of the vertex set satisfying maxi φ′(Si) = O(cid:0)(cid:0)1/ε3(cid:1)√λk log k(cid:1) for any ε > 0, and a collection of k non-empty, disjoint subsets S1, . . . , Sk ⊂ V satisfying maxi φ′(Si) = O(cid:0)k2√λk(cid:1). [LM14] gave an algorithm to find a par- tition of V into (1−ε)k disjoint subsets S1, S2, . . . , S(1−ε)k, such that φ′(Si) 6 O(cid:0)√log n log kOPT(cid:1). Given a parameter δ, the small-set edge expansion problem asks to compute the set S ⊂ V have the least edge expansion among all sets of cardinality at most δ V (or volume at most δvol (V )). Bansal et al. [BFK+11] and Raghavendra et al. [RST10] gave a bi-criteria approximation algorithm for the small-set edge expansion problem. [LM14] gave an algorithm that outputs (1− ε)k partition of maxi∈[k] φ′(Si) over all k-partitions S1, . . . , Sk of the vertex set. [LM14] also studied a balanced version of this problem, and gave bi-criteria approximation algorithms. S1, . . . , S(1−ε)k such that maxi φ′(Si) = O(cid:0)poly(1/ε)√log n log k OPT(cid:1), where OPT is least value Let ρk(G) denote minS1,...,Sk maxi∈[k] φ′(Si) where the minimum is over sets of k non-empty [KLL+13] showed that for any l > k, ρk(G) = disjoint subsets S1, . . . , Sk ⊂ V . Kwok et al. S1, . . . , Sk ⊂ V satisfying this bound. Combining this with the results of [LGT14, LRTV12], we get a V which have the least value of maxi∈[k] φ′(Si). Here the approximation factor depends on λl, but even in the best case when λl = Ω(1) for some l = O(k), the expression for the approximation O(cid:0)lk6λk/√λl(cid:1). They also gave a polynomial time algorithm to compute non-empty disjoint sets O(cid:0)lk6/√λl(cid:1) approximation to the problem of computing k non-empty disjoint subsets S1, . . . , Sk ⊂ guarantee reduces to O(cid:0)k7(cid:1). They also show that for any l > k and any ε > 0, there is a maxi∈[(1−ε)k] φ′(Si) = O(cid:0)(cid:0)(cid:0)l log2 k(cid:1) / (poly(ε)k)(cid:1) λk/√λl(cid:1). polynomial time algorithm to compute non-empty disjoint subsets S1, . . . , S(1−ε)k ⊂ V such that [PSZ17] define the family of well clustered graphs to be those graphs for which λk+1/ρk(G) = Ω(k2) (their structure theorem requires this ratio to be Ω(k2), their algorithms require the separation to be larger, i.e. Ω(k3)) . They show that for such graphs, using the bottom k eigenvectors of the normalized Laplacian matrix, one can compute a k-partition which is close Peng et al. 6 to the optimal k-partition for k-way edge expansion. They measure the closeness of their solution to the optimal solution in terms of the volume of the symmetric difference between the solution returned by their algorithm and the optimal solution. They start by showing that the vertex embedding of the graph into the k-dimensional space consisting of the bottom-k eigenvectors is clustered. Our technique to prove our main structural result Proposition 3.4, which shows that the SDP solution is clustered, is similar in spirit. Firstly, we note that the results of [PSZ17] apply to edge expansion problems and not vertex expansion problems. Moreover, due to the action of the monotone adversary, the λk+1 of instances from k-Part-edge could be very small in which case the results of [PSZ17] wouldn't be applicable. S1, . . . , S(1−ε)k of the vertex set such that maxi φ(Si) = O(cid:0)k2poly log(k)/e1.5(cid:1)√γk log r, where [CLTZ18] showed that for a hypergraph H = (V, E), there exist (1 − ε)k disjoint subsets r is the size of the largest hyperedge, φ(S) denotes the hypergraph expansion of a set of vertices S, γk is the kth smallest eigenvalue of the hypergraph Laplacian operator (we refer the reader to [CLTZ18] for the definition of φ(·), γk, etc.) Combining these ideas from [CLTZ18] with the ideas from [LM16], we believe it should be possible to obtain an algorithm that outputs (1 − ε)k dis- is OPT is least value of maxi∈[k] φ(Si) over all k-partitions S1, . . . , Sk of the vertex set. Using a standard reduction from vertex expansion in graphs to hypergraph expansion, we get analogs of the above mentioned results for vertex expansion in graphs. joint subsets S1, . . . , S(1−ε)k such that maxi φ(Si) = O(cid:0)k2poly log(k)poly(1/ε)(cid:1) √log n OPT, where def def G Vertex Expansion. An alternative, common definition of vertex expansion that has been studied = minS⊂V φV,a(S). As in the literature is φV,a(S) Louis et al. [LRV13] show, the computation φV = (V N (S) / (SV \ S)), and as before, φV,a G is equivalent upto constant factors. G and φV,a Feige et al. factors [LRV13] assuming the SSE hypothesis. Louis and Makarychev [LM16] gave a bi-criteria approximation for small-set vertex expansion. expansion of a graph. Bobkov et al. [BHT00] gave a Cheeger-type inequality for vertex expansion in terms of a parameter λ∞, which plays a role similar to λ2 in edge-expansion. Building on this, Louis et al. [LRV13] gave an SDP based algorithm to compute a set having vertex expansion at [FHL08] gave a O(cid:0)√log n(cid:1)-approximation algorithm for computing the vertex G log d(cid:19) in graphs having vertex degrees at most d. This bound is tight upto constant most O(cid:18)qφV Edge Expansion. Arora et al. [ARV09] gave a O(cid:0)√log n(cid:1)-approximation algorithm for computing the edge expansion of a graph. Cheeger's inequlity [AM85, Alo86] says that λ2/2 6 minS⊂V φ′(S) 6 √2λ2. Stochastic Block Models and Semi-Random Models. Stochastic Block Models (SBMs) are randomized instance-generation models based on the edge expansion objective and have been intensively studied in various works, starting with [HLL83, Bop87, JS98]. The goal is to iden- tify and recover communities in a given random graph, where edges within communities appear with a probability p that is higher than the probability q of edges across communities. Both exact and approximate recovery guarantees for SBMs have been investigated using various algo- rithms [McS01, MNS14, Mas14, ABH16, MNS15, MNS17], leading to the resolution of a certain conjecture regarding for what range of model parameters are recovery guarantees are possible. While the above results deal mostly with the case of SBMs with two communities, k-way SBMs (for k > 2 communities) have been studied in recent works [AS15a, AS15b, ABKK17]. Semi-Random Models allow instance generation using a combination of both random edges and some amount of monotone adversarial action (i.e. not change the underlying planted solution). 7 SDP-based methods seem to work well in this regard, since they are robust to such adversarial action. Many variants of semi-random models for edge expansion have been studied in literature. Examples include works due to Feige and Kilian [FK01], Guedon and Vershynin [GV16], Moitra et al. [MMV16] also allows for a small amount of non-monotone errors in their model. These works give approximate and exact recovery guarantees for a range of parameters in their respective models. [MPW16], and Makarychev et al. [MMV12, MMV14, MMV16]. 2 Preliminaries and Notation 2.1 Notation def def = {j ∈ T : {i, j} ∈ E}, and N (i) = NV (i). = {1, 2, . . . n}. The We denote graphs by G = (V, E), where the vertex set V is identified with [n] vertices are indexed by i, j. For any S ⊆ V , we denote the induced subgraph on S by G[S]. Given i ∈ V and T ⊆ V , define NT (i) Given the normalized Laplacian L = I − D−1/2AD−1/2, the spectral gap of G denoted by λ, is the second-smallest eigenvalue of L. Spectral expanders are a family of graphs with λ at least some constant (independent of the number of vertices in G). Specific to graphs G generated in the k-Part-vertex and k-Part-edge models, let S = {S1, . . . , St} be the collection of sets for any i ∈ V , let S(i) denote the set S ∈ S such that i ∈ S. For a single sub- set W ⊆ V , we define ∂W = {i ∈ W : ∃j /∈ W with j ∈ N (i)} ∪ {i /∈ W : ∃j ∈ W with j ∈ N (i)}, i.e., the symmetric vertex boundary of the cut (W, V \ W ). We let E(∂S) be the edges going across the cut (S, V \ S), for any S ⊆ V . Given any k-partition of the vertex set W = {W1, . . . , Wk}, we define ∂W = ∪i∈[k]∂Wi to be the set of boundary vertices on this partition, and E(∂W) = ∪i∈[k]E(∂Wi) to be the edges across this partition. 2.2 SDP for k-way edge and vertex expansion Our algorithms for both k-Part-edge and k-Part-vertex models use a natural semi-definite program- ming (SDP) relaxation for k-way expansion. The objective function we use is the 'min-sum' objective in each case. For k-Part-vertex , it looks to minimize the number of boundary vertices in a balanced k-way partition of the vertex set, and correspondingly in k-Part-edge, the total number of edges across a balanced k-way partition of the vertex set. For the k-Part-edge model, we use the following SDP relaxation. 8 SDP 2.1 (Primal). k-Part-edge subject to min U 1 2 Xi,j∈E Uii + Ujj − 2Uij Uii = 1 Uij > 0 Xj Uij = n/k Ujj > Uij + Ujk − Uik U (cid:23) 0 SDP 2.2 (Primal). k-Part-vertex min U Xi∈V subject to ηi > Uii + Ujj − 2Uij Uii = 1 Uij > 0 Xj Uij = n/k Ujj > Uij + Ujk − Uik U (cid:23) 0 ηi ∀i ∈ V ∀i, j ∈ V ∀i ∈ V ∀i, j, k ∈ V ∀i,∀j ∈ N (i) ∀i ∈ V ∀i, j ∈ V ∀i ∈ V ∀i, j, k ∈ V The intended integral solution for U in the SDP relaxation (SDP 2.2, SDP 2.1) for either model is Uij = 1, if i, j lie in the same subset in the optimal k-partition of V , and 0 otherwise. We can alternatively view the SDP variables as a set of vectors {ui ∈ Rn}i∈V , satisfying uT i uj = Uij. These can be obtained by the Cholesky decomposition of the matrix U . Notice that the constraint Pj Uij = n/k in the relaxations above is specific to k-way partitions with exactly n/k vertices in each partition, and hence is satisfied by both models for the integral solution. The second-to-last set of constraints in either SDP are called ℓ2 2 triangle inequalities, and can be rephrased in the language of vectors as: kui − ujk2 + kuk − ujk2 > kui − ukk2 ∀i, j, k ∈ V (2.1) It is easy to verify that these are satisfied by the ideal integral solution, corresponding to ui = et, where i ∈ St. For k-Part-edge, for every edge across the partition we accumulate a value of 1 in the SDP 9 objective in the integral solution. Since every St has φ(St) 6 εrd, we have: n k · (1 − 1 k ) 6 εrd n k =⇒ 2(cid:12)(cid:12)(cid:12)∪k E(∂St) 6 εrd t=1E(∂St)(cid:12)(cid:12)(cid:12) 6 εrdn Since the number of edges going across the partition is at most2 εrdn, this is an upper bound on the optimum of SDP 2.1. For k-Part-vertex , the integral solution will further set, ηi = 2 for any boundary vertex i of the partition S, and ηi = 0 if i is not a boundary vertex, yielding a primal objective value of 2εn. Thus, the optimal value of SDP 2.2 is at most 2εn. Furthermore, if OPT is as defined in Section 1.2, then in either case we have that SDP 6 OPT·n. We introduce some notation regarding the SDP solution vectors {ui}i∈V that will be useful for = kui − ujk2. Due to inequalities (2.1), d(·,·) is a metric. Given a set L ⊆ V , 2 diameter of L is diam(L) = maxi,j∈L d(i, j). A ball of ℓ2 2 = minj∈L d(i, j). The ℓ2 proofs. Let d(i, j) def def define d(i, L) radius a around a point x ∈ Rn is defined as B(x, a) def = {j ∈ V : d(j, x) 6 a}. Further proof-specific notations are defined as and when they are needed in the respective sections. 3 Bi-criteria Guarantees in the Planted Model We now give a proof of Theorem 1.3, Theorem 1.4 and Corollary 1.5. The main idea is to show that the SDP solution is clustered around k disjoint balls, each of which have a significant overlap with a distinct Si, for i ∈ [k]. We can then extract out k sets greedily using an ℓ1 line embedding. In what follows, it is convenient to view the variables in the primal SDP as being vectors ui ∈ Rn for each i ∈ V that satisfy uT i uj = Uij. 3.1 Preliminary Lemmas Lemma 3.1. Let δ 6 1/100 and α 6 1 be real numbers. Let {ui}i∈V be a feasible SDP solution vector set for SDP 2.1 or SDP 2.2. Suppose there exists a set L ⊆ V that satisfies: (a) L > αn (b) diam(L) 6 δ. We have: (a) (Edge) If {ui}i∈V is an optimal solution to SDP 2.1 with objective value βn, then there exists def an i ∈ L, and a ∈ [δ, 1/50] such that W = B(i, a) satisfies φ(W ) 6 O(β/α). (b) (Vertex) If {ui}i∈V is an optimal solution to SDP 2.2 with objective value βn, then there def exists an i ∈ L, and a ∈ [δ, 1/50] such that W = B(i, a) satisfies φV(W ) 6 O(β/α). 2we use a slightly loose upper bound for convenience, to match up parameters in our proofs with the k-Part- vertex model 10 Part (a) of the above lemma follows from standard arguments in edge-expansion literature. Part (b) is a slight modification of [LV18, Lemma 3.1] 3. We defer both proofs to Appendix A. We next show that if the SDP solution is clustered into k disjoint, well-separated balls of small diameter, then we can iteratively use Lemma 3.1 to find k disjoint sets, each with small vertex or edge expansion. Lemma 3.2. Let δ 6 1 100 and k ∈ Z be large enough. Suppose the optimal SDP solution vec- tors {ui}i∈V to SDP 2.1 (resp. SDP 2.2) yield an objective value of βn and satisfy the following properties: (a) There exist disjoint sets L1, L2, . . . , Lk ⊆ V , with diam(Lt) 6 δ, (b) For each t ∈ [k], and for some constant γ, we have Lt > γn/k, (c) For every t 6= t′, d(Lt, Lt′ ) > 1/10. Then, we can in polynomial time, find k disjoint sets W1, . . . , Wk ⊆ V such that for every t ∈ [k], Wt > γn/k, and φ(Wt) 6 O(βk/γ) (resp. φV(Wt) 6 O(βk/γ)). Proof. Let Φ = φ, if we are working with k-Part-edge, and Φ = φV if we are working with k-Part- vertex. The proof will work for either case. We first apply Lemma 3.1 with α = γ/k to each of the sets L1, . . . , Lk in turn to conclude the existence of the corresponding W1, . . . , Wk sets each with vertex expansion at most O(βk/γ) . Fix any t ∈ [k]. Note that from Lemma 3.1, the structure of Wt implies that we have Lt ⊆ Wt, and hence Wt > γn/k . Given the separation condition (c), the sets Wt are disjoint. Indeed, for any t 6= t′, if Wt = 2 triangle B(i, a), and Wt′ = B(i′, a) (where i, i′, a are given by Lemma 3.1), we have, by the ℓ2 inequality: d(Wt, Wt′) > d(i, i′) − 1 50 − 1 50 > 1 20 (3.1) Note that the above only shows existence of k disjoint sets. In order to actually find k sets satisfying the given conditions, we proceed greedily (this is the loop in step 2 of Algorithm 1). At the first step, we find: W1 = argmin {Φ(B(i, a)) : i ∈ V, r ∈ [δ, 1/50),B(i, a) > γn/k} Clearly, since W1 is a candidate in the above minimization, we have Φ( W1) 6 Φ(W1) 6 O(βk/γ). Furthermore, since diam( W1) 6 1/25, (3.1) implies that W1 can intersect at most one of the Wt sets. This is because if W1 contained points from Wt and Wt′, for t 6= t′, then (3.1) implies that diam(W1) > 1/20, which is not possible. Now, we proceed similarly for (k − 1) more steps: at each step t ∈ {2, . . . k}, find a set Wt that is disjoint from the previous W1, . . . , Wt−1 and has minimum Φ. Wt = argminnΦ(B(i, r)) : i ∈ V, r ∈ [δ, 1/50),B(i, r) > γn/k, Wt ∩(cid:16)⊎t−1 s=1 Ws(cid:17) = ∅o 3References to the results and proofs in [LV18] are with respect to the full version of that paper, available currently as an arXiv preprint. 11 Lemma 3.3. At the start of iteration t in step 2 of Algorithm 1, there exists A ⊆ [k], A > (k−t+1) such that [i∈A Wt!\ [i∈[t−1] Wi = ∅ Proof. This is because, like W1, every subsequent Wt can intersect at most one of the sets among W1, . . . , Wk. This implies that at least (k − t + 1) of the Wi's are untouched at the start of iteration t, proving the statement of the lemma. From the above lemma, at every iteration in step 2 of Algorithm 1, there is always a Wi, for some i ∈ [k] that is a feasible candidate for minimization at iteration t. This Wi is known to satisfy the requirements on size (Ω(γn/k)) and expansion Φ(Wi) 6 O(βk/γ). Thus, the above procedure always finds a non-empty Wt, whose size is at least Ω(γn/k), and which has Φ( Wt) 6 O(βk/γ). 3.2 Showing that the SDP solution is clustered We next show that for any input instance from the class k-Part-edge or k-Part-vertex with appro- priate parameters, every feasible set of SDP solution vectors are clustered. Using Lemma 3.2, we can then immediately conclude the proof of Theorem 1.3 and Theorem 1.4. Our main technical result is the following proposition. Proposition 3.4. Let {ui}i∈V be the optimal solution SDP 2.1 (resp. SDP 2.2) for an instance G from k-Part-edge(n, k, ε, λ, d, r) (resp. k-Part-vertex(n, k, ε, λ, d, r)) with εkr3/λ 6 1/800. Then, there exist sets L1, . . . , Lk ⊆ V such that: (a) diam(Lt) 6 1/100, Lt ∩ St > n/2k, d(Lt, Lt′ ) > 1/10. (b) ∀t ∈ [k] : (c) ∀t 6= t′ : Proof of Proposition 3.4. We begin by proving the following lemma. Lemma 3.5. Let {ui}i∈V be the optimal solution to the SDP for an instance G from k-Part- vertex or k-Part-edge. For each t ∈ [k], let µt = Ei∈St [ui]. The following holds: (a) ∀t ∈ [k] : Ej∈St[kµt − ujk2] 6 kεr3 1 > kµtk2 (b) (c) ∀t 6= t′ µT Proof. For this proof, we first discard/ignore all edges added by the monotone adversary within each St. We can do this without introducing errors, as an adversary adding edges within St only > 1 − kεr3/λ t µt′ 6 kεr3/λ increasesPij∈E(St) kui − ujk2. The proof only requires an upper bound on this quantity to work. This is argument is similar to that used in [LV18] for handling a monotone adversary. We require the following proposition regarding edge expander graphs; a proof can be found in λ [LV18, Proposition 2.16]. 12 Proposition 3.6 (See [LV18, Proposition 2.16]). Let G′ = (V ′, E′) be an n-vertex edge-expander graph with spectral gap λ. Suppose that the degrees of the vertices in G satisfy ∆(i) ∈ [d, rd], for some r > 1, and d ∈ N. Then for any X ∈ Rn, we have: λd (3.2) X{i,j}∈E′ (Xi − Xj)2 > 1 r2 · n Xi,j∈V ′×V ′ (Xi − Xj)2 We will also need the following fact, the simple proof appears at the end of the current proof. Fact 3.7. Let µ be the centroid of points x1, . . . , xN ∈ Rn. Then, i∈[N ]kµ − xik2 Proof. Consider the points yi = xi − µ, soPi yi = −→0 . Now, we have: kyi − yjk2 = 2NXi kxi − xjk2 =Xi,j kxi − xjk2 =Xi,j kxi − xjk2 = E 1 N 2Xi<j 2 ·Xi<j kyik2 = 2NXi kµ − xik2 Item (a): We need slightly different proofs for k-Part-edge and k-Part-vertex models for this. [k-Part-edge]: Since the SDP value is at most 2 · εrd · n, we have for every t ∈ [k]: X{i,j}∈E =⇒ X{i,j}∈E(St) =⇒ Xi,j∈St kui − ujk2 6 2 · εrd · n kui − ujk2 6 2 · εrd · n kui − ujk2 6 2 · εn · rd · nr2 kλd =⇒ E i∈St kµt − uik2 6 kεr3 λ . . . using Proposition 3.6 within St, and St = n/k . . . since µt is the centroid of St and using Fact 3.7 [k-Part-vertex]: Since the SDP objective isPi∈V ηi 6 2εn, we have: ∀t ∈ [k] : Xi∈St ηi 6 2εn Fix some t ∈ [k]. Let the degree of the edge expander within St be in the range [d, rd] for some 13 integer d. Recall that ηi = maxj∈N (i) kui − ujk2. This implies: j∈N (i)kui − ujk2 max 6 2εn =⇒ Xi∈St t 1 Xi∈St rd Xj∈N (i)∩S′ =⇒ X{i,j}∈E(St) =⇒ Xi,j∈St kui − ujk2 6 2εn . . . since average 6 max, and the max degree is rd kui − ujk2 6 εn · rd kui − ujk2 6 εn · rd · nr2 kλd =⇒ E i∈St kµt − uik2 6 . . . using Proposition 3.6 within St, and St = n/k kεr3 λ . . . since µt is the centroid of St and using Fact 3.7 Item (b): Since all the vectors {ui}i∈V are unit vectors, and µt is an average of a subset of these, we have that kµtk2 6 1. For the lower bound: kεr3 λ > E j∈St [kµt − ujk2] j∈Sthkujk2i − 2 E = kµtk2 + E > kµtk2 + 1 − 2 · kµtk2 j∈St = 1 − kµtk2 Rearranging yields the required lower bound. [µT t uj] . . . expanding out the terms . . . since all uj's are unit vectors, and using E j∈St [uj] = µt Item (c): We know from the primal SDP constraint that for every i ∈ V ,Pj∈V uT some t0 ∈ [k]. i uj = n/k. Fix =⇒ n k kµt0k2 + n uT uT i µt 6 Xj∈V i uj 6 (cid:16) n k(cid:17)2 Xi∈St0 =⇒ Xi∈St0Xt∈[k] k Xt:t6=t0 =⇒ Xt:t6=t0 µT t0µt 6 µT t0µt 6 kεr3 n k n k λ 14 . . . since µt is the centroid of St . . . since n k · µt0 = Xi∈St0 ui . . . using item (b) from this lemma Since all the inner products uT i uj are non-negative, each of the inner products in the last line are non-negative, and hence, all of them are upper bounded by kεr3/λ, proving item (c) of Lemma 3.5. The above concludes the proof of Lemma 3.5. We use this to prove Proposition 3.4. For each def = B(µt, 1/400). Clearly, diam(Lt) 6 1/100. t ∈ [k], define Lt Since the parameters for either k-Part model are assumed to satisfy εkr3/λ 6 1/800, we have that for every t ∈ [k], item (a) from Lemma 3.5 implies that Ej∈St[kµt − ujk2] 6 kεr3/λ 6 1/800. We can now use Markov's inequality: j∈St(cid:20)kµt − ujk2 > Pr 1 400(cid:21) = St \ (Lt ∩ St) St =⇒ Lt ∩ St St = 1 − Pr > 1 − n 2k =⇒ Lt ∩ St > j∈St(cid:20)kµt − ujk2 > Ej∈St[kµt − ujk2] 1/400 . . . since Lt def = B(µt, 1/400) 1 400(cid:21) = 1 2 To prove item (c) of the lemma, we first prove the following claim: Claim 3.8. Proof. ∀t 6= t′ kµt − µt′k2 > 9 10 kµt − µt′k2 = kµtk2 + kµt′k2 − 2µT kεr3 λ − 2 × > 4kεr3 kεr3 t µt′ λ + 1 − 19 20 > > 1 − > 1 − 9 10 λ kεr3 λ . . . using Lemma 3.5 . . . since kεr3 λ 6 1 800 . From the definition of the sets {Lt}t∈[k], we will use the (plain Euclidean) triangle inequality and the above claim. Let t 6= t′. We know that d(Lt, Lt′) = d(i, i′) for some i ∈ Lt and i′ ∈ Lt′. Using this: d(Lt, Lt′) = d(i, i′) = kui − ui′k2 > (kµt − µt′k − kµt − uik − kµt − ui′k)2 >(cid:18)(cid:13)(cid:13)µt − µ′ t(cid:13)(cid:13) − >(cid:18) 9 10(cid:19)2 10 − 1 1 20 − 1 10 . > 1 20(cid:19)2 . . . by triangle inequality on the point sequence µt → i → i′ → µt′ . . . since d(µt′, i′), d(µt, i) 6r 1 400 = 1 20 15 Algorithm 1 Algorithm for rounding SDP solutions for k-Part-vertex (k-Part-edge) instances Input: G = (V, E) from k-Part(n, k, ε, λ, r) and an optimal SDP solution {ui}i∈V on G Output: Disjoint sets W1, . . . , Wk ⊆ V with Wt > n/2k 1: C ← ∅ 2: for t ∈ 1, . . . k do Wt ← ∅ for i ∈ V do 3: ⊲ Can be done in a discrete fashion for r ∈ [1/100, 1/50) do W ← B(i, r) If (cid:12)(cid:12)(cid:12) W(cid:12)(cid:12)(cid:12) < n/2k or (For k-Part-edge): (For k-Part-vertex): If Wt = ∅ or φV(Wt) > φV( W ) then Wt ← W φ(Wt) > φ( W ) then Wt ← W or continue W ∩ C 6= ∅ If Wt = ∅ 4: 5: 6: 7: 8: 9: 10: end for end for C ← C ∪ Wt 11: 12: end for 13: return W1, . . . , Wt Using the above, we now infer the proof of Theorem 1.3 and Theorem 1.4. Proof of Theorem 1.3 and Theorem 1.4. Consider the optimal SDP solution vectors {ui}i∈V for an instance G from k-Part-edge(n, k, ε, λ, d, r) (resp. k-Part-vertex(n, k, ε, λ, d, r)), with the parameters satisfying the given conditions, and having an objective value of βn. Note that β 6 OPT, as the SDP is a relaxation. Using Proposition 3.4, we infer the existence of sets L1, . . . , Lk satisfying the conditions given. The SDP solution thus satisfies all the conditions of Lemma 3.2, with δ = 1 100 and γ = 1/2, and therefore, we can find in polynomial time, k disjoint subsets W1, . . . , Wk: Wt > n/2k, and φ(Wt) 6 O(βk), for every t ∈ [k] for k-Part-edge, or correspondingly φV(Wt) 6 O(βk) for k- Part-vertex. Algorithm 1 describes the steps in the algorithm explicitly. Proof of Corollary 1.5. The proof for both parts uses a technique to move from disjoint sets to partitions used before, for instance in [LGT14, LM14]. Since these works do it for edge expansion already, we state the proof for k-Part-vertex first. For k-Part-vertex: We start with the sets W1, . . . , Wk from Theorem 1.4. From the definition of φV, we have: ∂Wt = N (Wt) + N (V \ Wt) 6 O(1) · OPT · k · WtV \ Wt Define the partition P = {P1, . . . , Pk} as follows: Pi = Wi if i 6= k, and Pk = V \ ⊎i∈[k−1]Wi. = O(k · OPTWt) ∀t ∈ [k] n Clearly, we have: ∂Pk 6(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) k−1[t=1 ∂Wt(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 6 O(k · OPT k−1Xt=1 16 Wt) 6 O(kn · OPT) Above, the last inequality follows since the Wt's are all disjoint. Since Pk > Ω(n/k), and V \ Pk > Ω(n), we infer that φV,k (P) 6 φV(Pk) 6 O(cid:0)k2 · OPT(cid:1). For k-Part-edge: The proof is very similar to the preceding one for k-Part-vertex, except we work with edges. Again, from the definition of φ, we have, for the sets given by Theorem 1.3: E(∂Wt) 6 O(1) · OPT · k · WtV \ Wt n = O(k · OPTWt) As before, we define P = {P1, . . . , Pk} as follows: Pi = Wi if i 6= k, and Pk = V \ ⊎i∈[k−1]Wi. From the above bound on E(∂Wt), we get that: E(∂Pk) = O(k · OPT k−1Xt=1 Wt) = O(kn · OPT) , giving that φk(P) = O(k2 · OPT). Acknowledgements AL was supported in part by SERB Award ECR/2017/003296 and a Pratik- sha Trust Young Investigator Award. References [ABH16] Emmanuel Abbe, Afonso S Bandeira, and Georgina Hall. Exact recovery in the stochastic block model. IEEE Transactions on Information Theory, 62(1):471 -- 487, 2016. [ABKK17] Naman Agarwal, Afonso S Bandeira, Konstantinos Koiliaris, and Alexandra Kolla. Multisection in the stochastic block model using semidefinite programming. In Compressed Sensing and its Applications, pages 125 -- 162. Springer, 2017. [Alo86] [AM85] [ARV09] [AS15a] [AS15b] Noga Alon. Eigenvalues and expanders. Combinatorica, 6(2):83 -- 96, 1986. Noga Alon and Vitali D Milman. λ1, isoperimetric inequalities for graphs, and superconcentra- tors. Journal of Combinatorial Theory, Series B, 38(1):73 -- 88, 1985. Sanjeev Arora, Satish Rao, and Umesh V. Vazirani. Expander flows, geometric embeddings and graph partitioning. Journal of the ACM, 56(2), 2009. (Preliminary version in 36th STOC, 2004). Emmanuel Abbe and Colin Sandon. Community detection in general stochastic block mod- els: Fundamental limits and efficient algorithms for recovery. In IEEE 56th Annual Symp. on Foundations of Computer Science (FOCS), 2015, pages 670 -- 688. IEEE, 2015. Emmanuel Abbe and Colin Sandon. Recovering communities in the general stochastic block model without knowing the parameters. In Advances in neural information processing systems, pages 676 -- 684, 2015. [BFK+11] Nikhil Bansal, Uriel Feige, Robert Krauthgamer, Konstantin Makarychev, Viswanath Nagarajan, Joseph Naor, and Roy Schwartz. Min-max graph partitioning and small set expansion. In Foundations of Computer Science (FOCS), 2011 IEEE 52nd Annual Symposium on, pages 17 -- 26. IEEE, 2011. Sergey Bobkov, Christian Houdré, and Prasad Tetali. λ∞, Vertex Isoperimetry and Concentra- tion. Combinatorica, 20(2):153 -- 172, 2000. [BHT00] [Bop87] Ravi B. Boppana. Eigenvalues and graph bisection: An average-case analysis. In Proceedings of the 28th Annual Symposium on Foundations of Computer Science, SFCS '87, pages 280 -- 285, Washington, DC, USA, 1987. IEEE Computer Society. 17 [BP99] In Roberto Battiti and Marco Protasi. Approximate algorithms and heuristics for max-sat. Handbook of Combinatorial Optimization: Volume1 -- 3, pages 77 -- 148, Boston, MA, 1999. Springer US. [CLTZ18] T.-H. Hubert Chan, Anand Louis, Zhihao Gavin Tang, and Chenzi Zhang. Spectral Properties of Hypergraph Laplacian and Approximation Algorithms. J. ACM, 65(3):15:1 -- 15:48, 2018. [FHL08] Uriel Feige, MohammadTaghi Hajiaghayi, and James R. Lee. Improved approximation algorithms for minimum weight vertex separators. SIAM Journal on Computing, 38(2):629 -- 657, 2008. [FK01] [GV16] Uriel Feige and Joe Kilian. Heuristics for semirandom graph problems. Journal of Computer and System Sciences, 63(4):639 -- 671, 2001. Olivier Guédon and Roman Vershynin. Community detection in sparse networks via grothendieckâĂŹs inequality. Probability Theory and Related Fields, 165(3-4):1025 -- 1049, 2016. [HLL83] Paul W Holland, Kathryn Blackmond Laskey, and Samuel Leinhardt. Stochastic blockmodels: First steps. Social networks, 5(2):109 -- 137, 1983. [JS98] [KK95] Mark Jerrum and Gregory B Sorkin. The metropolis algorithm for graph bisection. Discrete Applied Mathematics, 82(1):155 -- 175, 1998. George Karypis and Vipin Kumar. Analysis of multilevel graph partitioning. In Proceedings of the 1995 ACM/IEEE Conference on Supercomputing, Supercomputing '95, New York, NY, USA, 1995. ACM. [KK98] George Karypis and Vipin Kumar. A fast and high quality multilevel scheme for partitioning irregular graphs. SIAM J. Sci. Comput., 20(1):359 -- 392, December 1998. [KLL+13] Tsz Chiu Kwok, Lap Chi Lau, Yin Tat Lee, Shayan Oveis Gharan, and Luca Trevisan. Improved cheeger's inequality: Analysis of spectral partitioning algorithms through higher order spectral gap. In Proceedings of the Forty-fifth Annual ACM Symposium on Theory of Computing, STOC '13, pages 11 -- 20, New York, NY, USA, 2013. ACM. [LGT14] [LM14] [LM16] [LR99] James R Lee, Shayan Oveis Gharan, and Luca Trevisan. Multiway spectral partitioning and higher-order cheeger inequalities. Journal of the ACM (JACM), 61(6):37, 2014. Anand Louis and Konstantin Makarychev. Approximation algorithm for sparsest k-partitioning. In Proceedings of the twenty-fifth annual ACM-SIAM symposium on Discrete algorithms, pages 1244 -- 1255. SIAM, 2014. Anand Louis and Yury Makarychev. Approximation algorithms for hypergraph small-set expan- sion and small-set vertex expansion. Theory of Computing, 12(1):1 -- 25, 2016. Tom Leighton and Satish Rao. Multicommodity max-flow min-cut theorems and their use in designing approximation algorithms. J. ACM, 46(6):787 -- 832, November 1999. [LRTV11] Anand Louis, Prasad Raghavendra, Prasad Tetali, and Santosh Vempala. Algorithmic extensions of cheegerâĂŹs inequality to higher eigenvalues and partitions. In Approximation, Randomiza- tion, and Combinatorial Optimization. Algorithms and Techniques, pages 315 -- 326. Springer, 2011. [LRTV12] Anand Louis, Prasad Raghavendra, Prasad Tetali, and Santosh Vempala. Many sparse cuts via higher eigenvalues. In Proceedings of the forty-fourth annual ACM symposium on Theory of computing, pages 1131 -- 1140. ACM, 2012. [LRV13] Anand Louis, Prasad Raghavendra, and Santosh Vempala. The complexity of approximating vertex expansion. In Proc. of the 54th Annual Symp. on Foundations of Computer Science, FOCS '13, pages 360 -- 369, Washington, DC, USA, 2013. IEEE Computer Society. 18 [LV18] [Mas14] [McS01] Anand Louis and Rakesh Venkat. Semi-random Graphs with Planted Sparse Vertex Cuts: Algorithms for Exact and Approximate Recovery. In 45th International Colloquium on Au- tomata, Languages, and Programming (ICALP), pages 101:1 -- 101:15, 2018. Full Version at: https://arxiv.org/abs/1805.09747. Laurent Massoulié. Community detection thresholds and the weak ramanujan property. In Proc. of the 46th Annual ACM Symp. on Theory of Computing, STOC '14, pages 694 -- 703, New York, NY, USA, 2014. ACM. Frank D. McSherry. Spectral partitioning of random graphs. In Proc. of the 42nd IEEE Symp. on Foundations of Computer Science (FOCS), pages 529 -- 537, Washington, DC, USA, 2001. IEEE Computer Society. [MMV12] Konstantin Makarychev, Yury Makarychev, and Aravindan Vijayaraghavan. Approximation algorithms for semi-random partitioning problems. In Proc. of the 44th Annual ACM Symp. on Theory of Computing, STOC '12, pages 367 -- 384. ACM, 2012. [MMV14] Konstantin Makarychev, Yury Makarychev, and Aravindan Vijayaraghavan. Constant factor approximation for balanced cut in the pie model. In Proc. of the 46th Annual ACM Symp. on Theory of Computing, STOC '14, pages 41 -- 49, New York, NY, USA, 2014. ACM. [MMV16] Konstantin Makarychev, Yury Makarychev, and Aravindan Vijayaraghavan. Learning commu- nities in the presence of errors. In 29th Annual Conference on Learning Theory, volume 49 of Proceedings of Machine Learning Research, pages 1258 -- 1291, Columbia University, New York, New York, USA, 23 -- 26 Jun 2016. PMLR. [MNS14] Elchanan Mossel, Joe Neeman, and Allan Sly. Belief propagation, robust reconstruction and optimal recovery of block models. In Conference on Learning Theory, pages 356 -- 370, 2014. [MNS15] Elchanan Mossel, Joe Neeman, and Allan Sly. Consistency thresholds for the planted bisection In Proc. of the 47th Annual ACM Symp. on Theory of Computing, STOC '15, pages model. 69 -- 75, New York, NY, USA, 2015. ACM. [MNS17] Elchanan Mossel, Joe Neeman, and Allan Sly. A proof of the block model threshold conjecture. Combinatorica, 2017. [MPW16] Ankur Moitra, William Perry, and Alexander S Wein. How robust are reconstruction thresholds for community detection? In Proceedings of the forty-eighth annual ACM symposium on Theory of Computing, pages 828 -- 841. ACM, 2016. [NR01] [PSZ17] [RS08] [RS10] [RST10] J Naor and Yuval Rabani. Tree packing and approximating fc-cuts. In Proceedings of the twelfth annual ACM-SIAM symposium on Discrete algorithms, volume 103, page 26. SIAM, 2001. R. Peng, H. Sun, and L. Zanetti. Partitioning well-clustered graphs: Spectral clustering works! SIAM Journal on Computing, 46(2):710 -- 743, 2017. R Ravi and Amitabh Sinha. Approximating k-cuts using network strength as a lagrangean relaxation. European Journal of Operational Research, 186(1):77 -- 90, 2008. Prasad Raghavendra and David Steurer. Graph expansion and the unique games conjecture. In Proceedings of the Forty-second ACM Symposium on Theory of Computing, STOC '10, pages 755 -- 764, New York, NY, USA, 2010. ACM. Prasad Raghavendra, David Steurer, and Prasad Tetali. Approximations for the isoperimetric and spectral profile of graphs and related parameters. In Proceedings of the Forty-second ACM Symposium on Theory of Computing, STOC '10, pages 631 -- 640, New York, NY, USA, 2010. ACM. [SV95] Huzur Saran and Vijay V Vazirani. Finding k cuts within twice the optimal. SIAM Journal on Computing, 24(1):101 -- 108, 1995. 19 [WS11] David P. Williamson and David B. Shmoys. The Design of Approximation Algorithms. Cambridge University Press, New York, NY, USA, 1st edition, 2011. A Missing Proofs from Section 3 A.1 Proof of Lemma 3.1 Since the edge-expansion version is already well-known in literature, we start with vertex-expansion. Proof of Lemma 3.1. We start by stating the following lemma regarding ℓ1-line embeddings, a proof can be found in [LV18, Appendix A.4]. Lemma A.1. If there is a mapping y : V → R that satisfies: nPi maxe={i,j} yi − yj Pi,j∈V yi − yj = δ0 , then there is a polynomial-time algorithm to find a non-trivial cut (W, W ′) with vertex expansion at most 2δ0. Furthermore, the set W can be described using a threshold-cut: there exists some t ∈ R such that W = {i : yi 6 t}. The rest of the proof now closely follows the proof given for [LV18, Lemma 3.1], requiring only minor modifications. We are given that there exists a set L such that L > αn, satisfying: 1 100 Thus, we can fix an arbitrary i0 ∈ L, which will satisfy : i,j∈Lkui − ujk2 max 6 (cid:12)(cid:12)(cid:12)(cid:12)B(cid:18)i0, Claim A.2. Pi,j∈V kui − ujk2 > 2n2(1 − 1 100(cid:1), so L′ > αn. = B(cid:0)i0, 1 Let L′ def k ) . Proof. 1 100(cid:19)(cid:12)(cid:12)(cid:12)(cid:12) > αn Xi,j∈V i uj(cid:17) kui − ujk2 =Xi,j (cid:16)kuik2 + kujk2 − 2 · uT =Xi,j (cid:0)2 − 2 · uT i uj(cid:1) = 2n2(cid:18)1 − k(cid:19) . 1 . . . expanding out the terms . . . since ui's are unit vectors . . . since ∀i, Xj uT i uj = n k Claim A.3. For every i ∈ V , we have B(i, 1/50) 6 9n/10 20 Proof. Suppose B(i, 1/50) = m. Since from the previous claim, Pi,j d(i, j) = 2 · n2(1 − 1/k), we should have: 2n2(cid:18)1 − =⇒ m2(4 − 1 k(cid:19) 6 m2 · ) 6(cid:18)2 + 1 25 1 25 2 + (n2 − m2) · 4 k(cid:19) n2 6 3n2 =⇒ m 6 9 10 n . The first line follows since pairs within the ball are at most 1 triangle inequality, while other pairs are at most squared distance 4 apart, being unit vectors. 25 -squared distance apart due to the ℓ2 2 Let R′ := V \ B(i0, 1/50); from the above claim, we infer that R′ > n/10. Note that L′ ⊆ B(i0, 1/100) ⊆ B(i0, 1/50) and is hence disjoint from R′. Furthermore, d(L′, R′) > 1/50 by the ℓ2 triangle inequality. Now, consider the mapping y : V → R+: 2 yi :=(max{0, d(i, i0) − 1 d(R′, i0) − 1 100 100} for i /∈ R′ for i ∈ R′ . We show that the mapping y satisfies the conditions of Lemma A.1, with δ0 = O(β). We first show that yi − yj 6 d(i, j). To see this, consider three cases. First, say i /∈ R′, j ∈ R′. Clearly, yj = d(R′, i0) − 1/100 6 d(j, i0) − 1/100. Also, yi 6 yj, from the definition of R′. Hence, yi − yj = yj − yi 6 d(j, i0) − d(i, i0) 6 d(j, i), from the triangle inequality. Next, suppose that i /∈ R′, j /∈ R′. Then yi − yj = d(i, i0) − d(j, i0) 6 d(i, j). The last inequality is from the ℓ2 Finally, suppose i ∈ R′, j ∈ R′. Then yi − yj = d(R′, i0) − d(R′, i0) = 0 6 d(i, j). Using the above, for any given i, we have: 2 triangle inequality. j∈N (i)yi − yj 6 max max j∈N (i) d(i, j) Next, we analyze the following sum: j∈R′ j∈R′ Xij∈V yi − yj > Xi∈L′ > Xi∈L′ =(cid:12)(cid:12)L′(cid:12)(cid:12)(cid:12)(cid:12)R′(cid:12)(cid:12) · > Ω(α) · n2 > Ω(α)Xi,j nPi max{i,j}∈E yi − yj Pi,j∈V yi − yj Combining the above, we get that: yi − yj (cid:12)(cid:12)(cid:12)(cid:12)0 − d(R′, i0) + 1 100(cid:12)(cid:12)(cid:12)(cid:12) 1 100 . . . since yi = 0, for i ∈ L′ . . . since d(R′, i0) > 1/50 kui − ujk2 . . . from Claim A.2, using k > 2 6 O(1) · nPi∈V maxj∈N (i) kui − ujk2 αPij kui − ujk2 21 6 O(β/α) Using Lemma A.1, we conclude that we can find a partition (W, W ′) with vertex expansion O(β/α). From the nature of our embedding (a threshold cut with the threshold 6 1/50), the required property on W being B(i0, a) for some a ∈ [δ, 1/50] is clearly true. For k-Part-edge: The proof follows closely the above proof, so we only give a brief outline here. Instead of Lemma A.1, we use a corresponding version for edge expansion that is well-known (see, for instance, the proof of [WS11, Theorem 15.5]). Lemma A.4. If there is a mapping y : V → R that satisfies: Pi,j∈E yi − yj Pi,j∈V yi − yj = δ0 Then there is a polynomial-time algorithm to find a non-trivial cut (W, W ′) with φ(W ) 6 δ0. Furthermore, the set W can be described using a threshold-cut: there exists some t ∈ R such that W = {i : yi 6 t}. We now proceed exactly as in the vertex case, to get sets L′, R′ and the mapping yi. Now, as we have that yi − yj 6 d(i, j), andPij yi − yj > Ω(αn2), invoking Lemma A.4 with δ0 = β, we recover the statement of the corollary. 22
1606.03427
1
1606
2016-06-10T18:59:39
Better partitions of protein graphs for subsystem quantum chemistry
[ "cs.DS" ]
Determining the interaction strength between proteins and small molecules is key to analyzing their biological function. Quantum-mechanical calculations such as \emph{Density Functional Theory} (DFT) give accurate and theoretically well-founded results. With common implementations the running time of DFT calculations increases quadratically with molecule size. Thus, numerous subsystem-based approaches have been developed to accelerate quantum-chemical calculations. These approaches partition the protein into different fragments, which are treated separately. Interactions between different fragments are approximated and introduce inaccuracies in the calculated interaction energies. To minimize these inaccuracies, we represent the amino acids and their interactions as a weighted graph in order to apply graph partitioning. None of the existing graph partitioning work can be directly used, though, due to the unique constraints in partitioning such protein graphs. We therefore present and evaluate several algorithms, partially building upon established concepts, but adapted to handle the new constraints. For the special case of partitioning a protein along the main chain, we also present an efficient dynamic programming algorithm that yields provably optimal results. In the general scenario our algorithms usually improve the previous approach significantly and take at most a few seconds.
cs.DS
cs
Better partitions of protein graphs for subsystem quantum chemistry Moritz von Looz1, Mario Wolter2, Christoph R. Jacob2, and Henning Meyerhenke1 1 {moritz.looz-corswarem, meyerhenke}@kit.edu Institute of Theoretical Informatics Karlsruhe Institute of Technology (KIT), Germany 2 {m.wolter, c.jacob}@tu-braunschweig.de Institute of Physical and Theoretical Chemistry TU Braunschweig, Germany Abstract. Determining the interaction strength between proteins and small molecules is key to analyzing their biological function. Quantum- mechanical calculations such as Density Functional Theory (DFT) give accurate and theoretically well-founded results. With common imple- mentations the running time of DFT calculations increases quadratically with molecule size. Thus, numerous subsystem-based approaches have been developed to accelerate quantum-chemical calculations. These ap- proaches partition the protein into different fragments, which are treated separately. Interactions between different fragments are approximated and introduce inaccuracies in the calculated interaction energies. To minimize these inaccuracies, we represent the amino acids and their interactions as a weighted graph in order to apply graph partition- ing. None of the existing graph partitioning work can be directly used, though, due to the unique constraints in partitioning such protein graphs. We therefore present and evaluate several algorithms, partially building upon established concepts, but adapted to handle the new constraints. For the special case of partitioning a protein along the main chain, we also present an efficient dynamic programming algorithm that yields provably optimal results. In the general scenario our algorithms usually improve the previous approach significantly and take at most a few seconds. 1 Introduction Context. The biological role of proteins is largely determined by their interac- tions with other proteins and small molecules. Quantum-chemical methods, such as Density Functional Theory (DFT), provide an accurate description of these interactions based on quantum mechanics. A major drawback of DFT is its time complexity, which has been shown to be cubic with respect to the protein size in the worst case [4,18]. For special cases this complexity can be reduced to being linear [21,9]. DFT implementations used for calculations on proteins are in between these bounds and typically show quadratic behavior with significant constant factors, rendering proteins bigger than a few hundred amino acids pro- hibitively expensive to compute [4,18]. As an example, Figure 4 in Appendix A shows an excerpt from experimental running times of quantum-chemical calcu- lations on protein fragments which support this quadratic dependence. To mitigate the computational cost, quantum-chemical subsystem methods have been developed [12,16]. In such approaches, large molecules are separated into fragments (= subsystems) which are then treated individually. A common way to deal with individual fragments is to assume that they do not interact with each other. The error this introduces for protein–protein or protein–molecule interaction energies (or for other local molecular properties of interest) depends on the size and location of fragments: A partition that cuts right through the strongest interaction in a molecule will give worse results than one that carefully avoids this. It should also be considered that a protein consists of a main chain (also called backbone) of amino acids. This main chain folds into 3D-secondary- structures, stabilized by non-bonding interactions (those not on the backbone) between the individual amino acids. These different connection types (backbone vs non-backbone) have different influence on the interaction energies. Motivation. Subsystem methods are very powerful in quantum chemistry [12,16] but so far require manual cuts with chemical insight to achieve good parti- tions [19]. Currently, when automating the process, domain scientists typically cut every X amino acids along the main chain (which we will call the naive approach in the following). This gives in general suboptimal and unpredictable results (see Figure 2 in Appendix A). By considering amino acids as nodes connected by edges weighted with the expected error in the interaction energies, one can construct (dense) graphs rep- resenting the proteins. Graph partitions with a light cut, i. e. partitions of the vertex set whose inter-fragment edges have low total weight, should then corre- spond to a low error for interaction energies. A general solution to this problem has high significance, since it is applicable to any subsystem-based method and since it will enable such calculations on larger systems with controlled accuracy. Yet, while several established graph partitioning algorithms exist, none of them is directly applicable to our problem scenarios due to additional domain-specific optimization constraints (which are outlined in Section 2). Contributions. For the first of two problem scenarios, the special case of con- tinuous fragments along the main chain, we provide in Section 4 a dynamic programming (DP) algorithm. We prove that it yields an optimal solution with a worst-case time complexity of O(n2 · maxSize). For the general protein partitioning problem, we provide three algorithms using established partitioning concepts, now equipped with techniques for ad- hering to the new constraints (see Section 5): (i) a greedy agglomerative method, (ii) a multilevel algorithm with Fiduccia-Mattheyses [8] refinement, and (iii) a simple postprocessing step that "repairs" traditional graph partitions. Our experiments (Section 6) use several protein graphs representative for DFT calculations. Their number of nodes is rather small (up to 357), but they 2 are complete graphs. The results show that our algorithms are usually better in quality than the naive approach. While none of the new algorithms is con- sistently the best one, the DP algorithm can be called most robust since it is always better in quality than the naive approach. A meta algorithm that runs all single algorithms and picks the best solution would still take only about ten seconds per instance and improve the naive approach on average by 13.5% to 20%, depending on the imbalance. In the whole quantum-chemical workflow the total partitioning time of this meta algorithm is still small. Parts of this paper have been published in the proceedings of the 15th International Symposium on Experimental Algorithms (SEA 2016). 2 Problem Description the letter Π and call the subsets fragments in this paper. if the union of the subsets yields V (V =(cid:83) endpoints in different subsets: cutweight(Π, G) =(cid:80) Given an undirected connected graph G = (V, E) with n nodes and m edges, a set of k disjoint non-empty node subsets V1, V2, ...Vk is called a k-partition of G 1≤i≤k Vi). We denote partitions with Let w(u, v) be the weight of edge {u, v} ∈ E, or 1 in an unweighted graph. Then, the cut weight of a graph partition is the sum of the weights of edges with u∈Vi,v∈Vj ,i(cid:54)=j,Vi,Vj∈Π w(u, v). The largest fragment's size should not exceed maxSize := (1 + ) · (cid:100)n/k(cid:101), where  is the so-called imbalance parameter. A partition is balanced iff  = 0. Given a graph G = (V, E) and k ∈ N≥2, graph partitioning is often defined as the problem of finding a k-partition with minimum cut weight while respecting the constraint of maximum imbalance . This problem is NP-hard [10] for gen- eral graphs and values of . For the case of  = 0, no polynomial time algorithm can deliver a constant factor approximation guarantee unless P equals NP [1]. 2.1 Protein Partitioning We represent a protein as a weighted undirected graph. Nodes represent amino acids, edges represent bonds or other interactions. (Note that our graphs are different from protein interaction networks [24].) Edge weights are determined both by the strength of the bond or interaction and the importance of this edge to the protein function. Such a graph can be constructed from the geometrical structure of the protein using chemical heuristics whose detailed discussion is beyond our scope. Partitioning into fragments yields faster running time for DFT since the time required for a fragment is quadratic in its size. The cut weight of a partition corresponds to the total error caused by dividing this protein into fragments. A balanced partition is desirable as it maximizes this acceleration effect. However, relaxing the constraint with a small  > 0 makes sense as this usually helps in obtaining solutions with a lower error. Note that the positions on the main chain define an ordering of the nodes. From now on we assume the nodes to be numbered along the chain. 3 New Constraints. Established graph partitioning tools using the model of the previous section cannot be applied directly to our problem since protein parti- tioning introduces additional constraints and an incompatible scenario due to chemical idiosyncrasies: – The first constraint is caused by so-called cap molecules added for the sub- system calculation. These cap molecules are added at fragment boundaries (only in the DFT, not in our graph) to obtain chemically meaningful frag- ments. This means for the graph that if node i and node i + 2 belong to the same fragment, node i + 1 must also belong to that fragment. Otherwise the introduced cap molecules will overlap spatially and therefore not represent a chemically meaningful structure. We call this the gap constraint. – More importantly, some graph nodes can have a charge. It is difficult to obtain robust convergence in quantum-mechanical calculations for fragments with more than one charge. Therefore, together with the graph a (possibly empty) list of charged nodes is given and two charged nodes must not be in the same fragment. This is called the charge constraint. We consider here two problem scenarios (with different chemical inter- pretations) in the context of protein partitioning: – Partitioning along the main chain: The main chain of a protein gives a natural structure to it. We thus consider a scenario where partition fragments are forced to be continuous on the main chain. This minimizes the number of cap molecules necessary for the simulation and has the additional advantage of better comparability with the naive partition. Formally, the problem can be stated like this: Given a graph G = (V, E) with ascending node IDs according to the node's main chain position, an integer k and a maximum imbalance , find a k-partition with minimum cut weight such that vj ∈ Vi ∧ vj + l ∈ Vi → vj + 1 ∈ Vi, 1 ≤ j ≤ n, l ∈ N+, 1 ≤ i ≤ k and which respects the balance, gap, and charge constraints. – General protein partitioning: The general problem does not require con- tinuous fragments on the main chain, but also minimizes the cut weight while adhering to the balance, gap, and charge constraints. 3 Related Work 3.1 General-purpose graph partitioning General-purpose graph partitioning tools only require the adjacency information of the graph and no additional problem-related information. For special inputs (very small n or k = 2 and small cuts) sophisticated methods from mathematical programming [11] or using branch-and-bound [5] are feasible – and give provably optimal results. To be of general practical use, in particular for larger instances, most widely used tools employ local heuristics within a multilevel approach, though (see the survey by Buluc et al. [2]). 4 The multilevel metaheuristic, popularized for graph partitioning in the mid- 1990s [14], is a powerful technique and consists of three phases: First, one com- putes a hierarchy of graphs G0, . . . , Gl by recursive coarsening in the first phase. Gl ought to be small in size, but topologically similar to the input graph G0. A very good initial solution for Gl is computed in the second phase. After that, the recursive coarsening is undone and the solution prolongated to the next-finer level. In this final phase, in successive steps, the respective prolongated solution on each level is improved using local search. A popular local search algorithm for the third phase of the multilevel process is based on the method by Fiduccia and Mattheyses (FM) [8] (many others exist, see [2]). The main idea of FM is to exchange nodes between blocks in the order of the cost reductions possible, while maintaining a balanced partition. After every node has been moved once, the solution with the best cost improvement is chosen. Such a phase is repeated several times, each running in time O(m). 3.2 Methods for subsystem quantum chemistry While this work is based on the molecular fractionation with conjugate cap (MFCC) scheme [31,13], several more sophisticated approaches have been de- veloped which allow to decrease the size of the error in subsystem quantum- mechanical calculations [7,6,16]. The general idea is to reintroduce the interac- tions missed by the fragmentation of the supermolecule. A prominent example is the frozen density embedding (FDE) approach [30,17,16]. All these methods strongly depend on the underlying fragmentation of the supermolecule and it is therefore desirable to minimize the error in the form of the cut weight itself. Thus, the implementation shown in this paper is applicable to all quantum-chemical subsystem methods needing molecule fragments as an input. 4 Solving Main Chain Partitioning Optimally As discussed in the introduction, a protein consists of a main chain, which is folded to yield its characteristic spatial structure. Aligning a partition along the main chain uses the locality information in the node order and minimizes the number of cap molecules necessary for a given number of fragments. The problem description from Section 2 – finding fragments with continuous node IDs – is equivalent to finding a set of k − 1 delimiter nodes vd1 , vd2, ...vdk−1 that separate the fragments. Note that this is not a vertex separator, instead the delimiter nodes induce a set of cut edges due to the continuous node IDs. More precisely, delimiter node vdj belongs to fragment j, 1 ≤ j ≤ k − 1. Consider the delimiter nodes in ascending order. Given the node vd2, the optimal placement of node vd1 only depends on edges among nodes u < vd2, since all edges {u, v} from nodes u < vd2 to nodes v > vd2 are cut no matter where vd1 is placed. Placing node vd2 thus induces an optimal placement for vd1, using only information from edges to nodes u < vd2 . With this dependency of the positions of vd1 and vd2 , placing node vd3 similarly induces an optimal choice 5 for vd2 and vd1 , using only information from nodes smaller than vd3 . The same argument can be continued inductively for nodes vd4 . . . vdk . Algorithm 1 is our dynamic-programming-based solution to the main chain partitioning problem. It uses the property stated above to iteratively compute the optimal placement of vdj−1 for all possible values of vdj . Finding the optimal placements of vd1, . . . vdj−1 given a delimiter vdj at node i is equivalent to the subproblem of partitioning the first i nodes into j fragments, for increasing values of i and j. If n nodes and k fragments are reached, the desired global solution is found. We allocate (Line 3) and fill an n × k table partCut with the optimal values for the subproblems. More precisely, the table entry partCut[i][j] denotes the minimum cut weight of a j-partition of the first i nodes: Lemma 1. After the execution of Algorithm 1, partCut[i][j] contains the mini- mum cut value for a continuous j-partition of the first i nodes. If such a partition is impossible, partCut[i][j] contains ∞. We prove the lemma after describing the algorithm. After the initialization of data structures in Lines 2 and 3, the initial values are set in Line 4: A partition consisting of only one fragment has a cut weight of zero. All further partitions are built from a predecessor partition and a new frag- ment. A j-partition Πi,j of the first i nodes consists of the jth fragment and a (j − 1)-partition with fewer than i nodes. A valid predecessor partition of Πi,j is a partition Πl,j−1 of the first l nodes, with l between i − maxSize and i − 1. Node charges have to be taken into account when compiling the set of valid predecessors. If a backwards search for Πi,j from node i encounters two charged nodes a and b with a < b, all valid predecessors of Πi,j contain at least node a (Line 7). The additional cut weight induced by adding a fragment containing the nodes [l + 1, i] to a predecessor partition Πl,j−1 is the weight sum of edges connecting nodes in [1, l] to nodes in [l+1, i]: c[l][i] =(cid:80){u,v}∈E,u∈[1,l],v∈[l+1,i] w(u, v). Line 8 computes this weight difference for the current node i and all valid predecessors l. For each i and j, the partition Πi,j with the minimum cut weight is then found in Line 10 by iterating backwards over all valid predecessor partitions and selecting the one leading to the minimum cut. To reconstruct the partition, we store the predecessor in each step (Line 11). If no partition with the given values is possible, the corresponding entry in partCut remains at ∞. After the table is filled, the resulting minimum cut weight is at partCut[n][k], the corresponding partition is found by following the predecessors (Line 16). We are now ready to prove Lemma 1 and the algorithm's correctness and time complexity. Proof (of Lemma 1). By induction over the number of partitions j. Base Case: j = 1,∀i. A 1-partition is a continuous block of nodes. The cut value is zero exactly if the first i nodes contain at most one charge and i is not larger than maxSize. This cut value is written into partCut in Lines 3 and 4 and not changed afterwards. 6 Algorithm 1: Main Chain Partitioning with Dynamic Programming Input: Graph G = (V, E), fragment count k, bool list isCharged, imbalance  Output: partition Π 1 maxSize= (cid:100)V /k(cid:101) · (1 + ); 2 allocate empty partition Π; 3 partCut[i][j] = ∞,∀i ∈ [1, n],∀j ∈ [1, k]; 4 partCut[i][1] = 0, ∀i ∈ [1, maxSize]; 5 for 1 ≤ i ≤ n do /* initialize empty table partCut with n rows and k columns */ windowStart = max(i − maxSize, 1); if necessary, increase windowStart so that [windowStart, i] contains at most one charged node; compute column i of cut cost table c; for 2 ≤ j ≤ k do partCut[i][j] = minl∈[windowStart,i] partCut[l][j − 1] + c[l][i]; pred[i][j] = argminl∈[windowStart,i] partCut[l][j − 1] + c[l][i]; 6 7 8 9 10 11 16 17 end 12 13 end 14 i = n; 15 for j = k; j ≥ 2; j− = 1 do nextI = pred[i][j]; assign nodes between nextI and i to fragment Πj; i = nextI ; 18 19 end 20 return Π Inductive Step: j − 1 → j. Let i be the current node: A cut-minimal j-partition Πi,j for the first i nodes contains a cut-minimal (j − 1)-partition Πi(cid:48),j−1 with continuous node blocks. If Πi(cid:48),j−1 were not minimum, we could find a better partition Π(cid:48) i(cid:48),j−1 and use it to improve Πi,j, a contradiction to Πi,j being cut- minimal. Due to the induction hypothesis, partCut[l][j−1] contains the minimum cut value for all node indices l, which includes i(cid:48). The loop in Line 10 iterates over possible predecessor partitions Πl,j−1 and selects the one leading to the minimum cut after node i. Given that partitions for j − 1 are cut-minimal, the partition whose weight is stored in partCut[i][j] is cut-minimal as well. If no allowed predecessor partition with a finite weight exists, partCut[i][j] (cid:117)(cid:116) remains at infinity. Theorem 1. Algorithm 1 computes the optimal main chain partition in time O(n2 · maxSize). Proof. The correctness in terms of optimality follows directly from Lemma 1. We thus continue with establishing the time complexity. The nested loops in Lines 5 and 9 require O(n · k) iterations in total. Line 7 is executed n times and has a complexity of maxSize. At Line 10 in the inner loop, up to maxSize predecessor partitions need to be evaluated, each with two constant time table accesses. 7 Computing the cut weight column c[·][i] for fragments ending at node i (Line 8) involves summing over the edges of O(maxSize) predecessors, each having at most O(n) neighbors. Since the cut weights constitute a reverse prefix sum, the column c[·][i] can be computed in O(n · maxSize) time by iterating backwards. Line 8 is executed n times, leading to a total complexity of O(n2 · maxSize). Following the predecessors and assigning nodes to fragments is possible in linear time, thus the O(n2 · maxSize) to compile the cut cost table dominates the (cid:117)(cid:116) running time. 5 Algorithms for General Protein Partitioning As discussed in Section 2, one cannot use general-purpose graph partitioning programs due to the new constraints required by the DFT calculations. More- over, if the constraint of the previous section is dropped, the DP-based algorithm is not optimal in general any more. Thus, we propose three algorithms for the general problem in this section: The first two, a greedy agglomerative method and Multilevel-FM, build on existing graph partitioning knowledge but incorpo- rate the new constraints directly into the optimization process. The third one is a simple postprocessing repair procedure that works in many cases. It takes the output of a traditional graph partitioner and fixes it so as to fulfill the constraints. 5.1 Greedy Agglomerative Algorithm The greedy agglomerative approach, shown in Algorithm 2 in Appendix B, is similar in spirit to Kruskal's MST algorithm and to approaches proposed for clustering graphs with respect to the objective function modularity [3]. It initially sorts edges by weight and puts each node into a singleton fragment. Edges are then considered iteratively with the heaviest first; the fragments belonging to the incident nodes are merged if no constraints are violated. This is repeated until no edges are left or the desired fragment count is achieved. The initial edge sorting takes O(m log m) time. Initializing the data struc- tures is possible in linear time. The main loop (Line 5) has at most m iterations. Checking the size and charge constraints is possible in constant time by keeping arrays of fragment sizes and charge states. The time needed for checking the gaps and merging is linear in the fragment size and thus at most O(maxSize). The total time complexity of the greedy algorithm is thus: T (Greedy) ∈ O(m · max{maxSize, log m}). 5.2 Multilevel Algorithm with Fiduccia-Mattheyses Local Search Algorithm 3 (Appendix B) is similar to existing multilevel partitioners using non-binary (i. e. k > 2) Fiduccia-Mattheyses (FM) local search. Our adapta- tion incorporates the constraints throughout the whole partitioning process, 8 though. First a hierarchy of graphs G0, G1, . . . Gl is created by recursive coars- ening (Line 1). The edges contracted during coarsening are chosen with a local matching strategy. An edge connecting two charged nodes stays uncontracted, thus ensuring that a fragment contains at most one charged node even in the coarsest partitioning phase. The coarsest graph is then partitioned into Πl using region growing or recursive bisection. If an optional input partition Π(cid:48) is given, it is used as a guideline during coarsening and replaces Πl if it yields a better cut. We execute both our greedy and DP algorithm and use the partition with the better cut as input partition Π(cid:48) for the multilevel algorithm. After obtaining a partition for the coarsest graph, the graph is iteratively uncoarsened and the partition projected to the next finer level. We add a rebal- ancing step at each level (Line 6), since a non-binary FM step does not guaran- tee balanced partitions if the input is imbalanced. A Fiduccia-Mattheyses step is then performed to yield local improvements (Line 10): For a partition with k fragments, this non-binary FM step consists of one priority queue for each frag- ment. Each node v is inserted into the priority queue of its current fragment, the maximum gain (i. e. reduction in cut weight when v is moved to another frag- ment) is used as key. While at least one queue is non-empty, the highest vertex of the largest queue is moved if the constraints are still fulfilled, and the movement recorded. After all nodes have been moved, the partition yielding the minimum cut is taken. In our variant, nodes are only moved if the charge constraint stays fulfilled. 5.3 Repair Procedure As already mentioned, traditional graph partitioners produce in general solutions that do not adhere to the constraints for protein partitioning. To be able to use existing tools, however, we propose a simple repair procedure for an existing partition which possibly does not fulfill the charge, gap, or balance constraints. To this end, Algorithm 4 in Appendix B performs one sweep over all nodes (Line 6) and checks for every node v whether the constraints are violated at this point. If they are and v has to be moved, an FM step is performed: Among all fragments that could possibly receive v, the one minimizing the cut weight is selected. If no suitable target fragment exists, a new singleton fragment is created. Note that due to the local search, this step can lead to more than k fragments, even if a partition with k fragments is possible. The cut weight table allocated in Line 1 takes O(n · k + m) time to create. Whether a constraint is violated can be checked in constant time per node by counting the number of nodes and charges observed for each fragment. A node needs to be moved when at least one charge or at least maxSize nodes have already been encountered in the same fragment. Finding the best target partition (Line 13) takes O(k) iterations, updating the cut weight table after moving a node v is linear in the degree deg(v) of v. The total time complexity of a repair step is thus: O(n · k + m + n · k +(cid:80) v deg(v)) = O(n · k + m). 9 6 Experiments 6.1 Settings We evaluate our algorithms on graphs derived from several proteins and com- pare the resulting cut weight. As main chain partitioning is a special case of general protein partitioning, the solutions generated by our dynamic program- ming algorithm are valid solutions of the general problem, though perhaps not optimal. Other algorithms evaluated are Algorithm 2 (Greedy), 3 (Multilevel), and the external partitioner KaHiP [26], used with the repair step discussed in Section 5.3. The algorithms are implemented in C++ and Python using the NetworKit tool suite [27], the source code is available from a hg repository3. We use graphs derived from five common proteins, covering the most frequent structural properties. Ubiquitin [25] (also see Figure 3 in Appendix A) and the Bubble Protein [22] are rather small proteins with 76 and 64 amino acids, respec- tively. Due to their biological functions, their overall size and their diversity in the contained structural features, they are commonly used as test cases for quantum- chemical subsystem methods [19]. The Green Fluorescent Protein (GFP) [23] plays a crucial role in the bioluminescence of marine organisms and is widely expressed in other organisms as a fluorescent label for microscopic techniques. Like the latter one, Bacteriorhodopsin (bR) [20] and the Fenna-Matthews-Olson protein (FMO) [29] are large enough to render quantum-chemical calculations on the whole proteins practically infeasible. Yet, investigating them with quantum- chemical methods is key to understanding the photochemical processes they are involved in. The graphs derived from the latter three proteins have 225, 226 and 357 nodes, respectively. They are complete graphs with weighted n(n− 1)/2 edges. All instances can be found in the mentioned hg repository in folder input/. In our experiments we partition the graphs into fragments of different sizes (i. e. we vary the fragment number k). The small proteins ubiquitin and bubble are partitioned into 2, 4, 6 and 8 fragments, leading to fragments of average size 8-38. The other proteins are partitioned into 8, 12, 16, 20 and 24 fragments, yielding average sizes between 10 and 45. As maximum imbalance, we use values for  of 0.1 and 0.2. While this may be larger than usual values of  in graph partitioning, fragment sizes in our case are comparably small and an imbalance of 0.1 is possibly reached with the movement of a single node. On these proteins, the running time of all partitioning implementations is on the order of a few seconds on a commodity laptop, we therefore omit detailed time measurements. Charged Nodes. Depending on the environment, some of the amino acids are charged. As discussed in Section 2, at most one charge is allowed per fragment. We repeatedly sample (cid:98)0.8 · k(cid:99) random charged nodes among the potentially charged, under the constraint that a valid main chain partition is still possible. To smooth out random effects, we perform 20 runs with different random nodes 3 https://algohub.iti.kit.edu/parco/NetworKit/NetworKit-chemfork/ 10 charged. Introducing charged nodes may cause the naive partition to become invalid. In these cases, we use the repair procedure on the invalid naive partition and compare the cut weights of other algorithms with the cut weight of the repaired naive partition. 6.2 Results For the uncharged scenario, Figure 1 shows a comparison of cut weights for dif- ferent numbers of fragments and a maximum imbalance of 0.1. The cut weight is up to 34.5% smaller than with the naive approach (or 42.8% with  = 0.2, see Figure 5). The best algorithm choice depends on the protein: For ubiqui- tin, green fluorescent protein, and Fenna-Matthew-Olson protein, the external partitioner KaHiP in combination with the repair step described in Section 5.3 gives the lowest cut weight when averaged over different fragment sizes. For the bubble protein, the multilevel algorithm from Section 5.2 gives on average the best result, while for bacteriorhodopsin, the best cut weight is achieved by the dynamic programming (DP) algorithm. The DP algorithm is always as least as good as the naive approach. This already follows from Theorem 1, as the naive partition is aligned along the main chain and thus found by DP in case it is optimal. DP is the only algorithm with this property, all others perform worse than the naive approach for at least one combination of parameters. The general intuition that smaller fragment sizes leave less room for improve- ments compared to the naive solution is confirmed by our experimental results. Figure 5 (Appendix A) shows the comparison with imbalance  = 0.2. While the general trend is similar and the best choice of algorithm depends on the protein, the cut weight is usually more clearly improved. Moreover, a meta algorithm that executes all single algorithms and picks their best solution yields average improvements (geometric mean) of 13.5%, 16%, and 20% for  = 0.1, 0.2, and 0.3, respectively, compared to the naive reference. Such a meta algorithm requires only about ten seconds per instance, negligible in the whole DFT workflow. Randomly charging nodes changes the results only insignificantly, as seen in Figure 6. The necessary increase in cut weight for the algorithm's solutions is likely compensated by a similar increase in the naive partition due to the necessary repairs. 7 Conclusions Partitioning protein graphs for subsystem quantum-chemistry is a new problem with unique constraints which general-purpose graph partitioning algorithms were unable to handle. We have provided several algorithms for this problem and proved the optimality of one in the special case of partitioning along the main chain. With our algorithms chemists are now able to address larger problems in an automated manner with smaller error. Larger proteins, in turn, in connection with a reasonable imbalance, may provide more opportunities for improving the quality of the naive solution further. 11 Fig. 1. Comparison of partitions given by several algorithms and proteins, for  = 0.1. The partition quality is measured by the cut weight in comparison to the naive solution. 12 24680.60.70.80.911.11.2kcutweightUbiquitinMLGreedyKaHiPDP24680.60.70.80.911.11.2kcutweightBubble812162024kBacteriorhodopsin8121620240.60.70.80.911.11.2kcutweightGreenFluorescentProtein812162024kFenna-Matthews-Olson References 1. Konstantin Andreev and Harald Racke. Balanced graph partitioning. Theory of Computing Systems, 39(6):929–939, 2006. 2. Aydin Bulu¸c, Henning Meyerhenke, Ilya Safro, Peter Sanders, and Christian Schulz. Recent advances in graph partitioning. Accepted as Chapter in Algorithm Engineering, Overview Paper concerning the DFG SPP 1307, 2016. Preprint avail- able at http://arxiv.org/abs/1311.3144. 3. A. Clauset, M.E.J. Newman, and C. Moore. Finding community structure in very large networks. Physical Review E, 70(6):66111, 2004. 4. Christopher J. Cramer. Essentials of Computational Chemistry. Wiley, New York, 2002. 5. Daniel Delling, Daniel Fleischman, Andrew V. Goldberg, Ilya Razenshteyn, and Renato F. Werneck. An exact combinatorial algorithm for minimum graph bisec- tion. Math. Program., 153(2):417–458, 2015. 6. Dmitri G. Fedorov and Kazuo Kitaura. Extending the Power of Quantum Chem- istry to Large Systems with the Fragment Molecular Orbital Method. J. Phys. Chem. A, 111:6904–6914, 2007. 7. Dmitri G. Fedorov, Takeshi Nagata, and Kazuo Kitaura. Exploring chemistry with the fragment molecular orbital method. Phys. Chem. Chem. Phys., 14:7562–7577, 2012. 8. C. Fiduccia and R. Mattheyses. A linear time heuristic for improving network partitions. In Proc. 19th ACM/IEEE Design Automation Conf., pages 175–181, Las Vegas, NV, June 1982. 9. C. Fonseca Guerra, J. G. Snijders, G. te Velde, and E. J. Baerends. Towards an order-N DFT method. Theor. Chem. Acc., 99:391, 1998. 10. M. R. Garey, D. S. Johnson, and L. Stockmeyer. Some simplified NP-complete problems. In Proceedings of the 6th Annual ACM Symposium on Theory of Com- puting (STOC'74), pages 47–63. ACM Press, 1974. 11. Bissan Ghaddar, Miguel F. Anjos, and Frauke Liers. A branch-and-cut algorithm based on semidefinite programming for the minimum k -partition problem. Annals OR, 188(1):155–174, 2011. 12. Mark S. Gordon, Dmitri G. Fedorov, Spencer R. Pruitt, and Lyudmila V. Slipchenko. Fragmentation Methods: A Route to Accurate Calculations on Large Systems. Chem. Rev., 112:632–672, 2012. 13. Xiao He, Tong Zhu, Xianwei Wang, Jinfeng Liu, and John Z. H. Zhang. Fragment Quantum Mechanical Calculation of Proteins and Its Applications. Acc. Chem. Res., 47:2748–2757, 2014. 14. B. Hendrickson and R. Leland. A multi-level algorithm for partitioning graphs. In Proceedings Supercomputing '95, page 28 (CD). ACM Press, 1995. 15. Christoph R Jacob, S. Maya Beyhan, Rosa E Bulo, Andr´e Severo Pereira Gomes, Andreas W Gotz, Karin Kiewisch, Jetze Sikkema, and Lucas Visscher. PyADF - A scripting framework for multiscale quantum chemistry. J. Comput. Chem., 32:2328–2338, 2011. 16. Christoph R. Jacob and Johannes Neugebauer. Subsystem density-functional the- ory. WIREs Comput. Mol. Sci., 4:325–362, 2014. 17. Christoph R. Jacob and Lucas Visscher. A subsystem density-functional the- ory approach for the quantum chemical treatment of proteins. J. Chem. Phys., 128:155102, 2008. 13 18. Frank Jensen. Introduction to Computational Chemistry. Wiley & Sons, Chichester, 2nd edition, 2007. 19. Karin Kiewisch, Christoph R. Jacob, and Lucas Visscher. Quantum-Chemical Elec- tron Densities of Proteins and of Selected Protein Sites from Subsystem Density Functional Theory. J. Chem. Theory Comput., 9:2425–2440, 2013. 20. Janos K. Lanyi and Brigitte Schobert. Structural changes in the l photointer- mediate of bacteriorhodopsin. Journal of Molecular Biology, 365(5):1379 – 1392, 2007. 21. Christian Ochsenfeld, Jorg Kussmann, and D. S. Lambrecht. Linear-Scaling Meth- ods in Quantum Chemistry. In Reviews in Computational Chemistry, volume 23, pages 1–82. Wiley-VCH, New York, 2007. 22. Johan Gotthardt Olsen, Claus Flensburg, Ole Olsen, Gerard Bricogne, and Anette Henriksen. Solving the structure of the bubble protein using the anomalous sulfur signal from single-crystal in-house CuKα diffraction data only. Acta Crystallo- graphica Section D, 60(2):250–255, 2004. 23. Mats Ormo, Andrew B. Cubitt, Karen Kallio, Larry A. Gross, Roger Y. Tsien, and S. James Remington. Crystal structure of the aequorea victoria green fluorescent protein. Science, 273(5280):1392–1395, 1996. 24. Georgios A. Pavlopoulos, Maria Secrier, Charalampos N. Moschopoulos, Theodoros G. Soldatos, Sophia Kossida, Jan Aerts, Reinhard Schneider, and Pan- telis G. Bagos. Using graph theory to analyze biological networks. BioData Mining, 4(1):1–27, 2011. 25. R. Ramage, J. Green, T. W. Muir, O. M. Ogunjobi, S. Love, and K. Shaw. Syn- thetic, structural and biological studies of the ubiquitin system: the total chemical synthesis of ubiquitin. Biochemical Journal, 299(1):151–158, 1994. 26. Peter Sanders and Christian Schulz. Think Locally, Act Globally: Highly Balanced Graph Partitioning. In Proceedings of the 12th International Symposium on Ex- perimental Algorithms (SEA'13), volume 7933 of LNCS, pages 164–175. Springer, 2013. 27. Christian Staudt, Aleksejs Sazonovs, and Henning Meyerhenke. NetworKit: An interactive tool suite for high-performance network analysis. CoRR, abs/1403.3005, 2014. 28. Theoretical Chemistry, Vrije Universiteit Amsterdam. Adf, Amsterdam density functional program. URL: http://www.scm.com. 29. Dale E. Tronrud and James P. Allen. Reinterpretation of the electron density at the site of the eighth bacteriochlorophyll in the fmo protein from pelodictyon phaeum. Photosynthesis Research, 112(1):71–74, 2012. 30. Tomasz Adam Wesolowski and Jacques Weber. Kohn-Sham equations with con- strained electron density: an iterative evaluation of the ground-state electron den- sity of interaction molecules. Chem. Phys. Lett., 248:71–76, 1996. 31. Da W. Zhang and J. Z. H. Zhang. Molecular fractionation with conjugate caps for full quantum mechanical calculation of protein–molecule interaction energy. J. Chem. Phys., 119:3599–3605, 2003. 14 Appendix A Illustrations and Additional Experimental Results ] . u . b r a [ r o r r e 650 600 550 500 450 400 2 4 6 8 10 number of amino acids in fragment Fig. 2. Predicted error for interaction energies with naive fragmentation every X amino acids for the small protein ubiquitin. Unpredictable minima and maxima depending on the location of the uniformly distributed cuts occur along the main chain. 15 Fig. 3. 3D-Visualization of Ubiquitin. Single amino acids in different colors. Helical secondary structure at the bottom, beta-sheet like secondary structures in the upper left and right. Measured (1.15n2 + 3.63n + 1.44)s s d n o c e s 150 100 50 0 2 4 6 8 10 number of amino acids in fragment Fig. 4. Time in seconds required for quantum chemical density functional (DFT, BP86, DZP) calculations of protein fragments on 16 Intel Xeon cores (2x Haswell- EP/2640v3/2.6 GHz) executed with pyADF [15] and ADF program package [28]. As seen by the close match of the red fit line, time grows quadratically. 16 Fig. 5. Comparison of cut weights for  = 0.2. 17 24680.60.70.80.911.11.2kcutweightUbiquitinMLGreedyKaHiP+RepairDP24680.60.70.80.911.11.2kcutweightBubble812162024kBacteriorhodopsin8121620240.60.70.80.911.11.2kcutweightGreenFluorescentProtein812162024kFenna-Matthews-Olson Fig. 6. Comparison of cut weights for  = 0.1 and node charges. 18 24680.60.70.80.911.11.2kcutweightUbiquitinMLGreedyKaHiP+RepairDP24680.60.70.80.911.11.2kcutweightBubble812162024kBacteriorhodopsin8121620240.60.70.80.911.11.2kcutweightGreenFluorescentProtein812162024kFenna-Matthews-Olson B Additional Pseudocodes Algorithm 2: Greedy Agglomerative Algorithm Input: Graph G = (V, E), fragment count k, list charged, imbalance  Output: partition Π 1 sort edges by weight, descending; 2 Π = create one singleton partition for each node; 3 chargedPartitions = partitions containing a charged node; 4 maxSize= (cid:100)V /k(cid:101) · (1 + ); 5 for edge {u, v} do allowed = True; if Π[u] ∈ chargedPartitions and Π[v] ∈ chargedPartitions then 7 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 allowed = False; end if Π[u] + Π[v] > maxSize then allowed = False; end for node x ∈ Π[u] ∪ Π[v] do if x + 2 ∈ Π[u] ∪ Π[v] and x + 1 (cid:54)∈ Π[u] ∪ Π[v] then allowed = False; end end if allowed then merge Π[u] and Π[v]; update chargedPartitions; end if number of fragments in Π equals k then break; end 24 25 end 26 return Π 19 Algorithm 3: Multilevel-FM Input: Graph G = (V, E), fragment count k, list charged, imbalance , [Π(cid:48)] Output: partition Π 1 G0, . . . , Gl = hierarchy of coarsened Graphs, G0 = G; 2 Πl = partition Gl with region growing or recursive bisection; 3 for 0 ≤ i < l do uncoarsen Gi from Gi+1; Πi = projected partition from Πi+1; rebalance Πi, possibly worsen cut weight; /* Local improvements gain = NaN; repeat oldcut = cut(Π(cid:48) Π(cid:48) gain = cut(Π(cid:48) until gain == 0 ; i, G) - oldcut; i, G); i = Fiduccia-Mattheyses-Step of Πi with constraints; 4 5 6 7 8 9 10 11 12 13 end Algorithm 4: Repairing a partition Input: Graph G = (V, E), k-partition Π, list charged, imbalance  Output: partition Π(cid:48) 1 cutWeight[i][j] = 0, 1 ≤ i ≤ n, 1 ≤ j ≤ k; 2 for edge {u, v} in E do 3 cutWeight[u][Π(u)]+ = w(u, v); cutWeight[v][Π(v)]+ = w(u, v); 4 5 end 6 for node v in V do /* Check whether node can stay if charge violated or size violated or gap of size 1 then Ψ = set of allowed target fragments; if Ψ is empty then create new fragment for v; end else /* Fiduccia-Mattheyses-step: To minimize the cut weight, move the node to the fragment to which it has the strongest connection target = argmaxi∈Ψ{cutWeight[v][i]}; move v to target; end update charge counter, size counter and cutWeight; 7 8 9 10 11 12 13 14 15 16 end 17 18 end 20 */ */ */
1906.01056
1
1906
2019-05-08T20:11:52
A separator-based method for generating weakly chordal graphs
[ "cs.DS" ]
We propose a scheme for generating a weakly chordal graph on n vertices with m edges. In this method, we first construct a tree and then generate an orthogonal layout (which is a weakly chordal graph on the n vertices) based on this tree. In the next and final step, we insert additional edges to give us a weakly chordal graph on m edges. Our algorithm ensures that the graph remains weakly chordal after each edge is inserted. The time complexity of an insertion query is O(n^3) time and an insertion takes constant time. On the other hand, a generation algorithm based on finding a 2-pair takes O(nm) time using the algorithm of Arikati and Rangan [1].
cs.DS
cs
A Separator-based Method for Generating Weakly Chordal Graphs Md. Zamilur Rahman Asish Mukhopadhyay School of Computer Science School of Computer Science University of Windsor Windsor, Canada University of Windsor Windsor, Canada Yash P. Aneja Odette School of Business University of Windsor Windsor, Canada Abstract We propose a scheme for generating a weakly chordal graph on n vertices with m edges. In this method, we first construct a tree and then generate an orthogonal layout (which is a weakly chordal graph on the n vertices) based on this tree. In the next and final step, we insert additional edges to give us a weakly chordal graph on m edges. Our algorithm ensures that the graph remains weakly chordal after each edge is inserted. The time complesity of an insertion query is O(n3) time and an insertion takes constant time. On the other hand, a generation algorithm based on finding a 2-pair takes O(nm) time using the algorithm of Arikati and Rangan [1]. 1 Introduction In this paper G = (V, E) will be used to denote a graph with V = n vertices and E = m edges. G is chordal if it has no chordless cycles of size four or more. However, as the following example shows (Figure 1), its complement G can contain chordless 4-cycles. c b d a (a) G e f c f a d (b) G e b Figure 1: Complement of a chordal graph with a chordless 4-cycle 1 This suggested the generalization of chordal graphs to weakly chordal (or weakly triangulated) graphs as those graphs G such that neither G nor its complement G contains chordless cycles of size five or greater [3]. From the symmetry of the definition it follows that G is also weakly chordal. Figure 2 shows an example of a weakly chordal graph (G) along with its complement (G). v1 v2 v2 v1 v6 v3 v6 v3 v5 v4 (a) G v4 v5 (b) G Figure 2: Weakly chordal graph In this paper we address the algorithmic problem of generating weakly chordal graphs. While the problem of generating graphs uniformly at random has received much attention (see [11], [12], [13], [7]), little is known about this problem. There are many situations where we would like to generate in- stances of these to test algorithms for weakly chordal graphs. For instance, in [8] the authors generate all linear layouts of weakly chordal graphs. A generation mechanism can be used to provide input instances for this algorithm. An edge e in G is peripheral if it is not the middle edge of a chordless path P4 spanning four vertices of G. In [4], Hayward proposed the following constructive characterization of weakly chordal graphs, based on the notion of a peripheral edge. Theorem 1.1 [4] A graph is weakly chordal if and only if it can be generated in the following manner: 1. Start with an empty graph G0. 2. Repeatedly add an edge ej to the graph Gj−1 to create the graph Gj such that ej is a peripheral edge of Gj. This is analogous to a similar characterization for chordal graphs by Fulkerson and Gross [2]. No details were provided as to how to decide if an edge is peripheral and the complexity of the generation method. The proof of this theorem uses the notion of a two-pair and a generation method can be devised based on this. A pair of vertices {u, v} in G is a two-pair if the only chordless paths between the u and v are of length 2. Interestingly enough, a weakly chordal graph that is not a clique has a two-pair [5]. Furthermore, let {u, v} be a two-pair in an arbitrary graph G. Then G + {u, v} is weakly chordal iff G is weakly chordal [10]. We can then generate a weakly chordal graph on n vertices by starting with a tree (which trivially satisfies the definition of weak chordality) and repeatedly find a two-pair {u, v} and add to G the edge joining u to v. To find a two-pair we can use an O(mn) algorithm due to Arikati and Rangan [1]. Unfortunately, this does not allow us to exploit the structural properties of a weakly chordal graph. Thus in this paper we propose a separator-based strategy that generalizes an algorithm due to Markenzon [6] for generating chordal graphs and allows us to exploit the structural properties of a weakly triangulated graph. 2 The paper is organized thus. In the next section, we collect in one place some common graph- theoretic terminology used throughout the paper and also add a brief review of Markenzon's in- cremental method [6] for generating chordal graphs. The following section contains details of our algorithm, beginning with a brief overview. The final section contains some concluding remarks and suggestions for further research. 1.1 Preliminaries For a given G, let n = V and m = E. The neighborhood of a vertex v is denoted as N (v) where N (v) = {u ∈ V : (u, v) ∈ E}. The closed neighborhood of a vertex v, denoted by N [v] is N (v) ∪ v. The complement of a graph G, denoted by G, contains the same set of vertices such that two vertices of G are adjacent iff they are not adjacent in G. The graph G in Fig 2(b) is the complement of the graph G (Fig 2(a)). For any vertex set S ⊆ V , the edge set E(S) ⊆ E is defined to be E(S) = {(u, v) ∈ E(u, v) ∈ S}. Let G[S] denote the subgraph of G induced by S, namely the subgraph (S, E(S)). In other words, an induced subgraph is a subset of the vertices of a graph G together with any edges whose endpoints are both in this subset. A path in a graph G is a sequence of vertices vi, vi+1, . . . ., vk, where {vj, vj+1} for j = i, i + 1, . . . ., k − 1, is an edge of G. The first vertex is known as the start vertex, the last vertex is called the end vertex, and the remaining vertices in the path are known as internal vertices. A cycle is a closed path where the start vertex and the end vertex coincide. The size of a cycle is the number of edges in it. A clique in G is a subset of vertices (S ⊆ V ) of G such that the induced subgraph G[S] is complete. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. A graph on n vertices that forms a clique on n vertices is called a complete graph (Kn). Based on the given n and m, Markenzon's method starts by generating a labeled tree on n vertices using Prufer's scheme [9]. Next, an edge is inserted in each iteration to reach m. The algorithm picks a pair of vertices {u, v} and checks whether v is reachable from u on the induced graph G[S], where S = V − Iu,v and Iu,v = N (u) ∩ N (v). If G[S] is connected, then a path exists between u and v and thus G + {u, v} is not chordal; otherwise, the augmented graph G + {u, v} is chordal. To make the search for a path efficient, the method reduces the set S from V − Iu,v to N (x) − Iu,v, for any x ∈ Iu,v. The correctness of the algorithm was established by proving the following theorem. Theorem 1.2 [6] Let G = (V, E) be a connected chordal graph and u, v ∈ V, (u, v) /∈ E. The augmented graph G + {u, v} is chordal if and only if G[V − Iu,v] is not connected. 2 Generation of Weakly Chordal Graphs 2.1 Overview of the Method Just as in Markenzon's incremental method for chordal graphs, we take as input the number of vertices, n, and the number of edges, m, of the weakly chordal graph G to be generated. Our proposed method starts with generating a tree. With the help of a tree, we construct an orthogonal layout made up of 4-cycles, each cycle corresponding to a node of this tree. We then insert additional edges into this initial layout to ensure that the final graph has m edges. Trees are weakly chordal graphs and so is the initial orthogonal layout of the 4-cycles. Additional edges are introduced to 3 reach the target value of m by picking a pair of vertices u and v at random and checking if the augmented graph G + {u, v} remains weakly chordal. If u and v have some common neighbors (Iu,v 6= ∅), we remove those common neighbors and check whether the removal of the common neighbors separates u and v, leaving them in different components. We create an induced graph on a set of vertices called AuxN odes that contain the neighbors of neighbors of Iu,v to check whether u and v are in different components. If so we insert an edge between u and v, else we search for shortest paths between u and v. We do not insert the edge {u, v} if the length of the shortest path is greater than 3. Otherwise, we have to check for other conditions, such as single or multiple P3 (P3 denotes a path of length 3), forbidden configurations, alternate longer paths between u and v to decide whether the insertion of {u, v} preserves weak chordality. If there are no common neighbors (Iu,v = ∅) between u and v, we apply the same rules to this case as when Iu,v does not separate u and v (as explained in the previous paragraph). The only difference is that here we have to consider the entire graph to search for shortest paths between u and v but the other subsequent steps remain the same. All the phases of this generation method are explained in full details in the next subsections. 2.2 Phase 1: Generation of Tree We generate a tree, T , on ⌈ n 2 ⌉ nodes that each node is of degree-4 at most as follows. Starting with a single node, we add new ones either by splitting an edge into two or joining a new node to one of the existing nodes, chosen at random. After ⌈ n 2 ⌉ nodes, have been added, we traverse the tree to check for adjacent degree-4 nodes. If such a pair is found, we separate them by introducing a new node adjacent to both. We define k as the number of nodes in the tree (T ). 2.3 Phase 2: Generation of Initial Layout In this phase, we generate an orthogonal initial layout of T . For each node in T , we create a four- cycle. Figure 3(a) shows a tree T with two nodes, a and b. For node a in the tree, we generate a four-cycle and for node b we generate another four-cycle adjacent to the existing four-cycle because node a is adjacent to node b in the tree. The corresponding layout is shown in Figure 3(b). We define this as the initial layout. For the example tree of Figure 3(c), the corresponding initial layout is shown in Figure 3(d). As explained in the first phase, after generating a tree, if two degree-4 nodes are adjacent, we insert a new node between them to separate them (see Figure 3(e), (f), and (g)). Since a four-cycle has only four sides, two degree-4 nodes cannot be adjacent. As we are interested in generating proper weakly chordal graphs (and not just chordal graphs), we want to have four-cycles in the initial layout. At this point, if the orthogonal layout has more than n vertices, we delete vertices from four cycles to make it equal to n. To delete a vertex, we select vertices having degree at most two. If the number of edges in the initial layout is greater than or equal to the given m, the algorithm stops and returns the layout as a weakly chordal graph. Otherwise, it takes the difference of the number of edges and inserts that many edges in the initial layout to produce a weakly chordal graph. Now we denote the number of edges as m′ in the initial orthogonal layout. 4 b a (a) Tree (T1) c h b a (b) Initial Layout (G1) b g b a f a d e (e) Tree (T3) c e d a b c a e d (c) Tree (T2) (d) Initial Layout (G2) i h e f g b c a d i h f e g b c d (f) Tree (T ′ 3) (g) Initial Layout (G3) Figure 3: Tree to layout (four-cycles) 2.4 Phase 3: Generation of Weakly Chordal Graph After generating an initial layout, we insert (m − m′) edges to generate weakly chordal graphs. We divide the insertion of an edge {u, v} into two cases. The first case considers when Iu,v is non-empty and the second case is when Iu,v is empty, where Iu,v = N (u) ∩ N (v), represents the set of common neighbors between u and v. Let's discuss the case first when Iu,v is non-empty. 2.4.1 Case 1: Iu,v is non-empty Since Iu,v is non-empty, we need to check whether the removal of Iu,v separates u and v. To do this, we create an induced graph, called AuxGraph on the set of vertices V − Iu,v. Now we perform a breadth-first search on AuxGraph, starting at u and if v has not been reached, then the augmented graph G + {u, v} is weakly chordal. Thus we can insert an edge {u, v} in the weakly chordal graph G because the removal of their common neighbors (Iu,v) in AuxGraph leaves u and v in different components. Instead of searching for a path on this large set of vertices, we consider an induced graph on a smaller subset of vertices. In [6], the authors built the induced graph on the neighbors of any vertex x in Iu,v for the chordal graph. But here we need to consider the neighbors of neighbors of every vertex x in Iu,v to explore paths between u and v. Formally the set of vertices included in AuxN odes can be defined as (Sx∈Iu,v (N (N (x \ {u, v})) ∪ N (x))) ∪ N (u) ∪ N (v) − Iu,v. Consider the graph shown in Figure 4. We want to introduce an edge between u and v which is not allowed because the insertion violates the property of the weakly chordal graph. There is only one common neighbor Iu,v = {a} between u and v. The N (a) is {b, d} and the induced graph on {u, v, b, d} shows there is no path between u and v but there are longer paths (u − c − d − e − v and u − c − d − b − v) exist between u and v. These paths are discoverable if we take the neighbors of neighbors of a and build AuxGraph on AuxN odes as defined above. The N (N (a)) includes 5 {b, c, d, e} and thus the AuxN odes comprises {u, v, b, c, d, e}. X a d u c b e v Figure 4: Why neighbors of neighbors? This is the first part of case 1 that we define as case 1.1. This idea is extended from [6], where the authors insert an edge {u, v} in a chordal graph when v has not been reached from u during a breadth-first search on AuxGraph. What happens if v is reachable from u in a weakly chordal graph? In a weakly chordal graph we may be able to insert an edge {u, v} even when a path exists between u and v. In a chordal graph, the separators are cliques but in a weakly chordal graph, the separators may not necessarily cliques. Now we have to explore all the shortest paths of length 3 or more between u and v. If there is a path longer than P3 exists, we do not insert {u, v} and choose another pair of vertices, otherwise, we check the other conditions for the possibility of insertion of {u, v}. We call this case 1.2. Again we divide this case 1.2 into two subcases: if there is a single P3 then we called case 1.2.1 and otherwise case 1.2.2 for multiple P3. Case 1.2.1: We find the neighbors of the shortest path. If the neighborhood of the shortest path is empty, we insert an edge {u, v}, otherwise, we find the alternate paths in the entire graph. Instead of searching for alternate paths in the entire graph, we search for alternate paths on different induced graphs created on {N (N (SP \ {u, v}))} (where SP represents the shortest path between u and v) by removing both the internal vertices of SP or exactly one of them to find alternate paths between u and v. Consider the two situations shown in Figure 5 where u − x − y − v is a path of length 3. In Figure 5(a), each vertex on Pi, i > 3 is a neighbor of either x or y but in Figure 5(b) there exists a vertex (b) which is neither a neighbor of x nor y. Thus we are interested in the neighbors of neighbors of the shortest path to discover other alternate paths. The alternate b e a c d f u x y v (a) x u y v a b c (b) Figure 5: Neighbors of a path paths may exist via some of the vertices in the shortest path and/or other vertices including in the neighbors or the neighbors of neighbors of the shortest path or disjoint path via the vertices not 6 included in SP . If no alternate paths exist, we can insert an edge {u, v}, otherwise we do not insert {u, v} and choose another pair of vertices. The algorithm 1 explains the Case 1.2.1 (for a single shortest path). Algorithm 1 SingleShortestPathSubCase Input: Single shortest path (SP , u, v) ⊲ {SP = v0 − v1 − · · · − vl} Compute N (x) 1: for each x in SP do 2: 3: end for 4: if N (SP ) \ SP = ∅ then 5: 6: else 7: 8: Insert edge {u, v} for each y in N (SP \ {u, v}) do Compute N (y) 9: 10: 11: 12: 13: end for Create different induced graphs on {N (N (SP \ {u, v}))} by removing both the internal vertices of SP or exactly one of them Check for alternate longer path between u and v if no alternate longer path exists then Insert edge {u, v} end if 14: 15: end if Case 1.2.2: In the case of multiple shortest paths, first we need to check for forbidden con- figurations. To define a forbidden configuration, let's consider the graphs shown in Figure 6. In Figure 6(a), we can insert an edge {u, v} because it does not create any chordless five cycles or more in the graph G, but it creates a chordless six cycle in the complement graph as illustrated in Fig- ure 6(b). As we know from the definition of the weakly chordal graph, a graph G is weakly chordal if neither G nor its complement G contains a chordless cycle of size 5 or more. But G + {u, v} creates a chordless six cycle in G. Thus, we cannot add {u, v} in G. The forbidden configuration checking is required when two or more shortest P3 paths exist between u and v and the checking has to be done by considering all pairwise disjoint shortest paths. Figure 7 illustrates other configurations where adding {u, v} to G may be allowed. u u v (a) G v (b) G Figure 6: Forbidden configuration After checking forbidden configurations, the next step is to check for alternate longer paths between u and v. Like case 1.2.1, instead of searching for alternate longer paths in the entire graph we do the search on the different induced graphs created on {N (N (allSP \ {u, v}))} (where 7 u u u u u u u v (a) G v (b) G v (c) G v (d) G v (e) G v (f) G v (g) G Figure 7: Other allowed configurations u u v Disjoint (a) path v Shared (b) path Figure 8: Different paths between u and v allSP represents all the shortest paths between u and v containing the set of vertices in the paths including two endpoints) by removing all the internal vertices of allSP or exactly one of them to find alternate paths between u and v. The alternate paths may exist via some of the vertices in the shortest path and/or the other vertices including in the neighbors/the neighbors of neighbors of the shortest path or disjoint path via the vertices not included in allSP . These two scenarios are illustrated in Figure 8. 8 Algorithm 2 MultipleShortestPathSubCase Input: Multiple shortest paths (allSP = {SP0, SP1, . . . , SPj}, u, v) ⊲ {SPi = v0 − v1 − · · · − vl} 1: if no forbidden configuration then 2: 3: for each x in SP do for each SP do 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: Compute N (x) end for end for for each y in N (allSP \ {u, v}) do Compute N (y) end for Create different induced graphs on {N (N (allSP \ {u, v}))} by removing both the internal vertices of SP or exactly one of them Check for alternate longer path between u and v if no alternate longer path exists then Insert edge {u, v} end if 14: 15: end if 9 Algorithm 3 FromInitLayoutToWCG Input: An initial layout G = (V, E) Output: A weakly chordal graph G + {u, v} 1: p = 0; q = m − m′ 2: while p < q do 3: Choose a pair of vertices u and v if {u, v} exists then continue else Compute N (u) and N (v) Compute Iu,v = N (u) ∩ N (v) if Iu,v is non-empty then for each x in Iu,v do Compute N (x) end for for each y in N(cid:0)x \ {u, v}(cid:1) do Compute N (y) ⊲ m′ is the no. of edges in the initial layout ⊲ case 1: Iu,v 6= ∅ 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: end for Create AuxGraph on (Sx∈Iu,v Find whether there is a path exist between u and v in AuxGraph if v is not reachable from u then (N (N (x \ {u, v})) ∪ N (x))) ∪ N (u) ∪ N (v) − Iu,v Insert edge {u, v} else if Find all the shortest paths between u and v then if all shortest paths are of length 3 (P3) then ⊲ case 1.1 ⊲ case 1.2 if there is a single shortest path between u and v then ⊲ case 1.2.1 call singleShortestPathSubCase else if there are multiple shortest paths between u and v then ⊲ case 1.2.2 call multipleShortestPathsSubCase end if end if end if else ⊲ case 2: Iu,v = ∅ if all shortest paths are of length 3 (P3) then if there is a single shortest path between u and v then ⊲ case 2.1 call singleShortestPathSubCase else if there are multiple shortest paths between u and v then ⊲ case 2.2 call multipleShortestPathsSubCase end if end if end if end if 38: 39: end while 10 2.4.2 Case 2: Iu,v is empty In this case, there are no common neighbors of u and v but a path exists between u and v. This case can be solved in a similar way as for case 1.2. Here the AuxGraph is the entire graph because Iu,v is empty. If any of the paths is greater than P3, we do not insert {u, v} and choose another pair of vertices. Otherwise, we apply the same single shortest path case 1.2.1 and multiple shortest path case 1.2.2 to check if the addition of {u, v} keeps the graph weakly chordal or not. Here we define the single shortest path case as case 2.1 and multiple shortest paths case as case 2.2. The details of all the above cases are formally described in algorithm 3. 2.4.3 An Example Figure 9 shows an example for the generation of weakly chordal graph for n = 8 and m = 12. All the phases are shown in Figure 9. Figure 9(a) shows the tree on ⌈ n 2 ⌉ nodes. There are three nodes in the tree and for each node in the tree, we create an orthogonal initial layout which is shown in Figure 9(b) where n = 8 and m′ = 10. We assign the labels of vertices as 0 . . . 7 in the initial layout. We need to insert (m − m′) = 2 more edges in the initial layout to generate a weakly chordal graph for the given input. Assume we want to insert edge {3, 4}. The insertion of an edge between 3 and 4 falls into the case where I3,4 is non-empty. Since the removal of I3,4 leaves vertices 3 and 4 in two different components, so we can insert an edge between vertices 3 and 4 according to case 1.1 as shown in Figure 9(c). Now we want to insert edge {3, 6}. The insertion of an edge between 3 and 6 falls into the case 1.2.1 because the removal of their common neighbor {5} does not separate 3 and 6. The N (5) is {3, 4, 6} and the N (N ({3, 4, 6}) \ {3, 6}) is {0, 5, 7, 3}. Now we create the AuxGraph on the AuxN odes = {0, 2, 3, 4, 6, 7} and then we search for the paths from 3 to 6. There is a single shortest path SP = {3, 4, 7, 6} exist that means it falls into case 1.2.1. We compute N (SP ) = {0, 2, 4, 3, 6, 7} and the N (SP ) \ SP 6= ∅, so we need to compute {N (N (SP \ {3, 6}))} which is {3, 4, 0, 7, 6} and create induced graph on these set of vertices. To discover disjoint or shared alternate paths from 3 to 6 we create different induced graphs by removing some vertices from the above-computed set of vertices. But there is no such path exists and we can insert an edge between 3 and 6. b a c (a) Tree (T1) 1 0 4 7 b a c 2 3 5 6 Initial (b) Layout (G1) 1 0 4 7 b a c 2 3 5 6 1 0 4 7 b a c 5 2 3 6 (c) WCG(G′ 1) (d) WCG(G′′ 1 ) Figure 9: Tree to weakly chordal graph 11 2.5 Time Complexity The tree generation is the first phase in the proposed approach and can be constructed in time O(k) where k is the number of nodes in a tree. For k nodes in the tree, we insert 3k + 1 edges in the layout and each edge insertion can be done in constant time. So the initial layout can be generated in O(k) time. In the third phase, the pair of vertices {u, v} is chosen at random to insert an edge between them. Two types of failures may arise. One is that the pair of vertices {u, v} corresponds to an existent edge and the other is the addition of {u, v} violates weak chordality property. To avoid the first type of failures either we can maintain a list of edges (those are present in the complement graph) not present in the current graph or we can check the existence of an edge in constant time by maintaining the adjacency matrix representation of the current graph. Computing the neighborhood of a vertex takes linear time. Thus step 7 takes linear time. By amortizing over the edges we can see that step 8 takes linear time in the number of edges m and the number of vertices n. Thus each of the neighborhood computations take linear time. The AuxGraph can be created in linear time on the number of vertices in the AuxN odes. Using breadth-first search (BFS), we find whether there is a path exist between u and v in linear time. To find all P3 shortest paths we also use BFS by keeping track of all predecessors between u and v. All the operations including neighborhood computations, induced graph creations, and finding alternate longer paths take linear time (see step 23 and step 32). For steps 25 and 34, the forbidden configuration checking is required when two or more shortest P3 paths exist between u and v and the checking has to be done by considering all pairwise disjoint shortest paths. The checking is performed by the presence of one of the cross edges (an edge from one of the internal nodes from one shortest path to the alternate internal node of another shortest path) on the induced graph on a pair of disjoint shortest paths. There are at most O(n3) pairs of mutually disjoint P3 paths between u and v and thus the step takes O(n3) time (see Appendix). We use BFS to find an alternate longer path between u and v. Since there are at most O(n2) multiple P3 paths between u and v and thus in total we spend O(n2) time. In the worst case, an insertion query runs in O(n3) time. The insertion of {u, v} is performed in time O(1) because we need to insert u in the neighborhood of v and v in the neighborhood of u. 3 Conclusions We have proposed a method for the generation of weakly chordal graphs. We have implemented the proposed algorithm in Python. An interesting open problem is to investigate how to generate weakly chordal graphs uniformly at random. This requires coming up with a scheme for counting the number of labeled weakly chordal graphs on n vertices having m edges. If we could also determine the probability distribution underlying our algorithm for generating weakly chordal graphs, then we could compute the relative entropy between the two distributions to estimate how close our algorithm is to generating weakly chordal graphs uniformly at random. 12 4 Appendix We are interested in finding all P3 shortest paths between u and v (see Figure 10). Suppose there are n vertices in the graph. Let {v1, v2, . . . , vl} be the set of vertices adjacent to v that lie on the P3 shortest paths between u and v. Likewise, let {v′ k} be the set of vertices adjacent to u that lie on these shortest paths. Thus lk is the upper bound of the number of paths between u and v. Since (l + k) ≤ (n − 2), then lk = O(n2). 4 . . . v′ 1, v′ 3, v′ 2, v′ Let di be the degree of vi relative to the vertices {v′ k}, for i = 1, . . . , l. Then the number of pairs of edge-disjoint paths between u and v is given by P athCount = Pi6=j didj. Let P di = t. Now it follows from the equality 2l P didj = (l − 1)(P di)2 − Pi6=j (di − dj)2 that P athCount is maximum when all di's are equal. Therefore an upperbound on P athCount is l2. t l = lt. Since t = O(lk), we have P athCount = O(l2k). 4 . . . v′ 2, v′ 1, v′ 3, v′ u v 0 1 v 0 2 v 0 3 v 0 4 v 0 k v1 v2 vl v Figure 10: P3 paths between u and v References [1] Srinivasa Rao Arikati and C. Pandu Rangan. An efficient algorithm for finding a two-pair, and its applications. Discrete Applied Mathematics, 31(1):71 -- 74, 1991. [2] D. R. Fulkerson and O. A. Gross. Incidence matrices and interval graphs. Pacific J. Math., 15(3):835 -- 855, 1965. [3] Ryan B. Hayward. Weakly triangulated graphs. J. Comb. Theory, Ser. B, 39(3):200 -- 208, 1985. [4] Ryan B. Hayward. Generating weakly triangulated graphs. Journal of Graph Theory, 21(1):67 -- 69, 1996. [5] Ryan B. Hayward, Ch´ınh T. Ho`ang, and Fr´ed´eric Maffray. Optimizing weakly triangulated graphs. Graphs and Combinatorics, 5(1):339 -- 349, 1989. [6] Lilian Markenzon, Oswaldo Vernet, and Luiz Henrique Araujo. Two methods for the generation of chordal graphs. Annals OR, 157(1):47 -- 60, 2008. [7] Brendan D. McKay and Nicholas C. Wormald. Uniform generation of random regular graphs of moderate degree. J. Algorithms, 11(1):52 -- 67, 1990. 13 [8] Asish Mukhopadhyay, S. V. Rao, Sidharth Pardeshi, and Srinivas Gundlapalli. Linear layouts of weakly triangulated graphs. Discrete Math., Alg. and Appl., 8(3):1 -- 21, 2016. [9] H. Prufer. Neuer beweis eines satzes uber permutationen. Arch. Math. Phys., 27:742 -- 744, 1918. [10] Jeremy P. Spinrad and R. Sritharan. Algorithms for weakly triangulated graphs. Discrete Applied Mathematics, 59(2):181 -- 191, 1995. [11] G. Tinhofer. Generating Graphs Uniformly at Random, pages 235 -- 255. Springer Vienna, Vienna, 1990. [12] Nicholas C. Wormald. Generating random regular graphs. J. Algorithms, 5(2):247 -- 280, 1984. [13] Nicholas C. Wormald. Generating random unlabelled graphs. SIAM J. Comput., 16(4):717 -- 727, 1987. 14
1707.08300
1
1707
2017-07-26T06:37:33
Practical Adversarial Combinatorial Bandit Algorithm via Compression of Decision Sets
[ "cs.DS" ]
We consider the adversarial combinatorial multi-armed bandit (CMAB) problem, whose decision set can be exponentially large with respect to the number of given arms. To avoid dealing with such large decision sets directly, we propose an algorithm performed on a zero-suppressed binary decision diagram (ZDD), which is a compressed representation of the decision set. The proposed algorithm achieves either $O(T^{2/3})$ regret with high probability or $O(\sqrt{T})$ expected regret as the any-time guarantee, where $T$ is the number of past rounds. Typically, our algorithm works efficiently for CMAB problems defined on networks. Experimental results show that our algorithm is applicable to various large adversarial CMAB instances including adaptive routing problems on real-world networks.
cs.DS
cs
Practical Adversarial Combinatorial Bandit Algorithm via Compression of Decision Sets Shinsaku Sakaue NTT Communication Science Laboratories [email protected] Masakazu Ishihata Hokkaido University Shin-ichi Minato Hokkaido University [email protected] [email protected] July 27, 2017 Abstract We consider the adversarial combinatorial multi-armed bandit (CMAB) problem, whose decision set can be exponentially large with respect to the number of given arms. To avoid dealing with such large decision sets directly, we propose an algorithm performed on a zero-suppressed binary decision √ diagram (ZDD), which is a compressed representation of the decision set. The proposed algorithm achieves either O(T 2/3) regret with high probability or O( T ) expected regret as the any-time guarantee, where T is the number of past rounds. Typically, our algorithm works efficiently for CMAB problems defined on networks. Experimental results show that our algorithm is applicable to various large adversarial CMAB instances including adaptive routing problems on real-world networks. Introduction 1 The multi-armed bandit (MAB) problem [29] has been extensively studied as a fundamental framework for online optimization problems with partial observations. In the MAB, a player chooses an arm (choice) from a set of possible arms. Then, the player incurs a cost and obtains feedback according to the selected arm. The aim of the player is to minimize the cumulative cost by exploring possible arms and exploiting those with low costs. There have been many studies on MAB applications, e.g., clinical trials [25], and recommendation systems [26]. In many real-world problems, each possible choice that the player can make is not expressed as a single arm but as a super arm, which is a set of arms that satisfies certain combinatorial constraints; a full set of super arms is called a decision set. This problem is called the combinatorial multi-armed bandit (CMAB) problem, and the CMAB is said to be adversarial if the cost of each arm is arbitrarily changed by an adversary. Examples of the adversarial CMAB include various important problems on networks such as the online shortest path (OSP) problem [4, 14], the dynamic Steiner tree (DST) problem [15], and the congestion game (CG) [30]; although the original CG is a resource allocation problem over multiple players, it can be formulated as an adversarial CMAB if a player considers the other players to be adversaries. For instance, in the OSP on a traffic network, an arm corresponds to an edge (road) of a given network, a super arm is an s-t path that connects the current point s and the destination t, and the decision set is a set of all s-t paths. Furthermore, in the OSP, the cost of an arm (road) represents the traveling time on the road, and it dynamically changes due to the time-varying amount of traffic or accidents (e.g., cyber attacks in the case of the OSP on communication networks). In this paper, we focus on the adversarial CMAB. 1 The main difficulty with the adversarial CMAB is that the size of the decision set is generally exponential in the number of arms. To handle huge decision sets, existing methods for this problem assume that the decision set has certain properties. One such method is COMBEXP [10], which can cope with the difficulty if the decision set consists of, for example, sets of arms satisfying a size constraint, or matchings on a given network. However, it has been hard to design practical algorithms for adversarial CMAB instances with complex decision sets defined on networks; for example, the OSP, DST, and CG on undirected networks. In this paper, we develop a practical and theoretically guaranteed algorithm for the adversarial CMAB, which is particularly effective for network-based adversarial CMAB instances. We first propose COMBWM (COMBAND [9] with Weight Modification), which is theoretically guaranteed to achieve either O(T 2/3) regret with high probability or O(√T ) expected regret, where T is the number of rounds. The above bounds are any-time guarantees [7], and we can choose which regret value COMBWM actually achieves by setting its hyper parameter at an appropriate value. We then show that our COMBWM can be performed on a compressed decision set; we assume that a decision set is given as a zero-suppressed decision diagram (ZDD) [27], which is a compact graph representation of a family of sets. The time and space complexities of COMBWM with a ZDD are linear in the size of the ZDD, whereas those of the naive COMBWM is proportional to the size of a decision set. It is known that a ZDD tends to be small if it represents a set of subnetworks such as s-t paths or Steiner trees [21]. Thus our algorithm is effective for network-based adversarial CMAB instances including the OSP, DST, and CG. Experimental results on OSP, DST, and CG instances show that our algorithm is more scalable than naive algorithms that directly deal with decision sets. To the best of our knowledge, this is the first work to implement algorithms for the adversarial CMAB and provide experimental results, thus revealing the practical usefulness of adversarial CMAB algorithms. 2 Related work Many studies have considered the adversarial CMAB with specific decision sets, e.g., m-sets [20] and permutations [1]. In particular, the OSP, which is a CMAB problem on a network with an s-t path constraint, has been extensively studied [4, 14] due to its practical importance. Whereas the previous studies have focused on the OSP on directed networks, our algorithm is also applicable to the OSP on undirected networks. The adversarial CMAB with general decision sets has been also extensively studied in [3, 7, 5, 8, 9, 10, 31]. One of the best known algorithms for this problem is COMBAND [9], which has been proved to achieve O(√T ) expected regret. Recently the algorithm has been also proved to achieve O(T 2/3) regret with high probability in [7];1 more precisely, the regret of COMBAND is bounded by O(t2/3) with high probability in any t-th round (t = 1, . . . , T ), which is called an any-time guarantee. Although COMBAND has the strong theoretical results, its time complexity generally depends on the size of decision sets, which can be prohibitively large in practice. To avoid such expensive computation, COMBEXP [10] scales up COMBAND by employing a projection onto the convex hull of the decision set via KL-divergence. For some decision sets for which the projection can be done efficiently (e.g., m-sets or a set of matchings), COMBEXP runs faster than COMBAND, achieving the same theoretical guarantees. However, it is difficult to perform the projection for other decision sets (e.g., s-t paths or Steiner trees); actually it is NP-hard to do the projection in the case of the OSP and DST on undirected networks. On the other hand, thanks to recent advances in constructing decision diagrams (DDs), optimization techniques using DDs have been attracting much attention [6, 11, 28]. Those techniques are advantageous in that DDs can efficiently store all solutions satisfying some complex constraints; for example, constraints that are hard to represent as a set of inequalities. The ZDD [27], which we use in our algorithm, is a 1 The proof seems to include some mistakes. However, their techniques for the proof are still useful, and so we prove the O(T 2/3) high-probability regret bound of our algorithm by partially modifying their proof; the modified parts are the description of the algorithm and Lemma 2 in the supplementary materials. 2 kind of DD that is known to be suitable for storing specific network substructures (e.g., s-t paths or Steiner trees). Thus our algorithm with ZDDs runs fast in many CMAB instances defined on networks, including the OSP, DST, and CG. 3 Adversarial CMAB We here define the adversarial CMAB, which is a sequential decision problem consisting of T rounds. Let [m] := {1, . . . , m} for any m ∈ N. We use E = [d] to denote a set of arms and also use S ⊆ 2E to denote a decision set, where X ∈ S is a super arm. At each t-th round (t ∈ [T ]), an adversary secretly defines a loss vector (cid:96)t := ((cid:96)t,1, . . . , (cid:96)t,i)(cid:62) ∈ Rd and a player chooses a super arm Xt ∈ S. Then, the (cid:62) player incurs and observes the cost ct = (cid:96) t 1Xt, where 1Xt ∈ {0, 1}d is an indicator vector such that its i-th element is 1 if i ∈ Xt and 0 otherwise. Note that the player cannot observe (cid:96)t. The aim of the T(cid:88) player is to minimize the regret RT defined as follows: T(cid:88) RT := (cid:62) t 1Xt − min (cid:96) X∈S (cid:62) (cid:96) t 1X . t=1 t=1 The first term is the cumulative cost and the second term is the total cost of the best single super arm selected with hindsight. Namely, RT expresses the extra cost that the player incurs against the best (cid:62) single super arm.2 As is customary, we assume maxt∈[T ],X∈S (cid:96) t 1X ≤ 1. If the adversary and/or the player choose (cid:96)t and Xt in a stochastic manner, then Rt is a random (cid:81) variable of a joint distribution p((cid:96)1:t, X1:t), where X1:t = {X1, . . . , Xt} and (cid:96)1:t = {(cid:96)1, . . . , (cid:96)t}. In the adversarial CMAB, p is assumed to satisfy the following conditional independence: p((cid:96)1:T , X1:T ) = t∈[T ] p(Xt (cid:96)1:t−1, X1:t−1)p((cid:96)t (cid:96)1:t−1, X1:t−1), where X1:0 = (cid:96)1:0 = {}. p((cid:96)t X1:t−1, (cid:96)1:t−1) corresponds to the adversary's strategy and p(Xt X1:t−1, (cid:96)1:t−1) corresponds to the player's strategy. Since the player cannot directly observe (cid:96)1:t, the player's strategy must satisfy p(Xt X1:t−1, (cid:96)1:t−1) = p(Xt X1:t−1, c1:t−1). Using the joint distribution p, the expected regret RT is defined as follows: RT := E(cid:96)1:T ,X1:T ∼p[RT ]. The objective of the adversarial CMAB is to design the player's strategy p(Xt X1:t−1, c1:t−1) so that it minimizes RT or RT . In this paper, we use pt(Xt) as shorthand for p(Xt X1:t−1, c1:t−1). 4 Proposed algorithm for adversarial CMAB We here propose COMBWM (COMBAND with Weight Modification), which is an algorithm for designing the player's strategy pt(Xt) with strong theoretical guarantees as described later. Algorithm 1 gives the details of COMBWM. In what follows, we define L := maxX∈S (cid:107)1X(cid:107) for any given S ⊆ 2E, where (cid:107) · (cid:107) is the Euclidian norm. We also define λ as the smallest non-zero eigenvalue of EX∼u[1X 1(cid:62) X ], where u is the uniform distribution over S. Given an arbitrary non-negative vector w = (w1, . . . , wd)(cid:62) ∈ Rd and a decision set S ⊆ 2E, we define the constrained distribution p(X; w,S) over S as follows: (1) (cid:88) (cid:89) w(X), w(X) := wi. p(X; w,S) := w(X) Z(w,S) , Z(w,S) := X∈S i∈X Using the above, we define the player's strategy pt(Xt), which appears in Step 4, as follows: pt(Xt) := (1 − γt)p(Xt; (cid:101)wt,S) + γtp(Xt; 1E,S), (2) 2 If the adversary behaves adaptively, the above interpretation of the regret is somewhat inappropriate; in such cases using the policy regret [2] is considered to be more suitable. However, we here focus on the above regret and expected regret, leaving an analysis based on the policy regret for future work. 3 t,i 2L2 2L2 (cid:96)t,i t 1Xt − ηt+1 , ηt+1 ← λ(t+1)−1/α (cid:1) (i ∈ E) 1: (cid:101)w1,i ← 1 (i ∈ E) Algorithm 1 COMBWM(α,S) 2: for t = 1, . . . , T do , ηt ← λt−1/α γt ← t−1/α 3: (cid:80) 2 4: Xt ∼ pt (cid:62) t 1Xt ((cid:96)t is unobservable) 5: ct ← (cid:96) X∈S:i,j∈X pt(X) (i, j ∈ [d]) exp(cid:0) 6: Pt(i, j) ← (cid:101)wt+1,i ← (cid:101)wηt+1/ηt (cid:96)t ← ctP + 7: 8: 9: end for 10: return {Xt t ∈ [T ]} where (cid:101)wt = ((cid:101)wt,1, . . . ,(cid:101)wt,d)(cid:62) is the weight vector defined in Step 8, and γt is the parameter defined in Step 3; we note that p(Xt; 1E,S) is the uniform distribution over S. Thus pt is a mixture of two (i, j) entry P (i, j) is given by the co-occurence probability p(i ∈ X, j ∈ X) :=(cid:80) constrained distributions with the mixture rate γt. Given a distribution p over S, a matrix P is called a co-occurrence probability matrix (CPM) if its X∈S:i,j∈X p(X). The t used in Step 7 is the pseudo-inverse of Pt. Pt(i, j) = (1 − γt)p(i ∈ X, j ∈ X; (cid:101)wt,S) + γtp(i ∈ X, j ∈ X; 1E,S). The above COMBWM is based on COMBAND [9]; if we replace Step 8 of COMBWM with (cid:101)wt+1,i ← (cid:101)wt,i exp(−ηt matrix Pt computed in Step 6 is the CPM of pt, and P + From Eq. (2), the following equation holds: (3) (cid:96)t,i), COMBWM corresponds perfectly to the original COMBAND. Hence the one and only one difference is the weight modification in Step 8. However, introducing this weight modification gives (cid:16)(cid:16) dλ us the following theoretical guarantees (for proofs, see the supplementary materials): Theorem 1. For any S, COMBWM(α = 3,S) achieves RT ≤ O (cid:16)(cid:16) dλ probability at least 1 − δ. L2 + L2 ln S Theorem 2. For any S, COMBWM(α = 2,S) achieves RT ≤ O In other words, COMBWM achieves either O(T 2/3) regret with high probability or O(√T ) expected (cid:17) T 2/3(cid:17) (cid:17)√T (cid:113) L2 λ ln L2 + S+2 with λ (cid:17) δ . regret as an any-time guarantee by choosing the hyper parameter α appropriately. There are two difficulties when it comes to performing COMBWM; the first is sampling from the player's strategy pt(Xt) (Step 4), and the second is computing the CPM Pt (Step 6). Naive methods for sampling from pt and computing Pt require O(S) and O(d2S) computation times, respectively, where S is generally exponential in d, and so are the time complexities. In the following section, we propose efficient methods for sampling from any given constrained distribution p(X; w,S) and for computing the CPM of p(X; w,S). Because pt is a mixture of two constrained distributions, we can efficiently sample from pt and compute the CPM of pt using the proposed methods. 5 COMBWM on compressed decision sets As shown above, COMBWM requires sampling from constrained distributions and computing CPMs as its building blocks, which generally require O(S) and O(d2S) computation times, respectively. Moreover, computing L can also require O(S) time. Those computation costs can be prohibitively expensive since S is generally exponential in d. In this section, we present efficient algorithms for the building blocks that are based on dynamic programming (DP) on a ZDD, which is a compressed representation of S. We first briefly describe ZDDs and then propose two DP methods for sampling and computing CPMs. L can also be computed in a DP manner on a ZDD. 4 v to denote v's label, b-arc, and b-child, respectively. Consequently, ab 5.1 Zero-suppressed binary decision diagrams (ZDDs) A ZDD [27] is a compact graph representation of a family of sets. Given S ⊆ 2E, a ZDD for S is a directed acyclic graph (DAG) denoted by GS = (V, A), where V = {0, 1, . . . ,V − 1} is a set of vertices and A ⊆ V × V is a set of directed arcs. GS contains one root vertex r ∈ V and two terminal vertices: 1-terminal and 0-terminal. Without loss of generality, we assume that V = {0, . . . ,V − 1} is arranged in a topological order of GS; r = V − 1 holds and the b-terminal (b ∈ {0, 1}) is denoted simply by b ∈ V . Each non-terminal vertex v ∈ V \{0, 1} is labeled by an integer in E and has exactly two outgoing arcs: 1-arc and 0-arc. A vertex pointed by the b-arc of v is called the b-child of v. We use lv, v) holds. We use v, and cb ab Rv,u (v, u ∈ V ) to denote a set of routes (directed paths) from v to u on GS, where a route R ∈ Rv,u is a set of directed arcs: R ⊆ A. Given R ∈ Rv,u, we define X(R) ⊆ E as X(R) := {lv(cid:48) (v(cid:48), c1 v(cid:48)) ∈ R}. Then, GS satisfies that once GS is obtained, L = maxX∈S(cid:112) (4) Therefore, GS represents the decision set S as a set of all routes from its root r to the 1-terminal. Note X is easily computed by a DP method to find R ∈ Rr,1 that maximizes X(R). In general, a ZDD is assumed to be ordered and reduced. GS is said to be ordered if v > u ⇒ lv < lu holds for all v, u ∈ V \{0, 1}. A non-terminal vertex v is said to be redundant if c1 v = 0: its 1-arc directly points to the 0-terminal. A redundant vertex v can be removed by replacing all (u, v) ∈ A with (u, c0 v) without loss of the property (4). A non-terminal vertex v is said to be sharable if there exists another vertex v(cid:48) such that lv = lv(cid:48) and cb v(cid:48) (b ∈ {0, 1}): v and v(cid:48) have the same label and children. A sharable vertex v can be removed by replacing (u, v) ∈ A with (u, v(cid:48)). GS is said to be reduced if no vertex is redundant or sharable. In this paper, we assume that GS is ordered and reduced. We show an example of a ZDD in Figure 1. S = {X(R) R ∈ Rr,1}. v = (v, cb v = cb The ZDDs are known to store various families of sets compactly in many applications. In particular, if a decision set is a set of specific network substructures (e.g, a set of s-t paths or Steiner trees), the ZDD representing the decision set tends to be small. As we will see later, the time complexity of COMBWM with a ZDD GS = (V, A) is O(dV ), and so it runs fast if the ZDD is small. In theory, if S is a set of specific network substructures, then V is bounded by a value that is exponential in the pathwidth [17]. Thus, even if a network-based decision set is exponentially large in d, the time complexity of our algorithm in each round can be polynomial in d if the pathwidth of the network is bounded by a small constant. The frontier-based search [21], which is based on Knuth's Simpath algorithm [24], has recently received much attention as a fast top-down construction algorithm for ZDDs that represent a family of subnetworks. In practice ZDDs are easily obtained via existing software [16] for various network- based constraints. In this paper, we omit the details of ZDD construction and assume that a decision set S is represented by a ZDD GS rather than by the explicit enumeration of the components of S. 5 (a) (b) Figure 1: (a) An example network with an edge set E = {1, . . . , 5}, and (b) a ZDD that stores all paths from the start to the goal; each non-terminal ver- tex v is labeled lv ∈ E, and 0-arcs and 1-arcs are indicated by dashed and solid lines, respectively. Note that we have S = {X(R) R ∈ Rr,1} = {{1, 4},{2, 5},{1, 3, 5},{2, 3, 4}}. start goal 𝟏 𝟐 𝟑 𝟒 𝟓 𝟏 𝟐 𝟑 𝟓 𝟑 𝟒 1 0 5.2 Sampling from constrained distributions We here propose an efficient algorithm for sampling from a constrained distribution p(X; w,S). We first introduce the following forward weight (FW) Fv and backward weight (BW) Bv (v ∈ V ): (5) (cid:88) (cid:88) w(R), Bv := where w(R) is an abbreviation of w(X(R)) =(cid:81) R∈Rr,v Fv := w(R), i∈X(R) wi. By combining Eq. (1), (4), and (5), we obtain Z(w,S) = Br = F1. B := {B0, . . . , Br} and F := {F0, . . . , Fr} can be efficiently computed in a dynamic programming manner on GS as shown in Algorithm FW(GS , w) and BW(GS , w). Once we obtain B, we can draw a sample from p(X; w,S) by top-down sampling on GS without rejections as shown in Algorithm Draw(GS , w, B), where Ber(θ) is the Bernoulli distribution with the parameter θ ∈ [0, 1]. The space and time complexity when computing F and B is proportional to V . This constrained sampling is based on the same idea as that used in logic-based probabilistic modeling [18, 19]. R∈Rv,1 1: Algorithm FW(GS , w) 2: Fr ← 1 3: Fv ← 0 (∀v ∈ V \{r}) 4: for v = r, . . . , 2 do 5: 6: 7: end for 8: F := {F0, . . . , Fr} 9: return F + = Fv + = wlv Fv Fc0 Fc1 v v 1: Algorithm BW(GS , w) 2: B1 ← 1 3: Bv ← 0 (∀v ∈ V \{1}) 4: for v = 2, . . . , r do 5: + wlv Bc1 6: end for 7: B := {B0, . . . , Br} 8: return B Bv ← Bc0 v v 1: Algorithm Draw(GS , w, B) 2: X ← {}, v ← r 3: while v > 1 do 4: θ ← wlv Bc1 5: b ∼ Ber(θ) 6: X ← X ∪ {lv} if b = 1 v ← cb 7: 8: end while 9: return X /Bv v v 5.3 Computing co-occurrence probabilities Given a constrained distribution p(X; w,S), we define Pi,j := p(i ∈ X, j ∈ X; w,S) as the co-occurrence probability of i and j (i, j ∈ E). We here propose an efficient algorithm for computing Pi,j (i ≤ j), which suffices for obtaining Pi,j for all i, j ∈ [d] since Pi,j = Pj,i. Using Eq. (1) and the notion of GS, Pi,j can be written as follows: (6) Pi,j = (cid:88) Pi,i = R∈Rr,1:i∈X(R) w(R) Z(w,S) = (cid:88) R∈Rr,1:i,j∈X(R) (cid:88) (cid:88) v∈V :lv=i R(cid:48)∈Rr,v R(cid:48)(cid:48)∈Rc1 v ,1 w(R) Z(w,S) . (cid:88) w(R(cid:48) ∪ {i} ∪ R(cid:48)(cid:48)) Br = FvwiBc1 v Br . v∈V :lv=i We first consider Pi,i as a special case of Pi,j. By combining Eq. (5) and (6), we obtain Next, to compute Pi,j (i < j), we rewrite the right hand side of Eq. (6) using the backward weighted co-occurrence (BWC) Cv,j (j ≥ lv) as follows: (cid:88) (cid:88) FvwiCc1 v,j Pi,j = v∈V :lv=i Br , Cv,j := w(R). R∈Rv,1:j∈X(R) Because Cv,j is a variant of Bv, C := {Cv,j v ∈ V, j ≥ lv} can be computed in a similar manner to B as shown in Algorithm BWC(GS , w, B). To conclude, Pi,j can be computed by Algorithm CPM(GS , w, F, B, C). The total space and time complexity of computing P := {Pi,j i ≤ j} is O(dV ). 6 1: Algorithm BWC(GS , w, B) 2: Cv,j ← 0 (∀v ∈ V , ∀j ∈ E) 3: for v = 2, . . . , r do 4: Cv,lv ← wlv Bc1 for j = lv + 1, . . . , d do 5: 6: Cv,j ← Cc0 v,j + wlv Cc1 7: 8: end for 9: C := {Cv,j v ∈ V, j ≥ lv} 10: return C end for v,j v 1: Algorithm CPM(GS , w, B, F, C) 2: Pi,j ← 0 (∀i, j ∈ E) 3: for v = 2, . . . , r do 4: 5: 6: 7: 8: 9: end for 10: P := {Pi,j i, j ∈ [d], i ≤ j} 11: return P i ← lv Pi,i+ = FvwiBc1 for j = i + 1, . . . , d do v,j/Br Pi,j+ = FvwiCc1 end for /Br v 6 Experiments We applied our COMBWM with ZDDs to three network-based CMAB problems: the OSP, DST, and CG. In the OSP and DST, we used artificial networks to observe the scalability of our algorithm. In the CG, we used two real-world networks to show the practical utility of our algorithm. We implemented our algorithm in the C programming language and used Graphillion [16] to obtain the ZDDs. We note that constructing ZDDs with the software is not a drawback; in all of the following instances a ZDD was obtained within at most several seconds. 6.1 OSP and DST on artificial networks Experimental Setting: We applied our COMBWM with ZDDs to the OSP and DST instances on artificial networks, which are undirected grid networks with 3 × m nodes (m = 3, . . . , 10). In both problems, an arm corresponds to an edge of the given network. In the OSP, a decision set S is a set of all s-t paths from the starting node s to the goal node t that are placed on diagonal corners of the given grid. In the DST, S is a set of all Steiner trees that contains the four corners of the grid. The aim of the player is to minimize the cumulative cost of the selected subnetworks over some time horizon. In this experiment, we define the loss vector (cid:96)t as follows: We first uniformly sample µ0 from [0, 1]d. In the t-th round, we set µt = µt−1 with probability 0.9 or draw a new µt uniformly from [0, 1]d with probability 0.1. Then, for each i ∈ E, we draw hi ∼ Ber(µt,i) and set (cid:96)t,i = 1/d if ht = 1 otherwise −1/d. This setting is a stochastic CMAB with distributions Ber(µt,i) in the short run, but the adversary secretly reset µt with probability 0.1 in each round to foil the player. Compression Power: We first assess the compression power of ZDDs constructed for the decision sets of the OSP and DST instances. Table 1 shows the sizes of decision sets S and those of the corresponding ZDDs GS. In both problems, the ZDD size, V , grows much more slowly than S. In particular, with the DST on the 3 × 10 grid, we see that V is five orders of magnitude smaller than S. In such cases, our COMBWM, which only deals with a ZDD GS, is much more scalable than the naive method that directly deals with S. Empirical Regret: We next show that the empirical regrets of our COMBWM and COMBAND actually grow sublinearly, where COMBAND is also performed on ZDDs. We applied these algorithms to the OSP and DST on a 3 × 10 grid and computed their empirical regrets over a time horizon. Figures 2 (a) and (b) summarize their regrets for the OSP and DST, respectively. We see that all of the algorithms achieved more or less the same sublinear regrets. It was confirmed that all of the regret values were lower than those of the theoretical bounds stated in Theorem 1 and Theorem 2; the precise values of the bounds are provided in the supplementary materials. 7 Table 1: The sizes of decision sets S and the corresponding ZDDs GS for the OSP and DST (numbers with more than six digits are rounded to three significant digits). m S OSP V DST S V 3 12 31 266 80 4 38 76 4,285 304 5 125 183 69,814 1,147 6 414 451 1.14×106 4,616 7 1,369 1,039 1.86×107 18,032 8 4,522 2,287 3.04×108 67,484 9 14,934 4,991 4.97×109 238,364 10 49,322 11,071 8.12×1010 933,394 6.2 CG on real-world networks Experimental Setting: We applied our COMBWM with ZDDs to the CG, which is a multi-player version of the OSP, on two real-world networks. The CG is described as follows: Given m players and an undirected network with a starting node s and a goal node t, the players concurrently send a message from s to t. The aim of each player is to minimize the cumulative time needed to send T messages. In this problem an arm corresponds to an edge of a given network, and a super arm is an s-t path. The loss value of an arm is the transmission time required when using the edge, and the cost of a super arm is the total transmission time needed to send a message along the selected s-t path. In the experiments, we assume that the loss of each edge increases with the number of players who use the same edge at the same time; therefore, a player regards the other players as adversaries. We use X k t ∈ S (k ∈ [m]) t,i ∈ {0, 1} to denote the i-th element to denote the k-th player's choice in the t-th round and use X k of 1X k t,i to denote the transmission time that the k-th player consumes when sending t,i , where βi ∈ R is the a message using the i-th edge at the t-th round. We here define (cid:96)k length of the edge, κ is an overhead constant, and N−k t,i is the number of adversaries who also choose the i-th edge at the t-th round. Namely, we assume that the transmission time of each edge increases exponentially with the number of players using the same edge at the same time. Consequently, to reduce the total transmission time, the players should adaptively avoid contending with each other. Note that this setting violates the assumption ct < 1; however, in practice, this violation barely matters. In the experiments, we set m = 2 and κ = 10. We use two real-world communication networks in the Internet topology zoo [23]: the InternetMCI network (MCI) and the ATT North America network (ATT). Figure 2 (e) and (f) illustrate the topologies of the MCI and ATT, respectively. Both networks correspond to the U.S. map and we choose Los Angeles as the starting point s and New York as the goal t. The statistics for each network are shown in Table 2. :=(cid:80) . We also use (cid:96)k k(cid:48)(cid:54)=k X k(cid:48) t −k t,i := βiκN t,i Table 2: Statistics for two real-world communication networks. ZDD size V Network # nodes # edges # s-t paths S 756 MCI 1,444 213,971 ATT 37,776 33 56 19 25 Experimental Results: Figures 2 (c) and (d) show the regret values of each player for the MCI and ATT, respectively. The figure shows that each player attained sublinear regrets. Figures 2 (e) and (f) show the top two most frequently selected paths for each player. We see that each player successfully avoided congestion. In the full information setting where the players can observe the costs of all s-t paths after choosing the current path, it is known that the Hedge algorithm [13] can achieve the Nash equilibria [22] on the CG. In this experiment, even though we employed the bandit setting where each player can only observe the cost of the selected path, the players successfully found almost optimal strategies on both networks. To conclude, the experimental results suggest that our algorithm is useful for adaptive routing problems on real-world networks. 8 (a) OSP on the 3 × 10 grid (c) CG on MCI (e) MCI (b) DST on the 3 × 10 grid (d) CG on ATT (f) ATT Figure 2: (a) and (b) show the regret values for the OSP and DST, respectively. The regret values are averaged over 100 trials and the error bars indicate the standard deviations. (c) and (d) show the regret values of each player for the CG on the MCI and ATT, respectively. (e) and (f) are the topologies of the two networks; the triangles are the starting nodes and the squares are the goal nodes. The red (blue) paths indicate the top two paths most frequently chosen by player 1 (2). 7 Conclusion We proposed COMBWM with ZDDs, which is a practical and theoretically guaranteed algorithm for the adversarial CMAB. We also showed that our algorithm is effective for network-based adversarial CMAB instances, which include various important problems such as the OSP, DST, and CG. The efficiency of our algorithm is thanks to the compression of the decision sets via ZDDs, and its time and space complexities are linear in the size of ZDDs; more precisely, they are O(dV ). We showed experimentally that the ZDDs for the OSP, DST, and CG are much smaller in size than original decision sets. Our algorithm is also theoretically guaranteed to achieve either O(T 2/3) regret with high probability or O(√T ) expected regret as an any-time guarantee; we experimentally confirmed that our algorithm attained sublinear regrets. The results on CG showed that our algorithm is useful for adaptive routing problems on real-world networks. 9 05.0×104105Round050100150200250RegretCOMBWM(α=2)COMBWM(α=3)COMBAND(α=2)COMBAND(α=3)05.0×102103Round051015202530RegretCOMBWM(α=2)COMBWM(α=3)COMBAND(α=2)COMBAND(α=3)05.0×104105Round02.0×1054.0×1056.0×105Player1Player205.0×104105Round01.0×1062.0×1063.0×106Player1Player2 References [1] N. Ailon, K. Hatano, and E. Takimoto. Bandit online optimization over the permutahedron. In International Conference on Algorithmic Learning Theory, pages 215–229. Springer, 2014. [2] R. Arora, O. Dekel, and A. Tewari. Online bandit learning against an adaptive adversary: from regret to policy regret. arXiv preprint arXiv:1206.6400, 2012. [3] J.-Y. Audibert, S. Bubeck, and G. Lugosi. Regret in online combinatorial optimization. Math. Oper. Res., 39(1):31–45, February 2014. [4] B. Awerbuch and R. D. Kleinberg. Adaptive routing with end-to-end feedback: Distributed learning and geometric approaches. In 36th Annual ACM Symposium on Theory of Computing, pages 45–53. ACM, 2004. [5] P. L. Bartlett, V. Dani, T. Hayes, S. Kakade, A. Rakhlin, and A. Tewari. High-probability regret bounds for bandit online linear optimization. In 21st Annual Conference on Learning Theory, pages 335–342. Omnipress, 2008. [6] D. Bergman, A. A. Cire, W.-J. van Hoeve, and J. Hooker. Decision Diagrams for Optimization. Springer, first edition, 2016. [7] G. Braun and S. Pokutta. An efficient high-probability algorithm for linear bandits. arXiv preprint arXiv:1610.02072, 2016. [8] S. Bubeck, N. Cesa-Bianchi, and S. M. Kakade. Towards minimax policies for online linear optimization with bandit feedback. In Conference on Learning Theory, pages 1–14, 2012. [9] N. Cesa-Bianchi and G. Lugosi. Combinatorial bandits. J. Comput. Syst. Sci., 78(5):1404 – 1422, 2012. [10] R. Combes, M. Sadegh Talebi, A. Proutiere, and M. Lelarge. Combinatorial bandits revisited. In Advances in Neural Information Processing Systems, pages 2116–2124, 2015. [11] O. Coudert. Solving graph optimization problems with ZBDDs. In 1997 European Conference on Design and Test, page 224. IEEE Computer Society, 1997. [12] X. Fan, I. Grama, and Q. Liu. Hoeffding's inequality for supermartingales. Stoch. Proc. Appl., 122(10):3545– 3559, 2012. [13] Y. Freund and R. E. Schapire. Adaptive game playing using multiplicative weights. Games Econom. Behav., 29(1):79 – 103, 1999. [14] A. György, T. Linder, G. Lugosi, and G. Ottucsák. The on-line shortest path problem under partial monitoring. J. Mach. Learn. Res., 8(Oct):2369–2403, 2007. [15] M. Imase and B. M. Waxman. Dynamic Steiner tree problem. SIAM J. Discrete. Math., 4(3):369–384, 1991. [16] T. Inoue, H. Iwashita, J. Kawahara, and S. Minato. Graphillion: software library for very large sets of labeled graphs. Int. J. Software Tool. Tech. Tran., 18(1):57–66, 2016. [17] Y. Inoue and S. Minato. Acceleration of ZDD construction for subgraph enumeration via path-width optimization. Technical report, TCS-TR-A-16-80, Hokkaido University, 2016. [18] M. Ishihata, Y. Kameya, T. Sato, and S. Minato. Propositionalizing the EM algorithm by BDDs. In 18th International Conference on Inductive Logic Programming, pages 44–49, 2008. [19] M. Ishihata and T. Sato. Bayesian inference for statistical abduction using Markov chain Monte Carlo. In 3rd Asian Conference on Machine Learning, pages 81–96, 2011. [20] S. Kale, L. Reyzin, and R. E. Schapire. Non-stochastic bandit slate problems. In Advances in Neural Information Processing Systems, pages 1054–1062, 2010. [21] J. Kawahara, T. Inoue, H. Iwashita, and S. Minato. Frontier-based search for enumerating all constrained subgraphs with compressed representation. Technical report, TCS-TR-A-14-76, Hokkaido University, 2014. [22] R. Kleinberg, G. Piliouras, and E. Tardos. Multiplicative updates outperform generic no-regret learning in congestion games: Extended abstract. In 41st Annual ACM Symposium on Theory of Computing, pages 533–542. ACM, 2009. [23] S. Knight, H. X. Nguyen, N. Falkner, R. Bowden, and M. Roughan. The Internet topology zoo. IEEE J. Sel. Area. Comm., 29(9):1765–1775, 2011. 10 [24] D. E. Knuth. The Art of Computer Programming: Combinatorial Algorithms, Part 1, volume 4A. Addison- Wesley Professional, 1st edition, 2011. [25] V. Kuleshov and D. Precup. Algorithms for multi-armed bandit problems. arXiv preprint arXiv:1402.6028, 2014. [26] L. Li, W. Chu, J. Langford, and R. E. Schapire. A contextual-bandit approach to personalized news article recommendation. In 19th international conference on World wide web, pages 661–670. ACM, 2010. [27] S. Minato. Zero-suppressed BDDs for set manipulation in combinatorial problems. In 30th International Design Automation Conference, pages 272–277. ACM, 1993. [28] D. R. Morrison, E. C. Sewell, and S. H. Jacobson. Solving the pricing problem in a branch-and-price algorithm for graph coloring using zero-suppressed binary decision diagrams. INFORMS J. Comput., 28(1):67–82, 2016. [29] H. Robbins. Some aspects of the sequential design of experiments. In Herbert Robbins Selected Papers, pages 169–177. Springer, 1985. [30] R. W. Rosenthal. A class of games possessing pure-strategy Nash equilibria. Internat. J. Game Theory, 2(1):65–67, 1973. [31] T. Uchiya, A. Nakamura, and M. Kudo. Algorithms for adversarial bandit problems with multiple plays. In International Conference on Algorithmic Learning Theory, pages 375–389. Springer, 2010. 11 Supplementary material In what follows we prove Theorem 1 and Theorem 2. Section S1 presents two concentration inequalities that are important in the proofs. In Section S2 we provide some preliminaries for the proofs. Section S3 and Section S4 provide the proofs of Theorem 1 and Theorem 2, respectively. S1 Concentration inequalities The following concentration inequalities play crucial roles in the subsequent discussion. Theorem 3 (Azuma-Hoeffding inequality). If a martingale difference sequence {Zt}T t=1 satisfies at ≤ Zt ≤ bt almost surely with some constants at, bt for t = 1, . . . , T , then the following inequality holds with probability at least 1 − δ: T(cid:88) T(cid:88) (cid:118)(cid:117)(cid:117)(cid:116) ln(1/δ) Zt ≤ t=1 2 t=1 (bt − at)2. Theorem 4 (Bennett's inequality [12]). If a supermartingale difference sequence {Zt}T to a filtration {Ft}T−1 T(cid:88) we have the following with probability at least 1 − δ: t=1 with respect t=0 satisfies Zt ≤ b with some constant b > 0 for t = 1, . . . , T , then, for any v ≥ 0, T(cid:88) (cid:114) Var[Zt Ft−1] ≥ v or t=1 Zt ≤ b 3 1 δ ln + 2v ln 1 δ . t=1 S2 Preliminaries for the proofs 2L2 1: (cid:101)w1,i ← 1 and w1,i ← 1 (i ∈ E) , ηt ← λt−1/α Algorithm 2 COMBWM(α,S) 2: for t = 1, . . . , T do γt ← t−1/α 3: 2 4: Xt ∼ pt (cid:62) t 1Xt ((cid:96)t is unobservable) 5: ct ← (cid:96) 6: Pt ← (1 − γt)Qt + γtU (cid:96)t ← ctP + 7: (cid:96)t,i 8: − ηt 9: (i ∈ E) 10: end for 11: return {Xt t ∈ [T ]} wt+1,i ← (cid:101)wt,i exp(cid:0) (cid:101)wt+1,i ← wηt+1/ηt t 1Xt t+1,i 2L2 , ηt+1 ← λ(t+1)−1/α (cid:1) (i ∈ E) We here rewrite Algorithm 1 equivalently as in Algorithm 2, which will be helpful in terms of understanding the subsequent discussion. In what follows, we let K := S and µ := 1/K. We also define Et[·] := E[· X1:t−1, (cid:96)1:t] as the conditional expectation in the t-th round given all the history of rounds 1, . . . , t − 1 and the loss vector in round t. Similarly, we define the conditional variance in round t as Vart[·] := Var[· X1:t−1, (cid:96)1:t]. For any vector x = (x1, . . . , xn)(cid:62) ∈ Rn and p > 0, we define i=1 xip)1/p, and we often use (cid:107)x(cid:107) to express (cid:107)x(cid:107)2. For any matrix i=1 P (i, i) and denote the spectral norm of P as (cid:107)P(cid:107), i.e., (cid:107)P(cid:107) is the largest singular value of P . For any symmetric matrices P, Q ∈ Rn×n, we use P (cid:23) Q to express the fact that the smallest eigenvalue of P − Q is non-negative. the p-norm of x as (cid:107)x(cid:107)p := ((cid:80)n P ∈ Rn×n, we denote its i, j entry as P (i, j). We define the trace of P as Tr(P ) :=(cid:80)n 1 For all t ∈ [T ], we define distributions u and qt over S, and d × d matrices U and Qt as follows: u(X) := p(X; 1E,S) = µ, U := EX∼u[1X 1(cid:62) (cid:88) where (cid:101)wt(X) is an abbreviation of (cid:81) X ] = X∈S µ1X 1(cid:62) X , t ∈ [T ]: qt(X) := p(X; (cid:101)wt,S) = Qt := EX∼qt[1X 1(cid:62) X ] = (cid:101)wt(X) (cid:80) X(cid:48)∈S (cid:101)wt(X(cid:48)) (cid:88) , qt(X)1X 1(cid:62) X , i∈X (cid:101)wt,i. Note that we have the following for any X ∈ S and X∈S where pt(X) and Pt are those defined in Eq. (2) and (3), respectively. We note that the weight values wt,i (i ∈ E) defined in Step 8 of Algorithm 2 satisfy the following for any X ∈ S and t ≥ 2: pt(X) = (1 − γt)qt(X) + γtu(X), Pt = EX∼pt[1X 1(cid:62) pt(X)1X 1(cid:62) X ] = X = (1 − γt)Qt + γtU, (cid:88) X∈S (cid:18) (cid:19) , (cid:62) (cid:96) t(cid:48) 1X t−1(cid:88) t(cid:48)=1 ηt wt(X) = exp − ηt−1 qt(X) = (cid:80) ηt−1 wt(X) X(cid:48)∈S wt(X(cid:48)) . ηt ηt−1 (S1) (S2) (S4) (S5) w1,i = (cid:101)w1,i = 1 for all i ∈ E. For convenience, we let η0 := η1 in what follows, which makes Eq. (S2) hold for t = 1 since we have Recall that λ is the smallest non-zero eigenvalue of U = EX∼u[1X 1(cid:62) X ], and that ct ≤ 1 holds because of the loss value assumption. The following basic results will be used repetitively in what follows. Lemma 1 (Basic results). For any X ∈ S and t ∈ [T ], we have (S3) , (cid:62) and (cid:96) t 1X ≤ L2 γtλ 1 t (cid:107) ≤ γtλ P + t 1Xt] ≤ d, (cid:107)P + Et[1(cid:62) Xt PtP + t 1X = 1X , (cid:62) (cid:62) Et[(cid:96) t 1X . t 1X ] = (cid:96) (S6) Proof. The first inequality of Eq. (S3) comes from Pt (cid:23) γtU, and the second one is obtained from ct ≤ 1 as follows: (cid:62) t 1X = ct1(cid:62) (cid:96) Xt P + t 1X ≤ (cid:107)1Xt(cid:107)(cid:107)P + t (cid:107)(cid:107)1X(cid:107) ≤ L2 γtλ . Eq. (S4) can be obtained as follows: Et[1(cid:62) Xt t 1Xt] = Et[Tr(P + P + t 1Xt 1(cid:62) Xt )] = Tr(P + t Pt) ≤ d. The proof of Eq. (S5) is presented in [9, Lemma 14]. Finally, Eq. (S6) is obtained with Eq. (S5) as follows: (cid:62) (cid:62) Et[(cid:96) t 1X ] = Et[(cid:96) t 1Xt1XtP + t 1X ] = (cid:96) (cid:62) t PtP + t 1X = (cid:96) (cid:62) t 1X . 2 S3 Proof for the high-probability regret bound We show the complete proof of Theorem 1. Below is a detailed statement of the theorem. Theorem 5. The sequence of super arms {Xt}t∈[T ] obtained by COMBWM(α = 3,S) satisfies the following inequality for any X ∈ S with probability at least 1 − δ: (cid:114) (cid:19) (cid:62) ((cid:96) t 1Xt − (cid:96) (cid:62) t 1X ) ≤ + 3 2 + L 7 λ ln K + 2 δ T 2/3 + o(T 2/3). (cid:18) 3d(e − 2)λ 4L2 T(cid:88) Let (cid:101)xt :=(cid:80) T(cid:88) t=1 t (cid:101)xt − (cid:96) (cid:118)(cid:117)(cid:117)(cid:116) 1 + L2 λ 2 X∈S qt(X)1X. As in [7], the proof is obtained by bounding each term on the right hand side of the following equation: (cid:62) (cid:62) ((cid:96) t 1Xt − (cid:96) t 1X ) = t=1 T(cid:88) t=1 t (cid:101)xt) + ((cid:96) (cid:62) (cid:62) t 1Xt − (cid:96) T(cid:88) t=1 (cid:62) ((cid:96) T(cid:88) t=1 (cid:62) t 1X ) + (cid:62) (cid:62) ((cid:96) t 1X − (cid:96) t 1X ), T(cid:88) t=1 t (cid:101)xt − (cid:96) (cid:62) ((cid:96) (cid:62) t 1X ) ≤ ln K ηT + (e − 2) d where X ∈ S is an arbitrary super arm. To bound them, we prove the following three lemmas. (cid:33) Lemma 2. For any X ∈ S, we have (cid:32) T(cid:88) t=1 ηt 1 − γt T(cid:88) t=1 ln 1 δ η2 t γ2 t (1 − γt)2 with probability at least 1 − δ. Proof. With the weight values wt,i (i ∈ E) used in Algorithm 2, we define wt(X) :=(cid:81) Wt :=(cid:80) (cid:19)η i∈X wt,i and ). By r (cid:107)x(cid:107)r holds for any x ∈ RK and 0 < r ≤ s. Thus, letting s = ηt−1/ηt X∈S wt(X); we measure the progress of the algorithm in each round via ln(W η Hölder's inequality, (cid:107)x(cid:107)s ≥ K 1 and r = 1, we obtain (cid:19) ηt −1 t+1 /W t s − 1 −1 η t −1 t−1 −1 t ηt−1 η t ηt−1 −1 t−1 η t = wt(X) ηt ηt−1 ηt 1 ηt−1 − 1 ηt ≥ K wt(X) ηt ηt−1 . (cid:18)(cid:88) X∈S (cid:18)(cid:88) X∈S W Hence we have ln −1 t W η t+1 −1 η t−1 t W − ln K 1 ηt − 1 ηt−1 ≤ = = ≤ 1 ηt 1 ηt 1 ηt 1 ηt ηt ln ln ln ηt−1 ηt−1 X∈S Wt+1 wt(X) X∈S wt(X) ηt (cid:80) (cid:88) (cid:88) (cid:88) (cid:32) (cid:62) 1 − ηt (cid:96) t (cid:101)xt + (e − 2)ηt (cid:80) (cid:62) ηt−1 exp(−ηt (cid:96) t 1X ) X(cid:48)∈S wt(X(cid:48)) ηt (cid:62) (cid:16) qt(X) exp(−ηt (cid:96) t 1X ) (cid:62) 1 − ηt (cid:96) t 1X + (e − 2)η2 t (cid:101)xt + (e − 2)η2 (cid:88) X∈S (cid:62) qt(X)((cid:96) t 1X )2, (cid:88) qt(X) X∈S X∈S ln ln t X∈S = 1 ηt (cid:62) ≤ −(cid:96) t 1X )2(cid:17) (cid:33) (cid:62) t ((cid:96) (cid:62) qt(X)((cid:96) t 1X )2 3 where the second inequality comes from e−x ≤ 1 − x + (e − 2)x2 for any x ≤ 1; note that ηt is defined (cid:62) to satisfy ηt(cid:96) t 1X ≤ ηtL2/(γtλ) = 1. The third inequality is obtained by ln(1 + x) ≤ x for any x ≥ −1. The second term on the right hand side is bounded from above as follows: (cid:88) X∈S Therefore, we have (cid:62) qt(X)((cid:96) t 1X )2 ≤ pt(X) 1 − γt (cid:62) ((cid:96) t 1X )2 ≤ 1(cid:62) Xt t 1Xt P + 1 − γt . (cid:88) X∈S (cid:18) 1 (cid:19) Summing up both sides of the above for t = 1, . . . , T , we obtain the following inequality from W1 = K: 1 ηt ln Wt+1 − 1 ηt−1 ln Wt ≤ ηt − 1 ηt−1 (cid:62) ln K − (cid:96) T(cid:88) On the other hand, we have wT +1,i = exp(cid:0) ln WT +1 ≤ ln K − 1 ηT 1 ηT t=1 (cid:62) (cid:96) t (cid:101)xt + (e − 2) (cid:80)T (cid:96)t,i t=1 − ηT for any X ∈ S: 1 ηT ln WT +1 ≥ 1 ηT ln wT +1(X) = − t=1 Therefore, we obtain (S7) T(cid:88) t=1 t (cid:101)xt − (cid:96) (cid:62) ((cid:96) (cid:62) t 1X ) ≤ T(cid:88) t=1 ηt ln K ηT + (e − 2) . Xt 1(cid:62) t 1Xt P + 1 − γt t (cid:101)xt + (e − 2)ηt T(cid:88) (cid:1) by Eq. (S1). Thus the following holds T(cid:88) P + 1 − γt t 1Xt 1(cid:62) t=1 ηt Xt . (cid:62) (cid:96) t 1X . (cid:33) . η2 t t=1 γ2 t (1 − γt)2 (cid:19) ln 1 δ 1(cid:62) Xt t 1Xt . P + 1 − γt (1(cid:62) The second term on the right hand side can be bounded from above by using the Azuma–Hoeffding inequality (Theorem 3) for the martingale difference sequence t 1Xt]) as P + follows. First, note that we have t 1Xt − Et[1(cid:62) ηt 1−γt P + Xt Xt by Lemma 1. Thus, by the Azuma-Hoeffding inequality, the following holds with probability at least 1 − δ: Et[1(cid:62) Xt t 1Xt] ≤ d and 0 ≤ P + T(cid:88) t=1 ηt1(cid:62) t 1Xt Xt P + 1 − γt ≤ d T(cid:88) t=1 ηt1(cid:62) t 1Xt Xt P + 1 − γt (cid:118)(cid:117)(cid:117)(cid:116) ln(1/δ) 2 ηtL2 ≤ (1 − γt)γtλ γ2 T(cid:88) (cid:118)(cid:117)(cid:117)(cid:116) ln(1/δ) t=1 2 η2 t t (1 − γt)2 . T(cid:88) ηt 1 − γt + L2 λ (cid:32) T(cid:88) t=1 (cid:62) t 1X ) ≤ ln K ηT + (e − 2) d ηt 1 − γt + L2 λ Hence we obtain T(cid:88) t=1 t (cid:101)xt − (cid:96) (cid:62) ((cid:96) T(cid:88) Lemma 3. The following inequality holds with probability at least 1 − δ: L(cid:112)λγT (1 − γT ) (cid:19) T(cid:88) t (cid:101)xt) ≤ 2 (cid:62) (cid:62) t 1Xt − (cid:96) γt + 2 + 1 3 t=1 γt ((cid:96) T(cid:88) (cid:118)(cid:117)(cid:117)(cid:116)2 (cid:18) t=1 T + + (cid:18) 3L2 λ t=1 (1 − γt)2 ln 1 δ . 4 Proof. Let z := (cid:80) X∈S µ1X and ¯xt := Et[1Xt] = (1 − γt)(cid:101)xt + γtz. We obtain the proof by using Yt := (cid:96) Bennett's inequality (Theorem 4) for the martingale difference sequence t (cid:101)xt − Et[(cid:96) t (cid:101)xt] (cid:62) (cid:62) t (cid:101)xt − (cid:96) t (cid:101)xt t 1Xt − (cid:96) t (cid:101)xt + γt(cid:96) t ((cid:101)xt − z). Pt and Jensen's inequality (cid:101)xt(cid:101)x We first bound the values of Yt and Vart[Yt]. By Qt (cid:22) 1 1−γt have 1(cid:62) 1 − γt ≤ (cid:62) (cid:62) t 1Xt − (cid:96) (cid:62) (cid:62) t 1Xt − (cid:96) (cid:62) (cid:62) t 1Xt − (cid:96) t (cid:101)xt)2 ≤ c2 λγt(1 − γt) (cid:62) t ¯xt + (cid:96) t 1Xt ≤ P + t QtP + t 1(cid:62) (cid:62) ((cid:96) t 1Xt P + = (cid:96) = (cid:96) L2 (cid:62) (cid:62) Xt Xt , and hence Yt ≤ 1 + + 2γt ≤ 2 + L(cid:112)λγt(1 − γt) L(cid:112)λγT (1 − γT ) t (cid:101)xt)2] = Et[c2 t (cid:101)xt)2] ≤ Et[(1 − 1(cid:62) (cid:62) (cid:62) t (1 − 1(cid:62) t (cid:101)xt +(cid:101)x t (cid:101)xt] Vart[Yt] ≤ Et[((cid:96) t 1Xt − (cid:96) t 1Xt1(cid:62) t (cid:101)xt t (cid:101)xt +(cid:101)x P + (cid:62) t P + Xt P + P + Xt . Xt t (cid:101)xt)2] P + The variance of Yt is bounded as follows: (cid:62) t (cid:22) Qt, we (cid:62) t P + = Et[1 − 21(cid:62) Xt = 1 − 2¯x(cid:62) t P + ¯x(cid:62) 2 t P + = 1 − 1 − γt (1 − γt)2 ¯x(cid:62) 1 − 2γt (1 − γt)2 (z − 2¯xt)(cid:62)P + (1 − γt)2λ t (¯xt − γtz) + γ2 t t P + = 1 − ≤ 1 + ≤ 1 + t ¯xt + 3γtL2 t z γ2 t , T(cid:88) t=1 ((cid:96) (cid:62) (cid:62) t 1Xt − (cid:96) t (cid:101)xt + γt(cid:96) t ((cid:101)xt − z)) ≤ (cid:62) 1 (1 − γt)2 (¯xt − γtz)(cid:62)P + t (¯xt − γtz) (1 − γt)2 (z − 2¯xt)(cid:62)P + t z (cid:18) (cid:118)(cid:117)(cid:117)(cid:116)2 2 + (cid:18) 1 3 + L(cid:112)λγT (1 − γT ) T(cid:88) T + 3L2 λ (cid:19) ln 1 δ γt t=1 (1 − γt)2 (cid:19) ln 1 δ . where the third inequality comes from 1 − 2γt ≥ 0, and the last inequality is obtained by Lemma 1 with (cid:107)z(cid:107) ≤ L and (cid:107)¯xt(cid:107) ≤ L. Therefore, by using Bennett's inequality, we obtain t ((cid:101)xt − z) ≤ 2. (cid:18) T(cid:88) t=1 (cid:62) The proof is completed by (cid:96) Lemma 4. The following inequality holds for all X ∈ S simultaneously with probability 1 − δ: (cid:62) (cid:62) ((cid:96) t 1X − (cid:96) t 1X ) ≤ 1 3 1 + L2 γT λ ln K δ + (cid:19) (cid:118)(cid:117)(cid:117)(cid:116) 2L2 λ T(cid:88) t=1 1 γt . ln K δ Proof. We fix X ∈ S arbitrarily. The proof is obtained by using Bennett's inequality for the martingale (cid:62) (cid:62) (cid:62) (cid:62) t 1X; note that Et[(cid:96) t 1X ] = 0 holds by Lemma 1. First, the difference sequence (cid:96) t 1X − (cid:96) t 1X − (cid:96) 5 (cid:62) (cid:62) absolute value and variance of (cid:96) t 1X are bounded as follows: t 1X − (cid:96) L2 γtλ , (cid:62) (cid:62) (cid:96) t 1X − (cid:96) t 1X ≤ 1 + (cid:62) (cid:62) (cid:62) t 1X ] ≤ Et[((cid:96) Vart[(cid:96) t 1X − (cid:96) Hence, by Bennett's inequality, we have t 1X )2] ≤ Et[1(cid:62) t 1Xt1(cid:62) X P + Xt T(cid:88) t=1 (cid:62) (cid:62) ((cid:96) t 1X − (cid:96) t 1X ) ≤ (cid:19) (cid:18) 1 3 1 + L2 γT λ ln K δ + P + t 1X ] ≤ 1X P + T(cid:88) (cid:118)(cid:117)(cid:117)(cid:116) 2L2 ln K δ λ 1 γt t=1 t 1X ≤ L2 γtλ . with probability at least 1 − δ/K. Taking the union bound over all super arms X ∈ S, we obtain the claim. Using the above three lemmas, we prove Theorem 5 as follows. Proof of Theorem 5. Note that we have γt = t−1/3 have the following with probability at least 1 − δ/(K + 2): 2 and ηt = λ L2 γt = λt−1/3 2L2 . By using Lemma 2, we (cid:62) t 1X ) ≤ ln K ηT + (e − 2) d 2L2 ln K λ ≤ T 1/3 + (e − 2) K + 2 + ln L2 λ (cid:32) ηt 1 − γt 3dλ 4L2 (T 2/3 + 2T 1/3) + 2 δ η2 t γ2 t (1 − γt)2 K + 2 (cid:33) . 2T ln δ (cid:118)(cid:117)(cid:117)(cid:116) 1 T(cid:88) (cid:114) t=1 (cid:33) (cid:32) T(cid:88) t=1 T(cid:88) t=1 t (cid:101)xt − (cid:96) (cid:62) ((cid:96) T(cid:88) t=1 ≤ 2 3 2 ≤ ((cid:96) t (cid:101)xt) (cid:62) (cid:62) t 1Xt − (cid:96) (cid:18) T(cid:88) (cid:18) γt + 1 3 t=1 2 + T 2/3 + 2 + 1 3 We also obtain the following inequality with probability at least 1 − δ/(K + 2) by using Lemma 3: (cid:19) ln L(cid:112)λγT (1 − γT ) √2L √λ (T 1/6 + T −1/6) K + 2 + (cid:19) δ ln K + 2 δ (cid:118)(cid:117)(cid:117)(cid:116)2 (cid:18) (cid:115) T + (cid:18) 3L2 λ T(cid:88) t=1 9L2 λ + 2 T + T 2/3 (1 − γt)2 γt (cid:19) K + 2 δ . ln K + 2 δ (cid:19) ln Furthermore, we have the following inequality with probability at least 1 − Kδ/(K + 2) by using Lemma 4: T(cid:88) t=1 (cid:19) (cid:18) (cid:18) (cid:62) (cid:62) ((cid:96) t 1X − (cid:96) t 1X ) ≤ ≤ 1 3 1 3 K + 2 + 1 + 1 + L2 γT λ 2L2 λ (cid:19) ln T 1/3 δ ln K + 2 δ + K + 2 ln λ √3L √λ δ T 2/3 T(cid:88) (cid:115)(cid:18) t=1 1 γt 1 + 4 3T (cid:19) ln K + 2 δ . (cid:118)(cid:117)(cid:117)(cid:116) 2L2 Summing up both sides of the three inequalities and taking the union bound, we obtain the theorem. 6 S4 Proof for the expected regret bound We then show the proof of Theorem 2; the detailed statement is as follows. Theorem 6. The sequence of super arms {Xt}t∈[T ] obtained by COMBWM(α = 2,S) satisfies the following inequality for any X ∈ S: (cid:62) t 1X ) (cid:18) 2L2 ln K √T + o(√T ). (cid:34) T(cid:88) (e − 2)dλ (cid:19) (cid:35) + 2 E ((cid:96) + λ L2 X∈S qt(X)1X. The proof is obtained by bounding each term on the right hand side of (cid:62) t 1Xt − (cid:96) t=1 Let (cid:101)xt :=(cid:80) (cid:34) T(cid:88) (cid:35) the following equation for any X ∈ S: = E (S8) (cid:62) (cid:62) t 1X ) t 1Xt − (cid:96) E ((cid:96) t=1 ≤ (cid:34) T(cid:88) (cid:34) T(cid:88) t=1 t=1 = E (cid:35) (cid:35) Et[(cid:96) Et[(cid:96) (cid:62) (cid:62) t 1X ] t 1Xt − (cid:96) t (cid:101)xt] (cid:62) (cid:62) t 1Xt − (cid:96) (cid:34) T(cid:88) t=1 (cid:35) t (cid:101)xt − (cid:96) (cid:62) Et[(cid:96) (cid:62) t 1X ] , + E where the second equality comes from Lemma 1. To bound these terms, we prove the following two lemmas. Lemma 5. For any X ∈ S, we have (cid:62) Et[(cid:96) T(cid:88) (cid:35) E (cid:62) t 1X ] . t (cid:101)xt − (cid:96) ln K ηT ≤ + (e − 2)d t=1 ηt 1 − γt Proof. As in the proof of Lemma 2, we have Eq. (S7); (cid:34) T(cid:88) T(cid:88) t=1 t=1 Taking the expectation of both sides, we obtain (cid:62) t 1X ) ≤ ln K ηT (cid:62) ((cid:96) t (cid:101)xt − (cid:96) t (cid:101)xt − (cid:96) (cid:62) t 1X ] (cid:35) (cid:34) T(cid:88) t=1 E (cid:62) Et[(cid:96) ln K ηT ln K ηT ≤ ≤ ηt 1(cid:62) Xt t 1Xt P + 1 − γt . (cid:35) Et[1(cid:62) Xt P + t 1Xt] t=1 + (e − 2) T(cid:88) (cid:34) T(cid:88) + (e − 2)E T(cid:88) t=1 + (e − 2)d t=1 ηt 1 − γt ηt 1 − γt , where the second inequality is obtained by Lemma 1. (cid:34) T(cid:88) Lemma 6. The following inequality holds: (cid:35) t (cid:101)xt] (cid:62) (cid:62) Et[(cid:96) t 1Xt − (cid:96) (cid:88) (cid:62) Proof. Since (cid:96) t 1X ≤ 1 holds for any X ∈ S, we have t (cid:101)xt = (cid:62) (cid:62) Et[(cid:96) (cid:88) t 1Xt − (cid:96) t (cid:101)xt] = Et[(cid:96) (cid:88) (cid:62) t 1Xt] − (cid:96) X∈S t=1 E (cid:62) T(cid:88) t=1 γt. ≤ 2 pt(X)(cid:96) (cid:62) t 1X − (cid:88) X∈S = γtµ(cid:96) X∈S (cid:62) t 1X − X∈S γtqt(X)(cid:96) (cid:62) t 1X ≤ 2γt. qt(X)(cid:96) (cid:62) t 1X Summing up both sides for t = 1, . . . , T and taking the expectation, we obtain the claim. We now prove Theorem 6 as follows. 7 Proof of Theorem 6. Recall that we have γt = t−1/2 obtained by Eq. (S8), Lemma 5 and Lemma 6 as follows: 2 and ηt = λ L2 γt = λt−1/2 2L2 . The proof is readily (cid:34) T(cid:88) t=1 E (cid:35) (cid:34) T(cid:88) t=1 ((cid:96) (cid:62) (cid:62) t 1X ) t 1Xt − (cid:96) = E Et[(cid:96) (cid:35) t (cid:101)xt] (cid:62) (cid:62) t 1Xt − (cid:96) T(cid:88) (cid:34) T(cid:88) T(cid:88) t=1 ln K ηT + (e − 2)d √T + 2L2 ln K λ ηt 1 − γt (e − 2)dλ t=1 (cid:18) L2 + 2 γt √T + t=1 1 2 ≤ ≤ + E (cid:62) Et[(cid:96) (cid:62) t 1X ] (cid:35) t (cid:101)xt − (cid:96) (cid:19) ln(2√T − 1) + 2√T − 1. 8
1507.03823
1
1507
2015-07-14T12:36:15
A Lower Bound on Supporting Predecessor Search in $k$ sorted Arrays
[ "cs.DS" ]
We seek to perform efficient queries for the predecessor among $n$ values stored in $k$ sorted arrays. Evading the $\Omega(n \log k)$ lower bound from merging $k$ arrays, we support predecessor queries in $O(\log n)$ time after $O(n \log(\frac{k}{\log n}))$ construction time. By applying Ben-Or's technique, we establish that this is optimal for strict predecessor queries, i.e., every data structure supporting $O(\log n)$-time strict predecessor queries requires $\Omega(n \log(\frac{k}{\log n}))$ construction time. Our approach generalizes as a template for deriving similar lower bounds on the construction time of data structures with some desired query time.
cs.DS
cs
A Lower Bound on Supporting Predecessor Search in k sorted Arrays(cid:63) Carsten Grimm1,2 1 Otto-von-Guericke-Universitat Magdeburg, Magdeburg, Germany 2 Carleton University, Ottawa, Ontario, Canada Abstract. We seek to perform efficient queries for the predecessor among n values stored in k sorted arrays. Evading the Ω(n log k) lower bound from merging k arrays, we support predecessor queries in O(log n) time after O(n log( k log n )) construction time. By applying Ben-Or's technique, we establish that this is optimal for strict predecessor queries, i.e., ev- ery data structure supporting O(log n)-time strict predecessor queries requires Ω(n log( k log n )) construction time. Our approach generalizes as a template for deriving similar lower bounds on the construction time of data structures with some desired query time. 1 Introduction We are given k sorted arrays A1, A2, . . . , Ak storing n values in total. Let A be the sorted array that results from merging A1, A2, . . . , Ak. We would like to support efficient queries for the predecessor of any query value q in the array A, i.e., for the largest value in A that is smaller than or equal to q. However, we would like to accomplish this goal without explicitly constructing A and thereby avoiding the lower bound of Ω(n log k) from merging k sorted arrays. By combining partial merging with fractional cascading [2], we support O(log n)-time predecessor queries in A after O(n log( k log n )) construction. As our main contribution, we prove that the resulting data structure is, in fact, optimal when considering strict predecessor queries, i.e., queries for the largest entry of A that is strictly smaller than the query value q. By applying Ben-Or's technique [1], we establish a lower bound of Ω(n log( k log n )) on the construction time of every data structure that supports strict predecessor queries in O(log n) time. We are interested in lower bounds on the construction time of data structures for predecessor search in multiple arrays, because we wish to derive lower bounds on the construction time of more complex data structures. 2 Related Work While lower bounds for predecessor search have been extensively studied in various models of computation, such as the cell probe model [6], we are unaware of any results regarding the version studied in this work. One variant of predecessor (cid:63) This work was presented at the Young Researcher Workshop on Automata, Languages and Programming (YR-ICALP 2015), July 5th, 2015 in Kyoto, Japan. search that comes close is the setting of fractional cascading, where we seek to identify the predecessor of a query value in each array as opposed to the overall predecessor. Chazelle and Guibas [2] support simultaneous predecessor queries in k sorted arrays in O(k + log n) time after O(n) construction. When k = O(log n), fractional cascading solves our version of predecessor search optimally. Ben-Or's technique [1] works as follows: we formulate a problem as a question "x ∈ W ?" for some set W ⊆ IRd and then bound the height of any algebraic computation tree deciding this membership question by bounding the number of connected components of W . Ben-Or [1] improved known lower bounds, e.g., for the knapsack problem [3], and established new ones for a variety of problems including element distinctness and geometric constructions with ruler and compass. Sacrist´an [5] summarizes the results related to Ben-Or's technique. 3 An Upper Bound We divide the sorted arrays A1, A2, . . . , Ak into groups of size s. Then, we merge the s arrays in the j-th group into one sorted array Bj, e.g., by maintaining a min-heap of size s storing for each array the smallest entry that has yet to be inserted into Bj. Finally, we apply fractional cascading [2] on B1, . . . , B(cid:100)k/s(cid:101). This construction takes O(n log s) time and occupies O(n) space. We answer a predecessor query for q in O(k/s + log n) time by determining the predecessors p1, . . . , p(cid:100)k/s(cid:101) of q in each B1, B2, . . . , B(cid:100)k/s(cid:101), respectively; the largest of these values is the predecessor of q in A. When k = ω(log n), we obtain a query time of O(log n) and a construction time of O(n log( k log n )) by choosing s = Θ (k/ log n). 4 A Lower Bound Our general approach is as follows. Let T (n, m) be the total time required for answering a sequence of m queries. Assume we have a data structure with con- struction time C(n) supporting queries in Q(n) time. Answering m = (cid:98)n/Q(n)(cid:99) queries takes T (n, m) ≤ mQ(n) + C(n) ≤ n + C(n) time. Therefore, any lower bound of T (n,(cid:98)n/Q(n)(cid:99)) = Ω(X), with X = ω(n), implies a lower bound of C(n) = Ω(X). We shall use Ben-Or's technique to find a suitable X. Consider the following batch verification variant of strict predecessor search: We are given k sorted arrays A1, A2, . . . , Ak of lengths n1, n2, . . . , nk, respectively, and we are given m query points q1, q2, . . . , qm ∈ IR alongside with m supposed answers p1, p2, . . . , pm ∈ IR. We would like to check whether pi is indeed the strict predecessor of qi among all values in A1, A2, . . . , Ak for all i = 1, 2, . . . , m. This batch verification problem corresponds to the membership problem for  A1 ∈ IRn1 ... Ak ∈ IRnk q ∈ IRm p ∈ IRm (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Wm := The entries of A1, . . . , Ak are sorted and pi is the strict predecessor of query qi among A1, . . . , Ak for all i = 1, . . . , m. 2  ⊂ IRn+2m . According to Ben-Or's theorem, deciding the membership problem Wm for the batch verification problem takes Ω(log #Wm − d) time, where #Wm is the number of components of Wm and d = n + 2m is the dimension of Wm. As the next step, we establish a lower bound on #Wm by identifying a certain number of points that belong to pairwise distinct connected components of Wm. To study the structure of Wm, we start with some instance x ∈ Wm of batch verification, i.e., a point x ∈ IRn+2m encoding k sorted arrays A1, A2, . . . , Ak, queries q1, q2, . . . , qm, and answers p1, p2, . . . , pm such that pi is the strict prede- cessor of qi among all array entries for i = 1, 2, . . . , m. We can continuously move some of the entries of x without leaving Wm. For instance, we remain in Wm when moving a query without changing its strict predecessor. Other changes, like moving the supposed answer pi for query qi without moving the corresponding array entry, cause us to leave Wm. The components of Wm consist of instances that can reach one another via a continuous deformation without leaving Wm. Fig. 1. A distribution of array entries (empty circles) and queries (vertical bars). The colors indicate the array containing an entry, i.e., all entries of color i belong to Ai. (a) We can swap array entries that are no strict predecessors. (b) We can swap predecessors entries with non-predecessor entries. (c) We cannot move an array entry through a query. Fig. 2. Legal and illegal changes to the order of queries (vertical bars), array entries (empty circles), and strict predecessors (color of circle centers). We can swap entries and queries as shown in (a) and (b) without leaving W . As depicted in (c), moving an array entry through a query point q (or vice versa) froces us out of W , as the strict predecessor of q to would have to discontinuously jump to a new position. Consider the order of the array entries, query points, and answers of an instance x ∈ Wm, as illustrated in Figure 1. We estimate #Wm by counting orders in separate components of Wm. Figure 2 summarizes which changes lead to the same component and which changes leave the component. Most importantly, we cannot move a query value through an array entry or vice versa without causing the corresponding answer to discontinuously jump to a new position. To count the components of Wm, we consider the different ways to distribute n distinct values x1, x2, . . . , xn into sorted arrays A1, A2, . . . , Ak and then we 3 jump trap these distributions in as many separate components of Wm as possible by n1!n2!···nk! ways to distribute n distinct values placing query values. There are into k sorted arrays of sizes n1, n2, . . . , nk. n! Fig. 3. Trapping distributions of the values (circles) to the arrays (colors) using only n log n queries (vertical bars). We place one query point every log n entry values. Using the legal swaps from Figure 2, we can reorder the entries between two queries. As illustrated in Figure 3, we place one query point every log n array entries. Since we can swap any two of the log n entries between two queries, the number of components shrinks by a factor of at most (log n)! per query compared to placing one query between every two array entries, i.e., #W n log n ≥ Wn−1 (log n)! ≥ n log n n! n1!n2!··· nk! · (log n)! = Ω n log n (cid:16) log n )(cid:17) 2n log( k , where the asymptotic bound follows from Stirling's formula and from the fact that the expression is maximized when the lengths of the arrays are balanced. Theorem 1. Consider k sorted arrays A1, A2, . . . , Ak containing n entries in total, and let A be the sorted array that results from merging A1, A2, . . . , Ak. When k = ω(log n), every data structure that supports strict predecessor queries in A with a query time of O(log n) requires Ω(n log( k log n )) construction time. 5 Future Work In future research, we shall attempt to reestablish our lower bound for non-strict predecessor queries, e.g., by augmenting the algebraic computation tree model with support for symbolic perturbation [4]. Moreover, we shall apply our approach to derive new lower bounds for the construction of other data structures. References 1. Ben-Or, M.: Lower bounds for algebraic computation trees. In: Proceedings of the Fifteenth Annual ACM Symposium on Theory of Computing. pp. 80 -- 86 (1983) 2. Chazelle, B., Guibas, L.J.: Fractional cascading: I. A data structuring technique. Algorithmica 1(2), 133 -- 162 (1986) 3. Dobkin, D.P., Lipton, R.J.: A lower bound of 1 2 n2 on linear search programs for the knapsack problem. J. Comput. Syst. Sci. 16(3), 413 -- 417 (1978) 4. Emiris, I.Z., Canny, J.F.: A general approach to removing degeneracies. SIAM Journal on Computing 24(3), 650 -- 664 (1995) 5. Sacrist´an, V.: Lower bounds for some geometric problems. Tech. Rep. MA2-IR-98- 0034, Universitat Polit`ecnica de Catalunya (1999) 6. Sen, P., Venkatesh, S.: Lower bounds for predecessor searching in the cell probe model. J. Comput. Syst. Sci. 74(3), 364 -- 385 (2008) 4 lognlognlognlognlognlognlogn
1512.03220
1
1512
2015-12-10T11:31:53
Parameterized Tractability of the Maximum-Duo Preservation String Mapping Problem
[ "cs.DS", "cs.DM" ]
In this paper we investigate the parameterized complexity of the Maximum-Duo Preservation String Mapping Problem, the complementary of the Minimum Common String Partition Problem. We show that this problem is fixed-parameter tractable when parameterized by the number k of conserved duos, by first giving a parameterized algorithm based on the color-coding technique and then presenting a reduction to a kernel of size O(k^6 ).
cs.DS
cs
Parameterized Tractability of the Maximum-Duo Preservation String Mapping Problem Stefano Berettaa,b,∗, Mauro Castellic, Riccardo Dondid bDipartimento di Informatica, Sistemistica e Comunicazione, Universit`a degli Studi di Milano - Bicocca, Milano - Italia aIstituto di Tecnologie Biomediche, Consiglio Nazionale delle Ricerche, Segrate - Italia dDipartimento di Scienze Umane e Sociali, Universit`a degli Studi di Bergamo, Bergamo - Italia cNOVA IMS, Universidade Nova de Lisboa, Lisboa - Portugal Abstract In this paper we investigate the parameterized complexity of the Maximum-Duo Preservation String Mapping Problem, the complementary of the Minimum Common String Partition Problem. We show that this problem is fixed-parameter tractable when parameterized by the number k of conserved duos, by first giving a parameterized algorithm based on the color-coding technique and then presenting a reduction to a kernel of size O(k6). Keywords: Computational Biology, Common String Partition, Parameterized Algorithms, Kernelization 1. Introduction Minimum Common String Partition (MCSP) is a problem emerged in the field of comparative ge- nomics [9] and, in particular, in the context of ortholog gene assignments [9]. Given two strings (genomes) A and B, MCSP asks for a partition of the two strings into a minimum cardinality multiset of identical substrings. The complexity of this problem has been previously studied in literature. More precisely, the MCSP problem is known to be APX-hard, even when each symbol has at most 2 occurrences in each input string [15], while it admits a polynomial time algorithm when each symbol occurs exactly once in each input string. Approximation algorithms for this problem have been proposed in [10, 11, 15, 18]. More precisely, an O(log n log∗ n)-approximation algorithm has been given in [11], while an O(k)-approximation algorithm, when the number of occurrences of each symbol is bounded by k, has been given in [18]. When k = 2 and k = 3 respectively, approximation algorithms of factor 1.1037 and 4, respectively, have been given in [15]. The parameterized complexity [13, 19] of MCSP has also been investigated. First, fixed-parameter algorithms have been given when the problem is parameterized by two parameters. In [12] this problem has been shown to be fixed-parameter tractable, when parameterized by the number of substrings in the solution and by the repetition number of the input strings. Then, the MCSP problem has been shown to be fixed-parameter tractable when parameterized by the number of substrings in the solution and the maximum number of occurrences of a symbol in an input string [6, 17]. Recently, MCSP has been shown to be fixed-parameter tractable when parameterized by the single parameter number of substrings of the partition [7]. Here, we consider the complementary of the MCSP problem, called Maximum-Duo Preservation String Mapping Problem, where instead of minimizing the number of identical substrings in the partition, we aim to maximize the number of preserved duos, that is, the number of adjacencies of symbols that are not broken ∗Corresponding author Email addresses: [email protected] (Stefano Beretta), [email protected] (Mauro Castelli), [email protected] (Riccardo Dondi) Preprint submitted to Elsevier November 11, 2018 by the partition. This problem has been proposed in [8], has been shown to be APX-hard when each symbol has at most 2 occurrences in each input string [4], and can be approximated within factor 1 4 [4]. In this work, we study the parameterized complexity of the Maximum-Duo Preservation String Mapping Problem, where the parameter is the number of preserved adjacencies (duos). More precisely, after intro- ducing preliminary definitions and properties of Maximum-Duo Preservation String Mapping in Section 2, we describe in Section 3 a fixed-parameter algorithm for the problem, based on the color-coding technique. Then, in Section 4, we present a reduction to a polynomial kernel of size O(k6). The results described in this paper are mainly of theoretical interest, since a solution of the Maximum- Duo Preservation String Mapping Problem is expected to preserve many adjacencies. However, the fixed- parameter algorithms we propose can be of interests for describing the whole parameterized complexity status of the Minimum Common String Partition Problem and its variants. For example, while it is still unknown whether Minimum Common String Partition Problem admits a polynomial kernel, the result in Section 4 shows that such a kernel exists for the complementary problem. 2. Preliminaries In this section, we introduce some concepts that will be used in the rest of the paper and we give the formal definition of the Maximum-Duo Preservation String Mapping Problem. Fig. 1 illustrates some of the definitions we give in this section. Let Σ be a non-empty finite set of symbols. Given a string A over Σ, we denote by A the length of A and by A[i], with 1 ≤ i ≤ A the symbol of A at position i. Moreover, we denote by A[i, j], with 1 ≤ i < j ≤ A, the substring of A starting at position i and ending at position j. Given a string A, a duo is an ordered pair of consecutive elements (A[i], A[i + 1]). Consider a duo (A[i], A[i + 1]) in a string A and a duo (B[j], B[j + 1]) in a string B; they are preservable if A[i] = B[j] and A[i + 1] = B[j + 1]. Given two strings A and B, such that B is a permutation of A, we say that A and B are related. In the rest of the paper we assume that A = B = n. Given two related strings A and B, a mapping m of A into B is a bijective function from the positions of A to the positions of B such that m(i) = j implies that A[i] = B[j], i.e. the two positions i, j of the two strings contain the same symbol. A partial mapping m of A into B is a bijective function from a subset of positions of A to a subset of positions of B such that m(i) = j implies that A[i] = B[j]. The definition of mapping and partial mapping can be extended to two sets of duos of related strings A and B, that is if positions i and i + 1, with 1 ≤ i ≤ n − 1, are mapped into positions j and j + 1, with 1 ≤ j ≤ n − 1, we say that duo (A[i], A[i + 1]) is mapped into duo (B[j], B[j + 1]). Given two related strings A and B, and a mapping m of the positions of A into the positions of B, a duo (A[i], A[i + 1]) is preserved if m(i) = j and m(i + 1) = j + 1 (see Figure 1 for an example). A = a b c a b b c B = a c b b c a b Figure 1: An example of two related strings A and B. The mapping of their positions is represented by connecting posi- tions/substrings. Position 1 and 2 of A are mapped into positions 6 and 7 of B, hence duo (A[1], A[2]) of A is preserved; position 1 in A induces duo (A[1], A[2]). Similarly, the sequence dA(5,7) of consecutive duos is mapped into the sequence dB(3,5) of consecutive duos; hence duos (A[5], A[6]), (A[6], A[7]) of A are preserved. The number of preserved duos induced by the mapping is 3. Now, we give the definition of the Maximum-Duo Preservation String Mapping Problem (in its decision version). Maximum-Duo Preservation String Mapping Problem (Max-Duo PSM) 2 Input: two related strings A and B, an integer k. Output: is there a mapping m of A into B such that the number of preserved duos is at least k? In this paper, we focus on the parameterized complexity of Max-Duo PSM, when parameterized by the number k of preserved duos. Consider a string S, with S ∈ {A, B}, and a string ¯S ∈ {A, B} \ {S}. Given two positions 1 ≤ i < j ≤ n, we denote by dS(i,j) the sequence of consecutive duos (S[i], S[i + 1]), . . . , (S[j − 1], S[j]); the length of dS(i,j) is the number j − i of consecutive duos in it. Given the sequence dS(i,j) of consecutive duos, the string corresponding to dS(i,j) is S[i, j]. Given a string S[i, j] the sequence of duos induced by S[i, j] is dS(i,j). By a slight abuse of notation, we say that position i, with 1 ≤ i ≤ n − 1, of a string S, induces duo (S[i], S[i + 1]). Parameterized Complexity We briefly overview the main concepts about parameterized complexity that will be useful in the rest of paper. We refer the reader to [13, 19] for an introduction to parameterized complexity. A decision problem Π is fixed-parameter tractable under a parameter k when there exists an algorithm of time complexity O(f (k)poly − time(q)), where q is the size of an instance of problem Π, and f (k) is a computable function that depends only on k (and not on q). A reduction to a kernel for a given parameterized problem Π parameterized by k is a polynomial-time algorithm that, starting from an instance (I, k) (where k is the parameter) of Π, computes an instance (I ′, k′) (called kernel ) such that k′ ≤ k and the size of I ′ is a function on k. It is well-known [13, 19] that any problem which is fixed-parameter tractable can be reduced to a kernel of exponential size. Moreover, there exist problems that admit a polynomial-size kernel, that is the size of I ′ is a polynomial function in k. Our first FPT-algorithm is based on the well-known color-coding technique, introduced in [1]. Our color- coding approach is based on the definition of perfect family of hash functions, used in [1] to derandomize the technique. Color-coding is a technique widely used to design fixed-parameter algorithms. While most of the applications of such technique are for graph problems [1, 14], it has been recently applied to problems on strings [2, 3, 5]. Before introducing the formal definition of perfect hash functions, we give an informal description of the color-coding technique. Informally, consider a problem Π that, given a set U of n elements, aims to identify whether there exists a feasible solution which is a subset of U of size k (k < n). The existence of such a subset can be computed by enumerating all the subsets of size k in time O(nk). However, for some combinatorial problems, color-coding can be used to compute whether such a set exists or not in time f (k)poly − time(n), where f (k) is a function that depends only on k, by first appropriately color-coding the elements of the set U with k colors and then applying dynamic programming. Now, we give the formal definition of perfect families of hash functions, on which the color-coding technique is based. Definition 2.1. Let U be a set of cardinality n and let L be a set of size k. A family F of hash functions from U to L is called perfect if for any subset W ⊆ U , such that W = k, there exists a function f ∈ F such that for each x, y ∈ W , f (x) 6= f (y). Moreover, a perfect family F of hash functions from U to {l1, . . . , lk}, having size O(log U 2O(k)), can be constructed in time O(2O(k)U log U ) (see [1]). 3. An FPT Algorithm In this section, we present an FPT algorithm for Max-Duo PSM parameterized by the number of pre- served duos k between the input related strings A and B. More precisely, the FPT algorithm we present is parameterized by the number of positions of B that induce k preserved duos. Next, we prove the relation between the number of positions of B inducing the preserved duos and the number k of preserved duos of a solution of Max-Duo PSM on instance the (A, B, k). 3 Lemma 1. Consider two related strings A and B, a solution of Max-Duo PSM on the instance (A, B, k), and consider the p positions of B that induce such k duos. Then it holds p = k. Proof. The lemma follows easily from the fact that each preserved duo (S[i], S[i + 1]) of a string S, with S ∈ {A, B}, is induced by position i of S. Given an integer k, let C = {c1, . . . , ck} be a set of k colors. Let F be a family of perfect hash functions from the positions of B to the set C. Informally, we assign k distinct colors to the positions of B that may induce preserved duos, and by dynamic programming we compute if there exist k distinct positions in A that are mapped to these candidate duos of B. By Def. 2.1, we consider a function f ∈ F that associates a distinct color to each of the k positions of B that induces a preserved duo. Define D[i, C ′], for 1 ≤ i ≤ n, and C ′ ⊆ C, as a function equal to 1 if there exist a set SB of C ′ positions of B, each one associated with a distinct color in C ′, and a set SA of C ′ positions of A[1, i], such that there exists a mapping from SA to SB that preserves C ′ duos; otherwise, the function is equal to 0. Define P [h, i, C ′] as a function equal to 1 when there exist positions q and r in B, with 1 ≤ q < r ≤ B, such that each color in C ′ is associated with a position between q and r − 1, and substring B[q, r] is identical to A[h, i]; otherwise the function is equal to 0. We can compute D[i, C ′] as follows: D[i, C ′] = max C ′′⊆C ′ D[h, C ′′] × P [h + 1, i, C ′ \ C ′′] where h < i − 1, i − h − 1 = C ′ \ C ′′ D[i − 1, C ′]   In the basic case it holds D[1, C ′] = 1 if C ′ = 0, else D[1, C ′] = 0. It is easy to see that there exists a solution of Max-Duo PSM with k preserved duos, if and only if D[n, C] = 1. Next we prove the correctness of the recurrence. Lemma 2. Given two related strings A and B, there exists a partial mapping of A[1, i] into B that preserves C ′ duos induced by positions of B colored by C ′ if and only if D[i, C ′] = 1. Proof. We prove the lemma by induction on i. First consider the basic case, that is i = 1, then D[1, C ′] = 1 if and only if C ′ = 0, since A[1] contains no duo. Assume that the lemma holds for j < i, we show that it holds for j = i. (⇒) First, assume that D[i, C ′] = 1, then we show that there exists a partial mapping of A[1, i] into B that preserves C ′ duos induced by positions of B colored by C ′. By assuming D[i, C ′] = 1, then, if D[i−1, C ′] = 1, by induction hypothesis there exists a partial mapping of A[1, i − 1] into B that preserves C ′ duos induced by positions of B colored by C ′. On the other hand, we have D[i, C ′] = D[h, C ′′] × P [h + 1, i, C ′ \ C ′′] = 1, for some C ′′ ⊆ C ′, with C ′ \ C ′′ = i − h − 1. Then, since D[h, C ′′] = 1, by induction hypothesis there exists a partial mapping of A[1, h] into B that preserves C ′′ duos induced by positions of B colored by C ′′. Moreover, P [h + 1, i, C ′ \ C ′′] = 1, and it follows that there exist positions q and r of B such that each color in C ′ \ C ′′ is associated with a distinct position t of B, with q ≤ t ≤ r − 1, and B[q, r] is identical to A[h + 1, i]. Hence, it follows that i − h − 1 duos are preserved by mapping A[h + 1, i] into B[q, r], and are induced by positions of B colored by C ′ \ C ′′. As a consequence there exists a partial mapping of A[1, i] into B that preserves C ′ duos induced by positions of B colored by C ′. (⇐) Now, assume that there exists a partial mapping of A[1, i] into B that preserves C ′ duos induced by positions of B colored by C ′. We show that D[i, C ′] = 1. We can consider the following cases: there exists a sequence of preserved consecutive duos dA(h+1,i) mapped into a sequence of preserved consecutive duos dB(z+1,j), with j − z = i − h or no preserved duo is induced by position i − 1 of A. In the latter case, by induction hypothesis, D[i − 1, C ′] = 1 and hence D[i, C ′] = 1. In the former case, since function f assigns a distinct color to each position of B that induces a preserved duo, there exists a set C ′′ such that each position of dB(z+1,j) inducing a preserved duo with dA(h+1,i) is associated with a distinct color in C ′′ ⊆ C ′, and each position of B that induces a preserved duo 4 with a position of A[1, h] is associated with a distinct color of C ′ \ C ′′. Hence, P [h + 1, i, C ′′] = 1, for some set C ′′ ⊆ C ′. Moreover, by induction hypothesis D[h, C ′ \ C ′′] = 1, with i − h − 1 = C ′ \ C ′′, and by the first case of the recurrence D[i, C ′] = 1. From the previous lemma, we can conclude the correctness of the algorithm. Theorem 1. Let A and B be two related strings on an alphabet Σ. Then, it is possible to compute if there exists a solution of Max-Duo PSM on instance (A, B, k) in time 2O(k)O(poly(n) log(n)). Proof. The correctness of the algorithm follows from the correctness of the dynamic programming recurrence (see Lemma 2). Now, we consider the time complexity of the algorithm. We recall that n = A = B. First, assume that there exists a function f in a perfect family F of hash functions, such that f color-codes the positions of B. Table D[i, C ′] contains O(2kn) entries. Each entry is computed by the recurrence which looks at most 2kn possible entries. Indeed, in the first case, the recurrence must check the entries D[h, C ′′], where h ≤ n (hence, there are at most n of such values), and C ′′ ⊆ C ′ (hence, there are at most 2k of such subsets). Moreover, the value of P [h, i, C ′ \ C ′′] can be checked in constant time. Notice that P [h, i, C ′ \ C ′′] can be precomputed in time O(2kk3n2). Indeed P [h, i, C ′ \ C ′′] contains O(2kkn) positions, since for each position i in A, there exist at most k positions h + 1 and at most 2k subsets C ′ \ C ′′ to be checked. Given positions h and i, and subset C ′ \ C ′′, we must check that each color in C ′ \ C ′′ is associated with a position between q and r − 1 of B, and that substring B[q, r] is identical to A[h, i]. This can be done in time O(k2n) checking whether each substring B[q, r] of length bounded by k (there are at most O(kn) of such strings) is identical to A[h, i] and each color in C ′ \ C ′′ is associated with a position j of B[q, r − 1]. It follows that table D[i, C ′] can be computed in time O(22kk3n2) (considering the cost to precompute P [h + 1, i, C ′ \ C ′′]). In order to find an injective function f in a perfect family F , we must iterate through the 2O(k)O(log(n)) functions of F . Since the family F can be computed in time 2O(k)poly(n) and k ≤ n, it follows that the overall complexity is indeed 2O(k)O(poly(n) log(n)). 4. A Reduction to a Polynomial Kernel In this section, we prove that the Max-Duo PSM problem admits a polynomial size kernel, by presenting a polynomial-time algorithm that, starting from an instance (A, B, k) of Max-Duo PSM, computes an instance (A′, B′, k), such that the length of A′ and B′ is bounded by O(k6). The general idea of the reduction is that in Phase 1, starting from the related strings A and B, we compute two subsets of duos of A and B, denoted by CA and CB respectively, that may eventually be preserved, while any other duo not in these sets will not be preserved. Then, in Phase 2, starting from sets CA and CB, we compute two related strings A′ and B′ respectively, so that (A′, B′, k) is an instance of Max-Duo PSM. 4.1. Phase 1: Constructing Small Sets of Relevant Duos Here, we present the algorithm that in polynomial-time, starting from the related strings A and B, computes two subsets CA and CB, of duos of A and B, respectively, called candidate sets, having the following properties: 1. there exists a solution of Max-Duo PSM on instance (A, B, k) if and only if there exist C ′ A ⊆ CA, C ′ B ⊆ CB, with C ′ A = C ′ 2. CA and CB contains O(k6) duos. B = k such that there is a mapping of C ′ A into C ′ B; In order to compute CA and CB, the algorithm iteratively adds (bounding its size) a set of duos of A (of B, respectively) to CA (CB, respectively). Recall that k denotes the number of duos preserved by a solution of Max-Duo PSM. Before giving the details, we describe informally the three rules on which our Phase 1 of the kernelization is based. Rule 1 computes a maximum matching M of a graph that represents the duos of A and B. Since 5 M is a maximum matching, we are sure that if there exists a preserved duo whose corresponding string is ′ab′ in a solution, then all the duos whose corresponding string is ′ab′ will be added to set CA or set CB (see Lemma 4). Consider one of such duos (A[i], A[i + 1]); in Rule 2, we add to CA all the duos (not already included in CA) that belong to the sequences of consecutive duos induced by the substrings of size k + 1 that include (A[i], A[i+1]). This ensures that if a sequence dA(h,j), that consists of k duos and that includes (A[i], A[i+1]), is preserved by a solution of Max-Duo PSM, then the duos of dA(h,j) are included in CA. Finally, notice that (A[i], A[i + 1]) can be mapped to a set of duos of B whose size is not bounded by a function of k. Rule 3 adds either all the sequences of duos of B where a sequence of at most k duos of CA can be mapped (if such sequences are at most k2) or it adds at most k2 + 1 of such sequences (without loss of generality we add the k2 + 1 leftmost of such sequences). It is sufficient to add k2 + 1 sequences of duos, since we can ensure (see Lemma 7 and Lemma 8) that if there exists a solution where (A[i], A[i + 1]) is preserved, then the same property holds for a partial mapping of the duos of CA into the duos of CB. Indeed, since there exist at most k sequences of preserved duos of A, each one having length at most k, it follows that they can overlap at most k2 sequences of duos where (A[i], A[i + 1]) can be mapped. For this reason, by adding k2 + 1 disjoint sequences of duos, we can guarantee that there exists a sequence of duos of B where (A[i], A[i + 1]) can be mapped. We start by giving the details of our algorithm. First, we consider an easy bound on the length of each sequence of consecutive duos of A and B that can be preserved. Notice indeed that if there exists a sequence of consecutive duos of A having length at least k that can be mapped into a sequence of consecutive duos of B having length k (which can be computed in polynomial time), then obviously there exists a solution that preserves at least k duos. Hence, we assume that the following claim holds. Claim 1. There is no sequence of consecutive duos of A having length at least k that can be mapped into a sequence of consecutive duos of B having length at least k. Now, we are able to define the rules for the Phase 1 of the kernelization. The first rule is based on the approach of [4] that leads to a 1 4 -approximation algorithm. The approximation algorithm given in [4] is based on a graph representation of the duos of the given input strings. A maximum matching of this graph is then computed and it is decomposed into four submatchings; the maximum of such submatchings is then returned as the approximated solution of factor 1 4 . As in [4], we first consider a bipartite graph G = (VA ⊎ VB, E) associated with the related strings A and B, input of Max-Duo PSM, and defined as follows: • for each duo in A, there exists a vertex in VA; • for each duo in B, there exists a vertex in VB; • there exists an edge {va, vb} ∈ E connecting a vertex va ∈ VA to a vertex vb ∈ VB if and only if they represent a preservable duo. Now, we are ready to present the first rule of the kernelization algorithm. Rule 1. Compute (in polynomial time) a maximum matching M ⊆ E of G and define CA and CB as the sets of duos corresponding to the endpoints of each edge of M . More precisely and CA = {va ∈ VA{va, x} ∈ M } CB = {vb ∈ VB{x, vb} ∈ M }. It can be shown that CA, CB ≤ 4k, since otherwise we can compute a solution of Max-Duo PSM on instance (A, B, k). Lemma 3. Given two related strings A and B, let G be the corresponding graph. Let M be a maximum matching of G and let CA and CB be the two sets of duos built by Rule 1. Then, if M ≥ 4k and CA, CB ≥ 4k, Max-Duo PSM on instance (A, B, k) admits a feasible solution. 6 Proof. It is shown in [4] that the value of a maximum matching M is an upper bound on the number of preserved duos of the related strings A and B. Moreover, in [4] it is shown that M can be partitioned in polynomial-time into four submatchings, such that each of them induces a partial mapping of A into B; if more than k duos are preserved by one of the partial mappings, then it is a solution of Max-Duo PSM on instance (A, B, k). Then, if M ≥ 4k and, by construction of CA and CB, CA, CB ≥ 4k, one of the submatchings induces a partial mapping of A into B that preserves at least k duos, hence Max-Duo PSM on instance (A, B, k) admits a feasible solution. In the following, we assume that M < 4k and CA, CB < 4k. Next, we prove another useful property of the computed maximum matching M of G. We denote by MA (MB, respectively) the set of vertices of VA (VB, respectively) that are endpoints of an edge belonging to M . Lemma 4. Consider the symbols a, b ∈ Σ and assume that there exist preservable duos of the related strings A and B, whose corresponding string is ′ab′. Then, at most one of the sets VA \ MA and VB \ MB contains a vertex associated with a duo whose corresponding string is ′ab′. Proof. Assume by contradiction that the lemma does not hold. It follows that there exists one vertex of va ∈ VA associated with a duo of A whose corresponding string is ′ab′ and there exists one vertex of vb ∈ VB associated with a duo of B whose corresponding string is ′ab′, such that va, vb are not endpoints of an edge of M . Hence by adding such an edge to M (which exists by construction of G), it is possible to obtain a matching larger than M , which contradicts the fact that M is maximum. We recall that, given two positions 1 ≤ i < j ≤ n, dS(i,j) denotes the sequence of consecutive duos (S[i], S[i + 1]), . . . , (S[j − 1], S[j]). By a slight abuse of notation, we denote by dS(i−k,i+k) the sequence of duos between position S[l], where l = max{1, i − k}, and position S[r], where r = min{n, i + k}. Rule 2. For each duo (S[i], S[i + 1]) of CS, with S ∈ {A, B}, add to CS all the duos of dS(i−k,i+k). Given S ∈ {A, B}, we recall that ¯S is the string in {A, B} \ {S}. It can be shown that the following properties hold. Lemma 5. Given a string S, with S ∈ {A, B}, consider a duo (S[i], S[i + 1]) added by Rule 1 to CS. If there exists a solution of Max-Duo PSM on instance (A, B, k) that maps a sequence dS(i−t1,i+t2) with 0 ≤ t1 ≤ k and 1 ≤ t2 ≤ k, of consecutive duos of S that includes (S[i], S[i + 1]) into a sequence d ¯S(i−u1,i+u2) of consecutive duos of ¯S, then Rule 2 adds all the duos of dS(i−t1,i+t2) to CS. Proof. From Claim 1, it follows that we assume that if a solution of Max-Duo PSM on instance (A, B, k) defines a mapping of a sequence dS(i−t1,i+t2) of S into a sequence d ¯S(i−u1,i+u2) of ¯S, then t2 + t1 + 1 = u2 + u1 + 1 ≤ k, hence t1, t2 ≤ k and u1, u2 ≤ k. Since Rule 2 adds to CS the sequence dS(i−k,i+k) of duos, the lemma holds. Moreover, we can bound the number of duos added by Rule 2 as follows. Lemma 6. Rule 2 adds at most 8k2 duos to each set CS, with S ∈ {A, B}. Proof. Since M < 4k, it follows that there exist less than 4k positions i, with 1 ≤ i ≤ n, such that the sequence dS(i−k,i+k) of duos are added to CS. Since there exist 2k consecutive duos in dS(i−k,i+k), at most 8k2 duos are added to CS. We are now able to define Rule 3. 7 Rule 3. Consider a sequence dS(p,q) of consecutive duos that has length at most k, such that each duo (S[i], S[i + 1]), with p ≤ i ≤ q − 1, is added by Rule 1 and Rule 2 to set CS; add a set of candidate duos to C ¯S as follows: • if there exist at least k2 + 1 non-overlapping sequences in ¯S where dS(p,q) can be mapped: add to C ¯S all the duos belonging to the leftmost non-overlapping k2 + 1 sequences in ¯S where dS(p,q) can be mapped; • else, add to C ¯S all the duos belonging to the sequences of consecutive duos in ¯S where dS(p,q) can be mapped. It can be shown that the following property holds. Lemma 7. Consider a solution X that preserves a sequence dS(p,q) of consecutive duos such that each duo (S[i], S[i + 1]), with p ≤ i ≤ q − 1, is added by Rule 1 and Rule 2 to sets CS. Then Rule 3 either adds to C ¯S the duos of ¯S where dS(p,q) is mapped by X, or there are k2 + 1 non-overlapping sequences of consecutive duos of ¯S in C ¯S where dS(p,q) can be mapped. Proof. Consider a sequence dS(p,q) of consecutive duos preserved by a solution X of Max-Duo PSM on instance (A, B, k). Then, consider the two cases of Rule 3. In the second case, since C ¯S contains all the consecutive duos in ¯S where dS(p,q) can be mapped, then the lemma holds. Now, consider the first case of Rule 3. Then, by construction in C ¯S there are k2 + 1 non-overlapping sequences of consecutive duos in ¯S where dS(p,q) can be mapped. Lemma 8. Consider a solution X of Max-Duo PSM on instance (A, B, k). Then, there exist subsets of duos C ′ B ⊆ CB , such that there is a mapping of C ′ A ⊆ CA and C ′ A into C ′ B and C ′ A = C ′ B = k. Proof. Consider a duo (S[i], S[i + 1]), where S ∈ {A, B}, S[i] = a and S[i + 1] = b, such that a solution X of Max-Duo PSM on instance (A, B, k) maps a sequence dS(p,q) of consecutive duos of S, with i − k ≤ p < q ≤ i + k, into a sequence of consecutive duos d ¯S(t,u). Notice that all the duos of dS(p,q) belong to CS, or all the duos of d ¯S(t,u) belong to ¯S. Indeed, assume that the duo (S[i], S[i + 1]) is mapped into the duo ( ¯S[j], ¯S[j + 1]) by X. By Lemma 4, it follows that Rule 1 adds duo (S[i], S[i + 1]) to CS or ( ¯S[j + 1], ¯S[j + 1 + 1]) to C ¯S. Moreover, by Lemma 5, Rule 2 adds all the duos of dS(p,q) to CS or all the duos of d ¯S(t,u) to ¯S. In what follows, we assume w.l.o.g. that all the duos dS(p,q) belong to CS. Let S be the string having the maximum number of occurrences of duos whose corresponding string is ′ab′. Then, by Lemma 4 and by Rule 1, each duo of ¯S, whose corresponding string is ′ab′, is added to C ¯S. Moreover, consider a sequence dS(p,q) of consecutive duos of S, with i − k ≤ p < q ≤ i + k, mapped into a sequence d ¯S(t,u) of consecutive duos of ¯S. By Lemma 5, all the duos of d ¯S(t,u) are added to C ¯S by Rule 2. Hence, we can assume that the duos of dS(p,q) and the duos of d ¯S(t,u) belong to C ′ B respectively, and there is a mapping between such duos. A and C ′ Assume that is S the string having the minimum number of occurrences of ′ab′ and consider the sequence dS(p,q) of consecutive duos of X mapped into the sequence d ¯S(t,u) of consecutive duos. By Lemma 7, either all the consecutive duos of ¯S where dS(p,q) can be mapped are included in C ¯S, or the duos of k2 + 1 non-overlapping sequences of consecutive duos of ¯S, where dS(p,q) can be mapped, are included in C ¯S. In the former case, all the duos of d ¯S(t,u) are added to C ¯S by Rule 3, hence we can assume that the duos ¯S respectively, and there is a mapping between such S and C ′ of dS(p,q) and the duos of d ¯S(t,u) belong to C ′ duos. In the latter case, we show that, even if C ¯S does not contain all the duos of d ¯S(t,u), it contains a sequence of consecutive duos where dS(p,q) can be mapped. Notice that each sequence of consecutive duos of ¯S mapped to sequence of consecutive duos of S has length bounded by k (see Claim 1) and, since X preserves k duos, the set C ′ ¯S contains at most k of such sequences of consecutive duos. It follows that each sequence of ¯S can overlap at most k non-overlapping occurrences of dS(p,q) in ¯S. Hence the consecutive duos added to C ′ ¯S can overlap at most k2 non-overlapping sequence whole set of sequences of consecutive duos preserved of C ′ 8 of consecutive duos in ¯S where dS(p,q) can be mapped. Since we have added to C ¯S the duos belonging to k2 + 1 non-overlapping sequences of consecutive duos of ¯S where dS(p,q) can be mapped, then there exists at least a sequence d ¯S(w,y) of consecutive duos in C ¯S where dS(p,q) can be mapped. Hence we can assume that the duos of dS(p,q) and the duos of d ¯S(w,y) belong to C ′ ¯S respectively, and there is mapping between such duos. S and C ′ Now, we are able to bound the size of the sets CA and CB. Lemma 9. Given an input string S ∈ {A, B}, Rules 1-3 add at most O(k6) duos to each set CS . Proof. By Lemma 4, Rule 1 adds at most 4k duos to each set CS, with S ∈ {A, B}. By Lemma 6, Rule 2 adds at most O(k2) duos to each set CS, with S ∈ {A, B}. Rule 3 considers O(k2) sequences dS(p,q) of length bounded by k. For each such sequences of consecutive duos, Rule 3 adds duos to C ¯S in two possible ways. In the first case k2 + 1 sequences of consecutive duos are selected, each one having size at most k, thus O(k3) duos are added to C ¯S; thus O(k5) are added to In the second case there exist at most k2 non-overlapping sequences of consecutive duos (each one C ¯S. having length at most k) that can preserve dS(p,q). Moreover, each of the O(k2) non-overlapping sequences of consecutive duos where dS(p,q) can be mapped can overlap at most k sequences of consecutive duos that can preserve dS(p,q). Thus, for each of such O(k2) non-overlapping sequences of consecutive duos, O(k4) duos are added to C ¯S. Hence, the overall number of consecutive duos added to C ¯S is O(k6). 4.2. Phase 2: Completing the construction From the sets CA and CB previously computed, we construct an instance of Max-Duo PSM, that is two related strings A′ and B′. Furthermore, we will show that the length of A′ and B′ is bounded by O(k6) and that the preservable duos of A′ and B′ are those of CA and CB, respectively. Recall that A and B are two related strings over alphabet Σ. Consider the set TA of substrings of A (the set TB of substrings of B, respectively) that induces the duos in CA (in CB, respectively) and assume that TS, with S ∈ {A, B}, contains qS strings, namely t1,S, . . . tqS ,S. Before describing the two strings A′ and B′, we construct the alphabet Σ′ on which they are based, where: Σ′ = Σ ∪ {eA,i : 1 ≤ i ≤ qA} ∪ {eB,i : 1 ≤ i ≤ qB} ∪ {ga : a ∈ Σ has a different number of occurrences in TA and TB} We concatenate the substrings of TA (of TB, respectively) with symbols of Σ′ \ Σ. We compute an intermediate string PS, with S ∈ {A, B}, as follows. First, set PS = t1,S · eS,1. Then, for each i with 2 ≤ i ≤ qS, concatenate the string PS with string ti+1,S · eS,i. Finally, append string e ¯S,1 . . . e ¯S,qS at the right end of PS. Now, we append some strings to the right end of PA and PB in order to compute A′ and B′ over alphabet Σ′. More precisely, for each symbol a ∈ Σ such that the number of occurrences of a in PA and in PB is different, we apply the following procedure. Assume w.l.o.g. that PA contains hA,a occurrences of symbol a and PB contains hB,a occurrences of symbol a, with hA,a > hB,a. Then, we append a string (gaa)hA,a−hB,a (that is the string consisting of the concatenation of hA,a − hB,a occurrences of gaa) to the right end of PB, while we append the string (ga)hA,a−hB,a (that is the string consisting of the concatenation of hA,a − hB,a occurrences of ga) to the right end of PA. Similarly, if hA,a < hB,a, we append a string (gaa)hB,a−hA,a to the right end of PA, while we append the string (ga)hB,a−hA,a to the right end of PB (see Figure 2). The following lemma guarantees that the instance built on A′ and B′, is an instance of Max-Duo PSM. Lemma 10. Let A′ and B′ be the two strings computed starting from TA and TB, respectively. Then, A′ and B′ are related. Moreover, A′ and B′ are bounded by O(k6). 9 PA { A′ = B′ = t1,B · eB,1 . . . tqB ,B · eB,qB } z t1,A · eA,1 . . . tqA,A · eA,qA eB,1 . . . eB,qB } {z z eA,1 . . . eA,qA gaagaa . . . gaa } } {z (gaa)hA,a−hB,a z { PB (ga)hA,a −hB,a gaga . . . ga (gb)hA,b−hB,b gbgb . . . gb gbbgbb . . . gbb (gcc)hB,c−hA,c gccgcc . . . gcc gcgc . . . gc } } { z { } {z (gbb)hA,b −hB,b (gc)hB,c−hA,c {z } Figure 2: An example of two related strings A′ and B ′ constructed during Phase 2 from sets CA and CB (and sets TAand TB of substrings), respectively. We assume that the string TA contains more occurrences of symbol a, b (denoted by hA,a and hA,b, respectively) than TB (denoted by hB,a and hB,b, respectively), while string TB contains more occurrences of symbol c (denoted by hB,c) than TA (denoted by hA,c). Hence, strings gaa . . . gaa and gbb . . . gbb are appended to construct A′, while strings ga . . . ga and gb . . . gb are appended to construct B ′; string gcc . . . gcc is appended to construct B ′, while string gc . . . gcc is appended to construct A′. Proof. Notice that each symbol in Σ′ \ Σ by construction has the same number of occurrences in A′ and B′. Moreover, for each symbol in a ∈ Σ, both A′ and B′ contain by construction max(hA,a, hB,a) occurrences of a. From Lemma 9 it follows that CA and CB are bounded by O(k6), hence the symbols eS,i, with 1 ≤ i ≤ qS (where S ∈ {A, B}), inserted in A′ and B′ are at most O(k6). Similarly, the number of symbols ga /∈ Σ and a ∈ Σ inserted are at most O(k6), since in the worst case at most CA (CB, respectively) symbols of Σ are inserted in A′ (in B′, respectively), and for each of such symbols, exactly one occurrence of some symbol ga is inserted in A′ and B′. Finally, the following property holds. Lemma 11. Let X be a solution of Max-Duo PSM on instance (A′, B′, k), such that X maps (A′[i], A′[i+1]) into (B′[j], B′[j + 1]). Then (A′[i], A′[i + 1]) and (B′[j], B′[j + 1]) are duos of CA and CB , respectively. Proof. The lemma follows from the fact that, by construction, each preservable duo of A′ and B′ belongs to strings in TA and TB, respectively. Indeed, consider w.l.o.g. a duo (S ′[i], S ′[i + 1]) of S ′, with S ′ ∈ {A′, B′}, not in CS. Then, by construction of S ′, (S ′[i], S ′[i + 1]) must include at least a symbol x in Σ′ \ Σ, as each new occurrence of a symbol in Σ is adjacent to a symbol in Σ′ \ Σ. Now, notice that if x is equal to eS,jS , with 1 ≤ j ≤ qS, then by construction it belongs to duos with different symbols in S ′ and ¯S ′, as x is adjacent in ¯S ′ only to symbol in Σ′ \ Σ, while in S is adjacent only to symbols in Σ, with the exception of eS,qS , which again by construction cannot belong to a preservable duo. Now, consider a symbol gy ∈ Σ′ \ Σ. Then exactly one of A′, B′ contains a duo whose corresponding string is ygy and exactly one of A′, B′ contains a duo whose corresponding string is gygy. Moreover, exactly one of A′, B′ contains a duo whose corresponding string is zgy and exactly one of A′, B′ contains a duo whose corresponding string is gzgy, with z a symbol in Σ, with the exception of the first symbol appended to PA or PB, which again by construction cannot belong to a preservable duo. We conclude the description of the kernelization algorithm with the following theorem. 2 k6) Theorem 2. Given an instance (A, B, k) of Max-Duo PSM, Phase 1 and Phase 2 compute in time O(n an instance (A′, B′, k), with A′ and B′ bounded by O(k6), such that there exists a solution of Max-Duo PSM on instance (A, B, k) if and only if there exists a solution of Max-Duo PSM on instance (A′, B′, k). 5 Proof. Notice that by Lemma 10, A′ and B′ are bounded by O(k6). First, we show that there exists a solution of Max-Duo PSM on instance (A, B, k) if and only if there exists a solution of Max-Duo PSM on instance (A′, B′, k). (⇒) Consider a solution of Max-Duo PSM on instance (A′, B′, k), then a solution Max-Duo PSM on instance (A, B, k) can be computed by preserving those duos of (A, B, k) corresponding to the duos preserved by the solution of Max-Duo PSM on instance (A′, B′, k). 10 (⇐) By Lemma 8 and by Lemma 11, if there exists a solution of of Max-Duo PSM on instance (A, B, k), then there exists a solution of of Max-Duo PSM on instance (A′, B′, k). Now, we show that Phase 1 and Phase 2 compute instance (A′, B′, k) in time O(n 2 k6). Rule 1 requires time O(n2) to compute the graph G and O(n 2 ) to compute a maximum bipartite matching of G [16]. Rule 2 requires time O(k2) to add to CA and CB, for each of the at most O(k) duos of MA and MB, the O(k) duos of dS(i−k,i+k). Rule 3 requires time O(k6n) to add to CA and CB, for each duo added by Rule 1-2 (which are at most O(k2)), the sequences d ¯S(p,q) (which are at most O(k3)). 5 5 Finally, Phase 2 computes A′ and B′ in time O(k6). Indeed, PS can be computed in time O(k6) by concatenating a set of O(k6) strings. Moreover, we can count the number of occurrences of symbols of Σ in a string PS ∈ {A, B} in time O(k6), and we append O(k6) strings gaa, ga in time O(k6). 5. Conclusion In this paper, we have investigated the parameterized complexity of the Max-Duo PSM problem, by first giving a parameterized algorithm based on color-coding and then showing that it admits a kernel of size O(k6). From a paramterized complexity point of view, there are some interesting open problems for Max- Duo PSM. First, following the approach of parameterizing above a guaranteed value, it would be interesting to investigate the parameterized complexity of the problem when the parameter is the number of conserved duos minus the conserved duos induced by the submatching returned by the approximation algorithm in [4]. Furthermore, it would be interesting to improve upon the time (and space) complexity of our color-coding based algorithm. In particular, notice that our color-coding based algorithm requires exponential space complexity, as it makes use of two tables of size O(2kkn). References [1] Alon, N., Yuster, R., Zwick, U.: Color-coding. Journal of the ACM 42(4), 844 -- 856 (1995) [2] Bonizzoni, P., Della Vedova, G., Dondi, R., Pirola, Y.: Variants of constrained longest common subsequence. Inf. Process. Lett. 110(20), 877 -- 881 (2010) [3] Bonizzoni, P., Dondi, R., Mauri, G., Zoppis, I.: Restricted and swap common superstring: A multivariate algorithmic perspective. Algorithmica 72(4), 914 -- 939 (2015), http://dx.doi.org/10.1007/s00453-014-9882-8 [4] Boria, N., Kurpisz, A., Leppanen, S., Mastrolilli, M.: Improved approximation for the maximum duo-preservation string mapping problem. In: Brown, D., Morgenstern, B. (eds.) Algorithms in Bioinformatics - 14th International Workshop, WABI 2014, Wroclaw, Poland, September 8-10, 2014. Proceedings. Lecture Notes in Computer Science, vol. 8701, pp. 14 -- 25. Springer (2014) [5] Bulteau, L., Carrieri, A.P., Dondi, R.: Fixed-parameter algorithms for scaffold filling. Theor. Comput. Sci. 568, 72 -- 83 (2015), http://dx.doi.org/10.1016/j.tcs.2014.12.005 [6] Bulteau, L., Fertin, G., Komusiewicz, C., Rusu, I.: A fixed-parameter algorithm for minimum common string partition with few duplications. In: WABI. pp. 244 -- 258 (2013) [7] Bulteau, L., Komusiewicz, C.: Minimum common string partition parameterized by partition size is fixed- parameter tractable. In: Chekuri, C. (ed.) Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014. pp. 102 -- 121. SIAM (2014), http://dx.doi.org/10.1137/1.9781611973402.8 [8] Chen, W., Chen, Z., Samatova, N.F., Peng, L., Wang, J., Tang, M.: preservation string mapping problem with linear programming. Theor. Comput. Sci. http://dx.doi.org/10.1016/j.tcs.2014.02.017 Solving the maximum duo- (2014), 1 -- 11 530, [9] Chen, X., Zheng, J., Fu, Z., Nan, P., Zhong, Y., Lonardi, S., Assignment of ortholo- IEEE/ACM Trans. Comput. Biology Bioinform. 2(4), 302 -- 315 (2005), Jiang, T.: gous genes via genome rearrangement. http://doi.acm.org/10.1145/1100863.1100950 [10] Chrobak, M., Kolman, P., Sgall, J.: The greedy algorithm for the minimum common string partition problem. ACM Transactions on Algorithms 1(2), 350 -- 366 (2005), http://doi.acm.org/10.1145/1103963.1103971 [11] Cormode, G., Muthukrishnan, S.: The string edit distance matching problem with moves. ACM Transactions on Algo- rithms 3(1) (2007), http://doi.acm.org/10.1145/1219944.1219947 [12] Damaschke, P.: Minimum common string partition parameterized. In: Crandall, K.A., Lagergren, J. (eds.) Algorithms in Bioinformatics, 8th International Workshop, WABI 2008, Karlsruhe, Germany, September 15-19, 2008. Proceedings. Lecture Notes in Computer Science, vol. 5251, pp. 87 -- 98. Springer (2008) [13] Downey, R., Fellows, M.: Fundamentals of Parameterized Complexity. Springer (2013) [14] Fellows, M.R., Fertin, G., Hermelin, D., Vialette, S.: Upper and lower bounds for finding connected motifs in vertex-colored graphs. J. Comput. Syst. Sci. 77(4), 799 -- 811 (2011), http://dx.doi.org/10.1016/j.jcss.2010.07.003 11 [15] Goldstein, A., Kolman, P., Zheng, J.: Minimum common string partition problem: Hardness and approximations. Electr. J. Comb. 12 (2005) [16] Hopcroft, J.E., Karp, R.M.: An n5/2 algorithm for maximum matchings in bipartite graphs. SIAM J. Comput. 2(4), 225 -- 231 (1973) [17] Jiang, H., Zhu, B., Zhu, D., Zhu, H.: Minimum common string partition revisited. J. Comb. Optim. 23(4), 519 -- 527 (2012), http://dx.doi.org/10.1007/s10878-010-9370-2 [18] Kolman, P., Walen, T.: Reversal distance for strings with duplicates: Linear time approximation using hitting set. Electr. J. Comb. 14(1) (2007) [19] Niedermeier, R.: Invitation to Fixed-Parameter Algorithms. Oxford University Press (2006) 12
1809.02792
2
1809
2019-07-04T15:31:22
Fully-Functional Suffix Trees and Optimal Text Searching in BWT-runs Bounded Space
[ "cs.DS" ]
Indexing highly repetitive texts - such as genomic databases, software repositories and versioned text collections - has become an important problem since the turn of the millennium. A relevant compressibility measure for repetitive texts is r, the number of runs in their Burrows-Wheeler Transforms (BWTs). One of the earliest indexes for repetitive collections, the Run-Length FM-index, used O(r) space and was able to efficiently count the number of occurrences of a pattern of length m in the text (in loglogarithmic time per pattern symbol, with current techniques). However, it was unable to locate the positions of those occurrences efficiently within a space bounded in terms of r. In this paper we close this long-standing problem, showing how to extend the Run-Length FM-index so that it can locate the occ occurrences efficiently within O(r) space (in loglogarithmic time each), and reaching optimal time, O(m + occ), within O(r log log w ({\sigma} + n/r)) space, for a text of length n over an alphabet of size {\sigma} on a RAM machine with words of w = {\Omega}(log n) bits. Within that space, our index can also count in optimal time, O(m). Multiplying the space by O(w/ log {\sigma}), we support count and locate in O(dm log({\sigma})/we) and O(dm log({\sigma})/we + occ) time, which is optimal in the packed setting and had not been obtained before in compressed space. We also describe a structure using O(r log(n/r)) space that replaces the text and extracts any text substring of length ` in almost-optimal time O(log(n/r) + ` log({\sigma})/w). Within that space, we similarly provide direct access to suffix array, inverse suffix array, and longest common prefix array cells, and extend these capabilities to full suffix tree functionality, typically in O(log(n/r)) time per operation.
cs.DS
cs
Fully-Functional Suffix Trees and Optimal Text Searching in BWT-runs Bounded Space ∗ Travis Gagie1,2, Gonzalo Navarro2,3, and Nicola Prezza4 1 EIT, Diego Portales University, Chile 2 Center for Biotechnology and Bioengineering (CeBiB), Chile 3 Department of Computer Science, University of Chile, Chile 4 Department of Computer Science, University of Pisa, Italy Abstract. Indexing highly repetitive texts -- such as genomic databases, software repositories and versioned text collections -- has become an important problem since the turn of the millennium. A relevant compressibility measure for repetitive texts is r, the number of runs in their Burrows-Wheeler Transforms (BWTs). One of the earliest indexes for repetitive collections, the Run-Length FM-index, used O(r) space and was able to efficiently count the number of occurrences of a pattern of length m in the text (in loglogarithmic time per pattern symbol, with current techniques). However, it was unable to locate the positions of those occurrences efficiently within a space bounded in terms of r. Since then, a number of other indexes with space bounded by other measures of repetitiveness -- the number of phrases in the Lempel-Ziv parse, the size of the smallest grammar generating (only) the text, the size of the smallest automaton recognizing the text factors -- have been proposed for efficiently locating, but not directly counting, the occurrences of a pattern. In this paper we close this long-standing problem, showing how to extend the Run-Length FM-index so that it can locate the occ occurrences efficiently within O(r) space (in loglogarithmic time each), and reaching optimal time, O(m + occ), within O(r log logw(σ + n/r)) space, for a text of length n over an alphabet of size σ on a RAM machine with words of w = Ω(log n) bits. Within that space, our index can also count in optimal time, O(m). Multiplying the space by O(w/ log σ), we support count and locate in O((cid:100)m log(σ)/w(cid:101)) and O((cid:100)m log(σ)/w(cid:101) + occ) time, which is optimal in the packed setting and had not been obtained before in compressed space. We also describe a structure using O(r log(n/r)) space that replaces the text and extracts any text substring of length (cid:96) in almost-optimal time O(log(n/r) + (cid:96) log(σ)/w). Within that space, we similarly provide direct access to suffix array, inverse suffix array, and longest common prefix array cells, and extend these capabilities to full suffix tree functionality, typically in O(log(n/r)) time per operation. Our experiments show that our O(r)-space index outperforms the space-competitive alternatives by 1 -- 2 orders of magnitude. 1 Introduction The data deluge has become a pervasive problem in most organizations that aim to collect and process data. We are concerned about string (or text, or sequence) data, formed by collections of symbol sequences. This includes natural language text collections, DNA and protein sequences, source code repositories, semistructured text, and many others. The rate at which those sequence collections are growing is daunting, in some cases outpacing Moore's Law by a significant margin [109]. A key to handle this growth is the fact that the amount of unique material does not grow at the same pace of the sequences. Indeed, the fastest-growing string collections are in many cases highly repetitive, that is, most of the strings can be obtained from others with a few modifications. For example, most genome sequence collections store many genomes from the same species, which in the ∗Partially funded by Basal Funds FB0001, Conicyt, by Fondecyt Grants 1-171058 and 1-170048, Chile, and by the Danish Research Council DFF-4005-00267. An early partial version of this article appeared in Proc. SODA 2018 [46]. case of, say, humans differ by 0.1% [102] (there is some discussion about the exact percentage). The 1000-genomes project5 uses a Lempel-Ziv-like compression mechanism that reports compression ratios around 1% [40] (i.e., the compressed space is about two orders of magnitude less than the uncompressed space). Versioned document collections and software repositories are another natural source of repetitiveness. For example, Wikipedia reports that, by June 2015, there were over 20 revisions (i.e., versions) per article in its 10 TB content, and that p7zip6 compressed it to about 1%. They also report that what grows the fastest today are the revisions rather than the new articles, which increases repetitiveness.7 A study of GitHub (which surpassed 20 TB in 2016)8 reports a ratio of commit (new versions) over create (brand new projects) around 20.9 Version management systems offer a good solution to the problem of providing efficient access to the documents of a versioned collection, at least when the versioning structure is known. They factor out repetitiveness by storing the first version of a document in plain form and then the edits of each version of it. It is much more challenging, however, to provide more advanced functionalities, such as counting or locating the positions where a string pattern occurs across the collection. An application field where this need is most pressing is bioinformatics. The FM-index [32, 33] was extremely successful in reducing the size of classical data structures for pattern searching, such as suffix trees [114] or suffix arrays [81], to the statistical entropy of the sequence while emulating a significant part of their functionality. The FM-index has had a surprising impact far beyond the boundaries of theoretical computer science: if someone now sends his or her genome to be analyzed, it will almost certainly be sequenced on a machine built by Illumina10, which will produce a huge collection of quite short substrings of that genome, called reads. Those reads' closest matches will then be sought in a reference genome, to determine where they most likely came from in the newly-sequenced target genome, and finally a list of the likely differences between the target and the reference genomes will be reported. The searches in the reference genome will be done almost certainly using software such as Bowtie11, BWA12, or Soap213, all of them based on the FM-index.14 Genomic analysis is already an important field of research, and a rapidly growing industry [107]. As a result of dramatic advances in sequencing technology, we now have datasets of tens of thousands of genomes, and bigger ones are on their way (e.g., there is already a 100,000-human- genomes project15). Unfortunately, current software based on FM-indexes cannot handle such mas- sive datasets: they use 2 bits per base at the very least [65]. Even though the FM-index can represent the sequences within their statistical entropy [33], this measure is insensitive to the repetitiveness of those datasets [73, Lem. 2.6], and thus the FM-indexes would grow proportionally to the sizes of the sequences. Using current tools, indexing a set of 100,000 human genomes would require 75 TB of storage at the very least, and the index would have to reside in main memory to operate efficiently. To handle such a challenge we need, instead, compressed text indexes whose size is proportional to the amount of unique material in those huge datasets. 5http://www.internationalgenome.org 6http://p7zip.sourceforge.net 7https://en.wikipedia.org/wiki/Wikipedia:Size of Wikipedia 8https://blog.sourced.tech/post/tab vs spaces 9http://blog.coderstats.net/github/2013/event-types, see the ratios of push/create and commit.push. 10https://www.illumina.com. More than 94% of the human genomes in SRA [71] were sequenced by Illumina. 11http://bowtie-bio.sourceforge.net 12http://bio-bwa.sourceforge.net 13http://soap.genomics.org.cn 14Ben Langmead, personal communication. 15https://www.genomicsengland.co.uk/the-100000-genomes-project 2 1.1 Related work Makinen et al. [78, 108, 79, 80] pioneered the research on indexing and searching repetitive collec- tions. They regard the collection as a single concatenated text T [1..n] with separator symbols, and note that the number r of runs (i.e., maximal substrings formed by a single symbol) in the Burrows-Wheeler Transform [20] of the text is relatively very low on repetitive texts. Their index, Run-Length FM-Index (RLFM-index), uses O(r) words and can count the number of occurrences of a pattern P [1..m] in time O(m log n) and even less. However, they are unable to locate where those positions are in T unless they add a set of samples that require Θ(n/s) words in order to offer O(s log n) time to locate each occurrence. On repetitive texts, either this sampled structure is orders of magnitude larger than the O(r)-size basic index, or the locating time is extremely high. Many proposals since then aimed at reducing the locating time by building on other compression methods that perform well on repetitive texts: indexes based on the Lempel-Ziv parse [76] of T , with size bounded in terms of the number z of phrases [73, 42, 97, 9, 88, 15, 23]; indexes based on the smallest context-free grammar (or an approximation thereof) that generates T and only T [68, 21], with size bounded in terms of the size g of the grammar [25, 26, 41, 89]; and indexes based on the size e of the smallest automaton (CDAWG) [18] recognizing the substrings of T [9, 111, 7]. Table 1 summarizes the pareto-optimal achievements. We do not consider in this paper indexes based on other repetitiveness measures that only apply in restricted scenarios, such as those based on Relative Lempel-Ziv [74, 27, 11, 29] or on alignments [86, 87]. There are a few known asymptotic bounds between the repetitiveness measures r, z, g, and e: z ≤ g = O(z log(n/z)) [105, 21, 58] and e = Ω(max(r, z, g)) [9, 8]. Examples of string families are known that show that r is not comparable with z and g [9, 101]. Experimental results [80, 73, 9, 24], on the other hand, suggest that in typical repetitive texts it holds z < r ≈ g (cid:28) e. For highly repetitive texts, one hopes to have a compressed index not only able to count and locate pattern occurrences, but also to replace the text with a compressed version that nonetheless can efficiently extract any substring T [i..i+(cid:96)]. Indexes that, implicitly or not, contain a replacement of T , are called self-indexes. As can be seen in Table 1, self-indexes with O(z) space require up to O(z) time per extracted character, and none exists within O(r) space. Good extraction times are instead obtained with O(g), O(z log(n/z)), or O(e) space. A lower bound for grammar-based representations [113] shows that Ω((log n)1−/ log g) time, for any constant  > 0, is needed to access one random position within O(poly(g)) space. This bound shows that various current techniques using structures bounded in terms of g or z [17, 14, 43, 10] are nearly optimal (note that g = Ω(log n), so the space of all these structures is O(poly(g))). In an extended article [22, Thm. 6], the authors give a lower bound in terms of r, for binary texts on a RAM machine of w = Θ(log n) bits: Ω((log n)1−) for some constant  when using O(poly(r log n)) space. In more sophisticated applications, especially in bioinformatics, it is desirable to support a more complex set of operations, which constitute a full suffix tree functionality [54, 98, 77]. While Makinen et al. [80] offered suffix tree functionality, they had the same problem of needing Θ(n/s) space to achieve O(s log n) time for most suffix tree operations. Only recently a suffix tree of size O(e) supports most operations in time O(log n) [9, 8], where e refers to the e measure of T plus that of T reversed. Summarizing Table 1 and our discussion, the situation on repetitive text indexing is as follows. 1. The RLFM-index is the only structure able to count the occurrences of P in T in time O(m log n). However, it does not offer efficient locating within O(r) space. 3 Index Navarro [89, Thm. 6] Navarro [89, Thm. 5] Makinen et al. [80, Thm. 17] This paper (Lem. 1) This paper (Thm. 2) This paper (Thm. 3) Space O(z log(n/z)) O(g) O(r) O(r) Count time O(m log n + m log2+(n/z)) O(m2 + m log2+ g) O(m( log σ log log r + (log log n)2)) O(m log logw(σ + n/r)) O(r log logw(σ + n/r)) O(rw logσ logw(σ + n/r)) O(m) O((cid:100)m log(σ)/w(cid:101)) Space O(z) O(z log(n/z)) O(z log(n/z)) O(z log(n/z)) Index Kreft and Navarro [73, Thm. 4.11] Gagie et al. [42, Thm. 4] Bille et al. [15, Thm. 1] Christiansen and Ettienne [23, Thm. 2(3)] Christiansen and Ettienne [23, Thm. 2(1)] O(z log(n/z) + z log log z) Bille et al. [15, Thm. 1] Claude and Navarro [26, Thm. 1] Gagie et al. [41, Thm. 4] Makinen et al. [80, Thm. 20] Belazzougui et al. [9, Thm. 3] This paper (Thm. 1) This paper (Thm. 2) This paper (Thm. 3) Belazzougui and Cunial [7, Thm. 1] O(rw logσ logw(σ + n/r)) O(r log logw(σ + n/r)) O(z log(n/z) log log z) O(r + z) O(r) O(g + z log log z) O(r + n/s) O(g) O(e) Locate time O(m2h + (m + occ) log z) O(m log m + occ log log n) O(m(1 + log z/ log(n/z)) + occ(log z + log log n)) O(m + log z + occ(log z + log log n)) O(m + occ(log z + log log n)) O(m + occ log log n) O(m2 log logg n + (m + occ) log g) O(m2 + (m + occ) log log n) O((m + s · occ)( log σ log log r + (log log n)2)) O(m(log z + log log n) + occ(log z + log log n)) O((m + occ) log logw(σ + n/r)) O(m + occ) O((cid:100)m log(σ)/w(cid:101) + occ) O(m + occ) Structure Kreft and Navarro [73, Thm. 4.11] Gagie et al. [10, Thm. 2] Belazzougui et al. [14, Thm. 1] Belazzougui et al. [14, Thm. 2] Makinen et al. [80, Thm. 20] This paper (Thm. 4) Belazzougui and Cunial [7, Thm. 1] Space O(z) Extract time O((cid:96) h) O(z log(n/z)) O((1 + (cid:96)/ logσ n) log(n/z)) O(g) O(log n + (cid:96)/ logσ n) O(g log n log(n/g)) O(log n/ log log n + (cid:96)/ logσ n) O(r + n/s) O(r log(n/r)) O(e) O((s + (cid:96))( log σ log log r + (log log n)2)) O(log(n/r) + (cid:96) log(σ)/w) O(log n + (cid:96)) Structure Makinen et al. [80, Thm. 30] This paper (Thm. 9) Belazzougui and Cunial [8, Thm. 1] Space Typical suffix tree operation time O(r + n/s) O(r log(n/r)) O(e) O(s( log σ log log r + (log log n)2)) O(log(n/r)) O(log n) Table 1. Previous and our new results on counting, locating, extracting, and supporting suffix tree functionality. We simplified some formulas with tight upper bounds. The variables are the text size n, pattern length m, number of occurrences occ of the pattern, alphabet size σ, extracted length (cid:96), Lempel-Ziv parsing size z, smallest grammar size g, BWT runs r, CDAWG size e, and machine word length in bits w. Variable h ≤ z is the depth of the dependency chain in the Lempel-Ziv parse, and  > 0 is an arbitrarily small constant. Symbols r or e mean r or e of T plus r or e of its reverse. The z of Kreft and Navarro [73] refers to the Lempel-Ziv variant that does not allow overlaps between sources and targets, but their index actually works in either variant. 4 2. The only structure clearly smaller than the RLFM-index, using O(z) space [73], has unbounded locate time. Structures using about the same space, O(g), have an Ω(m2) one-time overhead in the locate time [25, 26, 41, 89]. 3. Structures offering lower locate times require Ω(z log(n/z)) space [42, 97, 15, 23, 89], Θ(r + z) space [9] (where r is the sum of r for T and its reverse), or Ω(e) space [9, 111, 7]. 4. Self-indexes with efficient extraction require Ω(z log(n/z)) space [105, 21, 43, 10, 15], Ω(g) space [17, 14], or Ω(e) space [111, 7]. 5. The only efficient compressed suffix tree requires Θ(e) space [8]. 6. Only a few of all these indexes have been implemented, as far as we know [80, 25, 73, 9]. 1.2 Contributions Efficiently locating the occurrences of P in T within O(r) space has been a bottleneck and an open problem for almost a decade. In this paper we give the first solution to this problem. Our precise contributions, largely detailed in Tables 1 and 2, are the following: 1. We improve the counting time of the RLFM-index to O(m log logw(σ + n/r)), where σ ≤ r is the alphabet size of T , while retaining the O(r) space. 2. We show how to locate each occurrence in time O(log logw(n/r)), within O(r) space. We reduce the locate time to O(1) per occurrence by using slightly more space, O(r log logw(n/r)). 4. By increasing the space to O(rw logσ logw(σ+n/r)), we obtain optimal locate time, O((cid:100)m log(σ)/w(cid:101)+ 3. By using O(r log logw(σ + n/r)) space, we obtain optimal locate time in the general setting, O(m + occ), as well as optimal counting time, O(m). This had been obtained before only with space bounds O(e) [7] or O(e) [111]. occ), and optimal counting time, O((cid:100)m log(σ)/w(cid:101)), in the packed setting (i.e., the pattern sym- bols come packed in blocks of w/ log σ symbols per word). This had not been achieved so far by any compressed index, but only by uncompressed ones [91]. 5. We give the first structure built on BWT runs that replaces T while retaining direct access. It extracts any substring of length (cid:96) in time O(log(n/r) + (cid:96) log(σ)/w), using O(r log(n/r)) space. As discussed, even the additive penalty is near-optimal [22, Thm. 6]. Within the same space, we also obtain optimal locating and counting time, as well as accessing subarrays of length (cid:96) of the suffix array, inverse suffix array, and longest common prefix array of T , in time O(log(n/r) + (cid:96)). 6. We give the first compressed suffix tree whose space is bounded in terms of r, O(r log(n/r)) words. It implements most navigation operations in time O(log(n/r)). There exist only compa- rable suffix trees within O(e) space [8], taking O(log n) time for most operations. 7. We provide a proof-of-concept implementation of the most basic index (the one locating within O(r) space), and show that it outperforms all the other implemented alternatives by orders of magnitude in space or in time to locate pattern occurrences. Contribution 1 is a simple update of the RLFM-index [80] with newer data structures for rank and predecessor queries [13]. We present it in Section 2, together with a review of the basic concepts needed to follow the paper. Contribution 2 is one of the central parts of the paper, and is obtained in Section 3 in two steps. The first uses the fact that we can carry out the classical RLFM-index counting process for P in a way that we always know the position of one occurrence in T [101, 100]; we give a simpler proof of this fact in Lemma 2. The second shows that, if we know the position in T of one occurrence 5 Functionality Count + Locate (Thm. 1) Count + Locate (Lem. 4) Count + Locate (Thm. 2) Count + Locate (Thm. 3) Extract (Thm. 4) Access SA, ISA, LCP (Thm. 5 -- 7) Count + Locate (Thm. 8) Suffix tree (Thm. 9) Space (words) O(r) O(r log logw(n/r)) O(r log logw(σ + n/r)) O(rw logσ logw(σ + n/r)) O(r log(n/r)) O(r log(n/r)) O(r log(n/r)) O(r log(n/r)) Time O(m log logw(σ + n/r) + occ log logw(n/r)) O(m log logw(σ + n/r) + occ) O(m + occ) O((cid:100)m log(σ)/w(cid:101) + occ) O(log(n/r) + (cid:96) log(σ)/w) O(log(n/r) + (cid:96)) O(m + occ) O(log(n/r)) for most operations Table 2. Our contributions. For any "Count + Locate", we can do only "Count" in the time given by setting occ = 0. of BWT , then we can quickly obtain the preceding and following ones with an O(r)-size sampling. This is achieved by using the BWT runs to induce phrases in T (which are somewhat analogous to the Lempel-Ziv phrases [76]) and showing that the positions of occurrences within phrases can be obtained from the positions of their preceding phrase start. The time O(1) is obtained by using an extended sampling. For Contributions 3 and 4, we use in Section 4 the fact that the RLFM-index on a text regarded as a sequence of overlapping metasymbols of length s has at most rs runs, so that we can process the pattern by chunks of s symbols. The optimal packed time is obtained by enlarging the samplings. In Section 5, Contribution 5 uses an analogue of the Block Tree [10] built on the BWT -induced phrases, which satisfies the property that any distinct string has an occurrence overlapping a border between phrases. Further, it is shown that direct access to the suffix array SA, inverse suffix array ISA, and array LCP of T , can be supported in a similar way because they inherit the same repetitiveness properties of the text. Contribution 6 needs, in addition to accessing those arrays, some sophisticated operations on the LCP array [37] that are not well supported by Block Trees. In Section 6, we implement suffix trees by showing that a run-length context-free grammar [?] of size O(r log(n/r)) can be built on the differential LCP array, and then implement the required operations on it. The results of Contribution 7 are shown in Section 7. Our experimental results show that our simple O(r)-space index outperforms the alternatives by orders of magnitude when locating the occurrences of a pattern, while being simultaneously smaller or nearly as small. The only compact structure outperforming our index, the CDAWG, is an order of magnitude larger. Further, in Section 8 we describe construction algorithms for all our data structures, achieving construction spaces bounded in terms of r for the simpler and most practical structures. We finally conclude in Section 9. This article is an extension of a conference version presented in SODA 2018 [46]. The extension consists, on the one hand, in a significant improvement in Contributions 3 and 4: in Section 4, optimal time locating is now obtained in a much simpler way and in significantly less space. Further, optimal time is obtained as well, which is new. On the other hand, Contribution 6, that is, the machinery to support suffix tree functionality in Section 6, is new. We also present an improved implementation in Section 7, with better experimental results. Finally, the construction algorithms in Section 8 are new as well. 6 2 Basic Concepts A string is a sequence S[1..(cid:96)] = S[1]S[2] . . . S[(cid:96)], of length (cid:96) = S, of symbols (or characters, or letters) chosen from an alphabet [1..σ] = {1, 2, . . . , σ}, that is, S[i] ∈ [1..σ] for all 1 ≤ i ≤ (cid:96). We use S[i..j] = S[i] . . . S[j], with 1 ≤ i, j ≤ (cid:96), to denote a substring of S, which is the empty string ε if i > j. A prefix of S is a substring of the form S[1..i] (also written S[..i]) and a suffix is a substring of the form S[i..(cid:96)] (also written S[i..]). The juxtaposition of strings and/or symbols represents their concatenation. We will consider indexing a text T [1..n], which is a string over alphabet [1..σ] terminated by the special symbol $ = 1, that is, the lexicographically smallest one, which appears only at T [n] = $. This makes any lexicographic comparison between suffixes well defined. Our computation model is the transdichotomous RAM, with a word of w = Ω(log n) bits, where all the standard arithmetic and logic operations can be carried out in constant time. In this article we generally measure space in words. 2.1 Suffix Trees and Arrays The suffix tree [114] of T [1..n] is a compacted trie where all the n suffixes of T have been inserted. By compacted we mean that chains of degree-1 nodes are collapsed into a single edge that is labeled with the concatenation of the individual symbols labeling the collapsed edges. The suffix tree has n leaves and less than n internal nodes. By representing edge labels with pointers to T , the suffix tree uses O(n) space, and can be built in O(n) time [114, 83, 112, 28]. The suffix array [81] of T [1..n] is an array SA[1..n] storing a permutation of [1..n] so that, for all 1 ≤ p < n, the suffix T [SA[p]..] is lexicographically smaller than the suffix T [SA[p + 1]..]. Thus SA[p] is the starting position in T of the pth smallest suffix of T in lexicographic order. This can be regarded as an array collecting the leaves of the suffix tree. The suffix array uses n words and can be built in O(n) time without building the suffix tree [69, 70, 61]. All the occurrences of a pattern string P [1..m] in T can be easily spotted in the suffix tree or array. In the suffix tree, we descend from the root matching the successive symbols of P with the strings labeling the edges. If P is in T , the symbols of P will be exhausted at a node v or inside an edge leading to a node v; this node is called the locus of P , and all the occ leaves descending from v are the suffixes starting with P , that is, the starting positions of the occurrences of P in T . By using perfect hashing to store the first characters of the edge labels descending from each node of v, we reach the locus in optimal time O(m) and the space is still O(n). If P comes packed using w/ log σ symbols per computer word, we can descend in time O((cid:100)m log(σ)/w(cid:101)) [91], which is optimal in the packed model. In the suffix array, all the suffixes starting with P form a range SA[sp..ep], which can be binary searched in time O(m log n), or O(m + log n) with additional structures [81]. The inverse permutation of SA, ISA[1..n], is called the inverse suffix array, so that ISA[i] is the lexicographical position of the suffix T [i..] among all the suffixes of T . Another important concept related to suffix arrays and trees is the longest common prefix array. Let lcp(S, S(cid:48)) be the length of the longest common prefix between two strings S (cid:54)= S(cid:48), that is, S[1..lcp(S, S(cid:48))] = S(cid:48)[1..lcp(S, S(cid:48))] but S[lcp(S, S(cid:48)) + 1] (cid:54)= S(cid:48)[lcp(S, S(cid:48)) + 1]. Then we define the longest common prefix array LCP [1..n] as LCP [1] = 0 and LCP [p] = lcp(T [SA[p− 1]..], T [SA[p]..]). The LCP array uses n words and can be built in O(n) time [64]. 7 2.2 Self-indexes A self-index is a data structure built on T [1..n] that provides at least the following functionality: Count: Given a pattern P [1..m], compute the number occ of occurrences of P in T . Locate: Given a pattern P [1..m], return the occ positions where P occurs in T . Extract: Given a range [i..i + (cid:96) − 1], return T [i..i + (cid:96) − 1]. The last operation allows a self-index to act as a replacement of T , that is, it is not necessary to store T since any desired substring can be extracted from the self-index. This can be trivially obtained by including a copy of T as a part of the self-index, but it is challenging when the self-index must use little space. In principle, suffix trees and arrays can be regarded as self-indexes that can count in time O(m) or O((cid:100)m log(σ)/w(cid:101)) (suffix tree, by storing occ in each node v) and O(m log n) or O(m + log n) (suffix array, with occ = ep − sp + 1), locate each occurrence in O(1) time, and extract in time O((cid:100)(cid:96) log(σ)/w(cid:101)). However, they use O(n log n) bits, much more than the n log σ bits needed to represent T in plain form. We are interested in compressed self-indexes [90, 96], which use the space required by a compressed representation of T (under some compressibility measure) plus some redundancy (at worst o(n log σ) bits). We describe later the FM-index, a particular self-index of interest to us. 2.3 Burrows-Wheeler Transform The Burrows-Wheeler Transform of T [1..n], BWT [1..n] [20], is a string defined as BWT [p] = T [SA[p] − 1] if SA[p] > 1, and BWT [p] = T [n] = $ if SA[p] = 1. That is, BWT has the same symbols of T in a different order, and is a reversible transform. The array BWT is obtained from T by first building SA, although it can be built directly, in O(n) time and within O(n log σ) bits of space [85]. To obtain T from BWT [20], one considers two arrays, L[1..n] = BWT and F [1..n], which contains all the symbols of L (or T ) in ascending order. Alternatively, F [p] = T [SA[p]], so F [p] follows L[p] in T . We need a function that maps any L[p] to the position q of that same character in F . The formula is LF (p) = C[c] + rank[p], where c = L[p], C[c] is the number of occurrences of symbols less than c in L, and rank[p] is the number of occurrences of symbol L[p] in L[1..p]. A simple O(n)-time pass on L suffices to compute arrays C and rank using O(n log σ) bits of space. Once they are computed, we reconstruct T [n] = $ and T [n − k] ← L[LF k−1(1)] for k = 1, . . . , n − 1, in O(n) time as well. Note that LF is a permutation formed by a single cycle. 2.4 Compressed Suffix Arrays and FM-indexes Compressed suffix arrays [90] are a particular case of self-indexes that simulate SA in compressed form. Therefore, they aim to obtain the suffix array range [sp..ep] of P , which is sufficient to count since P then appears occ = ep − sp + 1 times in T . For locating, they need to access the content of cells SA[sp], . . . , SA[ep], without having SA stored. The FM-index [32, 33] is a compressed suffix array that exploits the relation between the string L = BWT and the suffix array SA. It stores L in compressed form (as it can be easily compressed to the high-order empirical entropy of T [82]) and adds sublinear-size data structures to compute (i) any desired position L[p], (ii) the generalized rank function rankc(L, p), which is the number of 8 times symbol c appears in L[1..p]. Note that these two operations permit, in particular, computing rank[p] = rankL[p](L, p), which is called partial rank. Therefore, they compute LF (p) = C[L[p]] + rankL[p](L, p). For counting, the FM-index resorts to backward search. This procedure reads P backwards and at any step knows the range [spj, epj] of P [j..m] in T . Initially, we have the range [spm+1..epm+1] = [1..n] for P [m + 1..m] = ε. Given the range [spj+1..epj+1], one obtains the range [spj..epj] from c = P [j] with the operations spj = C[c] + rankc(L, spj+1 − 1) + 1, epj = C[c] + rankc(L, epj+1). Thus the range [sp..ep] = [sp1..ep1] is obtained with O(m) computations of rank, which dominates the counting complexity. For locating, the FM-index (and most compressed suffix arrays) stores sampled values of SA at regularly spaced text positions, say multiples of s. Thus, to retrieve SA[p], we find the smallest k for which SA[LF k(p)] is sampled, and then the answer is SA[p] = SA[LF k(p)] + k. This is because function LF virtually traverses the text backwards, that is, it drives us from L[p], which precedes suffix SA[p], to its position F [q], where the suffix SA[q] starts with L[p], that is, SA[q] = SA[p] − 1: SA[LF (p)] = SA[p] − 1. Since it is guaranteed that k < s, each occurrence is located with s accesses to L and computations of LF , and the extra space for the sampling is O((n log n)/s) bits, or O(n/s) words. For extracting, a similar sampling is used on ISA, that is, we sample the positions of ISA that are multiples of s. To extract T [i..i + (cid:96) − 1] we find the smallest multiple of s in [i + (cid:96)..n], j = s · (cid:100)(i + (cid:96))/s(cid:101), and extract T [i..j]. Since ISA[j] = p is sampled, we know that T [j − 1] = L[p], T [j − 2] = L[LF (p)], and so on. In total we require at most (cid:96) + s accesses to L and computations of LF to extract T [i..i + (cid:96) − 1]. The extra space is also O(n/s) words. For example, using a representation [13] that accesses L and computes partial ranks in constant time (so LF is computed in O(1) time), and computes rank in the optimal O(log logw σ) time, an FM-index can count in time O(m log logw σ), locate each occurrence in O(s) time, and extract (cid:96) symbols of T in time O(s + (cid:96)), by using O(n/s) space on top of the empirical entropy of T [13]. There exist even faster variants [12], but they do not rely on backward search. 2.5 Run-Length FM-index One of the sources of the compressibility of BWT is that symbols are clustered into r ≤ n runs, which are maximal substrings formed by the same symbol. Makinen and Navarro [78] proved a (relatively weak) bound on r in terms of the high-order empirical entropy of T and, more impor- tantly, designed an FM-index variant that uses O(r) words of space, called Run-Length FM-index or RLFM-index. They later experimented with several variants of the RLFM-index, where the one called RLFM+ [80, Thm. 17] corresponds to the original RLFM-index [78]. The structure stores the run heads, that is, the first positions of the runs in BWT , in a data structure E = {1} ∪ {1 < p ≤ n, BWT [p] (cid:54)= BWT [p − 1]} that supports predecessor searches. Each element e ∈ E has associated the value e.v = {e(cid:48) ∈ E, e(cid:48) ≤ e}, which is its position in a string 9 L(cid:48)[1..r] that stores the run symbols. Another array, D[0..r], stores the cumulative lengths of the runs after stably sorting them lexicographically by their symbols (with D[0] = 0). Let array C(cid:48)[1..σ] count the number of runs of symbols smaller than c in L. One can then simulate rankc(L, p) = D[C(cid:48)[c] + rankc(L(cid:48), q.v − 1)] + [if L(cid:48)[q.v] = c then p − q + 1 else 0], where q = pred(E, p), at the cost of a predecessor search (pred) in E and a rank on L(cid:48). By using up-to-date data structures, the counting performance of the RLFM-index can be stated as follows. Lemma 1. The Run-Length FM-index of a text T [1..n] whose BWT has r runs can occupy O(r) words and count the number of occurrences of a pattern P [1..m] in time O(m log logw(σ + n/r)). It also computes LF and access to any BWT [p] in time O(log logw(n/r)). Proof. We use the RLFM+ [80, Thm. 17], using the structure of Belazzougui and Navarro [13, Thm. 10] for the sequence L(cid:48) (with constant access time) and the predecessor data structure de- scribed by Belazzougui and Navarro [13, Thm. 14] to implement E (instead of the bitvector used in the original RLFM+). The RLFM+ also implements D with a bitvector, but we use a plain array. The sum of both operation times is O(log logw σ + log logw(n/r)), which can be written as O(log logw(σ+n/r)). To access BWT [p] = L[p] = L(cid:48)[pred(E, p).v] we only need a predecessor search on E, which takes time O(log logw(n/r)), and a constant-time access to L(cid:48). Finally, we compute LF faster than a general rank query, as we only need the partial rank query rankL[p](L, p) = D[C(cid:48)[L(cid:48)[q.v]] + rankL(cid:48)[q.v](L(cid:48), q.v) − 1] + (p − q + 1), which is correct since L[p] = L(cid:48)[q.v]. The operation rankL(cid:48)[q.v](L(cid:48), q.v) can be supported in constant time using O(r) space, by just recording all the answers, and therefore the time for LF on L is also (cid:117)(cid:116) dominated by the predecessor search on E (to compute q), of O(log logw(n/r)) time. We will generally assume that σ is the effective alphabet of T , that is, the σ symbols appear in T . This implies that σ ≤ r ≤ n. If this is not the case, we can map T to an effective alphabet [1..σ(cid:48)] before indexing it. A mapping of σ(cid:48) ≤ r words then stores the actual symbols when extracting a substring of T is necessary. For searches, we have to map the m positions of P to the effective alphabet. By storing a perfect hash or a deterministic dictionary [104] of O(σ(cid:48)) = O(r) words, we map each symbol of P in constant time. On the other hand, the results on packed symbols only make sense if σ is small, and thus no alphabet mapping is necessary. Overall, we can safely use the assumption σ ≤ r without affecting any of our results, including construction time and space. To provide locating and extracting functionality, Makinen et al. [80] use the sampling mechanism we described for the FM-index. Therefore, although they can efficiently count within O(r) space, they need a much larger O(n/s) space to support these operations in time proportional to s. Despite various efforts [80], this has been a bottleneck in theory and in practice since then. 2.6 Compressed Suffix Trees Suffix trees provide a much more complete functionality than self-indexes, and are used to solve complex problems especially in bioinformatic applications [54, 98, 77]. A compressed suffix tree is regarded as an enhancement of a compressed suffix array (which, in a sense, represents only the leaves of the suffix tree). Such a compressed representation must be able to simulate the operations on the classical suffix tree (see Table 4 later in the article), while using little space on top of the 10 compressed suffix array. The first such compressed suffix tree [106] used O(n) extra bits, and there are several variants using o(n) extra bits [37, 34, 103, 49, 1]. Instead, there are no compressed suffix trees using O(r polylog(n)) space. An extension of the RLFM-index [80] still needs O(n/s) space to carry out most of the suffix tree operations in time O(s log n). Some variants that are designed for repetitive text collections [1, 92] are heuristic and do not offer worst-case guarantees. Only recently a compressed suffix tree was presented [8] that uses O(e) space and carries out operations in O(log n) time. 3 Locating Occurrences In this section we show that, if the BWT of a text T [1..n] has r runs, then we can have an index using O(r) space that not only efficiently finds the interval SA[sp..ep] of the occurrences of a pattern P [1..m] (as was already known in the literature, see Section 2.5) but that can locate each such occurrence in time O(log logw(n/r)) on a RAM machine of w bits. Further, the time per occurrence becomes constant if the space is raised to O(r log logw(n/r)). We start with Lemma 2, which shows that the typical backward search process can be enhanced so that we always know the position of one of the values in SA[sp..ep]. We give a simplification of the previous proof [101, 100]. Lemma 3 then shows how to efficiently obtain the two neighboring cells of SA if we know the value of one. This allows us to extend the first known cell in both directions, until obtaining the whole interval SA[sp..ep]. Theorem 1 summarizes the main result of this section. Later, Lemma 4 shows how this process can be accelerated by using more space. We extend the idea in Lemma 5, obtaining LCP values in the same way we obtain SA values. While not of immediate use for locating, this result is useful later in the article and also has independent interest. Definition 1. We say that a text character T [i] is sampled if and only if T [i] is the first or last character in its BWT run. That is, T [SA[1] − 1] = T [n − 1] is sampled and, if p > 1 and BWT [p] (cid:54)= BWT [p − 1], then T [SA[p − 1] − 1] and T [SA[p] − 1] are sampled. In general, T [i] is s-sampled if it is at distance at most s from a BWT run border, where sampled characters are at distance 1. Lemma 2. We can store O(r) words such that, given P [1..m], in time O(m log logw(σ + n/r)) we can compute the interval SA[sp, ep] of the occurrences of P in T , and also return the position p and content SA[p] of at least one cell in the interval [sp, ep]. Proof. We store a RLFM-index and predecessor structures Rc storing the position in BWT of all the sampled characters equal to c, for each c ∈ [1..σ]. Each element p ∈ Rc is associated with its corresponding text position, that is, we store pairs (cid:104)p, SA[p] − 1(cid:105) sorted by their first component. These structures take a total of O(r) words. The interval of characters immediately preceding occurrences of the empty string is the entire BWT [1..n], which clearly includes P [m] as the last character in some run (unless P does not occur in T ). It follows that we find an occurrence of P [m] in predecessor time by querying pred(RP [m], n). Assume we have found the interval BWT [sp, ep] containing the characters immediately preced- ing all the occurrences of some (possibly empty) suffix P [j+1..m] of P , and we know the position and content of some cell SA[p] in the corresponding interval, sp ≤ p ≤ ep. Since SA[LF (p)] = SA[p]− 1, if BWT [p] = P [j] then, after the next application of LF -mapping, we still know the position and 11 value of some cell SA[p(cid:48)] corresponding to the interval BWT [sp(cid:48), ep(cid:48)] for P [j..m], namely p(cid:48) = LF (p) and SA[p(cid:48)] = SA[p] − 1. On the other hand, if BWT [p] (cid:54)= P [j] but P still occurs somewhere in T (i.e., sp(cid:48) ≤ ep(cid:48)), then there is at least one P [j] and one non-P [j] in BWT [sp, ep], and therefore the interval intersects an extreme of a run of copies of P [j], thus holding a sampled character. Then, a predecessor query pred(RP [j], ep) gives us the desired pair (cid:104)p(cid:48), SA[p(cid:48)] − 1(cid:105) with sp ≤ p(cid:48) ≤ ep and BWT [p(cid:48)] = P [j]. Therefore, by induction, when we have computed the BWT interval for P , we know the position and content of at least one cell in the corresponding interval in SA. To obtain the desired time bounds, we concatenate all the universes of the Rc structures into a single one of size σn, and use a single structure R on that universe: each (cid:104)p, SA[p−1](cid:105) ∈ Rc becomes (cid:104)(c − 1)n + p, SA[p] − 1(cid:105) in R, and a search pred(Rc, q) becomes pred(R, (c − 1)n + q) − (c − 1)n. Since R contains 2r elements on a universe of size σn, we can have predecessor searches in time O(log logw(nσ/r)) and O(r) space [13, Thm. 14]. This is the same O(log logw(σ + n/r)) time we obtained in Lemma 1 to carry out the normal backward search operations on the RLFM-index. (cid:117)(cid:116) Lemma 2 gives us a toehold in the suffix array, and we show in this section that a toehold is all we need. We first show that, given the position and contents of one cell of the suffix array SA of a text T , we can compute the contents of the neighbouring cells in O(log logw(n/r)) time. It follows that, once we have counted the occurrences of a pattern in T , we can locate all the occurrences in O(log logw(n/r)) time each. Definition 2. ([60]) Let permutation φ be defined as φ(i) = SA[ISA[i] − 1] if ISA[i] > 1 and φ(i) = SA[n] otherwise. That is, given a text position i = SA[p] pointed from suffix array position p, φ(i) = SA[ISA[SA[p]]− 1] = SA[p − 1] gives the value of the preceding suffix array cell. Similarly, φ−1(i) = SA[p + 1]. Definition 3. We parse T into phrases such that T [i] is the first character in a phrase if and only if T [i] is sampled. Lemma 3. We can store O(r) words such that functions φ and φ−1 are evaluated in O(log logw(n/r)) time. Proof. We store an O(r)-space predecessor data structure P ± with O(log logw(n/r)) query time [13, Thm. 14] for the starting phrase positions i of T (i.e., the sampled text positions). We also store, associated with such values i ∈ P ±, the positions in T next to the characters immediately preceding and following the corresponding position BWT [q], that is, N [i] = (cid:104)SA[q − 1], SA[q + 1](cid:105) for i = SA[q] − 1. Suppose we know SA[p] = k + 1 and want to know SA[p− 1] and SA[p + 1]. This is equivalent to knowing the position BWT [p] = T [k] and wanting to know the positions in T of BWT [p − 1] and BWT [p+1]. To compute these positions, we find in P ± the position i in T of the first character of the phrase containing T [k], take the associated positions N [i] = (cid:104)x, y(cid:105), and return SA[p− 1] = x + k − i and SA[p + 1] = y + k − i. To see why this works, let SA[p − 1] = j + 1 and SA[p + 1] = l + 1, that is, j and l are the positions in T of BWT [p − 1] = T [j] and BWT [p + 1] = T [l]. Note that, for all 0 ≤ t < k − i, T [k − t] is not the first nor the last character of a run in BWT . Thus, by definition of LF , LF t(p− 1), LF t(p), and LF t(p + 1), that is, the BWT positions of T [j− t], T [k− t], and T [l− t], are 12 Fig. 1. Illustration of Lemma 3. Since BWT [p] = T [k] and i is the predecessor of k, the cells p− 1, p, and p + 1 would travel together through consecutive applications of LF , reaching the positions N [i] = (cid:104)x, y(cid:105) after k − i steps. Thus it must be that BWT [p − 1] = T [x + k − i] and BWT [p + 1] = T [y + k − i]. contiguous and within a single run, thus T [j − t] = T [k − t] = T [l − t]. Therefore, for t = k − i − 1, T [j − (k − i− 1)] = T [i + 1] = T [l− (k − i + 1)] are contiguous in BWT , and thus a further LF step yields that BWT [q] = T [i] is immediately preceded and followed by BWT [q−1] = T [j−(k−i)] and BWT [q + 1] = T [l − (k − i)]. That is, N [i] = (cid:104)SA[q − 1], SA[q + 1](cid:105) = (cid:104)j − (k − i) + 1, l − (k − i) + 1(cid:105) (cid:117)(cid:116) and our answer is correct. Figure 1 illustrates the proof. We then obtain the main result of this section. Theorem 1. We can store a text T [1..n], over alphabet [1..σ], in O(r) words, where r is the number of runs in the BWT of T , such that later, given a pattern P [1..m], we can count the occurrences of P in T in O(m log logw(σ + n/r)) time and (after counting) report their occ locations in overall time O(occ · log logw(n/r)). 3.1 Larger and faster The following lemma shows that the above technique can be generalized. The result is a space-time tradeoff allowing us to list each occurrence in constant time at the expense of a slight increase in space usage. This will be useful later in the article, in particular to obtain optimal-time locating. Lemma 4. Let s > 0. We can store a data structure of O(rs) words such that, given SA[p], we can compute SA[p− j] and SA[p + j] for j = 1, . . . , s(cid:48) and any s(cid:48) ≤ s, in O(log logw(n/r) + s(cid:48)) time. Proof. Consider all BWT positions q1 < ··· < qt of s-sampled characters, and let W [1..t] be an 1 < ··· < q+ array such that W [k] is the text position corresponding to qk, for k = 1, . . . , t. Now let q+ 1 < ··· < q− be the BWT positions having a run border at most s positions after them, and q− t+ t− be the BWT positions having a run border at most s positions before them. We store the text positions corresponding to q+ t− in two predecessor structures P + and P −, respectively, of size O(rs). We store, for each i ∈ P + ∪ P −, its position f (i) in W , that is, W [f (i)] = i. To answer queries given SA[p], we first compute its P +-predecessor i < SA[p] in O(log logw(n/r)) time, and retrieve f (i). Then, it holds that SA[p + j] = W [f (i) + j] + (SA[p] − i), for j = 0, . . . , s. Computing SA[p − j] is symmetric (just use P − instead of P +). 1 < ··· < q− 1 < ··· < q+ t+ and q− 13 p−1p+1pliyq−1q+1qLFk−iN[i]=<x,y>BWTTxjk To see why this procedure is correct, consider the range SA[p..p + s]. We distinguish two cases. (i) BWT [p..p + s] contains at least two distinct characters. Then, SA[p] − 1 ∈ P + (because p is followed by a run break at most s positions away), and is therefore the immediate predecessor of SA[p]. Moreover, all BWT positions [p..p + s] are in q1, . . . , qt (since they are at distance at most s from a run break), and their corresponding text positions are therefore contained in a contiguous range of W (i.e., W [f (SA[p] − 1)..f (SA[p] − 1) + s]). The claim follows. (ii) BWT [p..p + s] contains a single character; we say it is unary. Then SA[p] − 1 /∈ P +, since there are no run breaks in BWT [p..p + s]. Moreover, by the LF formula, the LF mapping applied on the unary range BWT [p..p + s] gives a contiguous range BWT [LF (p)..LF (p + s)] = BWT [LF (p)..LF (p) + s]. Note that this corresponds to a parallel backward step on text positions SA[p] → SA[p] − 1, . . . , SA[p + s] → SA[p + s] − 1. We iterate the application of LF until we end up in a range BWT [LF δ(p)..LF δ(p + s)] that is not unary. Then, SA[LF δ(p)] − 1 is the immediate predecessor of SA[p] in P +, and δ + 1 is their distance. This means that with a single predecessor query on P + we "skip" all the unary BWT ranges BWT [LF k(p)..LF k(p+s)] for k = 1, . . . , δ−1 and, as in case (i), retrieve the contiguous range in W containing the values SA[p]− δ, . . . , SA[p + s]− δ, (cid:117)(cid:116) and add δ to obtain the desired SA values. 3.2 Accessing LCP Lemma 4 can be further extended to entries of the LCP array, which we will use later in the article. Given SA[p], we compute LCP [p] and its adjacent entries (note that we do not need to know p, but just SA[p]). For s = 1 this is known as the permuted LCP (PLCP) array [106]. Our result can indeed be seen as an extension of a PLCP representation by Fischer et al. [37]. In Section 6.2 we use different structures that enable the classical access, that is, compute LCP [p] from p, not SA[p]. Lemma 5. Let s > 0. We can store a data structure of O(rs) words such that, given SA[p], we can compute LCP [p − j + 1] and LCP [p + j], for j = 1, . . . , s(cid:48) and any s(cid:48) ≤ s, in O(log logw(n/r) + s(cid:48)) time. 1 < ··· < q− Proof. The proof follows closely that of Lemma 4, except that now we sample LCP entries corre- 1 < ··· < q+ sponding to suffixes following s-sampled BWT positions. Let us define q1 < ··· < qt, q+ t+, and q− t−, as well as the predecessor structures P + and P −, exactly as in the proof of Lemma 4. We store LCP(cid:48)[1..t] = LCP [q1], . . . , LCP [qt]. We also store, for each i ∈ P + ∪ P −, its corresponding position f (i) in LCP(cid:48), that is, LCP(cid:48)[f (i)] = LCP [ISA[i + 1]]. To answer queries given SA[p], we first compute its P +-predecessor i < SA[p] in O(log logw(n/r)) time, and retrieve f (i). Then, it holds that LCP [p + j] = LCP(cid:48)[f (i) + j] − (SA[p] − i − 1), for j = 1, . . . , s. Computing LCP [p − j] for j = 0, . . . , s − 1 is symmetric (using P − instead of P +). To see why this procedure is correct, consider the range SA[p..p + s]. We distinguish two cases. (i) BWT [p..p + s] contains at least two distinct characters. Then, as in case (i) of Lemma 4, SA[p] − 1 ∈ P + and is therefore the immediate predecessor i = SA[p] − 1 of SA[p]. Moreover, all BWT positions [p..p + s] are in q1, . . . , qt, and therefore values LCP [p..p + s] are explicitly stored in a contiguous range in LCP(cid:48) (i.e., LCP(cid:48)[f (i)..f (i) + s]). Note that SA[p] − i = 1, so LCP(cid:48)[f (i) + j] − (SA[p] − i − 1) = LCP(cid:48)[f (i) + j] for j = 0, . . . , s. The claim follows. (ii) BWT [p..p + s] contains a single character, so it is unary. Then we reason exactly as in case (ii) of Lemma 4 to define δ so that i(cid:48) = SA[LF δ(p)] − 1 is the immediate predecessor of SA[p] in P + and, as in case (i) of this proof, retrieve the contiguous range LCP(cid:48)[f (i(cid:48))..f (i(cid:48)) + s] containing 14 the values LCP [LF δ(p)..LF δ(p + s)]. Since the skipped BWT ranges are unary, it is not hard to see that LCP [LF δ(p + j)] = LCP [p + j] + δ for j = 1, . . . , s (note that we do not include j = 0 since we cannot exclude that, for some k < δ, LF k(p) is the first position in its run). From the equality δ = SA[p] − i(cid:48) − 1 = SA[p] − SA[LF δ(p)] (that is, δ is the distance between SA[p] and its predecessor minus one or, equivalently, the number of LF steps virtually performed), we then (cid:117)(cid:116) compute LCP [p + j] = LCP(cid:48)[f (i(cid:48)) + j] − δ for j = 1, . . . , s. As a simplification that does not change our asymptotic bounds (but that we consider in the implementation), note that it is sufficient to sample only the last (or the first) characters of BWT runs. In this case, our toehold in Lemma 2 will be the last cell SA[ep] of our current range SA[sp..ep]: if BWT [ep] = P [j], then the next toehold is ep(cid:48) and its position is SA[ep] − 1. Otherwise, there must be a run end (i.e., a sampled position) in SA[sp..ep], which we find with pred(RP [j], ep), and this stores SA[ep(cid:48)]. As a consequence, we only need to store N [i] = SA[q − 1] in Lemma 3 and just P − in Lemmas 4 and 5, thus reducing the space for sampling. This was noted simultaneously by several authors after our conference paper [46] and published independently [2]. For this paper, our definition is better suited as the sampling holds crucial properties -- see the next section. 4 Counting and Locating in Optimal Time In this section we show how to obtain optimal counting and locating time in the unpacked -- O(m) and O(m + occ) -- and packed -- O((cid:100)m log(σ)/w(cid:101)) and O((cid:100)m log(σ)/w(cid:101) + occ) -- scenarios, by using O(r log logw(σ + n/r)) and O(rw logσ logw(σ + n/r)) space, respectively. To improve upon the times of Theorem 1 we process P by chunks of s symbols on a text T ∗ formed by chunks, too. 4.1 An RLFM-index on chunks Given an integer s ≥ 1, let us define texts T k[1..(cid:100)n/s(cid:101)] for k = 0, . . . , s − 1, so that T k[i] = T [k + (i − 1)s + 1..k + is], where we assume T is padded with up to 2(s − 1) copies of $, as needed. That is, T k is T devoid of its first k symbols and then seen as a sequence of metasymbols formed by s original symbols. We then define a new text T ∗ = T 0 T 1 ··· T s−1. The text T ∗ has length n∗ = s · (cid:100)n/s(cid:101) < n + s and its alphabet is of size at most σs. Assume for now that σs is negligible; we consider it soon. We say that a suffix in T ∗ corresponds to the suffix of T from where it was extracted. Definition 4. Suffix T ∗[i∗..n∗] corresponds to suffix T [i..n] iff the concatenations of the symbols forming the metasymbols in T ∗[i∗..n∗] is equal to the suffix T [i..n], if we compare them up to the first occurrence of $. The next observation specifies the algebraic transformation between the positions in T ∗ and T . Observation 1 Suffix T ∗[i∗..n∗] corresponds to suffix T [i..n] iff i = ((i∗ − 1) mod (cid:100)n/s(cid:101)) · s + (cid:100)i∗/(cid:100)n/s(cid:101)(cid:101). The key property we exploit is that corresponding suffixes of T and T ∗ have the same lexico- graphic rank. Lemma 6. For any suffixes T ∗[i∗..n∗] and T ∗[j∗..n∗] corresponding to T [i..n] and T [j..n], respec- tively, it holds that T ∗[i∗..n∗] ≤ T ∗[j∗..n∗] iff T [i..n] ≤ T [j..n]. 15 Proof. Consider any i∗ (cid:54)= j∗, otherwise the result is trivial because i = j. We proceed by induction on n∗ − i∗. If this is zero, then T [i∗..n∗] = T [n∗] = T s−1[(cid:100)n/s(cid:101)] = T [s − 1 + ((cid:100)n/s(cid:101) − 1)s + 1..s − 1 + (cid:100)n/s(cid:101)s] = $s is always ≤ T [j∗..n∗] for any j∗. Further, by Observation 1, i = (cid:100)n/s(cid:101) · s is the rightmost suffix of T (extended with $s), formed by all $s, and thus it is ≤ T [j..n] for any j. Now, given a general pair T ∗[i∗..n∗] and T ∗[j∗..n∗], consider the first metasymbols T ∗[i∗] and T ∗[j∗]. If they are different, then the comparison depends on which of them is lexicographically smaller. Similarly, since T ∗[i∗] = T [i..i + s − 1] and T ∗[j∗] = T [j..j + s − 1], the comparison of the suffixes T [i..n] and T [j..n] depends on which is smaller between the substrings T [i..i + s − 1] and T [j..j + s − 1]. Since the metasymbols T ∗[i∗] and T ∗[j∗] are ordered lexicographically, the outcome of the comparison is the same. If, instead, T ∗[i∗] = T ∗[j∗], then also T [i..i+s−1] = T [j +s−1]. The comparison in T ∗ is then decided by the suffixes T ∗[i∗ + 1..n∗] and T ∗[j∗ + 1..n∗], and in T by the suffixes T [i + s..n] and T [j + s..n]. By Observation 1, the suffixes T ∗[i∗ + 1..n∗] and T ∗[j∗ + 1..n∗] almost always correspond to T [i + s..n] and T [j + s..n], and then by the inductive hypothesis the result of the comparisons is the same. The case where T ∗[i∗ + 1..n∗] or T ∗[j∗ + 1..n∗] do not correspond to T [i + s..n] or T [j + s..n] arises when i∗ or j∗ are a multiple of (cid:100)n/s(cid:101), but in this case they correspond to some T k[(cid:100)n/s(cid:101)], which contains at least one $. Since i∗ (cid:54)= j∗, the number of $s (cid:117)(cid:116) must be distinct, and then the metasymbols cannot be equal. An important consequence of Lemma 6 is that the suffix arrays SA∗ and SA of T ∗ and T , respectively, list the corresponding suffixes in the same order (the positions of the corresponding suffixes in T ∗ and T differ, though). Thus we can find suffix array ranges in SA via searches on SA∗. More precisely, we can use the RLFM-index of T ∗ instead of that of T . The following result is the key to bound the space usage of our structure. Lemma 7. If the BWT of T has r runs, then the BWT of T ∗ has r∗ = O(rs) runs. Proof. Kempa [?, see before Thm. 3.3] shows that the number of s-runs in the BWT of T , that is, the number of maximal runs of equal substrings of length s preceding the suffixes in lexicographic order, is at most s · r. Since SA and SA∗ list the corresponding suffixes in the same order, the number of s-runs in T essentially corresponds to the number of runs in T ∗, formed by the length-s metasymbols preceding the same suffixes. The only exceptions are the s metasymbols that precede some metasymbol T k[1] in T ∗. Other O(s) runs can appear because we have padded T with O(s) (cid:117)(cid:116) copies of $, and thus T has O(s) further suffixes. Still, the result is in O(rs). 4.2 Mapping the alphabet The alphabet size of T ∗ is σs, which can be large. Depending on σ and s, we could even be unable to handle the metasymbols in constant time. Note, however, that the effective alphabet of T ∗ must be σ∗ ≤ r∗ = O(rs), which will always be in o(n log2 n) for the moderate values of s we will use. Thus we can always manage metasymbols in [1..σ∗] in constant time. We use a compact trie of height s to convert the existing substrings of length s of T into numbers in [1..σ∗], respecting the lexicographic order. The trie uses perfect hashing to find the desired child in constant time, and the strings labeling the edges are represented as pointers to an area where we store all the distinct substrings of length s in T . We now show that this area is of length O(rs). Definition 5. We say that a text substring T [i..j] is primary iff it contains at least one sampled character (see Definition 1). 16 Lemma 8. Every text substring T [i..j] has a primary occurrence T [i(cid:48)..j(cid:48)] = T [i..j]. Proof. We prove the lemma by induction on j − i. If j − i = 0, then T [i..j] is a single character, and every character has a sampled occurrence i(cid:48) in the text. Now let j − i > 0. By the inductive hypothesis, T [i+1..j] has a primary occurrence T [i(cid:48) +1..j(cid:48)]. If T [i] = T [i(cid:48)], then T [i(cid:48)..j(cid:48)] is a primary occurrence of T [i..j]. Assume then that T [i] (cid:54)= T [i(cid:48)]. Let [sp, ep] be the BWT range of T [i + 1..j]. Then there are two distinct symbols in BWT [sp, ep] and thus there must be a run of T [i]'s ending or beginning in BWT [sp, ep], say at position sp ≤ q ≤ ep. Thus it holds that BWT [q] = T [i] and the text position i(cid:48)(cid:48) = SA[q] − 1 is sampled. We then have a primary occurrence T [i(cid:48)(cid:48)..j(cid:48)(cid:48)] = T [i..j]. (cid:117)(cid:116) Lemma 9. There are at most 2rs distinct s-mers in the text, for any 1 ≤ s ≤ n. Proof. From Lemma 8, every distinct s-mer appearing in the text has a primary occurrence. It follows that, in order to count the number of distinct s-mers, we can restrict our attention to the regions of size 2s − 1 overlapping the at most 2r sampled positions (Definition 1). Each sampled (cid:117)(cid:116) position overlaps with s s-mers, so the claim easily follows. The compact trie then has size O(rs), since it has σ∗ ≤ r∗ = O(rs) leaves and no unary paths, and the area with the distinct strings is also of size O(rs). The structure maps any metasymbol to the new alphabet [1..σ∗], by storing the corresponding symbol in each leaf. Each internal trie node v also stores the first and last symbols of [1..σ∗] stored at leaves descending from it, vmin and vmax. We then build the RLFM-index of T ∗ on the mapped alphabet [1..σ∗], and our structures using O(σs) space become bounded by space O(σ∗) = O(r∗). 4.3 Counting in optimal time Let us start with the base FM-index. Recalling Section 2.4, the FM-index of T ∗ consists of an array C∗[1..σ∗] and a string L∗[1..n∗], where C∗[c] tells the number of times metasymbols less than c occur in T ∗, and where L∗ is the BWT of T ∗, with the symbols mapped to [1..σ∗]. To use this FM-index, we process P by metasymbols too. We define two patterns, P ∗ · LP and P ∗ · RP , with P ∗[1..m∗] = P [1..s]P [s + 1..2s]··· P [(cid:98)m/s − 1(cid:99) · s + 1..(cid:98)m/s(cid:99) · s], LP = P [(cid:98)m/s(cid:99) · s + 1..m] · $s−(m mod s), and RP = P [(cid:98)m/s(cid:99) · s + 1..m] · @s−(m mod s), @ being the largest symbol in the alphabet. That is, P ∗ · PL and P ∗ · PR are P padded with the smallest and largest alphabet symbols, respectively, and then regarded as a sequence of (cid:98)m/s(cid:99) + 1 metasymbols. This definition and Lemma 6 ensure that the suffixes of T starting with P correspond to the suffixes of T ∗ starting with strings lexicographically between P ∗ · PL and P ∗ · PR. We use the trie to map the symbols of P ∗ to the alphabet [1..σ∗]. If a metasymbol of P ∗ is not found, it means that P does not occur in T . To map the symbols LP and RP , we descend by the symbols P [(cid:98)m/s(cid:99) · s + 1..m] and, upon reaching trie node v, we use the precomputed limits vmin and vmax. Overall, we map P ∗, LP and RP in O(m) time. We can then apply backward search almost as in Section 2.4, but with a twist for the last symbols of P ∗ · PL and P ∗ · PR: We start with the range [spm∗, epm∗] = [C∗[vmin] + 1, C∗[vmax]], and then carry out m∗ − 1 steps, for j = m∗ − 1, . . . , 1, as follows, with c being the mapping of P ∗[j]: spj = C∗[c] + rankc(L∗, spj+1 − 1) + 1, epj = C∗[c] + rankc(L∗, epj+1). 17 The resulting range, [sp, ep] = [sp1, ep1], corresponds to the range of P in T , and is obtained with 2(m∗ − 1) ≤ 2m/s operations rankc(L, i). A RLFM-index (Section 2.5) on T ∗ stores, instead of C∗ and L∗, structures E, L(cid:48), D, and C(cid:48), of total size O(σ∗ + r∗) = O(r∗). These simulate the operation rankc(L, i) in the time of a predecessor search on E and rank and access operations on L(cid:48). These add up to O(log logw(σ∗ + n/r∗)) time. We can still retain C∗ to carry out the first step of our twisted backward search on LP and RP , and then switch to the RLFM-index. Lemma 10. Let T [1..n], on alphabet [1..σ], have a BWT with r runs, and let s = O(log n) be a positive integer. Then there exists a data structure using O(rs) space that counts the number of occurrences of any pattern P [1..m] in T in O(m + (m/s) log logw(σ + n/r)). In particular, a structure using O(r log logw(σ + n/r)) space counts in time O(m). Proof. We build the mapping trie, the RLFM-index on T ∗ using the mapped alphabet, and the array C∗ of the FM-index of T ∗. All these require O(σ∗ + r∗) = O(r∗) space, which is O(rs) by Lemma 7. To count the number of occurrences of P , we first compute P ∗, LP , and RP on the mapped alphabet with the trie, in time O(m). We then carry out the backward search, which requires one constant-time step to find [spm∗, epm∗] and then 2(m∗ − 1) ≤ 2m/s steps requiring rankc(L, i), which is simulated by the RLFM-index in time O(log logw(σ∗ + n∗/r∗)). Since σ∗ ≤ σs, n∗ ≤ n+s, and r∗ ≥ r, we can write the time as O(log logw(σs+n/r)) ⊆ O(log s+log logw(σ+n/r)). The term O(log s) vanishes when multiplied by O(m/s) because there is an O(m) additive term. (cid:117)(cid:116) 4.4 Locating in optimal time To locate in optimal time, we will use the toehold technique of Lemma 2 on T ∗ and P ∗. The only twist is that, when we look for LP and RP in our trie, we must store in the internal trie node we reach by P [(cid:98)m/s(cid:99) · s + 1..m] the position p in SA∗ and the value SA∗[p] of some metasymbol starting with that string. From then on, we do exactly as in Lemma 2, so we can recover the interval SA∗[sp, ep] of P ∗ in T ∗. Since, by Observation 1, we can easily convert position SA∗[p] to the corresponding position SA[p] in T , we have the following result. Lemma 11. We can store O(rs) words such that, given P [1..m], in time O(m+(m/s) log logw(σ + n/r)) we can compute the interval SA[sp, ep] of the occurrences of P in T , and also return the position p and content SA[p] of at least one cell in the interval [sp, ep]. We now use the structures of Lemma 4 on the original text T and with the same value of s. Thus, once we obtain some value SA[p] within the interval, we return the occurrences in SA[sp..ep] by chunks of s symbols, in time O(s + log logw(n/r)). We then have the following result. Theorem 2. Let s > 0. We can store a text T [1..n], over alphabet [1..σ], in O(rs) words, where r is the number of runs in the BWT of T , such that later, given a pattern P [1..m], we can count the occurrences of P in T in O(m + (m/s) log logw(σ + n/r)) time and (after counting) report their occ locations in overall time O((1 + log logw(n/r)/s) · occ). In particular, if s = log logw(σ + n/r), the structure uses O(r log logw(σ + n/r)) space, counts in time O(m), and locates in time O(m + occ). 18 4.5 RAM-optimal counting and locating In order to obtain RAM-optimal time, that is, replacing m by (cid:100)m log(σ)/w(cid:101) in the counting and locating times, we can simply use Theorem 2 with s = (w/ log σ)·log logw(σ+n/r) = w logσ logw(σ+ n/r). There is, however, a remaining O(m) time coming from traversing the trie in order to obtain the mapped alphabet symbols of P ∗, PL, and PR. We then replace our trie by a more sophisticated structure, which is described by Navarro and Nekrich [91, Sec. 2], built on the O(rs) distinct strings of length s. Let d = (cid:98)w/ log σ(cid:99). The structure is like our compact trie but it also stores, at selected nodes, perfect hash tables that allow descending by d symbols in O(1) time. This is sufficient to find the locus of a string of length s in O((cid:100)s/d(cid:101)) = O((cid:100)s log(σ)/w(cid:101)) time, except for the last s mod d symbols. For those, the structure also stores weak prefix search (wps) structures [5] on the selected nodes, which allow descending by up to d − 1 symbols in constant time. The wps structures, however, may fail if the string has no locus, so we must include a verification step. Such verification is done in RAM-optimal time by storing the strings of length 2s−1 extracted around sampled text positions in packed form, in our memory area associated with the edges. The space of the data structure is O(1) words per compact trie node, so in our case it is O(rs). We then map P ∗, PL, and PR, in time O((cid:100)m log(σ)/w(cid:101)). Theorem 3. We can store a text T [1..n], over alphabet [1..σ], in O(rw logσ logw(σ + n/r)) words, where r is the number of runs in the BWT of T , such that later, given a pattern P [1..m], we can count the occurrences of P in T in O((cid:100)m log(σ)/w(cid:101)) time and (after counting) report their occ locations in overall time O(occ). 5 Accessing the Text, the Suffix Array, and Related Structures In this section we show how we can provide direct access to the text T , the suffix array SA, its inverse ISA, and the longest common prefix array LCP . The latter enable functionalities that go beyond the basic counting, locating, and extracting that are required for self-indexes, and will be used to enable a full-fledged compressed suffix tree in Section 6. We introduce a representation of T that uses O(r log(n/r)) space and can retrieve any substring of length (cid:96) in time O(log(n/r) + (cid:96) log(σ)/w). The second term is optimal in the packed setting and, as explained in the Introduction, the O(log(n/r)) additive penalty is also near-optimal in general. For the other arrays, we exploit the fact that the runs that appear in the BWT of T induce equal substrings in the differential suffix array, its inverse, and longest common prefix arrays, DSA, DISA, and DLCP , where we store the difference between each cell and the previous one. Therefore, all the solutions will be variants of the one that extracts substrings of T . Their extraction time will be O(log(n/r) + (cid:96)). 5.1 Accessing T Our structure to extract substrings of T is a variant of Block Trees [10] built around Lemma 8. Theorem 4. Let T [1..n] be a text over alphabet [1..σ]. We can store a data structure of O(r log(n/r)) words supporting the extraction of any length-(cid:96) substring of T in O(log(n/r) + (cid:96) log(σ)/w) time. 19 Proof. We describe a data structure supporting the extraction of α = w log(n/r) packed characters in O(log(n/r)) time. To extract a text substring of length (cid:96) we divide it into (cid:100)(cid:96)/α(cid:101) blocks and extract each block with the proposed data structure. Overall, this will take O((1 + (cid:96)/α) log(n/r)) = O(log(n/r) + (cid:96) log(σ)/w) time. log σ Let l∗ be the smallest number such that sl∗ < 4α = 4w log(n/r) Our data structure is stored in O(log(n/r)) levels. For simplicity, we assume that r divides n and that n/r is a power of two. The top level (level 0) is special: we divide the text into r blocks T [1..n/r], T [n/r + 1..2n/r], . . . , T [n− n/r + 1..n] of size n/r. For levels l > 0, we let sl = n/(r· 2l−1) and, for every sampled position i, we consider the two non-overlapping blocks of length sl: X 1 l,i = l,i = T [i..i + sl − 1]. Each such block X k T [i − sl..i − 1] and X 2 l,i, for k = 1, 2, is composed of two l,i[1..sl/2] X k half-blocks, X k l,i = X k l,i[sl/2 + 1..sl]. We moreover consider three additional consecutive and non-overlapping half-blocks, starting in the middle of the first, X 1 l,i[1..sl/2], and ending in the l,i[sl/2 + 1..sl], of the 4 half-blocks just described: T [i − sl + sl/4..i − sl/4 − middle of the last, X 2 1], T [i − sl/4..i + sl/4 − 1], and T [i + sl/4..i + sl − sl/4 − 1]. From Lemma 8, blocks at level l = 0 and each half-block at level l > 0 have a primary occurrence covered by blocks at level l +1. Such an occurrence can be fully identified by the coordinate (cid:104)i(cid:48), off (cid:105), where i(cid:48) is a sampled position (actually we store a pointer ptr to the data structure associated with sampled position i(cid:48)), and 0 < off ≤ sl+1 indicates that the occurrence starts at position i(cid:48)−sl+1+off of T . . Then l∗ is the last level of our structure. At this level, we explicitly store a packed string with the characters of the blocks. This uses in total O(r · sl∗ log(σ)/w) = O(r log(n/r)) words of space. All the blocks at level 0 and half-block at levels 0 < l < l∗ store instead the coordinates (cid:104)i(cid:48), off (cid:105) of their primary occurrence in the next level. At level l∗ − 1, these coordinates point inside the strings of explicitly stored characters. These pointers also add up to O(r· l∗) = O(r log(n/r)) words of space. Let S = T [j..j + α− 1] be the text substring to be extracted. Note that we can assume n/r ≥ α; otherwise all the text can be stored in plain packed form using n log(σ)/w < αr log(σ)/w = O(r log(n/r)) words and we do not need any data structure. It follows that S either spans two blocks at level 0, or it is contained in a single block. The former case can be solved with two queries of the latter, so we assume, without losing generality, that S is fully contained inside a block at level 0. To retrieve S, we map it down to the next levels (using the stored coordinates of primary occurrences of half-blocks) as a contiguous text substring as long as this is possible, that is, as long as it fits inside a single half-block. Note that, thanks to the way half-blocks overlap, this is always possible as long as α ≤ sl/4. By definition, then, we arrive in this way precisely at level l∗, where characters are stored explicitly and we can return the packed text substring. Figure 2 illustrates (cid:117)(cid:116) the data structure. log σ 5.2 Accessing SA Let us define the differential suffix array DSA[p] = SA[p] − SA[p − 1] for all p > 1, and DSA[1] = SA[1]. The next lemmas show that the runs of BWT induce analogous repeated substrings in DSA. Lemma 12. Let [p− 1, p] be within a BWT run. Then LF (p− 1) = LF (p)− 1 and DSA[LF (p)] = DSA[p]. 20 Fig. 2. Illustration of the proof of Theorem 4. Extracting the grayed square, we have arrived at a block around sampled position i in level l. Due to its size, the square must be contained in a half-block. This half-block (in thick line) has a copy crossing a sampled position i(cid:48) (we show this copy with a dashed line). Thus the extraction task is translated to level l + 1, inside another block of half the length. Since the square is still small enough, it must fall inside some half-block of level l + 1 (also in thick line). This continues until the last level, where the symbols are stored directly. Proof. Since p is not the first position in a BWT run, it holds that BWT [p − 1] = BWT [p], and thus LF (p − 1) = LF (p) − 1 follows from the formula of LF . Therefore, if q = LF (p), we have SA[q] = SA[p] − 1 and SA[q − 1] = SA[LF (p − 1)] = SA[p − 1] − 1; therefore DSA[q] = DSA[p]. (cid:117)(cid:116) Lemma 13. Let [p − 1..p + s] be within a BWT run, for some 1 < p ≤ n and 0 ≤ s ≤ n − p. Then there exists q (cid:54)= p such that DSA[q..q + s] = DSA[p..p + s] and [q − 1..q + s] contains the first position of a BWT run. Proof. By Lemma 12, it holds that DSA[p(cid:48)..p(cid:48) + s] = DSA[p..p + s], where p(cid:48) = LF (p). If DSA[p(cid:48) − 1..p(cid:48) + s] contains the first position of a BWT run, we are done. Otherwise, we apply Lemma 12 again on [p(cid:48)..p(cid:48) + s], and repeat until we find a range that contains the first position of a run. This search eventually terminates because there are r > 0 run beginnings, there are only n − s + 1 distinct ranges, and the sequence of visited ranges, [LF k(p)..LF k(p) + s], forms a single cycle; recall Section 2.3. Therefore our search will visit all the existing ranges before returning to [p..p + s]. (cid:117)(cid:116) This means that there exist 2r positions in DSA, namely those [q, q + 1] where BWT [q] is the first position of a run, such that any substring DSA[p..p + s] has a copy covering some of those 2r positions. Note that this is the same property of Lemma 8, which enabled efficient access and fingerprinting on T . We now exploit it to access cells in SA by building a similar structure on DSA. Theorem 5. Let the BWT of a text T [1..n] contain r runs. Then there exists a data structure using O(r log(n/r)) words that can retrieve any (cid:96) consecutive values of its suffix array SA in time O(log(n/r) + (cid:96)). Proof. We describe a data structure supporting the extraction of α = log(n/r) consecutive cells in O(log(n/r)) time. To extract (cid:96) consecutive cells of SA, we divide it into (cid:100)(cid:96)/α(cid:101) blocks and extract each block independently. This yields the promised time complexity. Our structure is stored in O(log(n/r)) levels. As before, let us assume that r divides n and that n/r is a power of two. At the top level (l = 0), we divide DSA into r blocks DSA[1..n/r], DSA[n/r + 1..2n/r], . . . , DSA[n − n/r + 1..n] of size n/r. For levels l > 0, we let sl = n/(r · 2l−1) and, for every position q that starts a run in BWT , we consider the two non-overlapping blocks of length 21 ii' l,q = X k l,q[1..sl/2] X k l∗,qX 2 l+1,qX 2 l,q = DSA[q + 1..q + sl].16 Each such block X k l,q = DSA[q − sl + 1..q] and X 2 sl: X 1 l,q, for k = 1, 2, is composed of two half-blocks, X k l,q[sl/2 + 1..sl]. We moreover consider three additional consecutive and non-overlapping half-blocks, starting in the middle of the first, X 1 l,q[1..sl/2], and ending in the middle of the last, X 2 l,q[sl/2+1..sl], of the 4 half-blocks just described: DSA[q − sl + sl/4 + 1..q − sl/4], DSA[q − sl/4 + 1..q + sl/4], and DSA[q + sl/4 + 1..q + sl − sl/4]. From Lemma 13, blocks at level l = 0 and each half-block at level l > 0 have an occurrence covered by blocks at level l + 1. Let the half-block X of level l (blocks at level 0 are analogous) have an occurrence containing position q∗ ∈ {q, q + 1}, where q starts a run in BWT . Then we store the pointer (cid:104)q∗, off , δ(cid:105) associated with X, where 0 < off ≤ sl+1 indicates that the occurrence of X starts at position q∗ − sl+1 + off of DSA, and δ = SA[q∗ − sl+1] − SA[q∗ − sl+1 + off − 1]. (We also store the pointer to the data structure of the half-block of level l + 1 containing the position q∗.) Additionally, every level-0 block X(cid:48) = DSA[q(cid:48) + 1..q(cid:48) + sl] stores the value S(X(cid:48)) = SA[q(cid:48)] (assume SA[0] = 0 throughout), and every half-block X(cid:48) = DSA[q(cid:48) + 1..q(cid:48) + sl+1/2] corresponding l+1,q = DSA[q−sl+1 +1..q +sl+1] stores the value ∆(X(cid:48)) = SA[q(cid:48)]−SA[q−sl+1]. to the area X 1 Let l∗ be the smallest number such that sl∗ < 4α = 4 log(n/r). Then l∗ is the last level of our structure. At this level, we explicitly store the sequence of DSA cells of the areas X 1 l∗,q, for each q starting a run in BWT . This uses in total O(r · sl∗) = O(r log(n/r)) words of space. The pointers stored for the O(r) blocks at previous levels also add up to O(r log(n/r)) words. Let S = SA[p..p + α − 1] be the sequence of cells to be extracted. This range either spans two blocks at level 0, or it is contained in a single block. In the former case, we decompose it into two queries that are fully contained inside a block at level 0. To retrieve a range contained in a single block or half-block, we map it down to the next levels using the pointers from blocks and half-blocks, as a contiguous sequence as long as it fits inside a single half-block. This is always possible as long as α ≤ sl/4. By definition, then, we arrive in this way precisely to level l∗, where the symbols of DSA are stored explicitly and we can return the sequence. We need, however, the contents of SA[p..p+α−1], not of DSA[p..p+α−1]. To obtain the former from the latter, we need only the value of SA[p]. During the traversal, we will maintain a value f with the invariant that, whenever the original position DSA[p] has been mapped to a position X[p(cid:48)] in the current block X, then it holds that SA[p] = f + X[1] + . . . + X[p(cid:48)]. This invariant must be maintained when we use pointers, where the original DSA values in a block X are obtained from a copy that appears somewhere else in DSA. The invariant is initially valid by setting f to the S(X) value associated with the level-0 block X that contains SA[p]. When we follow a pointer (cid:104)q, offs, δ(cid:105) and choose X(cid:48) from the 7 half-blocks that cover the target, we update f ← f + δ + ∆(X(cid:48)). When we arrive at a block X at level l∗, we scan O(α) symbols until reaching the first value of the desired position X[p(cid:48)]. The values X[1], . . . , X[p(cid:48)] (cid:117)(cid:116) scanned are also summed to f . At the end, we have that SA[p] = f . See Figure 3. 5.3 Accessing ISA and LCP A similar method can be used to access inverse suffix array cells, ISA[i]. Let us define DISA[i] = ISA[i]− ISA[i− 1] for all i > 1, and DISA[1] = ISA[1]. The role of the runs in SA will now be played by the phrases in ISA, which will be defined analogously as in the proof of Lemma 3: Phrases in ISA start at the positions SA[p] such that a new run starts in BWT [p] (here, last positions of runs 16Note that this symmetrically covers both positions q and q + 1; in Theorem 4, one extra unnecessary position is covered with X 1 l,q, for simplicity. 22 Fig. 3. Illustration of Theorem 5. The area to extract (a gray square) is inside the thick half-block (X), which points inside another area around position q in the next level. The sum of DSA over the offset from the beginning of the area to the mapped block (in thick dashed line) is stored at δ(X), in negative (hence the direction of the arrow). The squared area is mapped to a smaller half-block, X(cid:48), which records in ∆(X(cid:48)) the sum of DSA between the beginning of the area and X(cid:48) (see the other dashed arrow). By adding δ(X) + ∆(X(cid:48)), we map from the first thick block to the second. do not start phrases). Instead of LF , we use the cycle φ(i) of Definition 2. We make use of the following lemmas. Lemma 14. Let [i − 1..i] be within a phrase of ISA. Then it holds that φ(i − 1) = φ(i) − 1 and DISA[i] = DISA[φ(i)]. Proof. Consider the pair of positions T [i−1..i] within a phrase. Let them be pointed from SA[p] = i and SA[q] = i− 1, therefore ISA[i] = p, ISA[i− 1] = q, and LF (p) = q. Now, since i is not a phrase beginning, p is not the first position in a BWT run. Therefore, BWT [p− 1] = BWT [p], from which it follows that LF (p − 1) = LF (p) − 1 = q − 1. Now let SA[p − 1] = j, that is, j = φ(i). Then φ(i − 1) = SA[ISA[i − 1] − 1] = SA[q − 1] = SA[LF (p − 1)] = SA[p − 1] − 1 = j − 1 = φ(i) − 1. It also follows that DISA[i] = p − q = DISA[j] = DISA[φ(i)]. (cid:117)(cid:116) Lemma 15. Let [i − 1..i + s] be within a phrase of DISA, for some 1 < i ≤ n and 0 ≤ s ≤ n − i. Then there exists j (cid:54)= i such that DISA[j..j + s] = DISA[i..i + s] and [j − 1..j + s] contains the first position of a phrase. Proof. By Lemma 14, it holds that DISA[i(cid:48)..i(cid:48) + s] = DISA[i..i + s], where i(cid:48) = φ(i). If DISA[i(cid:48) − 1..i(cid:48) + s] contains the first position of a phrase, we are done. Otherwise, we apply Lemma 14 again on [i(cid:48)..i(cid:48) + s], and repeat until we find a range that contains the first position of a phrase. Just as in Lemma 12, this search eventually terminates because φ is a permutation with a single cycle. (cid:117)(cid:116) We can then use on DISA exactly the same data structure we defined to access SA in Theorem 5, and obtain a similar result for ISA. Theorem 6. Let the BWT of a text T [1..n] contain r runs. Then there exists a data structure using O(r log(n/r)) words that can retrieve any (cid:96) consecutive values of its inverse suffix array ISA in time O(log(n/r) + (cid:96)). Finally, by combining Theorem 5 and Lemma 5, we also obtain access to array LCP without knowing the corresponding text positions. 23 Xδ( )XX'q∆( )X' Theorem 7. Let the BWT of a text T [1..n] contain r runs. Then there exists a data structure using O(r log(n/r)) words that can retrieve any (cid:96) consecutive values of its longest common prefix array LCP in time O(log(n/r) + (cid:96)). Proof. Build the structure of Theorem 5, as well as the one of Lemma 5 with s = log(n/r). Then, to retrieve LCP [p..p + s(cid:48) − 1] for any 0 ≤ s(cid:48) ≤ s, we first compute SA[p] in time O(log(n/r)) using Theorem 5 and then, given SA[p], we compute LCP [p..p + s(cid:48) − 1] using Lemma 5 in time O(log logw(n/r) + s(cid:48)). Adding both times gives O(log(n/r)). To retrieve an arbitrary sequence of cells LCP [p..p+(cid:96)−1], we use the method above by chunks of s cells, plus a possibly smaller final chunk. As we use (cid:100)(cid:96)/s(cid:101) chunks, the total time is O(log(n/r)+(cid:96)). (cid:117)(cid:116) 5.4 Optimal counting and locating in O(r log(n/r)) space The O(r log(n/r)) space we need for accessing T is not comparable with the O(r log logw(σ + n/r)) space we need for optimal counting and locating. The latter is in general more attractive, because the former is better whenever r = ω(n/ logw σ), which means that the text is not very compressible. Anyway, we show how to obtain optimal counting and locating within space O(r log(n/r)). By the discussion above, we only have to care about the case r ≥ n/ log n. In such a case, it holds that r log(n/r) ≥ (n log log n)/ log n,17 and thus we are allowed to use Θ(n log log n) bits of space. We can then make use of a result of Belazzougui and Navarro [12, Lem. 6]. They show how we can enrich the O(n)-bit compressed suffix tree of Sadakane [106] so that, using O(n(log tSA + log log σ)) bits, one can find the interval SA[sp..ep] of P in time O(m + tSA) plus the time to extract a substring of length m from T .18 Since we provide tSA = O(log(n/r)) in Theorem 5 and extraction time O(log(n/r)+m log(σ)/w) in Theorem 4, this arrangement uses O(n(log log(n/r)+log log σ)) ⊆ O(n log log n) bits, and it supports counting in time O(m + log(n/r)). Once we know the interval, apart from counting, we can use Theorem 5 to obtain SA[p] for any sp ≤ p ≤ ep in time O(log(n/r)), and then use the structure of Lemma 4 with s = log(n/r) to extract packs of s(cid:48) ≤ s consecutive SA entries in time O(log logw(n/r) + s(cid:48)) ⊆ O(log(n/r) + s). Overall, we can locate the occ occurrences of P in time O(m + log(n/r) + occ). Finally, to remove the O(log(n/r)) term in the times, we must speed up the searches for patterns shorter than log(n/r). We index them using a compact trie as that of Section 4.2. We store in each explicit trie node (i) the number of occurrences of the corresponding string, to support counting, and (ii) a position p where it occurs in SA, the value SA[p], and the result of the predecessor queries on P + and P −, as required for locating in Lemma 4, so that we can retrieve any number s(cid:48) ≤ s of consecutive entries of SA in time O(s(cid:48)). By Lemma 9, the size of the trie and of the text substrings explicitly stored to support path compression is O(r log(n/r)). Theorem 8. We can store a text T [1..n], over alphabet [1..σ], in O(r log(n/r)) words, where r is the number of runs in the BWT of T , such that later, given a pattern P [1..m], we can count the occurrences of P in T in O(m) time and (after counting) report their occ locations in overall time O(occ). 17Since r log(n/r) grows with r up to r = n/e, we obtain the lower bound by evaluating it at r = n/ log n. 18The O(n log log σ) bits of the space are not explicit in their lemma, but are required in their Section 5, which is used to prove their Lemma 6. 24 6 A Run-Length Compressed Suffix Tree In this section we show how to implement a compressed suffix tree within O(r log(n/r)) words, which solves a large set of navigation operations in time O(log(n/r)). The only exceptions are going to a child by some letter and performing level ancestor queries, which may cost as much as O(log(n/r) log n). The first compressed suffix tree for repetitive collections was built on runs [80], but just like the self-index, it needed Θ(n/s) space to obtain O(s log n) time in key operations like accessing SA. Other compressed suffix trees for repetitive collections appeared later [1, 92, 29], but they do not offer formal space guarantees (see later). A recent one, instead, uses O(e) words and supports a number of operations in time typically O(log n) [8]. The two space measures are not comparable. 6.1 Compressed Suffix Trees without Storing the Tree Fischer et al. [37] showed that a rather complete suffix tree functionality including all the operations in Table 3 can be efficiently supported by a representation where suffix tree nodes v are identified with the suffix array intervals SA[vl..vr] they cover. Their representation builds on the following primitives: 1. Access to arrays SA and ISA, in time we call tSA. 2. Access to array LCP , in time we call tLCP . 3. Three special queries on LCP : (a) Range Minimum Query, RMQ(i, j) = arg min i≤k≤j LCP [k], choosing the leftmost one upon ties, in time we call tRMQ. (b) Previous/Next Smaller Value queries, PSV(p) = max({q < p, LCP [q] < LCP [p]} ∪ {0}), NSV(p) = min({q > p, LCP [q] < LCP [p]} ∪ {n + 1}), in time we call tSV. An interesting finding of Fischer et al. [37] related to our results is that array PLCP , which stores the LCP values in text order, can be stored in O(r) words and accessed efficiently; therefore we can compute any LCP value in time tSA (see also Fischer [34]). We obtained a generalization of this property in Section 3.2. They [37] also show how to represent the array TDE [1..n], where TDE [i] is the tree-depth of the lowest common ancestor of the (i − 1)th and ith suffix tree leaves (and TDE [1] = 0). Fischer et al. [37] represent its values in text order in an array PTDE , which just like PLCP can be stored in O(r) words and accessed efficiently, thereby giving access to TDE in time tSA. They use TDE to compute operations TDepth and LAQT efficiently. Abeliuk et al. [1] show that primitives RMQ, PSV, and NSV can be implemented using a simplified variant of range min-Max trees (rmM-trees) [95], consisting of a perfect binary tree on top of LCP where each node stores the minimum LCP value in its subtree. The three primitives are then computed in logarithmic time. They define the extended primitives PSV(cid:48)(p, d) = max({q < p, LCP [q] < d} ∪ {0}), NSV(cid:48)(p, d) = min({q > p, LCP [q] < d} ∪ {n + 1}), 25 Description Suffix tree root. Text position i of leaf v. String depth for internal nodes, i.e., length of string represented by v. Tree depth, i.e., depth of tree node v. Number of leaves in the subtree of v. Parent of v. First child of v. Next sibling of v. Suffix-link, i.e., if v represents a · α then the node that represents α, for a ∈ [1..σ]. Operation Root() Locate(v) Ancestor(v, w) Whether v is an ancestor of w. SDepth(v) TDepth(v) Count(v) Parent(v) FChild(v) NSibling(v) SLink(v) WLink(v, a) Weiner-link, i.e., if v represents α then the node that represents a · α. SLinki(v) LCA(v, w) Child(v, a) Letter(v, i) LAQS(v, d) LAQT (v, d) Iterated suffix-link. Lowest common ancestor of v and w. Child of v by letter a. The ith letter of the string represented by v. String level ancestor, i.e., the highest ancestor of v with string-depth ≥ d. Tree level ancestor, i.e., the ancestor of v with tree-depth d. Table 3. Suffix tree operations. and compute them in time tSV(cid:48), which in their setting is the same tSV of the basic PSV and NSV primitives. The extended primitives are used to simplify some of the operations of Fischer et al. [37]. The resulting time complexities are given in the second column of Table 4, where tLF is the time to compute function LF or its inverse, or to access a position in BWT . Operation WLink, not present in Fischer et al. [37], is trivially obtained with two LF -steps. We note that most times appear multiplied by tLCP in Fischer et al. [37] because their RMQ, PSV, and NSV structures do not store LCP values inside, so they need to access the array all the time; this is not the case when we use rmM-trees. The time of LAQS is due to improvements obtained with the extended primitives PSV(cid:48) and NSV(cid:48) [1].19 The time for Child(v, a) is obtained by binary searching among the σ minima of LCP [vl, vr], and extracting the desired letter (at position SDepth(v) + 1) to compare with a. Each binary search operation can be done with an extended primitive RMQ(cid:48)(p, q, m) that finds the mth left-to-right occurrence of the minimum in a range. This is easily done in tRMQ(cid:48) = tRMQ time on a rmM-tree by storing, in addition, the number of times the minimum of each node occurs below it [95], but it may be not so easy to do on other structures. Finally, the complexities of TDepth and LAQT make use of array TDE . While Fischer et al. [37] use an RMQ operation to compute TDepth, we note that TDepth(v) = 1 + max(TDE [vl], TDE [vr + 1]), because the suffix tree has no unary nodes (they used this simpler formula only for leaves).20 An important idea of Abeliuk et al. [1] is that they represent LCP differentially, that is, the array DLCP [1..n], where DLCP [i] = LCP [i] − LCP [i − 1] if i > 1 and DLCP [1] = LCP [1], using a context-free grammar (CFG). Further, they store the rmM-tree information in the nonterminals, 19They also use these primitives for NSibling, mentioning that the original formula has a bug. Since we obtain better tRMQ than tSV(cid:48) time, we rather prefer to fix the original bug [37]. The formula fails for the penultimate child of its parent. To compute the next sibling of [vl, vr] with parent [wl, wr], the original formula [vr + 1, u] with u = RMQ(vr + 2, wr) − 1 (used only if vr < wr − 1) must now be checked as follows: if u < wr and LCP [vr + 1] (cid:54)= LCP [u + 1], then correct it to u = wr. 20We observe that LAQT can be solved exactly as LAQS, with the extended PSV(cid:48)/NSV(cid:48) operations, now defined on the array TDE instead of on LCP . However, an equivalent to Lemma 16 for the differential TDE array does not hold, and therefore we cannot use that solution within the desired space bounds. 26 Operation Root() Locate(v) Ancestor(v, w) SDepth(v) TDepth(v) Count(v) Parent(v) FChild(v) NSibling(v) SLink(v) WLink(v) SLinki(v) LCA(v, w) Child(v, a) Letter(v, i) LAQS(v, d) LAQT (v, d) Generic Complexity 1 tSA 1 tRMQ + tLCP tSA 1 tLCP + tSV tRMQ tLCP + tRMQ tLF + tRMQ + tSV tLF tSA + tRMQ + tSV tRMQ + tSV Our Complexity 1 log(n/r) 1 log(n/r) log(n/r) 1 log(n/r) log(n/r) log(n/r) log(n/r) log logw(n/r) log(n/r) log(n/r) tLCP + (tRMQ(cid:48) + tSA + tLF ) log σ log(n/r) log σ tSA + tLF tSV(cid:48) (tRMQ + tLCP ) log n log(n/r) log(n/r) + log logw r log(n/r) log n Table 4. Complexities of suffix tree operations. Letter(v, i) can also be solved in time O(i· tLF ) = O(i log logw(n/r)). that is, a nonterminal X expanding to a substring D of DLCP stores the (relative) minimum m(X) = min 0≤k≤D D[i] k(cid:88) k(cid:88) i=1 i=1 of any LCP segment having those differential values, and its position inside the segment, p(X) = arg min D[i]. 0≤k≤D Thus, instead of a perfect rmM-tree, they conceptually use the grammar tree as an rmM-tree. They show how to adapt the algorithms on the perfect rmM-tree to run on the grammar, and thus solve primitives RMQ, PSV(cid:48), and NSV(cid:48), in time proportional to the grammar height. Abeliuk et al. [1], and also Fischer et al. [37], claim that the grammar produced by RePair [75] is of size O(r log(n/r)). This is an incorrect result borrowed from Gonz´alez et al. [51, 52], where it was claimed for DSA. The proof fails for a reason we describe in our technical report [44, Sec. A]. We now start by showing how to build a grammar of size O(r log(n/r)) and height O(log(n/r)) for DLCP . This grammar is of an extended type called run-length context-free grammar (RLCFG) [97], which allows rules of the form X → Y t that count as size 1. We then show how to implement the operations RMQ and NSV/PSV in time O(log(n/r)) on the resulting RLCFG, and NSV(cid:48)/PSV(cid:48) in time O(log(n/r)+log logw r). Finally, although we cannot implement RMQ(cid:48) in time below Θ(log n), we show how the specific Child operation can be implemented in time O(log(n/r) log σ). Note that, although we could represent DLCP using a Block-Tree-like structure as we did in Section 5 for DSA and DISA, we have not devised a way to implement the more complex operations we need on DLCP using such a Block-Tree-like data structure within polylogarithmic time. Using the results we obtain in this and previous sections, that is, tSA = O(log(n/r)), tLF = O(log logw(n/r)), tLCP = tSA + O(log logw(n/r)) = O(log(n/r)), tRMQ = tSV = O(log(n/r)), tSV (cid:48) = O(log(n/r) + log logw r), and our specialized algorithm for Child, we obtain our result. 27 Theorem 9. Let the BWT of a text T [1..n], over alphabet [1..σ], contain r runs. Then a compressed suffix tree on T can be represented using O(r log(n/r)) words, and it supports the operations with the complexities given in the third column of Table 4. 6.2 Representing DLCP with a run-length grammar In this section we show that the differential array DLCP can be represented by a RLCFG of size O(r log(n/r)). We first prove a lemma analogous to those of Section 5. Lemma 16. Let [p−2, p] be within a BWT run. Then LF (p−1) = LF (p)−1 and DLCP [LF (p)] = DLCP [p]. Proof. Let i = SA[p], j = SA[p − 1], and k = SA[p − 2]. Then LCP [p] = lcp(T [i..], T [j..]) and LCP [p−1] = lcp(T [j..], T [k..]). We know from Lemma 12 that, if q = LF (p), then LF (p−1) = q−1 and LF (p − 2) = q − 2. Also, SA[q] = i − 1, SA[q − 1] = j − 1, and SA[q − 2] = k − 1. Therefore, LCP [LF (p)] = LCP [q] = lcp(T [SA[q]..], T [SA[q − 1]..) = lcp(T [i − 1..], T [j − 1..]). Since p is not the first position in a BWT run, it holds that T [j − 1] = BWT [p − 1] = BWT [p] = T [i − 1], and thus lcp(T [i − 1..], T [j − 1..]) = 1 + lcp(T [i..], T [j..]) = 1 + LCP [p]. Similarly, LCP [LF (p) − 1] = LCP [q − 1] = lcp(T [SA[q − 1]..], T [SA[q − 2]..) = lcp(T [j − 1..], T [k − 1..]). Since p − 1 is not the first position in a BWT run, it holds that T [k − 1] = BWT [p − 2] = BWT [p − 1] = T [j − 1], and thus lcp(T [j − 1..], T [k − 1..]) = 1 + lcp(T [j..], T [k..]) = 1 + LCP [p − 1]. Therefore DLCP [q] = LCP [q] − LCP [q − 1] = (1 + LCP [p]) − (1 + LCP [p − 1]) = DLCP [p]. (cid:117)(cid:116) It follows that, if p1 < . . . < pr are the positions that start runs in BWT , then we can define a bidirectional macro scheme [110] of size at most 4r + 1 on DLCP . Definition 6. A bidirectional macro scheme (BMS) of size b on a sequence S[1..n] is a partition S = S1 . . . Sb such that each Sk is of length 1 (and is represented as an explicit symbol) or it appears somewhere else in S (and is represented by a pointer to that other occurrence). Let f (i), for 1 ≤ i ≤ n, be defined arbitrarily if S[i] is an explicit symbol, and f (i) = j + i(cid:48) − 1 if S[i] = Sk[i(cid:48)] is inside some Sk that is represented as a pointer to S[j..j(cid:48)]. A correct BMS must hold that, for any i, there is a k ≥ 0 such that f k(i) is an explicit symbol. Note that f (i) maps the position S[i] to the source from which it is to be obtained. The last condition then ensures that we can recover any symbol S[i] by following the chain of copies until finding an explicitly stored symbol. Finally, note that all the f values inside a block are consecutive: if Sk = S[i..i(cid:48)] has a pointer to S[j..j(cid:48)], then f ([i..i(cid:48)]) = [j..j(cid:48)]. Lemma 17. Let p1 < . . . < pr be the positions that start runs in BWT , and assume p0 = −2 and pr+1 = n + 1. Then, the partition formed by (1) all the explicit symbols DLCP [pi + k] for 1 ≤ i ≤ r and k ∈ {0, 1, 2}, and (2) all the nonempty regions DLCP [pi +3..pi+1−1] for all 0 ≤ i ≤ r, pointing to DLCP [LF (pi + 3)..LF (pi+1 − 1)], is a BMS. Proof. By Lemma 16, it holds that LF (pi + 3 + k) = LF (pi + 3) + k and DLCP [pi + 3 + k] = DLCP [LF (pi + 3) + k] for all 0 ≤ k ≤ pi+1 − pi − 4, so the partition is well defined and the copies are correct. To see that it is a BMS, it is sufficient to notice that LF is a permutation with one cycle on [1..n], and therefore LF k(p) will eventually reach an explicit symbol, for some 0 ≤ k < n. (cid:117)(cid:116) We now make use of the following result. 28 Lemma 18 ([45, Thm. 1]). Let S[1..n] have a BMS of size b. Then there exists a RLCFG of size O(b log(n/b)) that generates S. Since DLCP has a BMS of size at most 4r + 1, the following corollary is immediate. Lemma 19. Let the BWT of T [1..n] have r runs. Then there exists a RLCFG of size O(r log(n/r)) that generates its differential LCP array, DLCP . 6.3 Supporting the primitives on the run-length grammar We describe how to compute the primitives RMQ and PSV/NSV on the RLCFG of DLCP , in time tRMQ = tSV = O(log(n/r)). The extended primitives PSV(cid:48)/NSV(cid:48) are solved in time tSV (cid:48) = O(log(n/r)+log logw r). While analogous procedures have been described before on CFGs and trees [1, 95], the extension to RLCFGs and the particular structure of our grammar requires a complete description. The RLCFG built in Lemma 18 [45] is of height O(log(n/r)) and has one initial rule S → X1 . . . XO(r). The other rules are of the form X → Y1Y2 or X → Y t for t > 2. All the right-hand symbols can be terminals or nonterminals. The data structure we use is formed by a sequence DLCP(cid:48) = X1 . . . XO(r) capturing the initial rule of the RLCFG, and an array of the other O(r log(n/r)) rules. For each nonterminal X expanding to a substring D of DLCP , we store its length l(X) = D and its total difference d(X) = D[1] + . . . + D[l(X)]. For terminals X, assume l(X) = 1 and d(X) = X. We also store a cumulative length array L[0] = 0 and L[x] = L[x − 1] + l(Xx) that can be binary searched to find the symbol of DLCP(cid:48) that contains any desired position DLCP [p]. To ensure that this binary search takes time O(log(n/r)) when r = ω(n/r), we can store a sampled array of positions S[1..r], where S[t] = x if L[x − 1] < t · (n/r) ≤ L[x] to narrow down the binary search to a range of O(n/r) entries of L. We also store a cumulative differences array A[0] = 0 and A[x] = A[x − 1] + d(Xx). Although we have already provided access to any LCP [p] in Section 5.3, it is also possible to do it with these structures. We first find x by binary searching L for p, possibly with the help of S, and set f ← A[x − 1] and p ← p − L[x − 1]. Then we enter recursively into nonterminal X = Xx. If its rule is X → Y1Y2, we continue by Y1 if p ≤ l(Y1); otherwise we set f ← f + d(Y1), p ← p − l(Y1), and continue by Y2. If, instead, its rule is X → Y t, we compute t(cid:48) = (cid:100)p/l(Y )(cid:101) − 1, set f ← f + t(cid:48) · d(Y ), p ← p − t(cid:48) · l(Y ), and continue by Y . When we finally arrive at a terminal X, the answer is f + d(X). All this process takes time O(log(n/r)), the height of the RLCFG. Answering RMQ. To answer this query, we store a few additional structures. We store an array M such that M [x] = minL[x−1]<k≤L[x] LCP [k], that is, the minimum value in the area of LCP expanded by Xx = DLCP(cid:48)[x]. We store a succinct data structure RMQM , which requires just O(r) bits and finds the leftmost position of a minimum in any range M [x..y] in constant time, without need to access M [36]. We also store, for each nonterminal X, the already defined values m(X) and p(X) (for terminals X, we can store m(X) and p(X) or compute them on the fly). To compute RMQ(p, q) on LCP , we first use L and S to determine that DLCP [p..q] contains the expansion of DLCP(cid:48)[x+1..y−1], whereas DLCP(cid:48)[x..y] expands to DLCP [p(cid:48)..q(cid:48)] with p(cid:48) < p ≤ q < q(cid:48). Thus, DLCP [p..q] partially overlaps DLCP(cid:48)[x] and DLCP(cid:48)[y] (the overlap could be empty). We first obtain in constant time the minimum position of the central area, z = RMQM (x + 1, y − 1), and then the minimum value in that area is LCP [L[z − 1] + p(Xz)]. To complete the query, we must compare this value with the minima in Xx(cid:104)p− p(cid:48) + 1, l(Xx)(cid:105) and Xy(cid:104)1, l(Xy) + q− q(cid:48)(cid:105), where X(cid:104)a, b(cid:105) 29 refers to the substring D[a..b] in the expansion D of X. A relevant special case in this scheme is that DLCP [p..q] is inside a single symbol DLCP(cid:48)[x] expanding to DLCP [p(cid:48)..q(cid:48)], in which case the query boils down to finding the minimum value in Xx(cid:104)p − p(cid:48) + 1, l(Xx) + q − q(cid:48)(cid:105). Let us disregard the rules X → Y t for a moment. To find the minimum in Xw(cid:104)a, b(cid:105), we identify the k = O(log(n/r)) maximal nodes of the grammar tree that cover the range [a..b] in the expansion of Xw. Let these nodes be Y1, Y2, . . . , Yk. We then find the minimum of m(Y1), d(Y1) + m(Y2), d(Y1) + d(Y2) + m(Y3), . . ., in O(k) time. Once the minimum is identified at Ys, we obtain the absolute value by extracting LCP [L[w − 1] + l(Y1) + . . . + l(Ys−1) + p(Ys)]. Our grammar also has rules of the form X → Y t, and thus the maximal coverage Y1, . . . , Yk may for some 1 ≤ t(cid:48) < t. We can then compute on the fly m(Y t(cid:48) include a part of these rules, say Y t(cid:48) ) as m(Y ) if d(Y ) ≥ 0, and (t(cid:48) − 1) · d(Y ) + m(Y ) otherwise. Similarly, p(Y t(cid:48) ) is p(Y ) if d(Y ) ≥ 0 and (t(cid:48) − 1) · l(Y ) + p(Y ) otherwise. Once we have the (up to) three minima from Xx, DLCP(cid:48)[x + 1..y − 1], and Xy, the position of the smallest of the three is RMQ(p, q). Answering PSV/NSV and PSV(cid:48)/NSV(cid:48). These queries are solved analogously. Let us describe NSV(cid:48)(p, d), since PSV(cid:48)(p, d) is similar. Let DLCP [p..] be included in the expansion of DLCP(cid:48)[x..], which expands to DLCP [p(cid:48)..] (for the largest possible p(cid:48) ≤ p), and let us subtract LCP [p(cid:48) − 1] = A[x − 1] from d to put it in relative form. We first consider Xx(cid:104)p − p(cid:48) + 1, l(Xx)(cid:105) = X(cid:104)a, b(cid:105), obtaining the O(log(n/r)) maximal nonterminals Y1, Y2, . . . , Yk that cover X(cid:104)a, b(cid:105), and find the first Ys where d(Y1) + . . . + d(Ys−1) + m(Ys) < d. Then we subtract d(Y1) + . . . + d(Ys−1) from d, add l(Y1) + . . . + l(Ys−1) to p, and continue recursively inside Ys to find the precise point where the cumulative differences fall below d. The recursive traversal from Ys works as follows. If Ys → Y1Y2, we first see if m(Y1) < d. If so, we continue recursively on Y1; otherwise, we subtract d(Y1) from d, add l(Y1) to p, and continue recursively on Y2. If, instead, the rule is Ys → Y t, we proceed as follows. If d(Y ) ≥ 0, then the answer must be in the first copy of Y , thus we recursively continue on Y . If d(Y ) < 0, instead, we must find the copy t(cid:48) into which we continue. This is the smallest t(cid:48) such that (t(cid:48) − 1)· d(Y ) + m(Y ) < d, that is, t(cid:48) = max(1, 2 + (cid:98)(d − m(Y ))/d(Y )(cid:99)). Thus we subtract (t(cid:48) − 1) · d(Y ) from d, add (t(cid:48) − 1) · l(Y ) to p, and continue with Y . Finally, when we arrive at a terminal X, it holds that m(X) < d and the answer to the query is the current value of p. All of this process takes time O(log(n/r)), the height of the grammar. It might be, however, that we traverse Y1, Y2, . . . , Yk, that is, the whole Xx(cid:104)p − p(cid:48) + 1, l(Xx)(cid:105), and still do not find a value below d. We then must find where we fall below (the current value of) d inside DLCP(cid:48)[x + 1..]. Once this search identifies the leftmost position DLCP(cid:48)[z] where the answer lies, we complete the search on Xz(cid:104)1, l(Xz)(cid:105) as before, for d ← d − A[z − 1] + A[x]. The search problem can be regarded as follows: Given the array B[z] = A[z] + m(Xz), find the leftmost position z > x such that B[z] < A[x] + d. Navarro and Sadakane [95, Sec. 5.1] show that this query can be converted into a weighted ancestor query on a tree: given nodes with weights that decrease toward the root, the query gives a node v and a weight w and seeks for its nearest ancestor with weight < w. In our case, the tree has O(r) nodes and the weights are LCP values, in the range [0..n − 1]. Kopelowitz and Lewenstein [72, Sec. 3.2] show how this query can be solved in O(r) space and the time of a predecessor query. Those predecessor queries are done on universes of size n where there can be arbitrarily few elements. However, we can resort to binary search if there are O(n/r) elements, within the allowed time O(log(n/r)). Therefore, the predecessor queries have 30 to be implemented only on sets of Ω(n/r) elements. By using the structure of Belazzougui and Navarro [13, Thm. 14], the predecessor time is O(log logw r). Therefore, we obtain time tSV(cid:48) = O(log(n/r) + log logw r). This time can be reduced to tSV = O(log(n/r)) for the simpler primitives PSV/NSV as follows: When r is so large that log(n/r) < log log n, that is, r > n/ log n, the allowed Θ(r log(n/r)w) bits of space are actually Ω(n log log n). We are then entitled to use O(n) bits of space, within which we can solve queries PSV and NSV in O(1) time [37, Thm. 3]. 6.4 Supporting operation Child Operation Child (v, a) requires us to binary search the O(σ) positions where the minimum occurs in LCP [vl + 1..vr], and choose the one that descends by letter a. Each check for a takes O(log(n/r)) time, as explained. ) = n(Y ) if d(Y ) (cid:54)= 0 and t(cid:48) · n(Y ) if d(Y ) = 0. To implement this operation efficiently, we will store for each nonterminal X the number n(X) of times m(X) occurs inside the expansion of X. To do the binary search on LCP [p..q] (with p = vl +1 and q = vr), we first compute RMQ(p, q) as in the previous section, and then find the desired occurrence of its relative version, µ = LCP [RMQ(p, q)]− LCP [p− 1], through Xx(cid:104)p− p(cid:48) + 1, l(Xx)(cid:105), DLCP(cid:48)[x + 1..y − 1], and Xy(cid:104)1, l(Xy) + q − q(cid:48)(cid:105). The values p(cid:48), q(cid:48), x, and y are those we computed to obtain RMQ(p, q). Searching inside a nonterminal. To process Xw(cid:104)a, b(cid:105) we first determine how many occurrences of µ it contains. We start with a counter c = 0 and scan again Y1, Y2, . . . , Yk. For each Ys, if d(Y1) + . . . + d(Ys−1) + m(Ys) = µ, we add c ← c + n(Ys). To process Y t(cid:48) in constant time note that, if µ occurs in Y t(cid:48) , then it occurs only in the first copy of Y if d(Y ) > 0, only in the last if d(Y ) < 0, and in every copy if d(Y ) = 0. Therefore, n(Y t(cid:48) After we compute c in O(log(n/r)) time, we binary search the c occurrences of µ in Xw(cid:104)a, b(cid:105). For each of the O(log c) = O(log σ) steps of this binary search, we must find a specific occurrence of µ, and then compute the corresponding letter to compare with a and decide the direction of the search. As said, we can compute the corresponding letter in time O(log(n/r)). We now show how a specific occurrence of µ is found within the same time complexity. Finding a specific occurrence inside a nonterminal. Assume we want to find the c(cid:48)th occurrence of µ in Xx(cid:104)p − p(cid:48) + 1, l(Xx)(cid:105). We traverse once again Y1, Y2, . . . , Yk. For each Ys, if d(Y1) + . . . + d(Ys−1) + m(Ys) = µ, we subtract c(cid:48) ← c(cid:48) − n(Ys). When the result is below 1, the occurrence is inside Ys. We then add l(Y1) + . . . + l(Ys−1) to p, subtract d(Y1) + . . . + d(Ys−1) from µ, restore c(cid:48) ← c(cid:48) + n(Ys), and recursively search for µ inside Ys. Let Ys → Y1Y2. If m(Y1) (cid:54)= µ, we continue on Y2 with p ← p + l(Y1) and µ ← µ − d(Y1). If m(Y1) = µ and n(Y1) ≥ c(cid:48), we continue on Y1. Otherwise, we continue on Y2 with p ← p + l(Y1), µ ← µ − d(Y1) and c(cid:48) ← c(cid:48) − n(Y1). To process Y t in the quest for c(cid:48), we do as follows. If d(Y ) > 0, then µ can only occur in the first copy of Y . Thus, if m(Y ) (cid:54)= µ, we just skip Y t with p ← p + t · l(Y ) and µ ← µ − t · d(Y ). If m(Y ) = µ, we see if n(Y ) ≥ c(cid:48). If so, then we enter into Y ; otherwise we skip Y t with p ← p+t·l(Y ), µ ← µ− t· d(Y ) and c(cid:48) ← c(cid:48) − n(Y ). The case where d(Y ) < 0 is similar, except that when we enter into Y , it is the last one of Y t, and thus we set p ← p + (t − 1) · l(Y ) and µ ← µ − (t − 1) · d(Y ). Finally, if d(Y ) = 0, then the minimum of Y appears many times. If m(Y ) (cid:54)= µ, we skip Y t with p ← p + t · l(Y ) and µ ← µ − t · d(Y ). Otherwise, if t · n(Y ) < c(cid:48), we must also skip Y t, updating p 31 and µ, and also c(cid:48) ← c(cid:48) − t · n(Y ). Otherwise, we must enter into the t(cid:48)th occurrence of Y , where t(cid:48) = (cid:100)c(cid:48)/n(Y )(cid:101), by continuing on Y with p ← p + (t(cid:48) − 1) · l(Y ), µ ← µ − (t(cid:48) − 1) · d(Y ) and c(cid:48) ← c(cid:48) − (t(cid:48) − 1) · n(Y ). Therefore, if the desired minimum is in Xw(cid:104)a, b(cid:105), we spot it in O(log(n/r) log σ) time. Searching the central area. If we do not find the desired letter inside Xx(cid:104)p − p(cid:48) + 1, l(Xx)(cid:105) or Xy(cid:104)1, l(Xy) + q − q(cid:48)(cid:105), we must find it in DLCP(cid:48)[x + 1..y − 1]. Here we proceed differently. From the computation of RMQ(p, q) we know if there are occurrences of µ in DLCP(cid:48)[x + 1..y − 1]. If there are, then any minimum in this range is an occurrence of µ. We binary search those minima by using a representation that uses O(r) bits on top of M and finds an approximation to the median of the minima in constant time [35] (it might not be the median but its rank is a fraction between 1/16 and 15/16 of the total). For each DLCP [z] that contains some occurrence of µ, we obtain its leftmost position L[z − 1] + p(Yz) and determine the associated letter, compare it with a and determine if the binary search on DLCP(cid:48)[x+1..y−1] goes left or right. Since there are O(σ) minima in DLCP(cid:48)[x + 1..y − 1], the search also takes O(log(n/r) log σ) time. done on Xw(cid:104)a, b(cid:105) to determine the exact occurrence, if it exists. Once we have finally determined that our letter must occur inside some Xz, we process it as 7 Experimental results We implemented our simplest scheme, that is, Theorem 1 using O(r) space, and compared it with the state of the art. 7.1 Implementation We implemented the simpler version described by Bannai et al. [2] of the structure of Theorem 1 (with s = 1) using the sdsl library [48].21 For the run-length FM-index, we used the implementation described by Prezza [101, Thm. 28] (suffix array sampling excluded), taking (1 + )r(log(n/r) + 2) + r log σ bits of space (lower-order terms omitted for readability) for any constant  > 0 fixed at construction time and supporting O(log(n/r) + log σ)-time LF mapping. In our implementation, we chose  = 0.5. This structure employs Huffman-compressed wavelet trees (sdsl's wt huff) to represent run heads, as in our experiments they turned out to be comparable in size and faster than Golynski et al.'s structure [50], which is implemented in sdsl's wt gmr. Our locate machinery is implemented as follows. We store one gap-encoded bitvector First[1..n] marking with a bit set the text positions that are the first in their BWT run (note that First[i] refers to text position i, not BWT position). First is implemented using sdsl's sd vector, takes overall r(log(n/r)+2) bits of space (lower-order terms omitted), and answers queries in O(log(n/r)) time. We also store a vector FirstToRun[1..r] such that text position First.select1(i) belongs to the FirstToRun[i]-th BWT run. FirstToRun is a packed integer vector stored in r log r bits. Finally, we explicitly store r suffix array samples in a vector Samples[1..r]: Samples[p] is the text position corresponding to the last letter in the p-th BWT run. Samples is also a simple packed vector, stored in r log n bits of space. Let SA[sp..ep] be the range of our query pattern. The run-length FM-index and vector Samples are sufficient to find the range [sp..ep] and locate SA[ep] using the simplified toe-hold lemma [2]. 21https://github.com/simongog/sdsl-lite 32 Moreover, for 0 < i < n it holds that φ(i) = Samples[FirstToRun[First.rank1(i )] − 1] + ∆, where ∆ = i − First.predecessor(i) (assuming for simplicity that the first text position is marked in First; the general case can easily be handled with few more operations). Note that φ is evaluated in just O(log(n/r)) time. Notably, this time drops to O(1) in the average case, that is, when bits set in First are uniformly distributed. This is because sdsl's sd vector breaks the bitvector into r equal-sized buckets and solves queries inside each bucket (which in the average case contains just O(1) bits set). Occurrences SA[ep − 1], SA[ep − 2], . . . , SA[sp] are then retrieved as φk(SA[ep]), for k = 1, . . . , ep − sp. Overall, our index takes at most ((1 + ) log(n/r) + 2 log n + log σ + 4 + 2) r bits of space for any constant  > 0 (lower-order terms omitted for readability) and, after counting, locates each pattern occurrence in O(log(n/r)) time. Note that the space of our index essentially coincides with the information-theoretic minimum needed for storing the run-length BWT and 2r text positions in plain format (which is r log(n/r) + r log σ + 2r log n bits); therefore it is close to the optimum, since our locate strategy requires storing 2r text positions. In the following, we refer to our index as r-index; the code is publicly available22. 7.2 Experimental Setup We compared r-index with the state-of-the-art index for each compressibility measure: lzi23 [73, 24] (z), slp23 [25, 24] (g), rlcsa24 [79, 80] (r), and cdawg25 [9] (e). We also included hyb26 [30, 31], which combines a Lempel-Ziv index with an FM-index, with parameter M = 8, which is optimal for our experiment. We tested rlcsa using three suffix array sample rates per dataset: the rate X resulting in the same size for rlcsa and r-index, plus rates X/2 and X/4. We measured memory usage and locate times per occurrence of all indexes on 1000 patterns of length 8 extracted from four repetitive datasets, which are also published with our implementation: DNA: an artificial dataset of 629,145 copies of a DNA sequence of length 1000 (Human genome) where each character was mutated with probability 10−3; boost: a dataset consisting of concatenated versions of the GitHub's boost library; einstein: a dataset consisting of concatenated versions of Wikipedia's English Einstein page; world leaders: a collection of all pdf files of CIA World Leaders from 2003 to 2009 downloaded from the Pizza&Chili corpus. Table 5 shows the main characteristics of the datasets: the length n, the alphabet size σ, the number of runs r in their BWT, the number z of LZ77 phrases27, and the size of g the grammar generated by Repair28. Note the varying degrees of repetitiveness: boost is the most repetitive dataset, followed by DNA and einstein, which are similar, and followed by the least repetitive one, world leaders. It can be seen that g ≥ z by a factor of 1.3 -- 2.8 and r ≥ g by a factor of 1.0 -- 1.8. Therefore, we could expect in general that the indexes based on grammars or on Lempel-Ziv parsing are smaller than r-index, but as we see soon, the differences are not that large. 22https://github.com/nicolaprezza/r-index 23https://github.com/migumar2/uiHRDC 24https://github.com/adamnovak/rlcsa 25https://github.com/mathieuraffinot/locate-cdawg 26https://github.com/hferrada/HydridSelfIndex 27Using code requested to the authors of an efficient LZ77 parser [59]. 28Using the "balanced" version offered at http://www.dcc.uchile.cl/gnavarro/repair.tgz 33 Dataset DNA boost einstein world leaders n r z g σ 10 1,287,508 (0.065) 551,237 (0.028) 727,671 (0.037) 629,140,006 629,145,600 96 63,480 (0.003) 958,671 (0.049) 292,117 (0.015) 631,239 (0.032) 629,145,600 194 89 573,487 (0.391) 175,740 (0.120) 507,525 (0.346) 62,025 (0.003) 22,747 (0.001) 46,968,181 Table 5. The main characteristics of our dataset. The numbers in parentheses are rough approximations to the bits/symbol achievable by the associated compressors by using one 4-byte integer per run, phrase, or right-hand-side grammar symbol. Memory usage (Resident Set Size, RSS) was measured using /usr/bin/time between index loading time and query time. This choice was motivated by the fact that, due to the datasets' high repetitiveness, the number occ of pattern occurrences was very large. This impacts sharply on the working space of indexes such as lzi and slp, which report the occurrences in a recursive fashion. When considering this extra space, these indexes always use more space than the r-index, but we prefer to emphasize the relation between the index sizes and their associated compressibility measure. The only existing implementation of cdawg works only on DNA files, so we tested it only on the DNA dataset. 7.3 Results Figure 4 summarizes the results of our experiments. On all datasets, the time per occurrence of r-index is 100 -- 300 nanoseconds per occurrence, outperforming all the indexes based on Lempel-Ziv or grammars by a factor of 10 to 100. These indexes are generally smaller, using 45% -- 95% (lzi), 80% -- 105% (slp), and 45% -- 100% (hyb) of the space of r-index, at the expense of being orders of magnitude slower, as said: 20 -- 100 (lzi), 8 -- 50 (slp), and 7 -- 11 (hyb) times. Further, r-index dominates all practical space-time tradeoffs of rlcsa: using the same space, rlcsa is 20 -- 500 times slower than rindex, and letting it use 1.7 -- 4.4 times the space of r-index, it is still 5 -- 100 times slower. The regular sampling mechanism of the FM-index is then completely outperformed. Finally, cdawg is almost twice as fast as r-index, but it is 60 times larger (indeed, larger than a classical FM-index), which leaves it out of the competition on "small" indexes. Comparing with the bits per symbol of Table 5, we note that the space of r-index is 2 -- 4 words per run, whereas lzi and hyb use 3 -- 6 words per Lempel-Ziv phrase and slp uses 4 -- 6 words per symbol on the right-hand-side of a rule. The low space per run of r-index compared to the indexes based on z or g shrink the space gap one could expect from comparing the measures r, z, and g. 7.4 Scalability We finish with an experiment showing the space performance of the indexes on a real collection of Influenza nucleotide sequences from NCBI29. It is formed by 641,444 sequences, of total size 0.95 GB after removing the headers and newlines. We built the indexes on 100 prefixes of the dataset, whose sizes increased evenly from 1% to 100% of the sequences. As the prefixes grew, they became more repetitive; we measured how the bits per symbol used by the indexes decreased accordingly. As a repetition-insensitive variant, we also include a classical succinct FM-index (fm-index), with a typical sampling rate of (cid:100)lg n(cid:101) positions for locating, plain bitvectors for the wavelet trees and for marking the sampled SA positions, and a rank implementation using 1.25 bits per input bit. 29ftp://ftp.ncbi.nih.gov/genomes/INFLUENZA/influenza.fna.gz, the description is in the parent directory. 34 Fig. 4. Locate time per occurrence and working space (in bits per symbol) of the indexes. The y-scale measures nanoseconds per occurrence reported and is logarithmic. Figure 5 shows the evolution of the index sizes. As we add more and more similar sequences, all the indexes (except the FM-index) decrease in relative size (bps), as expected. On the complete collection, fm-index still uses 4.75 bits per symbol (bps), whereas r-index has decreased to 0.88 bps (about 2.4 words per run), hyb to 0.52 bps (about 5.5 words per phrase, 60% of r-index), slp to 0.49 bps (about 1.9 words per symbol, 56% of r-index), and lzi to 0.22 bps (about 2.3 words per phrase, 25% of r-index). We remind that, in exchange, r-index is 10 -- 100 times faster than those indexes, and that it uses 18% of the space of the classic fm-index (a factor that decreases as the collection grows). This collection, where the repetitiveness is not as high as in the previous datasets (in fact, it is close to that of world leaders), shows that r (and thus r-index) is more sensitive than g and z to the decrease in repetitiveness. In particular, g and z are always O(n/ logσ n), and thus the related indexes always use O(n log σ) bits. Instead, r can be as large as n [101], so in the worst case r-index can use Θ(n log n) bits. Note, in particular, that the other indexes are below the 2 bps of the raw data after processing just 3% of the collection; r-index breaks this barrier only after 8%. 8 Construction In this section we analyze the working space and time required to build all our data structures. Table 6 summarizes the results. The working space does not count the space needed to read the text in online form, right-to-left. Times are worst-case unless otherwise stated. Expected cases hold with high probability (w.h.p.), which means over 1 − 1/nc for any fixed constant c. 8.1 Dictionaries and predecessor structures A dictionary mapping t keys from a universe of size u to an interval [1..O(t)] can be implemented as a perfect hash function using O(t) space and searching in constant worst-case time. Such a function can be built in O(t) space and expected time [38]. A construction that takes O(t) time w.h.p. [115] starts with a distributor hash function that maps the keys to an array of buckets B[1..t]. Since the largest bucket contains O(log t/ log log t) keys w.h.p., we can build a fusion tree [39] on each bucket, which requires linear space and construction time, and constant query time. 35 lll2.02.53.03.54.04.55.0DNARSS (bits/symbol)time/occ (log10(ns))00.412 ...lll0.000.060.122.02.53.03.54.04.55.0boostRSS (bits/symbol)lll0.00.20.42.02.53.03.54.04.55.0einsteinRSS (bits/symbol)lll012342.02.53.03.54.04.55.0world_leadersRSS (bits/symbol)lr−indexrlcsalzicdawgslphyb Fig. 5. Index sizes (in bits per symbol, bps) for increasing prefixes of a repetitive collection of genomic data. If we are interested in deterministic construction time, we can resort to the so-called determin- istic dictionaries, which use O(t) space and can be built in time O(t(log log t)2) [104]. A minimum perfect hash function (mphf ) maps the keys to the range [1..t]. This is trivial using O(t) space (we just store the mapped value), but it is also possible to store a mphf within O(t) bits, building it in O(t) expected time and O(t) space [6]. Such expected time holds w.h.p. as well if they use a distributor function towards t(cid:48) = O(t/ log t) buckets. For each bucket Bi, i ∈ [1..t(cid:48)], they show that w.h.p. O(log t) trials are sufficient to find a perfect hash function σ(i) for Bi, adding up to O(t) time w.h.p. Further, the indexes σ(i) found distribute geometrically (say, with a constant parameter p), and the construction also fails if their sum exceeds λ · t/p for some constant λ of our choice. The probability of that event is exponentially decreasing with t(cid:48) for any λ > 1 [56]. A monotone mphf (mmphf ), in addition, preserves the order of the keys. A mmphf can be stored in O(t log log u) bits while answering in constant time. Its construction time and space is as for a mphf [3, Sec. 3] (see also [4, Sec. 3]). Therefore, all the expected cases we mention related to building perfect hash functions of any sort hold w.h.p. as well. Alternatively, their construction time can turn into worst-case w.h.p. of being correct. Our predecessor structure [13, Thm. 14] requires O(t) words and answers in time O(log logw(u/t)). Its reduced-space version [13, Sec. A.1 and A.2], using O(t log(u/t)) bits, does not use hashing. It is a structure of O(log logw(u/t)) layers, each containing a bitvector of O(t) bits. Its total worst-case construction time is O(t log logw(u/t)), and requires O(t) space. Finally, note that if we can use O(u) bits, then we can build a constant-time predecessor structure in O(u) time, by means of rank queries on a bitvector. 8.2 Our basic structure The basic structures of Section 2.5 can be built in O(r) space. We start by using an O(r)-space construction of the run-length encoded BWT that scans T once, right to left, in O(n log r) time [101] (see also Ohno et al. [99] and Kempa [?]). The text T is not needed anymore from now on. 36 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 0 10 20 30 40 50 60 70 80 90 100bps% of datasetInfluenzafm-indexr-indexlzislphyb Structure Basic counting and locating (Lem. 1) or Fast locating (Thm. 1 + Lem. 4, s = log logw(n/r)) or Optimal counting and locating (Thm. 2) or RAM-optimal counting and locating (Thm. 3) or Text substrings (Thm. 4) or Accessing SA, ISA, and LCP (Thm. 5, 6 & 7) or Construction space O(r) O(n) Construction time O(n log r) O(n) O(n(log r + log logw(n/r))) O(r log logw(n/r)) O(n) O(n(log r + log logw(n/r))) O(r log logw(σ + n/r)) O(n + r(log log σ)3) O(n(log r + log logw(n/r))) O(rw logσ logw(σ + n/r)) O(n) O(n) + O(rw1+) exp. O(n) O(n + rw1+) exp. O(n(log r + log logw(n/r))) O(r log(n/r)) O(n) O(n(log r + log logw(n/r))) O(r log(n/r)) O(n) O(n) O(n) O(r log(n/r) log n/ log log n) O(n) O(n) O(n + r log logw r) O(n) O(n(log r + log logw(n/r))) O(B + r log(n/r)) O(n(log r + log logw(n/r))) O(B + r log(n/r)) Optimal counting/locating, O(r log(n/r)) space (Thm. 8) O(n + r(log log σ)2) exp. Suffix tree (Thm. 9) without operation LAQS with O(Sort(n)) I/Os with O(n/B + log(n/r)) I/Os, no TDepth & LAQT Table 6. Construction time and space for our different data structures, for any constant  > 0. All the expected times ("exp.") hold w.h.p. as well. Variable B is the block size in the external memory model, where Sort(n) denotes the I/O complexity of sorting n integers. We then build the predecessor structure E that enables the LF -steps in time O(log logw(n/r)). The construction takes O(r log logw(n/r)) time and O(r) space. The positions p that start or end BWT runs are easily collected in O(r) time from the run-length encoded BWT . The structures to compute rank on L(cid:48) in time O(log logw σ) [13] also use predecessor structures. These are organized in r/σ chunks of size σ. Each chunk has σ lists of positions in [1..σ] of lengths (cid:96)1, . . . , (cid:96)σ, which add up to σ. The predecessor structure for the ith list is then built over a sample of (cid:96)i/ logw σ elements, in time O(((cid:96)i/ logw σ) log logw(σ logw(σ)/(cid:96)i)). Adding over all the lists, we obtain O((σ/ logw σ) log logw σ) ⊆ O(σ). The total construction time of this structure is then O(r). In total, the basic structures can be built in O(n log r) time and O(r) space. Of course, if we can use O(n) construction space, then we easily obtain O(n) construction time, by building the suffix array in linear time and then computing the structures from it. In this case the predecessor structure E is implemented as a bitvector, as explained, and LF operates in constant time. 8.3 Fast locating Structure E collects the starts of runs. In Section 3 we build two extended versions that collect starts and ends of runs. The first is a predecessor structure R (Lemma 2), which organizes the O(r) run starts and ends separated by their character, on a universe of size σn. The second uses two predecessor structures (Lemmas 3 and 4), called P + and P − in Lemma 4, which contain the BWT positions at distance at most s from run borders. To build both structures, we simulate a backward traversal of T (using LF -steps from the position of the symbol $) to collect the text positions of all the run starts and ends (for R), or all the elements at distance at most s from a run start or end (for P + and P −). We use predecessor and successor queries on E (the latter are implemented without increasing the space of the predecessor 37 structure) and accesses to L(cid:48) to determine whether the current text position must be stored, and where. The traversal alone takes time O(n log logw(n/r)) for the LF -steps. The predecessor structure R is built in O(r) space and O(r log log(σn/r)) ⊆ O(n log log σ) ⊆ O(n log r) (since σ ≤ r) time. The structures P + and P − contain O(rs) elements in a universe of size n, and thus are built in O(rs) space and time O(rs log log(n/(rs))) ⊆ O(n) (we index up to rs elements but never more than n). Overall, the structure of Theorem 1, enhanced as in Lemma 4, can be built in O(rs) space and O(n log r + n log logw(n/r)) time. If we can use O(n) space for the construction, then the LF - steps can be implemented in constant time and the traversal requires O(n) time. In this case, the structures R, P + and P − can also be built in O(n) time, since the predecessor searches can be implemented with bitvectors. For the structure of Lemma 5 we follow the same procedure, building the structures P + and P −. The classical algorithm to build the base LCP array [64] uses O(n) time and space. Within this space we can also build the predecessor structures in O(n) time, as before. Note that this structure is not needed for Theorem 1, but in later structures. Using those, we will obtain a construction of LCP using less space (see Section 8.6). 8.4 Optimal counting and locating The first step of this construction is to build the compact trie that contains all the distinct substrings of length s of T . All these lie around sampled text positions, so we can simulate a backward traversal of T using E and L(cid:48), as before, while maintaining a window of the last s symbols seen. Whenever we hit a run start or end in L, we collect the next s − 1 symbols as well, forming a substring of length 2s − 1, and from there we restart the process, remembering the last s symbols seen.30 This traversal costs O(n log logw(n/r)) time as before. The memory area where the edges of the compact trie will point is simply the concatenation of all the areas of length 2s − 1 we obtained. We now collect the s substrings of length s from each of these areas, and radix-sort the O(rs) resulting strings of length s, in time O(rs2). After the strings are sorted, if we remove duplicates (getting σ∗ distinct strings) and compute the longest common prefix of the consecutive strings, we easily build the compact trie structure in a single O(σ∗)-time pass. We then assign consecutive mapped values to the σ∗ leaves and also assign the values vmin and vmax to the internal nodes. By recalling the suffix array and text positions each string comes from, we can also assign the values p and SA[p] (or SA∗[p]) to the trie nodes. To finish, we must create the perfect hash functions on the children of each trie node. There are O(rs) children in total but each set stores at most σ children, so the total deterministic time to create the dictionaries is O(rs(log log σ)2). In total, we create the compact trie in time O(n log logw(n/r)+ rs2 + rs(log log σ)2) and space O(rs). The construction of the RLFM-index of T ∗ can still be done within this space, without explicitly generating T ∗, as follows. For each position L[i], the BWT of T , we perform s LF -steps to obtain the metasymbol corresponding to L∗[i], which we use to traverse the compact trie in order to find the mapped symbol L∗[i]. Since the values of L∗ are obtained in increasing order, we can easily compress its runs on the fly, in O(rs) space. The BWT of T ∗ is then obtained in time O(ns log logw(n/r)). We can improve the time by obtaining this BWT run by run instead of symbol by symbol: We 30If we hit other run starts or ends when collecting the s − 1 additional symbols, we form a single longer text area including both text samples; we omit the details. 38 start from each run L[x1, y1] and compute x2 = LF (x1). From it, we find the end y2 of the run x2 belongs in L. The new run is L[x2, y2]. We repeat the process s times until obtaining L[xs, ys]. The next run of L∗ is then L∗[x1, x1 + (ys − xs)]. The computation of yk from xk can be done by finding the predecessor of xk in E and associating with each element in E the length of the run it heads, which is known when building E. In this way, the cost to compute the BWT of T ∗ decreases to O(r∗ log logw(n/r)) ⊆ O(n log logw(n/r)). From the BWT , the other structures of the RLFM-index of T ∗ are built as in Section 8.2, in time O(r∗ log logw(n/r∗)) ⊆ O(n) and space O(r∗) ⊆ O(rs). The array C∗ is also built in O(r∗) ⊆ O(rs) time and O(σ∗) ⊆ O(rs) space. To finish, we need to build the structure of Lemma 4, which as seen in Section 8.3 is built in O(rs) space and O(n log logw(n/r)) time. With s = log logw(σ + n/r), the total construction time is upper bounded by O(n(log logw(n/r) + (log log σ)2)) and the construction space by O(rs) (we limit rs by n because we never have more than n symbols in the trie or runs in L∗). When added to the O(n log r) time to build the BWT of T , the total simplifies to O(n(log r + log logw(n/r))) because σ ≤ r. If we can use O(n) space for the construction, then the LF -steps can be implemented in constant time. We can generate T ∗ explicitly and use linear-time and linear-space suffix array construction algorithms, so all the structures are built in time O(n). The compact trie can be built by pruning at depth s the suffix tree of T , which is built in O(n) time. We still need to build the perfect hash functions for the children, in deterministic time O(rs(log log σ)2). When added to O(n), the total simplifies to O(n + r(log log σ)3). The difference when building the RAM-optimal version is that the compact trie must be changed by the structure of Navarro and Nekrich [91, Sec. 2]. In their structure, they jump by logσ n symbols, whereas we jump by w/ log σ symbols. Their perfect hash functions, involving O(rs) nodes, can be built in time O(rs(log log(rs))2), whereas their weak prefix search structures [5, Thm. 6] are built in expected time O(rsw) for any constant  > 0. For the value of s used in this case, the time can be written as O(rw1+). The construction space stays in O(rs). 8.5 Access to the text The structure of Theorem 4 can be built as follows. We sample the text positions of starts and ends of BWT runs. Each sampled position induces a constant number of half-blocks at each of the O(log(n/r)) levels (there are also r blocks of level 0). For each block or half-block, we must find its primary occurrence. We first find all their rightmost BWT positions with an LF -guided scan of T of time O(n log logw(n/r)), after which we can read each block or half-block backwards in O(log logw(n/r)) time per symbol. For each of them, we follow the method described in Lemma 8 to find its primary occurrence in O(log logw(σ + n/r)) time per symbol, doing the backward search as we extract its symbols backwards too. Since at level l there are O(r) blocks or half-blocks of length O(n/(r · 2l−1)), the total length of all the blocks and half-blocks adds up to O(n), and the total time to find the primary occurrences is O(n log logw(σ + n/r)). We also need to fill in the text at the leaves of the structure. This can be done with an additional traversal of the BWT , filling in the T values (read from L(cid:48)) at the required positions whenever we reach them in the traversal. The extra time for this operation is O(n log logw(n/r)) (we use predecessor and successor queries on E to determine when our BWT position is close enough to a sample so that the current symbol of L(cid:48) must be recorded in the leaf associated with the sample). 39 Therefore, the structure of Theorem 4 is built in O(n log logw(σ + n/r)) time and O(r log(n/r)) working space, once the basic structure of Lemma 1 is built. In case of having O(n) space for construction, we can replace predecessor structures with rank queries on bitvectors of n bits, but we still have the O(log logw σ) time for rank on L(cid:48). Thus the total time is O(n log logw σ). Although this is the most intuitive construction, we will slightly improve it in Section 8.6. 8.6 Suffix array access and byproducts The other structures of Section 5 give access to cells of the suffix array (SA), its inverse (ISA), and the longest common prefix array (LCP ). The structure of Theorem 5 is analogous to that of Theorem 4: it has O(log(n/r)) levels and O(r) blocks or half-blocks of length sl = n/(r · 2l−1) at each level l. However, its domain is the suffix array cells and the way to find a primary occurrence of each block is different. At each level, we start with any interval of length sl and compute LF on its left extreme. This leads to another interval of length sl. We repeat the process until completing the cycle and returning to the initial interval. Along the way, we collect all the intervals that correspond to blocks or half-blocks of this level. Each time the current interval contains or immediately follows a sampled BWT position in E, we make it the primary occurrence of all the blocks or half-blocks collected so far (all those must coincide with the content of the current block or half-block), and reinitialize an empty set of collected blocks. This process takes O(n log logw(n/r)) time for a fixed level. We can perform a single traversal for all the levels simultaneously, storing all the blocks in a dictionary using the left extreme as their search key. As we traverse the BWT , we collect the blocks of all lengths starting at the current position p. Further, we find the successor of p − 1 in E to determine the minimum length of the blocks that cover or follow the nearest sampled position, and all the sufficiently long collected blocks find their primary occurrence starting at p. The queries on E also amount to O(n log logw(n/r)) time. This multi-level process requires a dictionary of all the O(r log(n/r)) blocks and half-blocks. If we implement it as a predecessor structure, it takes O(r log(n/r)) space, it is constructed in O(r log(n/r) log logw(n/r)) time, and answers the O(n) queries in time O(n log logw(n/r)). The collected segments can be stored separated by length, and the O(log(n/r)) active lengths be marked in a small bitvector, where we find the nonempty sets over some length in constant time. We also need to fill the DSA cells of the leaves of the structure. This can be done with an additional traversal of the BWT , filling in the SA values at the required positions whenever we reach them in the traversal. We can then easily convert SA to DSA values in the leaves. This does not add extra time or space, asymptotically. The construction of the structures of Theorem 6 is analogous. This time, the domain of the blocks and half-blocks are the text positions and, instead of traversing with LF , we must use φ. This corresponds to traversing the BWT right to left, keeping track of the corresponding position in T . We can maintain the text position using our basic structure of Lemma 3. Then, if the current text position is i, we can use the predecessor structures on T to find the first sampled position following i − 1, to determine which collected blocks have found their primary occurrence. We can similarly fill the required values DISA by traversing the BWT right-to-left and writing the appropriate ISA values. Therefore, we can build the structures within the same cost as Theorem 5. In both cases, if we have O(n) space available for construction, we can build the structures in O(n) time, since LF can be computed in constant time and all the dictionaries and predecessor 40 structures can be implemented with bitvectors. We can also use these ideas to obtain a slightly faster construction for the structures of Theorem 4, which extract substrings of T . Lemma 20. Let T [i− 1..i] be within a phrase. Then it holds that φ(i− 1) = φ(i)− 1 and T [i− 1] = T [φ(i) − 1]. Proof. The fact that φ(i − 1) = φ(i) − 1 is already proved in Lemma 14. From that proof it also follows that T [i − 1] = BW T [p] = BW T [p − 1] = T [j − 1] = T [φ(i) − 1]. (cid:117)(cid:116) Lemma 21. Let T [i − 1..i + s] be within a phrase, for some 1 < i ≤ n and 0 ≤ s ≤ n − i. Then there exists j (cid:54)= i such that T [j − 1..j + s − 1] = T [i − 1..i + s − 1] and [j − 1..j + s] contains the first position of a phrase. Proof. The proof is analogous to that of Lemma 15. By Lemma 20, it holds that T [i(cid:48)−1..i(cid:48) +s−1] = T [i − 1..i + s − 1], where i(cid:48) = φ(i). If T [i(cid:48) − 1..i(cid:48) + s] contains the first position of a phrase, we are done. Otherwise, we apply Lemma 20 again on [i(cid:48) − 1..i(cid:48) + s], and repeat until we find a range that contains the first position of a phrase. This search eventually terminates because φ is a permutation (cid:117)(cid:116) with a single cycle. We can then find the primary occurrences for all the blocks in Theorem 4 analogously as for DISA (Theorem 6). We traverse T with φ (i.e., we traverse the BWT right to left, using Lemma 3 to compute φ each time). This time we index the blocks and half-blocks using their right extreme, collecting all those that end at the current position i of T . Then, at each position i, we use the predecessor structures on T to find the nearest sampled position preceding i + 1, to determine which collected blocks and half-blocks have found their primary occurrence. We can similarly fill the required values of T with a final traversal of BWT , accessing L(cid:48). Therefore, we can build these structures within the same cost of Theorem 6. Finally, the construction for LCP access in Theorem 7 is a direct combination of Theorem 5 (i.e., SA) and Lemma 5 (i.e., PLCP extension, with s = log(n/r)). In Section 8.3 we saw how to build the latter in O(n) time and space. Within O(n) space, we can also build the structure of Theorem 7 in O(n) time. We can, however, build the structure of Lemma 5 within O(r log(n/r)+rs) space if we first build SA, ISA, and the extraction structure. The classical linear-time algorithm [64] is as follows: we compare T [SA[2]..] with T [SA[1]..] until they differ; the number (cid:96) of matching symbols is LCP [2]. Now we jump to compute LCP [Ψ (2)], where Ψ (p) = ISA[(SA[p] mod n) + 1] is the inverse of LF [53]. Note that LCP [Ψ (2)] = lcp(T [SA[Ψ (2)]..], T [SA[Ψ (2)− 1]..]) = lcp(T [SA[2] + 1..], T [SA[Ψ (2)−1]..]) and, if (cid:96) > 0, this is at least (cid:96)−1 because T [SA[2]+1..] already shares the first (cid:96)− 1 symbols with some lexicographically smaller suffix, T [SA[1] + 1..]. Thus the comparison starts from the position (cid:96) onwards: LCP [Ψ (2)] = (cid:96)− 1 + lcp(T [SA[Ψ (2)] + (cid:96)− 1..], T [SA[Ψ (2)− 1] + (cid:96)− 1..]). This process continues until the cycle Ψ visits all the positions of LCP . We can simulate this algorithm, traversing the whole virtual array LCP [1..n] but writing only the O(rs) cells that are at distance s from a run border. We first build P +, P −, and LCP(cid:48) as for Lemma 5. We then traverse T backwards virtually, using LF , in time O(n log logw(n/r)), spotting the positions in P ± = P + ∪ P −. Say we find p ∈ P ± and the previous p(cid:48) ∈ P ± was found d steps ago. This means that p(cid:48) = Ψ d(p) is the next relevant suffix after p along the LCP algorithm. We store next[f (p)] = (cid:104)p(cid:48), d(cid:105), where next is a table aligned with LCP(cid:48). Once this pass is complete, we simulate the algorithm starting at the last relevant p value we found: we compute LCP [p] = (cid:96) and store LCP(cid:48)[f (p)] = (cid:96). Then, if next[f (p)] = (cid:104)p(cid:48), d(cid:105), we set p = p(cid:48) and (cid:96) = max(1, (cid:96) − d). 41 Along the process, we carry out O(rs) string comparisons for a total of O(n) symbols. Each string comparison takes time O(log(n/r)) in order to compute ISA. We extract the desired substrings of T by chunks of log(n/r) symbols, so that comparing (cid:96) symbols costs O((cid:96) + log(n/r)). Overall, the traversal takes time O(n + rs log(n/r)), plus the O(n log logw(n/r)) time to compute next. Added to the O(n log r + n log logw(n/r)) time needed in Section 8.3 to build the sampling structures, we have a total time of O(n log r + n log logw(n/r) + rs log(n/r)), within O(r log(n/r) + rs) space. For s = log(n/r), as required in Theorem 7, the space is O(r log(n/r)) and the time is in O(n log r + n log logw(n/r)), because O(rs log(n/r)) = O(r log2(n/r)) ⊆ O(n). Finally, to obtain optimal counting and locating in space O(r log(n/r)), we only need to care about the case r ≥ n/ log n, so the allowed space becomes Ω(n log log n) bits. In this case we use an O(n)-bit compressed suffix tree enriched with the structures of Belazzougui and Navarro [12, Lem. 6]. This requires, essentially, the suffix tree topology represented with parentheses, edge lengths (capped to O(log log n) bits), and mmphfs on the first letters of the edges towards the nodes' children. The parentheses and edge lengths are obtained directly left-to-right, with a sequential pass over LCP [64, 106]. If we have O(n log n) bits for the construction (which can be written as O(r log(n/r) log n/ log log n) space), the first letters are obtained directly from the suffix array and the text, all in O(n) time. The construction of the mmphfs on (overall) O(n) elements can be done in O(n) expected time. We need, in addition, the structures to extract substrings of T and entries of SA, and a compact trie on the distinct strings of length log(n/r) in T . With O(n) space, the other structures of Section 8.4 are built in O(n + r(log log σ)2) expected time. 8.7 Suffix tree The suffix tree needs the compressed representations of SA, ISA, and LCP . While these can be built in O(r log(n/r)) space, the suffix tree construction will be dominated by the O(n) space needed to build the RLCFG on DLCP in Lemmas 18 and 19. Therefore, we build SA, ISA, and LCP in O(n) time and space. Starting from the plain array DLCP [1..n], the RLCFG is built in O(log(n/r)) passes of the O(n)-time algorithm of Jez [57]. This includes identifying the repeated pairs, which can also be done in O(n) time via radix sort. The total time is also O(n), because the lengths of the strings compressed in the consecutive passes decrease exponentially. All the fields l, d, p, m, n, etc. stored for the nonterminals are easily computed in O(r log(n/r)) ⊆ O(n) time, that is, O(1) per nonterminal. The arrays L, A, and M are computed in O(r) time and space. The structure RMQM is built in O(r) time and bits [36]. Finally, the structures used for solving PSV(cid:48) and NSV(cid:48) queries on DLCP(cid:48) (construction of the tree for the weighted level-ancestor queries [36], supporting the queries themselves [72], and the simplification for PSV/NSV [37]), as well as the approximate median of the minima [35], are built in O(r) time and space, as shown by their authors. The construction of the predecessor data structures for the weighted level-ancestor queries requires creating several structures with O(r) elements in total, on universes of size n, having at least n/r elements in each structure. The total construction time is then O(r log logw r). Note that this predecessor structure is needed only for PSV(cid:48)/NSV(cid:48), not for PSV/NSV, and thus it can be omitted unless we need the operation LAQS. In addition, the suffix tree requires the construction of the compressed representation of PTDE [37]. This is easily done in O(n) space and time by traversing a classical suffix tree. 42 We note that, with O(n/B +log(n/r)) I/Os (where B is the external memory block size), we can build most of the suffix tree in main memory space O(B + r log(n/r)). The main bottleneck is the algorithm of Jez [57]. The algorithm starts with two sequential passes on DLCP , first identifying runs of equal cells (to collapse them into one symbol using a rule of the form X → Y t) and second collecting all the distinct pairs of consecutive symbols (to create some rules of the form X → Y Z). Both kinds of rules will add up to O(r) per pass, so the distinct pairs can be stored in a balanced tree in main memory using O(r) space. Once the pairs to replace are defined (in O(r) time), the algorithm traverses the text once again, doing the replacements. The new array is of length at most (3/4)n; repeating this process O(log(n/r)) times will yield an array of size O(r), and then we can finish. By streaming the successively smaller versions of the array to external memory, we obtain the promised I/Os and main memory space. The computation time is dominated by the cost of building the structures SA, ISA, and LCP in O(r log(n/r)) space: O(n(log r + log logw(n/r)). The balanced tree operations add another O(n log r) time to this complexity. The other obstacle is the construction of PTDE . This can be done in O(Sort(n)) I/Os, O(n) computation, and O(r) additional main memory space by emulating the linear-time algorithm to build the suffix tree topology from the LCP array [64]. This algorithm traverses LCP left to right, and maintains a stack of the internal nodes in the rightmost path of the suffix tree known up to now, each with its string depth (the stack is easily maintained on disk with O(n/B) I/Os). Each new LCP [p] cell represents a new suffix tree leaf. For each such leaf, we pop nodes from the stack until we find a node whose string depth is ≤ LCP [p]. The sequence of stack sizes is the array TDE . We write those TDE entries to disk as they are generated, left to right, in the format (cid:104)TDE [p], SA[p](cid:105). Once this array is generated on disk, we sort it by the second component, and then the sequence of first components is array PTDE . This array is then read from disk left to right, as we simultaneously fill the run-length compressed bitvector that represents it in O(r) space [37]. The left-to-right traversal of LCP and SA is done in O(n) time by accessing their compressed representation by chunks of log(n/r) cells, using Theorem 5 and Lemma 5 with s = log(n/r). 9 Conclusions We have closed the long-standing problem of efficiently locating the occurrences of a pattern in a text using an index whose space is bounded by the number of equal-letter runs in the Burrows- Wheeler transform (BWT) of the text. The occ occurrences of a pattern P [1..m] in a text T [1..n] over alphabet [1..σ] whose BWT has r runs can be counted in time O(m log logw(σ +n/r)) and then located in O(occ log logw(n/r)) time, on a w-bit RAM machine, using an O(r)-space index. Using space O(r log logw(σ + n/r)), the counting and locating times are reduced to O(m) and O(occ), respectively, which is optimal in the general setting. Further, using O(rw logσ logw(σ + n/r)) space we can also obtain optimal time in the packed setting, replacing O(m) by O((cid:100)m log(σ)/w(cid:101)) in the counting time. Our findings also include O(r log(n/r))-space structures to access consecutive entries of the text, suffix array, inverse suffix array, and longest common prefix array, in optimal time plus a per-query penalty of O(log(n/r)). We upgraded those structures to a full-fledged compressed suffix tree working in O(r log(n/r)) space and carrying out most navigation operations in time O(log(n/r)). All the structures can be built in times ranging from O(n) worst-case to O(nw1+) expected time and O(n) space, and many can be built within the same asymptotic space of the final solution plus a single pass over the text. The number of runs in the BWT is an important measure of the compressibility of highly repetitive text collections, which can be compressed by orders of magnitude by exploiting the 43 repetitiveness. While the first index of this type [79, 80] managed to exploit the BWT runs, it was not able to locate occurrences efficiently. This gave rise to many other indexes based on other measures, like the size of a Lempel-Ziv parse [76], the size of a context-free grammar [68], the size of the smallest compact automaton recognizing the text substrings [18], etc. While the complexities are not always comparable [45], the experimental results show that our proof-of-concept implementation outperforms all the space-efficient alternatives by one or two orders of magnitude in locating time. This work triggered several other lines of research. From the idea of cutting the text into phrases defined by BWT run ends, we showed that a run-length context-free grammar (RLCFG) of size O(r log(n/r)) can be built on the text by using locally consistent parsing [57]. This was generalized to a RLCFG built on top of any bidirectional macro scheme (BMS) [110], which allowed us to prove bounds on the Lempel-Ziv approximation to the optimal BMS, as well as several other related bounds between compressibility measures [45, 93]. Also, the idea that at least one occurrence of any text substring must cross a phrase boundary led Kempa and Prezza [67] to the concept of string attractor, a set of γ text positions with such a property. They prove that string attractors subsume all the other measures of repetitiveness (i.e., γ ≤ min(r, z, g)), and design universal data structures of size O(γ log(n/γ)) for accessing the compressed text, analogous to ours. Navarro and Prezza then extend these ideas to the first self-index on attractors [94], of size O(γ log(n/γ)) ⊆ O(r log(n/r)), yet they do not obtain our optimal query times. On the other hand, some questions remain open, in particular regarding the operations that can be supported within O(r) space. We have shown that this space is not only sufficient to rep- resent the text, but also to efficiently count and locate pattern occurrences. We required, however, O(r log(n/r)) space to provide random access to the text. This raises the question of whether effi- cient random access is possible within O(r) space. For example, recalling Table 1, random access in sublinear time is possible within O(g) space (g being the size of the smallest grammar) but it has only been achieved in O(z log(n/z)) space (z ≤ g being the size of the Lempel-Ziv parse); recall that r is incomparable with g and z. On the other hand, random access is possible within O(γ log(n/γ)) space for any attractor of size γ, as explained. A more specific question, but still intriguing, is whether we can provide random access to the suffix array of the text in O(r) space: note that we can return the cells that result from a pattern search within this space, but accessing an arbitrary cell requires O(r log(n/r)) space, and this translates to the size required by a suffix tree. On the other hand, it seems unlikely that one can provide suffix array or tree functionality within space related to g, z, or γ, since these measures are not related to the structure of the suffix array: this is likely to be a specific advantage of measure r. Finally, we are working on converting our index into an actual software tool for handling large repetitive text collections, and in particular integrating it into widely used bioinformatic software. This entails some further algorithmic challenges. One is to devise practical algorithms for building the BWT of very large repetitive datasets within space bounded by the repetitiveness. While our results in Section 8 are at a theoretical stage, recent work by Boucher et al. [19] may be relevant. Offering efficient techniques to insert new sequences in an existing index are also important in a practical context; there is also some progress in this direction [2]. Another important aspect is, as explained in Section 7, making the index less sensitive to lower repetitiveness scenarios, as it could be the case of indexing short sequences (e.g., sets of reads) or metagenomic collections. We are working on a hybrid with the classic FM-index to handle in different ways the areas with higher and lower repetitiveness. Finally, extending our index to enable full suffix tree functionality will require, 44 despite our theoretical achievements in Section 6, a significant amount of algorithm engineering to obtain good practical space figures. Acknowledgements We thank Ben Langmead for his pointers to the prevalence of the FM-index in bioinformatics software, and Meg Gagie for checking our grammar. References 1. A. Abeliuk, R. C´anovas, and G. Navarro. Practical compressed suffix trees. Algorithms, 6(2):319 -- 351, 2013. 2. H. Bannai, T. Gagie, and T. I. Online LZ77 parsing and matching statistics with RLBWTs. In Proc. 29th Annual Symposium on Combinatorial Pattern Matching (CPM), page article 7, 2018. 3. D. Belazzougui, P. Boldi, R. Pagh, and S. Vigna. Monotone minimal perfect hashing: Searching a sorted table In Proc. 20th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages with O(1) accesses. 785 -- 794, 2009. 4. D. Belazzougui, P. Boldi, R. Pagh, and S. Vigna. Theory and practice of monotone minimal perfect hashing. ACM Journal of Experimental Algorithmics, 16(3):article 2, 2011. 5. D. Belazzougui, P. Boldi, R. Pagh, and S. Vigna. Fast prefix search in little space, with applications. CoRR, abs/1804.04720, 2018. 6. D. Belazzougui, F. C. Botelho, and M. Dietzfelbinger. Hash, displace, and compress. In Proc. 17th Annual European Symposium (ESA), pages 682 -- 693, 2009. 7. D. Belazzougui and F. Cunial. Fast label extraction in the CDAWG. In Proc. 24th International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 10508, pages 161 -- 175, 2017. 8. D. Belazzougui and F. Cunial. Representing the suffix tree with the CDAWG. In Proc. 28th Annual Symposium on Combinatorial Pattern Matching (CPM), LIPIcs 78, pages 7:1 -- 7:13, 2017. 9. D. Belazzougui, F. Cunial, T. Gagie, N. Prezza, and M. Raffinot. Composite repetition-aware data structures. In Proc. 26th Annual Symposium on Combinatorial Pattern Matching (CPM), pages 26 -- 39, 2015. 10. D. Belazzougui, T. Gagie, P. Gawrychowski, J. Karkkainen, A. Ord´onez, S. J. Puglisi, and Y. Tabei. Queries on LZ-bounded encodings. In Proc. 25th Data Compression Conference (DCC), pages 83 -- 92, 2015. 11. D. Belazzougui, T. Gagie, S. Gog, G. Manzini, and J. Sir´en. Relative FM-indexes. In Proc. 21st International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 8799, pages 52 -- 64, 2014. 12. D. Belazzougui and G. Navarro. Alphabet-independent compressed text indexing. ACM Transactions on Algorithms, 10(4):article 23, 2014. 13. D. Belazzougui and G. Navarro. Optimal lower and upper bounds for representing sequences. ACM Transactions on Algorithms, 11(4):article 31, 2015. 14. D. Belazzougui, S. J. Puglisi, and Y. Tabei. Access, rank, select in grammar-compressed strings. In Proc. 23rd Annual European Symposium on Algorithms (ESA), LNCS 9294, pages 142 -- 154, 2015. 15. P. Bille, M. B. Ettienne, I. L. Gørtz, and H. W. Vildhøj. Time-space trade-offs for Lempel-Ziv compressed indexing. Theor. Comput. Sci., 713:66 -- 77, 2018. 16. P. Bille, I. L. Gørtz, B. Sach, and H. W. Vildhøj. Time -- space trade-offs for longest common extensions. Journal of Discrete Algorithms, 25:42 -- 50, 2014. 17. P. Bille, G. M. Landau, R. Raman, K. Sadakane, S. S. Rao, and O. Weimann. Random access to grammar- compressed strings and trees. SIAM Journal on Computing, 44(3):513 -- 539, 2015. 18. A. Blumer, J. Blumer, D. Haussler, R. M. McConnell, and A. Ehrenfeucht. Complete inverted files for efficient text retrieval and analysis. Journal of the ACM, 34(3):578 -- 595, 1987. 19. C. Boucher, T. Gagie, A. Kuhnle, and G. Manzini. Prefix-free parsing for building big BWTs. In Proc. 18th International Workshop on Algorithms in Bioinformatics (WABI), page article 2, 2018. 20. M. Burrows and D. Wheeler. A block sorting lossless data compression algorithm. Technical Report 124, Digital Equipment Corporation, 1994. 21. M. Charikar, E. Lehman, D. Liu, R. Panigrahy, M. Prabhakaran, A. Sahai, and A. Shelat. The smallest grammar problem. IEEE Transactions on Information Theory, 51(7):2554 -- 2576, 2005. 22. S. Chen, E. Verbin, and W. Yu. Data structure lower bounds on random access to grammar-compressed strings. CoRR, abs/1203.1080, 2012. 45 23. A. R. Christiansen and M. B. Ettienne. Compressed indexing with signature grammars. In Proc. 13th Latin American Symposium on Theoretical Informatics (LATIN), LNCS 10807, pages 331 -- 345, 2018. 24. F. Claude, A. Farina, M. Mart´ınez-Prieto, and G. Navarro. Universal indexes for highly repetitive document collections. Information Systems, 61:1 -- 23, 2016. 25. F. Claude and G. Navarro. Self-indexed grammar-based compression. Fundamenta Informaticae, 111(3):313 -- 337, 2010. 26. F. Claude and G. Navarro. Improved grammar-based compressed indexes. In Proc. 19th International Sympo- sium on String Processing and Information Retrieval (SPIRE), LNCS 7608, pages 180 -- 192, 2012. 27. H. H. Do, J. Jansson, K. Sadakane, and W.-K. Sung. Fast relative Lempel-Ziv self-index for similar sequences. Theoretical Computer Science, 532:14 -- 30, 2014. 28. M. Farach-Colton, P. Ferragina, and S. Muthukrishnan. On the sorting-complexity of suffix tree construction. Journal of the ACM, 47(6):987 -- 1011, 2000. 29. A. Farruggia, T. Gagie, G. Navarro, S. J. Puglisi, and J. Sir´en. Relative suffix trees. The Computer Journal, 61(5):773 -- 788, 2018. 30. H. Ferrada, T. Gagie, T. Hirvola, and S. J. Puglisi. Hybrid indexes for repetitive datasets. CoRR, abs/1306.4037, 2013. 31. H. Ferrada, D. Kempa, and S. J. Puglisi. Hybrid indexing revisited. In Proc. 20th Workshop on Algorithm Engineering and Experiments (ALENEX), pages 1 -- 8, 2018. 32. P. Ferragina and G. Manzini. Indexing compressed texts. Journal of the ACM, 52(4):552 -- 581, 2005. 33. P. Ferragina, G. Manzini, V. Makinen, and G. Navarro. Compressed representations of sequences and full-text indexes. ACM Transactions on Algorithms, 3(2):article 20, 2007. 34. J. Fischer. Wee LCP. Information Processing Letters, 110(8-9):317 -- 320, 2010. 35. J. Fischer and V. Heun. Finding range minima in the middle: Approximations and applications. Mathematics in Computer Science, 3(1):17 -- 30, 2010. 36. J. Fischer and V. Heun. Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM Journal on Computing, 40(2):465 -- 492, 2011. 37. J. Fischer, V. Makinen, and G. Navarro. Faster entropy-bounded compressed suffix trees. Theoretical Computer Science, 410(51):5354 -- 5364, 2009. 38. M. L. Fredman, J. Koml´os, and E. Szemer´edi. Storing a sparse table with O(1) worst case access time. Journal of the ACM, 31(3):538 -- 544, 1984. 39. M. L. Fredman and D. E. Willard. Surpassing the information theoretic bound with fusion trees. Journal of Computer and System Sciences, 47(3):424 -- 436, 1993. 40. M. H.-Y. Fritz, R. Leinonen, G. Cochrane, and E. Birney. Efficient storage of high throughput DNA sequencing data using reference-based compression. Genome Research, pages 734 -- 740, 2011. 41. T. Gagie, P. Gawrychowski, J. Karkkainen, Y. Nekrich, and S. J. Puglisi. A faster grammar-based self-index. In Proc. 6th International Conference on Language and Automata Theory and Applications (LATA), LNCS 7183, pages 240 -- 251, 2012. 42. T. Gagie, P Gawrychowski, J. Karkkainen, Y. Nekrich, and S. J. Puglisi. LZ77-based self-indexing with faster pattern matching. In Proc. 11th Latin American Symposium on Theoretical Informatics (LATIN), pages 731 -- 742, 2014. 43. T. Gagie, P. Gawrychowski, and S. J. Puglisi. Approximate pattern matching in LZ77-compressed texts. Journal of Discrete Algorithms, 32:64 -- 68, 2015. 44. T. Gagie, G. Navarro, and N. Prezza. Optimal-time text indexing in bwt-runs bounded space. CoRR, abs/1705.10382v4, 2017. 45. T. Gagie, G. Navarro, and N. Prezza. On the approximation ratio of Lempel-Ziv parsing. In Proc. 13th Latin American Symposium on Theoretical Informatics (LATIN), LNCS 10807, pages 490 -- 503, 2018. 46. T. Gagie, G. Navarro, and N. Prezza. Optimal-time text indexing in BWT-runs bounded space. In Proc. 29th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1459 -- 1477, 2018. 47. P. Gawrychowski and T. Kociumaka. Sparse suffix tree construction in optimal time and space. In Proc. 28th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 425 -- 439, 2017. 48. S. Gog, T. Beller, A. Moffat, and M. Petri. From theory to practice: Plug and play with succinct data structures. In Proc. 13th International Symposium on Experimental Algorithms (SEA), pages 326 -- 337, 2014. 49. S. Gog and E. Ohlebusch. Compressed suffix trees: Efficient computation and storage of LCP-values. ACM Journal of Experimental Algorithmics, 18:article 2.1, 2013. 50. A. Golynski, J. I. Munro, and S. S. Rao. Rank/select operations on large alphabets: A tool for text indexing. In Proc. 17th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 368 -- 373, 2006. 46 51. R. Gonz´alez and G. Navarro. Compressed text indexes with fast locate. In Proc. 18th Annual Symposium on Combinatorial Pattern Matching (CPM), LNCS 4580, pages 216 -- 227, 2007. 52. R. Gonz´alez, G. Navarro, and H. Ferrada. Locally compressed suffix arrays. ACM Journal of Experimental Algorithmics, 19(1):article 1, 2014. 53. R. Grossi and J. S. Vitter. Compressed suffix arrays and suffix trees with applications to text indexing and string matching. SIAM Journal on Computing, 35(2):378 -- 407, 2006. 54. D. Gusfield. Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology. Cam- bridge University Press, 1997. 55. T. I. Longest common extensions with recompression. In Proc. 28th Annual Symposium on Combinatorial Pattern Matching (CPM), LIPIcs 78, pages 18:1 -- 18:15, 2017. 56. S. Janson. Tail bounds for sums of geometric and exponential variables. CoRR, 1709.08157v1, 2017. 57. A. Jez. Approximation of grammar-based compression via recompression. Theoretical Computer Science, 592:115 -- 134, 2015. 58. A. Jez. A really simple approximation of smallest grammar. Theoretical Computer Science, 616:141 -- 150, 2016. 59. J. Karkkainen, D. Kempa, and S. J. Puglisi. Linear time lempel-ziv factorization: Simple, fast, small. In Proc. 24th Annual Symposium on Combinatorial Pattern Matching (CPM), pages 189 -- 200, 2013. 60. J. Karkkainen, G. Manzini, and S. J. Puglisi. Permuted Longest-Common-Prefix array. In Proc. 20th Annual Symposium on Combinatorial Pattern Matching (CPM), pages 181 -- 192, 2009. 61. J. Karkkainen, P. Sanders, and S. Burkhardt. Linear work suffix array construction. Journal of the ACM, 53(6):918 -- 936, 2006. 62. J. Karkkainen and E. Ukkonen. Lempel-Ziv parsing and sublinear-size index structures for string matching. In Proc. 3rd South American Workshop on String Processing (WSP), pages 141 -- 155, 1996. 63. R. M. Karp and M. O. Rabin. Efficient randomized pattern-matching algorithms. IBM Journal of Research and Development, 2:249 -- 260, 1987. 64. T. Kasai, G. Lee, H. Arimura, S. Arikawa, and K. Park. Linear-time longest-common-prefix computation in suffix arrays and its applications. In Proc. 12th Annual Symposium on Combinatorial Pattern Matching (CPM), LNCS 2089, pages 181 -- 192, 2001. 65. B. N. Keel and W. M. Snelling. Comparison of Burrows-Wheeler transform-based mapping algorithms used in high-throughput whole-genome sequencing: Application to Illumina data for livestock genomes. Frontiers in Genetics, 9:article 35, 2018. 66. D. Kempa and D. Kosolobov. LZ-End parsing in compressed space. In Proc. 27th Data Compression Conference (DCC), pages 350 -- 359, 2017. 67. D. Kempa and N. Prezza. At the roots of dictionary compression: String attractors. In Proc. 50th Annual ACM Symposium on the Theory of Computing (STOC), pages 827 -- 840, 2018. 68. J. C. Kieffer and E.-H. Yang. Grammar-based codes: A new class of universal lossless source codes. IEEE Transactions on Information Theory, 46(3):737 -- 754, 2000. 69. D. K. Kim, J. S. Sim, H. Park, and K. Park. Constructing suffix arrays in linear time. Journal of Discrete Algorithms, 3(2-4):126 -- 142, 2005. 70. P. Ko and S. Aluru. Space efficient linear time construction of suffix arrays. Journal of Discrete Algorithms, 3(2-4):143 -- 156, 2005. 71. Y. Kodama, M. Shumway, and R. Leinonen. The sequence read archive: Explosive growth of sequencing data. Nucleic Acids Research, 40(D1):D54 -- D56, 2012. 72. T. Kopelowitz and M. Lewenstein. Dynamic weighted ancestors. In Proc. 18th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 565 -- 574, 2007. 73. S. Kreft and G. Navarro. On compressing and indexing repetitive sequences. Theoretical Computer Science, 483:115 -- 133, 2013. 74. S. Kuruppu, S. J. Puglisi, and J. Zobel. Relative Lempel-Ziv compression of genomes for large-scale storage and retrieval. In Proc. 17th International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 6393, pages 201 -- 206, 2010. 75. J. Larsson and A. Moffat. Off-line dictionary-based compression. Proceedings of the IEEE, 88(11):1722 -- 1732, 2000. 76. A. Lempel and J. Ziv. On the complexity of finite sequences. IEEE Transactions on Information Theory, 22(1):75 -- 81, 1976. 77. V. Makinen, D. Belazzougui, F. Cunial, and A. I. Tomescu. Genome-Scale Algorithm Design. Cambridge University Press, 2015. 78. V. Makinen and G. Navarro. Succinct suffix arrays based on run-length encoding. Nordic Journal of Computing, 12(1):40 -- 66, 2005. 47 79. V. Makinen, G. Navarro, J. Sir´en, and N. Valimaki. Storage and retrieval of individual genomes. In Proc. 13th Annual International Conference on Computational Molecular Biology (RECOMB), LNCS 5541, pages 121 -- 137, 2009. 80. V. Makinen, G. Navarro, J. Sir´en, and N. Valimaki. Storage and retrieval of highly repetitive sequence collections. Journal of Computational Biology, 17(3):281 -- 308, 2010. 81. U. Manber and G. Myers. Suffix arrays: a new method for on-line string searches. SIAM Journal on Computing, 22(5):935 -- 948, 1993. 82. G. Manzini. An analysis of the Burrows-Wheeler transform. Journal of the ACM, 48(3):407 -- 430, 2001. 83. E. McCreight. A space-economical suffix tree construction algorithm. Journal of the ACM, 23(2):262 -- 272, 1976. 84. D. Morrison. PATRICIA -- practical algorithm to retrieve information coded in alphanumeric. Journal of the ACM, 15(4):514 -- 534, 1968. 85. J. I. Munro, G. Navarro, and Y. Nekrich. Space-efficient construction of compressed indexes in deterministic linear time. In Proc. 28th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 408 -- 424, 2017. 86. J. C. Na, H. Park, M. Crochemore, J. Holub, C. S. Iliopoulos, L. Mouchard, and K. Park. Suffix tree of align- ment: An efficient index for similar data. In Proc. 24th International Workshop on Combinatorial Algorithms (IWOCA), LNCS 8288, pages 337 -- 348, 2013. 87. J. C. Na, H. Park, S. Lee, M. Hong, T. Lecroq, L. Mouchard, and K. Park. Suffix array of alignment: A practical index for similar data. In Proc. 20th International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 8214, pages 243 -- 254, 2013. 88. G. Navarro. A self-index on block trees. In Proc. 24th International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 10508, pages 278 -- 289, 2017. 89. G. Navarro. Document listing on repetitive collections with guaranteed performance. CoRR, abs/1707.06374, 2018. 90. G. Navarro and V. Makinen. Compressed full-text indexes. ACM Computing Surveys, 39(1):article 2, 2007. 91. G. Navarro and Y. Nekrich. Time-optimal top-k document retrieval. SIAM Journal on Computing, 46(1):89 -- 113, 2017. 92. G. Navarro and A. Ord´onez. Faster compressed suffix trees for repetitive text collections. Journal of Experimental Algorithmics, 21(1):article 1.8, 2016. 93. G. Navarro and N. Prezza. On the approximation ratio of greedy parsings. CoRR, abs/1803.09517, 2018. 94. G. Navarro and N. Prezza. Universal compressed text indexing. Theoretical Computer Science, 2018. To appear. Available at https://arxiv.org/abs/1803.09520. 95. G. Navarro and K. Sadakane. Fully-functional static and dynamic succinct trees. ACM Transactions on Algo- rithms, 10(3):article 16, 2014. 96. Gonzalo Navarro. Compact Data Structures -- A practical approach. Cambridge University Press, 2016. 97. T. Nishimoto, T. I, S. Inenaga, H. Bannai, and M. Takeda. Dynamic index, LZ factorization, and LCE queries in compressed space. CoRR, abs/1504.06954, 2015. 98. E. Ohlebusch. Bioinformatics Algorithms: Sequence Analysis, Genome Rearrangements, and Phylogenetic Re- construction. Oldenbusch Verlag, 2013. 99. T. Ohno, Y. Takabatake, T. I, and H. Sakamoto. A faster implementation of online run-length Burrows-Wheeler Transform. CoRR, abs/1704.05233, 2017. 100. A. Policriti and N. Prezza. LZ77 computation based on the run-length encoded BWT. Algorithmica, 80(7):1986 -- 2011, 2018. 101. N. Prezza. Compressed Computation for Text Indexing. PhD thesis, University of Udine, 2016. 102. M. Przeworski, R. R. Hudson, and A. Di Rienzo. Adjusting the focus on human variation. Trends in Genetics, 16(7):296 -- 302, 2000. 103. L. M. S. Russo, G. Navarro, and A. Oliveira. Fully-compressed suffix trees. ACM Transactions on Algorithms, 7(4):article 53, 2011. 104. M. Ruzi´c. Constructing efficient dictionaries in close to sorting time. In Proc. 35th International Colloquium on Automata, Languages and Programming (ICALP), pages 84 -- 95, 2008. 105. W. Rytter. Application of Lempel-Ziv factorization to the approximation of grammar-based compression. Theoretical Computer Science, 302(1-3):211 -- 222, 2003. 106. K. Sadakane. Compressed suffix trees with full functionality. Theory of Computing Systems, 41(4):589 -- 607, 2007. 107. M. C. Schatz and B. Langmead. The DNA data deluge: Fast, efficient genome sequencing machines are spewing out more data than geneticists can analyze. IEEE Spectrum, 50(7):26 -- 33, 2013. 48 108. J. Sir´en, N. Valimaki, V. Makinen, and G. Navarro. Run-length compressed indexes are superior for highly repetitive sequence collections. In Proc. 15th International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 5280, pages 164 -- 175, 2008. 109. Z. D. Sthephens, S. Y. Lee, F. Faghri, R. H. Campbell, Z. Chenxiang, M. J. Efron, R. Iyer, S. Sinha, and G. E. Robinson. Big data: Astronomical or genomical? PLoS Biology, 17(7):e1002195, 2015. 110. J. A. Storer and T. G. Szymanski. Data compression via textual substitution. Journal of the ACM, 29(4):928 -- 951, 1982. 111. T. Takagi, K. Goto, Y. Fujishige, S. Inenaga, and H. Arimura. Linear-size CDAWG: New repetition-aware indexing and grammar compression. CoRR, abs/1705.09779, 2017. 112. E. Ukkonen. On-line construction of suffix trees. Algorithmica, 14(3):249 -- 260, 1995. 113. E. Verbin and W. Yu. Data structure lower bounds on random access to grammar-compressed strings. In Proc. 24th Annual Symposium on Combinatorial Pattern Matching (CPM), LNCS 7922, pages 247 -- 258, 2013. 114. P. Weiner. Linear Pattern Matching Algorithms. In Proc. 14th IEEE Symp. on Switching and Automata Theory (FOCS), pages 1 -- 11, 1973. 115. D. E. Willard. Examining computational geometry, van Emde Boas trees, and hashing from the perspective of the fusion tree. SIAM Journal on Computing, 29(3):1030 -- 1049, 2000. 49
1609.07780
1
1609
2016-09-25T18:03:00
Linear kernels for edge deletion problems to immersion-closed graph classes
[ "cs.DS", "cs.DM" ]
Suppose $\mathcal{F}$ is a finite family of graphs. We consider the following meta-problem, called $\mathcal{F}$-Immersion Deletion: given a graph $G$ and integer $k$, decide whether the deletion of at most $k$ edges of $G$ can result in a graph that does not contain any graph from $\mathcal{F}$ as an immersion. This problem is a close relative of the $\mathcal{F}$-Minor Deletion problem studied by Fomin et al. [FOCS 2012], where one deletes vertices in order to remove all minor models of graphs from $\mathcal{F}$. We prove that whenever all graphs from $\mathcal{F}$ are connected and at least one graph of $\mathcal{F}$ is planar and subcubic, then the $\mathcal{F}$-Immersion Deletion problem admits: a constant-factor approximation algorithm running in time $O(m^3 \cdot n^3 \cdot \log m)$; a linear kernel that can be computed in time $O(m^4 \cdot n^3 \cdot \log m)$; and a $O(2^{O(k)} + m^4 \cdot n^3 \cdot \log m)$-time fixed-parameter algorithm, where $n,m$ count the vertices and edges of the input graph. These results mirror the findings of Fomin et al. [FOCS 2012], who obtained a similar set of algorithmic results for $\mathcal{F}$-Minor Deletion, under the assumption that at least one graph from $\mathcal{F}$ is planar. An important difference is that we are able to obtain a linear kernel for $\mathcal{F}$-Immersion Deletion, while the exponent of the kernel of Fomin et al. for $\mathcal{F}$-Minor Deletion depends heavily on the family $\mathcal{F}$. In fact, this dependence is unavoidable under plausible complexity assumptions, as proven by Giannopoulou et al. [ICALP 2015]. This reveals that the kernelization complexity of $\mathcal{F}$-Immersion Deletion is quite different than that of $\mathcal{F}$-Minor Deletion.
cs.DS
cs
Linear kernels for edge deletion problems to immersion-closed graph classes Archontia C. Giannopouloua,b Micha(cid:32)l Pilipczukc,d Jean-Florent Raymondc,e,f Dimitrios M. Thilikose,g Marcin Wrochnac,d August 8, 2018 Abstract Suppose F is a finite family of graphs. We consider the following meta-problem, called F- Immersion Deletion: given a graph G and integer k, decide whether the deletion of at most k edges of G can result in a graph that does not contain any graph from F as an immersion. This problem is a close relative of the F-Minor Deletion problem studied by Fomin et al. [FOCS 2012], where one deletes vertices in order to remove all minor models of graphs from F. We prove that whenever all graphs from F are connected and at least one graph of F is planar and subcubic, then the F-Immersion Deletion problem admits: • a constant-factor approximation algorithm running in time O(m3 · n3 · log m); • a linear kernel that can be computed in time O(m4 · n3 · log m); and • a O(2O(k) + m4 · n3 · log m)-time fixed-parameter algorithm, where n, m count the vertices and edges of the input graph. These results mirror the findings of Fomin et al. [FOCS 2012], who obtained a similar set of algorithmic results for F-Minor Deletion, under the assumption that at least one graph from F is planar. An important difference is that we are able to obtain a linear kernel for F-Immersion Deletion, while the exponent of the kernel of Fomin et al. for F-Minor Deletion depends heavily on the family F. In fact, this dependence is unavoidable under plausible complexity assumptions, as proven by Giannopoulou et al. [ICALP 2015]. This reveals that the kernelization complexity of F-Immersion Deletion is quite different than that of F-Minor Deletion. Introduction 1 On the F-Minor Deletion problem. Given an class of graphs G, we denote by obsmn(G) the minor-obstruction set of G, that is the set of minor-minimal graphs that do not belong in G. Let us fix some finite family of graphs F. A graph G is called F-minor-free if G does not contain any graph from F as a minor. The celebrated Graph Minors Theorem of Robertson and Seymour [38] aTechnische Universitat Berlin, Berlin, Germany. bThe research of this author has been supported by the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (ERC consolidator grant DISTRUCT, agreement No 648527) and by the Warsaw Center of Mathematics and Computer Science. cInstitute of Informatics, University of Warsaw, Poland. dSupported by the Polish National Science Center grant SONATA DEC-2013/11/D/ST6/03073. eAlGCo project team, CNRS, LIRMM, Montpellier, France. fSupported by the Polish National Science Centre grant PRELUDIUM DEC-2013/11/N/ST6/02706. gDepartment of Mathematics, National and Kapodistrian University of Athens, Greece. 1 implies that for every family of graphs Π that is closed under taking minors, the set FG = obsmn(G) is finite. In other words, G is characterized by the minor-exclusion of finite set of graphs; that is G is exactly the class of FG-minor-free graphs. Hence, studying the classes of F-minor-free graphs for finite families F is the same as studying general minor-closed properties of graphs. Fomin et al. [19] performed an in-depth study of the following parameterized1 problem, named F-Minor Deletion2: Given a graph G and an integer parameter k, decide whether it is possible to remove at most k vertices from G to obtain an F-minor-free graph. By considering different families F, the F-Minor Deletion problem generalizes a number of concrete problems of prime importance in parameterized complexity, such as Vertex Cover, Feedback Vertex Set, or Planarization. It is easy to see that, for every fixed k, the graph class Gmn k,F , consisting of the graphs in the YES-instances (G, k) of F-Minor Deletion, is closed under taking of minors. We define Omn is finite and the meta-algorithmic consequences of the Graph Minors series of Robertson and Seymour [36, 38], it follows (non-constructively) that F-Minor Deletion admits an FPT-algorithm. The optimization of the running time of such FPT-algorithms for several instantiations of F has been an interesting project in parameterized algorithm design and so far it has been focused on problems generated by minor-closed graph classes. The goal of Fomin et al. [19] was to obtain results of general nature for F-Minor Deletion, which would explain why many concrete problems captured as its subcases are efficiently solvable using parameterized algorithms and kernelization. This has been achieved under the assumption that F contains at least one planar graph. More precisely, for any class F that contains at least one planar graph, the work of Fomin et al. [19] gives the following: (i) a randomized constant-factor approximation running in time O(nm); k,F ). By the fact that Omn k = obsmn(Gmn k (ii) a polynomial kernel for the problem; that is, a polynomial-time algorithm that, given an instance (G, k) of F-Minor Deletion, outputs an equivalent instance (G(cid:48), k(cid:48)) with k(cid:48) ≤ k and G(cid:48) ≤ O(kc), for some constant c that depends on F; (iii) an FPT-algorithm solving F-Minor Deletion in time 2O(k) · n2. (iv) a proof that every graph in Omn k has kcF vertices for some constant cF that depends (non- constructively) on F. We remark that, for the FPT-algorithm, the original paper of Fomin et al. [19] needs one more technical assumption, namely that all the graphs from F are connected. The fact that this condition can be lifted was proved in a subsequent work of Kim et al. [30]. The assumption that F contains at least one planar graph is crucial for the approach of Fomin et al. [19]. Namely, from the Excluded Grid Minor Theorem of Robertson and Seymour [37] it follows that for such families F, F-minor-free graphs have treewidth bounded by a constant depending only of F. Therefore, a YES-instance of F-Minor Deletion roughly has to look like a constant-treewidth graph plus k additional vertices that can have arbitrary connections. Having exposed this structure, Fomin et al. [19] apply protrusion-based techniques that originate in the work on meta-kernelization [4, 20]. Roughly speaking, the idea is to identify large parts of the graphs that have constant treewidth and a small interface towards the rest of the graph (so-called 1A parameterized problem can be seen as a subset of Σ∗ × N where its instances are pairs (x, k) ∈ Σ∗ × N. For graph problems, the string x usually encodes a graph G. A parameterized problem admits an FPT-algorithm, or, equivalently, belongs in the parameterized complexity class FPT, if it can be solved by an f (k) · xO(1) step algorithm. See [13, 17, 35] for more on parameterized algorithms and complexity. 2Fomin et al. use the name F-Deletion, but we choose to use the word "minor" explicitly to distinguish it from immersion-related problems that we consider in this paper. 2 protrusions), which can be replaced by smaller gadgets with the same combinatorial behaviour. Such preprocessing based on protrusion replacement is the base of all three aforementioned results for F-Minor Deletion. In the absence of a constant bound on the treewidth of an F-minor-free graph, the technique breaks completely. In fact, the kernelization complexity of Planarization, that is, F-Minor Deletion for F = {K5, K3,3}, is a notorious open problem. An interesting aspect of the work of Fomin et al. [19] is that the exponent of the polynomial bound on the size of the kernel for F-Minor Deletion grows quite rapidly with the family F. Recently, it has been shown by Giannopoulou et al. [23] that in general this growth is probably unavoidable: For every constant η, the Treewidth-η Deletion problem (delete k vertices to obtain a graph of treewidth at most η) has no kernel with O(kη/4−) vertices for any  > 0, unless NP ⊆ coNP/poly. Since graphs of treewidth η can be characterized by a finite set of forbidden minors Fη, at least one of which is planar, this refutes the hypothesis that all F-Minor Deletion problems admit polynomial kernels with a uniform bound on the degree of the polynomial. However, as shown by Giannopoulou et al. [23], such uniform kernelization can be achieved for some specific problem families, like vertex deletion to graphs of constant tree-depth. Immersion problems. Recall that a graph H can be immersed into a graph G (or that H is an immersion of G) if there is a mapping from H to G that maps vertices of H to pairwise different vertices of G and edges of H to pairwise edge-disjoint paths connecting the images of the respective endpoints3. Such a mapping is called an immersion model. Just like the minor relation, the immersion relation imposes a partial order on the class of graphs. Alongside with the minor order, Robertson and Seymour [39] proved that graphs are also well-quasi-ordered under the immersion order, i.e., every set of graphs that are pair-wise non-comparable with respect to the immersion relation is finite. This implies that for every class of graphs G that is closed under taking immersions the set obsim(G), containing the immersion minimal graphs that do not belong in G, is finite (we call obsimG immersion obstruction set of G). Therefore G can be characterized by a finite set of forbidden immersions. The general intuition is that immersion is a containment relation on graphs that corresponds to edge cuts, whereas the minor relation corresponds to vertex cuts. Also, the natural setting for immersions is the setting of multigraphs. Hence, from now on all the graphs considered in this paper may have parallel edges connecting the same pair of endpoints. Recently, there has been a growing interest in immersion-related problems [2, 6, 14 -- 16, 22, 24 -- 26, 29, 33, 42] both from the combinatorial and the algorithmic point of view. Most importantly for us, Wollan proved in [42] an analog of the Excluded Grid Minor Theorem, which relates the size of the largest wall graph that is contained in a graph as an immersion with a new graph parameter called tree-cut width. By a subcubic graph we mean a graph of maximum degree at most 3. The following theorem follows from the work of Wollan [42] and summarizes the conclusions of this work that are important for us. Theorem 1 ([24]). For every graph H that is planar and subcubic there exists a constant aH , such that every graph that does not contain H as an immersion has tree-cut width bounded by aH . In other words, for any family F of graphs that contains some planar subcubic graph, the tree-cut width of F-immersion-free graphs is bounded by a universal constant depending on F only. In Section 2 we discuss the precise definition of tree-cut width and how exactly Theorem 1 follows from the work of Wollan [42]. Also, note that if a family of graphs F does not contain any planar subcubic graph, then there is no uniform bound on the tree-cut width of F-immersion-free 3In this paper we consider weak immersions only, as opposed to strong immersions where the paths are forbidden to traverse images of vertices other than the endpoints of the corresponding edge. 3 graphs. Indeed, wall graphs are then F-immersion-free, because all their immersions are planar and subcubic, and they have unbounded tree-cut width. After the introduction of tree-cut width by Wollan [42], the new parameter gathered substantial interest from the algorithmic and combinatorial community [22, 24, 29, 33]. It seems that tree-cut width serves the same role for immersion-related problems as treewidth serves for minor-related problems and, in a sense, it can be seen as an "edge-analog" of treewidth. In particular, given the tree-cut width bound of Theorem 1 and the general approach of Fomin et al. [19] to F-Minor Deletion, it is natural to ask whether the same kind of results can be obtained for immersions where the considered modification is edge removal instead of vertex removal. More precisely, fix a finite family of graphs F containing some planar subcubic graph and consider the following F-Immersion Deletion problem: given a graph G and an integer k, determine whether it is possible to delete at most k edges of G in order to obtain a graph that does not admit any graph from F as an immersion. k,F consisting of the graphs in the YES-instances (G, k) of F-Immersion Deletion is closed under taking of immersions4, therefore Oim k,F ) is a finite set, by the well-quasi-ordering of graphs under immersions [39]. Together with the immersion-testing algorithm of Grohe et al. [27], this implies that F-Immersion Deletion admits (non-constructively) an FPT-algorithm. This naturally induces the parallel project of optimizing the performance of such FPT-algorithms for several instantiations of F. More concretely, is it possible to extend the general framework of Fomin et al. [19] to obtain efficient approximation, kernelization, and FPT algorithms also for F-Immersion Deletion? Theorem 1 suggests that the suitable analog of the assumption from the minor setting that F contains a planar graph should be the assumption that at least one graph from F is planar and subcubic. Parallel to the case of F-Minor Deletion, for every fixed k, the graph class Gim k = obsim(Gim Our results. In this work we give a definitive positive answer to this question. The following two theorems gather our main results; for a graph G, by G and (cid:107)G(cid:107) we denote the cardinalities of the vertex and edge sets of G, respectively. Theorem 2 (Constant factor approximation). Suppose F is a finite family of connected graphs and at least one member of F is planar and subcubic. Then there exists an algorithm that, given a graph G, runs in time O((cid:107)G(cid:107)3 log (cid:107)G(cid:107) · G3) and outputs a subset of edges F ⊆ E(G) such that G − F is F-immersion-free and the size of F is at most capx times larger than the optimum size of a subset of edges with this property, for some constant capx depending on F only. In Section 8 (Conclusions) we comment on how the constant-factor approximation can be generalized to work for F containing disconnected graphs as well, using the approach of Fomin et al. [18, 19]. Theorem 3 (Linear kernelization and obstructions). Suppose F is a finite family of connected graphs and at least one member of F is planar and subcubic. Then there exists an algorithm that, given an instance (G, k) of F-Immersion Deletion, runs in time O((cid:107)G(cid:107)4 log (cid:107)G(cid:107) · G3) and outputs an equivalent instance (G(cid:48), k) with (cid:107)G(cid:48)(cid:107) ≤ cker · k, for some constant cker depending on F only. Moreover, there exists a constant cF (non-constructively depending on F) such that every graph H in Oim k has at most cF · k edges. 4Notice that if we consider deletion of vertices instead of edges, then the graph class Gim is not closed under taking immersions (for example, in a star on 7 vertices with duplicated edges, deleting one vertex makes it K3-immersion-free, but this 'duplicated' star immerses 2K3, which has no such vertex). This is the main reason why we believe that edge deletion gives a more suitable counterpart to F-Minor Deletion for the case of immersions. k 4 Thus, Theorems 2 and 3 mirror the approximation and kernelization results and the obstruction bounds of Fomin et al. [19]. However, this mirroring is not exact as we even show that, in the immersion setting, a stronger kernelization procedure can be designed. Namely, the size of the kernel given by Theorem 3 is linear, with only the multiplicative constant depending on the family F, whereas in the minor setting, the exponent of the polynomial bound on the kernel size provably must depend on F (under plausible complexity assumptions). This shows that the immersion and minor settings behave quite differently and in fact stronger results can be obtained in the immersion setting. Observe that using Theorem 3 it is trivial to obtain a decision algorithm for F-Immersion fpt +(cid:107)G(cid:107)4 log (cid:107)G(cid:107)·G3) for some constant cfpt depending on F only: Deletion working in time O(ck one simply computes the kernel with a linear number of edges and checks all the subsets of edges of size k. Our techniques. Our approach to proving Theorems 2 and 3 roughly follows the general frame- work of protrusion replacement of Fomin et al. [19] (see also [4, 5]). We first define protrusions suited for the problem of our interest. In fact, our protrusions can be seen as the edge-analog of those introduced in [19] (as in [7]). A protrusion for us is simply a vertex subset X that induces an F-immersion-free subgraph (which hence has constant tree-cut width, by Theorem 1), and has a constant number of edges to the rest of the graph. When a large protrusion is localized, it can be replaced by a smaller gadget similarly as in the work of Fomin et al. [19]. However, we need to design a new algorithm for searching for large protrusions, mostly in order to meet the condition that the exponent of the polynomial running time of the algorithm does not depend on F. For this, we employ the important cuts technique of Marx [32] and the randomized contractions technique of Chitnis et al. [9]. All of these yield an algorithm that exhaustively reduces all large protrusions. Unfortunately, exhaustive protrusion replacement is still not sufficient for a linear kernel. However, we prove that in the absence of large reducible protrusions, the only remaining obstacles are large groups of parallel edges between the same two endpoints (called thetas), and, more generally, large "bouquets" of constant-size graphs attached to the same pair of vertices. Without these, the graph is already bounded linearly in terms of the optimum solution size. The approximation algorithm can thus delete all edges except for the copies included in bouquets and thetas, reducing the optimum solution size by a constant fraction of the deleted set. It then exhaustively reduces protrusions in the remaining edges, and repeats the process until the graph is F-immersion-free. To obtain a linear kernel we need more work, as we do not know how to reduce bouquets and thetas directly. Instead, we apply the following strategy based on the idea of amortization. After reducing exhaustively all larger protrusions, we compute a constant-factor approximate solution Fapx. Then we analyze the structure of the graph G − Fapx, which has constant tree-cut width. It appears that every bouquet and theta in G can be reduced up to size bounded linearly in the number of solution edges Fapx that "affect" it. After applying this reduction, we can still have large bouquets and thetas in the graph, but this happens only when they are affected by a large number of edges of Fapx. However, every edge of Fapx can affect only a constant number of bouquets and thetas and hence a simple amortization arguments shows that the total size of bouquets and theta is linear in Fapx, so also linear in terms of the optimum. We remark that this part of the reasoning and in particular the amortization argument explained above, are fully new contributions of this work. These arguments deviate significantly from those needed by Fomin et al. [19], because they were aiming at a weaker goal of obtaining a polynomial kernel, instead of linear. Also, we remark that, contrary to the work of Fomin et al. [19], all our algorithms are deterministic. For the second part of Theorem 3, we show that protrusions replacements can be done in 5 a way that the resulting graph is an immersion of the original one. This implies that, in the equivalent instance (G(cid:48), k) produced by our kernelization algorithm, the graph G(cid:48) is an immersion of G. Therefore if G is an immersion-obstruction of Gim k−1,F , then it should already have a linear, on k, number if edges (see Section 7). Application: immersion-closed parameters. Before we proceed to the proofs of Theorems 2 and 3, we would like to highlight one particular meta- algorithmic application of our results which was our original motivation. Suppose p is a graph parameter, that is, a function that maps graphs to nonnegative integers. We shall say that p is closed under immersion if whenever a graph H is an immersion of another graph G, then p(H) ≤ p(G). Furthermore, p is closed under disjoint union if p(G1 (cid:93) G2) = max(p(G1), p(G2)), for any two graphs G1 and G2; here, (cid:93) denotes the disjoint union of two graphs. Finally, p is large on walls if the set of integers {p(Wn,n)}n∈N is infinite, where Wn,n is the n × n wall, depicted in Figure 1, for n = 4. The following proposition follows easily from Theorem 1 and the fact that the immersion order is a well-quasi-order. Figure 1: W4,4. Proposition 4. Let p be a graph parameter that is closed under immersion and under disjoint union and moreover is large on walls. Then for every r ∈ N there exists a finite family of graphs Fp,r with the following properties: (a) every graph from Fp,r is connected; (b) Fp,r contains at least one planar subcubic graph; and (c) for every graph G, we have that p(G) ≤ r if and only if G is Fp,r-immersion-free. Proof. Denote by Gp,r the class of all graphs G for which p(G) ≤ r. Since p is immersion-closed, Gp,r is closed under taking immersions. Since the immersion order is a well-quasi-order on graphs, we infer that there is a finite family Fp,r of graphs such that a graph G belongs to Gp,r if and only if G is Fp,r-immersion-free. Moreover, we can assume that Fp,r is minimal in the following sense: for each H ∈ Fp,r and each H(cid:48) that can be immersed in H and is not isomorphic to H, we have that H(cid:48) ∈ Gp,r; equivalently, p(H(cid:48)) ≤ r. We need to argue that every member of Fp,r is connected and that Fp,r contains a planar subcubic graph. For the first check, suppose that there is some disconnected graph H in Fp,r. Then H has two proper subgraphs H1 and H2 such that H = H1 (cid:93) H2. Since H1, H2 are subgraphs of H, they can, in particular, be immersed in H. Both of them are strictly smaller than H, so we infer that p(H1) ≤ r and p(H2) ≤ r. As p is closed under disjoint union, we infer that p(H) = p(H1 (cid:93) H2) = max(p(H1), p(H2)) ≤ r. This is a contradiction to the fact that H /∈ Gp,r. For the second check, since p is unbounded on walls, there is some integer n such that p(Wn,n) > r. Consequently, Wn,n /∈ Gp,r, so Wn,n contains some graph H from Fp,r as an immersion. It can be easily seen that planar subcubic graphs are closed under taking immersions, so since Wn,n is planar and subcubic, we infer that H is also planar and subcubic. For a parameter p and a constant r, define the p-at-most-r Edge Deletion problem as follows: given a graph G and an integer k, determine whether at most k edges can be deleted from G to obtain a graph with the value of p at most r. We also define the associated parameter pr such that pr(G) = min{k ∃S ⊆ E(G) : S ≤ k ∧ p(G \ S) ≤ r}. 6 We also define Gk,pr = {G pr(G) ≤ k} By combining Proposition 4 with Theorems 2 and 3 we obtain the following corollary. Corollary 5. Let p be a graph parameter that is closed under immersion and under disjoint union and moreover is large on the class of walls5. Then, for every constant r, the p-at-most-r Edge Deletion problem admits a constant-factor approximation and a linear kernel. Moreover, there is a constant cr, depending (non-constructively) on r, such that for every k, every graph H in obsim(Gk,pr ) has at most cr · k edges. Natural immersion-closed parameters that satisfy the prerequisites of Corollary 5 include cutwidth, carving width, tree-cut width, and edge ranking; see e.g. [28, 31, 40 -- 42] for more details on these parameters. Corollary 5 mirrors the corollary given by Fomin et al. [19] for the Treewidth-η Deletion problem, for which their results imply the existence of a constant-factor approximation, a polynomial-kernel, a polynomial bound for the corresponding minor-obstruction set obsmn(Gk,twη ), and a single-exponential FPT algorithm, for every constant η. Organization of the paper. In Section 2 we introduce notation, recall known definitions and facts, and prove some easy observations of general usage. In Section 3 we provide several adjustments of the notions of tree-cut decompositions and tree-cut width. In particular, we provide a simpler definition of tree-cut width that we use throughout the paper, and show that an optimum-width tree- cut decomposition may be assumed to have some additional, useful properties. In Section 4 we discuss protrusions: finding them and replacing them. Section 5 contains the proof of Theorem 2 (constant factor approximation), while Section 6 contains the proof of Theorem 3 (linear kernelization). Section 7 is dedicated to the linear bound on the size of obstructions. We conclude with some finishing remarks in Section 8. 2 Preliminaries For a positive integer p, we denote [p] = {1, 2, . . . , p}. Graphs. In this work, all graphs are multigraphs without loops. That is, a graph G is a pair (V (G), E(G)), where V (G) is the vertex set and E(G) is a multiset of edges. An edge connects a pair of different vertices, called endpoints; we write uv ∈ E(G) for an edge with endpoints u, v ∈ V (G). Note that there might be several edges (called parallel edges) between two vertices. An edge is incident to a vertex if that vertex is one of its two endpoints. We write G for V (G) and (cid:107)G(cid:107) for E(G) (counting edges with multiplicities). For a subset of vertices X ⊆ V (G), G[X] is the subgraph induced by X. For a subset X ⊆ V (G) of vertices, we write G − X for the induced subgraph G[V (G) \ X]. For a subset F ⊆ E(G) of edges, we write G − F for the graph obtained from G by removing all edges of G, with V (G − F ) = V (G) and E(G − F ) = E(G) \ F . For two subsets X, Y ⊆ V (G), not necessarily disjoint, EG(X, Y ) denotes the set of all edges xy ∈ E(G) for which x ∈ X and y ∈ Y . The boundary of X is δG(X) = EG(X, V (G)\ X), while the set of edges incident to X is EG(X, V (G)). For v ∈ V (G), the degree of v is degG(v) = δG({v}). We also define the set of neighbors of v: NG(v) = {u ∈ V (G) : uv ∈ E(G)}. By NG(X) we denote the open neighborhood of X, that is, the set of all vertices outside X that have a neighbor in X. We drop the subscript G when it is clear from the context. A graph is subcubic if degG(v) ≤ 3 for every v ∈ V (G). 5A graph parameter p is large on a graph class C if {p(G) G ∈ C} is not a bounded set. 7 Trees. A forest is a graph where every connected component is a tree. For a forest T and an edge uv ∈ E(T ), we denote by Tuv and Tvu the components of T − uv containing u and v, respectively. Let T be a rooted tree. For every node t ∈ V (T ), we denote by π(t) its unique parent on the tree T . A node t(cid:48) is a sibling of t if t (cid:54)= t(cid:48) and t and t(cid:48) have the same parent. of X such that(cid:83)k T1, . . . , Tr are the connected components of T , then(cid:83) Tree-cut width. A near-partition of a set X is a family of (possibly empty) subsets X1, . . . , Xk A tree-cut decomposition of a graph G is a pair T = (T,X ) such that T is a forest and X = {Xt : t ∈ V (T )} is a near-partition of the vertices of V (G). Furthermore, we require that if t∈V (Ti) Xt for i ∈ [r] are exactly the vertex sets i=1 Xi = X and Xi ∩ Xj = ∅ for every i (cid:54)= j. W ⊆ V (T ), define XW as (cid:83) of connected components of G. In other words, the forest T has exactly one tree per each connected component of G, with this tree being a tree-cut decomposition of the connected component. We call the elements of V (T ) nodes and the elements of V (G) vertices for clarity. The set Xt is called the bag of the decomposition corresponding to the node t, or just the bag at t. By choosing a root in each tree of T , thus making T into a rooted forest, we can talk about a rooted tree-cut decomposition. Let G be a graph with a tree-cut decomposition T = (T,X = {Xt : t ∈ V (T )}). For a subset t∈W Xt. For a subgraph T (cid:48) of T we write XT (cid:48) for XV (T (cid:48)). For an uv for XTuv to avoid multiple subscripts. Notice that, since X is a vu} is a near-partition of the vertex set of a connected component of G. We vu] edge uv ∈ E(T ) we write X T near-partition, {X T will call the decomposition connected if for every edge uv ∈ E(T ), the graphs G[X T are connected. uv] and G[X T uv, X T t uv, X T The adhesion of an edge e = uv of T , denoted adhT (e), is defined as the set EG(X T vu). An adhesion is thin if it has at most 2 edges, and is bold otherwise. The torso at a node t of T is the graph HT t defined as follows. Let T (cid:48) be the connected component of T that contains t, and let T1, T2, . . . , Tp be the components of T (cid:48) − t (note there might be no such components if t was an isolated node). Observe that {Xt, XT1, . . . , XTp} is a near-partition of XT (cid:48), whereas XT (cid:48) induces a connected component of G. Then the torso HT is the graph obtained from G[XT (cid:48)] by identifying the vertices of XTi into a single vertex zi, for each i ∈ [p], and removing all the loops created in this manner. Note that, thus, every edge between a vertex of XTi and a vertex of XTj , for some i (cid:54)= j, becomes an edge between zi and zj; similarly for edges between XTi and Xt. The vertices of Xt are called the core vertices of the torso, while the vertices zi are called the peripheral vertices of the torso. Finally, the 3-center of a node t of T , denoted by HT t , is the graph obtained from the torso HT t by repeatedly suppressing peripheral vertices of degree at most two and deleting any resulting loops. That is, any peripheral vertex of degree zero or one is deleted, while a peripheral vertex of degree two is replaced by an edge connecting its two neighbors; if the two neighbors are equal, the resulting loop is deleted, potentially allowing further suppressions. As Wollan [42] shows, any maximal sequence of suppressions leads to the same graph HT t . We omit the subscripts and superscripts T when they are clear from the context. The width of the decomposition T = (T,X ), denoted width(T ), is t )}. V (HT max{ max e∈E(T ) adh(e), max t∈V (T ) The tree-cut width of G, denoted by tctw(G), is the minimum width of a tree-cut decomposition of G. Ganian et al. [22] showed that bounded tree-cut width implies bounded treewidth. Besides, Kim et al. [29] showed that the dependency cannot be improved to subquadratic. Lemma 6 (see [22]). For any graph G, tw(G) ≤ 2tctw(G)2 + 3tctw(G). 8 Finally, Kim et al. [29] proposed a 2-approximation FPT algorithm for computing the tree-cut width of a graph. Theorem 7 (see [29]). There is an algorithm that, given a graph G and an integer r, runs in time 2O(r2 log r) · G2 and either concludes that tctw(w) > r, or returns a tree-cut decomposition of G of width at most 2r. Immersions. For two graphs G and H we say that G contains H as an immersion, or H is immersed in G, if there exist an injective mapping µV : V (H) → V (G), and a mapping µE from edges of H to paths in G such that: • for any edge uu(cid:48) ∈ E(H), µE(uu(cid:48)) is a path in G with endpoints µV (u) and µv(u(cid:48)); and • for any pair of different edges e, e(cid:48) ∈ E(H), the paths µE(e) and µE(e(cid:48)) do not have common edges. For a family of graphs F, we say a graph G is F-immersion-free, or F-free for short, if for every H ∈ F, G does not contain H as an immersion. We define the following parameterized problem: F-Immersion Deletion Input: A graph G and a positive integer k. Parameter: k Question: Is there a set F ⊆ E(G), such that F ≤ k and G − F is F-immersion-free? By OPTF (G) we denote the minimum size of a set F ⊆ E(G) such that G − F is F-free. If the family F is clear from the context, we omit the subscript. The following result follows from the work of Wollan [42]; the improved bound is obtained using the polynomial Excluded Grid Minor Theorem by Chekuri and Chuzhoy [8, 10, 11]. In particular, note that Theorem 1 stated in the introduction follows from it. Theorem 8. Let F be a family of graphs that contains at least one planar subcubic graph. Then if G is an F-free graph, then tctw(G) ≤ aF , where aF = O(maxH∈F (H + (cid:107)H(cid:107))30) is a constant depending on F only. Proof. Recall that the r × r wall Wr,r is a grid-like graph with maximum degree three (see Figure 1). Theorem 17 of [42] states that if G is a graph with tree-cut width at least 4r10 · w(r), then G admits an immersion of the r × r wall Wr,r. Here, w(r) is the upper bound in the Excluded Grid Minor Theorem, that is, the maximum treewidth of a graph that excludes the r × r grid as a minor. The currently best upper bound for w(r), given by Chuzhoy in [11], is w(r) ≤ O(r19polylog(r)). It is easy to see (see e.g., [24]) that there is a constant d such that every planar subcubic graph H with at most r vertices and edges can be immersed into the (dr) × (dr)-wall Wdr,dr. Hence, by the results above it follows that excluding such a graph H as an immersion imposes an upper bound of O(r30) on the tree-cut width of a graph. The above theorem is a starting point for our algorithms. In particular, it implies that we can test whether a graph is F-free in linear time. Lemma 9. Let F be a family of graphs that contains at least one planar subcubic graph. There is a linear-time algorithm that checks whether a given graph is F-free. 9 Proof. Let aF be the constant given by Theorem 8 for the family F, and let G be the input graph. Using Bodlaender's algorithm [3] for computing treewidth, for k = 2a2F + 3aF we either conclude that tw(G) > k, or compute a tree decomposition of G of width at most k. This takes time f (k) · G for some function f , hence linear time since k is a constant. In the first case, when tw(G) > 2a2F + 3aF , we may directly conclude that G is not F-free, because from Lemma 6 it follows that tctw(G) > aF , and then Theorem 8 implies that G is not F-free. Thus, we may now assume that we have constructed a tree decomposition of G of width at most k = 2a2F + 3aF . Observe now that for any fixed graph H, the property of admitting H as an immersion can be expressed in MSO2 (Monadic Second-Order logic on graphs with quantification over edge subsets). See, for example, [25]. Therefore, by applying Courcelle's Theorem [12], for every graph H ∈ F we may decide whether G is H-free in time g(k) · (cid:107)G(cid:107) for some function g; that is, in linear time since k is a constant. By verifying this for every graph H ∈ F we decide whether G is F-free. From now on, throughout the whole paper, we assume that F is a fixed family containing only connected graphs, of which at least one is planar and subcubic. We define the constant MAXF = maxH∈F (cid:107)H(cid:107) and let aF be the bound from Theorem 8. 3 Adjusting tree-cut decompositions 3.1 Alternative definition of tree-cut width To simplify many arguments, we give a simpler definition of tree-cut width and show it to be equivalent. Let G be a graph with a tree-cut decomposition T = (T,X = {Xt : t ∈ V (T )}). For every t ∈ V (T ), we define wT (t) = Xt + {t(cid:48) ∈ NT (t) : adhT (tt(cid:48)) is bold}. We drop the subscript T when it is clear from the context. We then set w(t)} width(cid:48)(T ) = max{ max e∈E(T ) adh(e), max t∈V (T ) and define tctw(cid:48)(G) as the minimum of width(cid:48)(T ) over all tree-cut decompositions T of G. Theorem 10. For every graph G it holds that tctw(G) = tctw(cid:48)(G). Moreover, given a tree- cut decomposition T = (T,X ) of G, it always holds that width(T ) ≤ width(cid:48)(T ), and a tree-cut decomposition T (cid:48) such that width(cid:48)(T (cid:48)) ≤ width(T ) can be computed in time O((cid:107)G(cid:107) · G2 · width(T )). Proof. Let G be a graph and T = (T,X = {Xt : t ∈ V (T )})) be a tree-cut decomposition. We first show that width(T ) ≤ width(cid:48)(T ). Consider any t ∈ V (T ) and let t1, t2, . . . , t(cid:96) be the neighbors of t in T . For i ∈ [(cid:96)], denote by zi the peripheral vertex of the torso of t, HT t , obtained after consolidating (i.e. identifying into one vertex) the set X T tit. We claim that V (HT t ) ≤ w(t). Recall that HT t its vertices are core (zi) = adh(tti) vertices Xt and peripheral vertices z1, . . . , z(cid:96) that were not suppressed. Since degHT for i ∈ [(cid:96)], the vertex zi might not suppressed (and thus, belong to the 3-center at t) only when adh(tti) ≥ 3, which implies V (HT t ) ≤ Xt + {t(cid:48) ∈ NT (t) : adh(tt(cid:48)) is bold} = w(t) is the 3-center at t: (1) t This holds for every t ∈ V (T ), hence width(T ) ≤ width(cid:48)(T ). 10 width (i.e. width(T ) = tctw(G)) and, among such optimum decompositions, (cid:80) In particular, tctw(G) ≤ tctw(cid:48)(G). We now proceed to showing that tctw(G) = tctw(cid:48)(G). Note that without loss of generality we may assume that G is connected, as we may consider each connected component separately. Hence, all the tree-cut decompositions considered in the sequel will consist of just one tree. Let us choose a tree-cut decomposition T = (T,X ) of G as follows: T has the optimum e∈E(T ) adh(e) is t ) = w(t) for every t ∈ V (T ), which implies that t ) (cid:54)= w(t), and t ) < w(t). We denote by t1, t2, . . . , t(cid:96) the neighbors of t in T and define zi for minimum possible. We will now prove that V (HT width(cid:48)(T ) = width(T ) = tctw(G) by definition, concluding the claim. Towards a contradiction, let us assume that there exists t ∈ V (T ) with V (HT thus by (1), V (HT i ∈ [(cid:96)] as above. t t t (zp) ≥ 3 and degHT t ; see Figure 2. Observe that, since the inequality V (HT Without loss of generality, let (z1, z2, . . . , zk) be a maximal sequence of vertices whose suppression t ) < w(t) is strict, at least one of t . Let zp be the first such vertex, that is, (zi) ≤ 2 for i < p. Note that p (cid:54)= 1 as, by definition, the first vertex to get t . Let C1, . . . , Cp(cid:48) be the connected components of the graph t . Since their degrees are at most two each component Ci (zp) ∩ V (Ci) (cid:54)= ∅}, that is, First notice that the set C is not empty. Indeed, if zp would not have any neighbor in at least t after suppressing Second, for C ∈ C, observe that if z is a neighbor of zp in C, then z has degree at most t , including its neighbor zp, and hence z has degree at most 1 in C. Therefore, every C. We have (zp)∩ V (C) ⊆ {zC, z(cid:48) (zp)∩ V (C) (cid:54)= ∅, without loss of generality leads to HT the suppressed vertices originally has degree 3 or more in HT degHT suppressed has degree at most 2 in HT induced by the vertices z1, . . . , zp−1 in HT t . Let C = {Ci : NHT is either an induced cycle or an induced path in HT let C be the subset of the graphs C1, . . . , Cp(cid:48) in which zp has a neighbor. one the components C1, . . . , Cp(cid:48) then it still would have degree at least 3 in HT the vertices of these graphs, z1, . . . , zp−1. 2 in HT C ∈ C is an induced path in HT NHT we will assume that always zCzp ∈ E(HT t ). Claim 11. There exists C ∈ C such that NHT Proof. We prove the claim by contradiction. That is, suppose that for every C ∈ C, C has a t ) \ {zp}. This must be a neighbor outside {zi : i ∈ [p − 1]} (since C is a connected neighbor in V (HT component of the subgraph induced by these vertices), thus for every C ∈ C, there is a vertex z ∈ C such that z has a neighbor z(cid:48) in V (HT Let C ∈ C. Since the internal vertices of the path C have degree exactly 2 both in C and in HT t , they have no neighbors outside C. Consider now two cases depending on V (C). t , whose endpoints we henceforth denote by zC and z(cid:48) C}, and since by definition NHT t ) \ {zi : i ∈ [p]}. (V (C)) ⊆ {zp}. t t t • If V (C) = 1, then zC = z(cid:48) edge to zp; since zC = z(cid:48) C has an edge to a neighbor z(cid:48) in V (HT C has degree 2 in HT t , it has no other incident edges in HT t . t ) \ {zi : i ∈ [p]} and an • If V (C) ≥ 2, then zC has an edge to a neighbor in C and an edge to zp, and again, no other t ) \ {zi : i ∈ [p]}. Then z(cid:48) incident edges. Thus it must be that z(cid:48) C has a neighbor z(cid:48) in V (HT has an edge to z(cid:48), to a neighbor in C, and no other incident edges. C We conclude that in both cases, for every C ∈ C, we have E(C, zp) = 1; moreover, after t ) \ {zi : i ∈ [p]}, t does not drop after suppressing (zp) ≥ 3 by choice of zp, and after suppressing z1, . . . , zp−1, (cid:121) suppressing the vertices z1, . . . , zp−1, including those of C, zp has an edge to V (HT a different one for every C ∈ C. Therefore, the degree of zp in HT z1, . . . , zp−1. However, initially degHT the vertex zp must have degree at most 2 to be itself suppressed, a contradiction. t 11 zC1 = z(cid:48) C1 z(cid:48) C2 Xt zC2 zq3 zq2 X T (cid:48) ttp zq1 zp XT3 XT2 XT1 Xt Xtp X T tpt Figure 2: On the left, the torso HT t , including the peripheral vertices z1, . . . , zp suppressed in HT t . On the right, the modified decomposition, with subtrees T1, . . . , Tr attached to tp instead of t. This improves the decomposition by making adh(ttp) strictly smaller (because of zpzq1, zpzq3). Let now C ∈ C be such that NHT (C) ⊆ {zp}. Let zq1, zq2, . . . , zqr be the vertices of the path C. We construct a new tree-cut decomposition T (cid:48) = (T (cid:48),X ) of G by removing the edges ttqi from T and adding the edges tptqi, for all i ∈ [r]. That is, t and V (T (cid:48)) = V (T ) E(T (cid:48)) = (E(T ) \ {ttqi : i ∈ [r]}) ∪ {tptqi : i ∈ [r]}. e∈E(T (cid:48)) adhT (cid:48)(e) <(cid:80) minimum possible width, and that(cid:80) Note that the bags in T (cid:48) are exactly the same as in T . We will show that T (cid:48) = (T (cid:48),X ) has the e∈E(T ) adhT (e), a contradiction to the tqi tp for each i ∈ [r]; we will denote this subtree of T and T (cid:48) by Ti choice of T . Notice that Ttqi t = T (cid:48) from now on. The bags assigned to this subtree do not change either, thus for every i ∈ [r] we have (2) (3) adhT (cid:48)(tqitp) = adhT (tqit). Similarly, notice that for every edge e ∈ (E(T ) ∩ E(T (cid:48))) \ {ttp} we have ttp) = V (Tttp) \(cid:83) tpt, X T (cid:48) ttp, and(cid:83) adhT (cid:48)(e) = adhT (e). Finally, let us consider the edge ttp. By construction V (T (cid:48) words, V (G) is partitioned into X T from adhT (ttp) by deleting EG(XTi, X T Claim 12. For every i ∈ [r], EG(XTi, X T (cid:48) Proof. By the choice of C, the only neighbor of V (C) = {zq1, . . . , zqr} in HT each i ∈ [r], the vertex zqi has neighbors only in zq1, . . . , zqr and zp in HT from G by consolidating XTi into zqi (for i ∈ [r]) and X T that the only edges in G leaving XTi go to XT1 ∪ ··· ∪ XTr ∪ X T X T tpt. Since X T (cid:48) ttp = V (G) \ X T Similarly, by the choice of C, zp has an edge to V (C) = {zq1, . . . , zqr} in HT tpt by removing XT1 ∪ ··· ∪ XTr , the first claim follows. tpt and XTi for some i ∈ [r]. an edge between X T It follows that adhT (cid:48)(ttp) (cid:40) adhT (ttp). Together with (2), (3), this implies t i∈[r] V (Ti). In other i∈[r] XTi. Observe that adhT (cid:48)(ttp) is obtained tpt) and adding EG(XTi, X T (cid:48) ttp) = ∅. Moreover, there exists i ∈ [r], EG(XTi, X T ttp), for all i ∈ [r]. tpt) (cid:54)= ∅. is zp. That is, for is constructed tpt into zp (among others), this means ttp is obtained from t . Since HT t t . This means G has (cid:121) adhT (cid:48)(e) ≤ max e∈E(T ) adhT (cid:48)(e) < (cid:88) adhT (e) adhT (e). (4) (5) max e∈E(T ) (cid:88) e∈E(T (cid:48)) e∈E(T ) 12 t To prove our claim it remains to show that maxt∈V (T ) V (HT t ). Recall first that V (T ) = V (T (cid:48)). For every vertex s ∈ V (T ) \ {t, tp} the torso at s in decomposition T is the same as the torso at s in decomposition T (cid:48). This implies that HT . From the way T (cid:48) was constructed, we have NT (cid:48)(t) ⊆ NT (t). Moreover, recall that for every vertex s ∈ NT (cid:48)(t), adhT (cid:48)(st) ⊆ adhT (st). Therefore HT (cid:48) Consider now the torso at t in decomposition T (cid:48), i.e. HT (cid:48) t ) ≤ maxt∈V (T ) V (HT (cid:48) t ) cannot be larger than V (HT t , and thus V (HT (cid:48) is a subgraph of HT s = HT (cid:48) s . t ). t t V (HT tp ) = (zqi) = Consider finally the torso at the node tp in decomposition T (cid:48), i.e. HT (cid:48) tp )∪{zqi : i ∈ [r]}. Recall, however, that adhT (cid:48)(tptqi) = adhT (ttqi) and therefore, degHT (cid:48) (zqi) ≤ 2. This implies that the vertices zqi, for all i ∈ [r], get suppressed in HT (cid:48) tp . Notice that V (HT (cid:48) tp tp (more tp by suppressing them). For other vertices s in degHT precisely, we can start the procedure of obtaining HT (cid:48) NT (cid:48)(tp) we have adhT (cid:48)(stp) ⊆ adhT (stp). Hence V (HT (cid:48) tp ) cannot be larger than V (HT tp ). t ) ≤ V (HT In any case we obtain that V (HT (cid:48) t ) for every t ∈ V (T ). Together with (4), we obtain that width(T (cid:48)) ≤ width(T ), that is, T (cid:48) has the minimum possible width (because we assumed t ) = w(t), for every t ∈ V (T ), that T has). But then (5) contradicts our choice of T . Hence, V (HT is, width(T ) = width(cid:48)(T ), which concludes the proof that tctw(G) = tctw(cid:48)(G). For the algorithmic statement, note that in the proof, either we show that width(T ) = width(cid:48)(T ), or we construct a decomposition T (cid:48) such that width(T (cid:48)) ≤ width(T ) and the sum of all adhesion sizes in T (cid:48) is strictly smaller than in T (Equation (5)). Since the construction can be easily performed in time O((cid:107)G(cid:107) · G) by computing all torsos and 3-centers, and since the initial sum of all adhesion sizes can be at most O(G · width(T )), the construction can be performed repeatedly until width(T ) = width(cid:48)(T ), concluding the algorithm. 3.2 Making the decomposition connected The goal of this section is to prove that one can make a tree-cut decomposition connected without increasing its width (more precisely, width(cid:48)) by much. For this, we will temporarily need a slight variation on tctw(cid:48). Let G be a graph and T = (T,X ) be a tree-cut decomposition of G. For every t ∈ V (T ), recall that δT (t) denotes the set of edges of T incident to t. We define (cid:88) adh(e) , and z(t) = Xt + width(cid:48)(cid:48)(T ) = max t∈V (T ) e∈δ(t) adh(e)≥3 z(t). Lemma 13. For every graph G and every tree-cut decomposition T of G, width(cid:48)(T ) − 1 ≤ width(cid:48)(cid:48)(T ) ≤ (width(cid:48)(T ))2. Proof. Let G be a graph and T = (T,X = {Xt : t ∈ V (T )}) be a tree-cut decomposition of G. We first prove that width(cid:48)(T ) ≤ width(cid:48)(cid:48)(T ) + 1, which is equivalent to the left inequality. Recall that width(cid:48)(T ) = max{maxe∈E(T ) adh(e), maxt∈V (T ) w(t)}. Clearly for each t ∈ V (T ), from definitions of w(t) and z(t) we have (cid:88) e∈δ(t) adh(e)≥3 adh(e) = z(t). w(t) = Xt + {e ∈ δT (t) : adh(e) ≥ 3} ≤ Xt + In particular, maxt∈V (T ) w(t) ≤ maxt∈V (T ) z(t). 13 Let e∗ ∈ E(T ) be an edge of T that maximizes adh(e∗). If adh(e∗) ≤ 2, then trivially adh(e∗) ≤ Xt + 1 ≤ z(t) + 1 for some t ∈ V (T ). Otherwise, if adh(e∗) ≥ 3, let t be an endpoint of e∗; then z(t) ≥ Xt + adh(e∗), so in particular adh(e∗) ≤ z(t). Thus in any case, we conclude that width(cid:48)(T ) = max{adh(e∗), max t∈V (T ) w(t)} ≤ max t∈V (T ) z(t) + 1 = width(cid:48)(cid:48)(T ) + 1. We now prove that width(cid:48)(cid:48)(T ) ≤ (width(cid:48)(T ))2. Notice that, by definition, adh(e) ≤ width(cid:48)(T ). max e∈E(T ) Moreover, for every t ∈ V (T ), Xt + {e ∈ δT (t) : adh(e) ≥ 3} = w(t) ≤ width(cid:48)(T ). Therefore, z(t) = Xt + ≤ Xt + (cid:88) (cid:88) e∈δ(t) adh(e)≥3 e∈δ(t) adh(e)≥3 adh(e) width(cid:48)(T ) = Xt + {e ∈ δ(t) : adh(e) ≥ 3} · width(cid:48)(T ) ≤ (width(cid:48)(T ))2. Thus, we conclude that width(cid:48)(cid:48)(T ) = maxt∈V (T ) z(t) ≤ (width(cid:48)(T ))2. Recall that a tree-cut decomposition T = (T,X = {Xt : t ∈ V (T )}) of G is connected if for vu] are connected. We now show that we may every edge uv ∈ E(T ), the graphs G[X T always find such a tree-cut decomposition. Lemma 14. Given a tree-cut decomposition of a graph G with width(cid:48) at most k, a connected tree-cut decomposition of G with width(cid:48) at most k2 + 1 can be constructed in time O((cid:107)G(cid:107) · G2 · k2). uv] and G[X T Proof. If a graph is disconnected, we may consider its connected components separately, find a connected tree-cut decomposition for each component and conclude the claim by taking the disjoint union of the decompositions. We will thus henceforth assume that G is a connected graph. Suppose G has a tree-cut decomposition of width(cid:48) at most k. Then by Lemma 13, the same decomposition has width(cid:48)(cid:48) at most k2. Let T = (T,X = {Xt : t ∈ V (T )}) be a tree-cut decomposition of G such that width(cid:48)(cid:48)(T ) ≤ k2 and, subject to that,(cid:80) e∈E(T ) adhT (e)2 is minimum possible. We claim that T is a connected decomposition. Towards a contradiction, assume that G[X T uv] is not connected, for some uv ∈ E(T ). Let G1, G2, . . . , Gr be its connected components. Let T (cid:48) = (T (cid:48),X (cid:48)) be the tree-cut decomposition of G obtained from (T,X ) in the following way. Let T1, T2, . . . , Tr be r distinct copies of Tuv where, for every i ∈ [r], V (Ti) = {zi : z ∈ V (Tuv)} E(Ti) = {fi : f ∈ E(Tuv)}. 14 To obtain T (cid:48), we remove Tuv from T , add the trees T1, T2, . . . , Tr instead, and for each i = 1, 2, . . . , r we add a new edge ei between v and ui ∈ V (Ti). Therefore, V (T (cid:48)) = V (Tvu) ∪ (cid:91) E(T (cid:48)) = E(Tvu) ∪ (cid:91) i∈[r] V (Ti) E(Ti) ∪ (cid:91) i∈[r] {ei}. i∈[r] (6) (7) (8) Notice then that Ti = T (cid:48) (cid:40) uiv, for each i ∈ [r]. We define X (cid:48) in the following way. if s ∈ V (Tvu) if s = zi for some z ∈ V (Tuv) and i ∈ [r]. Xs Xz ∩ V (Gi) X(cid:48) s = We will obtain a contradiction by proving that width(cid:48)(cid:48)(T (cid:48)) ≤ width(cid:48)(cid:48)(T ) and (cid:88) e∈E(T (cid:48)) adhT (cid:48)(e)2 < (cid:88) e∈E(T ) adhT (e)2. However, towards our goal, we have to first show how adhesions in T (cid:48) correspond to adhesions in T . Notice that for every f ∈ E(T ) ∩ E(T (cid:48)), adhT (cid:48)(f ) = adhT (f ). (9) The remaining edges of T (cid:48) are of the form pjqj ∈ E(Tj) or ej, for some j ∈ [r]. In the latter case, let us write pj = uj and qj = v. We claim that {adhT (cid:48)(pjqj) : j ∈ [r]} is a near-partition of adhT (pq) (here, if pjqj = ej = ujv, then p = u and q = v). Indeed, adhT (cid:48)(pjqj) is by construction equal to the i(cid:54)=j V (Gi). Since, E(V (Gj), V (Gi)) = ∅, for i (cid:54)= j, set of edges between X T it follows that pq ∩ V (Gj), X T pq ∩ V (Gi) : i ∈ [r]} is a near-partition of X T pq, qp) = adhT (pq), as claimed. Since X T we infer that {adhT (cid:48)(pjqj) : j ∈ [r]} is a near-partition of EG(X T Therefore, for all edges f ∈ E(Tvu), as well as for f = uv (in which case fi = ei), we have adhT (cid:48)(pjqj) = EG(X T pq is a near-partition of V (G) and {X T pq ∩ V (Gj) and X T qp ∪(cid:83) qp, X T qp). pq, X T (cid:88) i∈[r] adhT (cid:48)(fi) = adhT (f ). (10) We are now able to prove that width(cid:48)(cid:48)(T (cid:48)) ≤ width(cid:48)(cid:48)(T ). That is, we want to show that maxt∈V (T (cid:48)) zT (cid:48)(t) ≤ maxt∈V (T ) zT (t). Here zT (·) and zT (cid:48)(·) are the z(·)-functions as in the definition of tctw(cid:48)(cid:48), applied respectively in decompositions T and T (cid:48). t = Xt and, from (9) we obtain that for Let first t ∈ V (Tvu) \ {v}. From (8) we obtain that X(cid:48) every edge y ∈ δT (t), adhT (cid:48)(y) = adhT (y). Thus, zT (cid:48)(t) = zT (t). Let now ti ∈ V (Ti), for some i ∈ [r]. From (8) we obtain that X(cid:48) ti ≤ Xt. Moreover, for every edge fi incident to ti, from (10) we obtain that adhT (cid:48)(fi) ≤ adhT (f ). Thus, zT (cid:48)(ti) ≤ zT (t). v = Xv. Observe that δT (cid:48)(v) = E1 (cid:93) E2, where Finally, let t = v. From (8), we obtain that X(cid:48) E1 = δT (v) \ {uv} and E2 = {ei i ∈ [r]}. Then from Equation (9), for every edge y ∈ E1 we have i∈[r] adhT (cid:48)(ei) = adhT (e). From this it follows that zT (cid:48)(v) ≤ zT (v). adhT (cid:48)(y) = adhT (y), and from Equation (10), we also have(cid:80) 15 Thus for each t(cid:48) ∈ V (T (cid:48)), we have zT (cid:48)(t(cid:48)) ≤ maxt∈V (T ) zT (t) = width(cid:48)(cid:48)(T ), and hence width(cid:48)(cid:48)(T (cid:48)) ≤ width(cid:48)(cid:48)(T ). Furthermore, from (9) and (10), we have adhT (cid:48)(e) = (cid:88) adhT (cid:48)(fi)2 ≤(cid:0)(cid:88) e∈E(T (cid:48)) adhT (e) (cid:88) adhT (cid:48)(fi)(cid:1)2 = adhT (f )2. e∈E(T ) i∈[r] (cid:88) i∈[r] Notice now that from (10), for each f ∈ E(Tvu) ∪ {uv} we have (11) Here, for f = uv we consider fi = ei. uv, X T Since X T vu is a near-partition of V (G) and V (G1), . . . , V (Gr) is a partition of X T uv, we have that X T uv, V (G1), . . . , V (Gr) is a near-partition of all of V (G). Furthermore, since G is connected uv) is non-empty for each i ∈ [r]. and EG(V (Gi), V (Gj)) = ∅ for i (cid:54)= j, it must be that EG(V (Gi), X T This means adhT (cid:48)(ei) is non-empty, and since r ≥ 2, we infer that the inequality in (11) is strict for f = uv. We conclude that (cid:88) e∈E(T (cid:48)) (cid:88) e∈E(T ) adhT (cid:48)(e)2 < adhT (e)2, (12) a contradiction to the choice of T . This concludes the proof that G has a connected tree-cut decomposition of width(cid:48)(cid:48) at most k2 and hence, by Lemma 13, of width(cid:48) at most k2 + 1. Note that in the proof, we either proved that T is already connected, or constructed a decomposition T (cid:48) with width(cid:48)(cid:48)(T (cid:48)) ≤ width(cid:48)(cid:48)(T ) and with a strictly smaller sum of squares of adhesion sizes (Equation (12)). Since the construction can be easily performed in O((cid:107)G(cid:107) · G) time, and since the sum of squares of adhesion sizes is initially bounded by O(G · k2) (as each adhesion has size bounded by width(cid:48) of the decomposition, which is at most k), the construction can be performed repeatedly until T is connected, concluding the algorithm. 3.3 Neat tree-cut decompositions Recall that a tree-cut decomposition can be rooted by selecting a root in every its tree, which naturally imposes child-parent relation on the nodes, as well as the sibling relation. As already mentioned, the parent of a node t is denoted by π(t). We now define additional properties of rooted tree-cut decompositions, and show that these properties can be achieved by simple modifications of the decomposition. This will help us in the next sections, where we will handle tree-cut decompositions combinatorially and algorithmically. The main notion that we will be interested in is called neatness. Definition 15. Let G be a graph and T = (T,X = {Xt : t ∈ V (T )}) be a rooted tree-cut decomposition of G. We say that T is neat if it is connected and, furthermore, for every non-root node t ∈ V (T ) such that adh(tπ(t)) is thin, and every sibling t(cid:48) of t, there are no edges between X T tπ(t) and X T t(cid:48)π(t) in G. The second condition was used by Ganian et al. [22] under the name niceness. We now show that every connected tree-cut decomposition can be made neat without increasing its width. The proof of this result follows closely the lines of the proof of [22, Lemma 1]. Theorem 16. Given a connected tree-cut decomposition of a graph G with width(cid:48) at most k, a neat tree-cut decomposition of G with width(cid:48) at most k can be computed in time O(G3). 16 Proof. Similarly as before, if a graph is disconnected, we may consider its connected components separately, find a neat tree-cut decomposition for each component and conclude the claim by joining the decompositions into one forest. We will thus henceforth assume that G is a connected graph. Let T = (T,X ) be a connected tree-cut decomposition of G with width(cid:48)(T ) ≤ k. Let us arbitrarily choose a node r ∈ V (T ) to be the root of T . We will show that, after this rooting, T can be transformed into a neat tree-cut decomposition of G. Similarly to [22], we will call a node t ∈ V (T ) \ {r} bad if adh(tπ(t)) ≤ 2 and there exists a sibling t(cid:48) of t, such that there is an edge in G between X T t(cid:48)π(t). Moreover, for a bad vertex t we say that a node b is a bad neighbor of t if b ∈ V (Tt(cid:48)π(t)) for some sibling t(cid:48) of t, and there is an edge between Xb and X T tπ(t) and X T tπ(t) in G. We define the following two procedures, similarly to [22], see Figure 3: Rerouting(t): let t be a bad node and let b be a bad neighbor of t of maximum depth. Then remove the edge tπ(t) from T and add a new edge bt, thus making t a child of b. Top-down Rerouting: as long as (T,X ) is not a neat tree-cut decomposition, pick a bad node t of minimum depth and perform Rerouting(t). π(t) t t(cid:48) u b v Figure 3: A decomposition with a bad node t and a bad neighbor b -- the rerouting procedure will reattach the subtree Ttπ(t) below b. Two edges of G in adh(ttp) are shown. We first make sure that rerouting does not spoil the connectivity of a decomposition. Claim 17. Let T = (T,X = {Xt : t ∈ V (T )}) be a connected rooted tree-cut decomposition and t ∈ V (T ) be a bad vertex of T . If T (cid:48) = (T (cid:48),X ) is the rooted tree-cut decomposition obtained from T after running Rerouting(t), then T (cid:48) is also connected. Proof. Notice first that, by construction, we have E(T (cid:48)) = (E(T ) \ {tπ(t)}) ∪ {tb}. Let P denote the path in T (cid:48) (and in T ) that leads from π(t) to b. Observe that if uv is an edge of E(T (cid:48)) \ (E(P ) ∪ {tb}), then V (T (cid:48) tb) = V (Ttπ(t)) and V (T (cid:48) vu) = vu] are connected. Consider now the edge tb of T (cid:48). Notice that bt] are uv) = V (Tuv) and V (T (cid:48) tb] and G[X T (cid:48) bt) = V (Tπ(t)t). This implies that the graphs G[X T (cid:48) uv] and G[X T V (Tvu). Thus G[X T V (T (cid:48) connected as well. Finally, consider an edge e = uv of P and, without loss of generality, we assume that u is the parent of v. Notice then that X T (cid:48) vu = X T vu ∪ X T tπ(t) and 17 X T (cid:48) uv = X T uv \ X T tπ(t). vu and X T vu, it follows that the graph G[X T (cid:48) vu] is connected. To show that X T (cid:48) uv = X T uv\X T tπ(t) are connected. Moreover, since t is a tπ(t) and Xb in G. Therefore, Recall that the subgraphs of G induced by X T bad vertex and b is a bad neighbor of t, there exists an edge between X T as Xb ⊆ X T is thin. That is, δG(X T Observe then that X T Since G[X T any path that connected two vertices of X T (cid:48) edges between these parts. Thus, G[X T (cid:48) tπ(t) also induces a connected subgraph in G, recall that adhT (tπ(t)) tπ(t) and Xb in G. tπ(t). tπ(t) it remains connected, because tπ(t) would imply at least two (cid:121) tπ(t)) ≤ 2, and recall that there is an edge between X T tπ(t), where there is at most one edge between X T (cid:48) uv] is connected, this implies that after removing X T uv and went through X T uv = X T (cid:48) uv ∪ X T uv and X T uv] is also connected. Next, we verify that rerouting does not increase the width. Claim 18. Let T = (T,X ) be a rooted tree-cut decomposition and t ∈ V (T ) be a bad vertex of T . If T (cid:48) = (T (cid:48),X ) is the rooted tree-cut decomposition obtained from T after running Rerouting(t), then width(cid:48)(T (cid:48)) ≤ width(cid:48)(T ). Proof. As before, notice first that we have E(T (cid:48)) = (E(T ) \ {tπ(t)}) ∪ {tb}. Let P denote the path in T (cid:48) (and in T ) that leads from π(t) to b. Observe that if e is an edge of E(T (cid:48)) \ (E(P ) ∪ {tb}) then adhT (cid:48)(e) = adhT (e). Notice also that Finally, let e be an edge of P . Notice that the edge between X T adhT (cid:48)(tb) = adhT (tπ(t)). tπ(t) and Xb belongs to adhT (e) but not to adhT (cid:48)(e). Moreover, since adhT (tπ(t)) ≤ 2, there exists at most one edge that belongs to adhT (cid:48)(e) but not to adhT (e). We conclude that adhT (cid:48)(e) ≤ adhT (e), for every e ∈ E(P ). In particular, maxe∈E(T (cid:48)) adh(e) ≤ maxe∈E(T ) adh(e). Furthermore, since the bag at every node is unchanged, wT (cid:48)(v) can be larger than wT (v) only for v = b. (Here, wT (·) and wT (cid:48)(·) are functions w(·) as in the definition of width(cid:48), applied to decompositions T and T (cid:48), respectively.) However, even in this case the only additional edge incident to b is tb, whose adhesion has size at most 2. We conclude that wT (cid:48)(v) ≤ wT (v) for each v ∈ V (T ), and hence width(cid:48)(T (cid:48)) ≤ width(cid:48)(T ). (cid:121) The above two claims show that it is safe to apply the Rerouting procedure. We now show that applying it exhastively, as described in procedure Top-down Rerouting, always terminates within a polynomial number of steps. Claim 19. Top-down Rerouting terminates after O(T2) invocations of Rerouting(t). Proof. We note that the proof is again similar to the one in [22]. However, we include it for the sake of completeness. For a tree-cut decomposition T = (T,X ) and a node v ∈ V (T ) let depth(v, T ) = distT (v, r), where r is the root of T . Notice, that for every v ∈ V (T ) we have depth(v, T ) ≤ T, and hence (cid:88) v∈V (T ) depth(v, T ) ≤ T2. Let T = (T,X ) be a rooted tree-cut decomposition of G and t be a bad node of T such that the distance of t from r is minimum. Let T (cid:48) = (T (cid:48),X ) be the tree-cut decomposition of G obtained after performing Rerouting(t). Notice that, for every v ∈ V (Ttπ(t)), depth(v, T (cid:48)) ≥ depth(v, T ) + 1. Moreover, for every v ∈ V (Tπ(t)t), depth(v, T (cid:48)) = depth(v, T ). This implies that depth(v, T ) < depth(v, T (cid:48)) ≤ T2. (cid:88) v∈V (T ) (cid:88) v∈V (T (cid:48)) 18 Therefore, since the sum of depths of nodes increases at each step, and it is always upper bounded by T2, the Top-down Rerouting procedure terminates after at most T2 steps. (cid:121) This concludes the proof that Top-down Rerouting produces a neat tree-cut decomposition of width(cid:48) bounded by k2 + 1. Since we always assume T = O(G), Rerouting is invoked O(G2) times. Finding a bad node and a bad neighbor can be done in O(G) time by inspecting edges of thin adhesions and computing the least-common-ancestor in T of the two bags containing their endpoints, using e.g. Gabow and Tarjan's classical algorithm [21]. Since Rerouting can be performed in O(G) time, the algorithm runs in O(G3) total time. We can now combine all tools developed so far to prove the following statement, which will later serve as an abstraction for getting tree-cut decompositions of F-free graphs with good properties. Corollary 20. Given an F-free graph G, a neat tree-cut decomposition of width(cid:48) at most bF of G can be computed in time O((cid:107)G(cid:107) · G2), where bF = 4(aF )2 + 1 is a constant depending on F only. Here, aF is the constant given by Theorem 8. Proof. We have tctw(G) ≤ aF by Theorem 8. By Theorem 7, a tree-cut decomposition of width at most 2aF can be computed in time O(G2). From it, by Theorem 10, a decomposition of width(cid:48) at most 2aF can be computed in time O((cid:107)G(cid:107) · G2). Then, by Lemma 14, a connected decomposition of width(cid:48) at most 4(aF )2 + 1 can be computed in time O((cid:107)G(cid:107) · G2). Finally, by Theorem 16, a neat decomposition of width(cid:48) at most 4(aF )2 + 1 can be computed in time O(G3). Let G be a graph with a neat tree-cut decomposition T = (T,X ), and let p ∈ V (T ). For t ∈ NT (p), we say the component Ttp of T − p is connected with a neat adhesion to p if the adhesion of tp is thin, and moreover all of its edges have an endpoint in Xp. We now prove a result that shows what the neat decompositions are useful for: provided some node has many neighbors, all but a constant number of them is connected to it via neat adhesions. Corollary 21. Let G be a graph with a neat tree-cut decomposition T = (T,X ) with width(cid:48)(T ) ≤ b, for some integer b. Then for every p ∈ V (T ), at most 2b + 1 of the connected components of T − p are not connected with a neat adhesions to p. Proof. Let p ∈ V (T ). By the definition of width(cid:48), at most b of the edges in δT (p) have adhesions containing more than two edges of G; all other edges in δT (p) have thin adhesions. Additionally, at most one edge in pt ∈ δT (p) has the property that π(p) = t; all other edges pt ∈ δT (p) satisfy π(t) = p. Consider then the remaining edges in δT (p), say pt1, . . . , ptr, for some r ≥ δT (p) − b − 1. They have thin adhesions and satisfy π(ti) = p. Recall that adh(pti) contains precisely the edges of G with one endpoint in X T tip and the other in X T pti. By definition of a neat decomposition (and since adh(tip) = adh(tiπ(ti)) is thin), the edges t(cid:48)p for any sibling t(cid:48) of ti. This means of G contained in adh(pti) cannot have an endpoint in X T π(p)p = ∅). π(p)p ∪ Xp (if p is the root, assume X T that they have one endpoint in X T π(p)p is bounded by adh(π(p)p) ≤ b. Therefore, However, the number of edges between X T at least r − b of the decomposition edges tip (i ∈ [r]) have adhesions containing only edges of G that have an endpoint in Xp. This means that for at least r − b ≥ δT (p) − 2b − 1 indices i ∈ [r], the component Ttip of T − p is connected with a neat adhesion to p. tip and one in X T tip and X T 19 4 Protrusions We now introduce the notion of a protrusion that is suitable for our problem. Namely, protrusions are F-free parts of the graph with a constant-size boundary. Definition 22. An r-protrusion of a graph G is a set X ⊆ V (G) such that δ(X) ≤ r and G[X] is F-free. Recall that by Corollary 20, the subgraph induced by a protrusion, as an F-free graph, always has a neat tree-cut decomposition of width(cid:48) bounded by a constant bF . In the sequel, we will only deal with 2bF - and 2-protrusions. 4.1 Replacing protrusions As in [19], the base for our kernelization algorithm is protrusion replacement. That is, the algorithm iteratively finds a protrusion X that is large but has small δ(X), and replaces it with a gadget X(cid:48) that has the same behaviour, but is smaller. The following lemma, whose proof is the main goal of this section, formalizes this intuition. Lemma 23. There is a constant cF and algorithm that, given a graph G and a 2bF -protrusion X in it with (cid:107)G[X](cid:107) > cF , outputs in linear time a graph G(cid:48) with OPT(G) = OPT(G(cid:48)) and (cid:107)G(cid:48)(cid:107) < (cid:107)G(cid:107). Moreover, there is a linear-time algorithm working as follows: given a subset F (cid:48) of edges of G(cid:48) such that G(cid:48) − F (cid:48) is F-free, the algorithm computes a subset F of edges of G such that G − F is F-free and F ≤ F (cid:48) (and is called a solution-lifting algorithm). The proof of Lemma 23 follows closely the strategy used by Fomin et al. [19]: Every 2bF - protrusion can be assigned a type, where the number of types is bounded by a function depending on F only. The type of a protrusion can be computed efficiently due to protrusions having constant treewidth. Protrusions with the same type behave in the same way with respect to the problem of our interest, and hence can be replaced by one another. Therefore, we store a replacement table consisting of the smallest protrusion of each type, so that every larger protrusion can be replaced by a smaller representative stored in the table. The lifting algorithm finds, using dynamic programming, a partial solution in the large protrusion that has the same behaviour as the given partial solution in the replacement protrusion, while being not larger. We now proceed with implementing this plan formally. We start with defining boundaried graphs. Definition 24. An r-boundaried graph consists of an underlying graph G and an r-tuple (u1, . . . , ur) of (not necessarily different) vertices of G, called the boundary. Given two r-boundaried graphs G = (G, (u1, . . . , ur)) and H = (H, (v1, . . . , vr)), we define their gluing, denoted G ⊕ H, to be the following graph: take the disjoint union of G and H, and for each i ∈ [r] add one edge uivi. Finally, we define (cid:107)G(cid:107) to be (cid:107)G(cid:107). We extend all notation for graphs to boundaried graphs, always applying it to the underlying graph. Thus, we can talk about, e.g., F-free boundaried graphs. Boundaried graphs can be naturally equipped with a Myhill-Nerode-like equivalence relation concerning the problem of our interest. Definition 25. Two r-boundaried graphs G1 and G2 are called F-equivalent if for every r-boundaried graph H, the following holds: OPT(G1 ⊕ H) = OPT(G2 ⊕ H). 20 Obviously, F-equivalence is an equivalence relation on r-boundaried graphs. We now introduce a condition that implies F-equivalence, which will be combinatorially easier to handle. Suppose G is an r-boundaried graph, with boundary (u1, u2, . . . , ur). Define the extended graph ext(G) as follows: for each i ∈ [r], introduce a new vertex copy(ui) that is adjacent only to ui. Suppose further that Q is some graph. If φ is a partial function from V (Q) to [r], then by a φ-rooted immersion model of Q in ext(G) we mean an immersion model of Q in ext(G) that is faithful w.r.t. φ in the following sense: for each vertex v of Q that has defined image under φ, v is mapped to copy(uφ(v)) in the immersion model. Fix a positive integer r and recall that MAXF = maxH∈F (cid:107)H(cid:107). Consider a graph Q and a partial function φ from V (Q) to [r]. We call the pair (Q, φ) relevant if the following conditions hold: • (cid:107)Q(cid:107) ≤ (r + 1)MAXF and Q has no isolated vertices; and • φ is non-empty, i.e., it assigns a value to at least one argument. The set of relevant pairs will be denoted by Rr,F . Observe that Rr,F ≤ 2poly(r,MAXF ). (13) Indeed, there are at most 2poly(r,MAXF ) graphs with at most (r + 1) · MAXF edges and no isolated vertices, and for each of them there are at most (r + 1)O((r+1)MAXF ) possible partial functions φ. Definition 26. Let r be a positive integer and let G be an r-boundaried graph. For a set S ⊆ Rr,F of relevant pairs, the deletion number of G w.r.t. S is the minimum number of edges that need to be deleted from ext(G) so that it does not admit a φ-rooted immersion model of Q, for each (Q, φ) ∈ S. Note that the edges uicopy(ui), for i ∈ [r], may also be deleted in this definition. The signature of G, denoted σ[G], is the function from subsets of Rr,F to nonnegative integers defined as follows: σ[G](S) = deletion number of G w.r.t. S. The following lemma explains the relation between F-equivalence and signatures. Lemma 27. If two F-free r-boundaried graphs have the same signatures, then they are F-equivalent. Proof. Let G1, G2 be a pair of F-free r-boundaried graphs that have the same signature. For t = 1, 2, r) be the boundary of Gt. Take any r-boundaried graph H, and let (v1, . . . , vr) be its let (ut 1, . . . , ut boundary. We need to prove that OPT(G1 ⊕ H) = OPT(G2 ⊕ H). It suffices to prove that OPT(G1 ⊕ H) ≤ OPT(G2 ⊕ H), because then the converse inequality will follow by symmetry. Throughout the proof, we implicitly identify G1, G2, and H with their copies in the gluings G1 ⊕ H and G2 ⊕ H. We also use the extended graphs ext(G1) and ext(G2), with the notation copy(·), and injective mappings ι1 : E(ext(G1)) → E(G1 ⊕ H) ι2 : E(ext(G2)) → E(G2 ⊕ H) defined as follows. If e ∈ E(G1), then ι1(e) = e, and if e = u1 i ) for some i = 1, . . . , r, then ι1(e) = u1 Suppose F1 is an optimum-size subset of edges of G1 ⊕ H such that (G1 ⊕ H)− F1 is F-free; that is, F1 = OPT(G1 ⊕ H). Let L1 = ι−1 1 (F1 \ E(H)); that is, L1 consists of all edges of ext(G1) that correspond to edges of F1 under mapping ι1. Let S be the set of all relevant pairs (Q, φ) ∈ Rr,F for which ext(G1)−L1 does not admit a φ-rooted immersion model of Q. Since G1 and G2 have the same i vi. Mapping ι2 is defined in the same way. i copy(u1 21 G2 H Q ⇒ Figure 4: Construction of graph Q from the immersion model I. The model I is depicted on the left panel; the red vertices are the images of the vertices of H. The obtained graph Q is on the left panel. The yellow vertices are the images of vertices of H that lie within V (G2), whereas the green vertices are the copies of boundary vertices that are included in the vertex set of Q. The former graphs G2 and H are depicted in very light grey in order to show from where the different parts of Q come from. signatures, there is a subset of edges L2 ⊆ E(ext(G2)) with L2 ≤ L1 such that ext(G2) − L2 also does not admit a φ-rooted immersion model of Q, for every (Q, φ) ∈ S. We define F2 ⊆ E(G2 ⊕ H) as follows: F2 = ι2(L2) ∪ (F1 ∩ E(H)). Since L2 ≤ L1, we also have that F2 ≤ F1. Hence it suffices to show that (G2 ⊕ H) − F2 is F-free. For the sake of contradiction suppose that (G2 ⊕ H) − F2 contains an immersion model I of some graph H ∈ F. Clearly I must use at least one edge outside E(H), because otherwise I would be also an immersion model of H in (G1 ⊕ H) − F1, which is F-free by assumption. Also, I must use at least one edge outside E(G2), because otherwise it would be an immersion model of H in G2, which is F-free by the supposition of the lemma. Take any edge e of H, and let Pe be the path in the model I that is the image of e. Each vertex traversed by Pe belongs either to V (G2) or to V (H). For each maximal interval I on Pe of vertices belonging to V (G2), consider the path in ext(G2) constructed as follows: take all edges of Pe incident to the vertices of I (so including the edge preceding and succeeding I on the path), and map them to the edges of ext(G2) using ι−1 2 . This image is a path in ext(G2) whose endpoints are either copies copy(u2 Starting from H, construct a graph Q as follows (see Fig. 4 for reference). The vertex set of Q consists of all the vertices of H that are mapped to V (G2) in the model I, plus the set of all the i vi is used in the model I. The edges of Q are defined by vertices copy(u2 the construction of the previous paragraph: every path R constructed for some maximal interval on some path Pe gives rise to an edge in Q connecting the endpoints of R. It is now easy to see that the above paths define a φ-rooted immersion model of Q in ext(G2) − L2, where φ assigns each vertex copy(u2 We now verify that (Q, φ) is a relevant pair. First, since every graph of F is connected and has at least one edge, it is immediate that Q has no isolated vertices. For every edge e of H, the path Pe can alternate between V (G2) and V (H) at most r times, and hence e can give rise to at most r + 1 edges in Q; it follows that i ) of some boundary vertices, or the original endpoints of Pe. i ) for which the edge u2 i ) its index i. (cid:107)Q(cid:107) ≤ (r + 1)(cid:107)H(cid:107) ≤ (r + 1)MAXF . Finally, since I uses at least one edge outside E(H) and at least one edge outside E(G2), we conclude that neither Q nor φ is empty. 22 Since (Q, φ) is a relevant pair for which there is a φ-rooted immersion model of Q in ext(G2)− L2, we have that (Q, φ) /∈ S. By the way we defined S, it follows that there is a φ-rooted immersion model of Q in ext(G1) − L1. Take the edges of this model, map them according to ι1 to edges of G1 ⊕ H, and add all the edges used by model I within E(H). It can be now easily seen that all these edges form an immersion model of H in (G1 ⊕ H) − F1, which is a contradiction with (G1 ⊕ H) − F1 being F-free. It is not hard to see that the deletion numbers in fact cannot be too large. Lemma 28. If G is an r-boundaried graph and S ⊆ Rr,F is a subset of relevant pairs, then the deletion number of G w.r.t. S is at most r. Proof. Let (u1, . . . , ur) be the boundary of G. Since φ is non-empty for each (Q, φ) ∈ S, in order to make ext(G) not admit φ-rooted minor of Q one can always remove all the edges uicopy(ui), for i ∈ [r]. Hence, the deletion number of G w.r.t. S is upper bounded by the number of these edges, that is, by r. Lemmas 27 and 28, together with (13), immediately yield the following. Corollary 29. The number of possible signatures of r-boundaried graphs is at most 222poly(r,MAXF ) Consequently, F-equivalence has at most this many equivalence classes. . Finally, we need the algorithmic tractability of signatures. Lemma 30. For every positive integer r, there exists a linear-time algorithm that, given an F-free r-boundaried graph G, computes its signature. Proof. For each such subset S of relevant pairs, the deletion number of G w.r.t. S can be computed in linear time as follows. First, observe that, due to G being F-free, by Proposition 6 and Theorem 8 we infer that the treewidth of ext(G) is bounded by a constant depending on F only. Hence, using Bodlaender's algorithm [3] we can compute in linear time a tree decomposition of ext(G1) of constant width. Then, on this tree decomposition we apply the optimization variant of Courcelle's theorem, due to Arnborg et al. [1] (see also [13, Theorem 7.12] for a modern presentation). For this, we observe that finding the minimum cardinality of an edge subset of ext(G) that hits all φ-rooted immersion model of Q, for each (Q, φ) ∈ S, can be expressed in a straightforward way as an MSO2 optimization problem; the formula's length depends only on r and F. Thus, the algorithm of Arnborg et al. [1] solves this optimization problem in linear-time, yielding the deletion number of G w.r.t. S. By applying this procedure to all subsets S of relevant pairs, whose number is bounded by a constant depending on r and F, we obtain the whole signature of G. We are ready to prove the basic protrusion replacement lemma, i.e., Lemma 23. Proof of Lemma 23. We first describe the algorithm that computes G(cid:48). Recall that, by Corollary 29, for any r ≤ 2bF the number of possible signatures of r-boundaried graphs is bounded by a constant depending F only. Define the following table T : for each r ≤ 2bF and each possible signature ρ of r-boundaried graphs, we store in T the smallest, in terms of the number of edges, F-free r-boundaried graph Gρ for which σ[Gρ] = ρ. If no F-free r-boundaried graph has signature ρ, a marker ⊥ is stored instead. Note that table T depends only on family F, and hence can be hardcoded in the algorithm. Define cF to be the largest number of edges among the graphs stored in T ; then cF is a constant depending on F only. 23 Let r = δ(X). Based on G[X] and G − X, define r-boundaried graphs GX and H as follows. The underlying graph of GX is G[X], and of H is G − X. Fix an arbitrary ordering e1, e2, . . . , er of the edges of δ(X). Then the i-th boundary vertex of GX is the endpoint of ei that lies in X, and the i-th boundary vertex of H is the second endpoint of ei, the one that lies outside of X. It follows that G = GX ⊕ H. Using the algorithm of Lemma 30, compute the signature ρ := σ[GX ]. Note here that GX is F-free by the supposition that X is a protrusion. Since GX has signature ρ, it follows that table T stores some r-boundaried graph Gρ with the same signature. As (cid:107)G[X](cid:107) = (cid:107)GX(cid:107) > cF and (cid:107)Gρ(cid:107) ≤ cF , we have that (cid:107)Gρ(cid:107) < (cid:107)GX(cid:107). Define G(cid:48) := Gρ ⊕ H. As (cid:107)Gρ(cid:107) < (cid:107)GX(cid:107), we have that (cid:107)G(cid:48)(cid:107) < (cid:107)G(cid:107). Since GX and Gρ have the same signatures and are both F-free, by Lemma 27 we have that they are F-equivalent. Hence OPT(G) = OPT(GX ⊕ H) = OPT(Gρ ⊕ H) = OPT(G(cid:48)), and we conclude that G(cid:48) can be output by the algorithm. ρ be the image of F (cid:48) H = F (cid:48) ∩ E(H) and let F (cid:48) extended graph ext(Gρ), and let (cid:102)F (cid:48) We now describe the solution lifting algorithm. Suppose we are given a subset F (cid:48) of edges of G(cid:48) ρ = F (cid:48) \ F (cid:48) such that G(cid:48) − F (cid:48) is F-free. Recall that G(cid:48) = Gρ ⊕ H. Let F (cid:48) H; here, we implicitly identify Gρ and H with their copies in the gluing G(cid:48) = Gρ ⊕ H. Consider the ρ under the mapping ι−1 defined as in the proof of Lemma 27: the edges of Gρ are mapped to themselves, while the edges between GX and H are mapped to the corresponding edges between the boundary vertices and their copies in ext(Gρ). Since ext(Gρ) is a graph of constant size, we can compute in constant time the subset S ⊆ Rr,F of those relevant pairs (Q, φ) ∈ Rr,F , for which ext(Gρ) does not admit a φ-rooted immersion model and GX w.r.t S are equal. Hence, there exists a subset (cid:102)FX of edges of ext(GX ) with (cid:102)FX ≤ (cid:102)F (cid:48) of Q. Observe that since the signatures of Gρ and GX are the same, the deletion numbers of Gρ such that also in ext(GX ) − (cid:102)FX there is no φ-rooted immersion model of Q, for each (Q, φ) ∈ S. ρ, Observe that such set (cid:102)FX can be computed in linear time using the algorithm of Arnborg et al. [1] as follows. Just as in Lemma 30, the fact that GX is F-free implies that ext(GX ) has constant treewidth. Hence, we can compute its tree decomposition of constant width using Bodlaender's algorithm [3]; this takes linear time. Then, on this decomposition we run the algorithm of Arnborg et al. [1] for the MSO2 optimization problem defined as follows: find the smallest subset of edges whose removal leaves no φ-rooted immersion model of Q, for each (Q, φ) ∈ S. The algorithm of Arnborg et al. [1] can within the same linear running time also reconstruct the solution, so we are the edges of GX are mapped to themselves, while the edges between the boundary vertices and their copies are mapped to the corresponding edges between GX and H. Define F := FX ∪ F (cid:48) H. By indeed able to construct (cid:102)FX . Let now FX ⊆ E(G) be the image of (cid:102)FX under the mapping ι defined as in the proof of Lemma 27: the construction of FX we have that for every relevant pair (Q, φ) ∈ Rr,F , if ext(GX ) − (cid:102)FX admits a φ-rooted immersion model of Q, then so does ext(Gρ) −(cid:102)F (cid:48) G − F is also F-free. Also, F ≤ F (cid:48) due to (cid:102)FX ≤ (cid:102)F (cid:48) ρ. A simple replacement argument, essentially the same as in the proof of Lemma 27, shows that the F-freeness of G(cid:48) − F (cid:48) implies that ρ, so the solution F can be returned by the solution-lifting algorithm. We henceforth define a replaceable protrusion in G as a 2bF -protrusion X with (cid:107)G[X](cid:107) > cF , where cF is the constant given by Lemma 23. 24 Note that the proof of Lemma 23 a priori does not give any concrete upper bound on the sizes of the replacement graphs stored in table T , and on the obtained constant cF . Also, it is unclear how to compute the table T based on the knowledge of F. Obviously, we do not need the computability of T or any concrete upper bound on cF , because we design algorithms for a family F fixed in advance, so objects that depend on F only may be hard-coded in the algorithms. However, we find it instructive to discuss the matter of computability of T and the bound on cF , at least intuitively. First of all, the algorithm of Arnborg et al. [1] is based on constructing an automaton that traverses the given tree decomposition of a graph. In our case, we have a constant upper bound on the minimum size of the sought set, so we are actually working with a finite-state tree automaton. By tracing the standard translation from MSO2 to tree automata, one can estimate the number of states in the tree automaton constructed by the algorithm. This number is bounded by a tower function of constant height applied to MAXF and the width of the decomposition; this is because the formula expressing the problem has constant quantifier rank. This also gives an upper bound on the minimum size of a tree decomposition that the automaton evaluates to a given state, which directly corresponds to the sizes of graphs stored in table T . The automaton can be explicitly constructed by the algorithm of Arnborg et al. [1], and from the automaton one can retrieve small candidates for graphs stored in T . The above strategy roughly shows that the graphs that are stored in T are of size bounded by a tower function of constant height applied to MAXF and the width of the decomposition. However, based on this idea one can also give a direct proof, as follows. Take any graph G stored in T , and let T be its tree-cut decomposition of width at most bF . With every node x of T one can associate a boundaried graph Gx, which corresponds to the subtree rooted at x; the adhesion between x and its parent forms the boundary. Assume for a moment that G is very large. Suppose first that the depth of T is large, more precisely larger than the total number of signatures of r-boundaried graphs, for r ≤ bF . Then there is some root-to-leaf path in T that contains two nodes x and y, say x being an ancestor of y, for which Gx and Gy have the same signatures. It can be easily seen that the part between Gx and Gy can be "unpumped": we can replace Gx with Gy, obtaining a smaller graph G(cid:48) with the same signature as G. If this unpumping cannot be applied, then the depth of T is bounded by the number of signatures, and Gx can be large only if some node has a large number of children. But then again, a similar unpumping strategy can be applied if the number of children is larger than some constant depending on the number of possible signatures. Thus we obtain an explicit upper bound on the size of a graph that can be stored in T instead of G. Once all these arguments are formalized, one can prove the following result that gives an upper bound on the sizes of graphs that are stored in T . Lemma 31. Suppose r is a positive integer and ρ is a signature of r-boundaried graphs. If there exists an F-free r-boundaried graph with signature ρ, then there is also one with at most 4exp(poly(r, MAXF )) vertices and edges, where 4exp(·) is the 4-times folded exponential function. Note that once we have a computable upper bound, table T may be constructed from F in constant time by brute force. We would like to remark that the same unpumping strategy was recently applied by Chatzidimitriou et al. [7] for the parameter tree-partition width, which is similar to treewidth. The full proof of Lemma 31 will appear in the journal version of this paper. 4.2 Finding excessive protrusions Recall that a replaceable protrusion in a graph G is a 2bF -protrusion X with (cid:107)G[X](cid:107) > cF . To find replaceable protrusions in the input graph, we need to assume some additional connectivity constraint (which will be implied from a connected tree-cut decomposition) -- this is captured by 25 the following definition. The larger protrusion size is needed to make any connected component of the protrusion replaceable. Definition 32. A 2bF -protrusion B in a connected graph G is called excessive if (cid:107)G[B](cid:107) > 2bF · cF and G − B has at most two connected components. Replaceable protrusions could be found easily if we allowed a (far worse) running time of the form (cid:107)G(cid:107)O(bF ), but this would affect the running times in both our main results. With the above definition in hand, we use the following two techniques instead. The first is important cuts, introduced by Marx [32], see also the exposition in [13, Chapter 8.2]. Intuitively, we consider (S, T )-cuts (i.e., edge sets whose removal separates the vertex sets S and T ) that are 'pushed' towards T , meaning that we make the set of vertices reachable from S inclusion-wise maximal, without increasing the cut size. Such cuts can be effectively enumerated, allowing us to find a protrusion's boundary. Definition 33. Consider a graph G and disjoint vertex sets S, T ⊆ V (G). Let ∆ ⊆ E(G) be an (S, T )-cut and let R be the set of vertices reachable from S in G − ∆. We say ∆ is an important cut if it is inclusion-wise minimal and there is no (S, T )-cut ∆(cid:48) with ∆(cid:48) ≤ ∆ such that R(cid:48) ⊃ R, where R(cid:48) is the set of vertices reachable from S in G − ∆(cid:48). Lemma 34 ( [32]). Let S, T ⊆ V (G) be two disjoint sets of vertices in a graph G and let k ≥ 0. The set of all important (S, T )-cuts of size at most k can be enumerated in time O(4k · k · (cid:107)G(cid:107)). The second technique we use is randomized contractions by Chitnis et al. [9]. While randomized refers to the intuition behind this technique, following [9] we use the technique of splitters of Naor et al. [34] to make its usage deterministic. A convenient black-box access to splitters is given by the following lemma. Lemma 35 ( [9]). Given a set U of size m together with integers 0 ≤ a, b ≤ m, one can in time 2O(min(a,b) log(a+b)) · m log m construct a family F of at most 2O(min(a,b) log(a+b)) · log m subsets of U , such that the following holds: for any sets A, B ⊆ U with A ∩ B = ∅, A ≤ a, B ≤ b, there exists a set T ∈ F with A ⊆ T and B ∩ T = ∅. These two techniques allow us to reduce excessive protrusions: we use the randomized contractions technique to find a large enough subset of a presumed excessive protrusion, after which important cuts allow us to find a boundary that makes this subset a replaceable protrusion. Lemma 36. There is an algorithm that, given a connected graph G, runs in time O((cid:107)G(cid:107) log (cid:107)G(cid:107)·G2) and either correctly concludes that G does not contain any excessive protrusion, or it outputs some replaceable protrusion in G. Proof. We describe the algorithm under the assumption that G contains some excessive protrusion; in this case, we show that the algorithm can compute some replaceable protrusion. If the algorithm fails to find some replaceable protrusion, then this certifies that G has no excessive protrusions, and this conclusion can be reported by the algorithm. Let B be an excessive protrusion in G. Since G is connected and B is a 2bF -protrusion, B induces at most 2bF connected components in G. Let B(cid:48) be the largest one (in the number of edges). Then clearly B(cid:48) is a 2bF -protrusion with (cid:107)B(cid:48)(cid:107) > cF and with G[B(cid:48)] connected. Furthermore, G − B(cid:48) has at most two components, because G − B has, and every connected component of G[B] is adjacent to at least one of the components of G − B, due to the connectivity of G. We consider B(cid:48) instead of B from now on. 26 Let T be a tree spanning a subset of B(cid:48) with min(B(cid:48), cF + 2) vertices. Then (cid:107)T(cid:107) ≤ cF + 1 and (cid:107)G[V (T )](cid:107) > cF . Let s1, s2 be arbitrary vertices in the two components of G − B(cid:48) (set s1 = s2 if it has only one component) and set S = {s1, s2}. To find T , we now apply Lemma 35 for universe U := E(G) and constants a := (cid:107)T(cid:107) ≤ cF + 1 and b := δ(B(cid:48)) ≤ 2bF . Thus, in time O((cid:107)G(cid:107) log (cid:107)G(cid:107)) we construct a family F of O(log (cid:107)G(cid:107)) subsets of E(G) with the following guarantee: for at least one F ∈ F, we have E(T ) ⊆ F and δ(B(cid:48)) ∩ F = ∅. The algorithm guesses this set F ∈ F and the vertices of S (by iterating over F · G2 possibilities); we shall consider the guess successful if F indeed has the above property and S indeed intersects each component of G − B(cid:48). Make the edges of F undeletable by considering the graph ¯G obtained from G by contracting all edges in F (we use the same vertex labels in ¯G by abuse of notation). Observe that δ(B(cid:48)) is an (S, V (T ))-cut in G of size at most 2bF . If the guess was successful, it is an (S, V (T ))-cut of size at most 2bF in ¯G too, and furthermore by choice of S, the set of vertices reachable from S in ¯G− δ(B(cid:48)) is precisely V ( ¯G) \ B(cid:48). Consider a corresponding important cut, that is, let ∆ ⊆ E( ¯G) be an important (S, V (T ))-cut of size at most 2bF such that the set of vertices reachable from S in ¯G − ∆ contains V ( ¯G) \ B(cid:48) (the existence of such a cut is easily proved, see [13, 32]). Let ¯X be the set of vertices reachable from T in ¯G − ∆; then ¯X ⊆ B(cid:48) and δ( ¯X) ⊆ ∆. Let X be the set of vertices in G that gets contracted to ¯X in ¯G. Then also X ⊆ B(cid:48) and δ( ¯X) ⊆ ∆ (as a subset of E(G)\ F ). That is, X is F-free (because B(cid:48) is) and δ(X) ≤ 2bF , meaning X is a 2bF -protrusion. As X contains V (T ), we have (cid:107)G[X](cid:107) ≥ (cid:107)G[V (T )](cid:107) > cF , meaning X is a replaceable protrusion. Since ∆ is an important cut of size at most 2bF , we can use Lemma 34 to find it, and thus to find X, in O((cid:107)G(cid:107)) time. Therefore, for at least one of O(G2 log (cid:107)G(cid:107)) guesses, the algorithm will find a replaceable protrusion. To handle unsuccessful guesses, the algorithm checks if the obtained set X is in fact a replaceable protrusion; this takes O((cid:107)G(cid:107)) time for each guess, by Proposition 9. We remark that we only defined excessive protrusions in connected graphs. Note that if B is an excessive protrusion in a connected component H of G, it would not necessarily be an excessive protrusion in G, since G− B may have more components than H − B (they are however not adjacent to B). We will thus consider the property that no component of G has an excessive protrusion. By this we mean that for each connected component H of G, there is no excessive protrusion in H. By exhaustively (at most (cid:107)G(cid:107) times) executing the algorithm of Lemma 36 and replacing any obtained protrusion using Lemma 23, we can get rid of all excessive protrusions. We formalize this in the following lemma, which will serve as the abstraction of protrusion replacement in the sequel. Lemma 37 (Exhaustive Protrusion Replacement). There is an algorithm that, given a graph G, runs in time O((cid:107)G(cid:107)2 log (cid:107)G(cid:107) · G2) and computes a graph G(cid:48) such that OPT(G) = OPT(G(cid:48)), (cid:107)G(cid:48)(cid:107) ≤ (cid:107)G(cid:107), and no connected component of G(cid:48) has an excessive protrusion. Moreover, there exists a solution-lifting algorithm that works as follows: given a subset F (cid:48) of edges of G(cid:48) for which G(cid:48) − F (cid:48) is F-free, the algorithm runs in time O((cid:107)G(cid:107)2) and outputs a subset F of edges of G such that F ≤ F (cid:48) and G − F is F-free. Proof. Inspect every connected component H of G, and to each of them apply the algorithm of Lemma 36, which runs in time O((cid:107)G(cid:107) · log (cid:107)G(cid:107) · G2). This algorithm either concludes that H has no excessive protrusion, or finds some replaceable protrusion X in H. Then X is also a replaceable protrusion in G, so by applying Lemma 23 to X we can compute in linear time a new graph G(cid:48) with OPT(G(cid:48)) = OPT(G) and (cid:107)G(cid:48)(cid:107) < (cid:107)G(cid:107). Having found G(cid:48), we can restart the whole algorithm on G(cid:48). Eventually, the algorithm of Lemma 36 concludes that each component has no excessive 27 protrusions and can hence output G. The solution-lifting algorithm follows by iteratively applying the solution-lifting algorithm of Lemma 23 for all the consecutive replacements performed above. Since the number of edges strictly decreases in each iteration, the number of iterations is bounded by the number of edges of the original graph G. Therefore, the claimed running time follows. 5 Constant-factor approximation It would be ideal if just applying the Exhaustive Protrusion Replacement (Lemma 37) reduced the size of the graph to linear in OPT. Then, we would already have a linear kernel, and taking all its edges would yield a constant-factor approximation. Unfortunately, there are graphs with no excessive protrusions, where the size is not bounded linearly in OPT. To see this, observe that even an arbitrarily large group of parallel edges is not a protrusion, so our current reduction rules will not reduce their multiplicity, even if they amount to 99% of the graph. Hence, we need to find a way to discover and account for such groups (we remark here that reducing each to O(OPT) would be relatively easy, giving a quadratic kernel only, though). More generally, the structures that turn out to be problematic are large groups of constant-size 2-protrusions attached to the same pair of vertices; a group of parallel edges is a degenerated case of this structure. To describe the problematic structures formally, we introduce the notion of a bouquet. Pruning bouquets and sets of parallel edges to constant size does not give an equivalent graph (because a larger bouquet may always require a larger number of edge deletions). However, the edge set of the resulting pruned graph intersects some optimal solution of the original graph; this is because for any deleted element, pruning preserves some number of isomorphic elements. Moreover, since the intersection is a solution for the pruned graph and the pruned graph has no bouquets, we can show that the number of edges of the pruned graph is linear in the size of the intersection. Pruning thus gives a procedure that finds a subset of edges which intersects an optimal solution and such that the size of the subset is at most a constant factor larger than the size of this intersection. By iteratively finding such a set and removing it, we obtain a solution that is at most a constant factor larger than the optimum. In the next section we will leverage the obtained constant-factor approximation to reduce all bouquets at once, thus achieving a linear kernel. 5.1 Bouquets Let us define the following constant (recall that MAXF = maxH∈F (cid:107)H(cid:107)) dF := max{2bF · cF + 2bF , 3MAXF} + 1 We now introduce the notions of bouquets and thetas. Intuitively, a bouquet is a family of at least dF isomorphic 2-protrusions, while a theta is a set of at least dF parallel edges. Definition 38. Consider a graph G, a set U ⊆ V (G) and a family of 2-protrusions {Si}i∈I such that for each i ∈ I: • N (Si) = U (implying U ≤ 2); • G[Si] is connected; and • G[U ∪ Si] is isomorphic to G[U ∪ Sj] for all i, j ∈ I, with an isomorphism that maps each vertex of U to itself. 28 We call such a family a bouquet attached to U if it is maximal under inclusion (i.e. there is no proper superfamily which is also a bouquet) and has at least dF elements. The edge set of the bouquet is the set of all edges incident to some Si. Definition 39. For two vertices u, v ∈ V (G), a theta attached to {u, v} is a set of edges between u and v that is maximal under inclusion and has at least dF elements. The constant dF is chosen so that a protrusion containing a set to which a bouquet (or theta) is attached is large enough to be excluded as an excessive protrusion, and so that any immersion of a graph of F cannot simultaneously intersect all elements of a bouquet. Indeed, in any immersion of some H ∈ F in a graph G, the image of an edge of H is a path in G, which visits every vertex of the bouquet's attachment at most once, and hence intersects at most three elements of the bouquet. Thus in total, the immersion model intersects at most maxH∈F 3(cid:107)H(cid:107) = 3MAXF elements of the bouquet or theta, which is less than dF . We now show that the number of edges of a graph with no excessive protrusions, no bouquets and no thetas is linearly bounded in the optimum solution size, which formalizes the intuition that these structures are the only obstacles preventing the graph from being a linear kernel. The following well-known notion and lemma are useful for proving such bounds. For a rooted forest T and a set M ⊆ V (T ), the least common ancestor closure (lca-closure) of M is the set lca(M ) ⊆ V (T ) obtained from M by repeatedly adding to it the least common ancestor of every pair of nodes in the set (unless the nodes are in different connected components of the forest T ). Lemma 40 ([19]). Let T be a rooted forest and M ⊆ V (T ). Then lca(M ) ≤ 2M and every connected component C of T − lca(M ) has at most two neighbors in T . Lemma 41. Let G be a connected graph with no excessive protrusions, no bouquets and no thetas. Then either G is F-free, or (cid:107)G(cid:107) ≤ c · OPT(G) for some constant c depending on F only. Proof. Denote k := OPT(G) and suppose G is not F-free, that is, k ≥ 1. Let F ⊆ E(G) be a set of k edges such that G − F is F-free. By Corollary 20, G − F has a neat tree-cut decomposition (T,X = {Xt, : t ∈ V (T )}) with width(cid:48)(T,X ) ≤ bF . Let M ⊆ V (T ) be the lca-closure of the set of the nodes of T that correspond to the bags which contain some vertices incident to edges of F . Since F ≤ k there are at most 2k such bags and, by Lemma 40, we have that M ≤ 4k and that every connected component of T − M has at most two neighbors in T ; see Figure 5. Recall that by XT (cid:48) we denote the union of bags at the nodes of a subtree T (cid:48) of T . Claim 42. For any connected component T (cid:48) of T − M , (cid:107)G[XT (cid:48)](cid:107) ≤ 2bF · cF . Proof. Suppose to the contrary that (cid:107)G[XT (cid:48)](cid:107) > 2bF · cF . We verify that then XT (cid:48) is an excessive protrusion. Indeed, XT (cid:48) has no vertices incident to F , so G[XT (cid:48)] is F-free. Moreover, T (cid:48) has at most two neighbors in T , so δG(XT (cid:48)) ≤ 2bF and T − V (T (cid:48)) has at most two components adjacent to T (cid:48). By the properties of neat decompositions, the unions of bags of these two components of T − V (T (cid:48)) induce at most two connected components in G − F ; in other words, G − F − XT (cid:48) has at most two connected components adjacent to XT (cid:48), say C1, C2. Then NG−F (XT (cid:48)) ⊆ C1 ∪ C2 and since XT (cid:48) has no vertices incident to F , also NG(XT (cid:48)) ⊆ C1 ∪ C2. Since G is connected, this implies G − XT (cid:48) has at most two connected components (because every vertex of G − XT (cid:48) has a path connecting it to XT (cid:48) in G, which must visit NG(XT (cid:48))). This shows that XT (cid:48) is an excessive protrusion, contradicting (cid:121) assumptions. 29 We set c(cid:48) := 2bF · cF . Each connected component of T − M has exactly one or exactly two neighbors in M ; it cannot have zero neighbors in M , as it would then induce a component in G − F with no vertices incident to F , contradicting that G is connected and not F-free. Observe that the number of components that have exactly two neighbors in M is at most M − 1, because replacing each such component with an edge connecting its neighbors yields a forest with vertex set M . It remains to bound the number of components in T − M with exactly one neighbor in M . Suppose T1, . . . , Tp are those connected components of T − M for which the neighborhood in T is exactly t, for some t ∈ M . Again, by XTi we denote the union of the bags at the nodes of Ti. By Corollary 21, at most 2bF + 1 of them are not connected with neat adhesions to t, so assume w.l.o.g. that T1, . . . , Tp−2bF−1 are. That is, NG(XTi) is a non-empty subset of Xt of size at most two, for all i = 1, . . . , p − 2bF − 1. Since there are at most b2F such subsets of size at most 2, at least p−2bF−1 ≥ p/b2F − 3 of the sets XTi have the same neighborhood U in G. By the neatness of the decomposition, each G[XTi] is connected and moreover (cid:107)G[XTi](cid:107) ≤ c(cid:48) by Claim 42. This implies in particular that XTi ∪ U ≤ c(cid:48) + 3. This means that there are at most (c(cid:48) + 4)2c(cid:48) possible isomorphism types for G[XTi ∪ U ]. If there were at least dF components with the same isomorphism type, they would form a bouquet. Hence p/b2F − 3 ≤ (c(cid:48) + 4)2c(cid:48) · dF , meaning that b2F p ≤ ((c(cid:48) + 4)2c(cid:48) · dF + 3) · b2F . We define c(cid:48)(cid:48) := ((c(cid:48) + 4)2c(cid:48) · dF + 3) · b2F . Therefore, T − M is partitioned into at most M − 1 + c(cid:48)(cid:48) · M ≤ (c(cid:48)(cid:48) + 1) · M connected components. By Claim 42, for each of these components, the vertices contained in its bags induce a subgraph with at most c(cid:48) edges. In addition to these edges, the edge set of G contains only: • k edges of the deletion set F ; • dF · b2F edges in G[Xt] for each t ∈ M (G[Xt] has at most bF vertices and every pair has less than dF edges in between, as G has no thetas); and • up to ((c(cid:48)(cid:48) + 1) · M + M) · bF = (c(cid:48)(cid:48) + 2) · M · bF edges between parts of the partition of V (T ) given by individual elements of M and connected components of T − M (each edge of T between different parts yields at most bF edges). Since M ≤ 4k, we infer that the number of edges in G is at most 4(c(cid:48)(cid:48) + 1)k · c(cid:48) + k + 4k · dF · b2F + 4(c(cid:48)(cid:48) + 2)k · bF = c(cid:48)(cid:48)(cid:48) · k, for a constant c(cid:48)(cid:48)(cid:48) := 4c(cid:48)(c(cid:48)(cid:48) + 1) + 1 + 4dF · b2F + 4bF (c(cid:48)(cid:48) + 2). 5.2 Finding a constant-factor approximation piece by piece To handle bouquets and thetas algorithmically, we first show that they are disjoint, as otherwise they would constitute a large protrusion. In this subsection, we frequently use the observation that, in a connected graph, a 2-protrusion with more than 2bF · cF edges is an excessive protrusion. Indeed, if X is a 2-protrusion in a connected graph G, then it is always the case that G − X has at most two connected components, due to δ(X) ≤ 2. Lemma 43. Let G be a connected graph with no excessive protrusions. Then every two bouquets and/or thetas in G have disjoint edge sets. Furthermore, if a bouquet or theta is attached to U ⊆ V (G), then U is disjoint with all elements of any bouquet. 30 M F Figure 5: A graph G with a solution F (five red dotted edges), in a tree-cut decomposition of G− F . The set M used in Lemma 41 is highlighted in blue: three bags incident to F , a fourth central one in their lca-closure. Remaining components turn out to have sizes bounded by a constant (light gray). Two bouquets are present, their attachments visible as light yellow vertices. Proof. Suppose a bouquet or theta X is attached to UX and a bouquet Y = {Yj}j∈J is attached to UY . Observe that either UX = 1 or the two vertices of UX are joined by at least dF > 2 edge-disjoint paths in G; so in any case all of UX is on one side of the cut δ(Yj), for each j ∈ J. If UX ⊆ Yj for some j, then all but possibly two elements of X would be contained in the side Yj of this cut. Hence Yj would be a 2-protrusion with (cid:107)G[Yj](cid:107) ≥ dF − 2 > 2bF · cF and thus an excessive protrusion, contradicting assumptions. We infer that UX is disjoint with the elements of any bouquet, which concludes the second part of the claim. i∈I Xi and Y =(cid:83) bouquet attached to UY . Let X =(cid:83) To show the first part of the claim, first notice that two thetas cannot have intersecting edge sets, as they are maximal sets of parallel edges. Secondly, if a theta contained an edge from the edge set of a bouquet Y = {Yj}j∈J , then either it would be an edge of δ(Yj) for some j ∈ J, contradicting δ(Yj) ≤ 2; or it would be an edge of G[Yj], again implying that (cid:107)G[Yj](cid:107) > 2bF · cF and that thus Yj is an excessive protrusion, contradicting assumptions. Finally, consider the case X = {Xi}i∈I is a bouquet attached to UX and Y = {Yj}j∈J is a j∈J Yj. We already showed that UX ∩ Y = ∅ and symmetrically UY ∩ X = ∅. Therefore UX , UY ⊆ V (G) \ (X ∪ Y ). We infer that the edge-sets of the two bouquets can intersect only if the sets X and Y intersect. Hence Xi ∩ Yj (cid:54)= ∅ for some i ∈ I, j ∈ J. If there was an edge between some u ∈ Xi ∩ Yj and some v ∈ Yj \ Xi, then v ∈ N (Xi) = UX and v ∈ Yj, contradicting UX ∩ Y = ∅. Hence there is no edge between Xi ∩ Yj and Yj \ Xi. Since Yj is connected and Xi ∩ Yj is non-empty, this implies Yj ⊆ Xi. A symmetric reasoning yields that Xi ⊆ Yj, so Xi = Yj. But then UX = UY and all the elements of both bouquets are pairwise isomorphic with an isomorphism that fixes UX = UY . We infer that the union of the two bouquets is also a bouquet. Hence, by maximality of bouquets, we conclude that {Xi}i∈I and {Yj}j∈J are in fact the same bouquet. 31 We now proceed to formalizing the procedure of pruning all bouquets and thetas to constant size. We show that the remaining edge set, named ∆, has the property that its removal from G strictly decreases OPT(G) and its size is linear in that decrement. Lemma 44. Given a connected graph G with no excessive protrusion that is not F-free, one can find in in time O(G3) a set ∆ ⊆ E(G) such that (for some c depending on F only): ∆ ≤ c · (OPT(G) − OPT(G − ∆)). OPT(G − ∆) < OPT(G) and Proof. The algorithm finds all bouquets and thetas and deletes all but dF − 1 elements from each. More precisely, the algorithm first deletes all but dF − 1 edges from each theta in G, resulting in a subgraph G(cid:48). Note that since dF − 1 > 2bF , this reduction of thetas cannot introduce excessive protrusions in the graph and hence remaining bouquets are disjoint in the sense of Lemma 43. The algorithm then sets V (cid:48) := V (G(cid:48)) = V (G), finds all bouquets in G(cid:48) and deletes from V (cid:48) all vertices of all but dF − 1 elements of each bouquet. The algorithm then outputs ∆ := E(G(cid:48)[V (cid:48)]). Bouquets in G(cid:48) can be found by checking all possible attachments U of size at most 2 and all components of G − U containing at most 2bF · cF edges (2-protrusions cannot have more edges, as they would form excessive protrusions otherwise). There are O(G2) possible attachments U and checking all components of G − U for any U takes time O(G), hence the running time follows. To prove that ∆ = E(G(cid:48)[V (cid:48)]) has the claimed properties, let us first show that G(cid:48)[V (cid:48)] is not F-free; we use the following slightly more general statement later. Claim 45. Let S ⊆ V (G). If G(cid:48)[V (cid:48) ∩ S] is F-free, then so is G(cid:48)[S]. If G(cid:48)[S] is F-free, then so is G[S]. In particular, G(cid:48)[V (cid:48)] is not F-free. Proof. Suppose G[S] (or G(cid:48)[S]) is not F-free. Then there is an immersion model of a graph from F in G[S] (or G(cid:48)[S]). Since such a model intersects at most dF − 1 elements of any theta or bouquet, we can find an immersion model that intersects only the elements that were not deleted from G when constructing G(cid:48), nor from V (cid:48) when constructing G(cid:48)[V (cid:48)]. This means G(cid:48)[S] and G(cid:48)[V (cid:48) ∩ S] also contain an immersion of a graph in F, that is, they are not F-free. (cid:121) Consider now an optimal solution F ⊆ E(G) for G. Then F ∩ ∆ is a solution (not necessarily optimal) for the subgraph G(cid:48)[V (cid:48)], meaning F ∩ ∆ is non-empty (as G(cid:48)[V (cid:48)] is not F-free) and OPT(G(cid:48)[V (cid:48)]) ≤ F ∩ ∆. Observe that since OPT(G) = F, we have OPT(G) − OPT(G − F ∩ ∆) = F ∩ ∆. Hence OPT(G) − OPT(G − ∆) ≥ F ∩ ∆, and in particular, OPT(G − ∆) < OPT(G). We show in the three claims below that G(cid:48)[V (cid:48)] is connected and has no excessive protrusions, no bouquets and no thetas. Therefore, by Lemma 41, G(cid:48)[V (cid:48)] has at most c · OPT(G(cid:48)[V (cid:48)]) edges, for some constant c depending on F only. Using the above inequalities, we reach the desired conclusion: ∆ = E(G(cid:48)[V (cid:48)]) ≤ c · OPT(G(cid:48)[V (cid:48)]) ≤ c · F ∩ ∆ ≤ c · (OPT(G) − OPT(G − ∆)). It remains to show that G(cid:48)[V (cid:48)] is indeed connected, has no excessive protrusions, no bouquets and no thetas. Clearly G(cid:48) has no theta and thus G(cid:48)[V (cid:48)] has no theta either. Any edge or path deleted in the construction can be replaced with one that was not deleted, hence G(cid:48)[V (cid:48)] is connected. Claim 46. G(cid:48) has no excessive protrusions. 32 Proof. Suppose S ⊆ V (G(cid:48)) = V (G) is an excessive protrusion in G(cid:48). If there was a theta in G attached to a set U with one vertex in S and the other outside of S, then in G(cid:48) there would still be least dF − 1 edges connecting S and V (G(cid:48)) \ S, contradicting that δG(cid:48)(S) ≤ 2bF < dF − 1. Hence there is no such theta and, in particular, δG(cid:48)(S) = δG(S). Since S is not an excessive protrusion in G, there must be a theta in G(cid:48) with an attachment U contained in S. Thus G[S] has at least dF edges, which is more than 2bF · cF . As S is an excessive protrusion in G(cid:48), G(cid:48) − S has at most two connected components and thus so does G − S. Note that since S is a 2bF -protrusion in G(cid:48), we have δG(S) = δG(cid:48)(S) ≤ 2bF and since G(cid:48)[S] is F-free, so is (cid:121) G[S] (Claim 45). Therefore S is an excessive protrusion in G, a contradiction. Claim 47. G(cid:48)[V (cid:48)] has no excessive protrusions. Proof. Suppose S is an excessive protrusion in G(cid:48)[V (cid:48)]. Since it is not an excessive protrusion in G(cid:48), it must be the case that S had more incident edges in G(cid:48) than in G(cid:48)[V (cid:48)], i.e. δG(cid:48)(S) (cid:41) δG(cid:48)[V (cid:48)](S). By the construction of G(cid:48), we infer that there is a bouquet {Yj}j∈J in G(cid:48) attached to some UY and a j ∈ J such that Yj was removed when constructing V (cid:48) and was adjacent to S. Since N (Yj) = UY , we have that UY ∩ S (cid:54)= ∅. We claim that UY ⊆ S. If UY has one vertex this is clear. Otherwise, if UY has two vertices, then at least dF − 1 elements of the bouquet connect them in G(cid:48)[V (cid:48)], yielding a family of more than 2bF edge-disjoint paths between them. Thus UY lies entirely on one side of the cut δG(cid:48)[V (cid:48)](S), because δG(cid:48)[V (cid:48)](S) ≤ 2bF . Since UY ∩ S (cid:54)= ∅, we conclude that UY ⊆ S. Similarly, we deduce that every other bouquet in G(cid:48) has an attachment fully contained in either S or in V (cid:48) \ S. Recall that V (cid:48) is obtained from V (G(cid:48)) by removing vertices of some elements from each bouquet. It follows that δG(cid:48)[V (cid:48)](S) is a cut in G(cid:48) too. More precisely, let S∗ ⊆ V (G(cid:48)) be the set consisting of S and those elements of bouquets deleted when constructing V (cid:48) that were attached to vertices in S. Then δG(cid:48)(S∗) = δG(cid:48)[V (cid:48)](S). Note that as S is a 2bF -protrusion in G(cid:48)[V (cid:48)], we have δG(cid:48)(S∗) = δG(cid:48)[V (cid:48)](S) ≤ 2bF and since G(cid:48)[S] = G(cid:48)[V (cid:48) ∩ S∗] is F-free, so is G(cid:48)[S∗] (Claim 45). Thus S∗ is a 2bF -protrusion in G(cid:48). Since UY ⊆ S ⊆ S∗, S∗ must contain all elements of {Yj}j∈J except for at most δG(cid:48)(S∗) ≤ 2bF . Consequently, (cid:107)G(cid:48)[S∗](cid:107) ≥ dF − 2bF > 2bF · cF . As S is an excessive protrusion in G(cid:48)[V (cid:48)], we have that G(cid:48)[V (cid:48)] − S has at most two connected components. The graph G(cid:48) − S∗ can be obtained from G(cid:48)[V (cid:48)] − S by reintroducing elements of bouquets (which induced connected subgraphs) with attachments in V (cid:48) \ S, hence G − S∗ also has at most two components. Therefore, S∗ is an excessive protrusion in G(cid:48), a contradiction. (cid:121) Claim 48. G(cid:48)[V (cid:48)] has no bouquet. Proof. Suppose G(cid:48)[V (cid:48)] has a bouquet {Xi}i∈I attached to some UX ⊆ V (cid:48). Since it was not removed when constructing V (cid:48), it was not a bouquet in G(cid:48), so it must be that δG(cid:48)[V (cid:48)](Xi) (cid:40) δG(cid:48)(Xi) for some i ∈ I. By the construction of V (cid:48), there must be some bouquet {Yj}j∈J attached to some UY in G with some Yj, j ∈ J adjacent to Xi. Again, UY either consists of one vertex, or of two vertices that are still connected in G(cid:48)[V (cid:48)] by dF − 1 > 2 edge-disjoint paths (namely paths contained in the elements of {Yj}j∈J that did not get deleted). Hence all of UY lies on the same side of the cut δ(Xi) in G(cid:48)[V (cid:48)]. Since Yj is adjacent to Xi, NG(cid:48)(Yj) = UY intersects Xi and thus UY ⊆ Xi. As δG(cid:48)[V (cid:48)](Xi) ≤ 2, we have that δG(cid:48)[V (cid:48)](Xi) can intersect at most two of the dF − 1 elements of the bouquet {Yj}j∈J that survive in G(cid:48)[V (cid:48)]. All the other elements of this bouquet must lie on the same side of the cut δ(Xi) as UY , that is, they must be contained in Xi. So in fact Xi is a 2-protrusion in G(cid:48)[V (cid:48)] containing at least dF − 3 > 2bF · cF edges and thus an excessive protrusion, a contradiction. (cid:121) 33 With the above claims, we conclude that G(cid:48)[V (cid:48)] has no excessive protrusions, no bouquets and no thetas. Therefore, it satisfies the conditions of Lemma 41. We extend Lemma 44 to disconnected graphs by simply considering each connected component separately. Corollary 49. Suppose we are given a graph G that is not F-free and in which every connected component does not have any excessive protrusion. Then one can find in time O(G3) a set ∆ ⊆ E(G) such that (for some constant c depending on F only): OPT(G − ∆) < OPT(G) and ∆ ≤ c · (OPT(G) − OPT(G − ∆)). Proof. Let C1, . . . , Cr be the connected components of G and let without loss of generality C1, . . . , Cr(cid:48) be those that are not F-free, for some r(cid:48) ≤ r ∈ N. Since G is not F-free and all graphs of F are connected, we have r(cid:48) ≥ 1. Since every component Ci has no excessive protrusion, for each 1 ≤ i ≤ r(cid:48) we compute a set ∆i ⊆ E(Ci) by invoking Lemma 44 on Ci. Then, for some constant c depending on F only, we have that: Let ∆ =(cid:83)r(cid:48) Ci that are F-free have OPT(Ci) = 0, thus and OPT(Ci − ∆i) < OPT(Ci) i=1 ∆i. Since all the graph in F are connected, OPT(G) =(cid:80)r r(cid:48)(cid:88) and similarly OPT(G − ∆) = r(cid:48)(cid:88) OPT(G) = OPT(Ci) ∆i ≤ c · (OPT(Ci) − OPT(Ci − ∆i)) i=1 OPT(Ci). Components OPT(Ci − ∆i) Since r(cid:48) ≥ 1, we have OPT(C1 − ∆1) < OPT(C1) and thus OPT(G − ∆) < OPT(G). Finally i=1 i=1 r(cid:48)(cid:88) Therefore, the algorithm can in O((cid:80)r(cid:48) ∆ = i=1 ∆i ≤ c · (OPT(G) − OPT(G − ∆)). i=1 Ci3) ≤ O(G3) time output ∆ as a result. To get a constant-factor approximation algorithm, we invoke the above corollary iteratively. Intuitively, we maintain a set of edges F , initially empty, and invoke the corollary on G− F to find a set ∆ such that adding it to F decreases OPT(G− F ), while increasing F by only a constant factor more. We then run the algorithm of Lemma 37 to remove excessive protrusions from G− F , reducing in a sense those parts of the graph where no more edges need to be deleted. Eventually, we reach OPT(G − F ) = 0, meaning F is a solution of size linear in OPT(G). The proof is straightforward, but requires reconstructing at every step a solution to the original graph given to Lemma 37. Theorem 50 (Theorem 2, reformulated). There is an algorithm running in time O((cid:107)G(cid:107)3 log (cid:107)G(cid:107) · G3) that given a graph G, outputs a set F ⊆ E(G) of size at most capx · OPT(G) such that G − F is F-free, for some constant capx depending on F only. Proof. Let G0 = G and ∆0 = ∅. The algorithm computes a sequence of graphs Gi with (cid:107)Gi(cid:107) ≤ (cid:107)G(cid:107) and sets ∆i ⊆ E(Gi) as follows. For i ≥ 0, Gi+1 is computed from Gi − ∆i by invoking Lemma 37 on this graph. That is, in time O((cid:107)G(cid:107)2 log (cid:107)G(cid:107) · G3) we compute a graph Gi+1 in which no connected component contains any excessive protrusions and moreover (cid:107)Gi+1(cid:107) ≤ (cid:107)Gi − ∆i(cid:107) ≤ (cid:107)G(cid:107) and 34 OPT(Gi+1) = OPT(Gi − ∆i). For i ≥ 1, provided Gi is not F-free, ∆i is computed from Gi by invoking Corollary 49. That is, in time O(G3) we find a set ∆i ⊆ E(Gi) such that OPT(Gi − ∆) < OPT(Gi) and ∆i ≤ c · (OPT(Gi) − OPT(Gi − ∆i)). Here, c is the constant given by Corollary 49. Eventually, since OPT(Gi+1) < OPT(Gi), there is an 1 ≤ r ≤ OPT(G) such that Gr is F-free. We reconstruct a sequence of solutions Fi ⊆ E(Gi) for Gi as follows. Clearly Fr := ∅ is a solution If Fi+1 is a solution for Gi+1, then using the solution-lifting algorithm of Lemma 37, for Gr. i ≤ Fi+1. Then a solution F (cid:48) i ∪ ∆i is a solution for Gi. This way, we reconstruct a solution F0 for G0 = G in at most Fi := F (cid:48) OPT(G) iterations, that is, in total time O((cid:107)G(cid:107)2 · OPT(G)). Constructing the graphs Gi took O((cid:107)G(cid:107)2 log (cid:107)G(cid:107) · G3 · OPT(G)) total time, so since OPT(G) ≤ (cid:107)G(cid:107), the time bound follows. To bound the size of the solution, we show inductively that Fi ≤ c · OPT(Gi) for i = r, . . . , 0. i for Gi − ∆i can be constructed in time O((cid:107)G(cid:107)2) such that F (cid:48) Clearly this hold for i = r. If it holds for i + 1, then it holds for i, because: Fi ≤ F (cid:48) i + ∆i ≤ Fi+1 + ∆i ≤ c · OPT(Gi+1) + c · (OPT(Gi) − OPT(Gi+1)) = c · OPT(Gi). 6 Linear kernel In the previous section we have already observed (Lemma 41) that the only structures in the graph that prevent it from being a linear kernel are excessive protrusions, bouquets, and thetas. Using the Exhaustive Protrusion Replacement (Lemma 37) we can get rid of excessive protrusions, but bouquets and thetas can still be present in the graph. It would be ideal if we could reduce the size of every bouquet or theta to a constant, but unfortunately we are so far unable to do this. Instead, we employ the following strategy based on the idea of amortization. First, we reduce all excessive protrusions using Lemma 37. Second, using Theorem 50, we compute an approximate solution F that is larger than the optimum only by a constant multiplicative factor. Then, we investigate every bouquet in the graph and we estimate the number of edges of F that, in some sense, "affect" the bouquet. It can be then shown that the size of the bouquet can be reduced to linear in terms of the number of edges that affect it. Thus, after performing this reduction there still might be large bouquets in the graph, but only because a large number of edges of F affect them. However, every edge of F will affect at most a constant number of bouquets, so the total size of the bouquets will amortize to linear in terms of F, hence also linear in terms of OPT. The same amortization reasoning also enables us to bound the total sum of sizes of thetas. We first show that if we know a local solution that isolates a bouquet into an F-free part, then connected components of G − ∆ that intersect U ∪(cid:83) components of G− ∆ that contain some vertices of U ∪(cid:83) this bouquet can be proportionally bounded without changing OPT(G). Lemma 51. Let {Xi}i∈I be a bouquet attached to U in G. Suppose ∆ ⊆ E(G) is such that all the i∈I Xi are F-free. Then OPT(G) = OPT(G(cid:48)), where G(cid:48) is obtained from G by removing vertices of all except dF + ∆ elements of the bouquet. Proof. Suppose that, to the contrary, G(cid:48) admits an edge subset F ⊆ E(G(cid:48)) of size k such that G(cid:48) − F is F-free, but G does not. Let C ⊆ V (G) be the union of the vertex sets of those connected i∈I Xi. By assumption, G[C]− ∆ is F-free. Note that δ(C) ⊆ ∆. Let EC be the set of all the edges incident to vertices of C in G. We claim that ∆ > F ∩ EC. To show this, define F (cid:48) := (F \ EC) ∪ ∆. Observe that G − F (cid:48) is F-free: as all graphs in F are 35 connected, an immersion model of one of them in G − F (cid:48) ⊆ G − δ(C) would either be contained in C or disjoint from it. The first case would contradict the assumption that G[C] − F (cid:48) ⊆ G[C] − ∆ is F-free. In the second case, the immersion model would be contained in V (G) \ C, which is equal to V (G(cid:48)) \ C, because C contains all the vertices of the bouquet. That is, it would be contained in in G[V (G) \ C] − F (cid:48) ⊆ G(cid:48)[V (G(cid:48)) \ C] − (F \ EC) = G(cid:48)[V (G(cid:48)) \ C] − F , which would contradict the assumption that G(cid:48) − F is F-free. By our supposition that G does not admit a solution of size k, we infer that F (cid:48) > k ≥ F, and hence ∆ > F ∩ EC, as claimed. Since G− F cannot be F-free, by our assumption that G has no solution of size k, it contains an immersion model of some graph in F. As argued after the definition of a bouquet, this immersion model can intersect at most dF elements of the bouquet {Xi}i∈I . Since G(cid:48) still has dF + ∆ isomorphic elements of this bouquet, G(cid:48) − F has at least dF + ∆ − F ∩ EC > dF isomorphic elements that are not intersected by F . Therefore, even if the immersion model in G− F intersected any elements removed from G(cid:48), they can be replaced by not intersected elements that remained unchanged in G(cid:48) − F , thus yielding an immersion model of the same graph in G(cid:48) − F . This means that G(cid:48) − F is not F-free, a contradiction. The same reasoning can also be applied to limit the sizes of thetas. The proof is exactly the same and hence we leave it to the reader. Lemma 52. Let {ei}i∈I be a theta attached to {u, v} = U in G. Suppose ∆ ⊆ E(G) is such that all the connected components of G − ∆ that contain some vertex of U are F-free. Then OPT(G) = OPT(G(cid:48)), where G(cid:48) is obtained from G by removing all edges of {ei}i∈I except for dF + ∆. The above lemmas allow us to reduce bouquets and sets of parallel edges effectively, given a local part of an approximate solution. By appropriately amortizing bounds with the total size of the approximate solution, we finally get a linear bound on an irreducible equivalent instance. Lemma 53. Let G be a connected graph with no excessive protrusions and let F ⊆ E(G) be such that G − F is F-free. Then either (cid:107)G(cid:107) ≤ c · F for some constant c depending on F only, or given G and F , one can compute in time O((cid:107)G(cid:107) · G2) a subgraph G(cid:48) of G such that OPT(G) = OPT(G(cid:48)) and (cid:107)G(cid:48)(cid:107) < (cid:107)G(cid:107). Proof. We begin as in the proof of Lemma 41, except that given F we can now do the same effectively. That is, using Corollary 20, we compute a neat tree-cut decomposition T = (T,X ) of G − F with width(cid:48)(T ) ≤ bF in time O((cid:107)G(cid:107) · G2). For a node t of T , by Xt we denote the bag at t. Let M ⊆ V (T ) be the lca-closure of the set of bags containing a vertex incident to F ; M can be easily computed in linear time. By Lemma 40, M ≤ 4F and every connected component of T − M has at most two neighbors in T . Then Claim 42 from the proof of Lemma 41 can be argued exactly in the same manner. We recall it for convenience and refer the reader to the proof of Claim 42 for the argumentation. Claim 54 (Claim 42, restated). Take any connected component T (cid:48) of T − M and let XT (cid:48) be the union of the bags at the nodes of T (cid:48). Then (cid:107)G[XT (cid:48)](cid:107) ≤ 2bF · cF . For a node t ∈ M , let F (t) be the set of those edges of F that are incident to some vertex of Xt. We denote c1 := 2bF · cF . A standard hand-shaking argument shows that(cid:88) F (t) ≤ 2F. t∈M 36 (14) Let T1, . . . , Tp(t) be the connected components of T − t which contain some other nodes of M and let S1, . . . , Sq(t) be those with none. Again, by XTi, resp. XSi, we denote the union of bags at the nodes of Ti, respectively Si. Consider the forest with vertex set M defined as follows: put an edge between two nodes of M if there is a component of T − M that neighbors both of them. Observe that p(t) is the degree of t in this forest. Therefore, as there are at most M − 1 edges in any forest on M vertices, we infer that p(t) ≤ 2(M − 1). (15) (cid:88) t∈M Define f (t) := F (t) + bF · p(t) + dF . By (14) and (15) we conclude that f (t) ≤ 2F + bF · 2(M − 1) + M · dF ≤ d1 · F, for d1 := 2 + 8bF + 4dF . (16) (cid:88) t∈M We proceed similarly as in the proof of Lemma 41. Consider an arbitrary t ∈ M . By Corollary 21, at least q(t) − (2bF + 1) of the trees S1, . . . , Sq(t) are connected to t via a neat adhesion; let I1 ⊆ {1, 2, . . . , q(t)} be the set of their indices. That is, for each i ∈ I1 we have that δ(XSi) ≤ 2 and N (XSi) is a subset of Xt of size at most 2. Since there are at most b2F subsets of Xt of size at most 2, at least (q(t) − 2bF − 1)/b2F of subtrees {Si}i∈I1 have the same neighborhood N (XSi) = U , for some U ⊆ Xt of size at most 2; let I2 ⊆ I1 be the set of their indices. By Claim 54, for each i ∈ I2 we have that XSi induces in G a subgraph with at most c1 edges. It follows that there are at most c2 := (2c1 + 1)c1+2 possible isomorphism types for graphs G[XSi ∪ U ] for i ∈ I2 (considering isomorphisms that fix U ). Therefore, if (q(t) − 2bF − 1)/(b2F · c2) ≥ f (t), then there is a subset I3 ⊆ I2 of size at least f (t) for which sets {XSi}i∈I3 are elements of a single bouquet X attached to U . Let ∆ ⊆ E(G) be the set comprising of F (t) and the adhesions corresponding to the edges connecting subtrees T1, . . . , Tp(t) with t in T . Then ∆ separates in G the vertices of Z := Xt ∪ XS1 ∪ . . . ∪ XSq(t) from the rest of the graph; that is, all the edges between Z and V (G) \ Z are contained in ∆. Since ∆ contains F (t) and none of the sets XSi is incident to any edge of F , we infer that G[Z] − ∆ is F-free. Hence all the components of G − ∆ that contain some vertex of the bouquet X are F-free. By applying Lemma 51, we infer that either X ≤ dF + ∆ ≤ dF + F (t) + bF · p(t) = f (t), (17) or all except f (t) elements of the bouquet can be deleted to obtain a strictly smaller subgraph G(cid:48) (cid:40) G with OPT(G(cid:48)) = OPT(G). Hence, if (17) does not hold, then the algorithm can output G(cid:48) and terminate. We can thus conclude the proof, unless for all t ∈ M the following holds: or equivalently (q(t) − 2bF − 1)/(b2F · c2) ≤ f (t), q(t) ≤ f (t) · c2 · b2F + 2bF + 1. (18) We henceforth assume that this is the case. Similarly, if there are more than f (t) edges with the same pair of endpoints U ⊆ Xt, by Lemma 52 all but f (t) of them can be deleted to obtain a strictly smaller subgraph G(cid:48) (cid:40) G with OPT(G(cid:48)) = OPT(G). We can thus conclude the proof unless, for each t ∈ M , there is no group of 37 more than f (t) parallel edges connecting the same pair of endpoints in Xt. We henceforth assume that the latter alternative is the case. Since Xt ≤ width(cid:48)(T ) ≤ bF , we have the following for each t ∈ M : (cid:107)G[Xt](cid:107) ≤ b2F · f (t). (19) (cid:88) We proceed with analyzing the size of the instance, with the goal of showing that it is bounded linearly in F. By (16) and (18) we have q(t) ≤ c2 · b2F · d1 · F + M · (2bF + 1) ≤ c3 · F, for c3 := c2 · b2F · d1 + 4(2bF + 1). t∈M That is, the total number of components of T − M with exactly one neighbor in T is at most c3 ·F. As we argued before, the number of components of T − M with exactly two neighbors in T is at most M − 1. Hence, T − M has at most c3 · F + M − 1 connected components in total. (20) We now examine the edges of G. Every edge of G is either: (i) in F , or (ii) in G[Xt] for some t ∈ M , or (iii) in G[XT (cid:48)] for a component T (cid:48) of T − M , or (iv) in an adhesion corresponding to an edge of T connecting a connected component of T − M with a node of M . The total number of edges of each of these types is respectively bounded by: (i) F, (ii) b2F · d1 · F (by (16) and (19)), (iii) c1 · (c3 · F + M − 1) (by Claim 54 and (20)), and (iv) 2bF · (c3 · F + M − 1) (by width(cid:48)(T ) ≤ bF , (20), and the fact that each component of T − M neighbors at most two nodes of M ). Therefore, we conclude that (cid:107)G(cid:107) ≤ c · F for c := 1 + (c1 + 2bF ) · (c3 + 4) + b2F · d1 as required. We are ready to conclude the description of our kernelization algorithm, that is, to prove Theorem 3. For convenience, we recall its statement and adjust it to the current notation. Theorem 55 (Theorem 3, reformulated). There is an algorithm that, given an instance (G, k) of F-Immersion Deletion, runs in time O((cid:107)G(cid:107)4 log (cid:107)G(cid:107) · G3) and either correctly concludes that (G, k) is a NO-instance, or outputs an equivalent instance (G(cid:48), k) such that G(cid:48) has at most cker · k edges, where cker is a constant depending on F only. 38 Proof. We fix the constant cker as cker := capx · c, (cid:107)G(cid:48)(cid:107)/F > c. where c is the constant given by Lemma 53. Let (G, k) be the input instance. We first apply the algorithm of Lemma 37, which runs in time O((cid:107)G(cid:107)2 log (cid:107)G(cid:107) · G3) and yields a new graph G(cid:48) such that (cid:107)G(cid:48)(cid:107) ≤ (cid:107)G(cid:107), OPT(G(cid:48)) = OPT(G) and each connected component of G(cid:48) has no excessive protrusion. From now on, we work on the graph G(cid:48) instead of G. If we already have that (cid:107)G(cid:48)(cid:107) ≤ c · k, then we can simply output (G(cid:48), k), so assume that this is not the case. Apply the approximation algorithm of Lemma 50 to G(cid:48), yielding in time O((cid:107)G(cid:107)3 log (cid:107)G(cid:107) · G3) a subset of edges F such that G(cid:48) − F is F-free and F ≤ capx · OPT(G(cid:48)). If F > capx · k, then we can infer that OPT(G) = OPT(G(cid:48)) > k and thus we terminate the algorithm by concluding that (G, k) is a NO-instance. Hence, assume otherwise, that F ≤ capx · k. Because (cid:107)G(cid:48)(cid:107) > capx · c · k, we have that (21) For each connected component H of G(cid:48), let FH = F ∩ E(H). Obviously H − FH is F-free, as it is an induced subgraph of G(cid:48) − F . By (21), there exists some connected component H of G(cid:48) for which (cid:107)H(cid:107)/FH > c, that is, (cid:107)H(cid:107) > c · FH. Therefore, as H is connected and has no excessive protrusions (as a connected component of G(cid:48)), we can apply the algorithm of Lemma 53 to H. This application takes O((cid:107)H(cid:107) · H2) time and outputs a subgraph H(cid:48) of H with (cid:107)H(cid:48)(cid:107) < (cid:107)H(cid:107) and OPT(H(cid:48)) = OPT(H). We can now replace H with H(cid:48) in G(cid:48), thus obtaining a new graph G(cid:48)(cid:48), and restart the whole algorithm on the instance (G(cid:48)(cid:48), k). Since OPT(H(cid:48)) = OPT(H) and every graph of F is connected, it follows that also OPT(G(cid:48)) = OPT(G) and, hence, the instance (G(cid:48)(cid:48), k) is equivalent to (G, k). Also, (cid:107)H(cid:48)(cid:107) < (cid:107)H(cid:107) implies (cid:107)G(cid:48)(cid:48)(cid:107) < (cid:107)G(cid:48)(cid:107) ≤ (cid:107)G(cid:107), so the number of edges is strictly smaller in the instance (G(cid:48)(cid:48), k) that in the original instance (G, k). We conclude that the algorithm will either terminate by concluding that (G, k) is a NO instance, or it will output (G(cid:48), k), provided (cid:107)G(cid:48)(cid:107) ≤ cker · k, or it will restart on an equivalent instance (G(cid:48)(cid:48), k) with (cid:107)G(cid:48)(cid:48)(cid:107) < (cid:107)G(cid:107). The number of iterations is bounded by the number of edges in the original graph and each iteration takes O((cid:107)G(cid:107)3 log (cid:107)G(cid:107) · G3) time, so the running time bound follows. 7 Bounding the size of the obstructions k = obsim(Gim In order to prove the second part of Theorem 3 it is enough to prove that, in the statement of the first part, the graph of the equivalent instance (G(cid:48), k) is an immersion of G. To see this, assume that H ∈ Oim k,F ). Clearly, (H, k) is a NO-instance of F-Immersion Deletion. If we run the kernelization algorithm on (H, k) the result should be a NO-instance (H(cid:48), k) where H(cid:48) is an immersion of H. As H is an immersion obstruction of Gim k,F , for every proper immersion of H, the pair (H(cid:48), k) should be a YES-instance. Therefore H(cid:48) = H and, according to the first statement of Theorem 3, H has a linear, on k, number of edges. It remains now to modify the kernelization algorithm of Theorem 3 so that, when it runs with input (G, k), it outputs a pair (G(cid:48), k) where G(cid:48) is an immersion of G. Recall that the algorithm, during its execution, either applies replacements of replaceable protrusions (i.e., 2bF -protrusions with more than cF edges) with smaller ones (Lemma 23), or removes edges from thetas and buckets (Lemma 53). Therefore we need to modify the protrusion replacement in Lemma 23 so that G(cid:48) is an immersion of G. Before we explain this modification, we first need some definitions. Given two r-boundaried graphs G = (G, (u1, . . . , ur)) and H = (H, (v1, . . . , vr)), we say that H is a rooted immersion of H if H is an immersion of G where the corresponding mapping µV maps vi to ui for every i ∈ {1, . . . , r}. We next argue that for every r, rooted r-boundaried graphs are 39 well-quasi-ordered with respect to the rooted-immersion relation. Indeed, Robertson and Seymour proved in [39] that the set of all colored (by a bounded number of colors) graphs is well-quasi-ordered with respect to the colored immersion relation (here the function µV should additionally map vertices to vertices of the same color). By assigning to the boundaries of the r-boundaried graphs r different colors and using one more color for their non-boundary vertices, we deduce that r-boundaried graphs are well-quasi-ordered under the rooted immersion relation. Let Br be the set of all r-boundaried graphs. The set Br has a partition C(r) = {C(r) qr } 1 , . . . ,C(r) such that two r-boundaried graphs belong in the same set if and only if they have the same signature. According to Corollary 29, qr ≤ 222poly(r,MAXF ) . For every i ∈ {1, . . . , qr}, let Ci be the set of rooted immersion-minimal elements of Ci. As r-rooted graphs are well-quasi-ordered under rooted-immersions, we have that C(r) (cid:91) (cid:91) i is a finite set. We now consider the following set RF = C . (r) i r≤2bF i∈{1,...,qr} i . Let c∗ Notice that, for each r ∈ {1, . . . , 2bF}, each r-boundaried graph H belongs in some, say C(r) , of the classes in C(r), therefore it should contain as a rooted immersion some of the rooted graphs in C(r) F be the maximum number of edges in an r-boundaried graph of RF . This implies that every r-boundaried graph H of more than c∗ F edges can be replaced by an equivalent (i.e., one with the same signature) r-boundaried graph H(cid:48) that belongs in RF and is a rooted immersion of H. Therefore, if (G, k) is an instance of F-Immersion Deletion, H is an 2bF -protrusion of G of more F edges, and G = F ⊕ H, then (G(cid:48), k) is an instance equivalent to (G, k) where G(cid:48) = F ⊕ H(cid:48). than c∗ Moreover, as H(cid:48) is a rooted immersion of G, it follows that G(cid:48) is an immersion of G as required. i Notice that the above argumentation does not give any way to compute c∗ F as the, inherently non-constructive, proof in [39] does not provide any way to compute a bound to the size of the graphs is a finite number). We wish to report that it is actually possible to in C(r) prove a constructive version of the second statement of Theorem 3. This proof is postponed in later versions of this paper, as it resides on results that are currently under developement. (it only says that C(r) i i 8 Conclusions In this work we have proved that the protrusion machinery, introduced in [4, 5, 19], can be applied to immersion-related problems in a similar manner as to minor-related problems. In particular, we have given a constant-factor approximation algorithm and a linear kernel for the F-Immersion Deletion problem, which on one hand mirrors and on the other surpasses the results of Fomin et al. [19] for F-Minor Deletion. Namely, while the exponent of the polynomial bounding the kernel size provably has to depend on the family F in the minor setting [23], in the immersion setting we were able to give a linear kernel, with only the multiplicative constant depending on F. We consider this apparent difference of complexity interesting and worth studying further. The immediate next goal is to lift the technical assumption that all graphs from F are connected. While this assumption plays an important role in several of our proofs, we expect that it is not necessary and can be lifted using the techniques of Kim et al. [30] or Fomin et al. [18,19] that worked in the minor setting. In fact, a constant-factor approximation, without the assumption on the connectivity of F, can easily be obtained in the following way, as in the full version of the work of Fomin et al. [18]. Since Theorem 8 works just as well in the case of F containing disconnected graphs, a set of edges whose deletion makes a graph F-free also makes it a graph tree-cut width bounded 40 by some constant aF . Thus, OPTF (G) is not smaller than the optimum size of a set of edges whose deletion turns G into a graph of tree-cut width at most aF . Tree-cut width is a graph parameter satisfying the conditions of Corollary 5, hence given a graph G, we can construct in polynomial time a set of edges F ⊆ E(G) of size at most a constant factor larger than OPTF (G), such that G − F has tree-cut width at most aF . A standard application of the optimization variant of Courcelle's theorem, due to Arnborg et al. [1], then gives a set F (cid:48) ⊆ E(G − F ) such that G − F − F (cid:48) is F-free and F (cid:48) = OPTF (G − F ) ≤ OPTF (G). Hence by outputting F ∪ F (cid:48), one achieves a constant factor approximation for F-Immersion Deletion. For the linear kernel for F-Immersion Deletion, we so far do not see how to avoid the assumption on the connectivity of F. We believe that an important conceptual insight that is given by this paper is the confirmation of usefulness of the notions of tree-cut width and tree-cut decompositions. Our work, together with a few other recent ones [22, 29, 33, 42], shows that tree-cut width is often the right parameter to study in the context of problem related to immersions and edge-disjointness, and plays a similar role as treewidth for minors and vertex-disjointness. We expect that more results of this kind will appear in future. Clearly, the remaining insisting problem on the study of F-Immersion Deletion problem is to consider cases where none of the graphs in F is planar subcubic. This comes as an analogue to instantiations of the F-Minor Deletion problem where F contain only non-planar graphs. In both cases the existence of a polynomial kernel can been seen as a major challenge in parameterized algorithms. Especially, for F-Immersion Deletion, further advances are necessary on the structure of graphs excluding non-planar or non-subcubic immersions. While some results in this direction have appeared in [2, 15, 33, 42], it is still unclear whether the current combinatorial insight can produce general algorithmic results on F-Immersion Deletion. Acknowledgements. The authors wish to thank an anonymous referee for suggesting a more direct approach to finding excessive protrusions, as well as Ignasi Sau, Petr Golovach, Eun Jung Kim, and Christophe Paul for preliminary discussions on the F-Immersion Deletion problem. References [1] S. Arnborg, J. Lagergren, and D. Seese. Easy problems for tree-decomposable graphs. J. Algorithms, 12(2):308 -- 340, 1991. [2] R. Belmonte, A. Giannopoulou, D. Lokshtanov, and D. M. Thilikos. The Structure of W4- Immersion-Free Graphs. ArXiv e-prints 1602.02002, Feb. 2016. [3] H. L. Bodlaender. A linear-time algorithm for finding tree-decompositions of small treewidth. SIAM J. Comput., 25(6):1305 -- 1317, 1996. [4] H. L. Bodlaender, F. V. Fomin, D. Lokshtanov, E. Penninkx, S. Saurabh, and D. M. Thilikos. (Meta) Kernelization. In Proceedings of FOCS 2009, pages 629 -- 638. IEEE Computer Society, 2009. [5] H. L. Bodlaender, F. V. Fomin, D. Lokshtanov, E. Penninkx, S. Saurabh, and D. M. Thilikos. (meta) kernelization. ArXiv e-prints 0904.0727, 2009. [6] H. D. Booth, R. Govindan, M. A. Langston, and S. Ramachandramurthi. Fast algorithms for K4 immersion testing. J. Algorithms, 30(2):344 -- 378, 1999. 41 [7] D. Chatzidimitriou, J.-F. Raymond, I. Sau, and D. M. Thilikos. An O(log OP T )-approximation for covering and packing minor models of θr. ArXiv e-prints 1510.03945, Oct. 2015. [8] C. Chekuri and J. Chuzhoy. Polynomial bounds for the grid-minor theorem. In Proceedings of STOC 2014, pages 60 -- 69. ACM, 2014. [9] R. H. Chitnis, M. Cygan, M. Hajiaghayi, M. Pilipczuk, and M. Pilipczuk. Designing FPT algorithms for cut problems using randomized contractions. In Proceedings of FOCS 2012, pages 460 -- 469. IEEE Computer Society, 2012. [10] J. Chuzhoy. Excluded grid theorem: Improved and simplified. In Proceedings of STOC 2015, pages 645 -- 654. ACM, 2015. [11] J. Chuzhoy. Improved Bounds for the Excluded Grid Theorem. ArXiv e-prints 1602.02629, Feb. 2016. [12] B. Courcelle. The Monadic Second-Order logic of graphs. I. Recognizable sets of finite graphs. Inf. Comput., 85(1):12 -- 75, 1990. [13] M. Cygan, F. V. Fomin, L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, and S. Saurabh. Parameterized Algorithms. Springer, 2015. [14] M. Devos, Z. Dvor´ak, J. Fox, J. McDonald, B. Mohar, and D. Scheide. A minimum degree condition forcing complete graph immersion. Combinatorica, 34(3):279 -- 298, 2014. [15] Z. Dvor´ak and P. Wollan. A structure theorem for strong immersions. Journal of Graph Theory, 2015. To appear. [16] Z. Dvor´ak and L. Yepremyan. Complete graph immersions and minimum degree. ArXiv e-prints 1512.00513, Dec. 2015. [17] J. Flum and M. Grohe. Parameterized Complexity Theory. Texts in Theoretical Computer Science. An EATCS Series. Springer-Verlag, Berlin, 2006. [18] F. V. Fomin, D. Lokshtanov, N. Misra, and S. Saurabh. Planar F-Deletion: Approximation and optimal FPT algorithms. ArXiv e-prints 1204.4230, Oct. 2012. [19] F. V. Fomin, D. Lokshtanov, N. Misra, and S. Saurabh. Planar F-deletion: Approximation, kernelization and optimal FPT algorithms. In Proceedings of FOCS 2012, pages 470 -- 479. IEEE Computer Society, 2012. [20] F. V. Fomin, D. Lokshtanov, S. Saurabh, and D. M. Thilikos. Bidimensionality and kernels. In Proceedings of SODA 2010, pages 503 -- 510. SIAM, 2010. [21] H. N. Gabow and R. E. Tarjan. A linear-time algorithm for a special case of disjoint set union. In Proceedings of STOC 1983, pages 246 -- 251. ACM, 1983. [22] R. Ganian, E. J. Kim, and S. Szeider. Algorithmic applications of tree-cut width. In G. F. Italiano, G. Pighizzini, and D. Sannella, editors, Proceedings of MFCS 2015, volume 9235 of Lecture Notes in Computer Science, pages 348 -- 360. Springer, 2015. [23] A. C. Giannopoulou, B. M. P. Jansen, D. Lokshtanov, and S. Saurabh. Uniform kernelization complexity of hitting forbidden minors. In Proceedings of ICALP 2015, volume 9134 of Lecture Notes in Computer Science, pages 629 -- 641. Springer, 2015. 42 [24] A. C. Giannopoulou, O.-j. Kwon, J.-F. Raymond, and D. M. Thilikos. Packing and Covering Immersion Models of Planar Subcubic Graphs. ArXiv e-prints 1602.04042, Feb. 2016. [25] A. C. Giannopoulou, I. Salem, and D. Zoros. Effective computation of immersion obstructions for unions of graph classes. J. Comput. Syst. Sci., 80(1):207 -- 216, 2014. [26] R. Govindan and S. Ramachandramurthi. A weak immersion relation on graphs and its applications. Discrete Mathematics, 230(1 -- 3):189 -- 206, 2001. [27] M. Grohe, K. Kawarabayashi, D. Marx, and P. Wollan. Finding topological subgraphs is fixed-parameter tractable. In Proceedings of STOC 2011, pages 479 -- 488. ACM, 2011. [28] A. V. Iyer, H. D. Ratliff, and G. Vijayan. On an edge ranking problem of trees and graphs. Discrete Applied Mathematics, 30(1):43 -- 52, 1991. [29] E. Kim, S. Oum, C. Paul, I. Sau, and D. M. Thilikos. An FPT 2-approximation for tree-cut decomposition. In Proceedings of WAOA 2015, pages 35 -- 46, 2015. [30] E. J. Kim, A. Langer, C. Paul, F. Reidl, P. Rossmanith, I. Sau, and S. Sikdar. Linear kernels and single-exponential algorithms via protrusion decompositions. In Proceedings of ICALP 2013, volume 7965 of Lecture Notes in Computer Science, pages 613 -- 624. Springer, 2013. [31] T. W. Lam and F. L. Yue. Edge ranking of graphs is hard. Discrete Applied Mathematics, 85(1):71 -- 86, 1998. [32] D. Marx. Parameterized graph separation problems. Theor. Comput. Sci., 351(3):394 -- 406, 2006. [33] D. Marx and P. Wollan. Immersions in highly edge connected graphs. SIAM J. Discrete Math., 28(1):503 -- 520, 2014. [34] M. Naor, L. J. Schulman, and A. Srinivasan. Splitters and near-optimal derandomization. In Proceedings of FOCS 1995, pages 182 -- 191. IEEE Computer Society, 1995. [35] R. Niedermeier. Invitation to fixed-parameter algorithms, volume 31 of Oxford Lecture Series in Mathematics and its Applications. Oxford University Press, Oxford, 2006. [36] N. Robertson and P. Seymour. Graph minors. XIII. The disjoint paths problem. J. Comb. Theory, Ser. B, 63(1):65 -- 110, 1995. [37] N. Robertson and P. D. Seymour. Graph minors. V. Excluding a planar graph. J. Comb. Theory, Ser. B, 41(1):92 -- 114, 1986. [38] N. Robertson and P. D. Seymour. Graph minors. XX. Wagner's conjecture. J. Comb. Theory, Ser. B, 92(2):325 -- 357, 2004. [39] N. Robertson and P. D. Seymour. Graph minors XXIII. Nash-Williams' immersion conjecture. J. Comb. Theory, Ser. B, 100(2):181 -- 205, 2010. [40] P. D. Seymour and R. Thomas. Call routing and the ratcatcher. Combinatorica, 14(2):217 -- 241, 1994. [41] D. M. Thilikos, M. J. Serna, and H. L. Bodlaender. Cutwidth I: A linear time fixed parameter algorithm. J. Algorithms, 56(1):1 -- 24, 2005. 43 [42] P. Wollan. The structure of graphs not admitting a fixed immersion. J. Comb. Theory, Ser. B, 110:47 -- 66, 2015. 44
1906.04842
1
1906
2019-06-11T22:13:43
Similarity Problems in High Dimensions
[ "cs.DS" ]
The main contribution of this dissertation is the introduction of new or improved approximation algorithms and data structures for several similarity search problems. We examine the furthest neighbor query, the annulus query, distance sensitive membership, nearest neighbor preserving embeddings and set similarity queries in the large-scale, high-dimensional setting.
cs.DS
cs
Similarity Problems in High Dimensions1 Funded by the European Research Council, grant no. 614331 Johan Sivertsen Advisor: Rasmus Pagh Submitted: August 2017 ii Resumé Beregning baseret på faellestraek mellem datapunkter fra sto- re maengder højdimensionel data er en hjørnesten i mange dele af moderne datalogi, fra kunsting intelligens til informationssøgning. Den store maengde og kompleksitet af data gør, at vi almindeligvis forventer, at der ikke kan findes praecise svar på mange udregnin- ger uden uoverstigelige krav til forbruget af enten tid eller plads. I denne afhandling bidrager vi med nye eller forbedrede approk- simationsalgoritmer og datastrukturer til en raekke problemer der omhandler faellestraek mellem datapunkter. Specifikt: • Vi praesenterer en algoritme der finder en tilnaermelsesvis fjer- neste nabo hurtigere end med den tidligere hurtigste metode. • Vi kombinerer denne algoritme med de bedste kendte tek- nikker til tilnaermelsesvis naermeste nabo for at finde en nabo i tilnaermet ring. • Vi introducerer den første ikke-trivielle algoritme til tilnaermet afstandsfølsomt medlemskab uden falske negativer. • Vi påviser at indlejringer der bevarer naermeste nabo kan udføres hurtigere ved at anvende idéer fra rammevaerket udviklet til hurtige afstandsbevarende indlejringer. • Vi praesenterer en hurtig ny randomiseret algoritme til maeng- de sammenføjning med sammefaldskrav, flere gange hurtigere end tidligere algorithmer. Abstract iii Similarity computations on large amounts of high-dimensional data has become the backbone of many of the tasks today at the frontier of computer science, from machine learning to informa- tion retrieval. With this volume and complexity of input we com- monly accept that finding exact results for a given query will entail prohibitively large storage or time requirements, so we pursue ap- proximate results. The main contribution of this dissertation is the introduction of new or improved approximation algorithms and data structures for several similarity search problems. We exam- ine the furthest neighbor query, the annulus query, distance sensi- tive membership, nearest neighbor preserving embeddings and set similarity queries in the large-scale, high-dimensional setting. In particular: • We present an algorithm for approximate furthest neighbor im- proving on the query time of the previous state-of-the-art. • We combine this algorithm with state-of-the-art approximate nearest neighbor algorithms to address the approximate annulus query. • We introduce the first non-trivial algorithm for approximate distance sensitive membership without false negatives. • We show that nearest neighbor preserving embeddings can be per- formed faster by applying ideas from the framework of Fast Distance Preserving Embeddings. • We introduce and analyse a new randomized algorithm for set similarity join, several times faster than previous algorithms. iv Acknowledgements First and foremost I would like to thank my supervisor Rasmus Pagh. My interest in randomized algorithms was first sparked by the lectures he gave at the end of an algorithms course. I feel very fortunate to have been able to continue studying and researching with him since then. Asides from an astounding talent as a re- searcher, Rasmus represents a professionalism, kindness and pa- tience that is very rare. Through writing the articles that this thesis is based on, I got to work with some great co-authors besides Rasmus. I would like to thank Francesco Silvestri, Mayank Goswami, Matthew Skala and Tobias Christiani for the hours of discussion and for sharing in the frustrations and joys of research with me. I also had the fortune of being able to spend the spring of 2016 at Carnegie Mellon Uni- versity in Pittsburgh. This was possible thanks to the kindness of Professor Anupam Gupta. I would like to thank Anupam for being an excellent academic host during those months and for many in- sightful discussions. Further I would like to thank the many other welcoming and incredibly gifted people at CMU who made my stay very memorable. During the past three years I have enjoyed the pleasant com- pany of my colleagues in the 4b corridor of the ITU. I would like to thank everyone here for the seminars, technical discussions, non- technical discussion and lunch conversations over the years. Espe- cially I would like to thank the other PhD students in my group, Thomas Ahle, Tobias Christiani and Matteo Dusefante for the ad- ventures, both in and out of Hamming space. On a personal level, I would like to thank my family and friends for their unquestioning belief in times of doubt. Special thanks are due to my parents Michael and Vibeke for laying the foundation I stand on today. Finally, I am most grateful to my wife Agnieszka for encouraging me to pursue a PhD and for supporting me always. Contents 1 2 Introduction 1.1 1.2 1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . Representing data . . . . . . . . . . . . . . . . . . . . . . Scale and dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2 4 6 8 c-Approximate Furthest Neighbor (AFN) (c, r, w)-Approximate Annulus Query (AAQ) 10 (r, c, )-Distance Sensitive Approximate Membership Query (DAMQ) 11 Fast Nearest Neighbor preserving embeddings 12 14 (λ, ϕ)-Set Similarity join 15 16 17 18 19 19 22 23 Similarity Search . 1.1.1 1.1.2 Problems and results . 1.2.1 1.2.2 1.2.3 1.2.4 . . . . . . . . . 1.2.5 . . . . . . . . . . . . . . . . . . Preliminaries and techniques . . . . . . . . . . . . . . . . . . . . . 1.3.1 Computational Model . . . . . . . . . . . . . . . . . . . . Distance functions and similarity measures . . . . . . . . . . . 1.3.2 Notation 1.3.3 . . . . . . . . . . . . . . . . . . . . . . . Divide and Conquer 1.3.4 . . . . . . . . . . . . . . . . . . . . . 1.3.5 Randomization and Concentration . . . . . . . . . . . . . . . Hashing . 1.3.6 . . . . . . . . . . . . . . . . . . . . . . 1.3.7 Locality Sensitive Hashing . . . . . . . . . . . . . . . . . . . . . . . . . Furthest Neighbor 2.1 . . . . . . . . . Related work Notation . Introduction . . 2.1.1 . 2.1.2 . Algorithms and analysis . 2.2.1 2.2.2 2.2.3 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Furthest neighbor with query-dependent candidates . . . . . . Furthest neighbor with query-independent candidates . . . . . . A lower bound on the approximation factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 2.3 25 25 27 28 29 29 32 35 37 vi 3 2.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Annulus Query 3.1 Introduction . 3.1.1 Upper bound . Conclusion . . . Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 3.3 4 Distance Sensitive Approximate Membership 4.1 4.2 4.3 4.4 4.5 . . Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . Motivation and practicality . . . . . . . . . . . . . . . . . . 4.1.1 Our results 4.1.2 . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.3 Related work . . . . . . . . . . . . . . . . . . . . . . . . Problem definition and notation . . . . . . . . . . . . . . . . . . . . Lower bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.1 . . . . . . . . . . . . . . . . . . . . . . . . 4.3.2 . . . . . . . . . . . . . . . . . . . . . . . Upper bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Vector signatures . . . . . . . . . . . . . . . . . . . . . . A filter with point-wise error 4.4.2 . . . . . . . . . . . . . . . . . 4.4.3 A filter with average error . . . . . . . . . . . . . . . . . . . Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . Average error Point-wise error . . . . . Fast Nearest Neighbor Preserving Embeddings 5.1 5.2 5.3 Introduction . Preliminaries . Fast Nearest Neighbor Preserving Embeddings 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Smoothness . . . . . . . . . . . . . . . . . . . . . . . . . Fixing s and f . . . . . . . . . . . . . . . . . . . . . . . . Distortion bound . . . . . . . . . . . . . . . . . . . . . . . Shrinkage bound . . . . . . . . . . . . . . . . . . . . . . . Embedding properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4 . . Set Similarity Join 6.1 6.2 . . Introduction . 6.1.1 Preliminaries . 6.2.1 6.2.2 Related work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Similarity measures Notation 5 6 Contents 44 45 45 45 46 49 51 51 52 53 53 54 56 57 61 64 64 75 76 76 77 77 79 79 81 83 83 84 85 90 91 91 93 95 95 96 Contents vii 6.3 6.4 6.5 6.6 6.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Overview of approach . 98 Chosen Path Set Similarity Join Description . 99 6.4.1 Comparison to Chosen Path . . . . . . . . . . . . . . . . . . 100 6.4.2 . . . . . . . . . . . . . . . . . . . . . . 101 6.4.3 Analysis . Implementation . . . . . . . . . . . . . . . . . . . . . . . 107 Chosen Path Similarity Join . . . . . . . . . . . . . . . . . . 108 6.5.1 . . . . . . . . . . . . . . . . . . . . . . 110 MinHash LSH . 6.5.2 . . . . . . . . . . . . . . . . . . . . . . 110 AllPairs . 6.5.3 . . BayesLSH . 6.5.4 . . . . . . . . . . . . . . . . . . . . . . 111 . . . . . . . . . . . . . . . . . . . . . . . 112 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . 114 6.6.1 . . . . . . . . . . . . . . . . . . . . . . . . 116 6.6.2 . Conclusion . . . . . . . . . . . . . . . . . . . . . . . 118 . . . . . . . . . . . . . . . . Results . Parameters . . . . . . 7 A Summary and open problems 121 Appendix A.1 Properties of Gaussians . . A.2 √2-AFN in d + 1 points . 125 . . . . . . . . . . . . . . . . . . . . . . 125 . . . . . . . . . . . . . . . . . . . . . . 126 List of Figures List of Tables Bibliography 127 128 129 Chapter 1 Introduction 1.1 Similarity Search Computers today are increasingly tasked with analyzing complex con- struct like music or images in ways that are sensible to humans. How- ever a computer has no more appreciation for a series of bits represent- ing the Goldberg variations than for some representing the sound of repeatedly slamming a car door. Barring a revolution in artificial intelli- gence computers have no inherent interpretation of the data they store. This poses a barrier to the ways computers can help us. At the same time the amount of digital data has exploded, both in complexity and volume. Consider as an example the fact that early dig- ital cameras like the 1990 Dycam Model 1 could capture and store 32 low resolution black and white images1 and was too expensive for more than a few professional users. Today a modern smart phone can cap- tures and store thousands of high quality color images, and the number of smart phone users is counted in billions. These images are of course not only captured, but shared, compared and searched in all manner of ways. Similar explosive developments have taking place with almost any kind of digital data imaginable, from video and music, to sensor data and network traffic data. This development means large amounts of data has become cheap and accessible, providing one way of circumventing the barrier: Given large amounts of available data, computers can learn by example. Com- puters are extremely well suited for quickly comparing large amounts 1The Dycam 1 featured a 375 x 240 pixel sensor, capturing 256 shades of grey. 2 Chapter 1. Introduction of data and figuring out exactly how similar they are. Consider the task from before: Classify a recording as either "Bach" or "Car door". With no concept of music or sound this is a difficult task for a computer. But if the computer has access to a database of examples from both categories we might simply ask which example is most similar to the recording and return the category of that example. This is idea behind the k-Nearest Neighbors (k-NN) classifier, a simple but powerful machine learning al- gorithm. At the heart of it sits the Nearest Neighbor (NN) problem: Given a set of data points and a query point, return the point most similar to the query. This is part of a larger family of problems that might gener- ally be called similarity search problems: Answer questions about a set of points based on the similarity of the points to a query point. The NN problem is probably the most fundamental similarity search problem, and we will often return to it as it encompasses many of the challenges in the field. Similarity search problems are vital components of many machine learning techniques, and they are equally important in many other areas of computer science like information retrieval, compression, data mining and image analysis. The main contribution of this thesis is a series of improvements in solving various similarity search problems, both in the speed and space necessary to solve them, and in the quality of the answers. Before we can begin to study the problems, we must first address two obvious questions about the definition above: How did the images, music, traffic data etc. above turn into points, and what does it mean for two points to be similar? Readers familiar with high-dimensional metric spaces and O-notation can skip ahead to Section 1.2. Representing data 1.1.1 To process our data we first need to represent it digitally. As an exam- ple think of a collection of text-only documents i.e. strings of letters and spaces. In order to store them in a computer, a normal method is to agree to some standard of translating letters into numbers, then store the numbers representing the document on the computer. Say the doc- uments all contain only d = 2 letters each. If we map letters to their index in the alphabet, a → 0, b → 1 etc., we can represent the data as points in the set N2: the set of all pairs of natural numbers2. We call d the dimensionality or features of the data. 2Table 1.1 lists the standard notation for working with sets that we will be using. 1.1. Similarity Search 3 (5, f ) (4, e) (3, d) (2, c) (1, b) BE 1 BC 2 ED 2 (0, a) (0, a) (1, b) (2, c) (3, d) (4, e) (5, f ) Figure 1.1: The strings "BE", "BC" and "ED" represented as points in N2 and the hamming distance between them. Notation R N Description Real numbers Natural numbers {0, 1} Set of bits ∅ The empty set {∅} Set containing ∅ [n] Integers from 1 to n B(x, r) Radius r ball around x Xd {(x1, . . . , xd)xi ∈ X} Union of X and Y X ∪ Y X ∩ Y Intersection of X and Y The power set of X P (X) Table 1.1: Set notation Next, we need to define what it means for two documents to be similar? Often the concept of similarity is intuitively understood, but hard to put an exact measure on. For our purposes we will need exact measures. In our example, one idea is to consider strings to be similar if they contain the same letters in many positions. This would suggest using the Hamming distance, H, i.e. counting the number of positions where the letters differ, illustrated in Figure 1.1. We then have an exact distance function that we can use as an inverse measure for similarity. When data is represented as points in some set X and dis- tances between the points are measured using a distance function D we say that the data is in the space (X, D). In the example we used (X = N2, D = H). Of course we could have chosen many other distances functions, it depends entirely on the desired no- tion of similarity. In this dissertation we will assume that our data is already mapped into a well defined space. Further, we will assume that the distance function used captures the similarities relevant to the given application. From now on "similarity" will be a formalized, measurable concept, and it will be the inverse of "distance". We will return to this discussion in Section 1.3.2. 4 Chapter 1. Introduction Description Notation S Input data set S n q Query point d Data dimensionality D Distance function Table 1.2: Frequently used symbols and their meaning. Scale and dimension 1.1.2 Solving problems at scale means that we have to be able to keep up with the explosive growth in data. For most similarity search prob- lems, including the NN problem, we can always answer a query by computing the similarity of the query point, q, and every point in the input data set, S. This works well when S is small, but when sud- denly the amount of data explodes, so does our query time. We say that the query time is linear in n, where n is the size of S. To han- dle the explosive growth in data, we must be able to answer the query while only looking at a small part of S. In fact, as S grows, the per- centage of S we need to look at must rapidly decrease. That is, we will be interested in solutions that provide query time sub-linear in n. Imagine that we are given a set of surnames and tasked with build- ing a phone book. Instead of mapping each letter to a number like in the previous example, we might simply map each name to its al- phabetic order. With this mapping we can represent the strings in a 1-dimensional space, simply points along a line (see Figure 1.2). When we are looking up a name in the phone book we are solving a 1-dimensional search problem. Using binary search we can solve it in logarithmic time in the number of names. Logarithmic query time is a very desirable property because it is highly sub-linear. Roughly speaking, every time the length of the phone book doubles, we will only need to look at one extra name as we search for a number. This enables us to "keep up" with the explosive growth in data (See figure. 1.3). If we are trying to capture more complicated relations than a strict ordering, having only one dimension is very limiting. When under- standing if two pieces of music are similar, we might employ a myriad of dimensions, from tempo to scale to the meaning of the lyrics etc. Andersen, A. Andersen, D. Andersen, F. Anderson, D. Anderson, F. 1 2 3 4 5 Figure 1.2: A very short phonebook. 1.1. Similarity Search 5 Figure 1.4: A voronoi diagram for n = 20 points in Rd=2 To capture these complicated relationships we need to work in high- dimensional spaces. As an example, consider extending the mapping in Figure 1.1 from strings of length d = 2 to length d = 50. While we can no longer easily visualize the space, the mathematical concepts of e.g. (N50, H) are perfectly sound and workable. However, it is a challenge to develop scaling algorithms when d is large. For d = 2 this is already much more difficult. A classical result in computational geometry is the use of the Voronoi diagram (See Figure 1.4) for solving the NN problem in (R2, (cid:96)2). The dia- gram partitions R2 into n cells, one for each data point. For any location in a cell the nearest point in S is the data point associated with the cell. Using this diagram we are again able to get log- arithmic query time using point location: Given a new point x ∈ R2, find the associated cell. Hav- ing found the cell, the answer to the NN problem is simply the point associated with that cell. Both computing the Voronoi diagram and solving the point location problem have long histories and many different approaches have been developed, see [22] for an overview. Figure 1.3: Names in the phone book and how many we will see using a binary search. We can expand the idea of the Voronoi diagram to d > 2, however the size of the diagram grows exponentially as nd/2, so this will only InbookInsearch246810Years50100150200250Names 6 Chapter 1. Introduction be viable as long as d is small. In general for low-dimensional met- ric spaces there are many well-known similarity search algorithms (e.g. [45], [21]) but they all suffer from exponential growth in either storage or query time as d grows. Although d is not growing as fast as n, this is prohibitively expensive even for relatively small d. It is not doing us much good to achieve sub-linear growth in n if all gains are minute to the costs incurred from the high-dimensional setting. This makes these methods prohibitively expensive for large-scale, high-dimensional data. There are strong indications that this is not a failing of the solutions, but rather an inherent property of the problem [114, 2]. To avoid this curse of dimensionality a field of approximation algorithms has been thriving in recent years. Here we concede to losing accuracy in exchange for algorithms that have query time sub-linear in n and linear in d. The space is allowed to grow linearly in n and d. In this thesis we further expand this field with a set of new algorithms for solving approximate similarity search problems in high-dimensional spaces. 1.2 Problems and results The articles that make up this dissertation are listed below in the order their content appears here: 1. Rasmus Pagh, Francesco Silvestri, Johan Sivertsen and Matthew Skala. Approximate Furthest Neighbor in High Dimensions [97]. SISAP 2015. Chapter 2. 2. Rasmus Pagh, Francesco Silvestri, Johan Sivertsen and Matthew Skala. Approximate furthest neighbor with application to annulus query [98]. Information Systems 64, 2017. Chapters 2 and 3. 3. Mayank Goswami, Rasmus Pagh, Francesco Silvestri and Johan Sivertsen. Distance Sensitive Bloom Filters Without False Nega- tives [62]. SODA 2017. Chapter 4. 4. Johan Sivertsen. Fast Nearest Neighbor Preserving Embeddings. Unpublished. Chapter 5. 5. Tobias Christiani, Rasmus Pagh and Johan Sivertsen. Scalable and robust set similarity join. Unpublished. Chapter 6. 1.2. Problems and results 7 We will state the problems for any space (X, D) but the results are all for particular spaces. (See Table 1.1 and 1.4). Perhaps the most central problem in similarity search is the nearest neighbor (NN) problem. Using the notation in Table 1.2, we state the problem as: Nearest Neighbor (NN) Given S ⊆ X and q ∈ X. Return x ∈ S, such that D(q, x) is minimized. To circumvent the curse of dimensionality we will be relaxing our prob- lems in two ways. We will use the NN problem to illustrate the relax- ations. First, we will accept an answer x(cid:48) if it is a c-approximate nearest neighbor. That is, we will require only that D(q, x(cid:48)) ≤ cD(q, x), where x ∈ S is the actual nearest neighbor. The furthest neighbor and annu- lus query algorithms presented in this dissertation are generally only applicable when c > 1. However, this is often the case: Since we are searching for similar, but not necessarily equal things, the most similar and the almost most similar will often be equally useful. We can also consider cases where the similar thing is much closer (more than a factor c) to the query than the rest of the dataset. In such settings the returned c-approximate nearest neighbor is also the actual nearest neighbor. Secondly we will allow the distance, r, to be a parameter to the prob- lem. We say that x(cid:48) is r-near if D(q, x(cid:48)) ≤ r. The relaxed approximate near neighbor problem (ANN) is then stated as: Definition 1.1 ((c, r)-Approximate Near Neighbor). For c > 1, r > 0. If there exists a point x ∈ S such that D(x, q) ≤ r, report some point x(cid:48) ∈ S where D(x(cid:48), q) ≤ cr, otherwise report nothing. These relaxations were first introduced by Indyk and Motwani in [72]. They also show that we can use (c, r)-approximate near neighbor to find the c-approximate nearest neighbor by searching over settings of r. In many applications achieving a fixed similarity might also suffice on its own, regardless of the existence of closer points. Next we will introduce the problems addressed in this dissertation. For each problem we will give a formal definition, as well as a an overview of the main results and ideas used to obtain them. 8 Chapter 1. Introduction c-Approximate Furthest Neighbor (AFN) 1.2.1 While a lot of work has focused on nearest neighbor, less effort has gone into furthest neighbor. That is, locating the item from a set that is least similar to a query point. This problem has many natural applications, consider for example building a greedy set cover by selecting the point furthest from the points currently covered. Or as we will see in Chap- ter 3 we might use furthest neighbor in combination with near neighbor to find things that are "just right". We formally define the approximate furthest neighbor problem: Definition 1.2 (c-Approximate Furthest Neighbor). For c > 1. Given S ⊆ X and q ∈ X. Let x ∈ S denote the point in S furthest from q, report some point x(cid:48) ∈ S where D(x(cid:48), q) ≥ D(x, q)/c. The furthest neighbor in some sense exhibits more structure than the nearest neighbor. Consider a point set S ⊆ R2. No matter what q ∈ X is given, the point x ∈ S furthest from q will be a point on the convex hull of S as illustrated in Figure 1.5. If the convex hull is small and easily found an exact result could be efficiently produced by iterating through it. However, the convex hull can contain O(n) points and in high dimensions they are not easily found. A way to proceed is to approximate the convex hull, for example by the minimum enclosing ball. This always contains a √2-AFN [60], but for c < √2 we need a better approximation. In Chapter 2 we present an algorithm for c-AFN. We get O(dn1/c2) query time using O(dn2/c2) space. This work is the result of a collaborative effort with Ras- mus Pagh, Francesco Silvestri and Matthew Skala. The work was published as an article [97], and later in an extended journal version [98]. Here we give a brief high-level introduction to the main result. Chapter 2 also contains analysis for a query independent varia- tion of the data structure, space lower bounds as well as experimental results. The main algorithm is simi- lar to one introduced by Indyk [70]. His work intro- duces a decision algorithm for a fixed radius version of the problem and proceeds through binary search. We solve the c-AFN problem directly using a single data structure. Figure 1.5: A point set with its convex hull and minimum enclosing ball. 1.2. Problems and results 9 near far Figure 1.6: Distribution of ai · (x − q) for near and far x ∆ ai(x − q) We use the fact that in Rd, projections to a random vector preserve distances as stated in the following lemma: Lemma 1.1 (See Section 3.2 of Datar et al. [51]). For every choice of vectors x, y ∈ Rd: ai · (x − y) (cid:107)x − y(cid:107)2 ∼ N (0, 1). when the entries in ai are sampled from the standard normal distribution N (0, 1). So we can expect distances between projections to be normally dis- tributed around the actual distance. Points further from q will generally project to larger values as illustrated in Figure 1.6. This is helpful since it means that we can use well known bounds on the normal distribution to argue about the probability of a point projecting above or below some threshold ∆. We want to set ∆ so points close to q have a low probability of projecting above it, but points furthest from q still has a reasonably large probability of projecting above ∆. If we then examine all points projecting above ∆, one of them will likely be a c−AFN. To do this our structure uses a priority queue to pick the points along each random vector with largest projection value, as described in Section 2.2.1. 10 Chapter 1. Introduction (c, r, w)-Approximate Annulus Query (AAQ) 1.2.2 Sometimes we want to find the points that are not too near, not too far, but "just right". We could call this the Goldilocks problem, but formally we refer it as the annulus query problem. Figure 1.7: Goldilocks finds the porridge that is not too cold, not too hot, but "just right". ©Award Publications ltd. Annulus is french and latin for ring and the name comes from the shape of the valid area in the plane. The exact annulus query is illus- trated in Figure 1.8. Again, we will be working with an approximate version: Definition 1.3 ((c, r, w)-Approximate Annulus Query). For c > 1, r > 0,w > 1. If there exists a point x ∈ S such that r/w ≤ D(x, q) ≤ rw report some point x(cid:48) ∈ S where r/cw ≥ D(x(cid:48), q) ≤ crw, otherwise report nothing. A natural way to approach this problem is with a two part solution, one part filtering away points that are too far and the other removing those that are too near. In Chapter 3 we present a solution like this in (Rd, (cid:96)2) where we use locality sensitive hashing(LSH, see Section 1.3.7) for the first part and the AFN data structure from Chapter 2 for the sec- ond. Using an LSH with gap ρ, our combined data structure answers the (c, r, w)-Approximate Annulus Query with constant success prob- ability in time O(dnρ+1/c2) while using O(n2(ρ+1/c2)) additional space. This result was published in the journal version of the AFN paper [98]. 1.2. Problems and results 11 x q r/w rw Figure 1.8: The Annulus query around q returns x. (r, c, )-Distance Sensitive Approximate Membership Query (DAMQ) 1.2.3 Given a set S and a query point q a membership query asks if q is in S. In a famous result from 1970 Burton Bloom showed that the question can be answered using O(n log 1  ) space, where  is the probability of returning a false positive [25]. Importantly there are no false negatives (See Table 1.3). This one-sided error is of great importance in practice: If the set S we care about is relatively small in comparison to the universe X and queries are sampled more or less uniformly from X, we expect that in most cases q /∈ S. Since we never return a false negative, our only errors can occur on the small fraction of queries where we answer "yes". Answer "Yes" "No" x ∈ S correct false negative x /∈ S false positive correct Table 1.3: Membership query answers and error types. We can then use a secondary data structure to double checks all pos- itive answers. Since we will use it rarely, we can place the secondary structure somewhere slower to access, but where space is cheaper. For example on disk, as opposed to in memory. Or on a server somewhere, as opposed to locally. In this way the one-sided error allows us to use the approximate data structure to speed up most queries, while still giving exact answers. In a similarity search context we extend member- ship queries to be distance sensitive. We want a positive answer when something in S is similar to q, although perhaps not an exact match. 12 Chapter 1. Introduction Definition 1.4 ((r, c, )-Distance Sensitive Approximate Membership Query). For r > 0, c ≥ 1 and  ∈ [0, 1]. Given S ⊆ X and q ∈ X. • If ∃x ∈ S such that D(q, x) ≤ r report yes. • If ∀x ∈ S we have D(q, x) > cr report no with probability at least 1 − , or yes with probability at most . There is some prior work [77, 68], but these solutions yield false pos- itives as well as negatives. In Chapter 4 we present the first non-trivial solution with one-sided error. This work was co-authored with Mayank Goswami, Rasmus Pagh and Francesco Silvestri and was published at SODA in 2017 [62]. It turns out that unlike in the regular membership query, it is important to specify what the  error probability is over. If  is over the choice of q, the problem seems easier than if it is over the random choices made in the data structure and valid for all q. In the first case we call  the average error, in the latter the point-wise error. For ({0, 1}d, H) we present lower bounds (Section 4.3) for both cases as well as almost matching upper bounds for most parameter settings (Section 4.4). For a reasonable choice of parameters we get a space lower bound of Ω(n(r/c + log 1  )) bits for  point-wise error. To construct our upper bounds we represent the points in S with signatures that we construct to have some special properties. We let γ(x, y) denote the gap between the signatures of x and y. The value of the gap depends on the distance between the original two points. Crucially our construction guarantees that when the original distance is less than r the gap is always below a given threshold, but often above it when the original distance is greater cr. We can then answer the query by comparing the query signature to the collections of signatures from S. The space bounds follows from analyzing the necessary length of the signatures. Fast Nearest Neighbor preserving embeddings 1.2.4 So far we have been trying to circumvent the issues arising from high dimensionality by designing algorithms that give approximate results. Another was to achieve this is through dimensionality reduction. Broadly speaking the desire here is to find embeddings Φ : Rd → Rk with the property that D(Φx, Φy) ≈ D(x, y) and importantly k (cid:28) d. While finding Φ is not in it self a similarity search problem, it is a way of improving the performance on all approximate similarity search 1.2. Problems and results 13 problems. With Φ we can move a similarity problem from (Rd, D) into (Rk, D) and solve it there instead. In a famous result, Johnson and Lindenstrauss [74] showed a linear embedding from (Rd, (cid:96)2) with k = O( log n 2 ), while distorting distances by a factor at most (1 + ) (See lemma 5.1). The first aspect we might hope improve is getting k even smaller, but it has recently been shown that the original result is optimal [82, 81]. However, Indyk and Naor [73] showed that if we only care about preserving nearest neighbor distances, we can get significantly smaller k. Specifically, k can be made to depend not on n but on λs, the doubling constant of S (See def. 5.3). We call such embeddings nearest neighbor preserving (See def. 5.1). Aside from k, an important aspect is of course the time it takes to apply Φ. We can think of Φ as an k × d matrix, so it takes O(kd) time to apply it once. In 2009 Ailon and Chazelle [9] showed that the embedding matrix can be sparse if it is used in combination with some fast distance preserving operations. If f is the fraction of non-zero entries, this allow us to use fast matrix multiplication to apply the embedding in time O(kd f ). They showed a construction that gets f = O( log n In Chapter 5 we show that these two results can be happily married d ). to yield fast nearest neighbor preserving embeddings: Theorem 1.1 (Fast Nearest Neighbor Preserving Embeddings). For any (cid:19) S ⊆ Rd,  ∈ (0, 1) where S = n and δ ∈ (0, 1/2) for some (cid:18)log (2/) k = O 2 log (1/δ) log λS there exists a nearest neighbor preserving embedding Φ : Rd → Rk with parameters (, 1 − δ) requiring expected O operations. d log(d) + −2 log3 n (cid:16) (cid:17) The embedding construction is as suggested by [9], but with k bounded as in [73]. Our contribution is in analysing the requirements for nearest neighbor preserving embeddings and showing that they can be fulfilled by this sparse construction. We also offer some slight im- provement to the constants in f . 14 Chapter 1. Introduction (λ, ϕ)-Set Similarity join 1.2.5 The join is an important basic operation in databases. Typically records are joined using one or more shared key values. The similarity join is a variation where we instead join records if they are sufficiently similar: Definition 1.5 (Similarity Join). Given two sets S and R and a threshold λ, return the set S (cid:46)(cid:47)λ R = {(x, y)x ∈ S, y ∈ R, D(x, y) ≤ λ}. We will look at this problem not for sets of points, but for sets of sets, i.e. Set Similarity Join. To understand this change of setting let us briefly revisit the embedding of strings into (N2, H) in figure 1.1. If the ordering of the letters in each string is irrelevant or meaningless in a given application, the hamming distance seems a poor choice of distance function. We want D("ED", "DE") to be 0, not 2. This is captured by interpreting a string as a set of elements, as illustrated in Figure 1.9. B E D Figure 1.9: The sets {B, E} and {E, D}. Using the same letter to integer mapping as before, we think for example of "DE" as the set {3, 4} and S as a set In this setting we think of the dimension d of such sets. as the number of different elements, as opposed to using In the example d is the size of it for the size of the sets. the alphabet. We have then moved to the set P ([d]) and we switch to using similarity measures (See Section 1.3.2). The Set Similarity Join originates in databases where we might use it to perform entity resolution [16, 39, 104]. That is, iden- tify pairs (x ∈ S, y ∈ R) where x and y correspond to the same entity. These can then be used to merge data. Another popular use of similar- ity joins in practice is recommender systems. Here we link two similar, but different, entities in order to use the preferences of one to make recommendations to the other. In Chapter 6 we present a new algorithm, the CPSJoin, that solves the set similarity join problem with probabilistic bounds on recall, for- malized as: Definition 1.6 ((λ, ϕ)-Set Similarity Join). Given two sets of sets S and R, a threshold λ ∈ (0, 1) and recall probability ϕ ∈ (0, 1). Return L ⊆ S (cid:46)(cid:47)λ R such that for every (x, y) ∈ S (cid:46)(cid:47)λ R we have Pr[(x, y) ∈ L] ≥ ϕ. The CPSJoin is named after the Chosen Path algorithm [44] for the approximate near neighbor problem. We can think of the CPSJoin as an 1.3. Preliminaries and techniques 15 adaptive version of the Chosen Path algorithm, tailored to the (λ, ϕ)- Set Similarity Join problem (See Section 6.4.2 for a full comparison). The core idea is a randomized divide and conquer strategy. We can view the algorithm as running in a number of steps. At each step, we may either 1. solve the problem by brute force, or 2. divide the problem into smaller problems and handle them in sep- arate steps. The idea of the Chosen Path algorithm is to perform the division by selecting a random element from [d]. A new subproblem is then formed out of all entities containing that element. In this way the probability that x and y end up in the same subproblem is proportional to x ∩ y. This is repeated enough times to get the desired recall. We can view this process as forming a tree, at each step branching into smaller subproblems, until the leaves are eventually brute forced. The central question then is at what depth to stop branching. Building on previous techniques would suggest using either a global worst case depth, k, for all points [44, 59, 95], or an individual kx pr. point depth [7]. We develop an adaptive technique that picks out a point when the ex- pected number of comparisons to that point stops decreasing. We show that our adaptive strategy has several benefits. Our main theoretical contribution is showing that the query time is within a constant factor of the individually optimal method. The CPSJoin uses time It achieves recall ϕ = Ω(ε/ log(n)) and uses O(n log(n)/) working space with high probability. Note that we are trading time against recall and space. We also implemented CPSJoin and performed extensive experi- ments. Our experiments show speed-ups in the 2 − 50× range for 90% recall on a collection of standard benchmark data sets. 1.3 Preliminaries and techniques In this section we introduce the techniques that will be used throughout the thesis. The section serves both to acknowledge prior work and to ∑ x∈S O  ∑ y∈S\{x} min kx  . (sim(x, y)/λ)kx + (1/λ)kx 16 Chapter 1. Introduction highlight new techniques in the context of their priors. Readers familiar with randomized algorithms and data structures can skip ahead to Sec- tion 2. We will describe the techniques from a high level perspective for the purpose of establishing shared intuition and a common language. Computational Model 1.3.1 When devising new algorithms we will primarily be interested in their cost in terms of two resources, time and space (i.e. storage). To build precise arguments about the cost of a given algorithm we will need a mathematical model for how the algorithm will be carried out. Here we face a trade-off between the simplicity of the model, the general applicability and the precision. While these first two demands are somewhat correlated, it is difficult to fulfill all three simultaneously. However, our focus is on finding time and space costs that can be used to compare different algorithms and give an insight into their relative performance. Hence precision is of less importance, as long as algorithms are somewhat evenly affected. Unit cost models are well suited for this task. We will base our model on the real-RAM model as introduced by Shamos [105]. We could also use the word-RAM model, but by using full reals we avoid discussing issues of precision that are not at the core of the algorithms. However we do not have numerically unstable processes and results should hold in both models. To avoid unrealistic abuses, say by packing the input set into a single real, we do not have a modulo operation or integer rounding. We model the computers memory as consisting of infinitely many indexed locations Mi, each location holding a real number: M = {(i, Mi ∈ R)i ∈ N}. We assume that we can carry out any of the following operations at unit cost: • Read or Write any Mi. • Compare two reals, ≤, <, =, >,≥. • Arithmetic operations between two reals +,−,·, /. • Sample a random variable from a uniform, normal or binomial distribution. 1.3. Preliminaries and techniques 17 The time cost of an algorithm will then be the total number of these operations performed. When talking about search algorithms we will often split the time cost into preprocessing- and query time. All opera- tions that can be carried out without knowledge of the query point(s) are counted as preprocessing. Query time counts only the remaining operations. The storage requirement is simply the number of memory locations accessed. Of course, we will also try to be considerate of other resources, like how complex something is to implement, but we do not include these concerns in the model. We will be using standard O-notation [78] to give bounds in the model. In short, let g, f : X → R: • O( f (x)) denotes the set of all g(x) such that there exists positive constants C and x0 with g(x) ≤ C f (x) for all x ≥ x0. • Ω( f (x)) denotes the set of all g(x) such that there exists positive constants C and x0 with g(x) ≥ C f (x) for all x ≥ x0. Although O( f ) is a set, it is standard to use g = O( f ) and "g is O( f )" to mean g ∈ O( f ). O() is used to omit polylog factors. 1.3.2 Distance functions and similarity measures We will mostly be formalizing "similarity" through the inverse notion of distance. Given a point in space, similar things will be close, differing things far away. But we will also sometimes use direct similarity mea- sures. Table 1.4 contains the distance functions and similarity measures we will be using throughout. We write D(·,·) for distance functions, and sim(·,·) for similarity measures. This is a little confusing, but done for historical reasons. Both notions are well established in separate branches of mathematics. The distance functions are central in geometry, dating back to the ancient Greeks. Most of our work will focus on (cid:96)p norms, in particular the Euclidean distance (cid:96)2. For a thorough discussion of the (cid:96)p norms we refer to [101]. The similarity measures originated in biology where they where de- veloped to compare subsets of a bounded set, like [d] or the set of all flowers. In Chapter 6 we use Jaccard similarity as well as the Braun- Blanquet variation. These measures range between 0 and 1, with 0 being no common elements and 1 being duplicate sets. 18 Name Hamming distance Minkowski distance Euclidian distance Jaccard similarity Chapter 1. Introduction i Distance function 1 if xi = yi 0 else (cid:40) Input (cid:16)∑d i xi − yip(cid:17)1/p x, y ∈ Xd H(x, y) = ∑d (cid:113) x, y ∈ Xd ∑d x, y ∈ Xd i xi − yi2 A, B ⊆ X J(A, B) = A∩B A∪B (cid:96)p(x, y) = (cid:96)2(x, y) = Braun-Blanquet similarity A, B ⊆ X BB(A, B) = max(A,B) Table 1.4: Distance functions and Similarity measures A∩B The odd space out is the Hamming space. We could define the Ham- ming similarity as (d − H(x, y))/d, but it is standard in the literature to use Hamming distance. A practitioner wondering about the correct embedding for a concrete application might use the notion of "opposite" as a start. It is always easy to define equal, but we can only define opposite in a bounded space. If we are in an unbounded space, say (Rd, (cid:96)2), no matter where we would put "the opposite" of a point, there is always something a little further away. If on the other hand it is easy to identify two things as completely different, a bounded space is probably the right choice. 1.3.3 Notation An overview of the notation used for sets is available in Table 1.1. Ta- ble 1.2 contains the reserved symbols we use when solving similarity search problems. In Table 1.4 we list the distance functions and similar- ity measures used. For random variables we write X ∼ Y when X and Y have the same distribution (See Section 1.3.5). We frequently work with balls, so some special notation for these is helpful. The d dimensional ball is defined in (Xd, D) as Bd(x, r) = {p ∈ XdD(p.x) ≤ r}. If we are arguing about the any ball of a given radius we write Bd(r). We will omit the d subscript when it is clear from the context. 1.3. Preliminaries and techniques 19 1.3.4 Divide and Conquer Much of the successful early work in similarity search is based on divide and conquer designs [21]. The main idea here is to divide S ⊆ X into halves along each dimension and recursively search through the parts until the nearest neighbor is found. This leads to powerful data struc- tures in low-dimensional spaces, but ultimately also to the amount of work growing exponentially in d. The kd-tree is a well known data struc- ture based on this design. For the NN problem it promises O (log n) query time on random data, O (n log n) preprocessing time and O (n) storage [20, 58], but for high dimensions it converges toward linear query time. In Chapter 6 the paradigm is used to recursively break problems into smaller sub-problems that are then individually handled. Of course the challenge then is to ensure that all relevant answers to the larger prob- lem emerge as answers in one of the sub problems. For exact algorithms, like the classical closest pair in two dimensions [67] problem, this is han- dled by checking all possible ways a solution could have been eliminated when generating sub problems. In Chapter 6 we handle it by randomly generating enough sub-problems to give probabilistic guarantees that all close pairs are checked. Randomization and Concentration 1.3.5 Algorithms that make random choices, or Randomized algorithms, are at the heart of modern similarity search. Randomization was already im- portant in early work to speed up construction of the d dimensional voronoi diagram [45], and it is essential in the later LSH based tech- niques. In order to analyse such algorithms we will borrow many ideas and results from the field of probability theory. We only cover a few of the most used tools here. See for example [89, 90] or [54] for an overview. If our algorithm is to take a random choice it must have access to a source of randomness. In reality this will normally be simulated with psudo-random numbers generated by another algorithm, but we will assume that we can access some random process to generate a random event. Let the sample space, Ω, be the set of all possible outcomes of a random event. 20 Chapter 1. Introduction Definition 1.7. A random variable, X, is a real valued function on the sample space X : Ω → R. A discrete random variable X takes on only a finite or countably infinite number of values. We will say that random variable X has cumulative distribution func- tion F if When F(x) has the form (cid:82) x F(x) = Pr[X ≤ x]. −∞ f (t)dt, or ∑x(cid:48)≤x f (x(cid:48)) for discrete X, we say that X has probability density function f (x). When two random variables X, Y have the same cumultative distribution function, i.e. ∀x Pr[X ≤ x] = Pr[Y ≤ x], it implies that ∀x Pr[X = x] = Pr[Y = x], (1.1) and we say that X and Y have the same distribution. We write this as X ∼ Y. We avoid using eq. 1.1 directly for this, because if X is not discrete Pr[X = x] = 0 for all x. For some distributions that we encounter often we use special symbols: Definition 1.8 (The normal distribution). We write X ∼ N (µ, σ2). When X follows the normal distribution with mean µ ∈ R and variance σ2 ∈ R, defined by probability density function: . f (x) = 1 (x−µ)2 2σ2 e √2πσ2 We refer to N (0, 1) as the standard normal distribution. The normal distribution is also called the Gaussian distribution and we sometimes refer to random variables as "Gaussians" if they follow the normal dis- tribution. When building randomized algorithms we often return to the Gaussian distribution. One reason is that it is 2−stable [118]: We call a distribution D over R p−stable where p ≥ 0, if for any real numbers v1, . . . , vd and for X, X1, X2, . . . , Xd ∼ D: (cid:32) d∑ i (cid:33)1/p vip X d∑ i viXi ∼ So for X, X1, X2, . . . , Xd ∼ N (0, 1) and some vector x ∈ Rd we have ∑ Xixi ∼ (cid:107)x(cid:107)2X ∼ Y where Y ∼ N (0,(cid:107)x(cid:107)2 2). 1.3. Preliminaries and techniques 21 Definition 1.9 (The binomial distribution). We write When X follows the binomial distribution with n ∈ N trials and success probability p ∈ [0, 1]. The probability density function is px(1 − p)n−x. x X ∼ B(n, p). (cid:19) (cid:18)n f (x) = The binomial distribution can be understood as counting the num- ber of heads in a series of n coin flips, if the coin shows head with probability p. A single flip of the coin is referred to as a Bernoulli trial. Note that X is then a discrete random variable, the only outcomes are the integers from 0 to n. This distribution arises often when working in Hamming space due to the binary nature of the space. A very powerful tool that we use frequently to analyse random pro- cesses is Markov's inequality: Theorem 1.2 (Markov's inequality). Let X be a non-negative random vari- able. Then, for all a > 0, Pr[X ≥ a] ≤ E[X] a . Using Markov's inequlity directly yields useful, but pretty loose bounds. If we have a good grasp of the moment generating function of X, M(t) = E[etX], we can get much stronger bounds out of Markov's inequality. The idea is to analyse eX rather than X. Since eX ≥ 0 even if X < 0 this also expands the range of variables we can use. We re- fer to bounds derived this way as "Chernoff bounds". For example for X ∼ B(n, 1/2) and  > 0 we can use Markov's inequality directly to get Pr[X ≥ (1 + ) n 2 ] ≤ 1 1 +  . While a Chernoff bound yields exponentially stronger bounds and captures the increasing concentration in n, Pr[X ≥ (1 + ) n 2 ] ≤ e−2n/2 . Even if we fix n, this is a lot better as illustrated in Figure 1.10. 22 Chapter 1. Introduction Figure 1.10: Illustration of Markov and Chernoff type bounds. 1.3.6 Hashing We use hashing as an umbrella term for applying functions that map some universe U into a limited range of M integers. Often we want functions that spread a large universe evenly over the output range. This idea was formalized by Carter and Wegman in the notions of universal hashing [33] and k-independent hashing [112]. We call a family of hash functions H universal if for a randomly chosen h ∈ H and distinct x1, x2 ∈ U and randomly chosen y1, y2 ∈ [M]: Pr[h(x1) = y1 ∧ h(x2) = y2] ≤ 1 M2 And we say that the family is k-independent if for any keys (x1,· · · , xk) ∈ U k and any (y1,· · · , yk) ∈ [M]k: Pr[h(x1) = y1 ∧ · · · ∧ h(xk) = yk] = M−k So for k ≥ 2, k-independent families are strongly universal. Another useful property was introduced by Broder et. al. [28, 31]: Let Sn be the set of all permutations of [n]. We say that a family of permutations F ⊆ Sn is min-wise independent if for any X ⊆ [n] and any x ∈ X, when π is chosen at random from F we have Pr[min(π(X)) = π(x)] = . 1 X That is, every element of X is equally likely to permute to the small- est value. We call H a familiy of MinHash functions if for a random h ∈ H, h(X) = min(π(X)) where π is a random permutation from a min-wise independent family of permutations. MinHash functions are very useful in Set Similarity because MarkovChernoff0.51.01.52.00.20.40.60.81.0 1.3. Preliminaries and techniques 23 Pr[h(x) = h(y)] = x ∩ y x ∪ y = J(x, y) . Let Xi = 1 if hi(x) = hi(y) and 0 otherwise. A Chernoff bound tells us that if X = 1 t ∑t i Xi, (cid:114) 3 ln t Pr[X − J(x, y) ≥ So we can get precise estimates of the Jaccard similarity from a small J(x, y)] ≤ 2e−J(x,y) ln t = tJ(x,y) (1.2) t . number of hash functions. Of course the number of permutations of [n] is n! so in practice we 2 allow F ⊆ Sn to be −min-wise independent: Pr[min(π(X)) = π(x)] ∈ 1 ±  X In practice we also want hash functions that are fast to evaluate and easy to implement. Zobrist hashing, or simple tabulation hashing, fits this description. It is −min-wise independent with  shrinking polynomi- ally in X [100], 3−independent and fast in practice [108]. Tabulation hashing works by splitting keys x = (x0,· · · , xc−1) into c parts. Each part is treated individually by mapping it to [M], say with a table of random keysto,· · · , tv−1 : U → [M]. Finally h : U c → [M] is computed by: Locality Sensitive Hashing h(x) = ⊕i∈[c]ti(xi) Where ⊕ denotes the bit-wise XOR operation. 1.3.7 Locality Sensitive Hashing(LSH) is the current state of the art for solving the ANN problem(Definition 1.1). The technique was first introduced by Indyk, Gionis and Motwani [72, 59] with an implementation that is still the best know for Hamming space. Since then it has been a subject of intense research. See [11] for an overview. The basic idea is to partition the input data using a hash function, H, that is sensitive to the metric space location of the input. This means that the collision probability is larger for inputs close to each other than for inputs that are far apart. This requirement is normally formalized as: (cid:40) Pr [H(u) = H(v)] ≥ P1 when D(u, v) ≤ r ≤ P2 when D(u, v) ≥ cr (1.3) 24 Chapter 1. Introduction P r[h(x) = h(q)] P r[h(x) = h(q)] 1 1 P1 P2 r cr (a) Ideal x − q r cr (b) Achievable x − q Figure 1.12: Ideal vs. achievable LSH function. where P1 > P2. So the of points in S colliding with q under H are likely near neighbors. The key to success for this method is in achieving a large gap between P1 and P2, quantified as ρ = − ln P1 (See Figure 1.12). Ideally, − ln P2 P2 would be 0, for example by the hash function returning the cell of the voronoi diagram associated with a point. But that would trap the function in the curse of dimensionality, either taking up too much space or time. So instead we use several functions that each return imperfect partitioning, as illustrated in Figure 1.11, but are fast to evaluate. Using a hash function with these properties the (c, r)-ANN problem can be solved using n1+ρ+o(1) extra space with dnρ+o(1) query time [65]. Recently lower bounds have been published on ρ for the (cid:96)1 [65] and (cid:96)2 [92] norm, and a re- sult for (cid:96)2 with ρ = 1/c2 has been know for a some years [12]. In Chapter 3 we explore the idea of storing the contents of the LSH buckets in a particular order. In our case we use pro- jection values onto a random line as approxima- tion of nearness to the convex hull. However the technique could be expanded to other ways of prioritizing points in scenarios where some sub- set of the nearest neighbors are of more interest than others. Figure 1.11: A non-perfect par- titioning of points in R2 Chapter 2 Furthest Neighbor Much recent work has been devoted to approximate nearest neighbor queries. Motivated by applications in recommender systems, we con- sider approximate furthest neighbor (AFN) queries and present a simple, fast, and highly practical data structure for answering AFN queries in high-dimensional Euclidean space. The method builds on the technique of Indyk (SODA 2003), storing random projections to provide sublin- ear query time for AFN. However, we introduce a different query al- gorithm, improving on Indyk's approximation factor and reducing the running time by a logarithmic factor. We also present a variation based on a query-independent ordering of the database points; while this does not have the provable approximation factor of the query-dependent data structure, it offers significant improvement in time and space complex- ity. We give a theoretical analysis, and experimental results. 2.1 Introduction The furthest neighbor query is an important primitive in computational geometry. For example it can been used for computing the minimum spanning tree or the diameter of a set of points [5, 53]. It is also used in recommender systems to create more diverse recommenda- tions [102, 103]. In this Chapter we show theoretical and experimental results for the c-approximate furthest neighbor problem (c-AFN, Defini- tion 1.2) in (Rd, (cid:96)2). We present a randomized solution with a bounded probability of not returning a c-AFN. The success probability can be made arbitrarily close to 1 by repetition. 26 q Chapter 2. Furthest Neighbor x x(cid:48) We describe and analyze our data struc- tures in Section 2.2. We propose two approaches, both based on random pro- jections but differing in what candidate points are considered at query time. In the main query-dependent version the can- didates will vary depending on the given query, while in the query-independent ver- sion the candidates will be a fixed set. x−q c Figure 2.1: Returning a (c)-AFN. The query-dependent data structure is presented in Section 2.2.1. It returns the c- approximate furthest neighbor, for any c > 1, with probability at least 0.72. When the number of dimensions is O(log n), our result requires O(n1/c2) time per query and O(n2/c2) total space, where n denotes the input size. Theorem 2.3 gives bounds in the general case. This data structure is closely similar to one proposed by Indyk [70], but we use a different approach for the query algorithm. The query-independent data structure is presented in Section 2.2.2. When the approximation factor is a constant strictly between 1 and √2, this approach requires 2O(d) query time and space. This approach is significantly faster than the query dependent approach when the di- mensionality is small. The space requirements of our data structures are quite high: the query-independent data structure requires space exponential in the di- mension, while the query-dependent one requires more than linear space when c < √2. However, we claim that this bound cannot be significantly improved. In Section 2.2.3 we show that any data structure that solves the c-AFN by storing a suitable subset of the input points must store at least min{n, 2Ω(d)} − 1 data points when c < √2. Section 2.3 describes experiments on our data structure, and some modified versions, on real and randomly-generated data sets. In prac- tice, we can achieve approximation factors significantly below the √2 theoretical result, even with the query-independent version of the algo- rithm. We can also achieve good approximation in practice with sig- nificantly fewer projections and points examined than the worst-case bounds suggested by the theory. Our techniques are much simpler to implement than existing methods for √2-AFN, which generally require convex programming [46, 88]. Our techniques can also be extended to general metric spaces. 2.1. Introduction 27 Related work 2.1.1 Exact furthest neighbor In two dimensions the furthest neighbor prob- lem can be solved in linear space and logarithmic query time using point location in a furthest point Voronoi diagram (see, for example, de Berg et al. [22]). However, the space usage of Voronoi diagrams grows exponen- tially with the number of dimensions, making this approach impractical in high dimensions. More generally, an efficient data structure for the exact furthest neighbor problem in high dimension would lead to sur- prising algorithms for satisfiability [113], so barring a breakthrough in satisfiability algorithms we must assume that such data structures are not feasible. Further evidence of the difficulty of exact furthest neighbor is the following reduction: Given a set S ⊆ {−1, 1}d and a query vec- tor q ∈ {−1, 1}d, a furthest neighbor (in Euclidean space) from −q is a vector in S of minimum Hamming distance to q. That is, exact furthest neighbor is at least as hard as exact nearest neighbor in d-dimensional Hamming space, which seems to be very hard to do in n1−Ω(1) without using exponential space [113, 8]. Approximate furthest neighbor Agarwal et al. [5] proposes an al- gorithm for computing the c-AFN for all points in a set S in time O where n = S and 1 < c < 2. Bespamyatnikh [24] gives a dynamic data structure for c-AFN. This data structure relies on (cid:16) n/(c − 1)(d−1)/2(cid:17) fair split trees and requires O(cid:0)1/(c − 1)d−1(cid:1) time per query and O (dn) space, with 1 < c < 2. The query times of both results exhibit an expo- nential dependency on the dimension. Indyk [70] proposes the first ap- proach avoiding this exponential dependency, by means of multiple ran- dom projections of the data and query points to one dimension. More precisely, Indyk shows how to solve a fixed radius version of the problem where given a parameter r the task is to return a point at distance at least r/c given that there exist one or more points at distance at least r. Then, he gives a solution to the furthest neighbor problem with approximation factor c + δ, where δ > 0 is a sufficiently small constant, by reducing it to queries on many copies of that data structure. The overall result is space O(dn1+1/c2) and query time O(dn1/c2), which improved the pre- vious lower bound when d = Ω (log n). The data structure presented in this chapter shows that the same basic method, multiple random projec- tions to one dimension, can be used for solving c-AFN directly, avoiding the intermediate data structures for the fixed radius version. Our result 28 Chapter 2. Furthest Neighbor is then a simpler data structure that works for all radii and, being inter- ested in static queries, we are able to reduce the space to O(dn2/c2). Methods based on an enclosing ball Goel et al. [60] show that a √2- approximate furthest neighbor can always be found on the surface of the minimum enclosing ball of S. More specifically, there is a set S∗ of at most d + 1 points from S whose minimum enclosing ball con- tains all of S, and returning the furthest point in S∗ always gives a √2- approximation to the furthest neighbor in S. (See also Appendix A.2). This method is query independent in the sense that it examines the same set of points for every query. Conversely, Goel et al. [60] show that for a random data set consisting of n (almost) orthonormal vectors, finding a c-approximate furthest neighbor for a constant c < √2 gives the ability to find an O(1)-approximate near neighbor. Since it is not known how to do that in time no(1) it is reasonable to aim for query times of the form n f (c) for approximation c < √2. We also give a lower bound supporting this view in Section 2.2.3. Applications in recommender systems Several papers on recom- mender systems have investigated the use of furthest neighbor search [102, 103]. The aim there was to use furthest neighbor search to create more diverse recommendations. However, these papers do not address performance issues related to furthest neighbor search, which are the main focus of our efforts. The data structures presented in this chapter are intended to improve performance in recommender systems relying on furthest neighbor queries. Other related works on recom- mender systems include those of Abbar et al. [1] and Indyk et al. [71], which use core-set techniques to return a small set of recommendations no two of which are too close. In turn, core-set techniques also underpin works on approximating the minimum enclosing ball [18, 79]. 2.1.2 Notation In this chapter we will use arg maxm S that have the largest values of f (x), breaking ties arbitrarily. S f (x) for the set of m elements from 2.2. Algorithms and analysis 29 2.2 Algorithms and analysis Furthest neighbor with query-dependent candidates 2.2.1 Our data structure works by choosing a random line and storing the order of the data points along it. Two points far apart on the line are likely far apart in the original space. So given a query we can the points furthest from the query on the projection line, and take those as candi- dates for furthest point in the original space. We build several such data structures and query them in parallel, merging the results. For any 1 ≤ i ≤ (cid:96), we let Si = arg maxm Given a set S ⊆ Rd of size n (the input data), let (cid:96) = 2n1/c2 (the number of random lines) and m = 1 + e2(cid:96) logc2/2−1/3 n (the number of candidates to be examined at query time), where c > 1 is the desired approximation factor. We pick (cid:96) random vectors a1, . . . , a(cid:96) ∈ Rd with each entry of ai coming from the standard normal distribution N(0, 1). x∈S ai · x and store the elements of Si in sorted order according to the value ai · x. Our data structure for c-AFN consists of (cid:96) subsets S1, . . . , S(cid:96) ⊆ S, each of size m. Since these subsets come from independent random projections, they will not nec- essarily be disjoint in general; but in high dimensions, they are unlikely to overlap very much. At query time, the algorithm searches for the furthest point from the query q among the m points in S1, . . . , S(cid:96) that maximize aix − aiq, where x is a point of Si and ai the random vector used for constructing Si. The pseudocode is given in Algorithm 1. We observe that although the data structure is essentially that of Indyk [70], our technique differs in the query procedure. Note that early termination is possible if r is known at query time. Correctness and analysis The algorithm examines distances to a set of m points with maximal projection values, we will call the set Sq: Sq = arg mmax x∈∪Si ai · (x − q), Sq = m. We choose the name Sq to emphasize that the set changes based on q. Our algorithm succeeds if and only if Sq contains a c-approximate furthest neighbor. We now prove that this happens with constant prob- ability. We make use of the following standard lemmas that can be found, for example, in the work of Datar et al. [51] and Karger, Motwani, and Sudan [76]. 30 Chapter 2. Furthest Neighbor decreasing order of ai · x. A query point q. Algorithm 1: Query-dependent approximate furthest neighbor Input: (cid:96) orderings of the input set S. Each S1≤i≤(cid:96) referencing S in 1 P ← An empty priority queue of (point, integer) pairs; 2 Q ←An empty array of reals; 3 I ←An empty array of iterators; 4 for i = 1 to (cid:96) do Qi ← ai · q; 5 Ii ←An iterator into Si; 6 Retrieve x from Ii and advance Ii; 7 Insert (x, i) into P with priority ai · x − Qi; 8 9 rval ← ⊥; 10 for j = 1 to m do 11 12 13 14 15 16 return rval (x, i) ← Highest priority element from P; if rval = ⊥ or x is further than rval from q then Retrieve x from Ii and advance Ii; Insert (x, i) into P with priority ai · x − Qi; rval ← x Lemma 2.1 (See Section 3.2 of Datar et al. [51]). For every choice of vectors x, y ∈ Rd: ai · (x − y) (cid:107)x − y(cid:107)2 ∼ N(0, 1). Lemma 2.2 (See Lemma 7.4 in Karger, Motwani, and Sudan [76]). For every t > 0, if X ∼ N(0, 1) then 1 t3 t − · e−t2/2 ≤ Pr[X ≥ t] ≤ 1 √2π · 1 t · e−t2/2 (cid:18)1 (cid:19) 1 √2π · The next lemma follows, as suggested by Indyk [70, Claims 2-3]. the equation et2/2tc2 = n/(2π)c2/2 (that is, t = O(cid:0)(cid:112)log n(cid:1)). Then, for a Lemma 2.3. Let p be a furthest neighbor from the query q with r = (cid:107)p − q(cid:107)2, and let p(cid:48) be a point such that (cid:107)p(cid:48) − q(cid:107)2 < r/c. Let ∆ = rt/c with t satisfying 2.2. Algorithms and analysis 31 sufficiently large n, we have (cid:2)a · (p(cid:48) − q) ≥ ∆(cid:3) logc2/2−1/3 n Pr a 1 n1/c2 . ≤ Pr n a [a · (p − q) ≥ ∆] ≥ (1 − o(1)) (cid:3) (cid:17)c2−1 1 t√2π (cid:2)X ≥ ∆/(cid:107)p(cid:48) − q(cid:107)2 (cid:16) ≤ Pr e−t2/2 a a 1 √2π Proof. Let X ∼ N (0, 1). By Lemma 2.1 and the right part of Lemma 2.2, we have for a point p(cid:48) that (cid:2)a · (p(cid:48) − q) ≥ ∆(cid:3) = Pr O(cid:0)(cid:112)log n(cid:1), and holds for a sufficiently large n. Similarly, by Lemma 2.1 (cid:18) c [X ≥ ∆/(cid:107)p − q(cid:107)2] = Pr [a · (p − q) ≥ ∆] = Pr 1 √2π [X ≥ ∆/r] = Pr e−t2/(2c2) ≥ (1 − o(1)) The last step follows because et2/2tc2 = n/(2π)c2/2 implies that t = and the left part of Lemma 2.2, we have for a furthest neighbor p that [X ≥ ∆c/r] = Pr a logc2/2−1/3 n n ≤ [X ≥ t/c] 1 n1/c2 . (cid:17)3(cid:19) (cid:16) c t t ≤ t − [X ≥ t] . a ≥ a a Pr a Pr a ≤ n (cid:111)(cid:17) Theorem 2.1. The data structure when queried by Algorithm 1 returns a c- (cid:17) AFN of a given query with probability 1 − 2/e2 > 0.72 in (cid:16) O n1/c2 logc2/2−1/3 n(d + log n) time per query. The data structure requires O(n1+1/c2(d + log n)) preprocess- ing time and total space O min dn2/c2 logc2/2−1/3 n, dn + n2/c2 logc2/2−1/3 n . (cid:16) (cid:110) Proof. The space required by the data structure is the space required for storing the (cid:96) sets Si. If for each set Si we store the m ≤ n points and the projection values, then O ((cid:96)md) memory locations are required. On the other hand, if pointers to the input points are stored, then the total re- quired space is O ((cid:96)m + nd). The representations are equivalent, and the 32 Chapter 2. Furthest Neighbor best one depends on the value of n and d. The claim on space require- ment follows. The preproceesing time is dominated by the computation of the n(cid:96) projection values and by the sorting for computing the sets Si. Finally, the query time is dominated by the at most 2m insertion or deletion operations on the priority queue and the md cost of searching for the furthest neighbor, O (m(log (cid:96) + d)). We now upper bound the success probability. Again let p denote a furthest neighbor from q and r = (cid:107)p − q(cid:107)2. Let p(cid:48) be a point such that (cid:107)p(cid:48) − q(cid:107)2 < r/c, and ∆ = rt/c with t such that et2/2tc2 = n/(2π)c2/2. The query succeeds if 1. ai(p − q) ≥ ∆ for at least one projection vector ai, and 2. the (multi)set S = {p(cid:48)∃i : ai(p(cid:48) − q) ≥ ∆,(cid:107)p(cid:48) − q(cid:107)2 < r/c} contains at most m − 1 points. If both (1) and (2) hold, then the size m set of candidates Sq examined by the algorithm must contain the furthest neighbor p. Note that we do not consider points at distance larger than r/c but smaller than r: they are c-approximate furthest neighbors of q and can only increase the success probability of our data structure. By Lemma 2.3, (1) holds with probability 1/n1/c2. Since there are (cid:96) = 2n1/c2 independent projections, this event fails to happen with probability at most (1 − 1/n1/c2)2n1/c2 ≤ 1/e2. For a point p(cid:48) at dis- tance at most r/c from q, the probability that ai(p(cid:48) − q) ≥ ∆ is less than (logc2/2−1/3 n)/n by Lemma 2.3. Since there are (cid:96) projections of n points, the expected number of such points is (cid:96) logc2/2−1/3 n. Then, we have that S is greater than m − 1 with probability at most 1/e2 by the Markov in- equality. Note that a Chernoff bound cannot be used since there exists a dependency among the projections onto the same random vector ai. By a union bound, we can therefore conclude that the algorithm succeeds with probability at least 1 − 2/e2 ≥ 0.72. 2.2.2 Suppose instead of determining the candidates depending on the query point by means of a priority queue, we choose a fixed candidate set to be used for every query. The √2-approximation the minimum enclosing sphere is one example of such a query-independent algorithm. In this Furthest neighbor with query-independent candidates 2.2. Algorithms and analysis 33 section we consider a query-independent variation of our projection- based algorithm. During preprocessing, we choose (cid:96) unit vectors y1, y2, . . . , y(cid:96) inde- pendently and uniformly at random over the sphere of unit vectors in d dimensions. We project the n data points in S onto each of these unit vectors and choose the extreme data point in each projection; that is, (cid:26) (cid:27) (cid:12)(cid:12)(cid:12)(cid:12) i ∈ [(cid:96)] arg max x∈S x · yi . The data structure stores the set of all data points so chosen; there are at most (cid:96) of them, independent of n. At query time, we check the query point q against all the points we stored, and return the furthest one. To prove a bound on the approximation, we will use the following result of Böröczky and Wintsche [27, Corollary 1.2]. Note that their notation differs from ours in that they use d for the dimensionality of the surface of the sphere, hence one less than the dimensionality of the vectors, and c for the constant, conflicting with our c for approximation factor. We state the result here in terms of our own variable names. Lemma 2.4 (See Corollary 1.2 in Böröczky and Wintsche [27]). For any angle ϕ with 0 < ϕ < arccos 1/√d, in d-dimensional Euclidean space, there exists a set V of at most Cd(ϕ) unit vectors such that for every unit vector u, there exists some v ∈ V with the angle between u and v at most ϕ, and 3 2 ln(1 + (d + 1) cos2 ϕ) , V ≤ Cd(ϕ) = γ cos ϕ · where γ is a universal constant. sind+1 ϕ · (d + 1) (2.1) 1 2 arccos 1 Let ϕc = 1 c ; that is half the angle between two unit vectors whose dot product is 1/c, as shown in Figure 2.2. Then by choosing (cid:96) = O(Cd(ϕc) · log Cd(ϕc)) unit vectors uniformly at random, we will argue that with high probability we choose a set of unit vectors such that every unit vector has dot product at least 1/c with at least one of them. Then the data structure achieves c-approximation on all queries. Theorem 2.2. With (cid:96) = O( f (c)d) for some function f of c and any c such that 1 < c < 2, with high probability over the choice of the projection vectors, the data structure returns a d-dimensional c-approximate furthest neighbor on every query. 34 Chapter 2. Furthest Neighbor P 1 ϕc = 1 2 arccos 1 c S Q arccos 1 c R 1 c Figure 2.2: Choosing ϕc. Proof. Let ϕc = 1 apply the usual half-angle formulas as follows: c . Then, since 1 2 arccos 1 c is between 1 2 and 1, we can sin ϕc = sin cos ϕc = cos 1 2 1 2 arccos arccos 1 c 1 c = = √1 − cos arccos 1/c √1 + cos arccos 1/c √2 √2 √1 − 1/c √1 + 1/c √2 √2 = = Substituting into (2.1) from Lemma 2.4 gives Cd(ϕc) = γ (d + 1)3/2 ln 1 + (d + 1) 1 + 1/c 2 2d/2√1 + 1/c (cid:32)(cid:18) (1 − 1/c)(d+1)/2 (cid:19)(d+1)/2 2 = O 1 − 1/c (cid:18) (cid:33) d3/2 log d . . (cid:19) Let V be the set of Cd(ϕc) unit vectors from Lemma 2.4; every unit vector on the sphere is within angle at most ϕc from one of them. The vectors in V are the centres of a set of spherical caps that cover the sphere. Since the caps are all of equal size and they cover the sphere, there is probability at least 1/Cd(ϕc) that a unit vector chosen uniformly at random will be inside each cap. Let (cid:96) = 2Cd(ϕc) ln Cd(ϕc). This (cid:96) = O( f (c)d). Then for each of the caps, the probability none of the pro- jection vectors yi is within that cap is (1− 1/Cd(ϕc))(cid:96), which approaches 2.2. Algorithms and analysis 35 exp(−2 ln Cd(ϕc)) = (Cd(ϕc))−2. By a union bound, the probability that every cap is hit is at least 1 − 1/Cd(ϕc). Suppose this occurs. Then for any query, the vector between the query and the true fur- thest neighbor will have angle at most ϕc with some vector in V, and that vector will have angle at most ϕc with some projection vector used in building the data structure. Figure 2.2 illustrates these steps: if Q is the query and P is the true furthest neighbor, a projection onto the unit vector in the direction from Q to P would give a perfect approximation. The sphere covering guarantees the existence of a unit vector S within an angle ϕc of this perfect projection; and then we have high probability of at least one of the random projections also being within an angle ϕc of S. If that random projection returns some candidate other than the true furthest neighbor, the worst case is if it returns the point labelled R, which is still a c-approximation. We have such approximations for all queries simultaneously with high probability over the choice of the (cid:96) projection vectors. Note that we could also achieve c-approximation deterministically, with somewhat fewer projection vectors, by applying Lemma 2.4 di- rectly with ϕc = arccos 1/c and using the centres of the covering caps as the projection vectors instead of choosing them randomly. That would require implementing an explicit construction of the covering, however. Böröczky and Wintsche [27] argue that their result is optimal to within a factor O(log d), so not much asymptotic improvement is possible. A lower bound on the approximation factor 2.2.3 In this section, we show that a data structure aiming at an approxima- tion factor less than √2 must use space min{n, 2Ω(d)} − 1 on worst-case data. The lower bound holds for those data structures that compute the approximate furthest neighbor by storing a suitable subset of the input points. Theorem 2.3. Consider any data structure D that computes the c-AFN of an n-point input set S ⊆ Rd by storing a subset of the data set. If c = √2(1 − ) with  ∈ (0, 1), then the algorithm must store at least min{n, 2Ω(2d)} − 1 points. Proof. Suppose there exists a set S(cid:48) of size r = 2Ω((cid:48)2d) such that for any x ∈ S(cid:48) we have (1 − (cid:48)) ≤ (cid:107)x(cid:107)2 2 ≤ (1 + (cid:48)) and x · y ≤ 2(cid:48), with 36 Chapter 2. Furthest Neighbor (cid:48) ∈ (0, 1). We will later prove that such a set exists. We now prove by contradiction that any data structure requiring less than min{n, r} − 1 input points cannot return a √2(1 − )-approximation. Assume n ≤ r. Consider the input set S consisting of n arbitrary points of S(cid:48). Let the data structure, D ⊂ S, be any n − 1 of these points. Set the query q to −x, where x ∈ S \ D. The furthest neighbor is x and it is at distance (cid:107)x − (−x)(cid:107)2 ≥ 2√1 − (cid:48). On the other hand, for any point y in D, we get (cid:107)y − (−x)(cid:107)2 = (cid:107)x(cid:107)2 2 + (cid:107)y(cid:107)2 2 + 2x · y ≤ 2(1 + (cid:48)) + 4(cid:48). Therefore, the point returned by the data structure cannot be better than a c(cid:48) approximation with (cid:113) c(cid:48) = (cid:107)x − (−x)(cid:107)2 (cid:107)y − (−x)(cid:107)2 ≥ √2 . (2.2) The claim follows by setting (cid:48) = (2 − 2)/(1 + 3(1 − )2). Assume now that n > r. Without loss of generality, let n be a multiple of r. Consider as an input the n/r copies of each vector in S(cid:48), each copy expanded by a factor i for any i ∈ [n/r]; specifically, let S = {ixx ∈ S(cid:48), i ∈ [n/r]}. Let D be any r − 1 points from S. Then there exists a point x ∈ S(cid:48) such that for every i ∈ [1, n/r], ix is not in the data structure. Consider the query q = −hx where h = n/r. The furthest neighbor of q in S is −q and it has distance (cid:107)q − (−q)(cid:107)2 ≥ 2h√1 − (cid:48). On the other hand, for every point y in the data structure, we get (cid:113) (cid:114) 1 − (cid:48) 1 + 3(cid:48) (cid:113) (cid:113) (cid:107)y − (−hx)(cid:107)2 = h2(cid:107)x(cid:107)2 2 + (cid:107)y(cid:107)2 2 + 2hx · y ≤ 2h2(1 + (cid:48)) + 4h2(cid:48). We then get the same approximation factor c(cid:48) given in equation 2.2, and the claim follows. The existence of the set S(cid:48) of size r follows from the Johnson- Lindenstrauss lemma [87]. Specifically, consider an orthornormal base x1, . . . xr of Rr. Since d = Ω(cid:0)log r/(cid:48)2(cid:1), by the Johnson-Lindenstrauss lemma there exists a linear map f (·) such that (1 − (cid:48))(cid:107)xi − xj(cid:107)2 (cid:107) f (xi) − f (xj)(cid:107)2 for any i, j. We also have that f (xi) · f (xj) = ((cid:107) f (xi)(cid:107)2 2 + (cid:107) f (xj)(cid:107)2 (cid:107) f (xi) − f (xj)(cid:107)2 to set S(cid:48) to { f (x1), . . . , f (xr)}. 2 ≤ 2 ≤ (1 + )(cid:107)xi − xj(cid:107)2 2 ≤ (1 + (cid:48)) 2 − 2)/2, and hence −2 ≤ f (xi) · f (xj) ≤ 2. It then suffices 2 and (1 − (cid:48)) ≤ (cid:107) f (xi)(cid:107)2 2.3. Experiments 37 The lower bound translates into the number of points that must be read by each query. However, this does not apply for query dependent data structures. 2.3 Experiments We implemented several variations of furthest neighbor query in both the C and F# programming languages. This code is available online1. Our C implementation is structured as an alternate index type for the SISAP C library [55], returning the furthest neighbor instead of the near- est. We selected five databases for experimentation: the "nasa" and "col- ors" vector databases from the SISAP library; two randomly generated databases of 105 10-dimensional vectors each, one using a multidimen- sional normal distribution and one uniform on the unit cube; and the MovieLens 20M dataset [66]. The 10-dimensional random distributions were intended to represent realistic data, but their intrinsic dimension- ality as measured by the ρ statistic of Chávez and Navarro [40] is signifi- cantly higher than what we would expect to see in real-life applications. For each database and each choice of (cid:96) from 1 to 30 and m from 1 to 4(cid:96), we made 1000 approximate furthest neighbor queries. To pro- vide a representative sample over the randomization of both the projec- tion vectors and the queries, we used 100 different seeds for generation of the projection vectors, and did 10 queries (each uniformly selected from the database points) with each seed. We computed the approxima- tion achieved, compared to the true furthest neighbor found by brute force, for every query. The resulting distributions are summarized in Figures 2.3 -- 2.7. We also ran some experiments on higher-dimensional random vector databases (with 30 and 100 dimensions, in particular) and saw approxi- mation factors very close to those achieved for 10 dimensions. (cid:96) vs. m tradeoff The two parameters (cid:96) and m both improve the approx- imation as they increase, and they each have a cost in the time and space bounds. The best tradeoff is not clear from the analysis. We chose (cid:96) = m as a typical value, but we also collected data on many other parameter choices. 1https://github.com/johanvts/FN-Implementations 38 Chapter 2. Furthest Neighbor Figure 2.3: Experimental results for 10-dimensional uniform distribution Figure 2.4: Experimental results for 10-dimensional normal distribution 2.3. Experiments 39 Figure 2.5: Experimental results for SISAP nasa database Figure 2.6: Experimental results for SISAP colors database 40 Chapter 2. Furthest Neighbor Figure 2.7: Experimental results for MovieLens 20M database Figure 2.8: The tradeoff between (cid:96) and m on 10-dimensional normal vectors 2.3. Experiments 41 Algorithm 2: Query-independent approximate furthest neighbor Input: The input set S sorted by maxi∈1...(cid:96) ai · x. A query point q. 1 rval ← ⊥; 2 for x ∈ The top m elements of S do if rval = ⊥ or x is further than rval from q then 3 4 rval ← x 5 return rval Figure 2.8 offers some insight into the tradeoff: since the cost of doing a query is roughly proportional to both (cid:96) and m, we chose a fixed value for their product, (cid:96)· m = 48, and plotted the approximation results in relation to m given that, for the database of normally distributed vectors in 10 dimensions. As the figure shows, the approximation factor does not change much with the tradeoff between (cid:96) and m. Query-independent ordering The furthest-neighbor algorithm de- scribed in Section 2.2.1 examines candidates for the furthest neighbor in a query dependent order. In order to compute the order for arbitrary queries, we must store m point IDs for each of the (cid:96) projections, and use a priority queue data structure during query, incurring some costs in both time and space. It seems intuitively reasonable that the search will usually examine points in a very similar order regardless of the query: first those that are outliers, on or near the convex hull of the database, and then working its way inward. We implemented a modified version of the algorithm in which the index stores a single ordering of the points. Given a set S ⊆ Rd of size n, for each point x ∈ S let key(x) = maxi∈1...(cid:96) ai · x. The key for each point is its greatest projection value on any of the (cid:96) randomly-selected projections. The data structure stores points (all of them, or enough to accomodate the largest m we plan to use) in order of decreasing key value: x1, x2, . . . where key(x1) ≥ key(x2) ≥ · · · . Note that this is not the same query-independent data structure discussed in Section 2.2.2; it differs both in the set of points stored and the order of sorting them. The query examines the first m points in the query independent order- ing and returns the one furthest from the query point. Sample mean approximation factor for this algorithm in our experiments is shown by the dotted lines in Figures 2.3 -- 2.8. 42 Chapter 2. Furthest Neighbor Variations on the algorithm We have experimented with a number of practical improvements to the algorithm. The most significant is to use the rank-based depth of projections rather than the projection value. In this variation we sort the points by their projection value for each ai. The first and last point then have depth 0, the second and second-to-last have depth 1, and so on up to the middle at depth n/2. We find the minimum depth of each point over all projections and store the points in a query independent order using the minimum depth as the key. This approach seems to give better results in practice. A further improvement is to break ties in the minimum depth by count of how many times that depth is achieved, giving more priority to investigating points that repeatedly project to extreme values. Although such algorithms may be difficult to analyse in general, we give some results in Section 2.2.2 for the case where the data structure stores exactly the one most extreme point from each projection. The number of points examined m can be chosen per query and even during a query, allowing for interactive search. After returning the best result for some m, the algorithm can continue to a larger m for a possibly better approximation factor on the same query. The smooth tradeoff we observed between (cid:96) and m suggests that choosing an (cid:96) during prepro- cessing will not much constrain the eventual choice of m. Discussion The main experimental result is that the algorithm works very well for the tested datasets in terms of returning good approxima- tions of the furthest neighbor. Even for small (cid:96) and m the algorithm returns good approximations. Another result is that the query inde- pendent variation of the algorithm returns points only slighly worse than the query dependent. The query independent algorithm is sim- it can be queried in time O (m) as opposed to pler to implement, O (m log (cid:96) + m) and uses only O (m) storage. In many cases these ad- vances more than make up for the slightly worse approximation ob- served in these experiments. However, by Theorem 2.3, to guarantee √2 −  approximation the query-independent ordering version would need to store and read m = n − 1 points. In data sets of high intrinsic dimensionality, the furthest point from a query may not be much further than any randomly selected point, and we can ask whether our results are any better than a trivial random selection from the database. The intrinsic dimensionality statistic ρ of Chávez and Navarro [40] provides some insight into this question. Note 2.3. Experiments 43 that instrinsic dimensionality as measured by ρ is not the same thing as the number of coordinates in a vector. For real data sets it is often much smaller than that. Intrinsic dimensionality also applies to data sets that are not vectors and do not have coordinates. Skala proves a for- mula for the value of ρ on a multidimensional normal distribution [106, Theorem 2.10]; it is 9.768 . . . for the 10-dimensional distribution used in Figure 2.4. With the definition µ2/2σ2, this means the standard devi- ation of a randomly selected distance will be about 32% of the mean distance. Our experimental results come much closer than that to the true furthest distance, and so are non-trivial. The concentration of distances in data sets of high intrinsic dimen- sionality reduces the usefulness of approximate furthest neighbor. Thus, although we observed similar values of c in higher dimensions to our 10-dimensional random vector results, random vectors of higher dimen- sion may represent a case where c-approximate furthest neighbor is not a particularly interesting problem. However, vectors in a space with many dimensions but low intrinsic dimensionality, such as the colors database, are representative of many real applications, and our algo- rithms performed well on such data sets. The experimental results on the MovieLens 20M data set [66], which were not included in the conference version of the present work, show some interesting effects resulting from the very high nominal (number of coordinates) dimensionality of this data set. The data set consists of 20000263 "ratings," representing the opinions of 138493 users on 27278 movies. We treated this as a database of 27278 points (one for each movie) in a 138493-dimensional Euclidean space, filling in zeroes for the large majority of coordinates where a given user did not rate a given movie. Because of their sparsity, vectors in this data set usually tend to be orthogonal, with the distance between two simply determined by their lengths. Since the vectors' lengths vary over a wide range (length proportional to number of users rating a movie, which varies widely), the pairwise distances also have a large variance, implying a low intrin- sic dimensionality. We measured it as ρ = 0.263. The curves plotted in Figure 2.7 show similar behaviour to that of the random distributions in Figures 2.3 and 2.4. Approximation factor im- proves rapidly with more projections and points examined, in the same pattern, but to a greater degree, as in the 10-coordinate vector databases, which have higher intrinsic dimensionality. However, here there is no noticeable penalty for using the query-independent algorithm. The data 44 Chapter 2. Furthest Neighbor set appears to be dominated (insofar as furthest neighbours are con- cerned) by a few extreme outliers: movies rated very differently from any others. For almost any query, it is likely that one of these will be at least a good approximation of the true furthest neighbour; so the algorithm that identifies a set of outliers in advance and then chooses among them gives essentially the same results as the more expensive query-dependant algorithm. 2.4 Conclusion We have proposed a data structure for solving the (c)-AFN problem. The data structure retrieves candidate points based on their rankings along random projections. To do so efficiently it employs a priority queue that is populated at query time. We give theoretical guarantees on the space and time requirements, as well as experimental confirmation of these. Further we give a space lower bound on any data structure that works to return the (c)-AFN by iterating a fixed list. This bound supports the suspicions raised by Goel et. al[60] that query time polynomial in d cannot be achieved for c < √2. We also suggest a simplified algorithm that can be viewed as an approximation of the convex hull. While harder to analyse, it is faster and gives very satisfactory experimental results. Our data structure extends naturally to general metric spaces. In- stead of computing projections with dot products, which requires a vec- tor space, we could choose some random pivots and order the points by distance to each pivot. The query operation would be essentially un- changed. Analysis and testing of this extension is a subject for future work. Chapter 3 Annulus Query The annulus query problem from Section 1.2.2 can be viewed as a prob- lem of finding nearest and furthest neighbors simultaneously. An obvi- ous path to follow is to combine techniques for these problems into a single data structure. 3.1 Introduction Similarity search is concerned with locating elements from a set S that are close to a given query q. The query can be thought of as describ- ing criteria we would like returned items to satisfy. For example, if a customer has expressed interest in a product q, we may want to rec- ommend similar products. However, we might not want to recommend products that are too similar. Thinking of e.g. a book recommenda- tion, we do not want to recommend e.g. just an older translation of the same work. We claim that a solution to the (c, r, w)- approximate annu- lus query problem (Definition 1.3) can be found by suitably combining Locality Sensitive Hashing techniques(LSH, See Section 1.3.7), with the approximation technique for furthest neighbor presented in Chapter 2. In this short chapter we show such a solution in (Rd, (cid:96)2) with constant failure probability. 3.1.1 Notation Consider an LSH function family H = {Rd → U}. We say that H is (r1, r2, p1, p2)-sensitive for (Rd, (cid:96)2) if: 46 Chapter 3. Annulus Query 1. PrH[h(q) = h(p)] ≥ p1 when (cid:107)p − q(cid:107)2 ≤ r1 2. PrH[h(q) = h(p)] ≤ p2 when (cid:107)p − q(cid:107)2 > r2 We will be using A(q, r, w) for the annulus between two balls, that is A(q, r, w) = B(q, rw) \ B(q, r/w). 3.2 Upper bound Theorem 3.1. Consider a (wr, wcr, p1, p2)-sensitive hash family H for (Rd, (cid:96)2) and let ρ = log 1/p1 . For any set S ⊆ Rd of at most n points there log 1/p2 exists a data structure for (c, r, w)-AAQ such that: • Queries can be answered in time O dnρ+1/c2 log(1−1/c2)/2 n . (cid:17) (cid:17) (cid:16) (cid:16) • The data structure takes space O storing S. n2(ρ+1/c2) log1−1/c2 n in addition to The failure probability is constant and can be reduced to any δ > 0 by increasing the space and time cost by a constant factor. We will now give a description of such a data structure and then prove that it has the properties stated in Theorem 3.1. Let k, (cid:96) and L be integer parameters to be chosen later. We construct a function family G : Rd → Uk by concatenating k members of H. Choose L functions g1, . . . , gL from G and pick (cid:96) random vectors a1, . . . , a(cid:96) ∈ Rd with entries sampled independently from N (0, 1). Preprocessing During preprocessing, all points x ∈ S are hashed with each of the functions g1, . . . , gL. We say that a point x is in a bucket Bj,i if gj(x) = i. For every point x ∈ S the (cid:96) dot product values ai · x are calculated. These values are stored in the bucket along with a reference to x. Each bucket consists of (cid:96) linked lists, list i containing the entries sorted on ai · x, decreasing from the head of the list. See Figure 3.1 for an illustration where pi,j is the tuple (ai · xj, ref(xj)). A bucket provides constant time access to the head of each list. Only non-empty buckets are stored. 3.2. Upper bound 47 Figure 3.1: Illustration of a bucket for {x1, x2, x3, x5} ⊂ S. (cid:96) = 3. p1,5 p1,2 p1,3 p1,1 p2,5 p2,3 p2,1 p2,2 p3,2 p3,3 p3,1 p3,5 aT 1 x aT 2 x aT 3 x Bj,i.Head() Querying For a given query point q the query procedure can be viewed as building the set Sq of points from S within B(q, rcw) with the largest ai∈[(cid:96)] · (p − q) values and computing the distances between q and the points in Sq. At query time q is hashed using g1, .., gL in O(dL). From each bucket Bj,gj(q) the top pointer is selected from each list. The selected points are then added to a priority queue with pri- ority ai · (p − q). This is done in O(L(cid:96)) time. Now we begin a cycle of adding and removing elements from the priority queue. The largest priority element is dequeued and the predecessor link is followed and the returned pointer added to the queue. If the pointer just visited was the last in its list, nothing is added to the queue. If the priority queue becomes empty the algorithm fails. Since r is known at query time in the (c, r, w)-AAQ it is possible to terminate the query procedure as soon as some point within the annulus is found. Note that this differs from the general furthest neighbor problem. For the analysis however we will consider the worst case where only the last element in Sq lies in the an- nulus and bound Sq to achieve constant success probability. We now return to theorem 3.1 Proof. Fix a query point q. By the problem definition, we may assume S ∩ A(q, r, w) ≥ 1. Define Sq ⊆ S to be the set of candidate points for which the data structure described in section 3.2 calculates the distance to q when queried. The correctness of the algorithm follows if Sq ∩ A(q, r, cw) ≥ 1. To simplify the notation let Pnear = S ∩ B(q, r/(cw)) and Pfar = S − B(q, r/w). The points in these two sets have useful properties. Let t be the solution to the equality: 1 √2π e −t2 2 t = 1 n 48 Chapter 3. Annulus Query If we set ∆ = rt cw, we can use the ideas from Lemma 2.3 to conclude that: 1 n Also, for p ∈ Pfar the lower bound gives: Pr[ai(p − q) ≥ ∆] ≤ , for p ∈ Pnear Pr[ai(p − q) ≥ ∆] ≥ (2π)(1−1/c2)/2 n−1/c2t(1−1/c2) 1 t ∈ O((cid:112)log n), (3.1) (cid:19) (cid:18) c2 t2 1 − By definition, O(n1/c2 log(1−1/c2)/2 n) we get: so for some function φ ∈ Pr[ai(p − q) ≥ ∆] ≥ 1 φ , for p ∈ Pfar. (3.2) Now for large n, let P be the set of points that projected above ∆ on at least one projection vector and hashed to the same bucket as q for at least one hash function. P = {x ∈ S∃j, i : gj(x) = gj(q) and ai · (x − q) ≥ ∆} Let (cid:96) = 2φ, m = 1 + e2(cid:96) and L = (cid:100)nρ/p1(cid:101). Using the probability bound (3.1) we see that E[P ∩ Pnear] ≤ 1 nn(cid:96) = (cid:96). So Pr[P ∩ Pnear ≥ m] < 1/e2 by Markov's inequality. By a result of Har-Peled, Indyk, and Mot- wani [65, Theorem 3.4], the total number of points from S \ B(q, rcw) across all gi(q) buckets is at most 3L with probability at least 2/3. So Pr[P \ B(q, rcw) > 3L] < 1/3. This bounds the number of too far and too near points expected in P. Pr[P \ A(q, r, cw) ≥ m + 3L] ≤ 1/3 + e−2 By applying [65, Theorem 3.4] again, we get that for each x ∈ A(q, r, w) there exists i ∈ [L] such that gi(x) = gi(q) with probability at least 1 − 1/e. Conditioning on the existence of this hash function, the probability of a point projecting above ∆ is at least 1 − (1 − 1/φ)2φ ≥ 1 − 1 e2 . Then it follows that Pr[P ∩ A(q, r, w) < 1] < 1/e + 1/e2. The points in P will necessarily be added to Sq before all other points in the buckets; then, if we allow for Sq = m + 3L, we get Pr[Sq ∩ A(q, r, cw) ≥ 1] ≥ 1 − (1/3 + 1/e + 2/e2) > 0.02. 3.3. Conclusion 49 The data structure requires us to store the top O (mL) points per pro- jection vector, per bucket, for a total space cost of O(m(cid:96)L2), in addition to storing the dataset, O(nd). The query time is O((dL + (cid:96)L) + m(d + log (cid:96)L)). The first term is for initializing the priority queue, and the sec- ond for constructing Sq and calculating distances. Let λ = (1 − 1/c2)/2. (cid:16) Since L = O(nρ) and (cid:96), m = O(n1/c2 logλ n) we get query time: d + log (nρ+1/c2 logλ n) O dnρ + nρ+1/c2 logλ n + n1/c2 logλ n (cid:17)(cid:17) (3.3) (cid:16) Depending on the parameters different terms might dominate the cost. But they can all be bounded by O(dnρ+1/c2 log(1−1/c2)/2 n) as stated in the theorem. The hash buckets take space: (cid:16) (cid:17) O n2(ρ+1/c2) log1−1/c2 n . (3.4) Depending on c, we might want to bound the space by O(n(cid:96)L) in- stead, which yields a bound of O(n1+ρ+1/c2 log(1−1/c2)/2 n). 3.3 Conclusion In this short chapter we showed a data structure for the (c, r, w)- approximate annulus query problem. We showed that the query time is sublinear in the size of S and linear in d. This makes the data structure well suited for the high-dimensional, high-volume paradigm, although the storage requirements can be quite large when c is close to 1. Later results have shown that similar bounds can be achieved through the combination of LSH with "anti"-LSH functions [17]. It is easy to employ the query-independent variation of the furthest neighbor data structure instead of the query dependent variation. This would significantly re- duce the space usage from O(m(cid:96)L2) to just O(m). It would also reduce the query time, although that is not dominated by the priority queue insertions that would be saved. Given our experimental results in Chap- ter 2 this alternative it seems to offer an attractive, practical solution to the approximate annulus query problem, although more difficult to analyse theoretically. Chapter 4 Distance Sensitive Approximate Membership The Bloom filter [25] is a well-known data structure for answering ap- proximate membership queries on a set S, i.e., queries of the form "Is x in S?". By allowing some false positive answers (saying 'yes' when the an- swer is in fact 'no') Bloom filters use space significantly below what is required for storing S. In the distance sensitive setting we work with a set S of (Hamming) vectors and seek a data structure that offers a similar trade-off, but answers queries of the form "Is x close to an element of S?" (in Hamming distance). Previous work on distance sensitive Bloom filters have accepted false positive and false negative answers. Absence of false negatives is of critical importance in many applications of Bloom filters, so it is natural to ask if this can be also achieved in the distance sensitive setting. Our main contributions are upper and lower bounds (that are tight in several cases) for space usage in the distance sensitive setting where false negatives are not allowed. 4.1 Introduction In this Chapter we present upper and lower bounds on the space complexity of filters for distance sensitive approximate membership queries((r, c, )-DAMQ, Definition 1.4) in ({0, 1}d, H). These filters an- swer queries of the form "Is x similar to some element of S?" Where "similar" means within a given Hamming distance r. We study distance sensitive filters under an approximation factor c ≥ 1: a small false pos- itive rate  is allowed when S has points at distance more than cr from the query point. However, false negatives are never allowed. This is in 52 Chapter 4. Distance Sensitive Approximate Membership contrast to previous work on this problem [77]. To our best knowledge, ours is the first solution with no false negatives. 4.1.1 Motivation and practicality Bloom filters are widely used in practice. One reason is because they require less space than a dictionary data structure for storing S. We argue that the lack of false negatives is also of critical importance to their frequent use in practice. Generally the set S is a subset from some much larger domain. If queries are roughly uniformly selected from the domain, answers to a membership query should most often be negative. For this majority of queries the Bloom filter always gives the correct, negative, answer. Since the filter then rarely gives a positive, possibly wrong, answer, these queries could all be double-checked using an exact, but less space- efficient, less accessible method (perhaps on a different machine). This allows us to use Bloom filters as a first component in an exact two-level data structure. Here it acts as an initial filter, reducing the use of a sec- ond, slower to access but exact data structure. Having false negatives means this two-level structure would fail to be exact. We would have to choose one of the levels: Either accept some possibility of getting a wrong answer or perform an expensive exact query every time. We are motivated by providing a data structure for distance sensitive member- ship query that can be used in this way, i.e. that does not have false negatives. There are many potential applications for this kind of data structure. As a concrete example, consider a journal comprising a large collection of academic papers. When accepting a new paper the journal might want to check if the new paper is very similar to any prior work al- ready published. By using a distance-sensitive filter this can be done in a space-efficient manner. Because we do not allow false negatives, any new paper passing this test (with a 'no' result) is guaranteed to be significantly different from all prior work. In the rare case that a paper fails the test, the submission process could be halted pending a con- sultation of the full archive. Furthermore, since the filter provides very little information about the content of the papers it would not need to be subject to the same access control as a full database of all the journals papers might be under. More interesting examples of applications for distance-sensitive filters can be found in [77] and for Bloom filters in general in [29]. 4.1. Introduction 53 4.1.2 Our results We study the space required for answering distance-sensitive approxi- mate membership queries with no false negatives. It turns out that, in contrast to approximate membership, we get different bounds depend- ing on how the false positive rate is defined: • If we desire a point-wise error bound (Definition 4.2) each query at distance ≥ cr (cid:17)(cid:17) from S, for the space usage for almost all parameters, and bits if n is not too large (see Theorem 4.3). ε d + log 1 n (cid:16) r (cid:16) r2 c−1 log 1 must be Ω(cid:16) Ω(cid:16) usage must be Ω(cid:16) c + c n ε (cid:17)(cid:17) (cid:16) r2 • If it suffices to have an ε average false positive rate (Definition 4.3) over all queries at distance ≥ cr from S, where Cl < d/2, the space (cid:17)(cid:17) n d + log 1 ε bits. (see Theorem 4.2). We match these lower bounds with almost tight upper bounds on space usage in Section. 4.4. We introduce the notion of vector signature, which can be seen as a succinct version of a CountSketch [38], and then show how to use them to design distance sensitive filters with point-wise and average errors. Our focus is on space usage rather than query-time, and indeed it would be surprising if poly-logarithmic query time in n is possible since our (point-wise) filter could be used, say with ε = 1/n, to solve the c- approximate nearest neighbor problem. The best currently know data structures for this problem use nΩ(1/c) time [14]. Related work 4.1.3 There is little prior work specifically on distance sensitive approximate membership. The problem corresponds to querying a standard Bloom filter in a ball around the query point, but this solution is slow, time Ω((d r)), and also not particularly space efficient since we would need to use a Bloom filter with a very small false positive rate to bound the prob- ability that none of the queries yield a false positive. More precisely, the required space usage for this approach would be Ω(nr log d r ) bits [34]. Mitzenmacher and Kirsch [77] considered data structures that look like Bloom filters but replace standard hash functions with locality sensi- tive hash (LSH) functions [72] to achieve distance sensitivity. However, 54 Chapter 4. Distance Sensitive Approximate Membership this approach introduces false negatives because LSH is not guaran- teed to produce collisions. In order to reduce the number of false nega- tives the conjunction used when querying Bloom filters is replaced by a threshold function: there should just be "many" hash collisions. Unfor- tunately, the achieved approximation factor is large, i.e. c = O (log n). Hua et al. [68] extended the data structure of [77] with practical im- provements and provided extensive experiments, confirming that false negatives also appear in practice. There has been some recent progress on developing LSH families that can answer near neighbor queries without false negatives [94], but it seems inherent to such families that the storage cost grows exponentially with r. Thus this approach is not promising, perhaps except for very small values of r. Finally, it is known that allowing a constant fraction of false negatives does not asymptotically improve the space usage that can be achieved by approximate membership data structures [96]. It is not apriori clear that space usage will be worse when false negatives are not allowed. Problem definition and notation 4.2 The Hamming distance H(p, q) between two points p, q ∈ {0, 1}d is the number of positions where p and q differ. Given a set S ⊆ {0, 1}d of n points and a point q ∈ {0, 1}d, we extend the meaning of H(·) by defining H(q, S) to be the minimum distance between q and any point in S, i.e. H(q, S) = minp∈S H(q, p). We use (A n) to denote {S ⊆ A : S = n} when A is a set. We will be using the Bd(x, r) notation as defined in section 2.1.2. We formally define distance sensitive approximate membership filters as follows: Definition 4.1. (Distance sensitive approximate membership filter) Let r ≥ 0, c ≥ 1, and ε ∈ [0, 1]. Given a set S ⊂ {0, 1}d define the two sets: Qnear = {x ∈ {0, 1}d : H(x, S) ≤ r}, Qfar = {x ∈ {0, 1}d : H(x, S) > cr}. A (r, c, ε)-distance sensitive approximate membership filter for S is a data-structure that on a query q ∈ {0, 1}d reports: • 'Yes' if q ∈ Qnear 4.2. Problem definition and notation 55 • 'No' if q ∈ Qfar, but with some probability of error (i.e. false posi- tives). If q /∈ Qnear ∪ Qfar the data structure can return any answer. Qnear Qfar × r cr (cid:88) ? (cid:88) (cid:88) × × × × × Figure 4.1: Illustration for n = 2 showing some queries with their de- sired output: (cid:88) → 'Yes', × →'No', ? → Undefined. In the rest of the chapter, we study space bounds under two error measures, named point-wise and average errors. Definition 4.2 (Point-wise error). A (r, c, ε)-distance sensitive approx- imate membership filter for S has point-wise error ε if, on a query q ∈ {0, 1}d, it reports: • 'Yes' if q ∈ Qnear; • 'No' with probability at least 1 − ε if q ∈ Qfar (the probability is over the random choices of the filter). This is a strong guarantee since each point in Qfar has probability ε to fail. If hard queries are not expected, it might be acceptable that some points give false positives in every instance of the data structure, as long as only an ε total fraction of points in Qfar give false positives. We refer to this weaker filter as the average error version: Definition 4.3 (Average error). A (r, c, ε)-distance sensitive approximate membership filter for S has average error ε if, on a query q ∈ {0, 1}d, it reports: 56 Chapter 4. Distance Sensitive Approximate Membership • 'Yes' if q ∈ Qnear; • 'No' with probability at least 1 − ε, if q is randomly and uniformly selected from Qfar (the probability is over the random selection in Qfar and over the random choices of the filter). The average-error guarantee implies that the filter provides the cor- rect answer to at least a (1 − ε) fraction, in expectation, of the points in Qfar. Clearly, a filter with point-wise error is also a filter with average er- ror. Though the difference between these two error measures may seem small, their properties and analysis differ substantially. 4.3 Lower bounds As a warm-up, we first investigate what can be done when no errors are allowed, that is when ε = 0 (in this case the average and point-wise error guarantees are equivalent). The next theorem shows that, up to constant factors, the optimal filter is no better than one that stores S explicitly. When ε = 0 there is no distinction between point-wise and average error. Throughout this chapter we let log x denote the logarithm of x in base 2. Theorem 4.1. Any distance sensitive approximate membership filter with error ε = 0 must use at least bits in the worst case. If d = ω(log n) and cr = o (d/ log d) then it must use Ω (nd) bits. Proof. The proof is an encoding argument. A set S ⊆ {0, 1}d of size n is encoded by Alice and sent to Bob who will recover it. Assume the optimal filter uses s bits in the worst case. Alice inserts the given set S into the optimal filter, and runs the query algorithm on each point in the universe. Since there are no false positives, the filter says 'yes' to a set P of at most nBd(cr) points. Alice encodes S as a subset of P using log (nBd(cr) ) + O (1) bits. Alice then sends the at most s bits of the optimal filter to Bob along with the strings encoding S as a subset of P. The decoding procedure is straightforward. Bob queries the optimal filter with all points in {0, 1}d, recovering P. Then, using P and the n (cid:32) n log (cid:33) 2d enBd(cr) 4.3. Lower bounds 57 second string of bits received from Alice, Bob can recover the initial set S. Since every set S of size n can be encoded, we get that: s + log from which follows that s ≥ log (cid:18)nBd(cr) (cid:33)n (cid:32)(cid:32) n 2d n ≥ log (cid:18)2d (cid:19) (cid:19) (cid:19)n(cid:33) (cid:18) enBd(cr) n / n ≥ nd − n log(en) − n logBd(cr) i=0 (d If d = ω(log n), we get s = Ω (nd − n logBd(cr)). Further, us- i ) < dcr for cr < d/2, we get that s = ing that Bd(cr) = ∑cr Ω (nd − ncr log d), which is Ω (nd) when cr = o (d/ log d). 4.3.1 Next we investigate the distance sensitive membership problem with average error ε > 0. Theorem 4.2. Assume that nBd(cr)/2d < ε < 1/4. Then any distance sensitive membership filter with average error ε must use Average error (cid:18) (cid:18)r2 d n + log (cid:18)1 (cid:19)(cid:19)(cid:19) ε Ω bits in the worst case. Before proving the theorem, we highlight some remarks: 1. The above theorem holds as long as nBd(cr) < 2d−2, i.e. the "membership set" covers less than a quarter of the full Hamming space. This is the most interesting range of parameters. Similarly to Bloom filters, our approach is not optimal when non-members are rare. As we will see later, the Ω(nr2/d) lower bound holds as long as nBd(cr) < 2d−1, and it starts to deteriorate when nBd(cr) approaches 2d. It is clear that some upper bound on nBd(cr) is necessary; if it approaches size 2d − O(n/d), then storing the com- plement exactly in O(n) bits suffices. Also note that at the lower limit of ε = nBd(cr)/2d, this lower bound matches the lower bound of the ε = 0 case in Theorem 4.1. Thus Theorem 4.1 fol- lows from Theorem 4.2. 58 Chapter 4. Distance Sensitive Approximate Membership 2. The term Bd(cr) has no simple closed expression for all c and r, and so the dependence of the hypothesis of the theorem on c, r and d is not straightforward. The rest of this section is devoted to the proof of Theorem 4.2. Proof. The proof is derived for a deterministic version of the distance sensitive membership filter: in this setting, the filter answers 'no' to at least a fraction of points in Qfar (i.e., points at distance at least cr from all points in the input point set S), and hence there can be at most εQfar false positives. We claim that such a lower bound applies also to a randomized filter. Suppose that a randomized filter requires s bits, with s smaller than the lower bound. Since the expected number of correct 'no' answers is at least (1 − ε)Qfar, there must exist random values for which the filter provides the correct solution for at least (1 − ε)Qfar points: by using these values, we obtain a deterministic average error filter with space complexity s lower than the lower bound, which is a contradiction. We first prove a Ω (n log(1/ε)) lower bound. The proof is an encod- ing argument that extends the scheme presented in the proof of Theo- rem 4.1 and in [34]. Alice receives a set S of size n from the universe to encode. Assume the optimal distance sensitive filter with ε average error uses s bits in the worst case. Alice inserts S into the filter, and runs the query algorithm on all points in the universe recovering P, the set of points the filter answers 'Yes' to. We first claim that P ≤ 2d+1ε. First, the number of positives not considered false is at most nBd(cr) (this bound is achieved when all the balls are disjoint), which is less than 2dε. Also the number of false positives is always at most 2dε. Adding these, we find that the total number of positives is at most 2d+1ε. Alice then encodes the set S as a subset of P, using at most log (2d+1ε n ) bits. Alice sends these bits to Bob along with the at most s bits representing the optimal filter for S. Bob queries the filter with all q ∈ {0, 1}d and recovers P. Bob then uses the extra bits sent by Alice to find the subset of P identical to S. We n (cid:19) (cid:18)2d 2d · · · (2d − n + 1) (cid:32) (cid:33)n (ε2d+1) · · · (ε2d+1 − n + 1) 2d (cid:19)(cid:19) (cid:18)1 (cid:19) (cid:18) 1 ε2d+1 (cid:18) n log ε 59 . 4.3. Lower bounds have that: s + log (cid:18)2d+1ε (cid:19) ≥ log n ⇒ s ≥ log ⇒ s ≥ log ⇒ s ≥ n log 2ε ∈ Ω n (cid:83) To prove the nr2/d lower bound, we first introduce some notation. Consider the hypercube graph on the d-dimensional Hamming cube where two points p and q have an edge between them if they have Ham- ming distance 1. Given a set A ⊂ {0, 1}d, let Ac denote its complement, and define ∂A to be the set of points in A that have an edge to a point in Ac (when either Ac or A is empty, ∂A is the empty set). Also, given an integer r > 0, define A−r = A \ x∈∂A Bd(x, r − 1). A−r contains exactly those points x ∈ A such that the ball Bd(x, r) is contained inside A. A deterministic filter that uses s bits can be viewed as a function F : ({0,1}d ) → {0, 1}s; given a set S ⊆ {0, 1}d of size n, F (S) is the memory representation of S that uses at most s bits. Let V(S) = ∪x∈S Bd(x, r) + ε(2d − ∪x∈S Bd(x, r)): we note that V(S) is an upper bound to the number of 'yes' answers returned by the filter (i.e., both true and false positives), and V(S) ≤ 2d−1 by the hypothesis of the theorem. Running the query algorithm on all points in the Hamming cube for c of negatives) the representation F (S) returns a set PS of positives (PS such that PS ≤ V(S). Let us denote by D the function that takes in a set S, and outputs the set PS of positives returned by the query algorithm on the representation F (S). Varying over all S ∈ ({0,1}d 1. ∀S, ∃P ∈ T such that Bd(x, r) ⊂ P for all x ∈ S. 2. For any P ∈ T and ∀S such that D(S) = P, P ≤ V(S). Thus D is a function from {0, 1}s to T , the image of which is all of T . This implies that s ≥ logT . So in order to get a lower bound on s it suffices to get a lower bound on the size of the smallest family T with the above properties. ), we get a family T of sets such that: n 60 Chapter 4. Distance Sensitive Approximate Membership Since all possible sets (from ({0,1}d n Fix P ∈ T . Define D−1(P) = {S : D(S) = P}. Any ball of radius r around a point p ∈ S such that S ∈ D−1(P) must be completely con- tained inside P. The maximum number of such points p is P−r. Thus we get that ∪S∈D−1(P) S ≤ P−r. This implies that D−1(P) ≤ (P−rn ). )) need to be covered, we get that T ≥ (2d n )/(P−rn ). We now need an upper bound on the size of P−r. Lemma 4.1 states that P−r ≤ 2de−2r2/d. The proof of the lower bound in Theorem 4.2 then follows by apply- (cid:18) (cid:19) ing Lemma 4.1: P−r (cid:33)n n (cid:18)2d (cid:32) T ≥ (cid:19) / n e2d P−r ≥ ≥ en(2r2/d+1), which implies that s ≥ logT = Ω(cid:0)nr2/d(cid:1). Combining our bounds, we get that when n, r and c satisfy the condition that nB(cr, d) ≤ 2d−2, any filter must use Ω(n(r2/d + log(1/ε))) bits in the worst case. Lemma 4.1. Let S, P and r be as above. Then P−r < 2de−2r2/d. Proof. Note that P is the set of positives (after running the query algo- rithm on all points in the Hamming space) on the filter F (S). Thus we have that P ≤ V(S) ≤ 2d−1. The size of P−r increases as P increases, so we have that P−r is at most maxA−r, where the maximum is taken over all sets A such that A = 2d−1. We will first prove that if A = 2d−1, then maxA−r is at most B(d/2 − r, d) (the size of the Hamming ball of radius d/2 − r). The proof is by induction (the statement is actually true for any r < d/2, not just the input parameter r, and so we will treat it as a variable). For r = 1, the statement is that A−1 is maximized when A is the Hamming ball of radius d/2. This is the statement of Harper's theorem, also called the vertex-isoperimetric inequality [26], that states that Ham- ming balls have the smallest vertex boundary among all sets of a given size. Assume now that the statement is true for r = k, i.e., of all sets A such that A = 2d−1, the one that maximizes A−k is the Hamming ball 4.3. Lower bounds 61 of radius d/2. In this case, note that A−k is the Hamming ball of radius d/2 − k. Assume that the statement for r = k + 1 is false, i.e., there is a set W (of size 2d−1) such that Bd(0, d/2)−(k+1) < W−(k+1). Note that by the inductive hypothesis, we know that Bd(0, d/2)−k ≥ W−k. However, the vertex-isoperimetric inequality can also be stated as: if a set W (that is not a ball) has size greater then or equal to that of the Hamming ball of radius R, then W ∪ Γ(W) is larger than the size of Hamming ball of radius R + 1, where Γ(W) is the set of neighbors of W. Thus Bd(0, d/2)−(k+1) < W−(k+1) actually implies Bd(0, d/2)−k < W−k, which contradicts the inductive hypothesis. Finally, we bound Bd(d/2 − r) using the following Chernoff- Hoeffding bound [89] for binomial random variables: If Xi denotes the outcome of the ith coin toss with an unbiased coin, i=1 Xi, then Pr[X ≤ µ − a] ≤ e−2a2/d, for all 0 < a < µ, where and X = ∑d µ = E[X] = d/2. Let X ∼ B(d, 0.5). Now we have that P−r ≤Bd(d/2 − r) =2dP[X ≤ d/2 − r] ≤2de−2r2/d. Point-wise error 4.3.2 The lower bound for the average case in Theorem 4.2 also applies to a filter with point-wise error guarantees. A (r, c, ε)-filter with point-wise error ε is also a (r, c, ε)-filter with average error ε: if each point fails with probability ε, then a random point fails with probability ε. However, a stronger lower bound holds for point-wise error if the number of points n is not too large. Theorem 4.3. Consider an (r, c, ε)-distance sensitive approximate membership filter with point-wise error on a set S of n points in {0, 1}d. Then, in the worst case, the filter must use: • Ω(cid:16) • Ω(cid:16) n n (cid:16) r2 (cid:16) r stant δ. (cid:17)(cid:17) (cid:17)(cid:17) d + log 1 ε c + log 1 ε bits if nBd(cr)/2d < ε < 1/4. bits if nBδcr(cr)/2δcr < ε < 1/4 for some con- 62 Chapter 4. Distance Sensitive Approximate Membership Proof. As already said, the first bound follows by applying Theorem 4.2 since a (r, c, ε)-filter with point-wise error is also a (r, c, ε)-filter with average error. We now prove the second claim. Observe that a filter for d- dimensional points with point-wise error ε is also a filter for d(cid:48)- dimensional points with the same guarantees when d > d(cid:48). Then, the lower bound obtained by Theorem 4.2 for dimension d(cid:48) = δcr, for some small constant δ, applies to dimension d, and it is also stronger since the lower bound in Theorem 4.2 is decreasing in d. However, the new bound needs to meet the condition of Theorem 4.2: given a filter for dimension d(cid:48) = δcr, then the condition states that nBδcr(cr)/2δcr < ε < 1/4. The theorem follows. We observe that the proof used to derive the stronger lower bound does not work for the average error measure: indeed, the average error rate relatively to a subspace (e.g., {0, 1}d(cid:48)) can be much larger than the one in the complete space (i.e., {0, 1}d). As we will see in the next section, there exists a filter that almost match the asymptotic lower bound if c ≥ 2. However, if 1 < c < 2 and although the upper bound is not optimal, the next theorem shows that a 1/(c − 1) overhead is unavoidable when 1 < c < 2. To help in assessing the hypothesis in the theorem, we notice that, when c = 1 + 1√r, the the- ε is sufficiently small, the upper bound has a O(cid:0)1/(c − 1)2(cid:1) overhead: orem holds for n ≤ 2Θ(r), ε ≤ 2−Θ(r), d = 2Ω(√r) and it gives a Ω(cid:0)nr3/2(cid:1) bound, whereas the previous theorem only gave Ω (nr). We note that the next theorem can be integrated with the previous Theorem 4.3 to get an additive nr/c or nr2/d more (according to the parameters). Theorem 4.4. Let c ≤ 2, ε ≤ (c − 1)/n be such that d(c − 1) ≥ ((c − 1)/ε)6/(r(c−1)) + (r(c − 1))3. Consider an (r, c, ε)-distance sensitive approxi- mate membership filter with point-wise error ε on a S set of n points in {0, 1}d. Then, the filter requires Ω bits in the worst case. (cid:18) n c − 1 (cid:18)1 (cid:19)(cid:19) log ε Proof. The main idea of the proof is to use the optimal filter in a one-way randomized protocol between two players (Alice and Bob) to send an arbitrary element x of a given set S from Alice to Bob who must identify 4.3. Lower bounds 63 which element he has: It is known (See the indexing problem [80]) that such a protocol requires Ω (logS) bits if the protocol succeeds with probability at least 2/3 and the two players share random bits. The proof uses two families of error correcting codes, C and M, that are explained below. Without loss of generality we assume that they are known to both Alice and Bob (the code families can be constructed with a deterministic brute-force algorithm). Let k = 1/(c − 1). The error correcting binary code C has m = 1/(nεk) codewords, each one with length dC = d/k bits, weight w = r/k and minimum Hamming distance between two codewords at least δ = r/k. [63, Theorem 6] shows that such a code exists of size at least dw−δ/2+1 C δ! (d(c − 1))r(c−1)/2 ≥ (r(c − 1))r(c−1) ≥ (d(c − 1))r(c−1)/6 c − 1 ≥ ε where in the third inequality we exploit the fact that d(c − 1) ≥ (r(c − 1))3 and in the last step we use d(c − 1) ≥ ((c − 1)/ε)6/(r(c−1)). The error correcting binary code M has n codewords and minimum Hamming distance rc (there is no requirement on codewords weights); we let M = {m1, . . . , mn}. By the Gilbert-Varshamov [85] bound such a code M exists with length dM = rc + log n. Alice arbitrary selects n codes xi = (xi,1, . . . , xi,k−1) from the set Ck. Then, she encodes each xi into xi = xi,1 · . . . · xi,k · z0 · mi, where · denotes the concatenation of binary sequences, z0 is a sequence of r/k = r(c − 1) zeros, and mi ∈ M. The length of each xi is dx = kdC + dM + r/k = d + log n + r(2c − 1). Finally, Alice inserts x0, . . . , xn−1 into the optimal filter and sends the filter to Bob using S(n, dX, c, r) bits. We now show that Bob can reconstruct each codeword xi by querying the filter at most 1/ε times. Codeword xi,1 is obtained by performing a query with q = q(cid:48) · z2 · z3 · mi for every possible codeword q(cid:48) ∈ C, where z2 is a sequence of (k − 1)δ = (k − 1)r(c − 1) zeros, z3 is a sequence of r/k ones, and mi ∈ M. The distance between q(cid:48) and any xj in the filter is D( xj, q) = D(xj,1, q(cid:48)) + D(xj,2 · . . . · xi,k, z2) + D(z0, z3) + D(mj, mi). It holds that: 1. D(xi,1, q(cid:48)) ≥ r(c − 1) if q (cid:54)= xi,1 and 0 otherwise; 64 Chapter 4. Distance Sensitive Approximate Membership 2. D(xj,2 · . . . xi,k, z1) = (k − 1)r(c − 1) = r − r(c − 1) since each code- word in C has weight r(c − 1); 3. D(z0, z3) = r(c − 1); 4. D(mj, mi) ≥ rc if mj (cid:54)= mi and 0 otherwise. Therefore, D( xj, q) = r if xi,1 = q(cid:48) and mi = mj, and D( xj, q) ≥ rc otherwise. A similar procedure holds for computing xi,j for each i and j. Bob performs mk queries per xi and nkm = 1/ε queries in total. The expected number of wrong queries is then 1 and, if the protocol is repeated independently, there is a constant probability that all queries succeed. Since Bob is able to reconstruct an entry from the set S = Cnk, by the aforementioned result in [80], we have S(n, dx, c, r, ε) ≥ Ω (logS) log(1/ε). ≥ Ω(cid:16) logCnk(cid:17) ≥ n c − 1 4.4 Upper bounds In this section we propose distance sensitive approximate membership filters with point-wise and average errors. We start in Section 4.4.1 by introducing the concept of vector signature. It can be seen as a succinct version of CountSketch [38], where we have thrown away information not required for answering distance sensitive approximate membership queries. In Sections 4.4.2 and 4.4.3, we then show how to use vector sig- natures to derive almost-optimal approximate membership filters with point-wise and average errors respectively. Vector signatures (cid:16) r (c−1) +(cid:0) c 4.4.1 A vector signature is a suitable function mapping a vector from {0, 1}d into O bits. The key feature of vector signa- tures is that a suitable function of the signatures of two vectors x and y is smaller than or equal to a certain threshold Ψ if D(x, y) ≤ r, while it (cid:1)2 log (cid:17)(cid:17) (cid:16) 1 ε c−1 4.4. Upper bounds 65 is larger than Ψ with probability 1 − ε if D(x, y) ≥ cr, as formalized in Theorem 4.5. Signature construction. The construction of the signature uses four parameters m, cmod, cdiv and δ that all depend on r, c and ε. Their values will be provided later. Let M be a m × d random matrix with entries chosen as follows. For each i ∈ {1, . . . , m}, j ∈ {1, . . . , d}, let Mi,j denote the element in the ith row and jth column of M, and let mi denote the ith row. Every entry of M is initially set to 0. Then each column j of M is constructed by performing δ = O (1 + (c/r) log(1/ε)) updates, where each update is defined by the following three steps: 1. Select s independently and uniformly from {−1, 1}. 2. Select a row i uniformly at random from {1, . . . , m}. 3. Update the entry at Mi,j by adding s. We let ui denote the number of updates performed on all entries of row mi; we have that (cid:107)mi(cid:107)1 ≤ ui (equality may not hold since two updates can affect the same entry and cancel each other). it is similar to the standard modulo operator, but it maps into the range [−(cid:98)cmod/2(cid:99),(cid:100)cmod/2(cid:101)) (the range is symmetric around zero when cmod is even). Specifically, For notational simplicity, we introduce the mod∗ operator: (cid:17) (cid:106)cmod (cid:107) , − 2 (cid:16)(cid:16) (cid:106)cmod (cid:107)(cid:17) α mod∗ cmod = α + 2 mod cmod where mod denotes the standard modulo operation into [0, cmod). Let cdiv, cmod be suitable values with asymptotic value O (c). The signature of a vector x ∈ {0, 1}d is then the m-dimensional vector σ(x) defined by (cid:22) (Mx)i mod∗ cmod (cid:23) . cdiv σ(x)i = Intuitively, the signature is a CountSketch where we remove large values with mod∗ cmod, and remove the less significant bits with the division by cdiv. 66 Chapter 4. Distance Sensitive Approximate Membership The gap vector between vectors x and y is the m-dimensional vector Γ(x, y) where the ith entry is ε = O δ = (cid:17)(cid:17) , c−1 Theorem 4.5. Let m Γ(x, y)i = cdiv (σ(x)i − σ(y)i mod∗ cmod) . (cid:16) 1 (cid:1)2 log (cid:16) r (c−1) +(cid:0) c The following theorem describes the main property of signature vec- Finally, we refer to γ(x, y) = (cid:107)Γ(x, y)(cid:107)1 as the gap between x and y. tors. O(cid:0)1 + c r log(1/ε)(cid:1), cdiv = O (c), and cmod = O (c) be suitable values. Then, there exists a value Ψ = O (δr), such that for each pair of vectors x, y ∈ {0, 1}d: • if D(x, y) ≤ r, then γ(x, y) ≤ Ψ; • if D(x, y) > cr, then γ(x, y) > Ψ with probability at least 1 − ε. We split the proof of Theorem 4.5 into two cases depending on the value of the approximation factor c: we first target constant approxima- tion factors, and then we focus on larger values. In the following proofs, we assume for notational convenience that two given vectors x and y differ on the first D(x, y) positions. We let x(cid:48) and y(cid:48) denote the prefix of length D(x, y) of x and y (i.e., the positions where they differ), M(cid:48) denote the first D(x, y) columns of M, m(cid:48)i the ith row of M(cid:48), and u(cid:48)i the number of updates affecting m(cid:48)i. Proof of Theorem 4.5 with c = O(1). For the case c = O (1), we set the following parameters: (cid:26) (cid:18)1 (cid:19)(cid:27)(cid:25) , r, 2 c − 1 log ε (cid:24) m = 24 max c2 c − 1 cdiv = 1, cmod = 2, δ = 1, Ψ = r. Note that the above values are consistent with the asymptotic values stated in Theorem 4.5 since c = O (1). With these values, the signature definition simplifies to σ(x)i = (Mx)i mod∗ 2, 4.4. Upper bounds 67 where each column of M is a random vector with exactly one entry in {−1, 1} and the remaining m− 1 entries set to zero. Then, the gap vector becomes: Γ(x, y)i = M(x − y)i mod∗ 2 = M(cid:48)(x(cid:48) − y(cid:48))i mod∗ 2. The first equality is true because there is no rounding if cdiv = 1, and σ is a linear function of x and y. The second one follows since the bit positions where x and y are equal do not affect the gap vector. When D(x, y) ≤ r, M(cid:48) contains at most r entries in {−1, 1} and hence Consider now the case D(x, y) ≥ cr. The second part of Theorem 4.5 γ(x, y) = (cid:107)M(cid:48)(x(cid:48) − y(cid:48))(cid:107)1 ≤ r, proving the first part of Theorem 4.5. follows by two claims: Claim 1: With probability at least 1− ε, there are more than r rows of M(cid:48) affected by an odd number of updates; we refer to these rows as odd rows. Claim 2: If m(cid:48)i is an odd row, then Γ(x, y)i = 1. i=1 Γi(x, y) > r = Ψ and hence The two claims imply that γ(x, y) = ∑m Theorem 4.5 follows. The following Lemmas 4.2 and 4.3 show that the above claims hold. Lemma 4.2 (Claim 1). Let x, y be two input vectors in {0, 1}d, and let M(cid:48) be the sub-matrix of M associated with the positions where x and y differ. If x and y have distance at least cr, then there are more than r odd rows in M(cid:48) with probability at least 1 − ε. Proof. Consider the D(x, y) updates used in the construction of M(cid:48). If after the first D(x, y) − cr updates there are more than (c + 1)r rows with an odd number of updates, then the theorem follows: indeed, the remaining cr updates can decrease the number of odd rows by at most cr. Suppose now that there are Yo ≤ (c + 1)r odd rows after the first D(x, y) − cr updates, and consider the last cr updates. Let Yj, with j ∈ {1, . . . cr} be a random variable set to 1 if the jth update affects an odd row, which then becomes an even row; Yi is set to 0 otherwise. The probability that Yj = 1 is p ≤ (Yo + j − 1)/m ≤ 3cr/m since there can be at most Yo + j − 1 odd rows before the jth update: the initial Yo odd rows and the rows affected by the previous j − 1 updates. Let 68 Chapter 4. Distance Sensitive Approximate Membership Y = ∑cr j=1 Yj. The expected value of Y is µ = pcr ≤ 3(cr)2/m. Let η = (c − 1)r/(2µ) − 1 (note that η ≥ 0). By a Chernoff bound, we have Pr[Y ≥ (c − 1)r/2] = Pr[Y ≥ µ(1 + η)] ≤ e−η2µ/2 (cid:19) (cid:18) (cid:16) ≤e− ≤e− ≤ε. ( c−1 c )2 m 24 + 3(cr)2 ( c−1 c )2 m 24− (c−1)r 2 2 2m − (c−1)r (cid:17) Therefore, with probability at least 1 − ε, there are Y < (c − 1)r/2 updates that affect odd rows and make them even. It follows that the number of odd rows after all updates is then Y0 + (cr − Y) − Y ≥ cr − 2Y > r. Lemma 4.3 (Claim 2). If row m(cid:48)i is odd, then Γi(x, y) = 1. Proof. When δ = 1, there is one update per column and the number of non zero entries in m(cid:48)i coincides with the number of updates (this may not happen if δ > 1). Let h1, . . . , hui denote the ui non zero entries in m(cid:48)i. We have that mi(x(cid:48) − y(cid:48)) = ∑ui j=1 M(cid:48)i,hj ) and M(cid:48)i,j are in {−1, 1} and since ui is odd, then the sum must be odd and Γi(x, y) = m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ 2 = 1. Proof of Theorem 4.5 for c = 1 + Ω(1). Let β = 15/(p1p2)2 where p1 and p2 are suitable constants (e.g. p1 = 0.9, p2 = 0.094). The proof presented here then holds for c ≥ 2) ≈ 545. We believe that a smaller approximation factor c can be obtained with a more careful analysis of the constants. The parameters used in the signature construction are set as follows: ). Since (x(cid:48)hj − y(cid:48)hj (x(cid:48)hj − y(cid:48)hj 5β/(4p2 (cid:113) (cid:24) (cid:24) c r (cid:26)r c (cid:18)2 (cid:19)(cid:27)(cid:25) , ε m = β max , log cdiv = 2c √5β cmod = 8c, , (cid:18)2 δ = log ε Ψ = δr + max (cid:19)(cid:25) (cid:26) , r, c log (cid:18)2 (cid:19)(cid:27) ε . 4.4. Upper bounds 69 Note that the above values are consistent with the asymptotic values stated in Theorem 4.5 since c = 1 + Ω(1). In contrast to the c = O (1) case, the gap vector and the gap cannot be expressed as a function of only the positions where x and y differ (i.e., x(cid:48) and y(cid:48)). In fact, due to the division by cdiv and the floor operation, the gap vector may depend on the positions where x and y coincide. However, we can still provide upper and lower bounds on the gap that depend only on x(cid:48) and y(cid:48). Indeed, it holds that: Γi(x, y) > m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod − cdiv Γi(x, y) < m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod + cdiv. (4.1) Suppose D(x, y) ≤ r, then by (4.1) the gap can be upper bounded as follows: γ(x, y) = m∑ i=1Γi(x, y) (cid:0) m∑ ≤ i=1 m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod + cdiv (cid:26) ≤ cdivm + m∑ (cid:19)(cid:27) i=1m(cid:48)i(x(cid:48) − y(cid:48)) r, c log + δr = Ψ. (cid:18)2 ≤ max ε (cid:1) In the third step, it is crucial to use mod∗ instead of mod since it guarantees that α mod∗ cmod ≤ α. The last step is true since entries in x(cid:48) − y(cid:48) are in {−1, 1} and M(cid:48) contains at most δr non-zero entries. The first part of Theorem 4.5 follows. Suppose now that D(x, y) ≥ cr. We say that row m(cid:48)i is dense if the number of updates ui is at least 4δD(x, y)/(5m). The proof that the gap is larger than Ψ with probability at least 1 − ε relies on the following claims: Claim 3: With probability at least 1 − ε/2, the number of dense rows is Claim 4: With probability at least p2, we have Γi(x, y) > 2c/(cid:112)5β for a at least p1m. Claim 5: With probability at least 1− ε, there are at least 0.89p1p2m rows dense row m(cid:48)i. such that Γi(x, y) > 2c/(cid:112)5β. Then, we have that γ(x, y) = ∑m 70 3 max(cid:8)r, c log(cid:0) 2 ε Chapter 4. Distance Sensitive Approximate Membership i=1 Γi(x, y) > 0.89p1p2m2c/(cid:112)5β > (cid:1)(cid:9) > Ψ since m = (cid:100)β max{r/c, log(2/ε)}(cid:101) and β = 15/(p1p2)2. Thus, the second part of Theorem 4.5 follows. Before proving the claims in Lemmas 4.7-4.9, we introduce three technical lemmas. Lemma 4.4 gives a load bound on a balls and bins problem by using the bounded differences method to manage depen- dent random variables. Lemma 4.5 bounds the probability of a sum of {−1, 1} random variables to be in a specified interval after a modular operation. Finally, Lemma 4.6 gives a lower bound on the tail distribu- tion of the sum of {−1, 1} random variables by leveraging the Berry- Esseen theorem. (cid:16) (p/q)(cid:0)1 − (cid:112)log(1/ε)/(2q) Lemma 4.4. Consider p balls thrown uniformly and independently at ran- dom into q bins, with p ≥ q. For every α > 0 with probability at least (cid:112)2αq/p(cid:1) balls. bins with at least 1 − ε, there are more than q (cid:40) Proof. For every i ∈ {1, . . . , p} and j ∈ {1, . . . , q}, define the following random variable: 1 − e−α − (cid:17) Xi,j = 1 if ball i landed in bin j 0 otherwise Let also Xj = ∑i∈[p] Xi,j be the number of balls in the jth bin; the ex- pected value of Xj is µ = p/q for each j. Since the balls are thrown independently a Chernoff bound gives: Consider now the random variable Yj: (cid:104) Pr Yj = 1 − (cid:16) (cid:112)2α/µ 1 if Xj > µ(cid:0)1 − Xj ≤ µ (cid:40) (cid:17)(cid:105) (cid:112)2α/µ(cid:1) ≤ e−α 0 otherwise Let Y = ∑q j=1 Yj; we use YY1,..,Yq to denote the actual value of Y with the specified values. Since there is dependency among the Yj, we use the method of bounded differences [52] to bound the tail distribution, instead of a Chernoff bound. The random variable Y satisfies the Lips- chitz property with constant 1, that is: YY1,...,Yi,...,Yq − YY1,...,Y(cid:48)i ,...,Yq = Yi − Y(cid:48)i ≤ 1 4.4. Upper bounds 71 whenever Yi (cid:54)= Y(cid:48)i for every i ∈ {1, . . . , q}. By the method of bounded differences [52, Corollary 5.2], we get Pr [Y ≤ E[Y] − t] ≤ e−2t2/q, and then Pr [Y > E[Y] − t] ≥ 1 − ε if t = (cid:112)(q/2) log(1/ε). Since E[Y] ≥ q(cid:0)1 − Pr(cid:2)Xj ≤ µ(cid:0)1 − ≥ q (1 − e−α) , the claim follows. (cid:112)2α/µ(cid:1)(cid:3)(cid:1) Lemma 4.5. Consider a sequence s1, . . . , sk of independent and evenly dis- tributed random variables in {1,−1}, and an arbitrary value q ∈ N. Let S = ∑k i=1 si and Sq = S mod∗ q. Then for all values a, b such that 0 ≤ a < b ≤ (cid:100)q/2(cid:101) and b − a ≥ q/3, we have: Pr[S ≥ a] 2 < Pr[a ≤ Sq < b] < Pr[S ≥ a]. (4.2) Proof. Let k(cid:48) = k/q and assume for the sake of simplicity that k(cid:48) is an integer, and that q, b and a are even (the proof extends to the general case with minor adjustments). We define the following four quantities: H1= ∑k(cid:48)−1 H2= ∑k(cid:48)−1 H3= ∑k(cid:48)−1 H4= ∑k(cid:48)−1 (cid:96)=0 Pr [(cid:96)q + a ≤ S < (cid:96)q + b] ; (cid:96)=0 Pr [(cid:96)q + b ≤ S ≤ ((cid:96) + 1)q − b] ; (cid:96)=0 Pr [((cid:96) + 1)q − b < S ≤ ((cid:96) + 1)q − a] ; (cid:96)=0 Pr [((cid:96) + 1)q − a < S < ((cid:96) + 1)q + a] . Standard computations show that: Pr[a ≤ Sq < b] = H1 + H3 and that Pr[S ≥ a] = H1 + H2 + H3 + H4. We then have that Pr[a ≤ Sq < b] < Pr[S ≥ a], and the right side of the inequality in (4.2) follows. We now focus on the other side of the inequality. We prove that H1 ≥ H2 + H4. The random variable S has value i, with i ∈ [−k, k] if there are (k + i)/2 terms set to +1 and (k − i)/2 terms set to −1. If k + i is odd, this cannot happen and hence Pr[S = i] = 0. On the other hand, if k + i is even, we have Pr[S = i] = ( 2k since the si terms are independent and evenly distributed. Note that Pr[S = i] is decreasing for even values of i. Let us define [ α β/2] to ( α β/2) if β is even and to 0 if β is odd: we thus (k+i)/2] for any even/odd i. Let β ≥ α and γ ≥ 1, we have Pr[S = i] = [ have the following property: k k (k+i)/2) 1 (cid:21) (cid:20) (cid:21) (cid:20) (cid:20) (cid:20) α (cid:21) β/2 + α (β + 1)/2 > α (β + γ)/2 + α (β + γ + 1)/2 (cid:21) . 72 Chapter 4. Distance Sensitive Approximate Membership The correctness of the property follows from the fact that there is exactly one non zero term on each side of the inequality by definition of [ α β/2], and the non zero one on the right is decreasing in γ. We then have, for any integer (cid:96) ≥ 0, that : (cid:20) k (k+j) 2 (cid:21) 1 2k b+(cid:96)q−1∑ j=a+(cid:96)q Pr[a + (cid:96)q ≤ S < b + (cid:96)q] = 2 ≥ 2 (cid:20) k (cid:21) 1 a+((cid:96)+1)q−2b∑ (k+j) 2k j=a+(cid:96)q a+((cid:96)+1)q−2(b−a)−1 2 ∑ + 2 j=a+((cid:96)+1)q−2b+1 (cid:20) k (k+j) 2 (cid:21) 1 2k , where the step follows by the initial assumption (b − a) ≥ q/3. By using the above property of [ α β/2], we shift the indexes of the above summations (we add b − a to the first sum and 2(b − a) to the second one): (cid:20) k Pr[a + (cid:96)q ≤ S < b + (cid:96)q] >2 2k + 2 ((cid:96)+1)q−b∑ (k+j) j=(cid:96)q+b 2 (cid:21) 1 (cid:20) k (k+j) 2 (cid:21) 1 2k ((cid:96)+1)q+a−1∑ j=((cid:96)+1)q−a+1 ≥ Pr[(cid:96)q + b≤S≤((cid:96) + 1)q − b] + Pr[((cid:96) + 1)q − a<S<((cid:96) + 1)q + a] ≥H2 + H4. (Note that the derivation requires some adjustments when q, b or a are not even). Therefore, Pr[S ≥ a] = H1 + H2 + H3 + H4 < 2(H1 + H3) ≤ 2 Pr[a ≤ Sq < b]. The left side of the inequality in (4.2) follows. Lemma 4.6. Let S = ∑k random variables in {−1, +1}, and let α > 0 be any arbitrary value. Then, i=1 si, where the si terms are independent and unbiased Pr[S ≥ α√k] ≥ 2α √2π(α2 + 1)eα2/2 − 1 2√k . Proof. We observe that E[si] = 0, σ2 = E[s2 i ] = 1 and ρ = E[si3] = 1. By the Berry-Esseen theorem [23], we have that the random variable Q = S/(√kσ) = S/√k can be approximate by a standard normal dis- tribution N (0, 1) with error Pr[Q ≤ x] − Ψ(x) ≤ Cρ σ3√k , 4.4. Upper bounds 73 where Ψ(x) is the cumulative distribution function of the standard normal distribution N (0, 1) and C is a suitable constant smaller than 1/2 [109]. The above inequality can be rewritten as Pr[Q > x] − Ψc(x) ≤ 1 2√k , with Ψc(t) = 1 − Ψ(x). We then get Pr[S ≥ α√k] = 2 Pr[S ≥ α√k] = 2 Pr[Q ≥ α] ≥ 2Ψc(α) − Since Ψc(x) ≥ x/(√2π(x2 + 1)ex2/2) (See e.g. lows by inserting the bound for Ψc(x). . 1 2√k [48, 3]), the lemma fol- We are now ready to prove the three claims used in the proof of Theorem 4.5 for c = Ω (1). Lemma 4.7 (Claim 3). With probability at least 1 − ε/2, the number of dense rows in M(cid:48) is at least p1m, with p1 = 0.9. Proof. Matrix M(cid:48) is obtained by performing δ random updates per col- umn independently and uniformly distributed. The number of updates ui affecting row m(cid:48)i is distributed as the number of balls in a bin after randomly throwing δD(x, y) balls into m bins. By applying Lemma 4.4 with α = 3, it follows that, with probability at least 1 − ε/2, there are more than (cid:113) m(cid:48) ≥ (1 − 1/e3 − rows where log(2/ε)/(2m))m ≥ p1m (cid:32) (cid:115) (cid:33) ui ≥ δD(x, y) m 1 − 6m δD(x, y) 4δD(x, y) as soon as c ≥ 5(cid:112)6β + 1 (which is true under the initial hypothesis (cid:113) 5m ≥ 5β/(4p2 2)). These m(cid:48) rows are then dense. c ≥ 74 Chapter 4. Distance Sensitive Approximate Membership Lemma 4.8 (Claim 4). If m(cid:48)i is dense, then Γi(x, y) > 2c/(cid:112)5β with proba- Proof. Let K = 2c/(cid:112)5β(1 + 1/(cid:112)β) and assume that the inequality bility at least p2 = 0.094. m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod ≥ K holds. Then, the lemma follows by ap- plying (4.1): Γi(x, y) > m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod − cdiv ≥ K − cdiv = c/(√5β) + 2c/(cid:112)5β − cdiv = 2c/(cid:112)5β. We now show that the above inequality holds (i.e., m(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod ≥ K). The inner product m(cid:48)i(x(cid:48) − y(cid:48)) can be rewritten as ∑ui j=1 σj(x(cid:48) − y(cid:48)) f (j), where f (j) is the position in m(cid:48)i affected by the jth update. Since (x(cid:48) − y(cid:48)) has entries in {−1, 1} and the σj are independent, m(cid:48)i(x(cid:48) − y(cid:48)) has the same density function as S = ∑ui Pr[M(cid:48)i(x(cid:48) − y(cid:48)) mod∗ cmod ≥ K] = Pr[S mod∗ cmod ≥ K] > j=1 σj. Then, Pr[S ≥ K] , 2 where the last step follows by applying Lemma 4.5 with a = K, b = cmod/2 and q = cmod (note that b − a ≥ cmod/3). To lower bound Pr[S ≥ K], we apply Lemma 4.6 with α = 1 + 1/(cid:112)β since K ≤ √ui(1 + 1/(cid:112)β). Hence, Pr[S ≥ (1 + 1/(cid:112)β)√ui] √2π((1 + 1/(cid:112)β)2 + 1)e(1+1/√β)2/2 − 1 + 1/(cid:112)β ≥ 2 1 4√ui Pr[S ≥ K] 2 ≥ ≥ p2, where the last step follows by observing that √ui ≥ 2c/(cid:112)5β ≥ 1/p2, 0.89p1p2m rows such that Γi(x, y) > 2c/(cid:112)5β. and then by numerically evaluate the resulting bound. Lemma 4.9 (Claim 5). With probability at least 1 − ε, there are at least 4.4. Upper bounds 75 Γi(x, y) > c/(cid:112)β, and 0 otherwise. By the previous Lemma 4.8, we Proof. By Lemma 4.7, there are m(cid:48) ≥ p1m dense rows with probability 1 − ε/2. For each dense row, let Yi be a random variable sets to 1 if have that Pr[Yi = 1] ≥ p2. Let Y = ∑m(cid:48) i=1 Yi. Since the Yi are independent and E[Y] = p2m(cid:48), a Chernoff bound gives: (cid:20) (cid:18) (cid:113) (cid:19)(cid:21) Pr Y < p2m(cid:48) 1 − 2 log(2/ε)/(p2m(cid:48)) ≤ ε/2. By plugging in the actual values of variables, we have Pr[Y < 0.89p1p2m] ≤ ε/2. at least 0.89p1p2m of them satisfy Γi(x, y) > c/(cid:112)β. Therefore, by an union bound there are at least p1m dense rows and A filter with point-wise error 4.4.2 A distance sensitive approximate membership filter with point-wise er- ror is obtained by just storing the n signatures of the points in S. We have the following theorem: Theorem 4.6. There exists a (r, c, ε)-distance sensitive approximate member- ship filter with point-wise error which requires (cid:18) c (cid:19)2 c − 1 (cid:17)(cid:33)(cid:33) (cid:16) n ε log r (c − 1) + O (cid:32) (cid:32) c + log(cid:0) n n ε (cid:1)(cid:1)(cid:1) bits, and it is optimal if r/c ≥ log(n/ε) or ter uses O(cid:0)n(cid:0) r bits for any c > 1 on a set S of n points. When c ≥ 2, the fil- ε ≤ 1/n1+o(1). Proof. We assume a shared source of randomness that can be used to recover the random matrix M without storing it. Consider the n signa- tures of points in S constructed with error ε(cid:48) = ε/n. By an union bound, the n signatures give a false positive with probability ε. Since each sig- nature requires O bits by Theorem 4.5, the first part of the claim follows. The optimality with c ≥ 2 of the filter follows from Theorem 4.3. (cid:16) r (c−1) +(cid:0) c (cid:1)2 log(cid:0) n (cid:1)(cid:17) c−1 ε 76 Chapter 4. Distance Sensitive Approximate Membership A filter with average error 4.4.3 The point-wise error filters are of course valid average error filters, but in this setting we can also construct space efficient filters with a c = 1 approximation factor. Define Qr-far = {x ∈ {0, 1}d D(x, S) ≥ r} and similarly Q(r; cr)-far = {x ∈ {0, 1}d r ≤ D(x, S) ≤ cr}. By setting c = r in the point-wise filter, we obtain an average er- ror filter with c = 1 which matches the Ω (n log(1/ε)) lower bound of Theorem 4.2 for small r. Interestingly, this space bound shows that it is possible to support distance sensitive membership queries in the aver- age error setting with the asymptotic space bound of a Bloom filter. Theorem 4.7. Let r ≤ √d, n ≤ 2d/3 and ε ≥ 1/2d−2. Then, there exists an optimal (r, 1, ε)-distance sensitive approximate membership filter with average error which requires O (n log(1/ε)) bits on a set S of n points. Proof. Let us consider a (r, r, ε/4)-filter F with point-wise guarantees. The amount of false positives accepted by F is P ≤ (ε/4)Qr2-far + Q(r; r2)-far. We have Q(r; r2)-far ≤ nr2( d r2) ≤ (ε/4)2d since d ≥ r2, n ≤ 2d/3 and ε ≥ 4/2d/2. Trivially, we also have that Qr2-far ≤ 2d. We see that P ≤ ε2d−1. Now note that Qr-far ≥ 2d − nr(d r) ≥ 2d−1 by d ≥ r2 and n ≤ 2d/3. We combine the two bounds to see P ≤ ε2d−1 ≤ εQr-far. The opti- mality of F follows from Theorem 4.2 since r2/d < 1 and n log(1/ε) is a lower bound. 4.5 Conclusion To the best of our knowledge, this is the first time upper and lower space bounds are given for the problem of distance sensitive filters without false negatives. We have introduced distance sensitive signatures for Hamming vectors and used them to derive filters with point-wise and average errors. The proposed filters are optimal under certain assump- tions, but it is an open question to close the gap without these assump- tions, specifically when ε is large. Another interesting research direction is to investigate trade-offs be- tween space and query time: our filter requires reading all signatures at query time and it is not clear to which extent the query time can be improved. Chapter 5 Fast Nearest Neighbor Preserving Embeddings In this Chapter we show an analogue to the Fast Johnson-Lindenstrauss Transform for Nearest Neighbor Preserving Embeddings in (cid:96)2. These are randomized embeddings that preserve the (approximate) nearest neighbors for a set of points. The dimensionality of the embedding space is bounded not by the size of the embedded set n, but by its dou- bling dimension λ. For most large real-world datasets this will mean a considerably lower-dimensional embedding space than possible when preserving all distances. However the embedding is slow since it re- quires multiplication with a dense matrix. To reduce the embedding time we propose a sparse mapping. The resulting embeddings can be used with existing approximate nearest neighbor data structures to yield speed improvements. 5.1 Introduction Many algorithmic problems become overwhelmingly difficult in high- dimensional settings. One way of trying to combat this problem is to discover mappings that preserve the metric relevant to solving a given problem, while embedding it into a lower dimensional setting. Most famously Johnson and Lindenstrauss [74] showed the lemma: Lemma 5.1 (JL-Lemma [74]). For any integer d > 0, and any  > 0, δ ∈ (0, 1/2), for k = Θ(−2 log(1/δ)) there exists a distribution Π such that for 78 Chapter 5. Fast Nearest Neighbor Preserving Embeddings k × d matrices M ∼ Π, for any x ∈ Rd, Pr [(1 − )(cid:107)x(cid:107)2 ≤ (cid:107)Mx(cid:107)2 ≤ (1 + )(cid:107)x(cid:107)2] > 1 − δ S ⊆ Rd into k = O(cid:0)logS−2(cid:1) dimensions while preserving (cid:96)2 dis- The JL-Lemma shows the existence of an embedding of any set tances up to a multiplicative (1 ± ) distortion. Proofs can be found for many different M [57, 74, 50, 4], including Gaussian matrices [74, 50] In fact we might use any sub-gaussian dis- and {0,±1} matrices [4]. tribution to fill the matrix [73]. These low-dimensional embeddings can be used to speed up many fundamental high-dimensional problems like closest pair, nearest neighbor or minimum spanning tree. They can also be used to decrease the storage requirements of a dataset when we only need to preserve norms. Further discussion and examples can be found for instance in [110, 69]. It is known that if we want to preserve the norm for all x ∈ S, the embedding dimension k = O(logS−2) is optimal, see [82, 81]. However it might not be necessary to preserve norms for all all points in S. If for example we are interested in nearest neighbor queries we require only that neighbors remain close to each other, while far away points do not get too close. This idea was introduced and formalized as Nearest Neighbor Preserving Embeddings by Indyk and Naor [73], who also presented an embedding. Using a full Gaussian matrix they showed that nearest neighbor distance can be preserved while embedding into fewer dimensions than in the distance preserving setting. Specifically, k is O(−2 log λS log(2/)) where λS is the doubling constant of S. By removing the requirement that all distances be preserved we can get k smaller than in the bounds discussed above [82, 81, 10]. Another line of research has focused on improving the speed of the embeddings by using sparse matrices while keeping the distortion low [75, 49, 4, 9]. Call f < 1 the sparsity parameter1. If each entry in the used matrix is 0 with probability 1 − f we can improve the embedding time from O(dk) to expected time O(dk f ) by sparse matrix multiplica- tion. A classic sparse matrix construction is the Fast Johnson Linden- strauss Transform (FJLT) Φ : Rd → Rk [9]. In this chapter we show (cid:16) that the FJLT is in fact a Nearest Neighbor Preserving embedding with k = O(−2 log λS log(2/)) and sparsity parameter f = O(log2 n/d) for O d log d + −2 log3 n evaluation time. (cid:17) 1Normally q is used for this, but in this dissertation we reserve q for query points 5.2. Preliminaries 5.2 Preliminaries 79 Definition 5.1 (Nearest Neighbor Preserving Embeddings [73]). Let , δ ∈ (0, 1), and let S be a set of points in Rd. For any point x ∈ S let x(cid:48) denote the point closest to x in S \ {x} under the (cid:96)2 norm. We say that an embedding Φ : Rd → Rk is nearest neighbor preserving with parameters (, δ) if for every x ∈ S, the following properties hold with probability at least δ: 1. min z∈S\{x} (cid:107)Φx − Φz(cid:107)2 ≤ (1 + )(cid:107)x − x(cid:48)(cid:107)2, and 2. ∀y ∈ S: If (cid:107)x− y(cid:107)2 > (1 + 2)(cid:107)x− x(cid:48)(cid:107)2 then (cid:107)Φx− Φy(cid:107) > (1 + )(cid:107)x− x(cid:48)(cid:107)2. Definition 5.2 (Fast Johnson-Lindenstrauss Transform [9]). Let an em- bedding Φ be defined by a k× d matrix Φ := PHD as follows: D is a ran- dom ±1 diagonal d× d matrix, H is the d-dimensional Walsh-Hadamard transform, and P is a k × d matrix with entries X ∼ N (0, f −1) w.p. f 0 (cid:40) pij = . w.p. 1 − f Here f is the expected fraction of non-zero entries, called the sparsity parameter of the FJLT2. Definition 5.3 (Doubling constant λS). The doubling constant λS of a point set S ⊆ Rd is defined to be the smallest integer λ such that for every x ∈ S, and every r > 0, the point set B(x, r) ∩ S can be covered by at most λ balls B(z, r/2) where z ∈ S. We refer to log2 λS as the doubling dimension of S. 5.3 Fast Nearest Neighbor Preserving Embeddings Given the definitions above let us state the claim: Theorem 5.1 (Fast Nearest Neighbor Preserving Embeddings). For any (cid:19) S ⊆ Rd,  ∈ (0, 1) where S = n and δ ∈ (0, 1/2) for some (cid:18)log (2/) k = O 2 log (1/δ) log λS 2We typeset the three matrices with bold to avoid confusion with the definitions of D and H already in use 80 Chapter 5. Fast Nearest Neighbor Preserving Embeddings there exists a nearest neighbor preserving embedding Φ : Rd → Rk with parameters (, 1 − δ) requiring expected (cid:17) (cid:16) d log(d) + −2 log3 n O operations. By picking δ we can fix the probability of successfully sampling an embedding that is nearest neighbor preserving and close to the expected number of operations. Indyk and Naor presents a proof for embeddings that are constructed using full k × d Gaussian matrices G (see [73, The- orem 4.1]). Requiring O(kd) operations to embed each point. Our con- tribution will be to show how their techniques can be applied to sparse embeddings. We first identify the properties of a map that are sufficient for the Indyk-Naor proof to hold, and then construct sparse embeddings exhibiting the properties with a bounded probability of error. Definition 5.4. Let  ∈ (0, 1). We say that a distribution over maps Φ = PHD : Rd → Rk satisfies the Indyk-Naor property for a set S ⊆ Rd with error η ≥ 0 if with probability 1 − η over the choice of D, the map satisfies that for all x ∈ S, y ∈ S ∪ {0} (P1) PrP[(cid:107)Φ(x − y)(cid:107)2 (cid:54)∈ (1 ± )(cid:107)x − y(cid:107)2] ≤ e−Ω(k2), and (P2) PrP[(cid:107)Φx(cid:107)2 ≤ (cid:107)x(cid:107)2] ≤ (3)k. Note that the above probabilities are taken only over the choices of P. By bounding η with a constant < 1 we will then be able to extend the proof presented by Indyk and Naor to show the correctness of The- orem 5.1. We will then need to increase k by a corresponding constant to make up for the η loss, but the order of k remains unchanged. We will show that the FJLT[9] satisfies the Indyk-Naor properties. The first property to satisfy is the normal Johnson-Lindenstrauss prop- erty, but it is required to hold also for all difference vectors possible from S. The second property is stronger, when  (cid:28) 1/3. We will be referring to P1 and P2 as the Distortion and Shrinkage bound respectively. 5.3. Fast Nearest Neighbor Preserving Embeddings 81 Smoothness 5.3.1 Before we show the two properties from Definition 5.4 we will bound the probability of the diagonal matrix D being in a "smooth" setting. Our later proofs of the Distortion and Shrinkage bounds will be conditioned on this. We call a vector x ∈ Rd s-smooth if (cid:107)x(cid:107)∞ ≤ s (cid:107)x(cid:107)2. Note that since H and D are isometries (cid:107)HDx(cid:107)2 = (cid:107)x(cid:107)2. Definition 5.5. For any s > 0 we say that a given diagonal matrix D is in an s-smooth setting if ∀x, y ∈ S ∪ {0},(cid:107)HD(x − y)(cid:107)∞ ≤ s(cid:107)x − y(cid:107)2. (cid:18)(cid:113) log n (cid:19) In this section we will bound the probability of D not being in an s-smooth setting for s = O , and then in Section 5.3.3 and 5.3.4 we show how the Distortion and Shrinkage bounds follow from smooth- ness. d Let us first consider a single vector z = (x − y) where x, y ∈ S ∪ {0}. Assume (cid:107)HDz(cid:107)∞ ≥ s(cid:107)z(cid:107)2 then there is some entry 1 ≤ i ≤ d such that (HDz)i ≥ s(cid:107)z(cid:107)2. Let b = 1 (cid:107)z(cid:107)2 , then (HDz)ib ≥ s and Pr[(cid:107)HDz(cid:107)∞ ≥ s(cid:107)z(cid:107)2] = Pr[(cid:107)HDzb(cid:107)∞ ≥ s] where zb is a unit vector. So without loss of generality we can focus on unit vectors: Lemma 5.2. Given a unit vector x in Rd, for any s > 0 Pr[(cid:107)HDx(cid:107)∞ ≥ s] ≤ 2de−s2d/2. Proof. See [9] or [89](p.69). u1 = ∑d use: In short let u = HDx = (u1, .., ud)T, so i hixi where the hi are i.i.d. uniformly from {d−1/2,−d−1/2}. We E[esdu1] = d∏ i E[esdhixi ] = d∏ i 1 2 (es√dxi + e−s√dxi ) d∑ i=1 ≤ exp(s2d = es2d(cid:107)x(cid:107)2 2/2 x2 i /2) In a standard Chernoff bound (See Section 1.2). 82 Chapter 5. Fast Nearest Neighbor Preserving Embeddings As a small contribution we now show a slightly better bound for our setting based on approximating the Kinchine inequality constants. We use the fact that s will be bounded away from 0 like Ω(d−1/2). Lemma 5.3. Given cs > 2 and a unit vector x in Rd, for s ≥ √cs/d Pr[(cid:107)HDx(cid:107)∞ ≥ s] ≤ de−s2d ln( cse cs+1 )/2. Proof. Let u = HDx = (u1, .., ud)T, so u1 = ∑d i hixi where the hi are i.i.d. uniformly from {d−1/2,−d−1/2}. Let ±xi denote a uniformly random variable from {xi,−xi}. For all p ≥ 1 by Markov's inequality: i=1 ±xi (√ds)p Pr[u1 ≥ s] = Pr By the Kinchine inequality there is some constant Bp such that: ≥ (√ds)p (cid:104)(cid:12)(cid:12)(cid:12)∑d (cid:12)(cid:12)(cid:12)p(cid:105) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)p (5.1) (cid:35) ≤ E i=1±xi (cid:34)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) d∑ (cid:34)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) d∑ E (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)p(cid:35) i ±xi ≤ Bp(cid:107)x(cid:107) p 2 For p > 2 Haagerup [64] showed that Bp = 2(p−2)/2 Γ( p+1 2 ) Γ(3/2) (See also [91]). Since Γ(3/2) = √π 2 we can simplify this to Bp = 2 p 2 Γ( p+1 2 ) √π . Now we use that for x > 1, Γ(x) ≤ xx−1/2 ex−1 2 )( p+1 2 )−1/2 e( p+1 2 )−1 √2p √π Bp ≤ ( p+1 [84]: (cid:112)p + 1p (cid:114) p + 1 (cid:114) e √π√ep−1 π e = = p p ≤ (cid:114) p + 1 (cid:114) p + 1 e p es2d Plugging back into 5.1 we have: Pr[u1 ≥ s] ≤ 5.3. Fast Nearest Neighbor Preserving Embeddings We now set p = s2d to get: Pr[u1 ≥ s] ≤ (cid:19)s2d/2 (cid:18)1 e + 1 es2d Which gives the result when we use the constraint on s. 83 (5.2) 5.3.2 Fixing s and f Now let s = d−1/2(cid:112)c ln(n2d). We want to set c as small as possible, but such that D is in an s-smooth setting with probability at least 19 20. Using lemma 5.2 as in [9] we can get c = 8, but using lemma 5.3 with cs = c ln(n2d) for x (cid:54)= y we get: Pr[∃x, y ∈ S ∪ 0,(cid:107)HD(x − y)(cid:107)∞ ≥ s(cid:107)x − y(cid:107)2] ≤ ec ln(n2d) ln( cse cs+1 )/2 . = e−c ln( cse n2d cs+1 )/2 Which evaluates to below 19/20 for c = 7, even if we only assume ln(n2d) ≥ 1. Figure 5.1 shows a comparison between lemma 5.2 and lemma 5.3 if we assume ln(n2d) ≥ 10. constructed by setting f = min(cid:0)c(cid:48)s2, 1(cid:1) where c(cid:48) > 0 In the following we will let Φ be a FJLT embedding is some universal constant. We will then show that if D is s-smooth, this setting of f makes Φ = PDH satisfy the distortion and shrinkage bounds. Figure 5.1: Bounds from lemma 5.2 and 5.3 5.3.3 Distortion bound Lemma 5.4 (Distortion bound). For any x, y ∈ S ∪ {0} if D is in an s- smooth setting, for  > 0: Pr [(cid:107)Φ(x − y)(cid:107)2 /∈ (1 ± )(cid:107)x − y(cid:107)2] ≤ e−Ω(k2) Proof. The distortion bound is the main result in [9]. 56780.050.100.150.200.250.300.35FailurePrb. 84 Chapter 5. Fast Nearest Neighbor Preserving Embeddings Shrinkage bound 5.3.4 The shrinkage bound is stronger than the distortion bound for large . We will need it later to confine the probability of any of an infinite series of events happening to a small constant. Lemma 5.5 (Shrinkage bound). For a fixed vector x ∈ S, if D is in an s-smooth setting, for  ∈ (0, 1): Pr P [(cid:107)PHDx(cid:107)2 ≤ (cid:107)x(cid:107)2] ≤ (3)k Following [9] we rewrite (cid:107)PHD(cid:107)2 as ∑k Here yi ∼ N (0, f −1)biui where bi is 1 w.p f and 0 otherwise and u = HDx. De- fine a random variable Zi = biu2 i and we see that yi = N (0, Zi/ f ). By the regular scaling of Gaussian with their standard deviation (See Lemma A.2), it is clear that for an upper bound on: i=1 yi. k∑ Pr[ y2 i ≤ t] we only need to lower bound the Zi. I.e. Lemma 5.6. If ∀i ∈ [k] Zi ≥ f /2 and G is a full Gaussian matrix (entries sampled from N (0, 1)), then ∀t ≥ 0: i 2 ≤ t] ≤ Pr[(cid:107)Gx(cid:107)2 ≤ 2t] Pr[(cid:107)PHDx(cid:107)2 (cid:105) (cid:104) (cid:35) Proof. For i ∈ {1,· · · , k} assume Zi ≥ f 2 and let Xi ∼ N (0, 1), then: (cid:33)2 (cid:32)(cid:114)1 y2 i ≤ t (cid:105) (cid:107)PHDx(cid:107)2 2 ≤ t = Pr Pr (cid:34) k∑ ∑ i=1  = Pr (cid:104)∑ X2 ≤ Pr Xi 2 ≤ t i ≤ 2t . Where the first equality follows the rewriting above and the inequality from the bound on the Zi. In the s smooth setting the most extreme concentration permitted still implies that Zi ∼ B(s−2, f )s2 (See [9]). So Pr [∀i ∈ [k], Zi ≥ f /2] ≥ 19 20(Lemma 3 of [9]). If we combine this bound with Lemma 5.6 we are ready to prove Lemma 5.5. 5.3. Fast Nearest Neighbor Preserving Embeddings 85 (by Lemma 5.6) Proof. Let z ∈ S and let x = z(cid:107)z(cid:107)−1 2 . (cid:104) Pr [(cid:107)PHDz(cid:107)2 ≤ (cid:107)z(cid:107)2] = Pr [(cid:107)PHDx(cid:107)2 ≤ ] = Pr ≤ Pr X2 i ≤ 22 (cid:107)PHDx(cid:107)2 (cid:34) k∑ i (cid:35) Where Xi ∼ N (0, 1). In general for s, t > 0 we know: (cid:104) 2 ≤ 2(cid:105) (cid:35) (cid:34) k∑ i Pr X2 i ≤ t (cid:105) i e−s ∑ X2 e−st E ≤ = est(1 + 2s)−k/2 (cid:104) e−s ∑ X2 = Pr = est k∏ i=1 E i ≥ e−st(cid:105) (cid:105) (cid:105) i e−sX2 (cid:104) (cid:104) e−sX2 i Where the last step uses that E ∞.(See [50]) = 1√1+2s for −1/2 ≤ s ≤ Now to minimize we differentiate w.r.t s: test(1 + 2s)− k 2 + 2(− ⇒ s = (k/t − 1)/2 k 2 )est(1 + 2s)− k 2−1 = 0 ⇔ t = k(1 + 2s)−1 So est(1 + 2s)−k/2 = e(k−t)/2(k/t)−k/2 = e−t/2( k Now plug in t = 22 and we have et )−k/2 ≤ (et)k/2. (cid:35) (cid:34) k∑ i Pr X2 i ≤ 22 ≤ (2e2)k/2 ≤ (3)k Embedding properties 5.3.5 We have now seen how the Distortion and Shrinkage bounds follow from two events: First D must be in an s-smooth setting. Secondly all Zi must be within a constant factor of f . By Lemma 5.3 the first event happens with probability at least 19/20 when setting s = , assuming n2d ≥ 3.7. By choosing f corresponding to s as in[9], the second event 7 lg(n2d) d (cid:113) 86 Chapter 5. Fast Nearest Neighbor Preserving Embeddings LaTeXMP(cid:32)1 LaTeXMP(cid:32)2 LaTeXMP(cid:32)3 Figure 5.2: An illustration of the spanning tree construction used in the proof of Theorem 5.2. occurs with probability at least 19/20(See Lemma 3 of [9]). For the chosen parameters Φ = PHD satisfies the Indyk-Naor properties with probability > 9/10. (cid:17)2 (cid:16) 19 20 We can then move on to prove Theorem 5.1 by showing: Theorem 5.2 (Fast Nearest Neighbor Preserving Embeddings). For any S ⊆ Rd, , δ ∈ (0, 1) and some k = O log (1/δ) log λS . Let Φ = PHD be a FJLT matrix with expected O d log(d) + −2 log3(n) log(2/) (cid:18)log (2/) 2 (cid:16) (cid:19) (cid:17) embedding time. For every x ∈ S let x(cid:48) denotes the point closest to x in S \ {x} under (cid:96)2. With probability at least δ 1. min z∈S\{x} (cid:107)Φx − Φz(cid:107)2 ≤ (1 + )(cid:107)x − x(cid:48)(cid:107)2, and 2. if (cid:107)x − y(cid:107)2 > (1 + 2)(cid:107)x − x(cid:48)(cid:107)2 for some y ∈ S then (cid:107)Φx − Φy(cid:107) > (1 + )(cid:107)x − x(cid:48)(cid:107)2. Proof. Let Φ min{O(d−1 ln(n2d)), 1} so Φ satisfies the Indyk-Naor properties as pr. Definiton 5.4 with probability at least 9/10. The proof then follows PHD follow Definition 5.2 with = = f 5.3. Fast Nearest Neighbor Preserving Embeddings 87 from [73, Theorem 4.1]. For completeness we include an extended version of the proof here. For familiar readers, the only difference in this version is in making the spanning tree construction explicit. Without loss of generality let x = 0 and (cid:107)x(cid:48)(cid:107)2 = 1. To show the first property let y ∈ S satisfy (cid:107)y(cid:107)2 = 1, then by the distortion bound, Pr[(cid:107)Φy(cid:107) ≥ (1 + )] ≤ e−Ω(k2). So for some universal constant C > 0, setting k ≥ C ln(1/δ)/2 we get: Pr[ min z∈S\{x} (cid:107)Φx − Φz(cid:107)2 > (1 + )(cid:107)x − x(cid:48)(cid:107)2] < δ/2 To show the second property we construct a spanning tree of (S \ B(x, 1 + 2)) ∪ {0} with 0 at the root. Let ri = 1 + (i + 2). Consider the annuli: Ai = S ∩ B(0, ri+1) \ B(0, ri), for i ≥ 1 By the definition of λS, for any i we can construct a minimal set Si ⊆ S such that Ai ⊆ ∪t∈Si B(t, /4) and Si ≤ log2( 4ri  ). The first level of the tree consists of an edge between x and each t ∈ Si for all i ≥ 0. From each t a spanning tree is build on the points in B(t, /4) with t at the root, as described in lemma 5.7. Figure 5.2 illustrates the construction. Some ordering is imposed on the t points so points in overlapping balls are only spanned once. We can then restate the second property as ∃i ≥ 0,∃x ∈ Ai.(cid:107)Φx(cid:107) ≤ 1. ∃i ≥ 0,∃t ∈ Si.(cid:107)Φt(cid:107)2 ≤ 1 +  +  2. ∃i ≥ 0,∃t ∈ Si,∃x ∈ B(t,  4 ) ∩ S.Φx /∈ B(Φt, (1 + √i)  4,) 1 + , at least one of two events took place: 4 (1 + √i) Since (cid:107)t(cid:107)2 ≥ ri −  (cid:40) 4 there is some constant C such that: 1 + (1 + √i)/4 +  1 + (2 + i) − /4 ≤ 1 − /8 for i ≤ 1/2 C/√i for i > 1/2 (cid:107)Φt(cid:107) (cid:107)t(cid:107)2 = 88 Chapter 5. Fast Nearest Neighbor Preserving Embeddings Fix some i. Using the distortion and shrinkage bounds: (cid:105) (cid:104) (cid:40) ∃t ∈ Si,(cid:107)Φt(cid:107)2 ≤ 1 + (1 + √i)/4 +  (cid:40) e−ck2 for i ≤ 1/2 (3C/√i)k for i > 1/2 log2(4ri/) x log2(4ri/) x e−c(cid:48)k2 for i ≤ 1/2 i−c(cid:48)k for i > 1/2 λ λ Pr ≤ ≤ For k ≥ c(cid:48)(cid:48) 2 log(2/) log(λS) where c(cid:48)(cid:48) is some universal constant. For the second event lemma 5.7 gives: Pr[∃t,∃y ∈ B(t,  4 So there is some c(cid:48)(cid:48)(cid:48) where the first event is most likely. Hence: 2e−c(cid:48)(cid:48)(cid:48)k2 for i ≤ 1/2 2i−c(cid:48)(cid:48)(cid:48)k for i > 1/2 )∩ S, Φy /∈ B(Φt, (1 +√i) (cid:40) Pr[∃x ∈ Ai.(cid:107)Φx(cid:107)2 ≤ 1 + ] ≤ log2(4ri/4) x )] ≤ λ  4 e−ck(1+i) ≤ e−c(cid:48)k(1+i) Summing over all the i we get: Pr[∃i ≥ 0,∃x ∈ Ai.(cid:107)ΦS(cid:107)2 ≤ 1 + ] = 2i−c(cid:48)(cid:48)(cid:48)k ≤ δ/2 2 2 e−c(cid:48)(cid:48)(cid:48)k2 + ∑ i>1/2 ≤ ∞ ∑ i Pr[∃x ∈ Ai.(cid:107)Φx(cid:107)2 ≤ 1 + ] for some k ≥ log(1/δ) c 2 log(2/) log(λS) where c is some large enough constant. The number of operations required for embedding x is O(d) for the diagonal matrix D, O(d log d) for H using the Walsh- Hadamard transform [56] and finally O (P) where P is the number of non-zero entries. P ∼ B(kd, f ) so by our setting of f : E [P] = kd f = O(−2 log(λS) log(2/) log2(n)) = O(−2 log3(n) log(2/)) 5.3. Fast Nearest Neighbor Preserving Embeddings 89 Lemma 5.7. Let S be a subset of the unit ball in Rd, including 0. Then there exists universal constants c, C > 0 such that for  > 0 and k ≥ C log λS: Pr[∃x ∈ S,(cid:107)PHDx(cid:107)2 ≥ (1 + )] ≤ e−ck(1+)2. Proof. The proof is given in [73, Lemma 4.2]. We include a spanning tree version here for completeness. We build a spanning tree T on S with root 0 in the following way: Define sets for each possible level of the tree, L0, L1, . . . ⊆ S. Let L0 = 0. To build Lj+1, for every point t ∈ Lj let St be the minimal size set such that ∪s∈StB(t, 2−j−1) ∩ S covers all of B(t, 2−j) ∩ S. By the definition of doubling constant we know that St ≤ λS. Connect t to every point in St, if some St sets overlap only a single connection is made to avoid cycles. Let Lj+1 = ∪t∈LjSt. We observe that 0 < Lj ≤ λ Now let E(T) denote the edges in T. Let Ej be the subset of E(T) with one node in Lj and the other in Lj+1, by the construction of the tree ∀e ∈ Ej we have (cid:107)e(cid:107)2 ≤ 2−j+1. For every x ∈ S denote the unique path from 0 to x in T by p(x) ⊆ E(T). For 0 ≤ j ≤ p(x) let pj(x) ∈ Lj be the vertex on the path at level j, for j > p(x) let pj(x) = x. We can then compose x as ∑∞ j=0 to edges in E(T), and the remaining steps having 0 contribution. The argument then follows [73]: Pr[∃x ∈S,(cid:107)PHDx(cid:107)2 ≥ (1 + )] (cid:0)pj+1(x) − pj(x)(cid:1), the first p(x) steps corresponding (cid:19)−j(cid:35) (cid:18)3 (1 + ) (cid:34) j S. 3 2 ,for any unit vector x For k ≥ C log λS + 1. Crucially the second last step uses thatE(T) = S − 1. We can then use Lemma 5.3 to see that D is in a smooth setting (cid:34) ∃x ∈ S,∃j ≥ 0,(cid:107)PHD(pj+1(x) − pj(x))(cid:107)2 ≥ (cid:35) (cid:34) 1 +  3 Pr ∃e ∈ Ej,(cid:107)PHDe(cid:107)2 ≥ (cid:34) ∃e ∈ Ej,(cid:107)PHDe(cid:107)2 ≥ 2 (cid:19)−j(cid:35) (cid:18)3 (cid:18)4 (cid:19)j (cid:19)j (cid:18)4 3 (cid:35) (cid:107)e(cid:107)2 − 1 2j S Pr λ λ (cid:107)PHDx(cid:107)2 ≥ 1 + 3 S e−ck(1+)2(4/3)2j/100 ≤ e−ck(1+)2 6 2j 1 +  6 1 +  Pr = ≤ ≤ Pr ∞ ∑ j=0 ∞ ∑ j=0 ∞ ∑ j=0 ∞ ∑ j=0 ≤ ≤ 90 Chapter 5. Fast Nearest Neighbor Preserving Embeddings with constant probability, for our setting of s at least 19 then follows from Lemma 5.4. 20. The last step 5.4 Conclusion In this chapter we present embeddings that combine the low- dimensional embedding space achieved by Nearest Neighbor Pre- serving Embeddings [73] with a speedup of the embedding runtime achieved by a Fast-JL construction [9]. This results in embeddings that are faster than fully Gaussian Nearest Neighbor Preserving Embeddings and use fewer dimensions than any Johnson-Lindenstrauss type embed- ding. The benefit of Nearest Neighbor Preserving Embeddings generally depends on the difference between n = S and λS. While λS is always upper bounded by n it can often be much smaller, this helps to explain why some datasets can be successfully embedded into much fewer di- mensions, and much faster, than theoretical results looking only on S can explain. For datasets with low doubling dimension we can expect to find fast embeddings into a low number of dimensions, even if the dataset is very large. While the number of rows in the embedding matrix is independent of n, the sparsity of the matrix is not. This happens because we must ensure that all O(n2) possible edges in the constructed spanning trees used in lemma 5.7 are smooth. Future work could focus on alternative constructions to increase the sparsity. Chapter 6 Set Similarity Join Set similarity join is a fundamental and well-studied database operator. It is usually studied in the exact setting where the goal is to compute all pairs of sets that exceed a given level of similarity (measured e.g. as Jaccard similarity). But set similarity join is often used in settings where 100% recall may not be important -- indeed, where the exact set simi- larity join is itself only an approximation of the desired result set. We present a new randomized algorithm for set similarity join that can achieve any desired recall up to 100%, and show theoretically and empirically that it significantly outperforms state-of-the-art implementa- tions of exact methods, and improves on existing approximate methods. Our experiments on benchmark data sets show the method is several times faster than comparable approximate methods, at 90% recall the algorithm is often more than 2 orders of magnitude faster than exact methods. Our algorithm makes use of recent theoretical advances in high-dimensional sketching and indexing that we believe to be of wider relevance to the database community. 6.1 Introduction It is increasingly important for data processing and analysis systems to be able to work with data that is imprecise, incomplete, or noisy. Similarity join has emerged as a fundamental primitive in data cleaning and entity resolution over the last decade [16, 39, 104]. In this chapter we focus on set similarity join: Given collections R and S of sets the task is to compute R (cid:46)(cid:47)λ S = {(x, y) ∈ R × S sim(x, y) ≥ λ} 92 Chapter 6. Set Similarity Join where sim(·,·) is a similarity measure and λ is a threshold parameter. We deal with sets x, y ⊆ {1, . . . , d}, where the number d of distinct tokens can be naturally thought of as the dimensionality of the data. Many measures of set similarity exist [42], but perhaps the most well- known such measure is the Jaccard similarity, J(x, y) = x ∩ y/x ∪ y . For example, the sets x = {IT, University, Copenhagen} and y = {University, Copenhagen, Denmark} have Jaccard similar- ity J(x, y) = 1/2 which could suggest that they both correspond to the same entity. In the context of entity resolution we want to find a set T that contains (x, y) ∈ R × S if and only if x and y correspond to the same entity. The quality of the result can be measured in terms of precision (R (cid:46)(cid:47)λ S) ∩ T/T and recall (R (cid:46)(cid:47)λ S) ∩ T/R (cid:46)(cid:47)λ S (both of which should be as high as possible). We will be interested in methods that achieve 100% precision, but that might not have 100% recall. We some- times referring to methods with 100% recall as exact, and others as ap- proximate. Note that this is in view of the output size, not the similarity as in our other approximate similarity problems. Considering similarity join methods that are not exact allow for new randomized algorithmic techniques. It has been known from a theoretical point of view that this can lead to algorithms that are more scalable and robust (against hard inputs), compared to exact set similarity join methods for high- dimensional data. However, these methods have not seen widespread use in practical join algorithms, arguably because they have not been sufficiently mature, e.g. having large overheads that make asymptotic gains disappear and being unable to take advantage of features of real- life data sets that make similarity join computation easier. Our contributions. We present the Chosen Path Set Similarity Join (CPSJoin) algorithm, its theoretical underpinnings, and show experi- mentally that it achieves substantial speedup in practice compared to state-of-the-art exact techniques by allowing less than 100% recall. The two key ideas behind CPSJoin are: • A new recursive filtering technique inspired by the recently pro- posed ChosenPath index for set similarity search [44], adding new ideas to make the method parameter-free, near-linear space, and adaptive to a given data set. 6.1. Introduction 93 • Apply efficient sketches for estimating set similarity [83] that take advantage of modern hardware. We compare CPSJoin to the exact set similarity join algorithms in the comprehensive empirical evaluation of Mann et al. [86], using the same data sets, and to other approximate set similarity join methods sug- gested in the literature. The probabilistic approach scales much better on input instances where prefix filtering does not cut down the search space significantly. We see speedups of more than 1 order of magni- tude at 90% recall, especially for set similarity joins where the sets are relatively large (100 tokens or more) and the similarity threshold is low (e.g. Jaccard similarity 0.5). Related work 6.1.1 Exact similarity join. For space reasons we present just a sample of the most related previous work, and refer to the book of Augsten and Böhlen [16] for a survey of algorithms for exact similarity join in rela- tional databases, covering set similarity joins as well as joins based on string similarity. Early work on similarity join focused on the important special case of detecting near-duplicates with similarity close to 1, see e.g. [30, 104]. A sequence of results starting with the seminal paper of Bayardo et al. [19] studied the range of thresholds that could be handled. Recently, Mann et al. [86] conducted a comprehensive study of 7 state-of-the-art algorithms for exact set similarity join for Jaccard similarity threshold λ ∈ {0.5, 0.6, 0.7, 0.8, 0.9}. These algorithms all use the idea of prefix fil- tering [19], which generates a sequence of candidate pairs of sets that includes all pairs of similarity above the threshold. The methods differ in how much additional filtering is carried out. For example, [115] ap- plies additional length and suffix filters to prune the candidate pairs. The main finding by Mann et al. is that while advanced filtering techniques do yield speedups on some data sets, an optimized version of the basic prefix filtering method (referred to as "ALL") is always competitive, and often the fastest of the algorithms. For this reason we will be comparing our results against ALL. Locality-sensitive hashing. Locality-sensitive hashing (LSH) is a theoretically well-founded randomized method for creating candidate pairs [59]. Though some LSH methods guaranteeing 100% recall ex- ist [15, 94], LSH is usually associated with having less than 100% recall 94 Chapter 6. Set Similarity Join probability for each output pair. We know only of a few papers using LSH techniques to solve similarity join. Cohen et al. [47] used LSH tech- niques for set similarity join in a knowledge discovery context before the advent of prefix filtering. They sketch a way of choosing parame- ters suitable for a given data set, but we are not aware of existing im- plementations of this approach. Chakrabarti et al. [36] improved plain LSH with an adaptive similarity estimation technique, BayesLSH, that re- duces the cost of checking candidate pairs and typically improves upon an implementation of the basic prefix filtering method by 2 -- 20×. Our experiments include comparison to both methods [36, 47]. We refer to the recent survey paper [93] for an overview of theoretical developments, but point out that these developments have not matured sufficiently to yield practical improvements to similarity join methods. Locality-sensitive mappings. Several recent theoretical advances in high-dimensional indexing [13, 43, 44] have used an approach that can be seen as a generalization of LSH. We refer to this approach as locality- sensitive mappings (also known as locality-sensitive filters in certain set- tings). The idea is to construct a function F, mapping a set x into a set of machine words, such that: • If sim(x, y) ≥ λ then F(x) ∩ F(y) is nonempty with some fixed probability ϕ > 0. • If sim(x, y) < λ, then the expected intersection size E[F(x) ∩ F(y)] is "small". the exact meaning of "small" depends on the differ- Here ence λ − sim(x, y), but in a nutshell, if it is the case that almost all pairs have similarity significantly below λ then we can ex- pect F(x) ∩ F(y) = 0 for almost all pairs. Performing the similar- ity join amounts to identifying all candidate pairs x, y for which F(x) ∩ F(y) (cid:54)= ∅ (for example by creating an inverted index), and computing the similarity of each candidate pair. To our knowledge these indexing methods have not been tried out in practice, probably because they are rather complicated. An exception is the recent pa- per [44], which is relatively simple, and indeed our join algorithm is inspired by the index described in that paper. Distance estimation. Similar to BayesLSH [36] we make use of al- gorithms for similarity estimation, but in contrast to BayesLSH we use 6.2. Preliminaries 95 algorithms that make use of bit-level parallelism. This approach works when there exists a way of picking a random hash function h such that Pr[h(x) = h(y)] = sim(x, y) (6.1) for every choice of sets x and y. Broder et al. [32] presented such a hash function for Jaccard similarity, now known as MinHash or "minwise hashing", as discussed in Section 1.3.6. In the context of distance esti- mation, 1-bit minwise hashing of Li and König [83] maps t MinHash values to a compact sketch, using just t bits. Still, this is sufficient in- formation to be able to estimate the Jaccard similarity of two sets x and y just based on the Hamming distance of their sketches. (In fact, the approach of [83] is known to be close to optimal [99].) Like in [36] we will use distance estimation to perform an additional filtering of the set of candidate pairs, avoiding expensive exact similarity computations for candidate pairs of low similarity. Preliminaries 6.2 The CPSJoin algorithm solves the set similarity join problem with a probabilistic guarantee on recall, formalized in Definition 1.5. It returns a set L ⊆ S (cid:46)(cid:47)λ R in a way that for every (x, y) ∈ S (cid:46)(cid:47)λ R we are guar- anteed Pr[(x, y) ∈ L] ≥ ϕ. It is important to note that the probability is over the random choices made by the algorithm, and not over a ran- dom choice of (x, y). This means that the probability (x, y) ∈ S (cid:46)(cid:47)λ R is not reported in i independent repetitions of the algorithm is bounded by (1 − ϕ)i. A recall probability of, ϕ = 0.9 can be boosted to recall probability close to 1, e.g. 99.9% using t = 3 repetitions. Finally, note that recall probability ϕ implies that we expect recall at least ϕ, but the actual recall may be higher. Similarity measures 6.2.1 Our algorithm can be used with a broad range of similarity measures through randomized embeddings. This allows our algorithms to be used with, for example, Jaccard and cosine similarity thresholds. Embeddings map data from one space to another while approx- imately preserving distance information, with accuracy that can be tuned. In our case we are interested in embeddings that map data to sets 96 Chapter 6. Set Similarity Join of tokens. We can transform any so-called LSHable similarity measure sim, where we can choose h to make (6.1) hold, into a set similarity mea- sure by the following randomized embedding: For a parameter t pick hash functions h1, . . . , ht independently from a family satisfying (6.1). The embedding of x is the following set of size t: f (x) = {(i, hi(x)) i = 1, . . . , t} . It follows from (6.1) that the expected size of the intersection f (x) ∩ f (y) is t · sim(x, y). We can use a Chernoff bound to bound the number of functions necessary. (cid:35) (cid:34)(cid:12)(cid:12)(cid:12)(cid:12) f (x) ∩ f (y) t Pr (cid:114) (cid:12)(cid:12)(cid:12)(cid:12) ≥ − sim(x, y) 6 ln t t sim(x, y) ≤ 2t−sim(x,y) (See e.g. Equation 1.2). For our experiments with Jaccard similarity thresholds ≥ 0.5, we found that t = 64 gave sufficient precision for > 90% recall. In summary we can perform the similarity join R (cid:46)(cid:47)λ S for any LSHable similarity measure by creating two corresponding relations R(cid:48) = { f (x) x ∈ R} and S(cid:48) = { f (y) y ∈ S}, and computing R(cid:48) (cid:46)(cid:47)λ S(cid:48) with respect to the similarity measure BB( f (x), f (y)) = f (x) ∩ f (y)/t . (6.2) This measure is the special case of Braun-Blanquet similarity where the sets are known to have size t. Our implementation will take advantage of the set size t being fixed, though it is easy to extend to general Braun- Blanquet similarity. The class of LSHable similarity measures is large, as discussed It includes the Jaccard similarity, cosine similarity and other in [41]. commonly used similarity measures. If approximation errors are tol- erable, even edit distance can be embedded into Hamming space and handled by our algorithm [37, 116]. 6.2.2 Notation We are interested in sets S where an element, x ∈ S is a set with el- ements from some universe [d] = {1, 2, 3,· · · , d}. To avoid confusion we sometimes use "record" for x ∈ S and "token" for the elements of 6.3. Overview of approach 97 x. Throughout this chapter we will think of a record x both as a set of tokens from [d], as well as a vector from {0, 1}d, where: (cid:40) xi = 1 if i ∈ x 0 if i /∈ x It is clear that these representations are equivalent. The set {1, 4, 5} is equivalent to (1, 0, 0, 1, 1, 0,· · · , 0), {1, d} is equivalent to (1, 0,· · · , 0, 1), etc. 6.3 Overview of approach Our high-level approach is recursive and works as follows. To compute R (cid:46)(cid:47)λ S we consider each x ∈ R and either: 1. Compare x to each record in S (referred to as "brute forcing" x), or 2. create several subproblems Si (cid:46)(cid:47)λ Ri with x ∈ Ri ⊆ R, Si ⊆ S, and solve them recursively. The approach of [44] corresponds to choosing option 2 until reaching a certain level k of the recursion, where we finish the recursion by choos- ing option 1. This makes sense for certain worst-case data sets, but we propose an improved parameter-free method that is better at adapting to the given data distribution. In our method the decision on which op- tion to choose depends on the size of S and the average similarity of x to the records of S. We choose option 1 if S has size below some (con- stant) threshold, or if the average Braun-Blanquet similarity of x and ∑y∈S BB(x, y), is close to the threshold λ. In the former case it is S, 1 S cheap to finish the recursion. In the latter case many records y ∈ S will have BB(x, y) larger than or close to λ, so we do not expect to be able to produce output pairs with x in less than linear time in S. If none of the pruning conditions apply we choose option 2 and in- clude x in recursive sub problems as described below. But first we note that the decision of which option to use can be made efficiently for each x, since the average Braun-Blanquet similarity of pairs from R × S can be computed from token frequencies in time O(R + S). 98 Chapter 6. Set Similarity Join • Comparing x to each record of S. We speed up the computation by using distance estimation (in our case using 1-bit minwise hashing) to efficiently avoid exact computation of similarities BB(x, y) for y ∈ S where B(x, y) is significantly below λ. • Recursion. We would like to ensure that for each pair (x, y) ∈ R (cid:46)(cid:47)λ S the pair is computed in one of the recursive subproblems, i.e., that (x, y) ∈ Ri (cid:46)(cid:47)λ Si for some i. In particular, we want the expected number of subproblems containing (x, y) to be at least 1, i.e., E[{i (x, y) ∈ Ri (cid:46)(cid:47)λ Si}] ≥ 1. (6.3) Let R(cid:48) and S(cid:48) be the subsets of R and S that do not satisfy any of the pruning conditions. To achieve (6.3) for each pair (x, y) ∈ R (cid:46)(cid:47)λ S we recurse with probability 1/(λt), where t is the size of records in R and S, on the subproblem Ri (cid:46)(cid:47)λ Si with sets Ri = {x ∈ R(cid:48) i ∈ x} Si = {y ∈ S(cid:48) i ∈ y} for each i ∈ {1, . . . , d}. It is not hard to check that (6.3) is satis- fied for every pair (x, y) with BB(x, y) ≥ λ. Of course, expecting one subproblem to contain (x, y) does not directly imply a good probability that (x, y) is contained in at least one subproblem. But it turns out that we can use results from the theory of branching processes to show such a bound; details are provided in section 6.4. Chosen Path Set Similarity Join 6.4 The CPSJoin algorithm solves the (λ, ϕ)-set similarity join problem (Def- inition 1.5). To simplify the exposition we focus on a self-join version where given S we wish to report L ⊆ S (cid:46)(cid:47)λ S. Handling a general join S (cid:46)(cid:47)λ R follows the overview in section 6.3 and requires no new ideas: Essentially consider a self-join on S ∪ R but make sure to consider only pairs in S × R for output. We also make the simplifying assumption that all sets in S have a fixed size t -- as argued in section 6.2.1 the general case can be reduced to this one by embedding. The CPSJoin algorithm solves the (λ, ϕ)-set similarity join for ev- ery choice of λ ∈ (0, 1) and with a guarantee on ϕ that we will lower 6.4. Chosen Path Set Similarity Join 99 bound in the analysis. We provide theoretical guarantees on the ex- pected running time of CPSJoin as well as experimental results showing large speedups compared to existing state-of-the-art exact and approxi- mate similarity join techniques. In the experiments a single run of our algorithm typically only reports around one third of the similar points compared to the exact algorithms, but through independent repetitions we are able to obtain speedups in the range of 2 − 50× for many real data sets and parameter settings while keeping the recall above 90%. 6.4.1 Description The CPSJoin algorithm (see Algorithm 3 for pseudocode) works by re- cursively splitting the data set on elements of [d] that are selected ac- cording to a random process, forming a recursion tree with S at the root and subsets of S that are non-increasing in size as we get further down the tree. The randomized splitting has the property that the probability of a pair of points (x, y) being in a given node is increasing as a function of x ∩ y. Before each splitting step we run the recursive BruteForce subpro- cedure (see Algorithm 4 for pseudocode) that identifies subproblems that are best solved by brute force. It has two parts: 1. 2. If S is larger than limit the second part activates: If S is below some constant size, controlled by the parameter limit, we report S (cid:46)(cid:47)λ S exactly using a simple loop with O(S2) dis- tance computations (BruteForcePairs) and exit the recursion. In our experiments we have set limit to 250, with the precise choice seem- ingly not having a large effect as shown experimentally in Section 6.6.2. for every x ∈ S we check whether the expected number of comparisons that x is a part of is going to decrease after performing the splitting. If this is not the case, we immediately compare x against every point in S (BruteForcePoint), reporting close pairs, and proceed by removing x from S. The BruteForce procedure is then run again on the reduced set. The recursion exits if every point x ∈ S has a decreasing number of expected comparisons. This recursive procedure where we choose to handle some points by brute force crucially separates our algorithm from many other ap- proximate similarity join methods in the literature that typically are LSH-based [95, 47]. By efficiently being able to remove points at the "right" time, before they generate too many expensive comparisons fur- 100 Chapter 6. Set Similarity Join ther down the tree, we are able to beat the performance of other approx- imate similarity join techniques in both theory and practice. Another benefit of this rule is that it reduces the number of parameters com- pared to the usual LSH setting where the depth of the tree has to be selected by the user. Algorithm 3: CPSJoin(S, λ) 1 For j ∈ [d] initialize Sj ← ∅. 2 S ← BruteForce(S, λ) 3 r ← SeedHashFunction() 4 for x ∈ S do 5 6 6 7 for j ∈ x do if r(j) < 1 λx then Sj ← Sj ∪ {x} 7 for Sj (cid:54)= ∅ do CPSJoin(Sj, λ) Algorithm 4: BruteForce(S, λ) Global parameters: limit ≥ 1, ε ≥ 0. 1 Initialize empty map count[ ] with default value 0. 2 if S ≤ limit then 3 4 BruteForcePairs(S, λ) return ∅ 5 for x ∈ S do for j ∈ x do count[j] ← count[j] + 1 9 if 8 for x ∈ S do 1 S−1 BruteForcePoint(S, x, λ) return BruteForce(S \ {x}, λ) ∑j∈x(count[j]−1)/t > (1 − ε)λ then 10 11 12 return S Comparison to Chosen Path 6.4.2 The CPSJoin algorithm is inspired by the Chosen Path algorithm [44] for the approximate near neighbor problem and uses the same under- lying random splitting tree that we will refer to as the Chosen Path Tree. In the approximate near neighbor problem, the task is to construct a data structure that takes a query point and correctly reports an ap- proximate near neighbor, if such a point exists in the data set. Using 6.4. Chosen Path Set Similarity Join 101 the Chosen Path data structure directly to solve the (λ, ϕ)-set similar- ity join problem has several drawbacks that we avoid in the CPSJoin algorithm. First, the Chosen Path data structure is parameterized in a non-adaptive way to provide guarantees for worst-case data, vastly increasing the amount of work done compared to the optimal parame- terization when data is not worst-case. Our recursion rule avoids this and instead continuously adapts to the distribution of distances as we traverse down the tree. Second, the data structure uses space O(n1+ρ) where ρ > 0, storing the Chosen Path Tree of size O(nρ) for every data point. The CPSJoin algorithm, instead of storing the whole tree, essen- tially performs a depth-first traversal, allowing us to bound the space usage by O(n + m) where m is the output size. Finally, the Chosen Path data structure only has to report a single point that is approxi- mately similar to a query point, and can report points with similarity < λ. To solve the approximate similarity join problem the CPSJoin al- gorithm has to satisfy reporting guarantees for every pair of points (x, y) in the exact join. Analysis 6.4.3 The Chosen Path Tree for a data point x ⊆ [d] is defined by a random process: at each node, starting from the root, we sample a random hash function r : [d] → [0, 1] and construct children for every element j ∈ x such that r(j) < 1 . Nodes at depth k in the tree are identified by their λx path p = (j1, . . . , jk). Formally, the set of nodes at depth k > 0 in the Chosen Path Tree for x is given by (cid:26) (cid:27) xj λx Fk(x) = p ◦ j p ∈ Fk−1(x) ∧ rp(j) < (6.4) where p ◦ j denotes vector concatenation and F0(x) = {()} is the set containing only the empty vector. The subset of the data set S that survives to a node with path p = (j1, . . . , jk) is given by Sp = {x ∈ S xj1 = 1 ∧ · · · ∧ xjk = 1}. (6.5) The random process underlying the Chosen Path Tree belongs to the well studied class of Galton-Watson branching processes. Originally these where devised to answer questions about the growth and decline of family names in a model of population growth assuming i.i.d. off- spring for every member of the population across generations [111]. In 102 Chapter 6. Set Similarity Join order to make statements about the properties of the CPSJoin algorithm we study in turn the branching processes of the Chosen Path Tree asso- ciated with a point x, a pair of points (x, y), and a set of points S. Note that we use the same random hash functions for different points in S. Brute forcing. The BruteForce subprocedure described by Algorithm 4 takes two global parameters: limit ≥ 1 and ε ≥ 0. The parameter limit controls the minimum size of S before we discard the CPSJoin algorithm for a simple exact similarity join by brute force pairwise dis- tance computations. The second parameter, ε > 0, controls the sensi- tivity of the BruteForce step to the expected number of comparisons that a point x ∈ S will generate if allowed to continue in the branch- ing process. The larger ε the more aggressively we will resort to the brute force procedure. In practice we typically think of ε as a small con- stant, say ε = 0.05, but for some of our theoretical results we will need a sub-constant setting of ε ≈ 1/ log(n) to show certain running time guarantees. The BruteForce step removes a point x from the Chosen Path branching process, instead opting to compare it against every other point y ∈ S, if it satisfies the condition 1 S − 1 ∑ y∈S\{x} x ∩ y/t > (1 − ε)λ. (6.6) In the pseudocode of Algorithm 4 we let count denote a hash table that keeps track of the number of times each element j ∈ [d] appears in S. This allows us to evaluate the condition in equation (6.6) for an element x ∈ S in time O(x) by rewriting it as 1 S − 1 ∑ j∈x (count[j] − 1)/t > (1 − ε)λ. (6.7) We claim that this condition minimizes the expected number of com- parisons performed by the algorithm: Consider a node in the Chosen Path Tree associated with a set of points S while running the CPSJoin algorithm. For a point x ∈ S, we can either remove it from S immedi- ately at a cost of S − 1 comparisons, or we can choose to let continue in the branching process (possibly into several nodes) and remove it later. The expected number of comparisons if we let it continue k levels before removing it from every node that it is contained in, is given by (cid:19)k (cid:18) 1 λ x ∩ y t ∑ y∈S\{x} . (6.8) 6.4. Chosen Path Set Similarity Join 103 This expression is convex and increasing in the similarity x ∩ y/t be- tween x and other points y ∈ S, allowing us to state the following ob- servation: Observation 6.1 (Recursion). Let ε = 0 and consider a set S containing a point x ∈ S such that x satisfies the recursion condition in equation (6.6). Then the expected number of comparisons involving x if we continue branching exceeds S − 1 at every depth k ≥ 1. If x does not satisfy the condition, the opposite is observed. Tree depth. We proceed by bounding the maximal depth of the set of paths in the Chosen Path Tree that are explored by the CPSJoin algo- rithm. Having this information will allow us to bound the space usage of the algorithm and will also form part of the argument for the correct- ness guarantee. Assume that the parameter limit in the BruteForce step is set to some constant value, say limit = 10. Consider a point x ∈ S and let S(cid:48) = {y ∈ S x ∩ y/t ≤ (1 − ε)λ} be the subset of points in S that are not too similar to x. For every y ∈ S(cid:48) the expected number of vertices in the Chosen Path Tree at depth k that contain both x and y is upper bounded by (cid:19)k (cid:18) 1 λ E[Fk(x ∩ y)] = x ∩ y t ≤ (1 − ε)k ≤ e−εk. (6.9) Since S(cid:48) ≤ n we use Markov's inequality to show the following bound: Lemma 6.1. Let x, y ∈ S satisfy that x ∩ y/t ≤ (1− ε)λ then the probability that there exists a vertex at depth k in the Chosen Path Tree that contains x and y is at most e−εk. If x does not share any paths with points that have similarity that falls below the threshold for brute forcing, then the only points that remain are ones that will cause x to be brute forced. This observation leads to the following probabilistic bound on the tree depth: Lemma 6.2. With high probability the maximal depth of paths explored by the CPSJoin algorithm is O(log(n)/ε). 104 Chapter 6. Set Similarity Join Correctness. Let x and y be two sets of equal size t such that BB(x, y) = x ∩ y/t ≥ λ. We are interested in lower bounding the probability that there exists a path of length k in the Chosen Path Tree that has been chosen by both x and y, i.e. Pr [Fk(x ∩ y) (cid:54)= ∅]. Agresti [6] showed an upper bound on the probability that a branching process becomes extinct after at most k steps. We use it to show the following lower bound on the probability of a close pair of points colliding at depth k in the Chosen Path Tree. Lemma 6.3 (Agresti [6]). If sim(x, y) ≥ λ then for every k > 0 we have that Pr[Fk(x ∩ y) (cid:54)= ∅] ≥ 1 k+1. The bound on the depth of the Chosen Path Tree for x explored by the CPSJoin algorithm in Lemma 6.2 then implies a lower bound on ϕ. Lemma 6.4. Let 0 < λ < 1 be constant. Then for every set S of S = n points the CPSJoin algorithm solves the set similarity join problem with ϕ = Ω(ε/ log(n)). Remark 6.1. This analysis is very conservative: if either x or y is removed by the BruteForce step prior to reaching the maximum depth then it only increases the probability of collision. We note that similar guaran- tees can be obtained when using fast pseudorandom hash functions as shown in the paper introducing the Chosen Path algorithm [44]. Space usage. We can obtain a trivial bound on the space usage of the CPSJoin algorithm by combining Lemma 6.2 with the observation that every call to CPSJoin on the stack uses additional space at most O(n). The result is stated in terms of working space: the total space usage when not accounting for the space required to store the data set itself (our algorithms use references to data points and only reads the data when performing comparisons) as well as disregarding the space used to write down the list of results. Lemma 6.5. With high probability the working space of the CPSJoin algorithm is at most O(n log(n)/ε). Remark 6.2. We conjecture that the expected working space is O(n) due to the size of S being geometrically decreasing in expectation as we proceed down the Chosen Path Tree. 6.4. Chosen Path Set Similarity Join 105 Running time. We will bound the running time of a solution to the general set similarity self-join problem that uses several calls to the CP- SJoin algorithm in order to piece together a list of results L ⊆ S (cid:46)(cid:47)λ S. In most of the previous related work, inspired by Locality-Sensitive Hash- ing, the fine-grainedness of the randomized partition of space, here rep- resented by the Chosen Path Tree in the CPSJoin algorithm, has been controlled by a single global parameter k [59, 95]. In the Chosen Path setting this rule would imply that we run the splitting step without per- forming any brute force comparison until reaching depth k where we proceed by comparing x against every other point in nodes containing x, reporting close pairs. In recent work by Ahle et al. [7] it was shown how to obtain additional performance improvements by setting an indi- vidual depth kx for every x ∈ S. We refer to these stopping strategies as global and individual, respectively. Together with our recursion strat- egy, this gives rise to the following stopping criteria for when to compare a point x against everything else contained in a node: • Global: Fix a single depth k for every x ∈ S. • Individual: For every x ∈ S fix a depth kx. • Adaptive: Remove x when the expected number of comparisons is non-decreasing in the tree-depth. Let T denote the running time of our similarity join algorithm. We aim to show the following relation between the running time between the different stopping criteria when applied to the Chosen Path Tree: E[TAdaptive] ≤ E[TIndividual] ≤ E[TGlobal]. (6.10) First consider the global strategy. We set k to balance the contribution to the running time from the expected number of vertices containing a point, given by (1/λ)k, and the expected number of comparisons be- tween pairs of points at depth k, resulting in the following expected running time for the global strategy: min k O  . n(1/λ)k + ∑ x,y∈S x(cid:54)=y (sim(x, y)/λ)k 106 Chapter 6. Set Similarity Join The global strategy is a special case of the individual case, and it must therefore hold that E[TIndividual] ≤ E[TGlobal]. The expected running time for the individual strategy is upper bounded by: ∑ x∈S O (1/λ)kx + ∑ min kx  . (sim(x, y)/λ)kx y∈S\{x} We will now argue that the expected running time of the CPSJoin algo- rithm under the adaptive stopping criteria is no more than a constant factor greater than E[TIndividual] when we set the global parameters of the BruteForce subroutine as follows: limit = Θ(1), log(1/λ) ε = . log n Let x ∈ S and consider a path p where x is removed in from Sp by the BruteForce step. Let k(cid:48)x denote the depth of the node (length of p) at which x is removed. Compared to the individual strategy that removes x at depth kx we are in one of three cases, also displayed in Figure 6.1. 1. The point x is removed from path p at depth k(cid:48)x = kx. 2. The point x is removed from path p at depth k(cid:48)x < kx. 3. The point x is removed from path p at depth k(cid:48)x > kx. Figure 6.1: Path termination depth in the Chosen Path Tree The underlying random process behind the Chosen Path Tree is not affected by our choice of termination strategy. In the first case we there- fore have that the expected running time is upper bounded by the same (conservative) expression as the one used by the individual strategy. In the second case we remove x earlier than we would have under the in- dividual strategy. For every x ∈ S we have that kx ≤ 1/ε since for larger Case1Case2Case3kxk0xk0xk0x 6.5. Implementation 107 values of kx the expected number of nodes containing x exceeds n. We therefore have that kx − k(cid:48)x ≤ 1/ε. Let S(cid:48) denote the set of points in the node where x was removed by the BruteForce subprocedure. There are two rules that could have triggered the removal of x: Either S(cid:48) = O(1) or the condition in equation (6.6) was satisfied. In the first case, the ex- pected cost of following the individual strategy would have been Ω(1) simply from the 1/λ children containing x in the next step. This is no more than a constant factor smaller than the adaptive strategy. In the second case, when the condition in equation (6.6) is activated we have that the expected number of comparisons involving x resulting from S(cid:48) if we had continued under the individual strategy is at least (1 − ε)1/εS(cid:48) = Ω(S(cid:48)) which is no better than what we get with the adaptive strategy. In the third case where we terminate at depth k(cid:48)x > kx, if we retrace the path to depth kx we know that x was not removed in this node, implying that the expected number of comparisons when continuing the branching process on x is decreasing compared to removing x at depth kx. We have shown that the expected running time of the adaptive strategy is no greater than a constant times the expected running time of the individual strategy. We are now ready to state our main theoretical contribution, stated below as Theorem 6.1. The theorem combines the above argument that compares the adaptive strategy against the individual strategy together with Lemma 6.2 and Lemma 6.4, and uses O(log2 n) runs of the CPSJoin algorithm to solve the set similarity join problem for every choice of constant parameters λ, ϕ. Theorem 6.1. For every LSHable similarity measure and every choice of con- stant threshold λ ∈ (0, 1) and probability of recall ϕ ∈ (0, 1) we can solve the (λ, ϕ)-set similarity join problem on every set S of n points using working space O(n) and with expected running time  . (sim(x, y)/λ)kx + (1/λ)kx ∑ x∈S O min kx  ∑ y∈S\{x} Implementation 6.5 We implement an optimized version of the CPSJoin algorithm for solv- ing the Jaccard similarity self-join problem. In our experiments (de- 108 Chapter 6. Set Similarity Join scribed in Section 6.6) we compare the CPSJoin algorithm against the approximate methods of MinHash LSH [59, 32] and BayesLSH [36], as well as the AllPairs [19] exact similarity join algorithm. The code for our experiments is written in C++ and uses the benchmarking frame- work and data sets of the recent experimental survey on exact similarity join algorithms by Mann et al. [86]. For our implementation we assume that each set x is represented as a list of 32-bit unsigned integers. We proceed by describing the details of each implementation in turn. Chosen Path Similarity Join 6.5.1 The implementation of the CPSJoin algorithm follows the structure of the pseudocode in Algorithm 3 and Algorithm 4, but makes use of a few heuristics, primarily sampling and sketching, in order to speed things up. The parameter setting is discussed and investigated experimentally in section 6.6.2. Preprocessing. Before running the algorithm we use the embedding described in section 6.2.1. Specifically t independent MinHash func- tions h1, . . . , ht are used to map each set x ∈ S to a list of t hash values (h1(x), . . . , ht(x)). The MinHash function is implemented using Zobrist hashing [117] from 32 bits to 64 bits with 8-bit characters. We sample a MinHash function h by sampling a random Zobrist hash function g and let h(x) = argminj∈x g(j). Zobrist hashing (also known as simple tab- ulation hashing) has been shown theoretically to have strong MinHash properties and is very fast in practice [100, 108]. We set t = 128 in our experiments, see discussion later. During preprocessing we also prepare sketches using the 1-bit min- wise hashing scheme of Li and König [83]. Let (cid:96) denote the length in 64-bit words of a sketch x of a set x ∈ S. We construct sketches for a data set S by independently sampling 64 × (cid:96) MinHash functions hi and Zobrist hash functions gi that map from 32 bits to 1 bit. The ith bit of the sketch x is then given by gi(hi(x)). In the experiments we set (cid:96) = 8. Similarity estimation using sketches. We use 1-bit minwise hash- ing sketches for fast similarity estimation in the BruteForcePairs and BruteForcePoint subroutines of the BruteForce step of the CPSJoin x and y, we compute the number algorithm. Given two sketches, of bits in which they differ by going through the sketches word for word, computing the popcount of their XOR using the gcc builtin 6.5. Implementation 109 _mm_popcnt_u64 that translates into a single instruction on modern hardware. Let J(x, y) denote the estimated similarity of a pair of sets (x, y). If J(x, y) is below a threshold λ ≈ λ, we exclude the pair from further consideration. If the estimated similarity is greater than λ we compute the exact similarity and report the pair if J(x, y) ≥ λ. The speedup from using sketches comes at the cost of introducing false negatives: A pair of sets (x, y) with J(x, y) ≥ λ may have an estimated similarity less than λ, causing us to miss it. We let δ de- note a parameter for controlling the false negative probability of our sketches and set λ such that for sets (x, y) with J(x, y) ≥ λ we have that Pr[ J(x, y) < λ] < δ. In our experiments we set the sketch false negative probability to be δ = 0.05. Splitting step. The "splitting step" of the CPSJoin algorithm as de- scribed in Algorithm 3 where the set S is split into buckets Sj is im- plemented using the following heuristic: Instead of sampling a random hash function and evaluating it on each element j ∈ x, we sample an ex- pected 1/λ elements from [t] and split S according to the corresponding minhash values from the preprocessing step. This saves the linear over- head in the size of our sets t, reducing the time spent placing each set into buckets to O(1). Internally, a collection of sets S is represented as a C++ std::vector<uint32_t> of set ids. The collection of buckets Sj is implemented using Google's dense_hash hash map implementation from the sparse_hash package [61]. BruteForce step. Having reduced the overhead for each set x ∈ S to O(1) in the splitting step, we wish to do the same for the BruteForce step (described in Algorithm 4), at least in the case where we do not call the BruteForcePairs or BruteForcePoint subroutines. The main problem is that we spend time O(t) for each set when constructing the count hash map and estimating the average similarity of x to sets in S \ {x}. To get around this we construct a 1-bit minwise hashing sketch s of length 64 × (cid:96) for the set S using sampling and our precomputed 1-bit minwise hashing sketches. The sketch s is constructed as follows: Randomly sample 64 × (cid:96) elements of S and set the ith bit of s to be the ith bit of the ith sample from S. This allows us to estimate the av- erage similarity of a set x to sets in S in time O((cid:96)) using word-level parallelism. A set x is removed from S if its estimated average simi- larity is greater than (1 − ε)λ. To further speed up the running time we only call the BruteForce subroutine once for each call to CPSJoin, 110 Chapter 6. Set Similarity Join calling BruteForcePoint on all points that pass the check rather than recomputing s each time a point is removed. Pairs of sets that pass the sketching check are verified using the same verification procedure as the AllPairs implementation by Mann et al. [86]. In our experiments we set the parameter ε = 0.1. Duplicates are removed by sorting and performing a single linear scan. 6.5.2 MinHash LSH We implement a locality-sensitive hashing similarity join using MinHash according to the pseudocode in Algorithm 5. A single run of the Min- Hash algorithm can be divided into two steps: First we split the sets into buckets according to the hash values of k concatenated MinHash functions h(x) = (h1(x), . . . , hk(x)). Next we iterate over all non-empty buckets and run BruteForcePairs to report all pairs of points with simi- larity above the threshold λ. The BruteForcePairs subroutine is shared between the MinHash and CPSJoin implementation. MinHash there- fore uses 1-bit minwise sketches for similarity estimation in the same way as in the implementation of the CPSJoin algorithm described above. The parameter k can be set for each dataset and similarity threshold λ to minimize the combined cost of lookups and similarity estimations performed by algorithm. This approach was mentioned by Cohen et al. [47] but we were unable to find an existing implementation. In prac- tice we set k to the value that results in the minimum estimated running time when running the first part (splitting step) of the algorithm for val- ues of k in the range {2, 3, . . . , 10} and estimating the running time by looking at the number of buckets and their sizes. Once k is fixed we know that each repetition of the algorithm has probability at least λk of reporting a pair (x, y) with J(x, y) ≥ λ. For a desired recall ϕ we can therefore set L = (cid:100)ln(1/(1 − ϕ))/λk(cid:101). In our experiments we report the actual number of repetitions required to obtain a desired recall rather than using the setting of L required for worst-case guarantees. AllPairs 6.5.3 To compare our approximate methods against a state-of-the-art exact similarity join we use Bayardo et al.'s AllPairs algorithm [19] as re- cently implemented in the set similarity join study by Mann et al. [86]. The study by Mann et al. compares implementations of several differ- ent exact similarity join methods and finds that the simple AllPairs 6.5. Implementation 111 Algorithm 5: MinHash(S, λ) Parameters: k ≥ 1, L ≥ 1. 1 for i ← 1 to L do Initialize hash map buckets[ ]. Sample k MinHash fcts. h ← (h1, . . . , hk) for x ∈ S do buckets[h(x)] ← buckets[h(x)] ∪ {x} for S(cid:48) ∈ buckets do BruteForcePairs(S(cid:48), λ) 2 3 4 5 6 7 algorithm is most often the fastest choice. Furthermore, for Jaccard sim- ilarity, the AllPairs algorithm was at most 2.16 times slower than the best out of six different competing algorithm across all the data sets and similarity thresholds used, and for most runs AllPairs is at most 11% slower than the best exact algorithm (see Table 7 in Mann et al. [86]). Since our experiments run in the same framework and using the same datasets and with the same thresholds as Mann et al.'s study, we con- sider their AllPairs implementation to be a good representative of exact similarity join methods for Jaccard similarity. BayesLSH 6.5.4 For a comparison against previous experimental work on approximate similarity joins we use an implementation of BayesLSH in C as pro- vided by the BayesLSH authors [36, 35]. The BayesLSH package fea- tures a choice between AllPairs and LSH as candidate generation method. For the verification step there is a choice between BayesLSH and BayesLSH-lite. Both verification methods use sketching to estimate similarities between candidate pairs. The difference between BayesLSH and BayesLSH-lite is that the former uses sketching to estimate the sim- ilarity of pairs that pass the sketching check, whereas the latter uses an exact similarity computation if a pair passes the sketching check. Since the approximate methods in our CPSJoin and MinHash imple- mentations correspond to the approach of BayesLSH-lite we restrict our experiments to this choice of verification algorithm. In our experiments we will use BayesLSH to represent the fastest of the two candidate gen- eration methods, combined with BayesLSH-lite for the verification step. 112 Chapter 6. Set Similarity Join Dataset AOL BMS-POS DBLP ENRON FLICKR LIVEJ KOSARAK NETFLIX ORKUT SPOTIFY UNIFORM TOKENS10K TOKENS15K TOKENS20K # sets / 106 7.35 0.32 0.10 0.25 1.14 0.30 0.59 0.48 2.68 0.36 0.10 0.03 0.04 0.06 avg. set size 3.8 9.3 82.7 135.3 10.8 37.5 12.2 209.8 122.2 15.3 10.0 339.4 337.5 335.7 sets / tokens 18.9 1797.9 1204.4 29.8 16.3 15.0 176.3 5654.4 37.5 7.4 4783.7 10000.0 15000.0 20000.0 Experiments Table 6.1: Dataset size, average set size, and average number of sets that a token is contained in. 6.6 We run experiments using the implementations of CPSJoin, MinHash, BayesLSH, and AllPairs described in the previous section. In the ex- periments we perform self-joins under Jaccard similarity for similarity thresholds λ ∈ {0.5, 0.6, 0.7, 0.8, 0.9}. We are primarily interested in mea- suring the join time of the algorithms, but we also look at the number of candidate pairs (x, y) considered by the algorithms during the join as a measure of performance. Note that the preprocessing step of the approximate methods only has to be performed once for each set and similarity measure, and can be re-used for different similarity joins, we therefore do not count it towards our reported join times. In practice the preprocessing time is at most a few minutes for the largest data sets. Data sets. The performance is measured across 10 real world data sets along with 4 synthetic data sets described in Table 6.1. All datasets except for the TOKENS datasets were provided by the authors of [86] where descriptions and sources for each data set can also be found. Note that we have excluded a synthetic ZIPF dataset used in the study by Mann et al.[86] due to it having no results for our similarity thresh- olds of interest. Experiments are run on versions of the datasets where duplicate records are removed and any records containing only a single token are ignored. In addition to the datasets from the study of Mann et al. we add three synthetic datasets TOKENS10K, TOKENS15K, and TOKENS20K, 6.6. Experiments 113 designed to showcase the robustness of the approximate methods. These datasets have relatively few unique tokens, but each token appears in many sets. Each of the TOKENS datasets were generated from a uni- verse of 1000 tokens (d = 1000) and each token is contained in re- spectively, 10, 000, 15, 000, and 20, 000 different sets as denoted by the name. The sets in the TOKENS datasets were generated by sampling a random subset of the set of possible tokens, rejecting tokens that had already been used in more than the maximum number of sets (10, 000 for TOKENS10K). To sample sets with expected Jaccard similarity λ(cid:48) the size of our sampled sets should be set to (2λ(cid:48)/(1 + λ(cid:48)))d. For λ(cid:48) ∈ {0.95, 0.85, 0.75, 0.65, 0.55} the TOKENS datasets each have 100 ran- dom sets planted with expected Jaccard similarity λ(cid:48). This ensures an increasing number of results for our experiments where we use thresh- olds λ ∈ {0.5, 0.6, 0.7, 0.8, 0.9}. The remaining sets have expected Jaccard similarity 0.2. We believe that the TOKENS datasets give a good indi- cation of the performance on real-world data that has the property that most tokens appear in a large number of sets. Recall. In our experiments we aim for a recall of at least 90% for the In order to achieve this for the CPSJoin and approximate methods. MinHash algorithms we perform a number of repetitions after the pre- processing step, stopping when the desired recall has been achieved. This is done by measuring the recall against the recall of AllPairs and stopping when reaching 90%. In situations where the size of the true re- sult set is not known it can be efficiently estimated using sampling if it is not too small. Alternatively, the algorithms can be stopped once the rate of new results drops below some threshold, indicating that most results have been found. For BayesLSH using LSH as the candidate generation method, the recall probability with the default parameter setting is 95%, although we experience a recall closer to 90% in our experiments. Hardware. All experiments were run on an Intel Xeon E5-2690v4 CPU at 2.60GHz with 35MB L3,256kB L2 and 32kB L1 cache and 512GB of RAM. Since a single experiment is always confined to a single CPU core we ran several experiments in parallel [107] to better utilize our hardware. 114 Chapter 6. Set Similarity Join Threshold 0.5 Threshold 0.6 Threshold 0.7 Threshold 0.8 Threshold 0.9 Dataset AOL BMS-POS DBLP ENRON FLICKR KOSARAK LIVEJ NETFLIX ORKUT SPOTIFY TOKENS10K TOKENS15K TOKENS20K UNIFORM005 CP 362.1 27.0 9.2 6.9 48.6 377.9 131.3 25.3 26.5 2.5 3.4 4.4 5.7 3.9 MH 1329.9 40.0 22.1 16.4 68.0 311.1 279.4 121.8 115.7 9.3 4.8 6.2 12.0 6.6 ALL 483.5 62.5 127.9 78.0 17.2 73.1 571.7 1354.7 359.7 0.5 312.1 688.4 1264.1 54.1 CP MH ALL 117.8 20.9 63.8 23.2 6.0 14.4 145.3 520.4 106.4 0.3 236.8 535.3 927.0 27.6 444.2 13.7 10.1 9.9 37.2 89.2 129.6 60.0 60.1 3.4 3.9 7.1 11.4 3.0 113.4 7.1 2.5 4.4 30.9 62.7 48.7 8.2 15.4 1.5 2.9 4.0 4.0 1.6 CP MH ALL 13.7 42.2 2.7 5.6 1.1 27.4 2.4 6.0 2.5 13.8 1.6 7.2 28.2 30.6 4.8 177.3 8.0 36.3 0.2 1.0 1.5 164.0 1.8 390.4 2.1 698.4 0.9 10.5 152.9 5.6 3.7 6.3 21.3 16.1 52.9 22.6 25.1 2.6 1.7 3.7 4.5 1.4 CP MH ALL 4.2 34.6 1.3 2.0 0.6 7.8 1.6 1.6 1.0 6.3 0.5 3.9 7.1 16.2 2.4 46.2 7.4 12.2 0.1 1.0 0.6 114.9 0.7 258.2 0.8 494.3 0.5 3.6 100.6 3.9 1.8 2.7 11.3 9.9 41.0 14.1 19.7 1.9 1.2 1.7 2.2 1.0 CP MH ALL 1.6 21.0 0.2 0.9 0.3 0.8 0.4 0.7 0.3 3.4 0.1 1.2 1.5 9.2 1.6 5.4 3.7 4.8 0.1 0.5 0.2 63.2 0.2 140.0 0.3 273.4 0.1 0.4 43.8 1.4 0.7 1.7 5.2 2.6 12.6 5.8 13.3 0.6 0.4 0.7 0.8 0.3 Table 6.2: Join time in seconds for CPSJoin (CP), MinHash (MH) and AllPairs (ALL) with at least ≥ 90% recall. Results 6.6.1 Join time. Table 6.2 shows the average join time in seconds over five independent runs, when approximate methods are required to have at least 90% recall. We have omitted timings for BayesLSH since it was always slower than all other methods, and in most cases it timed out after 20 minutes when using LSH as candidate generation method. The join time for MinHash is always greater than the corresponding join time for CPSJoin except in a single setting: the dataset KOSARAK with threshold λ = 0.5. Since CPSJoin is typically 2 − 4× faster than Min- Hash we can restrict our attention to comparing AllPairs and CPSJoin where the picture becomes more interesting. Figure 6.2 shows the join time speedup that CPSJoin achieves over AllPairs. We achieve speedups of between 2 − 50× for most of the datasets, with greater speedups at low similarity thresholds. For a number of the datasets the CPSJoin algorithm is slower than AllPairs for the thresholds considered here. Looking at Table 6.1 it seems that CPSJoin generally performs well on most datasets where tokens are contained in a large number of sets on average (NETFLIX, UNIFORM, DBLP) and less well on datasets that have a lot of "rare" tokens (SPO- TIFY, LIVEJOURNAL, AOL), although the picture is not completely con- sistent as shown by the poor performance of CPSJoin on KOSARAK. 6.6. Experiments 115 BayesLSH. The poor performance of BayesLSH compared to the other algo- rithms (BayesLSH was always slower) can most likely be tracked down to differ- ences in the implementation of the candi- date generation methods of BayesLSH. The BayesLSH implementation uses an older implementation of AllPairs compared to the implementation by Mann et al. [86] which was shown to yield performance im- provements by using a more efficient verifi- cation procedure. The LSH candidate gen- eration method used by BayesLSH corre- sponds to the MinHash splitting step, but with k (the number of hash functions) fixed to one. Our technique for choosing k in the MinHash algorithm, aimed at mini- mizing the total join time, typically selects k ∈ {3, 4, 5, 6} in the experiments. It is therefore likely that BayesLSH can be com- petitive with the other techniques by com- bining it with other candidate generation procedures. Further experi- ments to compare the performance of BayesLSH sketching to 1-bit min- wise sketching for different parameter settings and similarity thresholds would also be instructive. Figure 6.2: Join time of CPSJoin with at least 90% recall. TOKEN datasets. The TOKENS datasets clearly favor the approximate join algorithms where CPSJoin is two to three orders of magnitude faster than AllPairs. By increasing the number of times each token appears in a set we can make the speedup of CPSJoin compared to All- Pairs arbitrarily large as shown by the progression from TOKENS10 to TOKENS20. The AllPairs algorithm generates candidates by searching through the lists of sets that contain a particular token, starting with rare tokens. Since every token appears in a large number of sets every list will be long. Interestingly, the speedup of CPSJoin is even greater for higher sim- ilarity thresholds. We believe that this is due to an increase in the gap between the similarity of sets to be reported and the remaining sets that have an average Jaccard similarity of 0.2. This is in line with our the- 0.50.60.70.80.90.11.010.0100.01000.0ThresholdSpeedup(x)llllllllllllllllllAOLBMS−POSDBLPENRONFLICKRKOSARAKLIVEJNETFLIXORKUTSPOTIFYTOKENS10KTOKENS15KTOKENS20KUNIFORM005 116 Chapter 6. Set Similarity Join oretical analysis of CPSJoin and most theoretical work on approximate similarity search where the running time guarantees usually depend on the approximation factor. Candidates and verification. Table 6.4 compares the number of pre- candidates, candidates, and results generated by the AllPairs and CP- SJoin algorithms where the desired recall for CPSJoin is set to be greater than 90%. For AllPairs the number of pre-candidates denotes all pairs (x, y) investigated by the algorithm that pass checks on their size so that it is possible that J(x, y) ≥ λ. The number of candidates is simply the number of unique pre-candidates as duplicate pairs are removed explic- itly by the AllPairs algorithm. For CPSJoin we define the number of pre-candidates to be all pairs (x, y) considered by the BruteForcePairs and BruteForcePoint sub- routines of Algorithm 4. The number of candidates are pre-candidate pairs that pass size checks (similar to AllPairs) and the 1-bit minwise sketching check as described in Section 6.5.1. Note that for CPSJoin the number of candidates may still contain duplicates as this is inherent to the approximate method for candidate generation. Removing du- plicates though the use of a hash table would drastically increase the space usage of CPSJoin. For both AllPairs and CPSJoin the number of candidates denotes the number of points that are passed to the exact similarity verification step of the AllPairs implementation of Mann et al. [86]. Table 6.4 shows that for AllPairs there is not a great difference be- tween the number of pre-candidates and number of candidates, while for CPSJoin the number of candidates is usually reduced by one or two orders of magnitude for datasets where CPSJoin performs well. For datasets where CPSJoin performs poorly such as AOL, FLICKR, and KOSARAK there is less of a decrease when going from pre-candidates to candidates. It would appear that this is due to many duplicate pairs from the candidate generation step and not a failure of the sketching technique. Parameters 6.6.2 In order to investigate how the parameter settings affect the performance of the CPSJoin algorithm we run experiments where we vary the brute force parameter limit, the brute force aggressiveness parameter ε, and 6.6. Experiments 117 (a) limit∈ {10,· · · , 500} (b) ε ∈ {.0, .1, .2, .3, .4, .5} (c) w ∈ {1, 2, 4, 8, 16} Figure 6.3: Relative join time for CPSJoin with at least 80% recall and similarity threshold λ = 0.5 for different parameter settings of limit, ε, and w. the sketch length in words (cid:96). Table 6.3 gives an overview of the different parameters and shows how they were set during the parameter exper- iments and the final setting used for our join time experiments. Figure 6.3 shows the CPSJoin join time for different settings of the parameters, relative to a certain parameter choice. We argue that the join times are relatively stable around our setting of parameters, leading us to believe that our technique of setting one parameter at a time is not too far away from the optimal setting, although changing one parameter probably changes the effect of other parameters to some extent. Figure 6.3 (a) shows the effect of varying the brute force limit on the join time. Lowering limit to 10 or 50 causes the join time to increase due to a combination of spending more time splitting sets into buckets and the lower probability of recall that comes when randomly splitting Parameter Description limit (cid:96) t ε δ Brute force limit Sketch word length Size of MinHash set Brute force aggressiveness Sketch false negative prob. Test Final 250 100 8 4 128 128 0.0 0.1 0.05 0.1 Table 6.3: Parameters of the CPSJoin algorithm, their setting during parameter experiments, and their setting for the final join time experi- ments 01234561050100250500BF limit (index=250)Join timellllllllllllAOLBMS−POSDBLPENRONFLICKRKOSARAKLIVEJNETFLIXORKUTSPOTIFYUNIFORM005012345670.00.10.20.30.40.5Epsilon (index=0.1)Join timellllllllllll01234124816Words in sketch (index=8)Join timellllllllll 118 Chapter 6. Set Similarity Join the data further during candidate generation. The join time is relatively stable for limit ∈ {100, 250, 500}. Figure 6.3 (b) shows the effect of varying the brute force aggressive- ness on the join time. As we increase ε, sets that are close to the other elements in their buckets are more likely to be removed by brute force comparing them to all other points. The tradeoff here is between the loss of probability of recall by letting a point continue in the Chosen Path branching process versus the cost of brute forcing the point. The join time is generally increasing as we increase ε due to the cost of perform- ing more brute force comparisons. Nevertheless, it turns out that ε = 0.1 is a slightly better setting than ε = 0.0 for almost all data sets. Figure 6.3 (c) shows the effect of varying the sketch length on the join time. There is a tradeoff between the sketch similarity estimation time and the precision of the estimate, leading to fewer false positives. For a similarity threshold of λ = 0.5 using only a single word negatively impacts the performance on most datasets compared to using two or more words. The cost of using longer sketches seems neglible as it is only a few extra instructions per similarity estimation so we opted to use (cid:96) = 8 words in our sketches. 6.7 Conclusion In this chapter we provide experimental and theoretical results on a new randomized set similarity join algorithm, CPSJoin. We compare CPSJoin experimentally to state-of-the-art exact and approximate set similarity join algorithms. CPSJoin is typically 2 − 4 times faster than previous approximate methods. Compared to exact methods it obtains speedups of more than an order of magnitude on real-world datasets, while keeping the recall above 90%. Among the datasets used in these experiments we note that NET- FLIX and FLICKR represents two archetypes. On average a token in the NETFLIX dataset appears in more than 5000 sets while on average a token in the FLICKR dataset appears in less than 20 sets. Our experi- ment indicate that CPSJoin brings large speedups to the NETFLIX type datasets, while it is hard to improve upon the perfomance of AllPairs on the FLICKR type. A direction for future work could be to tighten and simplify the theo- retical analysis to better explain the experimental results. We conjecture 6.7. Conclusion 119 Dataset AOL BMS-POS DBLP ENRON FLICKR KOSARAK LIVEJ NETFLIX ORKUT SPOTIFY TOKENS10K TOKENS15K TOKENS20K UNIFORM005 Threshold 0.5 ALL CP Threshold 0.7 ALL CP 8.5E+09 8.5E+09 1.3E+08 2.0E+09 1.8E+09 1.1E+07 6.6E+09 1.9E+09 1.7E+06 2.8E+09 1.8E+09 3.1E+06 5.7E+08 4.1E+08 6.6E+07 2.6E+09 2.5E+09 2.3E+08 9.0E+09 8.3E+09 2.4E+07 8.6E+10 1.3E+10 1.0E+06 5.1E+09 3.9E+09 9.0E+04 5.0E+06 4.8E+06 2.0E+04 1.5E+10 4.1E+08 1.3E+05 3.6E+10 9.6E+08 1.4E+05 6.4E+10 1.7E+09 1.4E+05 2.5E+09 2.0E+09 2.6E+05 7.4E+09 1.4E+09 1.2E+08 9.2E+08 1.7E+08 1.0E+07 4.6E+08 4.6E+07 1.6E+06 3.7E+08 6.7E+07 2.9E+06 2.1E+09 1.1E+09 6.1E+07 4.7E+09 2.1E+09 2.1E+08 2.8E+09 3.6E+08 2.2E+07 1.3E+09 3.1E+07 9.5E+05 1.1E+09 1.3E+06 8.4E+04 1.2E+08 3.1E+05 1.8E+04 1.7E+08 5.7E+06 1.3E+05 3.0E+08 7.2E+06 1.3E+05 4.4E+08 8.8E+06 1.4E+05 3.7E+08 9.5E+06 2.4E+05 6.2E+08 6.2E+08 1.6E+06 2.7E+08 2.6E+08 2.0E+05 1.2E+09 7.2E+08 9.1E+03 2.0E+08 1.3E+08 1.2E+06 9.3E+07 6.3E+07 2.5E+07 7.4E+07 6.8E+07 4.4E+05 5.8E+08 5.6E+08 8.1E+05 1.0E+10 3.4E+09 2.4E+04 3.0E+08 2.6E+08 5.6E+03 4.7E+05 4.6E+05 2.0E+02 8.1E+09 4.1E+08 7.4E+04 1.9E+10 9.6E+08 7.5E+04 3.4E+10 1.7E+09 7.9E+04 6.5E+08 6.1E+08 1.4E+03 2.9E+09 3.1E+07 1.5E+06 3.3E+08 4.9E+06 1.8E+05 1.3E+08 4.3E+05 8.5E+03 1.5E+08 2.1E+07 1.2E+06 9.0E+08 3.8E+08 2.3E+07 4.2E+08 2.1E+07 4.1E+05 1.2E+09 1.8E+07 7.6E+05 4.3E+08 6.4E+05 2.2E+04 7.2E+08 8.1E+04 5.3E+03 8.5E+07 2.7E+03 1.9E+02 4.9E+07 1.9E+06 6.9E+04 8.1E+07 1.9E+06 6.9E+04 1.0E+08 1.9E+06 7.4E+04 1.3E+08 3.9E+04 1.3E+03 Table 6.4: Number of pre-candidates, candidates and results for ALL and CP with at least 90% recall. 120 Chapter 6. Set Similarity Join that the running time of the algorithm can be bounded by a simpler function of the sum of similarities between pairs of points in S. We note that recursive methods such as ours lend themselves well to parallel and distributed implementations since most of the computation happens in independent, recursive calls. Further investigating this is an interesting possibility. Acknowledgement. The authors would like to thank Willi Mann for making the source code and data sets of the study [86] available, and Aniket Chakrabarti for information about the implementation of BayesLSH. Chapter 7 Summary and open problems In this chapter we revisit our results, but with a focus on future research directions and open problems. We refer to Section 1.2 for a general overview of the results. In Chapter 2 we presented a data structure for the approximate furthest neighbor problem (Definition 1.2). Our main contribution is the devel- opment of a new query procedure for the problem that eliminates the need for multiple r-far searches. We showed that for iteration-based data structures is not possible to store less than min{n, 2Ω(d)} − 1 points for c-AFN when c < √2. However when c = √2 we need just d + 1 points [60] (See also Appendix A.2). It would be interesting to under- stand better why √2 is a special threshold, and to extend the lower bound beyond iteration-based data structures. We show that the query- independent variation of our algorithm stores O( f (c)d) points for some function f (Section 2.2.2) However our algorithm only works with high probability, and we do not have a closed form for f . An interesting open problem is to close this gap to the lower bound. Open problem 7.1. Design a √2(1− )-AFN data structure for  ∈ (0, 1) using space O(d min{n, 2O(d2)}) with query time n1−Ω(1). In Chapter 3 we used the c-AFN result in combination with LSH tech- niques to solve to approximate annulus query problem (Definition 1.3). Our contribution here is the analysis of this combined data structure, achieving sub-linear query time. An interesting direction of future re- search is in further combination of our data structure with LSH based data structures. For example to improve the output sensitivity of near 122 Chapter 7. Summary and open problems neighbor search based on LSH. By replacing each hash bucket with an AFN data structure with suitable approximation factors, it is possible to control the number of times each point in S is reported. Recent work on distance-sensitive hashing suggest a larger framework extending to "anti-lsh" functions [17]. It would be interesting future work to place our results in that context. The distance sensitive membership query investigated in Chapter 4 has not been the subject of much prior research. In particular we have been unable to find any previous results without false negatives, so there are many unanswered questions. Our contributions are upper and lower bounds on the space usage for this problem in ({0, 1}d, H). Most press- ing we do not show much in regards to query time. Our method would use time O(n) to make a comparison to each of the stored signatures. This could possibly be improved by using additional similarity search methods that avoid false negatives (e.g. [94]), but that would come with increased false positives. In comparison a regular Bloom filter uses O(k) time independently of how many items are in the set. However, a solu- tion with constant time (or even polylog in n) could be used, say with ε = 1/n, to solve the c-approximate nearest neighbor problem. The best currently known data structures for this problem use nΩ(1/c) time [14]. Open problem 7.2. Design a distance sensitive approximate member- ship filter for ({0, 1}d, H) with query time O(n1/c) and space O(n1+1/c). The signature vector method we introduced does not really extend well to other spaces. This is another obvious area for future work. Open problem 7.3. Show non-trivial bounds for the (r, c, w)-DAMQ problem in (Rd, (cid:96)2). Note that embeddings a la Johnson and Lindenstrauss can not be used here as they would introduce false negatives. In Chapter 5 we look at nearest neighbor preserving embeddings. The benefit of using this setting as opposed to normal distance preserv- ing embeddings is that it is possible to embed into lower dimensional spaces. Our contribution is showing that this benefit can be achieved while using sparse matrices and giving an analysis of the FJLT transform in this setting. In the presented embedding, the embedding dimension- ality is independent of n, but relies instead on λX. Could the sparsity parameter f be a similarly disconnected from the size of the embedded 123 set? In the spanning tree construction used in the proof of Theorem 5.2 this seems to be achievable if we can show results using only distances between the covering balls, and not the actual points inside them. This would require a new way of bounding the probability that no point "leaves" a ball, independently of how many points are inside it. Cur- rently we get f = O(d−1 log2 n), but there are known (cid:96)2 embeddings with O() sparsity [75]. Achieving similar results for nearest neighbor preserving embeddings would allow for much faster embeddings. Open problem 7.4. Construct a nearest neighbor preserving embedding with k = O(−2 log λs log (2/)) and sparsity O(). Finally, in Chapter 6 we looked at the set similarity join problem (Defi- nition 1.6). We presented the CPSJoin algorithm, based on the Chosen Path Tree. Unlike previous LSH based methods we eliminate the setting of k as a parameter by presenting an automatically adapting algorithm. Our main theoretical contribution here is in analyzing the query time as well as giving probabilistic bounds for space and recall. Empirically our methods are very fast on all data sets, but they can still be beaten by exact methods on data sets well suited for prefix filtering. It would be interesting future work to develop approximate set similarity meth- ods that achieve high recall significantly faster than exact methods for all data sets. Another direction would be to attempt to improve our re- call guarantees, either through altering the algorithm or tightening the analysis. Appendix A Appendix Properties of Gaussians A.1 Lemma A.1. Let X ∼ N (0, x) and Y ∼ N (0, y). Then ∀t > 0: y ≥ x ⇒ Pr[X2 ≤ t] ≥ Pr[Y2 ≤ t] y ≤ x ⇒ Pr[X2 ≤ t] ≤ Pr[y2 ≤ t] (A.1) (A.2) (A.3) (A.4) (A.5) With equality exactly when x = y. Proof. Let y ≥ x: Pr[X2 ≤ t] = Pr[X ≤ √t] − Pr[X ≤ −√t] ≥ Pr[Y ≤ √t] − Pr[X ≤ −√t] ≥ Pr[Y ≤ √t] − Pr[Y ≤ −√t] = Pr[Y2 ≤ t] Similarly in the other direction when y ≤ x. We can generalize to sums of such variables: Lemma A.2. For any integer k ≥ 1. Let X = ∑k and Y = ∑k we have: i where Xi ∼ N (0, xi) i where Yi ∼ N (0, yi). Then if yi ≥ xi for all i ∈ {1,· · · , k} i=1 X2 i=1 Y2 Pr[Y ≤ t] ≤ Pr[X ≤ t]. Proof. We show a standard proof by induction. Define a new variable Sl = ∑k−l j . As a base case set l = 1: i + ∑k i=1 X2 j=k−l+1 Y2 Pr[S1 ≤ t] = Pr[Y2 k + k−1∑ i=1 X2 i ≤ t] ≤ Pr[S0 ≤ t]. 126 Appendix A. Appendix By fixing X2 all integers l > 0 up to l = k: i for 1 ≤ i ≤ k − 1 and using lemma. A.1. And generally for Pr[Sl ≤ t] = Pr[Sl−1 ≤ t] By fixing everything but the l'th variable and using lemma. A.1. We arrive at Pr[Y ≤ t] = Pr[Sk ≤ t] ≤ Pr[S0 ≤ t] = Pr[X ≤ t]. A.2 √2-AFN in d + 1 points x' o x q Figure A.1: Illustration of the construction in the plane. Theorem A.1. For c ≥ √2 there exists a data structure that computes the c-AFN of any set S ⊆ Rd by storing a size d + 1 subset of S. Proof. A proof outline is given in [60], we fill in a few details. Given a set S let B(o, r) be the minimum enclosing ball of S. Assume without loss of generality that r = 1. Let P = {x ∈ B(o, r)(cid:107)o − x(cid:107)2 = r}. Pick a set R of d + 1 points from P in a way that the convex hull of R contains o. One (expensive) way of doing this is to iterate through the points in P and remove all points that do not shrink the minimum enclosing ball of the remaining points on removal. The data structure stores R. Given any query point q, let t = (cid:107)o − q(cid:107)2. Let x ∈ S be the actual furthest neighbor. We see that (cid:107)x− q(cid:107)2 ≤ 1 + t. If o = q, any point in R is an exact furthest neighbor. Otherwise, consider the hyperplane passing through o and perpendicular to the line defined by q and o. Since o is inside the convex hull of R, R must contain at least one point, x(cid:48), on the (See Figure A.1). side of the hyperplane not containing q. Consider the triangle defined It is clear that (cid:107)x(cid:48) − q(cid:107)2 ≥ √t2 + 1. by x(cid:48), o and q. . This is minimized at 1/√2 when t = 1, so Hence (cid:107)x(cid:48)−q(cid:107)2 (cid:107)x−q(cid:107)2 ≥ (cid:107)x(cid:48) − q(cid:107)2 ≥ (cid:107)x−q(cid:107)2√2 √t2+1 1+t . List of Figures . . . . . . binary search. N2 and the hamming distance between them. 1.1 The strings "BE", "BC" and "ED" represented as points in . . . . . . . . . 1.2 A very short phonebook. . . . . . . . . . . . . . . . . . . . . . . 1.4 A voronoi diagram for n = 20 points in Rd=2 . . . . . . . . . . 1.3 Names in the phone book and how many we will see using a . . . . . . . . . . . . . . . . . . . . . . 1.5 A point set with its convex hull and minimum enclosing ball. 1.6 Distribution of ai · (x − q) for near and far x . . . . . . . . . . 1.7 Goldilocks finds the porridge that is not too cold, not too hot, . . . . . . . . . . . . . . . 1.8 The Annulus query around q returns x. . . . . . . . . . . . . . 1.9 The sets {B, E} and {E, D}. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10 Illustration of Markov and Chernoff type bounds. 1.12 Ideal vs. achievable LSH function. . . . . . . . . . . . . . . . . 1.11 A non-perfect partitioning of points in R2 . . . . . . . . . . . . but "just right". ©Award Publications ltd. 3 4 5 5 8 9 10 11 14 22 24 24 . . . . . . 2.1 Returning a (c)-AFN. . 26 . . . . . . . . . . . . . . . . . . . . . . 34 2.2 Choosing ϕc. . . . . . . . . . . . . . . . . . . . . . . . . 38 2.3 Experimental results for 10-dimensional uniform distribution 38 2.4 Experimental results for 10-dimensional normal distribution . 39 2.5 Experimental results for SISAP nasa database . . . . . . . . . 39 2.6 Experimental results for SISAP colors database . . . . . . . . . 2.7 Experimental results for MovieLens 20M database . . . . . . . 40 2.8 The tradeoff between (cid:96) and m on 10-dimensional normal vectors 40 3.1 Illustration of a bucket for {x1, x2, x3, x5} ⊂ S. (cid:96) = 3. . . . . . 4.1 DAMQ data-structure . . . . . . . . . . . . . . . . . . . . . . . 5.1 Bounds from lemma 5.2 and 5.3 . . . . . . . . . . . . . . . . . . 5.2 An illustration of the spanning tree construction used in the proof of Theorem 5.2. . . . . . . . . . . . . . . . . . . . . . . . . 47 55 83 86 6.1 Path termination depth in the Chosen Path Tree . . . . . . . . 106 Join time of CPSJoin with at least 90% recall. . . . . . . . . . . 115 6.2 6.3 Relative join time for CPSJoin with at least 80% recall and similarity threshold λ = 0.5 for different parameter settings of limit, ε, and w. . . . . . . . . . . . . . . . . . . . . . . . . . 117 A.1 Illustration of the construction in the plane. . . . . . . . . . . . 126 List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Set notation . . . . . . . . . . . 1.2 Frequently used symbols and their meaning. . . . . . . . . . . 1.3 Membership query answers and error types. 1.4 Distance functions and Similarity measures . . . . . . . . . . . 3 4 11 18 6.1 Dataset size, average set size, and average number of sets that 6.2 a token is contained in. . . . . . . . . . . . . . . . . . . . . . . . 112 Join time in seconds for CPSJoin (CP), MinHash (MH) and AllPairs (ALL) with at least ≥ 90% recall. 6.3 Parameters of the CPSJoin algorithm, their setting during pa- rameter experiments, and their setting for the final join time experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 . . . . . . . . . . . 114 . 6.4 Number of pre-candidates, candidates and results for ALL and CP with at least 90% recall. . . . . . . . . . . . . . . . . . . 119 Bibliography [1] S. Abbar, S. Amer-Yahia, P. Indyk, and S. Mahabadi. Real-time In Proceedings 22nd recommendation of diverse related articles. International Conference on World Wide Web (WWW), pages 1 -- 12, 2013. [2] A. Abboud and A. Rubinstein. Distributed PCP theorems for hard- ness of approximation in P. To appear: 58th IEEE Symposium on Foundations of Computer Science (FOCS), abs/1706.06407, 2017. [3] M. Abramowitz. Handbook of Mathematical Functions, With Formu- las, Graphs, and Mathematical Tables. Dover Publications, 1974. [4] D. Achlioptas. Database-friendly random projections: Johnson- Journal of Computer and System lindenstrauss with binary coins. Sciences, 66(4):671 -- 687, 2003. Special Issue on {PODS} 2001. [5] P. K. Agarwal, J. Matoušek, and S. Suri. Farthest neighbors, max- imum spanning trees and related problems in higher dimensions. Computational Geometry, 1(4):189 -- 201, 1992. [6] A. Agresti. Bounds on the extinction time distribution of a branch- ing process. Advances in Applied Probability, 6:322 -- 335, 1974. [7] [8] T. D. Ahle, M. Aumüller, and R. Pagh. Parameter-free locality sen- sitive hashing for spherical range reporting. In Proceedings of 28th Symposium on Discrete Algorithms (SODA), pages 239 -- 256, 2017. T. D. Ahle, R. Pagh, I. Razenshteyn, and F. Silvestri. On the com- plexity of maximum inner product search. In Proc. 8th 35th ACM Symposium on Principles of Database Systems (PODS), 2016. 130 Bibliography [9] N. Ailon and B. Chazelle. The fast johnson-lindenstrauss trans- form and approximate nearest neighbors. SIAM Journal on Com- puting, 39(1):302 -- 322, May 2009. [10] N. Alon and B. Klartag. Optimal compression of approximate inner products and dimension reduction. ArXiv e-prints, Oct. 2016. [11] A. Andoni. Nearest Neighbor Search: the Old, the New, and the Impos- sible. PhD thesis, MIT, 2009. [12] A. Andoni and P. Indyk. Near-Optimal Hashing Algorithms for Approximate Nearest Neighbor in High Dimensions. 2006 47th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 459 -- 468, 2006. [13] A. Andoni, T. Laarhoven, I. Razenshteyn, and E. Waingarten. Op- timal hashing-based time-space trade-offs for approximate near neighbors. In Proceedings of 28th Symposium on Discrete Algorithms (SODA), 2017. [14] A. Andoni and I. Razenshteyn. Optimal data-dependent hashing In Proceedings of the 47th ACM for approximate near neighbors. Symposium on Theory of Computing (STOC), pages 793 -- 801, 2015. [15] A. Arasu, V. Ganti, and R. Kaushik. Efficient exact set-similarity joins. In Proceedings of 32nd International Conference on Very Large Data Bases (VLDB), pages 918 -- 929. VLDB Endowment, 2006. [16] N. Augsten and M. H. Böhlen. Similarity joins in relational database systems. Synthesis Lectures on Data Management, 5(5):1 -- 124, 2013. [17] M. Aumüller, T. Christiani, R. Pagh, and F. Silvestri. Distance- sensitive hashing. ArXiv e-prints, Mar. 2017. [18] M. Badoiu and K. L. Clarkson. Optimal core-sets for balls. Com- putational Geometry, 40(1):14 -- 22, 2008. [19] R. J. Bayardo, Y. Ma, and R. Srikant. Scaling up all pairs similarity search. In Proceedings of 16th World Wide Web Conference (WWW), pages 131 -- 140, 2007. [20] J. L. Bentley. Multidimensional binary search trees used for asso- ciative searching. Communications of the ACM, 18(9):509 -- 517, 1975. Bibliography 131 [21] J. L. Bentley. Divide and conquer algorithms for closest point problems in multidimensional space. PhD thesis, University of North Carolina, 1976. [22] M. de Berg, O. Cheong, M. van Kreveld, and M. Overmars. Com- putational Geometry: Algorithms and Applications. Springer, 3rd ed. edition, 2008. [23] A. C. Berry. The accuracy of the Gaussian approximation to the sum of independent variates. Transactions of the American Mathe- matical Society, 49(1):122 -- 136, 1941. [24] S. N. Bespamyatnikh. Dynamic algorithms for approximate neigh- bor searching. In Proceedings of the 8th Canadian Conference on Com- putational Geometry (CCCG), pages 252 -- 257, Carleton University, Aug. 12 -- 15 1996. [25] B. H. Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422 -- 426, jul 1970. [26] B. Bollobás. Combinatorics: Set Systems, Hypergraphs, Families of Vectors, and Combinatorial Probability. Cambridge University Press, New York, NY, USA, 1986. [27] K. Böröczky, Jr. and G. Wintsche. Covering the sphere by equal spherical balls. In Discrete and Computational Geometry, volume 25 of Algorithms and Combinatorics, pages 235 -- 251. Springer, 2003. [28] A. Broder. On the resemblance and containment of documents. In Proceedings of the Compression and Complexity of Sequences 1997, SEQUENCES '97, pages 21 -- . IEEE Computer Society, 1997. [29] A. Broder and M. Mitzenmacher. Network applications of Bloom filters: a survey. Internet mathematics, 1(4):485 -- 509, 2004. [30] A. Z. Broder. Identifying and filtering near-duplicate docu- ments. In Proceedings of Symposium on Combinatorial Pattern Match- ing (CPM), pages 1 -- 10. Springer, 2000. [31] A. Z. Broder, M. Charikar, A. M. Frieze, and M. Mitzenmacher. Min-wise independent permutations. Journal of Computer and Sys- tem Sciences, 60(3):630 -- 659, June 2000. 132 Bibliography [32] A. Z. Broder, S. C. Glassman, M. S. Manasse, and G. Zweig. Syn- tactic clustering of the web. Computer Networks, 29(8-13):1157 -- 1166, 1997. [33] J. Carter and M. N. Wegman. Universal classes of hash functions. Journal of Computer and System Sciences, 18(2):143 -- 154, 1979. [34] L. Carter, R. Floyd, J. Gill, G. Markowsky, and M. Wegman. Exact and Approximate Membership Testers. Proceedings of the 10th ACM Symposium on Theory of Computing (STOC), pages 59 -- 65, 1978. [35] A. Chakrabarti, V. Satuluri, A. Srivathsan, and S. Parthasarathy. Bayesian locality sensitive hashing for fast similarity search, au- thor c implementation. https://sites.google.com/site/ lshallpairs/, 2012. [Online; accessed 15-May-2017]. [36] A. Chakrabarti, V. Satuluri, A. Srivathsan, and S. Parthasarathy. A bayesian perspective on locality sensitive hashing with extensions for kernel methods. ACM Transactions on Knowledge Discovery from Data (TKDD), 10(2):19, 2015. [37] D. Chakraborty, E. Goldenberg, and M. Kouck`y. Streaming al- gorithms for embedding and computing edit distance in the low distance regime. In Proceedings of 48th Symposium on Theory of Com- puting (STOC), pages 712 -- 725, 2016. [38] M. Charikar, K. C. Chen, and M. Farach-Colton. Finding frequent items in data streams. Theoretical Computer Science, 312(1):3 -- 15, 2004. [39] S. Chaudhuri, V. Ganti, and R. Kaushik. A primitive operator for similarity joins in data cleaning. In Proceedings of 22nd Conference on Data Engineering (ICDE), page 5, 2006. [40] E. Chávez and G. Navarro. Measuring the dimensionality of gen- eral metric spaces. Technical Report TR/DCC-00-1, Department of Computer Science, University of Chile, 2000. [41] F. Chierichetti and R. Kumar. LSH-preserving functions and their applications. Journal of the ACM, 62(5):33, 2015. [42] S. Choi, S. Cha, and C. C. Tappert. A survey of binary similarity and distance measures. J. Syst. Cybern. Informatics, 8(1):43 -- 48, 2010. Bibliography 133 [43] T. Christiani. A framework for similarity search with space-time In Proceedings of 28th tradeoffs using locality-sensitive filtering. Symposium on Discrete Algorithms (SODA), pages 31 -- 46. SIAM, 2017. [44] T. Christiani and R. Pagh. Set similarity search beyond minhash. In Proceedings of 49th Symposium on Theory of Computing (STOC), 2017. [45] K. L. Clarkson. A Randomized Algorithm for Closest-Point Queries. SIAM Journal on Computing, 4(17):830 -- 847, 1988. [46] K. L. Clarkson. Las Vegas algorithms for linear and integer pro- Journal of the ACM, gramming when the dimension is small. 42(2):488 -- 499, 1995. [47] E. Cohen, M. Datar, S. Fujiwara, A. Gionis, P. Indyk, R. Motwani, J. D. Ullman, and C. Yang. Finding interesting associations with- out support pruning. IEEE Transactions on Knowledge and Data En- gineering, 13(1):64 -- 78, 2001. [48] J. Cook. Upper and lower bounds for the normal distribution. Unpublished, http://www.johndcook.com/normalbounds.pdf, 2009. [49] A. Dasgupta, R. Kumar, and T. Sarlos. A sparse johnson: Linden- strauss transform. In Proceedings of the 42nd ACM Symposium on Theory of Computing (STOC), pages 341 -- 350, New York, NY, USA, 2010. ACM. [50] S. Dasgupta and A. Gupta. An Elementary Proof of a Theorem of Johnson and Lindenstrauss. Random Structures and Algorithms, 22(1):60 -- 65, 2003. [51] M. Datar, N. Immorlica, P. Indyk, and V. S. Mirrokni. Locality- sensitive hashing scheme based on p-stable distributions. In Pro- ceedings 20 Annual Symposium on Computational Geometry (SoCG), pages 253 -- 262, 2004. [52] D. Dubhashi and A. Panconesi. Concentration of Measure for the Analysis of Randomized Algorithms. Cambridge University Press, 2009. 134 Bibliography [53] D. Eppstein. Dynamic euclidean minimum spanning trees and extrema of binary functions. Discrete & Computational Geometry, 13:111 -- 122, 1995. [54] W. E. Feller. An Introduction to Probability Theory and its Applications. Wiley, 1968. [55] K. Figueroa, G. Navarro, and E. Chávez. Metric spaces library, 2007. Online. [56] B. J. Fino and V. R. Algazi. Unified matrix treatment of the fast IEEE Trans. Comput., 25(11):1142 -- walsh-hadamard transform. 1146, Nov. 1976. [57] P. Frankl and H. Maehara. The johnson-lindenstrauss lemma and the sphericity of some graphs. Journal of Combinatorial Theory, Series B, 44(3):355 -- 362, 1988. [58] J. H. Friedman, J. L. Bentley, R. A. Finkel, J. H. Freidman, J. L. Bentley, and R. A. Finkel. An Algorithm for Finding Best Matches in Logarithmic Expected Time. ACM Transactions on Mathematical Software, 1549(July):209 -- 226, 1976. [59] A. Gionis, P. Indyk, and R. Motwani. Similarity search in high dimensions via hashing. In Proceedings of 25th Conference on Very Large Data Bases (VLDB), pages 518 -- 529, 1999. [60] A. Goel, P. Indyk, and K. Varadarajan. Reductions among high dimensional proximity problems. In Proceedings 12th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 769 -- 778, 2001. [61] Google. sparse hash c++ implementation. https://github. com/sparsehash/sparsehash, 2017. [Online; accessed 1-May- 2017]. [62] M. Goswami, R. Pagh, F. Silvestri, and J. Sivertsen. Distance sen- In Proceedings of the sitive bloom filters without false negatives. 28th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 257 -- 269. SIAM, 2017. [63] R. L. Graham and N. J. A. Sloane. Lower bounds for constant weight codes. IEEE Transaction on Information Theory, 1980. Bibliography 135 [64] U. Haagerup. The best constants in the khintchine inequality. Stu- dia Mathematica, 70(3):231 -- 283, 1981. [65] S. Har-Peled, P. Indyk, and R. Motwani. Approximate nearest neighbors: towards removing the curse of dimensionality. Theory of Computing, 8(1):321 -- 350, 2012. [66] F. M. Harper and J. A. Konstan. The MovieLens datasets: History and context. ACM Transactions on Interactive Intelligent Systems, 5(4):19, Dec. 2015. [67] D. Hoey and M. I. Shamos. Closest-point problems. 2013 IEEE 54th Annual Symposium on Foundations of Computer Science, 00:151 -- 162, 1975. [68] B. Hua, Yu abd Xiao, B. Veeravalli, and D. Feng. Locality-sensitive Bloom filter for approximate membership query. IEEE Transactions on Computers, 61(6):817 -- 830, 2012. [69] P. Indyk. Algorithmic applications of low-distortion geometric embedding. In Poceedings of the 42nd Annual Symposium on Foun- dations of Computer Science (FOCS), pages 10 -- 33, 2001. [70] P. Indyk. Better algorithms for high-dimensional proximity prob- lems via asymmetric embeddings. In Proceedings of the 14th ACM- SIAM Symposium on Discrete Algorithms (SODA), pages 539 -- 545, 2003. [71] P. Indyk, S. Mahabadi, M. Mahdian, and V. S. Mirrokni. Compos- able core-sets for diversity and coverage maximization. In Proceed- ings 33rd ACM Symposium on Principles of Database Systems (PODS), pages 100 -- 108. ACM, 2014. [72] P. Indyk and R. Motwani. Approximate nearest neighbors: To- wards removing the curse of dimensionality. Proceedings of the 30th ACM Symposium on Theory of Computing (STOC), 8:321 -- 350, 1998. [73] P. Indyk and A. Naor. Nearest-neighbor-preserving embeddings. ACM Trans. Algorithms, 3(3):Art. 31, 12, 2007. [74] W. B. Johnson and J. Lindenstrauss. Extensions of Lipschitz map- pings into a Hilbert space. Contemporary mathematics, 26(January 1984):189 -- 206, 1984. 136 Bibliography [75] D. M. Kane and J. Nelson. Sparser johnson-lindenstrauss trans- forms. Journal of the ACM, 61(1):4:1 -- 4:23, 2014. [76] D. Karger, R. Motwani, and M. Sudan. Approximate graph color- ing by semidefinite programming. Journal of the ACM, 45(2):246 -- 265, 1998. [77] A. Kirsch and M. Mitzenmacher. Distance-sensitive Bloom filters. Proceedings of the 8th Workshop on Algorithm Engineering and Exper- iments (ALENEX), pages 41 -- 50, 2006. [78] D. E. Knuth. Big omicron and big omega and big theta. SIGACT News, 8(2):18 -- 24, Apr. 1976. [79] P. Kumar, J. S. Mitchell, and E. A. Yildirim. Approximate mini- mum enclosing balls in high dimensions using core-sets. Journal of Experimental Algorithmics, 8:1 -- 1, 2003. [80] E. Kushilevitz and N. Nisan. Communication complexity. Cam- bridge University Press, 1997. [81] K. G. Larsen and J. Nelson. The johnson-lindenstrauss lemma is optimal for linear dimensionality reduction. In Proceedings of the 43rd International Colloquium on Automata, Languages, and Program- ming, ICALP, pages 82:1 -- 82:11, 2016. [82] K. G. Larsen and J. Nelson. the johnson- lindenstrauss lemma. To appear: 58th IEEE Symposium on Foun- dations of Computer Science (FOCS), abs/1609.02094, 2017. Optimality of [83] P. Li and A. C. König. Theory and applications of b-bit minwise hashing. Communications of the ACM, 54(8):101 -- 109, 2011. [84] X. Li, C.-P. Chen, et al. Inequalities for the gamma function. J. Inequal. Pure Appl. Math, 8(1), 2007. [85] D. J. C. MacKay. Information Theory, Inference & Learning Algorithms. Cambridge University Press, 2002. [86] W. Mann, N. Augsten, and P. Bouros. An empirical evaluation of set similarity join techniques. Proceedings of the VLDB Endowment, 9(9):636 -- 647, 2016. Bibliography 137 [87] [88] J. Matoušek. On variants of the Johnson-Lindenstrauss lemma. Random Structures and Algorithms, 33(2):142 -- 156, 2008. J. Matoušek, M. Sharir, and E. Welzl. A subexponential bound for linear programming. Algorithmica, 16(4-5):498 -- 516, 1996. [89] M. Mitzenmacher and E. Upfal. Probability and computing: Ran- domized algorithms and probabilistic analysis. Cambridge University Press, 2005. [90] R. Motwani and P. Raghavan. Randomized algorithms. Chapman & Hall/CRC, 2010. [91] F. L. Nazarov and A. N. Podkorytov. Ball, Haagerup, and Distribu- tion Functions, pages 247 -- 267. Birkhäuser Basel, Basel, 2000. [92] R. O'Donnell, Y. Wu, and Y. Zhou. Optimal lower bounds for lo- cality sensitive hashing (except when q is tiny). ACM Transactions on Computation Theory, 2014. [93] R. Pagh. Large-scale similarity joins with guarantees (invited talk). In LIPIcs-Leibniz International Proceedings in Informatics, volume 31. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 2015. [94] R. Pagh. Locality-sensitive hashing without false negatives. In Proceedings of 27th Symposium on Discrete Algorithms (SODA), pages 1 -- 9. SIAM, 2016. [95] R. Pagh, N. Pham, F. Silvestri, and M. Stöckel. I/O-efficient simi- larity join. In Proceedings of 23rd European Symposium on Algorithms (ESA), pages 941 -- 952, 2015. [96] R. Pagh and F. F. Rodler. Lossy dictionaries. In Proceedings of the 9th European Symposium on Algorithms (ESA), pages 300 -- 311, 2001. [97] R. Pagh, F. Silvestri, J. Sivertsen, and M. Skala. Approximate fur- thest neighbor in high dimensions. In Proceedings of the 8th Interna- tional Conference on Similarity Search and Applications (SISAP), pages 3 -- 14. Springer, 2015. [98] R. Pagh, F. Silvestri, J. Sivertsen, and M. Skala. Approximate fur- thest neighbor with application to annulus query. Information Sys- tems, 64:152 -- 162, 2017. 138 Bibliography Is min-wise hashing [99] R. Pagh, M. Stöckel, and D. P. Woodruff. In Proceedings of the optimal for summarizing set intersection? 33rd Symposium on Principles of Database Systems (PODS), pages 109 -- 120. ACM, 2014. [100] M. Patra¸scu and M. Thorup. The power of simple tabulation hash- ing. Journal of the ACM, 59(3):14:1 -- 14:50, June 2012. [101] W. Rudin. Real and complex analysis. McGraw-Hill Book Company, 1987. [102] A. Said, B. Fields, B. J. Jain, and S. Albayrak. User-centric evalu- ation of a k-furthest neighbor collaborative filtering recommender algorithm. In Proceedings Conference on Computer Supported Cooper- ative Work (CSCW), pages 1399 -- 1408, 2013. [103] A. Said, B. Kille, B. J. Jain, and S. Albayrak. Increasing diversity through furthest neighbor-based recommendation. Proceedings of the WSDM Workshop on Diversity in Document Retrieval, 12, 2012. [104] S. Sarawagi and A. Kirpal. Efficient set joins on similarity pred- icates. In Proceedings of SIGMOD International Conference on Man- agement of Data, pages 743 -- 754. ACM, 2004. [105] M. I. Shamos. Computational Geometry, Ph.D. Dissertation. PhD thesis, Yale University, 1978. [106] M. A. Skala. Aspects of Metric Spaces in Computation. PhD thesis, University of Waterloo, 2008. [107] O. Tange. Gnu parallel - the command-line power tool. ;login: The USENIX Magazine, 36(1):42 -- 47, Feb 2011. [108] M. Thorup. Fast and Powerful Hashing using Tabulation. ArXiv e-prints, May 2015. [109] I. S. Tyurin. On the absolute constants in the Berry-Esseen in- equality and its structural and nonuniform improvements. Inform. Primen., 7:124 -- 125, 2013. [110] S. S. Vempala. The Random Projection Method, volume 65 of DI- MACS Series in Discrete Mathematics and Theoretical Computer Sci- ence. American Mathematical Society, 2004. Bibliography 139 [111] H. W. Watson and F. Galton. On the probability of the extinction of families. The Journal of the Anthropological Institute of Great Britain and Ireland, 4:138 -- 144, 1875. [112] M. N. Wegman and L. Carter. New classes and applications of In Proceedings of the 20th Annual Symposium on hash functions. Foundations of Computer Science (FOCS), pages 175 -- 182. IEEE Com- puter Society, 1979. [113] R. Williams. A new algorithm for optimal constraint satisfaction In Proceedings of the 31st International Col- and its implications. loquium on Automata, Languages and Programming (ICALP), pages 1227 -- 1237, 2004. [114] R. Williams. Better time-space lower bounds for SAT and related problems. In 20th Annual IEEE Conference on Computational Com- plexity (CCC), 11-15 June 2005, San Jose, CA, USA, pages 40 -- 49. IEEE Computer Society, 2005. [115] C. Xiao, W. Wang, X. Lin, J. X. Yu, and G. Wang. Efficient similarity joins for near-duplicate detection. ACM Transactions on Database Systems (TODS), 36(3):15, 2011. [116] H. Zhang and Q. Zhang. EmbedJoin: Efficient Edit Similarity Joins via Embeddings. ArXiv e-prints, Jan. 2017. [117] A. L. Zobrist. A new hashing method with application for game playing. ICCA journal, 13(2):69 -- 73, 1970. [118] V. M. Zolotarev. One-dimensional Stable Distributions, volume 65. translations of mathematical American Mathematical Society, monographs edition, 1986.
1604.06002
2
1604
2016-04-21T14:31:16
Practical combinations of repetition-aware data structures
[ "cs.DS" ]
Highly-repetitive collections of strings are increasingly being amassed by genome sequencing and genetic variation experiments, as well as by storing all versions of human-generated files, like webpages and source code. Existing indexes for locating all the exact occurrences of a pattern in a highly-repetitive string take advantage of a single measure of repetition. However, multiple, distinct measures of repetition all grow sublinearly in the length of a highly-repetitive string. In this paper we explore the practical advantages of combining data structures whose size depends on distinct measures of repetition. The main ingredient of our structures is the run-length encoded BWT (RLBWT), which takes space proportional to the number of runs in the Burrows-Wheeler transform of a string. We describe a range of practical variants that combine RLBWT with the set of boundaries of the Lempel-Ziv 77 factors of a string, which take space proportional to the number of factors. Such variants use, respectively, the RLBWT of a string and the RLBWT of its reverse, or just one RLBWT inside a bidirectional index, or just one RLBWT with support for unidirectional extraction. We also study the practical advantages of combining RLBWT with the compact directed acyclic word graph of a string, a data structure that takes space proportional to the number of one-character extensions of maximal repeats. Our approaches are easy to implement, and provide competitive tradeoffs on significant datasets.
cs.DS
cs
Practical combinations of repetition-aware data structures∗ Djamal Belazzougui1, Fabio Cunial2, Travis Gagie3,4, Nicola Prezza5, and Mathieu Raffinot6 1 CERIST, Algeria. 2 Max Planck Institute of Molecular Cell Biology and Genetics, Dresden, Germany. 3 Department of Computer Science, University of Helsinki, Finland. 4 Helsinki Institute for Information Technology, Finland. 5 Department of Mathematics and Computer Science, University of Udine, Italy. 6 Laboratoire Bordelais de Recherche en Informatique, CNRS, Bordeaux, France. Abstract Highly-repetitive collections of strings are increasingly being amassed by genome sequencing and genetic variation experiments, as well as by storing all versions of human-generated files, like webpages and source code. Existing indexes for locating all the exact occurrences of a pattern in a highly-repetitive string take advantage of a single measure of repetition. However, multiple, distinct measures of repetition all grow sublinearly in the length of a highly-repetitive string. In this paper we explore the practical advantages of combining data structures whose size depends on distinct measures of repetition. The main ingredient of our structures is the run-length encoded BWT (RLBWT), which takes space proportional to the number of runs in the Burrows-Wheeler transform of a string. We describe a range of practical variants that combine RLBWT with the set of boundaries of the Lempel-Ziv 77 factors of a string, which take space proportional to the number of factors. Such variants use, respectively, the RLBWT of a string and the RLBWT of its reverse, or just one RLBWT inside a bidirectional index, or just one RLBWT with support for unidirectional extraction. We also study the practical advantages of combining RLBWT with the compact directed acyclic word graph of a string, a data structure that takes space proportional to the number of one-character extensions of maximal repeats. Our approaches are easy to implement, and provide competitive tradeoffs on significant datasets. 1998 ACM Subject Classification E.1 Data structures, F.2.2 Pattern matching. Keywords and phrases repetitive strings, locate, count, run-length encoded BWT, Lempel-Ziv factorization, CDAWG. Digital Object Identifier 10.4230/LIPIcs.CVIT.2016.23 1 Introduction Locating all the exact occurrences of a string in a massive, highly-repetitive collection of similar texts is a fundamental primitive in the post-genome era, in which genomes from multiple related species, from multiple strains of the same species, and from multiple individuals, are being sequenced at an increasing pace. Most data structures designed for ∗ This work was partially supported by Academy of Finland under grant 284598 (Center of Excellence in Cancer Genetics Research). © D. Belazzougui et al.; 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:18 Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 23:2 Practical combinations of repetition-aware data structures such repetitive collections take space proportional to a specific measure of repetition, for example the number z of factors in a Lempel-Ziv parsing [1, 18], or the number r of runs in a Burrows-Wheeler transform [21]. In previous work we showed how to achieve competitive theoretical tradeoffs between space and time in locate queries, by combining data structures that depend on distinct measures of repetition, where all such measures grow sublinearly in the length of a highly-repetitive string [3]. Specifically, we described a data structure that takes approximately O(z + r) words of space, and that reports all the occurrences of a pattern of length m in a string of length n in O(m(log log n + log z) + pocc · log z + socc · log log n) time, where pocc and socc are the number of primary and of secondary occurrences, respectively (see Section 2.2). This compares favorably to the O(m2h + (m + occ) log z) reporting time of Lempel-Ziv 77 (LZ77) indexes [18], where h is the height of the parse tree. It also compares favorably in space to solutions based on the run-length encoded BWT (RLBWT) and on suffix array samples [21], which take O(n/k + r) words of space to achieve O(m log log n + k · occ · log log n) reporting time, where k is the sampling rate. We also introduced a data structure whose size depends on the number of right-extensions of maximal repeats, and that reports all the occ occurrences of a pattern in O(m log log n + occ) time. The main component of our constructions is the RLBWT, which we use for counting the number of occurrences of a pattern, and which we combine with the CDAWG and with data structures from Lempel-Ziv indexes, rather than with suffix array samples, for answering locate queries. In this paper we engineer a range of practical variants of such approaches, and we compare their space-time tradeoffs to a representative set of state-of-the-art indexes for repetitive collections, including RLCSA [21], a number of LZ77 implementations [17], and a recent implementation of the hybrid index [32]. One of our indexes based on RLBWT and LZ77 factors uses an amount of memory comparable to LZ77 indexes, but it answers count queries between two and four orders of magnitude faster than all LZ77 and hybrid index implementations. For long patterns, our index uses less space than the hybrid index, and it answers locate queries between one and two orders of magnitude faster than a number of LZ77 implementations, and as fast as the fastest LZ77 implementation. With short patterns, our index based on RLBWT and CDAWG answers locate queries between four and ten times faster than a version of RLCSA that uses comparable memory, and with extremely short patterns our index achieves speedups even greater than ten with respect to RLCSA. Preliminaries 2 2.1 Strings Let Σ = [1..σ] be an integer alphabet, let # = 0 /∈ Σ be a separator, and let T ∈ [1..σ]n−1 be a string. We denote by T the reverse of T, and by PT #(W) the set of all starting positions of a string W ∈ [0..σ]+ in the circular version of T#. We set Σr T #(W) = {a ∈ [0..σ] : PT #(W a) > 0} and Σ' T #(W) = {a ∈ [0..σ] : PT #(aW) > 0}. A repeat W ∈ Σ+ is a string that satisfies PT #(W) > 1. A repeat W is right-maximal (respectively, left-maximal) iff Σr T #(W) > 1). A maximal repeat is a repeat that is both left- and right-maximal. We say that a maximal repeat W is rightmost (respectively, leftmost) if no string W V with V ∈ [0..σ]+ is left-maximal (respectively, if no string V W with V ∈ [0..σ]+ is right-maximal). T #(W) > 1 (respectively, iff Σ' For reasons of space we assume the reader to be familiar with the notion of suffix tree STT # = (V, E) and of suffix-link tree of T#, which we do not define here. We denote by '(γ), or equivalently by '(u, v), the label of edge γ = (u, v) ∈ E, and we denote by '(v) the D. Belazzougui et al. 23:3 string label of node v ∈ V . It is well known that a string W is right-maximal (respectively, left-maximal) in T# iff W = '(v) for some internal node v of STT # (respectively, iff W = '(v) for some internal node v of STT #). Since left-maximality is closed under prefix operation, there is a bijection between the set of all maximal repeats of T# and the set of all nodes of the suffix tree of T# that lie on paths that start from the root and that end at nodes labelled by rightmost maximal repeats. Symmetrically, since right-maximality is closed under suffix operation, there is a bijection between the set of all maximal repeats and the set of all nodes of the suffix tree of T# that lie on paths that start from the root and that end at nodes labelled by leftmost maximal repeats. The compact directed acyclic word graph of T# (denoted by CDAWGT # in what follows) is the minimal compact automaton that recognizes the set of suffixes of T# [4, 7]. It can be seen as the minimization of STT # in which all leaves are merged to the same node (the sink) that represents T# itself, and in which all nodes except the sink are in one-to-one correspondence with the maximal repeats of T# [29] (the source corresponds to the empty string). The set of accepting nodes consists of the sink and of all maximal repeats that also occur as a suffix of T#. Like in the suffix tree, transitions are labelled by substrings of T#. Since a maximal repeat corresponds to a subset of its right-maximal suffixes, CDAWGT # can be built by putting in the same equivalence class all nodes of STT # that belong to the same maximal unary path of explicit Weiner links. Note also that the subgraph of STT # induced by maximal repeats is isomorphic to a spanning tree of CDAWGT #. For reasons of space we assume the reader to be familiar with the notion and uses of the Burrows-Wheeler transform of T, including the C array, LF mapping, and backward search. In this paper we use BWTT # to denote the BWT of T#, and we use range(W) = [sp(W)..ep(W)] to denote the lexicographic interval of a string W in a BWT that is implicit from the context. We say that BWTT #[i..j] is a run iff BWTT #[k] = c ∈ [0..σ] for all k ∈ [i..j], and moreover if any substring BWTT #[i0..j0] such that i0 ≤ i, j0 ≥ j, and either i0 6= i or j0 6= j, contains at least two distinct characters. It is well known that repetitions in T# induce runs in BWTT #: for example, the BWT of W k# consists of r ≤ W runs of length at least k and of a run of length one. We denote by rT # the number of runs in BWTT #, and we call run-length encoded BWT (denoted by RLBWTT #) any representation of BWTT # that takes O(rT #) words of space, and that supports rank and select operations (see e.g. [20, 21, 30]). Since the difference between rT # and rT # is negligible in practice, to simplify notation we denote both of them by r when T is implicit from the context. The Lempel-Ziv 77 factorization of T [34], abbreviated with LZ77 in the rest of the paper, is the greedy decomposition T1T2 ··· Tz of T defined as follows. Assume that T is virtually preceded by the set of distinct characters in its alphabet, and assume that T1T2 ··· Ti has already been computed for some prefix of length k of T: then, Ti+1 is the longest prefix of T[k + 1..n] such that there is a j ≤ k that satisfies T[j..j + Ti+1 − 1] = Ti+1. In the rest of the paper we drop subscripts whenever they are clear from the context. 2.2 String indexes The run-length compressed suffix array of T#, denoted by RLCSAT # in what follows, consists of a run-length compressed rank data structure for BWTT #, and of a sampled suffix array, denoted by SSAT # [21]. Given a pattern P ∈ [1..σ]m, we use the rank data structure to find the interval of BWTT # that contains all characters that precede the occurrences of P in T#: the length of this interval, uncompressed, is the number of such occurrences. To locate a specific occurrence, we start at the character that precedes it in BWTT # and we use rank queries to move backward, until we reach a character whose position has been sampled. CVIT 2016 23:4 Practical combinations of repetition-aware data structures Thus, the average time for locating an occurrence is inversely proportional to the size of SSAT #, and fast locating needs a large SSA regardless of the compressibility of the dataset. Mäkinen et al. suggested ways to reduce the size of the SSA [21], but they did not perform well enough in real repetitive datasets for the authors to include them in the software they released. For reasons of space we assume the reader to be familiar with LZ77 indexes (see e.g. [13, 16]). Here we just recall that a primary occurrence of a pattern P in T is one that crosses or ends at a phrase boundary in the LZ77 factorization T1T2 ··· Tz of T. All other occurrences are called secondary. Once we have computed primary occurrences, locating all socc secondary occurrences reduces to two-sided range reporting, and it takes O(socc · log log n) time with a data structure of O(z) words of space [16]. To locate primary occurrences, we use a data structure for four-sided range reporting on a z × z grid, with a marker at (x, y) if the x-th LZ factor in lexicographic order is preceded in the text by the lexicographically y-th reversed prefix ending at a phrase boundary. This data structure takes O(z) words of space, and it returns all the phrase boundaries that are immediately followed by a factor in the specified range, and immediately preceded by a reversed prefix in the specified range, in O((1 + k) log z) time, where k is the number of phrase boundaries reported [5]. Kärkkäinen and Ukkonen used two PATRICIA trees [22], one for the factors and the other for the reversed prefixes ending at phrase boundaries [16]. To locate primary occurrences, we query the first tree for the range of distinct factors in left-to-right lexicographic order that start with P[i + 1..m], and we query the second tree for the range of reversed prefixes T[1..pi − 1] starting with P[1..i], for all i ∈ [1..m]. The ranges returned by the trees are correct iff any factor starts with P[i + 1..m] and any reversed prefix at a phrase boundary starts with P[1..i]. To check the first range, we choose any factor in the range and compare its first m − i characters to P[i + 1..m]. To check the second range, we choose any reversed prefix in the range and compare its first i characters to P[1..i]. This takes O(m) time for every i, thus O(m2) time in total, assuming that T is not compressed. Replacing the uncompressed text by an augmented compressed representation, we can store T in O(z log n) space such that later, given P, we can find all occ occurrences of P in O(m log m + occ · log log n) time [13]. If we know in advance that all patterns will be of length at most M, then we can store in a FM-index the substrings of T consisting of characters within distance M of the nearest phrase boundary, and use that to find primary occurrences. This approach, called hybrid indexing, has been proposed several times recently: see e.g. [32] and references therein for more details. 2.3 Composite repetition-aware string indexes It is possible to combine RLBWTT # with the set of all starting positions p1, p2, . . . , pz of LZ factors of T, building a data structure that takes O(z + r) words of space, and that reports all the pocc primary occurrences of a pattern P ∈ [1..σ]m in O(m(log log n+log z)+pocc·log z) time [3]. Since such data structure is at the core of the paper, we summarize how it works in what follows. The same primary occurrence of P in T can cover up to m boundaries between two LZ factors. Thus, we consider every possible way of placing, inside P, the rightmost boundary between two factors, i.e. every possible split of P in two parts P[1..k − 1] and P[k..m] for k ∈ [2..m], such that P[k..m] is either a factor or a proper prefix of a factor. For every such k, we use four-sided range reporting queries to list all the occurrences of P in T that conform to the split, as described in Section 2.2. We encode the sequence p1, p2, . . . , pz implicitly, as follows: we use a bitvector last[1..n] such that last[i] = 1 iff SAT #[i] = n − pj + 2 for D. Belazzougui et al. 23:5 some j ∈ [1..z], i.e. iff SAT #[i] is the last position of a factor. We represent such bitvector as a predecessor data structure with partial ranks, using O(z) words of space [33]. Let STT # = (V, E) be the suffix tree of T#, and let V 0 = {v1, v2, . . . , vz} ⊆ V be the set of loci in STT # of all LZ factors of T. Consider the list of node labels L = '(v1), '(v2), . . . , '(vz), sorted in lexicographic order. It is easy to build a data structure that takes O(z) words of space, and that implements in O(log z) time function I(W, V 0), which returns the (possibly empty) interval of W in L (see e.g. [3]). Together with last, RLBWTT # and RLBWTT #, this data structure is the output of our construction. k−1..j0 k−1) − rank1(last, i0 Given P, we first perform a backward search in RLBWTT # to determine the number of occurrences of P in T#: if this number is zero, we stop. During backward search, we store in a table the interval [ik..jk] of P[k..m] in BWTT # for every k ∈ [2..m]. Then, we compute k−1] of P[1..k − 1] in BWTT # for every k ∈ [2..m], using backward search the interval [i0 k−1 − 1) = 0, then P[1..k − 1] never ends in RLBWTT #: if rank1(last, j0 at the last position of a factor, and we can discard this value of k. Otherwise, we convert [i0 k−1..j0 k−1)] of all the reversed prefixes of T that end at the last position of a factor. Rank operations on last can be implemented in O(log log n) time using predecessor queries. We get the lexicographic interval of P[k..m] in the list of all distinct factors of T using operation I(P[k..m], V 0), in O(log z) time. We use such intervals to query the four-sided range reporting data structure. k−1] to the interval [rank1(last, i0 k−1 − 1) + 1..rank1(last, j0 It is also possible to combine RLBWTT # with CDAWGT #, building a data structure that takes O(eT #) words of space, and that reports all the occ occurrences of P in O(m log log n+ occ) time, where eT # is the number of right-extensions of maximal repeats of T# [3]. Specifically, for every node v in the CDAWG, we store '(v) in a variable v.length. Recall that an arc (v, w) in the CDAWG means that maximal repeat '(w) can be obtained by extending maximal repeat '(v) to the right and to the left. Thus, for every arc γ = (v, w) of the CDAWG, we store the first character of '(γ) in a variable γ.char, and we store the length of the right extension implied by γ in a variable γ.right. The length γ.left of the left extension implied by γ can be computed by w.length − v.length − γ.right. For every arc of the CDAWG that connects a maximal repeat W to the sink, we store just γ.char and the starting position γ.pos of string W · γ.char in T. The total space used by the CDAWG is O(eT #) words, and the number of runs in BWTT # can be shown to be O(eT #) as well [3]. An alternative construction could use CDAWGT # and RLBWTT #. We use the RLBWT to count the number of occurrences of P in T in O(m log log n) time: if this number is not zero, we use the CDAWG to report all the occ occurrences of P in O(occ) time, using a technique already sketched in [6]. Specifically, since we know that P occurs in T, we perform a blind search for P in the CDAWG, as is typically done with PATRICIA trees. We keep a variable i, initialized to zero, that stores the length of the prefix of P that we have matched so far, and we keep a variable j, initialized to one, that stores the starting position of P inside the last maximal repeat encountered during the search. For every node v in the CDAWG, we choose the arc γ such that γ.char = P[i + 1] in constant time using hashing, we increment i by γ.right, and we increment j by γ.left. If the search leads to the sink by an arc γ, we report γ.pos + j and we stop. If the search ends in a node v that is associated with the maximal repeat W, we determine all the occurrences of W in T by performing a depth-first traversal of all nodes reachable from v in the CDAWG , updating variables i and j as described above, and reporting γ.pos + j for every arc γ that leads to the sink. The total number of nodes and arcs reachable from v is O(occ). CVIT 2016 23:6 Practical combinations of repetition-aware data structures 3 Combining RLBWT and LZ factors in practice We implement1 the combination of RLBWT and LZ factorization described in Section 2.3, exploring a range of practical variants of decreasing size. Specifically, in addition to the version described in Section 2.3 (which we call full in what follows), we implement a variant in which we drop RLBWTT #, simulating it with a bidirectional index (we call this variant bidirectional in what follows), a variant in which we drop RLBWTT #, the four-sided range reporting data structure, and the subset of suffix tree nodes (we call this variant light in what follows), and another variant in which we use a sparse version of the LZ parsing (we call this sparse in what follows). Moreover, we design a number of practical optimization to speed up locate queries: see Appendix C. We implement all variants using a representation of the RLBWT that is more space- efficient than the one described in [30]. Recall that the latter is encoded as follows: they store one character per run in a string H ∈ Σr, they mark with a one the beginning of each run in a bitvector Vall[0..n − 1], and for every c ∈ Σ they store the lengths of all runs of character c consecutively in a bit-vector Vc: specifically, every c-run of length k is represented in Vc as 10k−1. This representation allows one to map rank and access queries on BWTT # to rank, select and access queries on H, Vall, and Vc. By gap-encoding the bitvectors, this representation takes r(2 log(n/r)+log σ)(1+ o(1)) bits of space. We reduce the multiplicative factor of term log(n/r) by storing in Vall just one out of 1/ ones, where 0 <  ≤ 1 is an arbitrary constant. It is easy to see that we are still able to answer all queries on the RLBWT by using the vectors Vc to reconstruct the positions of the missing ones in Vall, using r(cid:0)(1 + ) log(n/r) + log σ(cid:1)(1 + o(1)) bits of space, but query times are multiplied by a factor 1/. In all our experiments we set  to 1/8. We represent H as a Huffman-encoded string (wt_huff<> in SDSL), and gap-encoded bitvectors with Elias-Fano (sd_vector<> in SDSL). 3.1 Full index The first variant is an engineered version of the data structure described in Section 2.3. We store both RLBWTT # and RLBWTT #. A gap-encoded bitvector end[0..n−1] of z log(n/z)(1+ o(1)) bits marks the rank, among all the suffixes of T#, of every suffix T[i..n− 1]# such that n − i − 2 is the last position of an LZ factor of T. Symmetrically, a gap-encoded bitvector begin[0..n − 1] of z log(n/z)(1 + o(1)) bits marks the rank, among all the suffixes of T#, of every suffix T[i..n − 1]# such that i is the first position of an LZ factor of T. Geometric range data structures (4-sided and 2-sided) are implemented as wavelet trees (wt_int<> in SDSL). The 4-sided range data structure supports locating primary occurrences, by storing the permutation of the z LZ factors of T, sorted lexicographically, in the order induced by the corresponding ones in end: in other words, every character of the wavelet tree is the lexicographic rank of an LZ factor, among all the LZ factors of T. For locating primary occurrences, we need to label every point in the 4-sided range data structure with a text position. We allocate log z bits rather than log n bits to every such label, by using as label the rank of the corresponding one in array begin, thus the data structure takes 2z log z(1 + o(1)) bits of space. The 2-sided range data structure stores z two-dimensional points whose coordinates are both in [1..T]. For locating secondary occurrences, every 1 The source code of all our implementations is available at [26, 27], and it is based on the SDSL library [15]. D. Belazzougui et al. 23:7 such point is again labeled with the rank of the corresponding one in array begin. The wavelet tree that implements the 2-sided range data structure can only store points whose set of x coordinates is [1..z]: we map text coordinates to this domain using a gap-encoded bitvector, which takes z log(n/z)(1 + o(1)) bits of space. Some coordinates could be repeated, since two LZ factors could share the same source start point: we keep track of duplicates using a succinct bitvector that takes z + o(z) bits of space, in which a coordinate that is repeated k > 0 times is encoded as 10k−1. Overall, the 2-sided range data structure takes z(2 log n + 1)(1 + o(1)) bits of space. Finally, we need a way to compute the lexicographic range of a string among all the LZ factors of T. We implement a simpler and more space-efficient strategy than the one proposed in [3]. Specifically, recall that LZ factors are right-maximal substrings of T#, or equivalently they are nodes of the suffix tree of T#. Recall also that the BWT intervals of two nodes of the suffix tree of T# are either disjoint or contained in one another. We sort the BWT intervals of all LZ factors by the order induced by the pre-order traversal of the suffix tree of T#: two distinct nonempty intervals [i0..j0] and [i00..j00] are such that [i0..j0] < [i00..j00] iff j0 < i00, or iff [i00..j00] is contained in [i0..j0]. The data structure is just the sorted array V of such intervals, and it takes 2z log n bits of space2. Given the BWT interval [i..j] of a string W, we find its lexicographic range among all sorted distinct LZ factors, in O(log z) time, as follows: (1) we binary-search V using the order described above, finding all intervals that are strictly smaller than [i..j]; (2) starting from the first interval in V that is greater than or equal to [i..j], we find all intervals in V that equal [i..j] or are contained in it, i.e. all intervals of factors that are either W itself or a right-extension of W. This requires just one binary search, since all such intervals are contiguous in V . In summary, the full index takes(cid:0)6z log n + 2(1 + )r log(n/r) + 2r log σ(cid:1) · (1 + o(1)) bits of space, and it supports count queries in O(m · (log(n/r) + log σ)) time and locate queries in O((m + occ) · log n) time. 3.2 Bidirectional index We can drop RLBWTT # and simulate it using just RLBWTT #, by applying the synchroniza- tion step performed in bidirectional BWT indexes (see e.g. [2] and references therein). This strategy penalizes the time complexity of locate queries, which becomes quadratic in the length of the pattern. Moreover, since in our implementation we store run-lengths separately for each character, a synchronization step requires σ rank queries to find the number of characters smaller than a given character inside a BWT interval. This operation could be performed in O(log σ) time if the string were represented as a wavelet tree. In summary, the of space, it supports count queries in O(m · (log(n/r) + log σ)) time, and it supports locate queries in O(m2σ log(n/r) + (m + occ) · log n) time. bidirectional variant of the index takes(cid:0)6z log n + (1 + )r log(n/r) + r log σ(cid:1) · (1 + o(1)) bits 3.3 Light index with LZ sparsification Once we have computed the interval of the pattern in BWTT #, we can locate all its primary occurrences by just forward-extracting at most m characters for each occurrence inside the 2 The sequence of first positions of all intervals in the sorted array is non-decreasing, thus we use gap encoding to save z log z bits of space. This adds a multiplicative factor of O(log(n/z)) to all query times. For clarity we describe just the simpler version in which intervals are encoded as 2z integers of log n bits each. CVIT 2016 23:8 Practical combinations of repetition-aware data structures range: this is because every primary occurrence of the pattern overlaps with the last position of an LZ factor. We implement forward extraction with select queries on RLBWTT #. This approach requires just RLBWTT #, the 2-sided range data structure, a gap-encoded bitvector endT that marks the last position of every LZ factor in the text, a gap-encoded bitvector endBW T that marks the last position of every LZ factor in BWTT #, and z integers of log z bits each, connecting corresponding ones in endBW T and in endT : this array plays the role of the sparse suffix array sampling used in RLCSA. We can reduce space even further by sparsifying the LZ factorization. Intuitively, the factorization of a highly-repetitive collection of strings T = T1T2 ··· Tk, where T2, . . . , Tk are similar to T1, is much denser inside T1 than it is inside T2 ··· Tk, thus excluding long enough contiguous regions from the factorization (i.e. not outputting factors inside such regions) could reduce the number of factors in dense regions. Formally, let d > 0, and consider the following generalization3 of LZ77, denoted here by LZ77-d: we factor T as X1Y1X2Y2 ··· Xzd Yzd, where zd is the size of the factorization, Yi ∈ Σd for all i ∈ [1..zd], and Xi is the longest prefix of XiYi ··· Xzd Yzd that appears at least twice in X1Y1X2Y2 ··· Xi To make the index described in this section work with LZ77-d, we need to sample the suffix array of T# at the lexicographic ranks that correspond to the last position of every Xi, and we need to redefine primary occurrences as those that are not fully contained inside an Xi. During locate we now need to extract d additional characters before each occurrence of the pattern, in order to locate primary occurrences that start inside a Yi. The 2-sided range data structure must also be built on the (sources of the) factors X1, . . . , Xzd. This bits of space, it answers locate queries in O((occ + 1) · (m + d) · log n) time and count queries in O(m(log(n/r) + log σ)) time. implementation of the index takes(cid:0)zd(3 log n + log(n/zd)) + (1 + )r log(n/r)(cid:1) · (1 + o(1)) 4 Combining RLBWT and CDAWG in practice We implement4 the combination of RLBWT and CDAWG described in Section 2.3, and we study the effect of two representations of the CDAWG in memory. In the first representation, the graph is encoded as a sequence of variable-length integers: every integer is represented as a sequence of bytes, in which the seven least significant bits of every byte are used to encode the integer, and the most significant bit flags the last byte of the integer. Nodes are stored in the sequence according to their topological order in the graph obtained from the CDAWG by inverting the direction of all arcs: to encode a pointer from a node v to its successor w in the CDAWG, we store the difference between the first byte of v and the first byte of w in the sequence. If w is the sink, such difference is replaced by a shorter code. We choose to store the length of the maximal repeat that corresponds to each node, rather than the offset of '(v) inside '(w) for every arc (v, w), since such lengths are short and smaller than the number of arcs in practice. In the second encoding we exploit the fact that the subgraph of the suffix tree of T# induced by maximal repeats is a spanning tree of CDAWGT # (see Section 2.1). Specifically, we encode such spanning tree with the balanced parenthesis scheme described in [23], and we resolve the arcs of the CDAWG that belong to the tree using corresponding tree operations. Such operations work on node identifiers, thus we need to convert node identifiers to the 3 The version of LZ77 considered in this paper is obtained by setting d = 0, and by requiring the text to be virtually preceded by all its distinct characters. 4 The source code of all our implementations is available at [28]. D. Belazzougui et al. 23:9 first byte in the byte sequence of the CDAWG, and vice versa. For this, we encode the monotone sequence of the first byte of all n nodes in the byte sequence using the quasi-succinct representation by Elias and Fano, which uses at most 2 + log(N/n) bits per starting position, where N is the number of bytes in the byte sequence [9]. Finally, we observe that classical CDAWG construction algorithms (e.g. the online algorithm described in [7]) are not space-efficient, and we design linear-time algorithms that build a representation of the CDAWG from BWTT # or BWTT #, using optimal additional space. Specifically, let enumerateLeft(i, j) be a function that returns the set of distinct characters that appear in BWTT #[i..j], not necessarily in lexicographic order. We prove the following lemmas in Appendix A and B: (cid:73) Lemma 1. Let T ∈ [1..σ]n−1#, where # = 0. Given a representation of BWTT # that answers enumerateLeft in time tEL per element in its output, and LF in time tLF , we can build the topology of CDAWGT #, as well as the first character and the length of the label of each arc, in randomized O(n(tEL + tLF )) time and zero space in addition to the input and the output. (cid:73) Lemma 2. Let T ∈ [1..σ]n−1#, where # = 0. Given a representation of BWTT # that answers enumerateLeft in time tEL per element in its output, and LF in time tLF , we can build the topology of CDAWGT #, as well as the first character and the length of the label of each arc, in randomized O(n(tEL + tLF )) time and O(σ2 log2 n) bits of space in addition to the input and the output. 5 Experimental results We test our implementations on five DNA datasets from the Pizza&Chili repetitive corpus [11], which include the whole genomes of approximately 36 strains of the same eukaryotic species ("Saccharomyces cerevisiae" and "Saccharomyces paradoxus" in the plots), a collection of 23 and approximately 78 thousand substrings of the genome of the same bacterium (respectively "Escherichia coli" and "Haemophilus influenzae"), and an artificially repetitive string obtained by concatenating a hundred mutated copies of the same substring of the human genome (denoted by "pseudo-real" in the plots)5. We compare our results to the FM index implementation in SDSL [15] with sampling rate 2i for i ∈ [5..10] (represented by black circles in all plots), to an implementation of RLCSA6 [24] with the same sampling rates (triangles in the plots), to the five variants in the implementation of the LZ77 index described in [17] (squares), and to a recent implementation of the compressed hybrid index [32] (diamonds). The FM index uses RRR bitvectors in its wavelet tree. For brevity, we call LZ1 the implementation of the LZ77 index that uses suffix trie and reverse trie. For each process, and for each pattern length 2i for i ∈ [3..10], we measure the maximum resident set size and the number of CPU seconds that the process spends in user mode7, both for 5 Compressing such files with p7zip [25], an implementation of LZ77 with large window, makes the uncompressed files between 21 and 370 times bigger than the corresponding compressed files [11]. 6 We compile the sequential version with PSI_FLAGS and SA_FLAGS turned off (thus, a gap-encoded bitvector rather than a succinct bitvector is used to mark sampled positions in the suffix array). The block size of psi vectors (RLCSA_BLOCK_SIZE) is 32 bytes. 7 We perform all experiments on a single core of a 6-core, 2.50 GHz, Intel Xeon E5-2640 processor, with access to 128GiB of RAM and running CentOS 6.3. We measure resources with GNU Time 1.7, and we compile with GCC 5.3.0. CVIT 2016 23:10 Practical combinations of repetition-aware data structures locate and for count queries, discarding the time for loading the indexes and averaging our measurements over one thousand patterns8. We observe two distinct regimes for locate queries, corresponding to short patterns (shorter than approximately 64) and to long patterns, respectively (Figures 1 and 3). Our full, bidirectional and light index implementations (red circles in all plots) do not achieve any new useful tradeoff, in any dataset, neither with short nor with long patterns. As expected, the running time per pattern of the bidirectional index depends quadratically on pattern length, but we observe a superlinear growth for the light index as well. The optimizations described in Appendix C (red dots) are effective only for the bidirectional index, their effectiveness increases with pattern length, and they manage to shave up to 80% of running time with patterns of length 1024. The size of the bidirectional index on disk is on average 20% smaller than the size of the full index on disk, and the size of the light index on disk is approximately 20% smaller than the size of the bidirectional index on disk. We experiment with skipping 2i characters before opening a new phrase in the light index with LZ sparsification (green in all plots), where i ∈ [5..10]. The size of the sparse index with skip rate 25 on disk is approximately 35% smaller than the size of the light index on disk. With short patterns, the memory used by the sparse index becomes smaller than RLCSA and comparable to the LZ index, but its running time per occurrence is between one and two orders of magnitude greater than the LZ index and comparable to RLCSA with sampling rates equal to or greater than 2048 (Figure 1, top). With long patterns, however, the sparse index becomes between one and two orders of magnitude faster than all variants of the LZ index, except variant LZ1, while using comparable memory. As a function of pattern length, the running time per occurrence of the sparse index grows more slowly than the running time of LZ1, suggesting that the sparse index becomes as fast as LZ1 for patterns of length between 1024 and 2048 (Figure 3, top). The sparse index is approximately 1.5 orders of magnitude slower than the hybrid index, but since the size of the hybrid index depends on maximum pattern length, the sparse index becomes smaller than the hybrid index for patterns of length between 64 and 128, and possibly even shorter (Figure 4, top). As expected, the sparse index is faster than both the LZ index and the hybrid index in count queries, especially for short patterns: specifically, the sparse index is between two and four orders of magnitude faster than all variants of the LZ index, with the largest difference for patterns of length 8 (Figure 3, bottom). The difference between the sparse index and variant LZ1 shrinks as pattern length increases. Similar trends hold for the hybrid index. The full, bidirectional and light indexes show similar count times as the sparse index. The disk size of the CDAWG is comparable to the disk size of RLCSA with sampling rate between 4 and 8 (Figure 4, bottom). Using the succinct representation of the CDAWG (blue dots in all plots) shaves between 20% and 30% of the disk size and resident set of the non-succinct representation (blue circles). However, using the non-succinct representation shaves between 20% and 80% of the time of the succinct representation, depending on dataset and pattern length. Using the CDAWG to answer locate queries does not achieve any new tradeoff with long patterns (Figure 1, bottom). However, with short patterns the running time per occurrence of the CDAWG is between 4 and 10 times smaller than the running time per occurrence of a version of RLCSA that uses comparable memory, and with patterns of length two the CDAWG achieves speedups even greater than 10. 8 We generate random patterns that contain just characters in {a, c, g, t} using the genpatterns tool from the Pizza&Chili corpus [11]. D. Belazzougui et al. 23:11 Figure 1 Space-time tradeoffs of our indexes (color) and of the state of the art (black). Top row: patterns of length 16. Bottom row: patterns of length 512. For more clarity, RLCSA and sparse index are tested also on additional configurations not mentioned in Section 5. Figure 2 Space-time traeoffs of the CDAWG (blue) compared to RLCSA (triangles) with sampling rate 2i, i ∈ [3..5]. Patterns of length 8, 6, 4, 2 (from left to right). CVIT 2016 23:12 Practical combinations of repetition-aware data structures Figure 3 Locate time per occurrence (top) and count time per pattern (bottom), as a function of pattern length, for the sparse index with skip rate 2i, i ∈ [5..10], the LZ77 index, and the hybrid index. Count plots show also the FM index and RLCSA. Figure 4 (Top) Disk size of the sparse index with skip rate 2i, i ∈ [10..15], compared to the hybrid index with maximum pattern length 2i, i ∈ [3..10], the LZ77 index, and RLCSA with sampling rate 2i, i ∈ [10..15]. (Bottom) Disk size of the CDAWG compared to RLCSA with sampling rate 2i, i ∈ [2..5]. D. Belazzougui et al. 23:13 Acknowledgements. We thank Miguel Ángel Martínez for providing implementations of the variants described in [17], and Daniel Valenzuela for providing the implementation described in [32]. 6 Future work Designing indexes for repetitive texts is an increasingly active field and it is beyond the scope of this paper to review all the recent proposals -- see, e.g., [10, 14, 31, 32] -- especially since some have not been implemented. We would like to draw attention to an index described simultaneously and independently by Do et al. [8] and Gagie et al. [12], however, because we think it can be improved and made competitive in practice. Their index is intended for collections of many similar strings, such as databases of genomes from the same species. The main idea is to choose one of the strings as a reference and build an FM-index for the Relative Lempel-Ziv parse [19] of the entire dataset with respect to that reference, treating the phrases as meta-characters. Using FM-indexes for the reference and its reverse and some auxiliary data structures, we can apply dynamic programming to quickly compute all the ways any given pattern can be decomposed into the suffix of a phrase (possibly empty), a sequence of complete phrases, and the prefix of a phrase (possibly empty). This is possible because the dictionary of potential phrases -- i.e., all the substrings of the reference -- is fixed, albeit very large, and does not change while we parse (in contrast to the dictionaries for LZ77 and LZ78). Using the FM-index for the parse and some more auxiliary data structures, we can quickly find whether and where any of the possible decompositions of the pattern occur in the the parse of the dataset. These occurrences correspond to occurrences of the pattern that cross phrase boundaries. We can then quickly find all the other occurrences of the pattern in the dataset. Unfortunately, if there are many distinct phrases in the parse, the FM-index for it may not compress well. This raises the question of how we can reduce the number of distinct phrases without increasing the number of phrases too much. Suppose we build a compressed kth-order de Bruijn graph for the collection of strings (i.e., a kth-order de Bruijn graph in which we have collapsed every maximal path whose internal nodes have in- and out-degree 1); assign each of its edges with a distinct meta-character; consider each string as a walk on the graph and, for each edge the walk crosses, replacing the substring causing us to cross that edge by the edge's meta-character. This results in a parse in which the number of distinct phrases is the number of edges in the graph (assuming each of the strings in the collection has length at least k). Notice also that, for any pattern of length at least k, the pattern corresponds to at most one walk on the uncompressed graph (which may start and finish in the middle of edges in the compressed graph); if there is no such walk, then the pattern does not occur in the collection. Using a de Bruijn graph also removes the need for choosing a reference and using range reporting. We may be able to improve the compression by, first, removing low-frequency edges in the original de Bruijn graph before compressing it and, second, replacing substrings only when they cause us to cross high-frequency edges with sufficiently long edge labels in the the compressed de Bruijn graph. With this modification, a pattern may appear in the collection even if it does not correspond to a walk on the uncompressed graph. However, if a substring causes us to cross a high-frequency edge with a long edge label in the compressed graph, then we can certainly replace that substring by the edge's meta-character. It follows that, for any pattern of length at least k, we need perform at most four searches in the FM-index for the parse to determine whether and where that pattern occurs in the collection. CVIT 2016 23:14 Practical combinations of repetition-aware data structures We plan to implement and test this modification of Do et al.'s and Gagie et al.'s index soon and report the results in a future paper. Acknowledgements. We thank Miguel Ángel Martínez for providing implementations of the variants described in [17], and Daniel Valenzuela for providing the implementation described in [32]. References 1 Diego Arroyuelo, Gonzalo Navarro, and Kunihiko Sadakane. Stronger Lempel-Ziv based compressed text indexing. Algorithmica, 62(1-2):54 -- 101, 2012. 2 Djamal Belazzougui. Linear time construction of compressed text indices in compact space. In Proceedings of the 46th Annual ACM Symposium on Theory of Computing, pages 148 -- 193. ACM, 2014. 3 Djamal Belazzougui, Fabio Cunial, Travis Gagie, Nicola Prezza, and Mathieu Raffinot. In Combinatorial Pattern Matching, pages Composite repetition-aware data structures. 26 -- 39. Springer, 2015. 4 Anselm Blumer, Janet Blumer, David Haussler, Ross McConnell, and Andrzej Ehren- feucht. Complete inverted files for efficient text retrieval and analysis. Journal of the ACM, 34(3):578 -- 595, 1987. 5 Timothy M Chan, Kasper Green Larsen, and Mihai Pătraşcu. Orthogonal range search- In Proceedings of the twenty-seventh annual symposium on ing on the RAM, revisited. computational geometry, pages 1 -- 10. ACM, 2011. 6 Maxime Crochemore and Christophe Hancart. Automata for matching patterns. In Hand- book of formal languages, pages 399 -- 462. Springer, 1997. 7 Maxime Crochemore and Renaud Vérin. Direct construction of compact directed acyclic word graphs. In Alberto Apostolico and Jotun Hein, editors, CPM, volume 1264 of Lecture Notes in Computer Science, pages 116 -- 129. Springer, 1997. 8 Huy Hoang Do, Jesper Jansson, Kunihiko Sadakane, and Wing-Kin Sung. Fast relative lempel-ziv self-index for similar sequences. Theoretical Computer Science, 532:14 -- 30, 2014. Peter Elias and Richard A Flower. The complexity of some simple retrieval problems. Journal of the ACM (JACM), 22(3):367 -- 379, 1975. 9 10 Hector Ferrada, Travis Gagie, Tommi Hirvola, and Simon J. Puglisi. Hybrid indexes for repetitive datasets. Philosophical Transactions of the Royal Society of London A, 372(2016), 2014. Paolo Ferragina and Gonzalo Navarro. Pizza&Chili repetitive corpus. http://pizzachili. dcc.uchile.cl/repcorpus.html. Accessed: 2016-04-10. 11 12 Travis Gagie, Pawel Gawrychowski, Juha Kärkkäinen, Yakov Nekrich, and Simon J. Puglisi. A faster grammar-based self-index. In Proceedings of the 6th Conference on Language and Automata Theory and Applications, pages 240 -- 251, 2012. 13 Travis Gagie, Paweł Gawrychowski, Juha Kärkkäinen, Yakov Nekrich, and Simon J Pug- lisi. LZ77-based self-indexing with faster pattern matching. In LATIN 2014: Theoretical Informatics, pages 731 -- 742. Springer, 2014. 14 Travis Gagie, Pawel Gawrychowski, Juha Kärkkäinen, Yakov Nekrich, and Simon J. Puglisi. Lz77-based self-indexing with faster pattern matching. In Proceedings of the 11th Latin American Symposium on Theoretical Informatics, pages 731 -- 742, 2014. Simon Gog, Timo Beller, Alistair Moffat, and Matthias Petri. From theory to practice: Plug and play with succinct data structures. In 13th International Symposium on Experimental Algorithms, (SEA 2014), pages 326 -- 337, 2014. 15 D. Belazzougui et al. 23:15 16 17 18 19 Juha Kärkkäinen and Esko Ukkonen. Lempel-Ziv parsing and sublinear-size index struc- tures for string matching. In Proc. 3rd South American Workshop on String Processing (WSP'96, pages 141 -- 155, 1996. Sebastian Kreft. Self-index based on lz77. Master's thesis, Department of Computer Science, University of Chile, 2010. Sebastian Kreft and Gonzalo Navarro. On compressing and indexing repetitive sequences. Theoretical Computer Science, 483:115 -- 133, 2013. Shanika Kuruppu, Simon J. Puglisi, and Justin Zobel. Relative lempel-ziv compression of genomes for large-scale storage and retrieval. In Proceedings of the 17th Symposium on String Processing and Information Retrieval, pages 201 -- 206, 2010. 20 Veli Mäkinen and Gonzalo Navarro. Succinct suffix arrays based on run-length encoding. In Combinatorial Pattern Matching, pages 45 -- 56. Springer, 2005. 21 Veli Mäkinen, Gonzalo Navarro, Jouni Sirén, and Niko Välimäki. Storage and retrieval of highly repetitive sequence collections. Journal of Computational Biology, 17(3):281 -- 308, 2010. 22 Donald R Morrison. Patricia -- practical algorithm to retrieve information coded in alpha- numeric. Journal of the ACM (JACM), 15(4):514 -- 534, 1968. J. Ian Munro and Venkatesh Raman. Succinct representation of balanced parentheses and static trees. SIAM J. Comput., 31(3):762 -- 776, March 2002. URL: http://dx.doi.org/ 10.1137/S0097539799364092, doi:10.1137/S0097539799364092. 23 24 Adam Novak. Convenient repository for/fork of the RLCSA library. https://github.com/ adamnovak/rlcsa. Accessed: 2016-04-10. Igor Pavlov. P7ZIP home. http://p7zip.sourceforge.net. Accessed: 2016-04-10. 25 26 Nicola Prezza. lz-rlbwt: Run-length compressed Burrows-Wheeler transform with LZ77 suffix array sampling. https://github.com/nicolaprezza/lz-rlbwt. Accessed: 2016-04- 10. 27 Nicola Prezza. form with sparse LZ77 suffix array sampling. lz-rlbwt-sparse. Accessed: 2016-04-10. lz-rlbwt-sparse: Run-length compressed Burrows-Wheeler trans- https://github.com/nicolaprezza/ 28 Mathieu Raffinot. locate-cdawg: Replacing sampling by CDAWG localisation in BWT indexing approaches. https://github.com/mathieuraffinot/locate-cdawg. Accessed: 2016-04-10. 29 Mathieu Raffinot. On maximal repeats in strings. Information Processing Letters, 80(3):165 -- 169, 2001. Jouni Sirén, Niko Välimäki, Veli Mäkinen, and Gonzalo Navarro. Run-length compressed indexes are superior for highly repetitive sequence collections. In String Processing and Information Retrieval, 15th International Symposium, SPIRE 2008, Melbourne, Australia, November 10-12, 2008., pages 164 -- 175, 2008. 30 31 Yoshimasa Takabatake, Yasuo Tabei, and Hiroshi Sakamoto. Improved esp-index: A prac- tical self-index for highly repetitive texts. In Proceedings of the 13th Symposium on Exper- imental Algorithms, pages 338 -- 350, 2014. 32 Daniel Valenzuela. CHICO: A compressed hybrid index for repetitive collections. In Pro- ceedings of the fifteenth International Symposium on Experimental Algorithms (SEA 2016), Lecture Notes in Computer Science. Springer, June 2016. 33 Dan E Willard. Log-logarithmic worst-case range queries are possible in space Theta(n). Information Processing Letters, 17(2):81 -- 84, 1983. Jacob Ziv and Abraham Lempel. A universal algorithm for sequential data compression. IEEE Transactions on information theory, 23(3):337 -- 343, 1977. 34 CVIT 2016 23:16 Practical combinations of repetition-aware data structures Proof of Lemma 1 A We use the algorithm described in [2] to enumerate a representation of every node of STT # by performing a depth-first traversal of the suffix link tree of T#. Such algorithm works in O(n · tEL) time and in O(σ2 log2 n) bits of working space9 , and it provides, for each node v, its interval in BWTT # and the length of its label, as well as the list of all its children, and for every such child w, the interval of w in BWTT # and the first character of the label of edge (v, w) in STT #. Since the label of every node of the CDAWG is a maximal repeat of T#, the set of nodes of the CDAWG (excluding the sink Ω) is in one-to-one correspondence with a subset of the nodes of the suffix tree. Specifically, a node v of STT # corresponds to a node v0 of the CDAWG if and only if '(v) is a left-maximal substring of T#. We can check the left-maximality of '(v) by counting the number of distinct characters in the BWT interval of v. Every time this number is greater than one, we have discovered a new node v0 of the CDAWG, and we assign to it a unique identifier by incrementing a global counter. Then, we scan every child w of v in STT #, and we store in a hash table a tuple (i, j, v0.id,'(v), c), where [i..j] is the interval of w and is used as key, and v0.id is the unique number assigned to v0. Note that every quadruplet we insert in the hash table has a unique key. If the BWT interval of w is of length one, then w is a leaf, an arc connects v0 in the CDAWG to the sink Ω with character c, and c is the first character of the label of edge (v, w) in STT #. We compute the starting position of '(v) · c for of all such arcs (v0, Ω) in the CDAWG in batch, by inverting BWTT # and querying the hash table. The hash table can be implemented to support both insertion and querying in O(1) randomized time. BWT inversion takes O(n · tLF ) time and an amount of memory that can be charged to the output. To build all arcs of the CDAWG that are not directed to the sink, we perform another traversal of the suffix-link tree, in the same order as the first traversal. Assume that, during this second traversal, we enumerate a node w whose BWT interval is present in the hash table: then, w is the child of a node v of the suffix tree that corresponds to a node v0 of the CDAWG. If w corresponds to a node w0 of the CDAWG as well, i.e. if '(w) if a left-maximal substring of T#, we add arc (v0, w0) to the CDAWG. Otherwise w is not left-maximal, thus the CDAWG must contain arc (v0, u0) where '(u0) = W · '(w) is the shortest left-extension of '(w) to be left-maximal, and the corresponding node u in the suffix tree can be reached from w by a unary path in the suffix-link tree. Thus, we keep an auxiliary buffer, initially empty. Every time we encounter a node w of the suffix tree whose interval [i..j] is such that a tuple (i, j, v0.id,'(v0), c) exists in the hash table, we append to the buffer tuple (v0.id,'(w)−'(v0), c). Moreover, if w is left-maximal, we empty the buffer and we transform every tuple (v0.id, k, c) in the buffer into an arc (v0.id, w0.id, k, c) of the CDAWG. The size of such buffer can be charged to the output. Proof of Lemma 2 B We proceed as in Appendix A, traversing the suffix-link tree of T#, and enumerating the intervals in BWTT # of every node of the suffix tree of T#, i.e. of every right-maximal substring of T#. Once we detect that a node v is also left-maximal in T#, we create a 9 The enumeration algorithm described in [2] uses the stack trick to fit the working space in O(σ2 log2 n) bits. Without such trick, the working space would be proportional to the largest number of left-extensions of maximal repeats that lie in the same path of the suffix-link tree of T #, which can be charged to the output of Lemma 1. D. Belazzougui et al. 23:17 new node v0 of the CDAWG, we assign a new unique identifier to it, we enumerate all the left-extensions c · '(v) in T#, and we push tuple (i, j, v0.id,'(v), c) in a hash table, where [i..j] is the interval of c · '(v) in BWTT # and is used as key, and v0.id is the unique number assigned to v0. If the BWT interval of c · '(v) is of length one, an arc connects v0 to the sink Ω with character c in the CDAWG. We compute the starting position in T# of c · '(v) for of all such arcs (v0, Ω) in the CDAWG in batch, by inverting BWTT # and querying the hash table. Note that, since we are possibly pushing the intervals in BWTT # of the destinations of implicit Weiner links in the suffix tree of T#, the hash table has to allow the presence of distinct tuples with the same key. To build all arcs of the CDAWG that are not directed to the sink, we perform another traversal of the suffix-link tree of T#, in the same order as the first traversal. Assume that, during this second traversal, we enumerate a node w of the suffix tree of T# whose interval in BWTT # is present in the hash table in a set of tuples T = {(i, j, v0.id,'(v), c)}. If w corresponds to a node w0 of the CDAWG as well, i.e. if '(w) if a left-maximal substring of T#, we add arc (v0, w0) to the CDAWG for every tuple in T . Otherwise w is not left-maximal in T#, thus the CDAWG must contain arc (v0, u0) for every tuple in T , where '(u0) = W · '(w) is the shortest left-extension of '(w) to be left-maximal in T#, and the corresponding node u in the suffix tree of T# can be reached from w by a unary path in the suffix-link tree of T#. Thus, we keep an auxiliary buffer, initially empty. Every time we encounter a node w of the suffix tree of T# whose interval [i..j] is such that a set of tuples T exists in the hash table, we append to the buffer a corresponding set of tuples {(v0.id,'(w), c)}. Moreover, if w is left-maximal in T#, we empty the buffer and we transform every tuple (v0.id, k, c) in the buffer into an arc (v0.id, w0.id,'(w) − k + 1, c) of the CDAWG. The size of such buffer can be charged to the output. C Speeding up locate queries on indexes based on RLBWT and LZ factors On indexes based on RLBWT and LZ factors, locate queries can be further engineered in a number of ways: 1. Thanks to the RLBWT, we know the total number of occurrences of P in T before starting to locate them: thus, we can stop locating as soon as we have found all occurrences. 2. We could add a compressed bitvector first[1..n] that flags a position i iff SAT #[i] = pj for some j ∈ [1..z]. As we backward-search P in BWTT #, we could mark the positions k ∈ [2..m] such that the interval of P[k..m] in BWTT # contains only zeros in first, and discard them in the following steps. For every discarded suffix, this strategy saves a O(m) backward search in the bidirectional index. 3. The four-sided range reporting data structure could use the reversed prefixes T[1..pi] rather than the reversed prefixes T[1..pi − 1] for all i ∈ [1..z]. This would allow checking, at position k in P, whether P[1..k − 1] ends at a position j of T such that j is the last position of a factor, and such that T[j + 1] = P[k]. To implement an ever more stringent filter, one could store an additional four-sided range reporting data structure that uses the reversed prefixes T[1..pi − 1 + h] for h > 1, reverting to the four-sided data structure for h = 1 when k > m − h. In the bidirectional index, we could quit the synchronized backward search for P[1..k − 1] in BWTT # as soon as we find a suffix P[i..k − 1] which is not right-maximal, and which is not followed by P[k] in T#, or which does not contain a factor as a suffix. Moreover, we could quit the backward search as soon as we detect that P[i..k − 1] is right-maximal, 4. CVIT 2016 23:18 Practical combinations of repetition-aware data structures 5. but it is neither a factor nor the suffix of a factor, and it does not contain a factor as a suffix. Such tests can be implemented e.g. using variations of function I, and by replacing the interval of P[1..k − 1] with the σ + 1 subintervals of P[1..k − 1] · a for all a ∈ [0..σ], as described in [2]. Every backward step would have a O(σ) overhead in this case. In the bidirectional index, we could speed up the backward search that we have to perform for every P[1..k − 1], by precomputing a table of intervals in BWTT # and BWTT # for all strings of length h. This would take at most 4σh log n bits of additional space, or at most z(h log σ + 4 log n) bits if we just store the h-mers that suffix a factor. Due to lack of space, in the main paper we study just the effects of the first two optimizations.
1704.05811
1
1704
2017-04-19T16:39:25
Online Weighted Degree-Bounded Steiner Networks via Novel Online Mixed Packing/Covering
[ "cs.DS" ]
We design the first online algorithm with poly-logarithmic competitive ratio for the edge-weighted degree-bounded Steiner forest(EW-DB-SF) problem and its generalized variant. We obtain our result by demonstrating a new generic approach for solving mixed packing/covering integer programs in the online paradigm. In EW-DB-SF we are given an edge-weighted graph with a degree bound for every vertex. Given a root vertex in advance we receive a sequence of terminal vertices in an online manner. Upon the arrival of a terminal we need to augment our solution subgraph to connect the new terminal to the root. The goal is to minimize the total weight of the solution while respecting the degree bounds on the vertices. In the offline setting edge-weighted degree-bounded Steiner tree (EW-DB-ST) and its many variations have been extensively studied since early eighties. Unfortunately the recent advancements in the online network design problems are inherently difficult to adapt for degree-bounded problems. In contrast in this paper we obtain our result by using structural properties of the optimal solution, and reducing the EW-DB-SF problem to an exponential-size mixed packing/covering integer program in which every variable appears only once in covering constraints. We then design a generic integral algorithm for solving this restricted family of IPs. We demonstrate a new technique for solving mixed packing/covering integer programs. Define the covering frequency k of a program as the maximum number of covering constraints in which a variable can participate. Let m denote the number of packing constraints. We design an online deterministic integral algorithm with competitive ratio of O(k log m) for the mixed packing/covering integer programs. We believe this technique can be used as an interesting alternative for the standard primal-dual techniques in solving online problems.
cs.DS
cs
Online Weighted Degree-Bounded Steiner Networks via Novel Online Mixed Packing/Covering Sina Dehghani ∗† Soheil Ehsani ∗† MohammadTaghi Hajiaghayi ∗† Vahid Liaghat ‡ Harald Racke § Saeed Seddighin ∗† Abstract We design the first online algorithm with poly-logarithmic competitive ratio for the edge-weighted degree-bounded Steiner forest (EW-DB-SF) problem and its generalized variant. We obtain our result by demonstrating a new generic approach for solving mixed packing/covering integer programs in the online paradigm. In EW-DB-SF, we are given an edge-weighted graph with a degree bound for every vertex. Given a root vertex in advance, we receive a sequence of terminal vertices in an online manner. Upon the arrival of a terminal, we need to augment our solution subgraph to connect the new terminal to the root. The goal is to minimize the total weight of the solution while respecting the degree bounds on the vertices. In the offline setting, edge-weighted degree-bounded Steiner tree (EW-DB-ST) and its many variations have been extensively studied since early eighties. Unfortunately, the recent ad- vancements in the online network design problems are inherently difficult to adapt for degree-bounded problems. In particular, it is not known whether the fractional solution obtained by standard primal-dual techniques for mixed packing/covering LPs can be rounded online. In contrast, in this paper we obtain our result by using structural properties of the optimal solution, and reducing the EW-DB-SF problem to an exponential-size mixed packing/covering integer program in which every variable appears only once in covering constraints. We then design a generic integral algorithm for solving this restricted family of IPs. As mentioned above, we demonstrate a new technique for solving mixed packing/covering integer programs. Define the covering frequency k of a program as the maximum number of covering constraints in which a variable can participate. Let m denote the number of packing constraints. We design an online deterministic integral algorithm with competitive ratio of O(k log m) for the mixed packing/covering integer programs. We prove the tightness of our result by providing a matching lower bound for any randomized algorithm. We note that our solution solely depends on m and k. Indeed, there can be exponentially many variables. Furthermore, our algorithm directly provides an integral solution, even if the integrality gap of the program is unbounded. We believe this technique can be used as an interesting alternative for the standard primal-dual techniques in solving online problems. 7 1 0 2 r p A 9 1 ] S D . s c [ 1 v 1 1 8 5 0 . 4 0 7 1 : v i X r a ∗University of Maryland. email: {dehghani,ehsani,seddighin}@umd.edu [email protected] †Supported in part by NSF CAREER award 1053605, NSF grant CCF-1161626, ONR YIP award N000141110662, ‡Stanford University. email: [email protected] §Technische Universitat Munchen. email: [email protected] DARPA/AFOSR grant FA9550-12-1-0423, and a Google faculty research award. 1 Introduction Degree-bounded network design problems comprise an important family of network design problems since the eighties. Aside from various real-world applications such as vehicle routing and communication net- works [6, 33, 39], the family of degree-bounded problems has been a testbed for developing new ideas and techniques. The problem of degree-bounded spanning tree, introduced in Garey and Johnson's Black Book of NP-Completeness [30], was first investigated in the pioneering work of Furer and Raghavachari [16] (Allerton'90). In this problem, we are required to find a spanning tree of a given graph with the goal of min- imizing the maximum degree of the vertices in the tree. Let b∗ denote the maximum degree in the optimal spanning tree. Furer and Raghavachari give a parallel approximation algorithm which produces a spanning tree of degree at most O(log(n)b∗). This result was later generalized by Agrawal, Klein, and Ravi [1] to the case of degree-bounded Steiner tree (DB-ST) and degree bounded Steiner forest (DB-SF) problem. In DB-ST, given a set of terminal vertices, we need to find a subgraph of minimum maximum degree that connects the terminals. In the more generalized DB-SF problem, we are given pairs of terminals and the output subgraph should contain a path connecting each pair. Furer and Raghavachari [17](SODA'92, J. of Algorithms'94) significantly improved the result for DB-SF by presenting an algorithm which produces a Steiner forest with maximum degree at most b∗ + 1. The study of DB-ST and DB-SF was the starting point of a very popular line of work on various degree- bounded network design problems; e.g. [29, 32, 28, 23, 13] and more recently [15, 14]. One particular variant that has been extensively studied was initiated by Marathe et al. [29] (J. of Algorithms'98): In the edge-weighted degree-bounded spanning tree problem, given a weight function over the edges and a degree bound b, the goal is to find a minimum-weight spanning tree with maximum degree at most b. The initial results for the problem generated much interest in obtaining approximation algorithms for the edge- weighted degree-bounded spanning tree problem [11, 10, 18, 24, 25, 26, 27, 35, 36, 37]. The groundbreaking results obtained by Goemans [19] (FOCS'06) and Singh and Lau [38] (STOC'07) settle the problem by giving an algorithm that computes a minimum-weight spanning tree with degree at most b + 1. Singh and Lau [28] (STOC'08) generalize their result for the edge-weighted Steiner tree (EW-DB-ST) and edge- weighted Steiner forest (EW-DB-SF) variants. They design an algorithm that finds a Steiner forest with cost at most twice the cost of the optimal solution while violating the degree constraints by at most three. Despite these achievements in the offline setting, it was not known whether degree-bounded problems are tractable in the online setting. The online counterparts of the aforementioned Steiner problems can be defined as follows. The underlying graph and degree bounds are known in advance. The demands arrive one by one in an online manner. At the arrival of a demand, we need to augment the solution subgraph such that the new demand is satisfied. The goal is to be competitive against an offline optimum that knows the demands in advance. Recently, Dehghani et al. [12] (SODA'16) explore the tractability of the Online DB-SF problem by showing that a natural greedy algorithm produces a solution in which the degree bounds are violated by at most a factor of O(log n), which is asymptotically tight. They analyze their algorithm using a dual fitting approach based on the combinatorial structures of the graph such as the toughness1 factor. Unfortunately, greedy methods are not competitive for the edge-weighted variant of the problem. Hence, it seems unlikely that the approach of [12] can be generalized to EW-DB-SF. The online edge-weighted Steiner connectivity problems (with no bound on the degrees) have been ex- tensively studied in the last decades. Imase and Waxman [22] (SIAM J. D. M.'91) use a dual-fitting argument to show that the greedy algorithm has a competitive ratio of O(log n), which is also asymptotically tight. 1The toughness of a graph is defined as minX⊆V components of H. X CC(G\X) ; where for a graph H, CC(H) denotes the collection of connected 2 Later the result was generalized to the EW SF variant by Awerbuch et al. [4] (SODA'96) and Berman and Coulston [7] (STOC'97). In the past few years, various primal-dual techniques have been developed to solve the more general node-weighted variants [2, 31, 21] (SIAM'09, FOCS'11, FOCS'13), prize-collecting vari- ants [34, 20] (ICALP'11,ICALP'14), and multicommodity buy-at-bulk [9] (FOCS'15). These results are obtained by developing various primal-dual techniques [2, 21] while generalizing the application of combi- natorial properties to the online setting [31, 20, 9]. In this paper however, we develop a primal approach for solving bounded-frequency mixed packing/covering integer programs. We believe this framework would be proven useful in attacking other online packing and covering problems. 1.1 Our Results and Techniques In this paper, we consider the online Steiner tree and Steiner forest problems at the presence of both edge weights and degree bounds. In the Online EW-DB-SF problem, we are given a graph G = (V, E) with n vertices, edge-weight function w, degree bound bv for every v ∈ V , and an online sequence of connectivity demands (si, ti). Let wopt denote the minimum weight subgraph which satisfies the degree bounds and connects all demands. Let ρ = maxe w(e) 2. mine:w(e)>0 w(e) Theorem 1.1 There exists an online deterministic algorithm which finds a subgraph with total weight at most O(log2 n)wopt while the degree bound of a vertex is violated by at most a factor of O(log2(n) log(nρ)). If one favors the degree bounds over total weight, one can find a subgraph with degree-bound violation O(log2(n) log(nρ)) log log(nρ) ) and total cost O(log2(n) log(nρ)) log log(nρ) )wopt. Our technical contribution for solving the EW-DB-SF problem is twofold. First by exploiting a struc- tural result and massaging the optimal solution, we show a formulation of the problem that falls in the restricted family of bounded-frequency mixed packing/cover IPs, while losing only logarithmic factors in the competitive ratio. We then design a generic online algorithm with a logarithmic competitive ratio that can solve any instance of the bounded-frequency packing/covering IPs. In what follows, we describe these contributions in detail. Massaging the optimal solution Initiated by work of Alon et al. [2] on online set cover, Buchbinder and Naor developed a strong framework for solving packing/covering LPs fractionally online. For the applications of their general framework in solving numerous online problems, we refer the reader to the survey in [8]. Azar et al. [5] generalize this method for the fractional mixed packing and covering LPs. The natural linear program relaxation for EW-DB-SF, commonly used in the literature, is a special case of mixed packing/covering LPs: one needs to select an edge from every cut that separates the endpoints of a demand (covering constraints), while for a vertex we cannot choose more than a specific number of its adjacent edges (packing constraints). Indeed, one can use the result of Azar et al. [5] to find an online fractional solution with polylogarithmic competitive ratio. However, doing the rounding in an online manner seems very hard. Offline techniques for solving degree-bounded problems often fall in the category of iterative and depen- dent rounding methods. Unfortunately, these methods are inherently difficult to adapt for an online settings since the underlying fractional solution may change dramatically in between the rounding steps. Indeed, this might be the very reason that despite many advances in the online network design paradigm in the past two decades, the natural family of degree-bounded problems has remained widely open. In this paper, 2Our competitive ratios have a logarithmic dependency on ρ, i.e., the ratio between largest and smallest weight. It follows from the result of [12] that one cannot obtain polylogarithmic guarantees if this ratio is not polynomially bounded 3 we circumvent this by reducing EW-DB-ST to a novel formulation beyond the scope of standard online packing/covering techniques and solving it using a new online integral approach. The crux of our IP formulation is the following structural property: Let (si, ti) denote the ith demand. We need to augment the solution Qi−1 of previous steps by buying a subgraph that makes si and ti con- nected. Let Gi denote the graph obtained by contracting the pairs of vertices sj and tj for every j < i. Note that any (si − ti)-path in Gi corresponds to a feasible augmentation for Qi−1. Some edges in Gi might be already in Qi−1 and therefore by using them again we can save both on the total weight and the vertex degrees. However, in Section 2 we prove that there always exists a path in Gi such that even without sharing on any of the edges in Gi and therefore paying completely for the increase in the weight and degrees, we can approximate the optimal solution up to a logarithmic factor. This in fact, enables us to have a formulation in which the covering constraints for different demands are disentangled. Indeed, we only have one covering constraint for each demand. Unfortunately, this implies that we have exponentially many variables, one for each possible path in Gi. This may look hopeless since the competitive factors obtained by standard fractional packing/covering methods introduced by Buchbinder and Naor [8] and Azar et al. [5], depend on the logarithm of the number of variables. Therefore we come up with a new approach for solving this class of mixed packing/covering integer programs (IP). Bounded-frequency mixed packing/covering IPs We derive our result for EW-DB-ST by demonstrat- ing a new technique for solving mixed packing/covering integer programs. We believe this approach could be applicable to a broader range of online problems. The integer program IP1 describes a general mixed packing/covering IP with the set of integer variables x ∈ Zn≥0 and α. The packing constraints are described by a m × n non-negative matrix P . Similarly, the q × n matrix C describes the covering constraints. The covering frequency of a variable xi is defined as the number of covering constraints in which xi has a pos- itive coefficient. The covering frequency of a mixed packing/covering program is defined as the maximum covering frequency of its variables. minimize s.t. α , P x ≤ α . Cx ≥ 1 . x ∈ Z≥0, α ∈ R>0 . (IP1) In the online variant of mixed packing and covering IP, we are given the packing constraints in advance. However the covering constraints arrive in an online manner. At the arrival of each covering constraint, we should increase the solution x such that it satisfies the new covering constraint. We provide a novel algorithm for solving online mixed packing/covering IPs. Theorem 1.2 Given an instance of the online mixed packing/covering IP, there exists a deterministic in- tegral algorithm with competitive O(k log m), where m is the number of packing constraints and k is the covering frequency of the IP. We note that the competitive ratio of our algorithm is independent of the number of variables or the number of covering constraints. Indeed, there can be exponentially many variables. Our result can be thought of as a generalization of the work of Aspnes et al. [3] (JACM'97) on virtual circuit routing. Although not explicit, their result can be massaged to solve mixed packing/covering IPs in which all the coefficients are zero or one, and the covering frequency is one. They show that such IPs 4 admit a O(log(m))-competitive algorithms. Theorem 1.2 generalizes their result to the case with arbitrary non-negative coefficients and any bounded covering frequency. We complement our result by proving a matching lower bound for the competitive ratio of any random- ized algorithm. This lower bound holds even if the algorithm is allowed to return fractional solutions. Theorem 1.3 Any randomized online algorithm A for integral mixed packing and covering is Ω(k log m)- competitive, where m denotes the number of packing constraints, and k denotes the covering frequency of the IP. This even holds if A is allowed to return a fractional solution. As mentioned before, Azar et al. [5] provide a fractional algorithm for mixed packing/covering LPs with competitive ratio of O(log m log d) where d is the maximum number of variables in a single constraint. They show an almost matching lower bound for deterministic algorithms. We distinguish two advantages of our approach compared to that of Azar et al: • The algorithm in [5] outputs a fractional competitive solution which then needs to be rounded on- line. For various problems such as Steiner connectivity problems, rounding a solution online is very challenging, even if offline rounding techniques are known. Moreover, the situation becomes hope- less if the integrality gap is unbounded. However, for bounded-frequency IPs, our algorithm directly produces an integral competitive solution even if the integrality gap is large. • Azar et al. find the best competitive ratio with respect to the number of packing constraints and the size of constraints. Although these parameters are shown to be bounded in several problems, in many problems such as connectivity problems and flow problems, formulations with exponentially many variables are very natural. Our techniques provide an alternative solution with a tight competitive ratio, for formulations with bounded covering frequency. the edge weights. For a subgraph H ⊆ G, we define w(H) := (cid:80) 1.2 Preliminaries Let G = (V, E) be an undirected graph of size n (V = n). Let w : E → Z>0 be a function denoting e∈E(H) w(e). For every vertex v ∈ V , let bv ∈ Z>0 denote the degree bound of v. Let degH (v) denote the degree of vertex v in subgraph H. We define the load lH (v) of vertex v w.r.t. H as degH (v)/bv. In DB-SF we are given graph G, degree bounds, and k connectivity demands. Let σi denote the i-th demand. The i-th demand is a pair of vertices σi = (si, ti), where si, ti ∈ V . In DB-SF the goal is to find a subgraph H ⊆ G such that for each demand σi, si is connected to ti in H, for every vertex v ∈ V , lH (v) ≤ 1, and w(H) is minimized. In this paper without loss of generality we assume the demand endpoints are distinct vertices with degree one in G and degree bound infinity. In the online variant of the problem, we are given graph G and degree bounds in advance. However the sequence of demands are given one by one. At arrival of demand σi, we are asked to provide a subgraph Hi, such that Hi−1 ⊆ Hi and si is connected to ti in Hi. The following integer program is a natural mixed packing and covering integer program for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. Let S denote the collection of subsets of vertices that separate the endpoints of at least one demand. For a set of vertices S, let δ(S) denote the set of edges with exactly one endpoint in S. In SF IP, for an edge e, xe = 1 indicates that we include e in the solution while xe = 0 indicates otherwise. The variable α indicates an upper bound on the violation of the load of every vertex and an upper bound on the violation of the weight. The first set of constraints ensures that the load of a vertex is upper bounded by α. The second constraint ensures that the violation for 5 the weight is upper bounded by α. The third set of constraints ensures that the endpoints of every demand are connected. minimize α . ∀v ∈ V 1 bv (cid:88) (cid:88) e∈δ({v}) xe ≤ α . w(e)xe ≤ α . 1 wopt ∀S ⊆ S (cid:88) e∈E xe ≥ 1 . e∈δ(S) xe ∈ {0, 1}, α ∈ Z>0 . (SF IP) (1) (2) (3) 1.3 Overview of the Paper We begin Section 2 by providing an online bounded frequency mixed packing/covering IP for EW-DB-SF. Further we prove that this formulation has plausible structures. In Section 3 we provide an online deter- ministic algorithm for online bounded frequency mixed packing/covering IPs. In Section 4 we merge the IP formulation in Section 2 and the techniques in Section 3 to obtain online polylogarithmic-competitive algorithms for EW-DB-SF. Finally in Section A we complement our algorithm for online bounded fre- quency mixed packing/covering IPs by providing a matching lower bound for the competitive ratio of any randomized algorithm. 2 Finding the Right Integer Program i.e. any f−approximation for this formulation, to be a set of i edges, connecting the endpoints of the first i demands. In particular Rσ(i) :=(cid:83)i In this section we design an online mixed packing and covering integer program for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. We show this formulation is near implies an O(f log2 n)-approximation for optimal, ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. In Section 4 we show there exists an online algorithm that finds an O(log3 n)-approximation of wopt and violates degree bounds by O(log3 n log wopt), where wopt denotes the optimal weight. First we define some notations. For a sequence of demands σ = (cid:104)(s1, t1), . . . , (sk, tk)(cid:105), we define Rσ(i) j=1 e(sj, tj), where e(sj, tj) denotes a direct edge from sj to tj. Moreover, we say subgraph Hi satisfies the connectivity of demand σi = (si, ti), if si and ti are connected in graph Hi ∪ Rσ(i − 1). Let Hi denote the set of In PC IP variable α denotes the violation in all subgraphs that satisfy the connectivity of demand σi. the packing constraints. Furthermore for every subgraph H ⊆ G and demand σi, there exists a variable H ∈ {0, 1}. xi H = 1 indicates we add the edges of H to the existing solution, at arrival of demand σi. The xi first set of constraints ensure the degree-bounds are not violated more than α. The second constraint ensures the weight is not violated by more than α. The third set of constraints ensure the endpoints of every demand are connected. 6 minimize α . ∀v ∈ V degH (v)xi H ≤ α . ∀σi ∀H ⊆ G, 1 ≤ i ≤ k i=1 H⊆G 1 bv k(cid:88) (cid:88) (cid:88) k(cid:88) (cid:88) H⊆G i=1 H ≥ 1 . xi H∈Hi H ∈ {0, 1} . xi α > 0 . 1 wopt w(H)xi H ≤ α . (PC IP) (4) (5) (6) We are considering the online variant of the mixed packing and covering program. We are given the packing Constraints (4) and (5) in advance. At arrival of demand σi, the corresponding covering Constraint (6) is added to the program. We are looking for an online solution which is feasible at every online stage. Moreover the variables xH should be monotonic, i.e. once an algorithm sets xH = 1 for some H, the value of xH is 1 during the rest of the algorithm. Figure (1) illustrates an example which indicates the difference between the solutions of PC IP and SF IP. Figure 1: An example where every vertex has degree-bound 3 and every edge has weight 1. The first demand is (v2, v5) and the second demand is (v3, v6). The optimal solution for SF IP is a subgraph, say H, with the set of all edges and vertices, i.e. H = G. However an optimal solution for PC IP is: Two subgraphs H1 for the first request which has edges {e(v1, v2), e(v1, v4), e(v4, v5)} and H2 for the second request which has edges {e(v2, v3), e(v4, v5), e(v4, v6)}. Note that w(H) = 5 and w(H1) + w(H2) = 6, since we have edge e(v4, v5) in both H1 and H2. Moreover the number of edges incident with v4 in the solution of PC IP is 4, i.e. degH1(v4) + degH2(v4) = 4. Let optIP and optSF denote the optimal solutions for PC IP and SF IP, respectively. Lemma 2.1 shows given an online solution for PC IP we can provide a feasible online solution for SF IP of cost optIP. Lemma 2.1 Given a feasible solution {x, α} for PC IP, there exists a feasible solution {x(cid:48), α} for SF IP. In the rest of this section, we show that we do not lose much by changing SF IP to PC IP. In particular Lemma G.1 shows optIP ≤ O(log2 n)optSF. To this end, we first define the connective list of subgraphs for a graph G, a forest F , and a list of demands σ. We then prove an existential lemma for such a list of subgraphs with a desirable property for any (cid:104)G, F, σ(cid:105). With that in hand, we prove optIP ≤ O(log n)optSF in Lemma G.1. 7 v1v2v4t2: v6t1: v5s1:s2: v3 Given a graph G, a list of demands σ = (cid:104)(s1, t1), (s2, t2) . . . , (sk, tk)(cid:105), and a forest of G, F we define a connective list of subgraphs for (cid:104)G, F, σ(cid:105) in the following way: Definition 2.2 Let Q = (cid:104)Q1, Q2, Q3, . . . , Qk(cid:105) be a list of k subgraphs of F . We say Q is a connective list of subgraphs for (cid:104)G, F, σ(cid:105) iff for every 1 ≤ i ≤ k there exists no cut disjoint from Qi that separates si from ti, but does not separate any sj from tj for j < i. The intuition behind the definition of connective subgraphs is the following: If Q is a connective list of subgraphs for an instance (cid:104)G, F, σ(cid:105) then for every i we are guaranteed that the union of all subgraphs ∪i In Lemma 2.3 we show for every (cid:104)G, F, σ(cid:105), there exists a connective list of j=1Qi connects si to ti. subgraphs for (cid:104)G, F, σ(cid:105), such that each edge of F appears in at most O(log n) subgraphs of Q. Lemma 2.3 Let G be a graph and F be a forest If σ is a collection of k demands (cid:104)(s1, t1), (s2, t2) . . . , (sk, tk)(cid:105), then there exists a connective list of subgraphs Q = (cid:104)Q1, Q2, . . . , Qk(cid:105) for (cid:104)G, F, σ(cid:105) such that every edge of F appears in at most 3 log V (F ) Qi's. in G. Finally, we leverage Lemma 2.3 to show optIP ≤ O(log n)optSF. Lemma 2.4 optIP ≤ O(log n)optSF. Finally, we leverage Lemma 2.3 to show optIP ≤ O(log2 n)optSF. Lemma 2.5 optIP ≤ O(log2 n)optSF. This shows we can use PC IP as an online mixed packing/covering IP to obtain an online solution for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST losing a factor of O(log2 n). In Section 4 we show this formulation is an online bounded frequency mixed packing/covering IP, thus we leverage our technique for such IPs to obtain a polylogarithmic-competitive algorithm for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. 3 Online Bounded Frequency Mixed Packing/Covering IPs In this section we consider bounded frequency online mixed packing and covering integer programs. For every online mixed packing and covering IP with covering frequency k, we provide an online algorithm that violates each packing constraint by at most a factor of O(k log m), where m is the number of packing constraints. We note that this bound is independent of the number of variables, the number of covering constraints, and the coefficients of the mixed packing and covering program. Moreover the algorithm is for integer programs, which implies obtaining an integer solution does not rely on (online) rounding. In particular we prove there exists an online O(k log m)-competitive algorithm for any mixed packing and covering IP such that every variable has covering frequency at most k, where the covering frequency of a variable xr is the number of covering constraints with a non-zero coefficient for xr. We assume that all variables are binary. One can see this is without loss of generality as long as we know every variable xr ∈ {1, 2, 3, . . . , 2l}. Since we can replace xr by l variables y1 r denoting the digits of xr and adjust coefficients accordingly. Furthermore, for now we assume that the optimal solution for the given mixed packing and covering program is 1. In Theorem 3.3 we prove that we can use a doubling technique to provide an O(k log m)-competitive solution for online bounded frequency mixed packing and covering programs with any optimal solution. The algorithm is as follows. We maintain a family of subsets S. Initially S = ∅. Let S(j) denote S at arrival of Cj+1. For each covering constraint Cj+1, we find a subset of variables Sj+1 and add Sj+1 to S. We find Sj+1 in the following way. For each set of variables S, we define a cost function τS(S(j)) according to our current S at arrival of Cj+1. We find a set Sj+1 that satisfies Cj+1 and minimizes τS(S(j)). More precisely we say a set of variables S satisfies Cj+1 if r , . . . , yl 8 • (cid:80) • For each packing constraint Pi,(cid:80) xr∈S 1 k Pir ≤ 1. xr∈S Cj+1,rxr ≥ 1, where Cj+1,r denotes the coefficient of Cj+1 for xr. Now we add Sj+1 to S and for every xr ∈ Sj+1, we set xr = 1. We note that there always exists a set S that satisfies Cj+1, since we assume there exists an optimal solution with value 1. Setting S to be the set of all variables with value one in an optimal solution which have non-zero coefficient in Cj+1, satisfies Cj+1. It only remains to define τS(S(j)). But before that we need to define ∆i(S) and Fi(S(j)). For packing k Pir. For packing constraint Pi and S(j), let constraint Pi and subset of variables S, we define ∆i(S) as ∆i(S) :=(cid:80) Now let τS(S(j)) =(cid:80)m i=1 ρFi(S(j))+∆i(S) − ρFi(S(j)), where ρ > 1 is a constant to be defined later. Fi(S(j)) := (cid:88) ∆i(S) . S∈S(j) xr∈S 1 Algorithm 1 Input: Packing constraints P , and an online stream of covering constraints C1, C2, . . .. Output: A feasible solution for online bounded frequency mixed packing/covering. Offline Process: 1: Initialize S ← ∅. Online Scheme; assuming a covering constraint Cj+1 is arrived: 1: Sj+1 ← arg minS{τS(S(j)) S satisfies Cj+1}. 2: for all xr ∈ Sj+1 do 3: xr ← 1. Let x∗ be an optimal solution, and x∗(j) denote its values at online stage j. We define Gi(j) as j(cid:88) (cid:88) l=1 r:Clr>0 x∗ rPir . 1 k Gi(j) := m(cid:88) Now we define a potential function Φj for online stage j. Φj = ρFi(S(j))(γ − Gi(j)) , i=1 where ρ, γ > 1 are constants to be defined later. Lemma 3.1 There exist constants ρ and γ, such that Φj is non-increasing. Proof. We find ρ and γ such that Φj+1 − Φj ≤ 0. By the definition of Φj, (7) (8) (9) (10) ρFi(S(j+1))(γ − Gi(j + 1)) − ρFi(S(j))(γ − Gi(j)) . Φj+1 − Φj = m(cid:88) Gi(j + 1)) − (γ − Gi(j)) = −(cid:80) (cid:80) m(cid:88) k x∗ Φj+1 − Φj = r:Cj+1,r>0 i=1 1 By Equation (7), ρFi(S(j+1)) − ρFi(S(j)) = ρFi(S(j))+∆i(S) − ρFi(S(j)). Moreover by Equation (8), (γ − rPir. For simplicity of notation we define Bi(j + 1) := 1 k x∗ r:Cj+1,r>0 rPir. Thus we can write Equation (10) as: ρFi(S(j+1))(γ − Gi(j) − Bi(j + 1)) − ρFi(S(j))(γ − Gi(j)) (11) i=1 9 Since Gi(j) ≥ 0 Fi(S(j + 1)) ≥ Fi(S(j)) = i=1 i=1 i=1 γ(ρFi(S(j))+∆i(S) − ρFi(S(j))) − ρFi(S(j))Bi(j + 1) . γ(ρFi(S(j))+∆i(S) − ρFi(S(j))) − ρFi(S(j+1))Bi(j + 1) (γ − Gi(j))(ρFi(S(j))+∆i(S) − ρFi(S(j))) − ρFi(S(j+1))Bi(j + 1) m(cid:88) ≤ m(cid:88) ≤ m(cid:88) Now according to the algorithm for each subset of variables S(cid:48) such that(cid:80) (cid:80)m i=1 ρFi(S(j))+∆i(S)−ρFi(S(j)) ≤(cid:80)m Φj+1 − Φj ≤ m(cid:88) m(cid:88) ρFi(S(j))(γρBi(j+1) − γ − Bi(j + 1)) . (11) as i=1 = xr∈S(cid:48) Cj+1(xr) ≥ 1, either τS(S(j)) ≤ τS(cid:48)(S(j)) or there exists a packing constraint Pi such that ∆i(S(cid:48)) > 1. In Bi(j + 1), we e = 1, thus for every Pi, Bi(j + 1) ≤ 1. Therefore setting S(cid:48) are considering variables xr such that x∗ r = 1 and Cj+1,r > 0, we have τS(S(j)) ≤ τS(cid:48)(S(j)). Thus to be the set of variables xr such that x∗ i=1 ρFi(S(j))+Bi(j+1)−ρFi(S(j)). Therefore we can rewrite Inequality γ(ρFi(S(j))+Bi(j+1) − ρFi(S(j))) − ρFi(S(j))Bi(j + 1) (12) i=1 We would like to find ρ and γ such that Φj is non-increasing. We find ρ and γ such that for each packing constraint Pi, γρBi(j+1) − γ − Bi(j + 1) ≤ 0. Thus γρBi(j+1) − γ ≤ Bi(j + 1) γρBi(j + 1) − γ ≤ Bi(j + 1) ρ ≤ 1 + 1/γ . Since 0 ≤ Bi(j + 1) ≤ 1 By simplifying Thus if we set ρ ≤ 1 + 1/γ, Φj is non-increasing, as desired. Now we prove Algorithm 1 obtains a solution of at most O(k log m). (13) (14) (15) (cid:3) Lemma 3.2 Given an online bounded frequency mixed packing covering IP with optimal value 1, there ex- ists a deterministic integral algorithm with competitive ratio O(k log m), where m is the number of packing constraints and k is the covering frequency of the IP. Proof. By Lemma 3.1 for each stage j, Φj+1 ≤ Φj. Therefore Φj ≤ Φ0 = γm. Thus for each packing constraint Pi, ρFi(S(j))(γ − Gi(j)) ≤ γm . (16) Thus, ρFi(S(j)) ≤ γm (γ − Gi(j)) ≤ γm γ − 1 . Since Gi(j) ≤ 1 (17) Thus we can conclude By definition of Fi(S(j)), Fi(S(j)) =(cid:80) S∈S(j) ∆i(S) =(cid:80) Fi(S(j)) ∈ O(log m) . S∈S(j) (18) k Pir. Since each variable xr is k Pi · x(j) ≤ Fi(S(j)) . Thus by Inequality (18) Pix(j) ∈ O(k log m), which (cid:3) (cid:80) xr∈S present in at most k sets, 1 completes the proof. 1 10 In Theorem 3.3 we prove there exists an online O(k log m)-competitive algorithm for bounded fre- quency online mixed packing and covering integer programs with any optimal value. Theorem 3.3 Given an instance of the online mixed packing/covering IP, there exists a deterministic inte- gral algorithm with competitive ratio O(k log m), where m is the number of packing constraints and k is the covering frequency of the IP. 4 Putting Everything Together the online mixed packing/covering formulation discussed in Sec- In this section we consider tion 2 for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST PC IP. In this section we show this formulation is an online bounded frequency mixed packing/covering IP. Therefore we our techniques discussed in Section 3 to obtain a polylogarithmic-competitive algorithm for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. First we assume we are given the optimal weight wopt as well as degree bounds. We can obtain the following theorem. Theorem 4.1 Given the optimal weight wopt, there exists an online deterministic algorithm which finds a subgraph with total weight at most O(log3 n)wopt while the degree bound of a vertex is violated by at most a factor of O(log3(n). Proof. By Lemma 2.1, given a feasible online solution for PC IP with violation α, we can provide an online solution for SF IP with violation α. Moreover by Lemma G.1, optIP ≤ O(log2 n)optSF. Thus given an online solution for PC IP with competitive ratio f, there exists an O(f log n)-competitive algorithm for ONLINE DEGREE-BOUNDED STEINER FOREST. We note that in PC IP we know the packing constraints H has non-zero coefficient only in the covering constraint corre- in advance. In addition every variable xi sponding to connectivity of the i-th demand endpoints, i.e. the covering frequency of every variable is 1. Therefore by Theorem 3.3 there exists an online O(log m)-competitive solution for PC IP, where m is the number of packing constraints, which is n + 1. Thus there exists an online O(log3 n)-competitive algorithm for ONLINE DEGREE-BOUNDED STEINER FOREST. This means the violation for both degree bounds and (cid:3) weight is of O(log3 n). Now we assume we are not given wopt. The following theorems directly hold by applying the doubling technique mentioned in Section D. Theorem 4.2 There exists an online deterministic algorithm which finds a subgraph with total weight at most O(log3 n)wopt while the degree bound of a vertex is violated by at most a factor of O(log3(n) log(wopt)). Moreover if one favors the degree bound over total weight we obtain the following bounds. Theorem 4.3 There exists an online deterministic algorithm which finds a subgraph with total weight at most O(log3 n log wopt )wopt while the degree bound of a vertex is violated by at most a factor of log log wopt O(log3 n log wopt ). log log wopt 11 References [1] A. Agrawal, P. N. Klein, and R. Ravi. How tough is the minimum-degree steiner tree?: A new approx- imate min-max equality. Technical Report CS-91-49, Brown University, 1991. [2] N. Alon, B. Awerbuch, Y. Azar, N. Buchbinder, and J. Naor. The online set cover problem. SIAM Journal on Computing, 39(2):361 -- 370, 2009. [3] J. Aspnes, Y. Azar, A. Fiat, S. Plotkin, and O. Waarts. On-line routing of virtual circuits with ap- plications to load balancing and machine scheduling. Journal of the ACM (JACM), 44(3):486 -- 504, 1997. [4] B. Awerbuch, Y. Azar, and Y. Bartal. On-line generalized steiner problem. In Proceedings of the seventh annual ACM-SIAM symposium on Discrete algorithms, pages 68 -- 74, 1996. [5] Y. Azar, U. Bhaskar, L. Fleischer, and D. Panigrahi. Online mixed packing and covering. In Pro- ceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 85 -- 100. SIAM, 2013. [6] F. Bauer and A. Varma. Degree-constrained multicasting in point-to-point networks. In INFOCOM'95. Fourteenth Annual Joint Conference of the IEEE Computer and Communications Societies. Bringing Information to People. Proceedings. IEEE, pages 369 -- 376. IEEE, 1995. [7] P. Berman and C. Coulston. On-line algorithms for steiner tree problems. In Proceedings of the twenty-ninth annual ACM symposium on Theory of computing, pages 344 -- 353, 1997. [8] N. Buchbinder and J. Naor. The design of competitive online algorithms via a primal: dual approach. Foundations and Trends R(cid:13) in Theoretical Computer Science, 3(2 -- 3):93 -- 263, 2009. [9] D. Chakrabarty, A. Ene, R. Krishnaswamy, and D. Panigrahi. Online buy-at-bulk network design. In FOCS, 2015. [10] K. Chaudhuri, S. Rao, S. Riesenfeld, and K. Talwar. A push-relabel algorithm for approximating degree bounded msts. In Proceedings of the 33rd international conference on Automata, Languages and Programming-Volume Part I, pages 191 -- 201. Springer-Verlag, 2006. [11] K. Chaudhuri, S. Rao, S. Riesenfeld, and K. Talwar. What would edmonds do? augmenting paths and witnesses for degree-bounded msts. Algorithmica, 55(1):157 -- 189, 2009. [12] S. Dehghani, S. Ehsani, M. Hajiaghayi, and V. Liaghat. Online degree-bounded steiner network design. In SODA, 2016. [13] A. Ene and A. Vakilian. Improved approximation algorithms for degree-bounded network design problems with node connectivity requirements. STOC, 2014. [14] A. Ene and A. Vakilian. Improved approximation algorithms for degree-bounded network design problems with node connectivity requirements. In Proceedings of the 46th Annual ACM Symposium on Theory of Computing, pages 754 -- 763. ACM, 2014. [15] T. Fukunaga and R. Ravi. Iterative rounding approximation algorithms for degree-bounded node- connectivity network design. In Foundations of Computer Science (FOCS), 2012 IEEE 53rd Annual Symposium on, pages 263 -- 272. IEEE, 2012. 12 [16] M. Furer and B. Raghavachari. An NC approximation algorithm for the minimum degree spanning tree problem. In Allerton Conf. on Communication, Control and Computing, pages 274 -- 281, 1990. [17] M. Furer and B. Raghavachari. Approximating the minimum-degree steiner tree to within one of optimal. Journal of Algorithms, 17(3):409 -- 423, 1994. [18] M. X. Goemans. Minimum bounded degree spanning trees. In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE Symposium on, pages 273 -- 282. IEEE, 2006. [19] M. X. Goemans. Minimum bounded degree spanning trees. In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE Symposium on, pages 273 -- 282, 2006. [20] M. Hajiaghayi, V. Liaghat, and D. Panigrahi. Near-optimal online algorithms for prize-collecting steiner problems. In Automata, Languages, and Programming, pages 576 -- 587. 2014. [21] M. T. Hajiaghayi, V. Liaghat, and D. Panigrahi. Online node-weighted steiner forest and extensions via disk paintings. In Foundations of Computer Science (FOCS), 2013 IEEE 54th Annual Symposium on, pages 558 -- 567, 2013. [22] M. Imase and B. M. Waxman. Dynamic Steiner tree problem. SIAM Journal on Discrete Mathematics, 4(3):369 -- 384, 1991. [23] R. Khandekar, G. Kortsarz, and Z. Nutov. On some network design problems with degree constraints. Journal of Computer and System Sciences, 79(5):725 -- 736, 2013. [24] P. N. Klein, R. Krishnan, B. Raghavachari, and R. Ravi. Approximation algorithms for finding low- degree subgraphs. Networks, 44(3):203 -- 215, 2004. [25] J. Konemann and R. Ravi. A matter of degree: Improved approximation algorithms for degree-bounded minimum spanning trees. In Proceedings of the thirty-second annual ACM symposium on Theory of computing, pages 537 -- 546. ACM, 2000. [26] J. Konemann and R. Ravi. Primal-dual meets local search: approximating mst's with nonuniform degree bounds. In Proceedings of the thirty-fifth annual ACM symposium on Theory of computing, pages 389 -- 395. ACM, 2003. [27] L. C. Lau, J. Naor, M. R. Salavatipour, and M. Singh. Survivable network design with degree or order constraints. SIAM Journal on Computing, 39(3):1062 -- 1087, 2009. [28] L. C. Lau and M. Singh. Additive approximation for bounded degree survivable network design. SIAM Journal on Computing, 42(6):2217 -- 2242, 2013. [29] M. V. Marathe, R. Ravi, R. Sundaram, S. Ravi, D. J. Rosenkrantz, and H. B. Hunt III. Bicriteria network design problems. Journal of Algorithms, 28(1):142 -- 171, 1998. [30] R. G. Michael and S. J. David. Computers and intractability: a guide to the theory of np-completeness. WH Freeman & Co., San Francisco, 1979. [31] J. Naor, D. Panigrahi, and M. Singh. Online node-weighted steiner tree and related problems. In Foundations of Computer Science (FOCS), 2011 IEEE 52nd Annual Symposium on, pages 210 -- 219, 2011. 13 [32] Z. Nutov. Degree-constrained node-connectivity. 582 -- 593. 2012. In LATIN 2012: Theoretical Informatics, pages [33] C. A. Oliveira and P. M. Pardalos. A survey of combinatorial optimization problems in multicast routing. Computers & Operations Research, 32(8):1953 -- 1981, 2005. [34] J. Qian and D. P. Williamson. An o (logn)-competitive algorithm for online constrained forest prob- lems. In Automata, Languages and Programming, pages 37 -- 48. 2011. [35] B. Raghavachari. Algorithms for finding low degree structures. NP-hard problems, pages 266 -- 295. PWS Publishing Co., 1996. In Approximation algorithms for [36] R. Ravi, M. V. Marathe, S. Ravi, D. J. Rosenkrantz, and H. B. Hunt III. Approximation algorithms for degree-constrained minimum-cost network-design problems. Algorithmica, 31(1):58 -- 78, 2001. [37] R. Ravi and M. Singh. Delegate and conquer: An lp-based approximation algorithm for minimum degree msts. In Automata, Languages and Programming, pages 169 -- 180. Springer, 2006. [38] M. Singh and L. C. Lau. Approximating minimum bounded degree spanning trees to within one of optimal. In Proceedings of the thirty-ninth annual ACM symposium on Theory of computing, pages 661 -- 670, 2007. [39] S. Voss. Problems with generalized steiner problems. Algorithmica, 7(1):333 -- 335, 1992. 14 A Lower Bound We present a (randomized) instance I for mixed packing and covering linear programs with the following parameters. I consists of m packing constraints, (2m − 2)d variables and a variable is only contained in log2 d covering constraints. There exists an optimum integral solution for I with violation α = 1. Any (fractional) online algorithm A incurs an expected violation of at least Ω(log2 m · log2 d), where the expectation is w.r.t. the randomized construction of I and w.r.t. the random choices of A in case A uses randomization. This gives Theorem 1.3. For the following description of the instance we assume that m and d are powers of 2. Consider a binary tree T with m leaf nodes. For each edge e in this tree we introduce d variables, and we denote the set of variables x ≤ α, where for edge e with Xe. For each leaf node v we introduce the packing constraint(cid:80) (cid:80) e∈Pv x∈Xe Pv denotes the path from the root r to v in the tree. The covering constraints are constructed in an online manner according to a random root-to-leaf path P(cid:96) in the tree ((cid:96) is a random leaf node). For a non-leaf node v on this path (starting at the root and ending at the parent of (cid:96)) we construct log2 d covering constraint only involving variables from XeL ∪ XeR, where eL and eR denote the child-edges of v. This sequence of covering constraints is constructed according to the following lemma. For a set X of variables we use w(X) to denote the total value assigned to these variables by the online algorithm. Lemma A.1 Given two sets XL and XR of variables, each of cardinality d. There is a randomized sequence of log2 d covering constraints over variables from XL ∪ XR such that any online algorithm has E[w(XL ∪ XR)] ≥ 1 Furthermore, there exist variables x(cid:96) ∈ XL, xr ∈ XR such that setting either of these variables to one 2 log2 d, after fulfilling these constraints. constraint(cid:80) already fulfills all constraints. Proof. Define AL ⊆ XL and AR ⊆ XR, as a set of active variables of XL and XR, respectively. Initially all variables in XL and XR are active, i.e., AL = XL and AR = XR. The constraints are constructed in log2 d rounds. In the beginning of the i-th round (i ∈ {0, . . . , log2 d− 1}) AL = AR = d/2i. We offer a covering constraint on the current set of active variables, i.e., we offer x ≥ 1. Then we remove 50% of the elements from AL, and 50% of the elements from AR, at random, i.e., from each set we remove a random subset of cardinality d/2i+1. After fulfilling the covering constraint for the i-th round, we have w(AL) + w(AR) ≥ 1. Removing ran- dom subsets from AL and AR, removes variables of expected total weight at least w(AL)/2 + w(AR)/2 ≥ 1/2. Hence, the total expected weight removed from active sets during all rounds is at least 1/2 · log2 d. This gives the bound on the expected weight of variables. x +(cid:80) x∈AR x∈AL Note that any variable that is active in the final round is contained in every constraint; setting any of these variables to one fulfills all constraints. Since, neither AL nor AR is empty in the final round the lemma (cid:3) follows. For the online algorithm we show that E[(cid:80) Note that by this construction an optimal offline algorithm can fulfill the covering constraints of a node v by setting a single variable from set Xe to 1, where e is the child-edge of v that is not on the path P(cid:96). Then, along any root-to-leaf path at most one set Xe contains a variable that is set to 1, and, hence, the maximum violation is α = 1. 4 (log2 m − 1) · log2 d, which means that in expectation the maximum violation is at least Ω(log m · log d). To see this, we represent the path P(cid:96) by a sequence of left-right decisions. For i = 1, . . . , log2 m − 1 define the binary random variable Yi that is 1 if to denote the at the i-th node the path P(cid:96) continues left, and is 0 otherwise. Further, we use W L w(Xe)] ≥ 1 e∈P(cid:96) i and W R i 15 random variable that describes the total weight assigned to variables in XeL and XeR, respectively, where eL and eR, are the child-edges of the i-th node on path P(cid:96). Then, E w(Xe) = E Yi · W L i + (1 − Yi) · W R i = E[Yi] · E[W L i ] + E[1 − Yi] · E[W R i ] (cid:34)(cid:88) e∈P(cid:96) (cid:35) (cid:34) log2 m−1(cid:88) log2 m−1(cid:88) i=1 (cid:35) log2 m−1(cid:88) i=1 (log2 m − 1) log2 d . = i=1 1 2 E[W L i + W R i ] ≥ 1 4 Here, the second equality follows as Yi is independent from W L Lemma A.1. i and W R i ; the last inequality holds due to B Omitted Proofs of Section 2 Proof of Lemma 2.1: Let (α, x) be an optimal solution of SF IP for a given graph G and a sequence of demands σ. We define subgraph F as the union of all edges of G whose value in x is equal to 1. Since constraints of type (1) ensure that the demands are satisfied, every pair (si, ti) is connected in F . Without loss of generality we assume F is a forest, since otherwise removing any edge from a cycle of F provides a better solution for SF IP which contradicts the optimality of (α, x). Now, according to Lemma 2.3, there exists a connective list of subgraphs Q for (cid:104)G, F, σ(cid:105) such that every edge of F appears in at most 3 log2 n subgraphs of Q where n is the size of the graph. We construct a solution (α(cid:48), x(cid:48)) to PC IP in the following way: j=1Qj. Therefore, for every i, Qi ∈ Hi holds. We set α(cid:48) = (3 log2 n)α, x(cid:48)i H = 0 for all other variables. Note that since Qi ∈ Hi for all i, then constraints of type (6) are trivially satisfied. H. Since every edge of F appears in at most 3 log2 n subgraphs of Q and x is a feasible solution for SF IP, for every vertex v in V (G) we have Since Q is a connective list of subgraphs for (cid:104)G, F, σ(cid:105), every demand (si, ti) is connected in ∪i = 1 for every 1 ≤ i ≤ k, and x(cid:48)i We define xe for an edge e ∈ E(G) as xe =(cid:80)k i=1 Qi k(cid:88) (cid:88) i=1 H⊆G 1 bv degH (v)x(cid:48)i H = (cid:80) H(cid:51)e x(cid:48)i (cid:88) 1 bv xe e∈δ(v) ≤ (3 log2 n) 1 bv ≤ (3 log2 n)α = α(cid:48) (cid:88) e∈δ(v) xe w(e)xe (cid:88) (cid:88) e∈E(G) 1 w(opt) e∈E(G) w(e) ≤ (3 log2 n) ≤ (3 log2 n)α = α(cid:48) and thus all constraints of type (4) are satisfied by x(cid:48). Moreover, k(cid:88) (cid:88) 1 w(opt) i=1 H⊆G w(H)x(cid:48)i H = 1 w(opt) and hence x(cid:48) meets Constraint (5). Thus, x(cid:48) is a feasible solution for PC IP and the proof is complete. 16 C Omitted Proofs of Section 3 Proof of Theorem 3.3: By Lemma 3.2, if the optimal solution of the IP is 1, then there exists a deterministic algorithm with competitive ratio O(k log m). We show one can use a doubling technique to obtain an O(k log m)-competitive algorithm without such assumption. We start by guessing α = 1. We use Algorithm 1 to find an online solution. Since Algorithm 1 is O(k log m)-competitive if α = 1, there exists a constant β such that no packing constraint is violated by more than β(k log m). At each online stage j if updating the solution violates a packing constraint by more than β(k log m), then α > 1. Thus we say we go to the next phase and do the following. First we divide every coefficient in packing constraints by 2. Note that this is equivalent to doubling α. Then we remove all previous solutions of the algorithm (we basically ignore them). We use Algorithm 1 again on the new IP from the beginning. We claim that we lose a factor of at most 4 due to these updates. At each phase every packing constraint is violated by at most βk log m. The total violation of each packing constraint after l phases is l(cid:88) β2i−1k log m ≤ β2ik log m . (19) i=1 Moreover our guess about α is not exact, since we know 2i−1 < α ≤ 2i. Thus we might violate each packing constraint by an additional factor of 2. Thus we can use Algorithm 1 to obtain a deterministic integral algorithm with competitive ratio 4β(k log m). D Doubling Method opt be our guess for wopt. Initially we set w(cid:48) More precisely, let w(cid:48) opt and use Algorithm PC IP to obtain online solution x. By Lemma 3.2 if w(cid:48) In this section we discuss how we can address the issue that we might not know wopt in advance. In partic- ular by Lemma 3.2 if we are given the degree bounds and wopt, the optimal solution for PC IP is 1. Thus Algorithm 1 provides an online solution for PC IP of O(log m), where m is the number of packing con- straints. We show we can start with an initial value for wopt and update it through several phases. We use Algorithm 1 at each phase. Eventually we lose a factor because of the number of phases we run Algorithm 1 and a factor of our approximation for wopt. opt = 1. We write PC IP according opt ≤ wopt, there exists a to w(cid:48) constant c such that every packing constraint is violated by a factor of at most c log m in solution x. At any online step, if a packing constraint is going to be violated by more that c log m, we stop the algorithm. Now opt × r. We ignore the current solution x. We write PC IP we know w(cid:48) by the updated value of w(cid:48) opt and do the same until no packing constraint is violated by more than c log m. Now we analyze the competitive ratio of the current solution. Let l denote the number of phases we updated w(cid:48) Lemma D.1 If r ≥ 2 each degree constraint is violated by O(l log m), and the weight constraint is violated by O(r log m), where m is the number of packing constraints. opt > wopt, thus we update w(cid:48) opt and run Algorithm 1. opt = w(cid:48) Proof. Since at each phase no packing constraint is violated by more than c log m, the total violation for every packing constraint is no more than lc log m. Thus the total violation in every degree bound is O(l log m). At each phase, the packing constraint corresponding to weights is violated by c log m, however w(cid:48) changing as well. The total violation of the weights is(cid:80)l−1 i=0 ric log m, since at each phase i, w(cid:48) opt is opt = ri−1. 17 Since r ≥ 2,(cid:80)l−1 i=0 ric log m < 2rl−1 = 2w(cid:48) is also violated by no more than 2c log m. However 1 than 2rc log mwopt. r w(cid:48) opt. Therefore the packing constraint corresponding to weights opt. Thus the total weight is no more (cid:3) opt < wopt ≤ w(cid:48) The following two lemmas follow directly from Lemma D.1. Lemma D.2 Given graph G and degree bounds. for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. There exists an online algorithm for PC IP that violates the weight packing constraint by O(log n) and violates each degree bound packing constraints by O(log n log wopt). Proof. Let r = 2. The number of phases l = O(log wopt). Thus by Lemma D.1 there exists an online algorithm for PC IP that violates the weight packing constraint by O(log n) and violates each degree bound (cid:3) packing constraints by O(log n log wopt). let wopt denote the optimal weight Lemma D.3 Given graph G and degree bounds. for ONLINE EDGE-WEIGHTED DEGREE-BOUNDED STEINER FOREST. There exists an online algorithm for PC IP that violates the weight packing constraint and each degree bound packing constraints by O(log n log wopt log log wopt let wopt denote the optimal weight ). Proof. Let r = log wopt ). Thus by Lemma D.1 there exists log log wopt an online algorithm for PC IP that violates the weight packing constraint and each degree bound packing (cid:3) constraints by O(log n log wopt log log wopt . The number of phases l = O( log wopt log log wopt ). E A Polynomial Algorithm for Finding the Path with the Minimum Cost Here we present a polynomial time method to find a set S that satisfies j + 1-th constraint and minimizes τS(S(j)). In our problem we can assume every two endpoints of previous demands have been contracted into one node. With this assumption the set S is in form of a path from sj to tj. The method we use is dynamic programming. Let dp be a dynamic table such that dp(l, v, w) denotes the minimum degree cost of a path with length l < n and weight w from sj to vertex v ∈ V . The degree cost of a path P is the sum of the terms corresponding to degree constraints in the calculation of τP (S(j)). The set S we are looking for has some length l(cid:48) and some weight w(cid:48). Knowing these two parameters, we can calculate τS(S(j)) using w(cid:48) and dp(l(cid:48), tj, w(cid:48)). If the maximum weight of an edge be a polynomial of n then the number of entries in the dynamic table dp is polynomial. Now we briefly explain how to calculate the value of each dp(l, v, w). Initially set dp(0, sj, 0) to zero and dp(l, v, w) to infinity for other entries. At every moment each entry with cost less than infinity represents a path from sj. At every iteration we update new entries by adding one vertex to the existing paths. We can now find the path minimizing τS(S(j)) by looking over dp(l(cid:48), tj, w(cid:48)), for all 0 ≤ l(cid:48) ≤ n and 0 ≤ w(cid:48) ≤ n maxe∈E{w(e)}. Since the size of dp and the number of iterations are polynomials of n, the whole method runs in polynomial time. F Rounding Lemma For a given tree T = (E(T ), V (T )), let π = (cid:104)π1, . . . , πn(cid:105) be a permutation on V (T ), and F be a collection j=1 pπi,πj = 1, of subsets of E(T ). Suppose a probability pπi,πj is assigned to every Fπi,πj in a way that(cid:80)i−1 18 (i,j):e∈Fπi,πj bounded load with respect to Lp and log n. load Lp as Lp := maxe∈E(t){Lp(e)}. The following lemma states the existence of a rounding q for p, which with a high probability has a for every 1 < i ≤ n. We define the load of p on an edge e as Lp(e) :=(cid:80) Lemma F.1 There exists a new assignment qπi,πj ∈ {0, 1} to every Fπi,πj , such that(cid:80)i−1 index for which(cid:80)j every 1 < i ≤ n, and the new load Lq is at most O(max{Lp, log n}) with a high probability. Proof. For every 1 < i ≤ n we need to set at least one of qπi,π1, . . . , qπi,πi−1 to 1. To do so, we select one of the qπi,πj 's using the following random process. Take a random number r ∈ [0, 1]. Let j be the smallest k=1 pπi,πk ≥ r. Set qπi,πj to 1 and the remaining to 0. Note that the probability of every Using this random process, the expected load of q on every edge e remains the same as the load of p on qπi,πj being 1 is exactly pπi,πj . pπi,πj and the overall j=1 qπi,πj = 1, for that edge, because E[Lq(e)] = E qπi,πj (i,j):e∈Fπi,πj (cid:20) (cid:88) (cid:88) (cid:88) (cid:88) (i,j):e∈Fπi,πj (i,j):e∈Fπi,πj (i,j):e∈Fπi,πj = = = (cid:21) E[qπi,πj ] P r[qπi,πj = 1] pπi,πj = Lp(e) . Moreover, Lq(e) is in fact the summation of a number of binary random variables which are not posi- tively correlated 3. Therefore, this summation can be upper bounded by the Chernoff bound: P r[Lq(e) > (1 + δ)Lp(e)] ≤ e− δLp(e) 3 . In the above variation of the Chernoff bound, δ > 1. Mention that to achieve a small enough probability 4, it suffices for δ to be at least Ω(log n/Lp(e)). Finally, we use the Union bound to show that Lq ∈ O(max{Lp, log n}) with a high probability. P r[Lq ∈ O(max{Lp, log n})] = P r[∀e ∈ E(T ) : Lq(e) ∈ O(max{Lp(e), log n})] = 1 − P r[∃e ∈ E(T ) : Lq(e) /∈ O(max{Lp(e), log n})] e∈E(T ) ≥ 1 − (cid:88) ≥ 1 − (cid:88) ≥ 1 − (cid:88) e∈E(T ) e∈E(T ) P r[Lq(e) /∈ O(max{Lp(e), log n})] (cid:1)Lp(e)] P r[Lq(e) > c(cid:0)1 + n2 ) = 1 − O( O( 1 1 n log n Lp(e) ) . (cid:3) 3In particular, qπi1 4At most O( 1 n2 ). ,πj1 and qπi2 ,πj2 are independent for i1 (cid:54)= i2, and are negatively correlated for i1 = i2 and j1 (cid:54)= j2. 19 G Reduction from weight guarantee to edge-wise guarantee Lemma G.1 Let R be a subspace of Rn that contains all points of Rn with non-negative coordinates and P be a convex set of points in R. If for every point x = (x1, x2, . . . , xn) ∈ R there exists a point p ∈ P such that n(cid:88) i=1 p.x ≤ k xi then P contains a point r such that maxn Proof. We define P (cid:48) as the set of all points in Rn whose all indices are greater than or equal to the corre- sponding indices of a point in P . In other words i=1 ri ≤ k. P (cid:48) = {p ∈ Rn∃q ∈ P such that pi ≥ qi for all 1 ≤ i ≤ n}. We show in the rest that (k, k, . . . , k) ∈ P (cid:48) which immediately implies the lemma. To this end, suppose for the sake of contradiction that (k, k, . . . , k) /∈ P (cid:48). Note that, since P is a convex set, so is P (cid:48). Therefore, there exists a hyperplane that separates all points of P (cid:48) from point (k, k, . . . , k). More precisely, there exist coefficients h0, h1, . . . , hn such that for all points p ∈ P (cid:48) and n(cid:88) n(cid:88) i=1 i=1 hipi > h0 hik < h0. (20) (21) Due to the construction of P (cid:48) we are guaranteed that all coefficients h1, h2, . . . , hn are non-negative numbers since otherwise for any index i such that hi < 0 there exists a point in P (cid:48) whose i'th index is large enough to violate Inequality (20). Now let x = (h1, h2, . . . , hn). By Inequalities (20) and (21) we have n(cid:88) for every p ∈ P (cid:48) which means there is no p ∈ P such that p.x ≤ k(cid:80)n hipi > h0 ≥ k n(cid:88) n(cid:88) xipi = p.x = i=1 i=1 i=1 of the lemma. n(cid:88) i=1 hi = k xi i=1 xi. This contradicts the assumption (cid:3) 20
1708.08377
2
1708
2017-09-17T11:50:50
Two-Dimensional Indirect Binary Search for the Positive One-in-Three Satisfiability Problem
[ "cs.DS", "cs.AI", "cs.CC", "cs.DM", "math.CO" ]
In this paper, we propose an algorithm for the positive one-in-three satisfiability problem (Pos1in3SAT). The proposed algorithm can efficiently decide the existence of a satisfying assignment in all assignments for a given formula by using a 2-dimensional binary search method without constructing an exponential number of assignments.
cs.DS
cs
Two-Dimensional Indirect Binary Search for the Positive One-In-Three Satisfiability Problem Shunichi Matsubara∗ Aoyama Gakuin University, 5-10-1, Fuchinobe, Chuo-ku, Sagamihara, Kanagawa, 252-5258, Japan Abstract In this paper, we propose an algorithm for the positive-one-in-three satisfiability problem (Pos1In3Sat). The proposed algorithm decides the existence of a satisfying assignment in all assignments for a given formula by using a 2-dimensional binary search method without con- structing an exponential number of assignments. 1 Introduction In this paper, we propose an algorithm for the positive-one-in-three satisfia- bility problem (Pos1In3Sat). Pos1In3Sat is known to be NP-complete [3]. We prove that the proposed algorithm can run efficiently. The proposed algorithm decides whether there is a satisfying assignment for a given positive 3CNF formula by using a 2-dimensional version of the binary search method. First, it constructs an equivalent positive 3CNF for- mula for the given formula as the preprocess for the binary search. Then, it encodes all partial assignments to single variables in the constructed positive 3CNF formula. As a result, we obtain a matrix whose components means a truth assignment in the constructed formula. The algorithm does the binary search for that matrix. Every row and column in that matrix are sorted in ascending order. Thus, the algorithm can expectedly do the binary search. Representing all components of the matrix requires an exponential space for the size of the input formula. However, we can use the matrix without constructing all the components. In Section 2, we define some basic concepts and notation. In Section 3, we propose an algorithm for Pos1In3Sat. Then, we prove its validity and analyze its running time. ∗ [email protected] 1 2 Basic concepts and notation In this section, we define basic concepts and notation that are used through- out the paper. We follow convention of literature in theoretical computer science or combinatorics. function on a predicate p; i.e.,(cid:74)p(cid:75) is 1 if p= 1, and 0 otherwise. We denote the empty string by ε. We denote by (cid:74)p(cid:75) a characteristic respectively. Given l, u∈ N, we denote the interval{i∈ N∶ l≤ i≤ u} by[l, u]. We denote the sets of all nonnegative and positive integers by N and N+, Given l, u∈ N and f∶ N→ N, if l> u, then we consider∑u x=l f(x) to be 0. Let Φ be a finite set. Let n∈ N+. We denote a vector in Φn by a lower case bold symbol. We denote i∈N+ Φi by Φ∗. Let b∈ Φn. Given b, for every i∈[1, n], we represent the ith component of b by the corresponding normal weight symbol bi; i.e., b=(b1,, bn). Conversely, given n elements b1,, bn of Φ, b denotes the vector (b1,, bn). Given l, u∈ N, we denote the vector(bl,, bu) by bl∶u. Given δ∈ Φ and k∈ N+, we denote the vector (δ,, δ) by δ(k). We omit the subscript "(k)" if no confusion arises. Let ·„„„„„„„„„„„„‚„„„„„„„„„„„„¶ a∈ Φn. We denote a≤ b if and only if ai≤ bi for every i∈[1, n]. Given a, b, i=1 aibi by a⋅ b. For convenience, we identify we denote the inner product∑n Φ, or a mapping from[1, n] to Φ if no confusion arises. For example, we identify the vector(b1,, bn) with the sequence b1,, bn, the string b1bn, or a mapping that maps i to bi for every i∈[1, n]. We denote b∈ b if b contains b as a component. We define a binary relation⊆ over Φ∗ as follows. Given a and b in Φn, a⊆ b if and only if ai= bi for every i∈[1,a]. Given b, we denote its reverse(bn,, b1) by bR. Given l, u∈[1, n], bR (bl∶u)R. l∶u denotes a vector in Φn with a sequence of length n over Φ, a string of length n over k We say that a finite set A of integers can be 2-dimensionally-sorted in ascending (descending) order if there is a matrix M such that every row and column are sorted in ascending (descending) order; and there is some one to one correspondence from A to the set of all components of M . 2.1 Concepts and notation on integers representation of n of length k. We omit the phrase "of length k" if no Let b∈ N+. Let n, k∈ N such thataelogb nae+ 1≤ k. If di isaen~bi−1ae mod b for every i∈[1, k], then we call the string dkd1 over[0, b− 1] the base-b confusion arises. Given a base-b representation α of some m ∈ N, (α)b length 0; i.e., we consider(ε)b to be 0. Given l, u∈[1, k] with l< u, if dkd1 is the base-b representation of n, then we call the substring dldu the base-b (l, u)-zone of n. We omit the phrase "base-b" if no confusion arises. denotes the integer m. We consider ε to be the base-b representation of 0 of 2 2.2 Boolean formulae In this subsection, we define notation and assumptions and review some concepts on Boolean formulae. We assume the reader to be familiar to basic concepts in Boolean satisfiability. The reader is referred to some books by some chapters in Arora and Barak [1], Creignou, Khanna, and Sudan [2], or Wegener [4] if necessary. 2.2.1 Assumptions In this subsubsection, we define assumptions on Boolean formulae, which we use throughout the paper. These assumptions are for technical reasons. By those assumption, we do not lose the generality of discussion on polynomial- time computability. We fix Z to be a countable set of Boolean variables. For every i∈ N+ zi denotes a Boolean variable in Z. We assume that every Boolean formula in this paper is defined over Z. We fix ϕ and ψ to be positive 3CNF formulae over Z. We assume a clause in a Boolean formula to be a sequence of literals although a clause is often assumed to be a set of literals in other literature. For example, we distinguish z1∨z2∨z3 from z3∨z2∨z2. Similarly, we assume C1 and C2, we distinguish a conjunction C1∧ C2 from C2∧ C1. Needless to a CNF formula to be a sequence of clauses although a CNF formula is often assumed to be a set of clauses in other literature. For example, given clauses say, the satisfiability of a given formula do not depend on whether clauses or formulae are regarded as sets or sequences. 2.2.2 Concepts and notation be the number of variables in the formula. Let ϕ be a given. We assume that ϕ consists of 2 or more clauses. We assume that every clause in ϕ contains distinct variables. We assume that no two clauses in ϕ consist of the identical combination of variables. We assume that the indices of variables occurring in ϕ are successive integers from 1; i.e., the set of all variables occurring in ϕ can be represented as {zi∶ i∈[1, k]} for some k∈ N. We consider the size of a Boolean formula to Let z∈ Z. Then, we call z or¬z literals. In particular, we call z a positive literal; and¬z a negative literal. We say that ϕ is positive if ϕ consists of only positive literals. We denote the set of all variables in ϕ by V(ϕ). We denote the set of all clauses in ϕ byCϕ. Suppose that ϕ is represented as Cm∧∧ C1; i.e., m=Cϕ. Let k be a mapping from {zi∶ i∈[1, j]} to {0, 1}, where j ∈[1,Vϕ]. We call σ a truth assignment for ϕ if σ = V(ϕ). We often call a truth assignment for ϕ simply an assignment for ϕ. Let σ∈{0, 1}ν. We say that a partial the number of variables in ϕ. We define a partial assignment σ for ϕ as 3 assignment σ is a 1-in-3-satisfying for ϕ if {z∶ σ(z) = 1, z ∈ Cj} ≤ 1 for every j∈[1, m]. We say that an assignment σ is 1-in-3-satisfying for ϕ if {zi∶ σ(zi)= 1}= 1 for every j∈[1, m]. Given ϕ, if there is a 1-in-3-satisfying σ for ϕ and a literal z in ϕ, we call z a true literal in σ if σ(z)= 1. Let j=1 bi−1(cid:74)zi∈ Cj(cid:75) by(ϕ, zi)b. b∈ N+. Given i∈[1, k], we denote the integer∑m We denote the vector((ϕ, z1)4,,(ϕ, zk)4) byϕ. assignment σ, then we say that ϕ is 1-in-3-satisfiable. We consider ε to be a partial assignment that does not assign anything. Given a partial assignment Problem 1 (Pos1In3Sat). Instance. A positive 3CNF formula ϕ. Question. Is ϕ 1-in-3-satisfiable? 2.3 Computational complexity We assume the reader to be familiar to basic concepts and results in compu- tational complexity theory. The reader is referred to Arora and Barak [1] if necessary. Basically, we estimate the running time of an algorithm by using a function in the bit length of a given input. On the other hand, this paper focuses on the polynomial-time computability of Pos1In3Sat. Thus, we analyze the running time of an algorithm roughly to some extent that we do not lose the correctness in favor of clarity of discussion. For example, as we described in Subsubsection 2.2.1, we adopt the number of variables as the size of a given 3CNF formula. 3 Algorithm In this section, we propose a new algorithm for Pos1In3Sat. Subsection 3.1 describes the outline and key ideas of this algorithm informally. Subsec- tion 3.2, describes the details of the algorithm formally. In Subsection 3.3, we prove the validity of the algorithm. Finally, in Subsection 3.4, we analyze the running time of the algorithm. ∧∧ C1 denotes a ψ. For every i∈[1, m1] and j∈[1, 3],i, j; ψ denotes an integer in[1, k1] such that Ci= zi,3;ψ∨ zi,2;ψ∨ zi,1;ψ. We denotei, j; ψ by simplyi, j For preparation, we fix some symbols as follows. Cm1 positive 3CNF formula ψ. Moreover, k1 denotes the number of variables in if no confusion arises. 3.1 Ideas In this subsection, we first outline the algorithm that we propose in this paper. After that, we describe some intuitive ideas of the algorithm by executing the algorithm for a 3CNF formula. 4 3.1.1 Outline i=1 4i−1. )4; i.e.,∑m1 In the proposed algorithm, every Boolean variable zi in a given ψ is encoded base-4 representation of length m1. In that base-4 representation, the jth digit from the right end means whether the clause Cj contains zi, where A basic strategy in the algorithm is a 2-dimensional version of binary search. First, the algorithm does a preprocess for the given ψ. By that procedure, we construct a positive 3CNF formula ϕ of m clauses and k to (ψ, zi)4. Given (ψ, zi)4, we can observe the following meaning for its j∈[1, m1]. That is,(ψ, zi)4 simulates the assignment of 1 to zi in ψ. Thus, we can represent a total truth assignment for ψ as the integer∑i∈I(ψ, zi)4 for some I⊆[1, k1]. If i∈ I, then we consider zi to be assigned 1 in ψ. Then, a satisfying assignment for ψ corresponds to( 11 variables. Then, the algorithm searches the integer ∑m i=1 4i−1 in the set of (ψ, zi)4, where α = 2k− 1 and I0,, Iα are (ψ, zi)4,,∑i∈Iα integers ∑i∈I0 distinct subsets of[1, k]. Needless to say, an exponential space is necessary (ψ, zi)4,,∑i∈Iα (ψ, zi)4. Thus, to explicitly construct all the integers∑i∈I0 (ψ, zi)4 is required to be sorted (ψ, zi)4,,∑i∈Iα Moreover, the sequence∑i∈I0 We fix ψ1 to be a positive 3CNF (z1∨ z2∨ z3) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ in an order. Sorting these integers in 1-dimension appears to be difficult. However, if we arrange those integers in 2-dimension, then we can sort them, as we will describe below. we can do this search without explicitly constructing the overall sequence. ∧(z1∨ z2∨ z4) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ In the m1 . C2 C1 remaining part of this subsection, we will describe the details of the pro- posed algorithm for ψ1. In the algorithm, for convenience, we replace ψ1 by new 3CNF formulae some times. Thus, for every symbol, we often use a parenthesized superscript for distinguishing the phase when the symbol is used. 3.1.2 Preprocess 2 1 ∨ z (0) (0) As a preparation for the main search, the proposed algorithm construct a new 3CNF formula from ψ1, and then encodes it to a set of integers. Let us describe it in more detail below. Let us represent ψ1 in the earliest phase . Then, for every ) ∨ z of the algorithm by(z ) ∨ z ∧(z ∨ z (0) (0) (0) (0) (0) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ )4 is illustrated in Table 1. i∈[1, 4], the base-4 representation for(ψ (0) (0) (0) First, the algorithm replaces the indices of the variables so that(ψ1, z1)4≤ for every i∈[1, 4] (ψ1, z2)4≤(ψ1, z3)4≤(ψ1, z4)4. Let us represent zi as z for every j∈{1, 2} in the phase immediately after those re- (1) (1) and Cj as C 1 , z C C 3 1 2 1 4 i j 2 i 5 1 , z Base-4 representation (ψ1, z1)4 Table 1: Base-4 representation for(ψ )4, where i∈[1, 4]. (0) (0) (ψ1, z3)4 (ψ1, z4)4 (ψ1, z2)4 ∧(z ) placements. That is, in this phase, ψ(1)=(z ∨ z ) ∨ z ∨ z ∨ z (1) (1) (1) (1) (1) (1) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ (1) (1) In ψ(1), every occurrence of every variable can be represented as Table 2. 11 10 11 01 C 2 C 1 2 4 3 4 3 1 i . Table 2: Correspondence between the indices of variables in two ways. z2,3 z2,2 z2,1 z1,3 z1,2 z1,1 z4 z3 z2 z4 z3 z1 In the next phase, the algorithm constructs three clauses for every clause , where j∈{1, 2}, by using the variables zj,1, zj,2, and zj,3 and new (1) "(2)" as a superscript of every symbol. In more details, we construct the variables zk1+4(j−1)+1, zk1+4(j−1)+2, and zk1+4(j−1)+3. In this phase, let us use C j 4j C C C following clauses. =(zk1+4(j−1)+3∨ zk1+4(j−1)+2∨ zj,3) (2) =(zk1+4(j−1)+3∨ zk1+4(j−1)+1∨ zj,2) (2) 4j−1 =(zk1+4(j−1)+3∨ zj,3∨ zj,2) (2) 4j−2 Moreover, the algorithm renames the clause Cj as C4j−3;, i.e., C (2) ∧(z10∨ z4∨ z3) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ∧(z7∨ z4∨ z3) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ∧(z10∨ z8∨ z3) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ∧(z7∨ z5∨ z3) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ (z10∨ z9∨ z4) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ∧(z7∨ z6∨ z4) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ = C (2) 4j−3 ∧(z4∨ z3∨ z2) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ ∧(z4∨ z3∨ z1) ·„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„‚„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„„¶ That is, the algorithm constructs the following ψ 1 . C5 C6 C8 C7 (1) j . C4 C3 C2 C1 3.1.3 Sorted matrix After the preprocess in Subsubsection 3.1.2, we can find a(24× 26)-matrix Mψ1, each of whose rows and columns is sorted. In this subsubsection, we describe more details of Mψ1. In this subsubsection, we fix σ to be an assignment for ψ 1 . Every component in Mψ1 corresponds to an assignment (2) 6 for ψ1; and conversely, given an assignment σ, there is a component in Mψ1 corresponding to σ. Given σ, we denote((σR 1∶4 (σ). )2+1) by fψ1 (σ) means the position of a component in Mψ1. Then, Mψ1 is Table 3: (ψ The pair fψ1 a matrix such that every row and column are sorted in ascending order. (2) 1 , z )2+1,(σR 5∶10 )4 for every i∈[1, 4]. (2) (ψ1, zi)4 (σ) (00000001)4 ((0001)2, 0) ((0010)2, 0) (00010001)4 ((0100)2, 0) (01120112)4 (11231123)4 ((1000)2, 0) fψ1 i i 1 2 3 4 σR 0000000001 0000000010 0000000100 0000001000 σR fψ1 i 1 2 3 4 is. Table 3 and Table 5 show the constructed integers that affect the ordering of the magnitudes in the column and row directions in Mψ1, respectively. By Tables 3 and 5, we can observe that the larger i is, the larger(ψ, zi)4 Table 4: Integer σ⋅ψ1, which is the value of the fψ1 (σ)-component in Mψ1, for σ∈{1}i{0}10−i, where i∈[1, 4]. σ⋅ψ1 (σ) (00000001)4 ((0001)2, 0) (00010001)4 ((0011)2, 0) (01120112)4 ((0111)2, 0) (11231123)4 ((1111)2, 0) )4 for every i∈[5, 10]. (2) (σ) (ψ1, zi)4 (00000100)4 (0,(000001)2) (0,(000010)2) (00001100)4 (0,(000100)2) (00002210)4 (0,(001000)2) (01002210)4 (11002210)4 (0,(010000)2) (0,(100000)2) (22102210)4 0000010000 0000100000 0001000000 0010000000 0100000000 1000000000 0000000001 0000000011 0000000111 0000001111 Table 5: (ψ i 5 6 7 8 9 10 (2) fψ1 1 , z i σR Table 4 shows that the first row in Mψ1 is sorted. By that table, we can find that every row in Mψ1 is sorted. Table 4 shows that the first column 7 Table 6: Integer σ⋅ψ1, which is the value of the fψ1 for σ∈{1}i{0}10−i, where i∈[5, 10]. (σ) (0,(000001)2) (0,(000011)2) (0,(000111)2) (0,(001111)2) (0,(011111)2) (0,(111111)2) 0000010000 0000110000 0001110000 0011110000 0111110000 1111110000 (σ)-component in Mψ1 σ⋅ψ1 (00000100)4 (00001100)4 (00002210)4 (01002210)4 (11002210)4 (22102210)4 i 5 6 7 8 9 10 fψ1 σR in Mψ1 is sorted. By that table, we can find that every column in Mψ1 is sorted. By Tables 4 and 6, we obtain the following property. Observation 2. Let(l1, u1)∈[1, 3]×[5, 9]. Let(l2, u2)∈[l1+ 1, 4]×[u1+ 1, 10]. Then, )4. )4+(ψ (ψ u1Q (2) (2) i=5 (µ). Then, (σ)≤ fψ1 Observation 3. Let σ and µ be vectors such that fψ1 )4 ≤ 24(ψ By Observation 2, the following holds. )4+ l1Q i=1 (2) 1 , z(2) (ψ (2) (2) (2) (2) 1 , z i 1 , z i 1 , z l2 σ⋅ψ1 ≤ µ⋅ψ1. 24 u2 Figure 1 visualizes the matrix Mψ1. We can see Observation 3 in Fig- ure 1. order. Consequently, we find the following observation. Observation 4. Let Mψ1 be the matrix whose(i, j)-element is f−1(i− 1, j− 1)⋅ψ1, where i∈[1, 24] and j∈[1, 26]. Then, Mψ1 is sorted in ascending 1 , and for every i∈[1, 10], fix zi to (2) . After constructing ψ1, the algorithm constructs the set{(ψ1, zi)4∶ i∈ (2) [1, 10]}. Then, it searches the integer ∑8 i=1 4i−1 among the matrix Mψ1. ∑8 i=1 4i−1 corresponds to a satisfying assignment for ψ1. An assignment σ satisfies ψ1 if and only σ⋅ψ1 is(11111111)4; i.e.,∑8 i=1 4i−1. Needless to say, In this subsubsection, we fix ψ1 to be ψ be z Indirect search for an implicit matrix 3.1.4 i representing all components in Mψ1 requires an exponential space for the input size. However, we can simultaneously do binary searches in column and row directions in Mψ1 without explicitly constructing all the integers. 8 Figure 1: Values of components of the matrix Mψ1, whose(i, j)-element is f−1(i− 1, j− 1)⋅ψ1, where i∈[1, 24] and j∈[1, 26]. Let us describe more details of that search below. Figure 2 illustrates the matrix Mψ1 in the first phase of the search. We first set the assignment 011111111 to the first candidate. In Figure 2, the left and right squares represents Mψ1 in case when the value of the component corresponding to the assignment 11111111 are smaller and larger than the one corresponding to the first candidate 01111111. respectively. 9 Row number of M1(0010)2+1(0100)2+1(0110)2+1(1000)2+1(1010)2+1(1100)2+1(1110)2+1Column number of M1(001000)2+1(010000)2+1(011000)2+1(100000)2+1(101000)2+1(110000)2+1(111000)2+1Value 1 of each component(00000000)4(01000000)4(02000000)4(03000000)4(10000000)4(11000000)4(12000000)4(13000000)4(20000000)4(21000000)4(22000000)4(23000000)4(30000000)4(31000000)4(32000000)4(33000000)4 Figure 2: Matrix Mψ in case when 2DIBSearch is first called. 3.2 Formal details In this subsection, we describe the details of our algorithms for Pos1In3Sat. 10 (cid:9)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:15)(cid:15)(cid:15)(cid:15)(cid:15)(cid:15)(cid:9)(cid:17)(cid:17)(cid:17)(cid:17)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:15)(cid:15)(cid:15)(cid:9)(cid:17)(cid:18)(cid:18)(cid:18)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:9)(cid:18)(cid:17)(cid:17)(cid:17)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:15)(cid:15)(cid:15)(cid:9)(cid:18)(cid:18)(cid:18)(cid:18)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:68)(cid:66)(cid:79)(cid:69)(cid:74)(cid:69)(cid:66)(cid:85)(cid:70)(cid:66)(cid:83)(cid:70)(cid:66)(cid:1)(cid:85)(cid:80)(cid:1)(cid:70)(cid:89)(cid:68)(cid:77)(cid:86)(cid:69)(cid:70)(cid:9)(cid:85)(cid:66)(cid:83)(cid:72)(cid:70)(cid:85)(cid:10)(cid:1)(cid:29)(cid:1)(cid:9)(cid:68)(cid:66)(cid:79)(cid:69)(cid:74)(cid:69)(cid:66)(cid:85)(cid:70)(cid:10)(cid:9)(cid:85)(cid:66)(cid:83)(cid:72)(cid:70)(cid:85)(cid:10)(cid:1)(cid:31)(cid:1)(cid:9)(cid:68)(cid:66)(cid:79)(cid:69)(cid:74)(cid:69)(cid:66)(cid:85)(cid:70)(cid:10)(cid:68)(cid:66)(cid:79)(cid:69)(cid:74)(cid:69)(cid:66)(cid:85)(cid:70)(cid:66)(cid:83)(cid:70)(cid:66)(cid:1)(cid:85)(cid:80)(cid:1)(cid:70)(cid:89)(cid:68)(cid:77)(cid:86)(cid:69)(cid:70)(cid:9)(cid:17)(cid:18)(cid:18)(cid:18)(cid:18)(cid:18)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:9)(cid:18)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:9)(cid:18)(cid:18)(cid:18)(cid:18)(cid:18)(cid:18)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:9)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:15)(cid:15)(cid:15)(cid:15)(cid:15)(cid:15)(cid:9)(cid:17)(cid:18)(cid:18)(cid:18)(cid:18)(cid:18)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:9)(cid:18)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:10)(cid:9386)(cid:12)(cid:18)(cid:9)(cid:18)(cid:18)(cid:18)(cid:18)(cid:18)(cid:18)(cid:10)(cid:9386)(cid:12)(cid:18) Algorithm 1: IsSat 1 IsSat(ψ) Input: A 3CNF formula ψ Output: A Boolean value, which means whether ψ is satisfiable. k1← (the number of variables in ψ) m1← (the number of clauses in ψ) Rename variables in ψ such that(ψ, z1)4≤≤(ψ, zk1 )4 foreach i∈[1, m1] Sort literals in Ci so that Ci= zi,3∨ zi,2∨ zi,1 and i, 3>i, 2>i, 1. foreach i∈[1, m1] C4i←(zk1+3i∨ zk1+3i−1∨ zi,3) C4i−1←(zk1+3i∨ zk1+3i−2∨ zi,2) C4i−2←(zk1+3i∨ zi,3∨ zi,2) C4i−3← Ci m← 4m1 ϕ← Cm∧∧ C1 k2← 3m1 Computeϕ. t←∑m i=1 4i−1. p←(0, 0) q←(2k1− 1, 2k2− 1) return 2DIBSearch(ϕ, p, q, k1, t) // the number of clauses in ϕ // the number of new variables // a target integer // a clause in ψ area 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // a new clause // a new clause // a new clause // the smallest corner in the search area // the largest corner in the search 11 2 2 2 3 4 5 6 7 8 9 return 0 return 1 a target value. Algorithm 2: 2DIBSearch // (the target) = (the current candidate) // (the target) < (the current candidate) Output: A Boolean value, which means whether t can be mean the smallest and largest points in the area to search; k1 Input: A 5-tuple(ϕ, p, q, k1, t), whereϕ is in N+; p∈ N2+ and q∈ N2+ means a bias for distinguishing coordinates; and t∈ N+ means represented as b⋅ϕ for some b∈{0, 1}k. 1 2DIBSearch(ϕ, p, q, k1, t) if q1− p1≤ 1 and q2− p2≤ 1 k← (the number of components ofϕ) // l means an indicator for ϕ. r← 2k1ae p1+q1 ae+ae p2+q2 ae (ϕ, zj)4aer~2j−1ae mod 2 // s means a candidate. s←∑k if s= t j=1 elseif t< s if q1− p1≥ 2 and q2− p2≥ 2 if 2DIBSearch(ϕ,(p1,ae p1+q1 ae),(p2,ae p2+q2 ae), k1, t)= 1 if 2DIBSearch(ϕ,(p1,ae p1+q1 ae),(ऄ p2+q2 अ , q2), k1, t)= 1 return 2DIBSearch(ϕ,(ऄ p1+q1 ae), k1, t) अ , q1),(p2,ae p2+q2 elseif q1− p1≤ 1 return 2DIBSearch(ϕ,(p1, q1),(p2,ae p2+q2 ae), k1, t) // when q2− p2≤ 1 return 2DIBSearch(ϕ,(p1,ae p2+q2 ae),(p2, q2), k1, t) elseif t> s if q1− p1≥ 2 and q2− p2≥ 2 if 2DIBSearch(ϕ,(p1,ae p1+q1 अ , q2), k1, t)= 1 ae),(ऄ p2+q2 if 2DIBSearch(ϕ,(ऄ p1+q1 ae), k1, t)= 1 अ , q1),(p2,ae p2+q2 return 2DIBSearch(ϕ,(ऄ p1+q1 अ , q1),(ऄ p2+q2 अ , q2), k1, t) elseif q1− p1≤ 1 return 2DIBSearch(ϕ,(p1, q1),(ऄ p2+q2 अ , q2), k1, t) // when q2− p2≤ 1 return 2DIBSearch(ϕ,(ऄ p1+q1 अ , q1),(p2, q2), k1, t) // (the target) > (the current candidate) return 1 return 1 return 1 return 1 else else 2 2 2 2 2 2 2 2 2 2 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2 2 2 2 2 2 12 ξlv )4>∑lv−1 i=1 (ϕ, zi)4. 3.3 Validity + 1,(σk1+1∶k)R 2 execute its procedure expectedly. Note that we do not compute all parts of the matrix M in Algorithms 1. We fix ϕ to be as in Algorithm 1. We fix f to be a mapping such that f(σ) is the pair((σ1∶k1 + 1) for a given assignment σ. We fix M to be the(2k1, 2k2)-matrix whose(i, j)-element is f−1(i, j)⋅ϕ, where i ∈ [1, 2k1] and j ∈ [1, 2k2]. Lemma 5 is necessary for 2DIBSearch to Lemma 5 (2-dimensional sortability). Let x and y be integers in [2, 2k1] and[2, 2k2], respectively. Then, the following holds. (5.1) mx−1,y< mx,y. (5.2) mx,y−1< mx,y. Proof of Lemma 5. We fix ξ to be the vector f−1(x, y). Let us first prove the inequality (5.1). Let θ be the vector f−1(x− 1, y). By definition,(ξR)2= 2k1y+ x and(θR)2= 2k1y+ x− 1. Then, there is an integer lv∈[1, k1] such that θi= ξi for every i∈[lv+ 1, k1+ k2]; θlv = 0; and = 1. Then, the following claim implies that ξ⋅ϕ> θ⋅ϕ; i.e., mx,y> mx−1,y. Claim 6. (ϕ, zlv Proof of Claim 6. The proof is by induction on lv. Let lc= max{j∶ zlv ∈ Cj, j ∈ [1, m1]}. Let lb be an integer in [1, 3] such that zlc,lb ∈ Clc. First, suppose that lb = 1. By lines 4-6 in Algorithm 1, (ϕ, zlc,lb−1) ≤ (ϕ, zlc−1,3). By lines 8-11 in Algorithm 1, 2(ϕ, zlc−1,3)4 < (ϕ, zlc,lb)4. Thus, 2(ϕ, zlc,lb−1)4 < (ϕ, zlc,lb)4. Next, suppose that lb ∈ {2, 3}. By lines 4-6 in Algorithm 1, (ϕ, zlc,lb−1)=(ϕ, zlc,lb−1). By lines 8-11 in Al- gorithm 1, 2(ϕ, zlc,lb−1)4<(ϕ, zlc,lb)4. Thus, 2(ϕ, zlc,lb−1)4<(ϕ, zlc,lb)4. (ϕ, zi)4< (ϕ, zi)4<(ϕ, zmaxv−1)4. Thus,∑maxv−1 By induction hypothesis,∑maxv−2 2(ϕ, zmaxv−1)4. Consequently,∑maxv−1 (Claim) i=1 i=1 Let us next prove the inequality (5.2). Let η be the vector f−1(x, y− 1). i=1 By definition, (ξR)2 = 2k1y+ x and (ηR)2 = 2k1(y− 1)+ x. By line 14 in Algorithm 1, k2 = 3m1. There are integers l0 ∈ [1, m1] and l1 ∈ [0, 2] such that ηi= ξi for every i∈[k1+ 3l0− l1− 1, k1+ k2]; θk1+3l0−l1 = 0; and = 1. Let λ= k1+ 3l0− l1. Then, the following claim implies that ξ⋅ϕ> η⋅ϕ; i.e., λx,y≥ λx−1,y. ξk1+3l0−l1 Claim 7. (ϕ, zλ)4>∑λ−1 (ϕ, zi)4. i=k1+1 only in time when i= l0 during all iterations of that loop. Thus, by lines 8- )4>∑2 11 in Algorithm 1,(ϕ, zk1+3l0−l1 (ϕ, zk1+3l0−i)4+ 2(ϕ, zk1+3(l0−1))4. i=l1+1 Proof of Claim 7. The proof is by induction on λ. In Algorithm 1, opera- tions for zλ are only in the loop of lines 7-11. Moreover, those operations are (ϕ, zi)4<(ϕ, zmaxv )R 2 )4. 13 That is,(ϕ, zλ)4>∑λ−1 pothesis, (ϕ, zk1+3(l0−1))4 >∑k1+3(l0−1)−1 ∑k1+3(l0−1) (Lemma 5) i=1 (ϕ, zi)4+ 2(ϕ, zk1+3(l0−1))4. By induction hy- i=k1+3l0−2 (ϕ, zi)4. Thus, 2(ϕ, zk1+3(l0−1))4 > (Claim 7) i=1 (ϕ, zi)4. Consequently,(ϕ, zλ)4>∑λ−1 i=1 (ϕ, zi)4. Lemma 8 (Equivalence of formulae). Let ψ and ϕ be as in Algorithm 1. Then, ψ is satisfiable if and only if ϕ is satisfiable. Proof of Lemma 8. By line 11 in Algorithm 1, ϕ contains all clauses in ψ. Thus, the "if " part is trivial. We will prove the "only if " part below. Suppose that ψ is satisfiable. Let σ be a satisfying assignment for ψ. It suffices to show that there is a satisfying assignment µ for ϕ such that µi = σi for every i ∈ [1, k1]. Let j ∈ [1, m1]. By line 11 in us then consider the conjunction of the clauses C4j=(zk1+3j∨zk1+3j−1∨zj,3), Algorithm 1, C4j−3 in ϕ is equal to Cj in ψ. Thus, µ satisfies C4j−3 in ϕ. Let C4j−1=(zk1+3j∨ zk1+3j−2∨ zj,2), and C4j−2=(zk1+3j∨ zj,3∨ zj,2) in ϕ. In Algorithm 1, for every[0, 2], zk1+3j−l occurs only in C4j∧ C4j−1∧ C4j−2 in ϕ. Thus, we can assign zk1+3j, zk1+3j−1, and zk1+3j−2 to values without affecting the values of all clauses except for C4j, C4j−1, and C4j−2. First, suppose that zj,1, zj,2, and zj,3 are assigned 1, 0, and 0 in ψ, respectively. If µ assigns zk1+3j, zk1+3j−1, and zk1+3j−2 to 1, 0, and 0, respectively, then µ satisfies C4j, C4j−1, and C4j−2. Next, suppose that zj,1, zj,2, and zj,3 are assigned 0, 1, and 0 in ψ, respectively. If µ assigns zk1+3j, zk1+3j−1, and zk1+3j−2 to 0, 1, and 0, respectively, then µ satisfies C4j, C4j−1, and C4j−2. Next, suppose that zj,1, zj,2, and zj,3 are assigned 0, 0, and 1 in ψ, respectively.  µ assigns zk1+3j, zk1+3j−1 and zk1+3j−2 to 0, 0, and 1, respectively, then µ satisfies C4j, C4j−1, and C4j−2. Consequently, ϕ is satisfiable. If 3.4 Running time time polynomial in k1. In this subsection, we analyze the running time of the proposed algorithm. Proof of Lemma 9. Each operation of addition, subtraction, multiplication, division, mod, floor, and ceiling can be computed in time polynomial in k1. Lemma 9 (Polynomial-time computability). Given ψ, IsSat(ψ) runs in Those operations are executed H(k, m) times, where H is a linear function that m1= Θ(k1). in Algorithm 1, we count the clause in ψ in time linear in m1. For every j∈ [1, k1], we can compute(ψ, zj)4 in time polynomial in k1. Moreover, we can sort the sequence(ψ, z1)4,,(ψ, zk1 )4 in ascending order in time polynomial in k1. After that procedure, we can rename variables in ψ (ψ, z1)4<< In line 1, we can count the variables in ψ in time linear in k1. In line 2 of k and m. In lines 2-18 in Algorithm 1, we spend time as follows. Note 14 linear in k1. Thus, we can do the loop in lines 5-6 in time polynomial in in k1. Thus, we can do the loop in lines 7-11 in time polynomial in k1. In (ψ, zk1 )4 in time linear in k1. That is, we can do the step in line 4 in time polynomial in k1. For every j∈[1, m1], we can do the step in line 6 in time k1. For every j ∈[1, m1], we can do the step in lines 8-11 in time linear line 15, we compute(ϕ, zj)4 for every j∈[1, k1+ 3m1]. That procedure are done in time polynomial in k1. By line 12, m= 4m1. Thus, m= Θ(k1). In line 16, we can compute∑m i=1 4i−1 in time polynomial in k1. By line 14, k2 = 3m1. Thus, k2 = Θ(k1). In line 18, we can compute 2k1 and 2k2 in IsSat(ψ) is O(k1). Claim 10. 2DIBSearch(ϕ, p, q, k1, t) runs in time polynomial in k1. k of components in ϕ is O(k1). components inϕ in time polynomial in k1. We can compute the expression in the righthand side in line 5. r takes at most O(k1) bits. The variable s most O(k1). Thus, all steps in lines 2-30 except for recursive calls can be Proof of Claim 10. Let us first analyze the running time of 2DIBSearch for all steps except for recursive calls. By the above discussion, the number In line 4, we can count the number of time polynomial in k1. Moreover, by Claim 10 below, we can do the step in line 19 in time polynomial in k1. Consequently, the total running time of has the largest bit length in all variables in Algorithm 2. Its bit length is at executed in time polynomial in k1. The depth of recursion depends on λ, but independent of λ0. We define In every recursive call, the bit lengths of the first, fourth, and fifth argu- ments are the same as the one in the calling procedure; and moreover, the ones of the second and third arguments are about the halves of the one in the calling procedure. We denote the sum of the bit lengths for representing ϕ, k1, and t by λ0. We denote the sum of the bit lengths for representing p and q by λ. In the first call for 2DIBSearch, λ is 2k1+ 2k2; i.e., 2k. T0(λ0) as an upper bound for the time of all steps except for recursive calls in 2DIBSearch(ϕ, p, q, k1, t). We define T(λ0, λ) as an upper bound for the total running time of 2DIBSearch(ϕ, p, q, k1, t). the value of s after line 6. (8-I) q1− p1≤ 1 and q2− p2≤ 1; i.e., the condition In a call of 2DIBSearch, there are the following six cases. Let s(1) be in line 2 is true. (8-II) t= s(1), q1− p1≥ 2, and q2− p2≥ 2; i.e., the condition in line 7 is true. (8-III) t< s(1), q1−p1≥ 2, and q2−p2≥ 2; i.e., the conditions in lines 9 and 10 are true. (8-IV) t< s(1) and (q1− p1≤ 1 or q2− p2≤ 1); t> s(1), q1− p1≥ 2, and q2− p2≥ 2; i.e., the conditions in lines 20 and 21 are true. (8-VI) t> s(1) and (q1− p1≤ 1 or q2− p2≤ 1); i.e., the condition i.e., the condition in lines 9 and 10 are true and false, respectively. (8-V) in lines 20 and 21 are true and false, respectively. Then, we obtain the 15 2 (1) 1 log3 2 . following recurrence. + T0(λ0) + T0(λ0) 4 for Algorithm 1, λ0 and λ are of polynomial order in k1. Consequently, in cases (8-I) and (8-II) in cases (8-III) or (8-V) in cases (8-IV) or (8-VI), T(λ0, λ)=B(λ0) 3Tλ0, λ Tλ0, λ where B is a polynomial. Let T1(λ0)= B(λ0)+ T0(λ0). Then, by Claim 11 below, T(λ0, λ) is of polynomial order in λ and λ0. By the above discussion 2DIBSearch(ϕ, p, q, k1, t) runs in time polynomial in k1. (Claim 10) Claim 11. T(λ0, λ)≤ λuT1(λ0), where u= tion of T1, B(λ0) < T1(λ0). Thus, in cases (8-I) and (8-II), T(λ0, λ) ≤ λuT1(λ0). In cases (8-III) to (8-VI), T(λ0, λ)≤ 3T(λ0, λ~4)+ T0(λ0). By in- duction hypothesis, T(λ0, λ)≤ 3(λ~4)uT1(λ0)+T0(λ0). By a rearrangement, 3(λ~4)uT1(λ0)+T0(λ0)= λu((3~4u)T1(λ0)+(1~λu)T0(λ0)). By the definition of T1, T0(λ0)< T1(λ0). By definition, λ≥ 4. Thus,(3~4λ)+(1~λu)≤ 1. It fol- lows that 3(λ~4)uT1(λ0)+ T0(λ0)≤ λuT1(λ0). That is, T(λ0, λ)≤ λuT1(λ0). (Claim 11) (Lemma 9) Proof of Claim 11. The proof is by induction on λ. By the defini- References [1] Sanjeev Arora and Boaz Barak. Computational Complexity: a Modern Approach. Cambridge University Press, New York, NY, 2009. [2] Nadia Creignou, Sanjeev Khanna, and Madhu Sudan. Complexity Clas- sifications of Boolean Constraint Satisfaction Problems. SIAM, 2001. [3] Thomas J. Schaefer. The complexity of satisfiability problems. In Pro- ceedings of the Tenth Annual ACM Symposium on Theory of Computing, STOC '78, pages 216–226, New York, NY, USA, 1978. ACM. [4] Ingo Wegener. The Complexity of Boolean Functions. John Wiley & Sons, Inc., New York, NY, USA, 1987. 16
1806.00305
1
1806
2018-06-01T12:20:45
Joint Size and Depth Optimization of Sorting Networks
[ "cs.DS" ]
Sorting networks are oblivious sorting algorithms with many interesting theoretical properties and practical applications. One of the related classical challenges is the search of optimal networks respect to size (number of comparators) of depth (number of layers). However, up to our knowledge, the joint size-depth optimality of small sorting networks has not been addressed before. This paper presents size-depth optimality results for networks up to $12$ channels. Our results show that there are sorting networks for $n\leq9$ inputs that are optimal in both size and depth, but this is not the case for $10$ and $12$ channels. For $n=10$ inputs, we were able to proof that optimal-depth optimal sorting networks with $7$ layers require $31$ comparators while optimal-size networks with $29$ comparators need $8$ layers. For $n=11$ inputs we show that networks with $8$ or $9$ layers require at least $35$ comparators (the best known upper bound for the minimal size). And for networks with $n=12$ inputs and $8$ layers we need $40$ comparators, while for $9$ layers the best known size is $39$.
cs.DS
cs
Joint Size and Depth Optimization of Sorting Networks✩ Department of Signal Theory and Communications, Universitat Polit`ecnica de Catalunya, Barcelona, Spain Jos´e A. R. Fonollosa 8 1 0 2 n u J 1 ] S D . s c [ 1 v 5 0 3 0 0 . 6 0 8 1 : v i X r a Abstract Sorting networks are oblivious sorting algorithms with many interesting theoretical properties and practical applications. One of the related classical challenges is the search of optimal networks respect to size (number of comparators) of depth (number of layers). However, up to our knowledge, the joint size-depth optimality of small sorting networks has not been addressed before. This paper presents size-depth optimality results for networks up to 12 channels. Our results show that there are sorting networks for n ≤ 9 inputs that are optimal in both size and depth, but this is not the case for 10 and 12 channels. For n = 10 inputs, we were able to proof that optimal-depth optimal sorting networks with 7 layers require 31 comparators while optimal-size networks with 29 comparators need 8 layers. For n = 11 inputs we show that networks with 8 or 9 layers require at least 35 comparators (the best known upper bound for the minimal size). And for networks with n = 12 inputs and 8 layers we need 40 comparators, while for 9 layers the best known size is 39. 1. Introduction A sorting algorithm is data-independent or oblivious if the sequence of comparisons does not depend on the input list. Sorting networks are oblivious sorting algorithms with many practical applications and rich theoretical properties [12]. From the practical point of view, sorting networks are the usual choice for simple parallel implementations in both hardware and software such as Graphics Processing Units (GPUs). Moreover, sorting networks are also of interest for secure computing methods like secure multi-party com- putation, circuit garbling and homomorphic encryption [4]. Other applications include median filtering, switching circuits, and encoding cardinality constraints in propositional satisfiability problems (SAT)[1]. Interestingly, we use this cardinality constraint in this paper to perform the joint size-depth optimization of sorting networks in a SAT framework. From the theoretical point of view comparator networks can be studied using the combinatorial and algebraic properties of permutations [5, 9], as well as constrained boolean monotone circuits using the zero-one principle [12, p. 223]. In the usual representation the n input values are fed into networks of n channels connected by comparators that swap unordered inputs from two channels. The sequence of data- independent comparisons can be parallelized grouping independent comparators in layers. The depth of a comparator network is the number of layers, i.e., the delay in a parallel implementation. The typical graphical representation of a comparator network is depicted in Figure 1. In this work we center our attention in the search of optimal sorting networks in both size (number of comparators) and depth (number of layers) for small values of n. For large values of n, Ajtai, Koml´os, and Szermer´edi [2] presented in 1983 a method to construct sorting networks that have asymptotically optimal size and depth with O(n log n) comparators in O(log n) layers. However, despite this good asymptotic behavior, the original AKS network and other more recent variants, are currently of little practical interest because of the huge constant hidden in the big-O notation. Simple recursive generation algorithms as the ✩Supported by the Spanish MINECO project TEC2015-69266-P (FEDER, UE) Email address: [email protected] (Jos´e A. R. Fonollosa) Preprint August 22, 2018 Figure 1: Comparator network of depth 3 with 5 comparators. proposed by Batcher [3] provide much better sorting networks in term of size and depth for networks of practical interest. For small, fixed values of input n, the search for efficient sorting networks in terms of size or depth is a optimization quest with more than 50 years of history. For n ≤ 16 the best known networks in terms of size are more than 40 years old [12] but their optimality has only been recently proved for n ≤ 10 [8]. The optimal-depth search follows a similar pattern. The best sorting networks in terms of depth for n ≤ 16 were already known 40 years ago [12] but the optimality proofs had to wait until 1989 n ≤ 10 [13], 2013 for n ≤ 16 [6] and 2015 for n = 17 [8]. Recent optimality results are based on reducing the exponential complexity of a exhaustive search ex- ploiting symmetries and efficient SAT encodings. In this paper we adapt optimal-depth SAT encodings [6, 11, 8] to include additional cardinality constraints that limit the total number of comparators. We also need to reconsider some of the standard simplifications or restrictions for optimal-depth search problems that are not longer valid for joint size and depth optimizations. For example, we can no longer assume that the first layer of the network is of maximal-size. A powerful symmetry-breaking tool in sorting network optimization is the use of a reduced set of prefixes that fix the first layers of the network reducing both the search space and the number of inputs of the sorting test. Bundala et al. developed in [6] an efficient generation of complete sets of two-layer prefixes on n channels for the specific optimal-depth problem. In our search for depth-size optimality results, we extend that work to consider any kind of two layer networks. Section 4 covers the symbolic generation of complete sets of two layers prefixes modulo symmetry for this general case. A recent related work of practical interest uses an evolutionary approach [10] to search for small and low depth sorting networks, but the search strategy lacks completeness. Our SAT-based approach is able to provide similar networks with provably size-depth optimality for small networks. 2. Preliminaries A comparator network is a set of channels connected by a sequence of comparators as illustrated in Figure 1. Channels are depicted as horizontal lines (with the first channel at the top). Each comparator (i,j) compares the input values (ini, inj) of the two connected channels (1 ≤ i < j ≤ n) and if necessary rearrange them such that outi = min(ini, inj) and outj = max(ini, maxj). The sequence of comparators can be grouped in maximal sets of independent comparators (layers) whose output can be computed in parallel. The depth of a comparator network is the number of layers. A sorting network is a comparator network that sorts all input sequences. A key tool for the proof of correctness of sorting networks is the 0-1-principle [12]: if a sorting network for n channels sorts all 2n sequence of 0's and 1's, then it sorts every arbitrary sequence of values. Another important well-known fact is that any permutation of the input channels of a comparator network (followed by an untangling procedure) does not change its sorting properties [12]. Parberry [13] use this property to fix the first layer in the search of optimal-depth lower bounds. He also mentions that we do not need to consider equivalent second layers up to permutation of channels. More recently, Bundala et al. [6] studied the characterization and symbolic representation of equivalent two layer prefixes up to permutation for the same optimal-depth search problem. Two networks C and C′ are equivalent up to permutation, denoted by C ≈ C′, if there is a permutation π such that C′ equals π(C) (after the untangling procedure). 2 3. Propositional Encodings for Joint Size and Depth Optimization of Sorting Networks In this section we adapt the SAT encoding proposed by Codish et al. [8] including additional cardinality constraints that limit the total number of comparators. For completeness' sake we include the original encoding and we follow a similar notation. A comparator network of depth d on n channels is represented by a set of Boolean variables Cd n = i,j indicating whether there is a comparator on channels i (cid:8) gk and j in layer k in the network or not. i,j (cid:12)(cid:12) 1 ≤ i < j ≤ n, 1 ≤ k ≤ d (cid:9), the value of gk 3.1. Validity encodings In a valid network the comparators of each layer are independent, i.e., each channel may be used only once: oncek i (Cd n) = ^ 1≤i6=j6=l≤n (cid:16)¬gk min(i,j),max(i,j) ∨ ¬gk min(i,l),max(i,l)(cid:17) valid (Cd n) = ^ 1≤k≤d,1≤1≤n once k i (Cd n) 3.2. Sorting encodings We denote the inputs into the network by the variables v0 i , with 1 ≤ i ≤ n and 1 ≤ k ≤ d, store the value on channel i in the network after layer k. A valid networks sorts if the following SAT constraints on vk i , with 1 ≤ i ≤ n, the variables vk i gk i,j are satisfied: used k i (Cd n) = _ j,i ∨ _ gk gk i,j updatek i (Cd j<i i<j n) =(cid:16)¬used k i (Cd (cid:0)gk j,i → (cid:0)vk (cid:0)gk i,j → (cid:0)vk ^ ^ 1≤j<i i<j≤n n) → (vk i ↔ vk−1 i i ↔ (vk−1 j )(cid:17) ∧ ∨ vk−1 i )(cid:1)(cid:1) ∧ i ↔ (vk−1 j ∧ vk−1 i )(cid:1)(cid:1) The update constraint describes the impact of comparators on the values vk i stored on each channel after every layer and the following sorts equation includes all the update constraints to assure the output y for a specific input x, where in our case y is the sorted version x. sorts(Cd n, x) = ^ (v0 i ↔ xi) ∧ 1≤i≤n ^ 1≤k≤d,1≤i≤n updatek i (Cd n) ∧ ^ 1≤i≤n (vd i ↔ yi) 3.3. Cardinality encoding This is the contribution of this paper to the SAT encoding of sorting networks. The previous encodings limit the number of layers to d. In order to perform a joint depth and size optimization we include additional clauses to limit the total number of comparators to s. Encodings of cardinality constraints into SAT have been thoroughly studied over the last few years. Interestingly, a good solution for our case is to use cardinality encodings based on sorting networks. In a binary sorting network that takes input variables (x1 . . . xn) and returns the sorted version in decreasing order (y1 . . . yn) the output variable ys becomes true if and only if there are at least s true input variables. Therefore, to express x1 + . . . + xn ≤ s it suffices to add a unit clause ¬ys+1. Standard cardinality encodings based on sorting networks requires O(n log2 n) clauses and variables. However, the selected 3 cardinality encoding proposed by Ab´ıo et al. which represents a significant optimization in our case. [1] reduces this to O(n log2 k) and enforces arc-consistency, A detailed enumeration of all the clauses and variables of the selected cardinality encoding is out of the scope of this paper. We assume here that we are given the cardinality variable cs+1 and the corresponding K cardinality clauses uk, with 1 ≤ k ≤ K (cs+1; u1, . . . , uK) = Cards+1(Cd n) where cs+1 is false and all the cardinality clauses are satisfied if and only if there are s or less comparator variables that are true. less s+1(Cd n) = ¬cs+1 ∧ ^ 1≤k≤K uk 3.4. Basic encoding A sorting network for n channels on d layers with s or less comparators exists if and only if the following constraint is satisfiable. ϕ(n, d, s) = valid (Cd n) ∧ less s+1(Cd n) ∧ ^ ¯x∈{0,1}n sorts(Cd n, ¯x) (1) 3.5. Additional encodings The basic sorting network encoding can be improved with additional constraints that restrict the search space or help to find conflicts quickly, as well as other optimizations described in [8]. In this subsection we just enumerate the additional constraints considered in our SAT encoding. The reader is refereed to [8] for a detailed justification. Redundant sorts clauses. The following encoding adds specific redundant sorts clauses that allows for more propagations, thus conflicts can be found earlier oneDown k i,j ↔ _ i<ℓ≤j oneUpk i,j ↔ _ i≤ℓ<j gk i,ℓ gk ℓ,j noneDown k i,j ↔ ¬oneDown k i,j noneUpk i,j ↔ ¬oneUpk i,j Given an input ¯x = (0, 0, . . . , 0, xt, xt+1, . . . , xt+r−1, 1, 1, . . . , 1), for all t ≤ i ≤ t + r − 1 and at each layer k, we add the following constraints to the definition of sorts vk−1 i ∧ noneDown k i,t+r−1 → vk i ^ 1≤k≤d ¬vk−1 i ∧ noneUpk t,i → ¬vk i ^ 1≤k≤d Other additional constraints of interest in our case follows the necessary conditions for the last layers [8]. However, we can not use constraints that may force redundant comparators. In our optimal networks the last layer can have adjacent unused channels. 4 Non-redundant comparators in the last layer connect adjacent channels. ϕ1 = (cid:8) ¬gd i,j (cid:12)(cid:12) 1 ≤ i, i + 1 < j ≤ n (cid:9) No comparator in the penultimate layer connect two channels that are more than 3 channels apart. A comparator (i, i + 2) or (i, i + 2) on the penultimate layer has implications in the last layer. ϕ2 = (cid:8) ¬gd−1 i,j (cid:12)(cid:12) 1 ≤ i, i + 3 < j ≤ n (cid:9) ϕ3 = (cid:8) gd−1 i,i+3 → gd ϕ4 = (cid:8) gd−1 i,i+1(cid:1) ∧ (cid:0)gd−1 i,i+1 ∨ gd i,i+2 → gd i,i+3 → gd And we also included the additional optimizations from [7] i+2,i+3 (cid:12)(cid:12) 1 ≤ i ≤ n − 3 (cid:9) i+1,i+2 (cid:12)(cid:12) 1 ≤ i ≤ n − 2 (cid:9) No redundant comparators. Eager comparator placement. σ1 = ^ 1 ≤ k < d ¬gk i,j ∨ ¬gk+1 i,j 1 ≤ i < j ≤ n σ2 = ^ 1 < k ≤ d i,j → used k−1 gk i 1 ≤ i < j ≤ n All adjacent comparators. (Cd n) ∨ used k−1 j (Cd n) σ3 = ^ (cid:0)g1 i,i+1 ∨ g2 1 ≤ i < n i,i+1 ∨ · · · ∨ gd i,i+1(cid:1) Only unsorted inputs. We can remove sort constraints sorts(Cd n, x) for already sorted inputs from the basic encoding. Sorted inputs always remain unchanged. Another key tool to obtain a tractable SAT encoding is to consider a fixed prefix. If we fix the first layers of the networks we not only reduce the search space in term of free comparators but also the number of sort constraints sorts(Cd n, x) and validity clauses. In the sorting encodings we have to consider only the rest of the network and the remaining unsorted sequences at the output of fixed prefix. We study the generation of a complete set of prefixes for our optimality results in the following section. 4. Symbolic representation of two-layer prefixes Bundala et al. [6] studied the characterization and symbolic representation of equivalent two-layer prefixes up to permutation for the optimal-depth search problem. The proposed symbolic representation is based on the observation that two-layer networks are fully characterized by the maximal-length simple path of each group of connected comparators. Figure 2 shows two equivalent two-layer networks (a) and (b), all the maximal paths of network (a′), and one maximal path of network (b′). Using this observation and additional symmetry properties of maximal-length paths, Bundala et al. de- veloped an efficient method to generate a complete set of prefixes for the optimal-depth sorting network problem. The generation algorithm considered only networks with a maximal first layer (with (cid:4) n 2(cid:5) compara- tors) and saturated prefixes ([7], Definition 7). For the joint depth-size optimization problem we can not keep those restrictions. We need to address the general case of isomorphic two-layer comparator networks with any number of comparators in the first and second layer. 5 The proposed symbolic generation of a complete set of prefixes is an extension of the generation algorithm of Bundala et al. [7] including non-maximal first layers. We follow a similar terminology and definitions. The smaller (resp. larger) channel in some comparator of the first layer is called a min-channel (respec- tively, a max-channel ) and an unused channel in the first layer will be called a free channels. In our case, we can have more than one free channel. Definition 1. (Bundala et al. [7]) A path in a two-layer network C is a sequence hp1p2 . . . pki of distinct channels such that each pair of consecutive channels is connected by a comparator in C. The word corresponding to hp1p2 . . . pki is hw1w2 . . . wki, where: wi =   0 if pi is a free channel 1 if pi is a min-channel 2 if pi is a max-channel A path is maximal if it is a simple path (with no repeated nodes) that cannot be extended (in either direction). A network is connected if its graph representation is connected. In general, we can have connected networks with up to two free channels, so we need to consider one additional type of word that we will name Tail-word. Definition 2. Let C be a connected two-layer network on n channels. We will classify C and its correspond- ing word based on the number of unused channels in the first and second layer. In a connected two-layer network we can have only four different kinds of words. Head-word. If n is odd, then word(C) is the word corresponding to the maximal path in C starting with the (unique) free channel. The number of Head-words on n channels is 2(n−1)/2. Figure 3 show the complete set of Head-words on n ≤ 5 channels. Stick-word. If n is even and C has two channels not used in layer 2, then word(C) is the lexicographically smallest of the words corresponding to the two maximal paths in C starting with one of these unused channels (which are reverse to one another). The number of Stick-words on (2, 4, 6, 8, 10, 12, 14, 16, ...) channels is (1, 3, 4, 10, 16, 36, 64, 136, ...) respectively (OEIS A051437)1. Figure 4 show the complete set of Stick-words on n ≤ 6 channels. Cycle-word. If n is even and all channels are used by a comparator in layer 2, then word(C) is the lexicographically smallest word corresponding to a maximal path in C that begins with two chan- nels connected in layer 1. The number of Cycle-words on (2, 4, 6, 8, 10, 12, 14, 16, ...) channels is (1, 2, 2, 4, 4, 9, 10, 22, ...) respectively (OEIS A053656)2. Figure 5 show the complete set of Stick-words on n ≤ 8 channels. Tail-word. If n is even and C has two free channels then word(C) is the lexicographically smallest of the words corresponding to the two maximal paths in C starting with each of the two free channels (which are reverse to one another). Each two-layer network represented by a Tail-word is equal to a Stick-word network with two additional free channels and two comparators connecting each of the unused channels in the second layer with these free channels. The number of Head-words on n channels is equal to the number of Tail-words in n − 2 channels. Figure 6 show the complete set of Tail-words on n ≤ 8 channels. 1The On-Line Encyclopedia of Integer Sequences, Sequence A051437 2The On-Line Encyclopedia of Integer Sequences, Sequence A053656 6 (a) (a′) (b) (b′) Figure 2: The two-layer networks (a) and (b) are equivalent up to permutation. The symbolic representation of both networks is (012, 0120, 1221, 1221c). The 4 words of this sentence are obtained from the 4 maximal paths represented in (a′) for each connected component. The path of (b) corresponding to the word 0120 is also depicted in (b′). 0 012 021 01212 01221 02112 02121 Figure 3: Complete set of Head-words on n ≤ 5 channels. The set of all possible words (not necessarily minimal with respect to lexicographic ordering) can be described by the following BNF-style grammar3. Word ::= Head Tail Stick Cycle Head ::= 0(12 21)∗ Tail ::= 0(12 21)+0 Stick ::= (12 21)+ Cycle ::= 12(12 21)+ (2) To avoid ambiguity with Stick-words, we annotate Cycle-words with a c tag. Definition 3. A two-layer comparator network C is represented by the multi-set word(C) containing w′ = word(C′) for each connected component C′ of C. The set is denoted by the sentence w1; w2; . . . ; wk where the words are in lexicographic order. 3 We do not include the Tail-word description of a network with a single comparator in the second layer, because it is already covered by the equivalent single comparator in the first layer, Stick-word 12 7 12 1212 1221 2112 121212 121221 122112 211212 Figure 4: Complete set of Stick-words on n ≤ 6 channels. 12c 1212c 1221c 121212c 121221c 12121212c 12121221c 12122121c 12211221c Figure 5: Complete set of Cycle-words on n ≤ 8 channels. 8 0120 012120 012210 021120 01212120 01212210 01221120 02112120 Figure 6: Complete set of Tail-words on n ≤ 8 channels. Figure 2 illustrates the case of a two-layer network with 4 connected components, one of each type. Definition 4. Let w be a word in the language of Equation (2), and n = w. The two-layer network net(w) has a first layer with m comparators of the form (2i − 1, 2i), with 1 ≤ i ≤ m, where: m =   n 2 n−1 2 n−2 2 if w is a Stick-word or a Cycle-word if w is a Cycle-word if w is a Tail-word The second layer is then defined as follows. 1. If w is a Stick-word or a Cycle-word, ignore the first character; then, for k = 0, . . . ,(cid:4) n 2(cid:5) − 1, take the next two characters xy of w and add a second-layer comparator between channels 2k + x and 2(k + 1) + y. Ignore the last character; if w is a Cycle-word, connect the two remaining channels at the end. (Figure 4 and 5) 2. If w is a Head-word, proceed as above but start by connecting the free channel to the channel indicated by the second character. (Figure 3) 3. If w is a Tail-word, ignore the zeros and proceed as for a Stick-word. Then connect the channel indicated by second character with the second free channel, and the remaining channel indicated by the penultimate character with the first free channel. (Figure 6) To generate a network from a sentence, we generate the network of each word and compose them bottom- up as illustrated in Figure 2(a) for the sentence (012, 0120, 1221, 1221c). Figure 7 depicts the 22 different 5-channel two-layer networks (up to permutation) and its corresponding sentences. This complete set includes the empty network (0, 0, 0, 0, 0) with no comparators, networks without any comparator in the second layer (0, 0, 0, 12), (0, 12, 12), and networks with the word 21c, i.e., a redundant comparator. 9 n R(Hn) R(Tn) R(T ′ n) R(Gn) R(Sn) R(S′ n) 3 5 2 1 4 2 1 4 14 8 6 8 2 2 5 22 14 9 16 6 4 n R(Hn) R(Tn) R(T ′ n) R(Gn) R(Sn) R(S′ n) 18 53,325 35,356 19,191 6,422 651 411 7 84 58 36 52 14 8 6 50 32 23 20 6 5 19 8 178 123 83 61 15 12 20 90,021 59,576 31,301 26,796 2,632 1,367 155,518 102,182 54,352 15,906 1,478 894 9 300 211 127 165 37 22 10 588 404 256 152 27 21 11 1,004 698 403 482 88 48 12 1,900 1,305 786 414 70 50 13 3,234 2,223 1,245 1,378 212 117 14 5,904 3,996 2,304 1,024 136 94 15 10,054 6,812 3,712 3,780 494 262 16 17,959 12,046 6,716 2,627 323 211 17 30,435 20,372 10,879 10,187 1,149 609 21 261,204 171,172 88,847 69,498 5,988 3,098 22 445,800 290,270 152,011 38,392 3,040 1,787 23 745,198 483,982 248,867 177,388 13,514 6,920 24 1,259,611 813,798 421,233 92,989 6,744 3,848 25 2,095,183 1,349,972 689,320 447,765 30,312 15,469 26 3,511,839 2,252,214 1,155,520 221,836 14,036 7,830 Table 1: Values of R(Hn), R(Tn), R(T ′ n), R(Gn), R(Sn) and R(S ′ n) for n ≤ 26. Lemma 1. [7]. Let C and C′ be two-layer comparator networks on n channels. Then C ≈ C′ if and only if word(C) = word(C′). We denote by H m n the set of all possible n-channel two-layer network whose first layer has m comparators of the form (2i − 1, 2i), with 1 ≤ i ≤ m and 0 ≤ m ≤ (cid:4) n 2(cid:5). And by Hn the union of the entire sequence. 2 ⌋ ⌊ n [ Hn = H m n m=0 n with m = (cid:4) n The set H m 2(cid:5) is the set of networks with a fixed maximal first layer (denoted by Gn in [7]). The set of representatives of the equivalence classes of Hn and Gn is denoted by R(Hn) and R(Gn) respectively. For a given n the set R(Hn) can be generated from all multi-sets of valid words with a total of n channels. Figure 7 shows the complete R(H5) set. However, in the search for optimal networks we can remove prefixes with redundant comparators (word 12c), the empty network, and prefixes without any comparator in the second layer (with only the words 0 and 12 in its symbolic representation). We denote R(Tn) the resulting reduced set of prefixes. 4.1. Reflections It is well-known that a reflection of a sorting network is also a sorting network [12, 7]. Formally, the reflection of comparator network C is the network CR that replaces each comparator (i, j) in C with a comparator (n − j + 1, n − i + 1) in CR. Note that the reflection operation is not in general a permutation. Therefore, we can further reduce the number of prefixes in our complete set by removing those that are reflections of others. In the resulting symbolic representation of the complete set of two-layers prefixes, denoted by R(T ′ n), we keep the lexicographically smallest of the two sentences word(C) and word(CR). The symbolic representation word(CR) can be obtained from word(C) swapping min-channels with max- channels, and then selecting the lexicographically smallest representation for each type of word and for the whole sentence according to definitions 2 and 3. Figure 8 shows two equivalent two-layer prefixes up to reflection, and the corresponding sentence representation. Table 1 shows the cardinality of R(Hn), R(Tn) and R(T ′ the cardinality of R(Gn), saturated prefixes R(Sn) and saturated prefixes without reflections R(S′ interest in the optimal-depth sorting problem [7]. n) for n ≤ 26. For comparison, we also include n) of 10 Theorem 1. For any n ≥ 3, the set R(T ′ for the search of optimal sorting networks in size and depth. n) of two-layer comparator networks is a complete set of prefixes 5. Results Using the propositional encodings of section 3 and standard SAT solvers4, we can obtain optimal networks for n ≤ 10 channels in a few seconds. For n ≤ 9 channels, there are networks that are optimal in both size and depth (Figures 9, 10, 11, and 12). For n = 10 channels, optimal-depth sorting networks with 7 layers need a minimum of 31 comparators, while optimal-size sorting networks with 29 comparators require 8 layers (Figures 13 and 14). Theorem 2. The optimum size for a sorting network on 10 channels of depth 7 is 31. Theorem 3. The optimum depth for a sorting network on 10 channels with 29 comparators is 8. For n = 11 and n = 12 channels, we use the results of section 4 to fix the two first layers. The set of prefixes were also optimized with the evolutionary algorithm developed by Ehlers and Mller [11] to reduce the number of variables in the resulting SAT formula. The absolute minimal size S(n) for n = 11 channels is currently unknown. The lower bound on S(11) is 33, but only networks with a minimum of 35 comparators are known. Our depth-restricted results show that 35 is the optimal size for sorting networks with 8 or 9 layers. For n = 12 channels the lower bound of S(n) is 37 and the current upper bound 39. In this case we obtain that optimal-depth sorting networks with 8 layers need a minimum of 40 comparators while for sorting networks with 9 layers the minimum is 39 comparators. (Figures 20 and 21) For sorting networks on 11 channels with 8 layers, only 5 prefixes of the total of 403 prefixes in R(T ′ 11) give a network of size 35 (Figures 15, 16, 17, 18, 19). Note that the first layer of the network on Figure 17 is not maximal, i.e., the prefix is not an element of the set R(G11). For networks with s ≤ 34 comparators and d ≤ 9 layers all the propositional encodings with any of the 403 prefixes in R(T ′ 11) are unsatisfiable. Theorem 4. The optimum size for a sorting network on 11 channels of depth 8 or 9 is 35. For depth-optimal sorting networks on 12 channels with 8 layers, the minimum number of comparators is 40. This depth-restricted minimum size can be achieved with only 4 out of the 786 prefixes in R(T ′ 12). Figure 20 is an example with only 5 comparators in the first layer. We need to increment the number of layers to 9 to be able to obtain sorting networks on 12 channels with 39 comparators. Theorem 5. The optimum size for a sorting network on 12 channels of depth 8 is 40. For channels with more than 12 channels of more than 9 layers, the complexity of the SAT encoding begins to be out of the reach of current SAT solvers in the search of complete unsatisfiability results. However, we can use the proposed propositional encoding to obtain good networks for a given prefix in a few seconds or minutes, for example, a Green-type prefix [12]. 6. Conclusions We have addressed the joint size and depth optimization of sorting networks, to obtain depth-restricted minimum size results for sorting networks on n ≤ 12 channels. Our work extends the tools developed by Bundala et al. [7] for the search of depth-optimal networks. One of our contributions is the inclusion of size constraints in the propositional encoding of depth-restricted sorting networks. We have also addressed the symbolic representation of the general two-layer prefixes required in the proposed optimization problem. We have shown that for n = 10 channels, optimal-depth sorting networks with 7 layers need a minimum of 31 comparators, while optimal-size sorting networks with 29 comparators require 8 layers. The minimum size S(n) for sorting networks on n ≥ 11 channels is currently unknown. However, our results show that 35 is the minimum size for sorting networks on 11 channels with 8 or 9 layers, and 40 the minimum size for depth-optimal sorting networks on 12 channels with 8 layers. 4Unsatisfiability results were checked with 3 SAT solvers: minisat, glucose, and cryptosat 11 (01212) (01221) (02112) (02121) (0, 1212) (0, 1221) (0, 2112) (0, 1212c) (0, 1221c) (0, 0120) (0, 0, 012) (0, 0, 021) (0, 0, 0, 12) (0, 0, 0, 12c) (0, 0, 0, 0, 0) (0, 12, 12) (0, 12, 12c) (0, 12c, 12c) (012, 12) (021, 12) (012, 12c) (021, 12c) Figure 7: The complete set R(H5) of two-layer prefixes on 5 channels, including networks with redundant comparators: (0, 0, 0, 12c), (0, 12, 12c), (0, 12c, 12c), (012, 12c), (021, 12c), and networks without any comparator in the second layer: (0, 0, 0, 0, 0), (0, 0, 0, 12), (0, 12, 12). Hence, R(H5) = 22 and R(T5) = 22 − 5 − 3 = 14. 12 C CR CR c Figure 8: The network C R is the reflection of C, while C R The symbolic representation of C is (012, 0120, 1221c, 2112) while the normalized symbolic representation of C R (C R (0120, 021, 1221c, 2112). c = net(word(C R)) is the canonical permutation of network C R. c ) is References References [1] Ignasi Ab´ıo, Robert Nieuwenhuis, Albert Oliveras, and Enric Rodr´ıguez-Carbonell. A parametric approach for smaller and better encodings of cardinality constraints. In International Conference on Principles and Practice of Constraint Programming, pages 80 -- 96. Springer, 2013. [2] M. Ajtai, J. Koml´os, and E. Szemer´edi. Sorting in c log n parallel steps. Combinatorica, 3(1):1 -- 19, January 1983. [3] K. E. Batcher. Sorting networks and their applications. In Proceedings of the April 30 -- May 2, 1968, Spring Joint Computer Conference, AFIPS '68 (Spring), pages 307 -- 314, New York, NY, USA, 1968. ACM. [4] Dan Bogdanov, Sven Laur, and Riivo Talviste. A practical analysis of oblivious sorting algorithms for secure multi-party In Karin Bernsmed and Simone Fischer-Hubner, editors, Secure IT Systems, pages 59 -- 74, Cham, 2014. computation. Springer International Publishing. [5] N.G. De Bruijn. Sorting by means of swappings. Discrete Mathematics, 9(4):333 -- 339, 1974. [6] Daniel Bundala, Michael Codish, Lu´ıs Cruz-Filipe, Peter Schneider-Kamp, and Jakub Z´avodn´y. Optimal-depth sorting networks. CoRR, abs/1412.5302, 2014. [7] Daniel Bundala and Jakub Zavodny. Optimal sorting networks. In Language and Automata Theory and Applications - 8th International Conference, LATA 2014, Madrid, Spain, March 10-14, 2014. Proceedings, pages 236 -- 247, 2014. [8] Michael Codish, Lu´ıs Cruz-Filipe, Thorsten Ehlers, Mike Muller, and Peter Schneider-Kamp. Sorting networks: To the end and back again. Journal of Computer and System Sciences, 2016. [9] N.G. de Bruijn. Sorting arrays by means of swaps. Indagationes Mathematicae (Proceedings), 86(2):125 -- 132, 1983. [10] Bert Dobbelaere. Sorterhunter. an evolutionary approach to find small and low latency sorting networks. https://github.com/bertdobbelaere/SorterHunter, 2018. [11] Thorsten Ehlers and Mike Muller. New bounds on optimal sorting networks. In Conference on Computability in Europe, pages 167 -- 176. Springer, 2015. [12] Donald E. Knuth. The Art of Computer Programming, Volume 3: (2Nd Ed.) Sorting and Searching. Addison Wesley Longman Publishing Co., Inc., Redwood City, CA, USA, 1998. [13] Ian Parberry. A computer assisted optimal depth lower bound for sorting networks with nine inputs. In Supercomputing, 1989. Supercomputing'89. Proceedings of the 1989 ACM/IEEE Conference on, pages 152 -- 161, Nov 1989. 13 Figure 9: Optimal sorting networks on 2, 3, 4, and 5 channels with 1 layer and 1 comparator, 3 layers and 3 comparators, 3 layers and 5 comparators, and 5 layers and 9 comparators, respectively. Figure 10: Optimal sorting networks on 6 channels with 5 layers and 12 comparators, and on 7 channels with 6 layers and 16 comparators. Figure 11: Optimal sorting network on 8 channels with 6 layers and 19 comparators. Figure 12: Optimal sorting network on 9 channels with 7 layers and 25 comparators. 14 Figure 13: Optimal sorting network on 10 channels with 7 layers and 31 comparators. Figure 14: Optimal sorting network on 10 channels with 8 layers and 29 comparators. Figure 15: Optimal sorting network on 11 channels with 8 layers and 35 comparators. Prefix (012, 12211221c). 15 Figure 16: Optimal sorting network on 11 channels with 8 layers and 35 comparators. Prefix (012, 1212, 1221c). Figure 17: Optimal sorting network on 11 channels with 8 layers and 35 comparators. Prefix (012, 1221c, 1221c). Figure 18: Optimal sorting network on 11 channels with 8 layers and 35 comparators. Prefix (012, 0120, 1221c). 16 Figure 19: Optimal sorting network on 11 channels with 8 layers and 35 comparators. Prefix (0122112, 1221c). Figure 20: Optimal sorting network on 12 channels with 8 layers and 40 comparators. Figure 21: Optimal sorting network on 12 channels with 9 layers and 39 comparators. 17
1911.08320
1
1911
2019-11-19T14:52:50
Property Testing of LP-Type Problems
[ "cs.DS" ]
Given query access to a set of constraints $S$, we wish to quickly check if some objective function $\varphi$ subject to these constraints is at most a given value $k$. We approach this problem using the framework of property testing where our goal is to distinguish the case $\varphi(S) \le k$ from the case that at least an $\epsilon$ fraction of the constraints in $S$ need to be removed for $\varphi(S) \le k$ to hold. We restrict our attention to the case where $(S, \varphi)$ are LP-Type problems which is a rich family of combinatorial optimization problems with an inherent geometric structure. By utilizing a simple sampling procedure which has been used previously to study these problems, we are able to create property testers for any LP-Type problem whose query complexities are independent of the number of constraints. To the best of our knowledge, this is the first work that connects the area of LP-Type problems and property testing in a systematic way. Among our results is a tight upper bound on the query complexity of testing clusterability with one cluster considered by Alon, Dar, Parnas, and Ron (FOCS 2000). We also supply a corresponding tight lower bound for this problem and other LP-Type problems using geometric constructions.
cs.DS
cs
Property Testing of LP-Type Problems Rogers Epstein ∗ Sandeep Silwal † November 20, 2019 Abstract Given query access to a set of constraints S, we wish to quickly check if some objective function ϕ subject to these constraints is at most a given value k. We approach this problem using the framework of property testing where our goal is to distinguish the case ϕ(S) ≤ k from the case that at least an ǫ fraction of the constraints in S need to be removed for ϕ(S) ≤ k to hold. We restrict our attention to the case where (S, ϕ) are LP-Type problems which is a rich family of combinatorial optimization problems with an inherent geometric structure. By utilizing a simple sampling procedure which has been used previously to study these problems, we are able to create property testers for any LP-Type problem whose query complexities are independent of the number of constraints. To the best of our knowledge, this is the first work that connects the area of LP-Type problems and property testing in a systematic way. Among our results is a tight upper bound on the query complexity of testing clusterability with one cluster considered by Alon, Dar, Parnas, and Ron (FOCS 2000). We also supply a corresponding tight lower bound for this problem and other LP-Type problems using geometric constructions. 1 Introduction Many problems in combinatorial optimization can be represented as a pair ϕ(S) = (S, ϕ) where S is a set of constraints and ϕ is a function of the constraints that we would like to minimize. This class includes many problems that are NP-hard, even for the decision version of some problems where we would like to determine if ϕ(S) is at most some constant k. For instance, let S be the constraints that two nodes in a graph are connected by an edge (so S can be thought of as a set of edges) and ϕ be the chromatic number of a graph with those edges. Then it is NP-complete to determine if ϕ(S) ≤ 3. In this work, we consider a relaxation of the above hard class of problems by using the framework of property testing. Specifically, given a value parameter k and distance parameter ǫ, we wish to determine if ϕ(S) ≤ k or if (S, ϕ) is ǫ-far from ϕ(S) ≤ k, where ǫ-far means that at least ǫS many of the constraints of S need to be removed for ϕ(S) ≤ k to hold. We assume we have query access to the constraints and knowledge of ϕ and our goal is to perform the property testing task by looking at a 'small' number of constraints. Therefore, our query complexity is measured by how many constraints of S we see. Even under the property testing setting, this question is too broad. For example, property testing algorithms for sparse graph problems utilize very specific combinatorial properties of the problem (see [GGR98, GR98, GR02, Ron10, Gol17]) which means that it is not possible to study all combinatorial optimization problems together. Therefore, we focus our attention to an important class called LP-Type Problems, which are formally described in Definition 2.1. Informally, these problems have an underlying geometrical structure which can be used to create efficient testing algorithms. ∗Massachusetts Institute of Technology, Cambridge, MA 02139. Email: [email protected]. †Massachusetts Institute of Technology, Cambridge, MA 02139. Email: [email protected]. Research supported by the NSF Graduate Research Fellowship under Grant No. 1122374. Our main result is a 'meta' algorithm that is able to perform property testing for any LP-Type problem, and in many cases, is able to give tight upper bounds, such as a tight upper bound for a case of testing of clusterability considered in [ADPR00]. To the best of our knowledge, this is the first work that connects the area of LP-Type problems and property testing in a systematic way. The class of these problems is quite general and includes problems which have been previously studied individually in property testing, such as testing clusterability of points in [ADPR00], and newer testing problems, such as determining if a set of linear constraints is feasible or 'far' from feasible. We also give a matching lower bound for many of these problems using geometric constructions. For a comprehensive overview of our contributions, see Section 2.2. Related Work Many problems in property testing can be modeled as a set of constraints and some opti- mization function over these constraints. These include well studied graph problems such as bipartiteness, expansion, k-colorability, and many other problems [GGR98, GR98, GR02, Ron10]. This line of work was initiated by Goldreich and Ron and there are many results in the area of graph property testing. The query type for these problems usually are adjacency list and adjacency matrix queries where one can ask for a particular neighbor of a vertex or if an edge exists between two given vertices. For more information about graph property testing, see [Gol17] and the references within. Overall, these testing problems differ from our setting where our queries are essentially access to random constraints. This model where queries are accesses to constraints have also been studied in the case where we wish to test properties of a metric space and queries are access to points (see [Ona08, ADPR00, Ras03]). There are instances of these problems that are also examples of LP-Type problems that we consider. For more information, see Section 2.2. LP-Type problems have a rich literature and there have been many previous work on them, including general algorithms to solve LP-Type problems [Sei91, Cla95, SW92, MSW96]. The algorithms for these problems have runtimes that are generally linear in the number of constraints, but exponential in the dimen- sion of the LP-Type problem (see Definition 2.3). This is in contrast to our testing algorithms that have no dependence on the number of constraints. Furthermore, many properties of LP-Type problems have been generalized to a larger class of problems called violator spaces [GMR S06, BG09]. We do not explicitly consider them here since these problems do not yield any additional interesting property testing applications but our results carry over to this setting in a straightforward manner. Lastly, there is existing work on property testing for constraint satisfaction problems (CSPs) where given an instance of a CSP, one is given query access to an assignment of the variables and the task is to determine if the assignment is 'close' or 'far' from satisfying the instance [CVY16]. This is different than our setting where we wish to check if ϕ(S) ≤ k where ϕ is a function of the constraints in S. Organization In Section 2, we formally define the class of LP-Type problems. In Section 2.2 we outline our contributions. In Section 3, we present our algorithms and prove their correctness and in Section 4, we apply our algorithm to specific LP-Type problems. Finally, we complement some of these problems with lower bounds in Section 5. 2 Preliminaries 2.1 Notation and Definitions We formally define LP-Type problems as well as some related concepts. These definitions are standard in the literature for LP-Type problems but we reproduce them below for the sake of completeness. For more 1 information, see [SW92, MSW96, GW96]. Definition 2.1 (LP-Type Problem). Let S be a finite set and ϕ be a function that maps subsets of S to some value. We say (S, ϕ) is a LP-Type problem if ϕ satisfies the following two properties: • Monotonicity: if A ⊆ B ⊆ S then ϕ(A) ≤ ϕ(B) • Locality: For all A ⊆ B ⊆ S and elements x ∈ S, if ϕ(A) = ϕ(B) = ϕ(A ∪ {x}), then ϕ(A) = ϕ(B ∪ {x}). LP-Type problems have a natural definition of 'dimension' which influences the runtime of many algo- rithms for LP-Type problems as well as our algorithm for property testing of LP-Type problems. First, we must define the notion of a basis. Definition 2.2 (Basis of LP-Type problems). Given an LP-Type problem, a basis B ⊆ S is a set such that for all proper subsets B′ ⊂ B, we have ϕ(B′) < ϕ(B). Given the above definitions, we can now define the dimension of a LP-Type problem. Definition 2.3 (Dimension of LP-Type problem). The dimension δ of an LP-Type problem is the largest possible size of a basis B ⊆ S. This is sometimes also called the combinatorial dimension. An example of a LP-Type problem is when S is a set of linear inequalities in d dimensions and ϕ is a linear objective function. In this case, the dimension of this LP-Type problem corresponds to the usual notion of dimension and is equal to d [SW92, MSW96, Cla95]. There are many examples of well-studied LP-Type problems, and in many of these cases explicit bounds, if not exact values, are known regarding their dimensions. For more information, see our contributions in Section 2.2. In general, the dimension of the problem tends to grow with the 'difficulty' of solving it and for property testing, our query complexity bound is also a function of the dimension. We now formally define property testing for LP-Type problems. Definition 2.4 (Property Testing of LP-Type problems). Given an LP-Type problem (S, ϕ), a parameter k, a distance parameter ǫ, and query access to the constraints in S, we wish to distinguish the following two cases: • Output accept with probability at least 2/3 if ϕ(S) ≤ k (Completeness Case) • Output reject with probability at least 2/3 if at least ǫS constraints need to be removed from S for ϕ(S) ≤ k to hold (Soundness Case). Remark 2.5. We say that S is ǫ-far if it falls in the soundness case. 2.2 Our Contributions The main contribution of this paper is a comprehensive algorithm for property testing of LP-Type problems with query complexity O(δ/ǫ) where δ is the dimension of the LP-Type problem. Note that this bound is independent of the number of constraints which is S. Our algorithm is simple and proceeds by first sam- pling a small set of random constraints in S, constructing a partial solution, and 'testing' this partial solution against few other randomly chosen constraints. The analysis that we reject in the ǫ-far case (soundness) is straightforward. However, the main technical challenge lies in showing that our algorithm accepts in the completeness case. To do so, we use a 'sampling' lemma which roughly says that for a randomly chosen subset R of S of a particular size (depending on the dimension δ) and x a randomly chosen element of S\R, we have ϕ(R) = ϕ(R ∪ {x}). Using this result, we show that we are likely to accept in the completeness case. For the full detailed analysis, see Section 3. 2 We highlight the power of our approach by considering the query complexity bounds that we get for a few selected problems. In many cases, we are also able to get matching lower bounds. More specifically, we obtain the following results as an application of our framework: 1. We consider the problem of determining if a set of linear inequalities in d variables is feasible (there exists a satisfying assignment) or if at least ǫ-fraction of the constraints need to be removed for the set of constraints to be feasible. While this problem does not exactly fall under the LP-Type defini- tion (since there is no optimization function), we modify the 'meta' algorithm slightly to given an algorithm with query complexity is O(d/ǫ). 2. We study the problem of determining if a set of points in d dimensions labeled {+1,−1} is linearly separable or if at least ǫ-fraction of the points need to be relabeled or removed for the points to be linearly separable. Using result 1 above, we directly get a query complexity bound of O(d/ǫ). We also give a matching lower bound for this problem which implies a lower bound for result 1. 3. We obtain a result for property testing of many classical LP-Type problems. In particular, we consider the following problems: • Smallest enclosing ball: Accept if a set of points in Rd can be covered by a ball of radius r and reject if at least ǫ-fraction of the points need to be removed to be able to be covered by a ball of radius r. This problem has been previously studied in [ADPR00]. We beat the upper bound obtained in this paper by getting a tight query complexity of O(d/ǫ) queries (also see point 4 below). • Smallest intersecting ball: Accept if a set of closed convex bodies in Rd can all be intersected by a ball of radius r and reject if at least ǫ-fraction of the convex bodies need to be removed to be able to be intersected by a ball of radius r. • Smallest volume annulus: Accept if a set of points in Rd can be enclosed in an annulus of volume V and reject if at least ǫ-fraction of the points need to be removed to be encloseable by an annulus of volume V . In all these cases, it is known that the dimension of the LP-Type problem is linearly related to the dimension of the points in S, so we get an upper bound of O(d/ǫ) queries. 4. We get a matching lower bound of O(d/ǫ) queries for the smallest enclosing ball problem and the smallest intersecting ball problem. This provides a lower bound for the radius cost of clustering considered by Alon et al. in [ADPR00] in the case of 1 cluster. Remark 2.6. Note that there are also many examples of LP-Type problems where the constraints in S describe points in dimension d but the dimension of the LP-Type problem is not a linear function of d. For example, if ϕ(S) is the smallest ellipsoid that encloses the set of points in S which are in Rd, then (S, ϕ) has dimension O(d2) as a LP-Type problem [GW96]. We did not explicitly highlight these problems but our approach also gives an upper bound on the query complexity for the property testing versions of these problems. 3 Meta Algorithm for Property Testing of LP-Type problems We now present our 'meta' algorithm, LP-TYPE TESTER, for property testing of LP-Type problems as defined in Definition 2.4. Given a LP-Type problem (S, ϕ), Our algorithm first samples a subset R of O(δ/ǫ) constraints from S where δ is the dimension of the LP-Type problem. It then calculates the value of 3 ϕ on the sampled subset. After this step, an additional O(1/ǫ) constraints are sampled randomly from S. If ϕ(R ∪ {x}) differs from ϕ(R) where x is any of the additional random constraints, then our algorithm outputs reject. Otherwise, the algorithm outputs accept. We present our approach in Algorithm 1 along with our main theorem, Theorem 3.1 which proves the correctness of Algorithm 1. Algorithm 1: LP-TYPE TESTER : δ, ǫ, k, query access to constraints in S Input Output: accept or reject 1 r ← ⌈10δ/ǫ⌉ 2 R ← random sample of size r of constraints from S. 3 if ϕ(R) > k then 4 Output reject and abort. 5 for 2/ǫ rounds do 6 x ← uniformly random constraint of S \ R if ϕ(R ∪ {x}) 6= ϕ(R) then Output reject and abort. 7 8 9 Output accept. Theorem 3.1 (Correctness of LP-TYPE TESTER). Given an LP-Type problem (S, ϕ) of dimension δ and parameters k and ǫ, the following statements hold with probability at least 2/3: • Completeness case: LP-TYPE TESTER outputs accept ϕ(S) ≤ k. • Soundness Case: LP-TYPE TESTER outputs reject if at least ǫS constraints need to be removed from S for ϕ(S) ≤ k to hold. Remark 3.2. Note that the query complexity of Algorithm 1 is O(δ/ǫ) which is independent of S, the number of constraints. Furthermore, the runtime is polynomial in δ/ǫ since we are only solving O(1/ǫ) linear programs in δ variables and O(δ/ǫ) constraints. Overview of the proof To prove the correctness of LP-TYPE TESTER, we analyze the completeness case and the soundness case separately. For the soundness case, we show that with sufficiently large probability, either ϕ(R) > k or LP-TYPE TESTER outputs reject during the second sampling phase where we sample an additional O(1/ǫ) constraints. To show this, we use the locality property of LP-Type problems (see Defi- nition 2.1) to show that there must be 'many' x such that ϕ(R∪{x}) 6= ϕ(R). To analyze the completeness case, we use the Sampling Lemma, Lemma 3.5, to show that there are 'few' x such that ϕ(R∪{x}) 6= ϕ(R) so that Algorithm 1 outputs accept with sufficiently large probability. Before we present the proof of Theorem 3.1, we present the Sampling Lemma as described above. This lemma has previously been used to study LP-Type problems. For completeness, we present a proof. For more information, see [SW92, MSW96, GMR S06, GW01]. Before we present the lemma, we introduce two new definitions. Definition 3.3 (Violators and Extreme Elements). For a subset R ⊆ S, define the violators and extreme elements of R as the following: • Define the violators of R as the set V (R) = {s ∈ S\R ϕ(R ∪ {s}) 6= ϕ(R)}. • Define the extreme elements of R as the set X(R) = {s ∈ R ϕ(R) 6= ϕ(R\{s}}. 4 Remark 3.4. Note that s is a violator of R if and only if s is an extreme element of in R ∪ {s}. We now present the Sampling Lemma. Lemma 3.5 (Sampling Lemma). Let vr = E[V (R)] and xr = E[X(R)] where both expectations are taken over the random subsets R of S which have size r. Suppose S = n. Then for 0 ≤ r ≤ n, we have vr n − r = xr+1 r + 1 . Proof. Let 1{·} denote an indicator variable. Note that (cid:18)n r(cid:19)vr = XR∈(S = XQ∈( S r) Xs∈S\R r+1)Xs∈Q 1{s is a violator of R} = XR∈(S 1{s is extreme for Q} =(cid:18) n r) Xs∈S\R r + 1(cid:19)xr+1. 1{s is extreme for R ∪ {s}} Since the proof is complete. (cid:0) n r+1(cid:1) (cid:0)n r(cid:1) = r!(n − r)! (r + 1)!(n − r − 1)! = n − r r + 1 , Remark 3.6. Note that (S, ϕ) does not need to be a LP-Type problem for the Sampling Lemma to hold true. If (S, ϕ) is a LP-Type problem, there is a direct relationship between the expected number of violators and the dimension of (S, ϕ) as defined in 2.3. The following corollary also appears in many forms in literature (for instance [SW92, MSW96, GMR S06, BG09]) but we present its proof for completeness. Corollary 3.7. Let (S, ϕ) be a LP-Type problem of dimension δ and let S = n. If R ⊆ S is subset of size r chosen uniformly at random, then vr = E[V (R)] satisfies δ(n − r) r + 1 vr ≤ . Proof. We show that for any set R ⊆ S, we have X(R) ≤ δ. Then the corollary follows from Lemma 3.5. Let R′ be the smallest subset of R such that ϕ(R′) = ϕ(R). We first claim that V (R′) = V (R). It is clear that V (R) ⊆ V (R′) by monotonicity (see Definition 2.1). For the other inclusion, consider x ∈ V (R′). If x 6∈ V (R), we have ϕ(R ∪ {x}) = ϕ(R) = ϕ(R′) so by locality, we have ϕ(R′) = ϕ(R′ ∪ {x}) which contradicts the fact that x ∈ V (R′). Therefore, our claim holds true. We now claim that R′ is a basis as defined in Definition 2.2. Suppose for the sake of contradiction that R′ is not a basis. Then there exists a F ⊂ R′ such that ϕ(F ) = ϕ(R′). We now claim that V (R′) = V (F ). It is clear that V (R′) ⊆ V (F ). To show the other inclusion, let x ∈ V (F ). Then if x was not a violator of R′, then ϕ(R′ ∪ {x}) = ϕ(R′) = ϕ(F ) which would imply that ϕ(F ∪ {x}) = ϕ(F ) by the locality property in Definition 2.1 which is false by definition. Hence, V (F ) = V (R′) = V (R) which contradicts the minimality of R′. Therefore, R′ is a basis. Finally, we claim that if x ∈ X(R) then x ∈ R′. This must be true because otherwise, we have R′ ⊆ R \ {x} ⊆ R which results in a contradiction by monotonicity. Finally, since X(R) ⊆ R′ and R′ is a basis, it follows that X(R) ≤ δ, as desired. Remark 3.8. Corollary 3.7 holds for a larger class of problems than LP-Type problems called violator spaces ([GMR S06, BG09]. However, we omitted this extra layer of abstraction since there are no additional natural property testing consequences from considering violator spaces over LP-Type problems. 5 Proof of Theorem 3.1. We first prove the soundness case. Consider the set R that was randomly sampled in step 2 of LP-TYPE TESTER. Assume that ϕ(R) ≤ k since this can only decrease the probability that our algorithm outputs reject. Now we claim that there must be at least ǫS choices of x in step 6 of LP-TYPE TESTER that results in ϕ(R ∪ {x}) > ϕ(R) (so that we correctly output reject). To show this, note that if ϕ(R) = ϕ(R ∪ {x}) = ϕ(R ∪ {y}) for x 6= y then by locality, it follows that ϕ(R) = ϕ(R ∪ {x, y}). Therefore, if there are less than ǫS choices of x in step 6 of LP-TYPE TESTER such that ϕ(R ∪ {x}) > ϕ(R), then we would have ϕ(R∪ R′) = ϕ(R) ≤ k where R∪ R′ ≥ (1− ǫ)S which would contradict our assumption that at least ǫS constraints need to be removed from S for ϕ(S) ≤ k to hold true. Therefore, the probability our algorithm does not output reject in any of the 2/ǫ rounds is at most (1 − ǫ)2/ǫ ≤ e−2 < 1 3 (1) which means that we output reject with probability at least 2/3, as desired. We now prove Theorem 3.1 for the completeness case. Let vr = E[V (R)]. Since r = R = 10δ/ǫ, Corollary 3.7 gives us vr ≤ δ(S − r) r + 1 ≤ ǫS 10 . Therefore in the completeness case, the probability that a randomly chosen x satisfies ϕ(R ∪ {x}) 6= ϕ(R) is at most ǫ/10. Since we choose 2/ǫ random constraints, the probability we don't find such a x is at least (1 − ǫ/10)2/ǫ ≥ 1 − 2 10 > 2 3 . (2) Therefore, LP-TYPE TESTER outputs accept with probability at least 2/3, as desired. 4 Property Testing Applications of LP-TYPE TESTER We now give applications of the framework we build in Section 3. We first consider the problem of testing feasibility of a set of linear inequalities. As a direct consequence, we can test if a set of labeled points can be linearly sepearable (either by linear hyperplanes or by functions that have a finite basis). These two applications will not be an immediate corollary of Theorem 3.1 since there is no objective function that we want to optimize, but our results follow from Theorem 3.1 with some slight modificatons. We then consider direct applications of Algorithm 1 to some cannonical LP-Type problems such as the smallest enclosing ball. Theorem 3.1 gives direct upper bounds for property testing for these problems. 4.1 Testing Feasibility of a System of Linear Equations We first begin by considering testing feasibility of a set of linear inequalities. Recall that in this problem, we have n linear constraints in Rd (such as x1 +··· + xd ≤ 1) and we want to distinguish the following two cases with probability at least 2/3: • The system of linear inequalities can all be mutually satisfied, i.e., the system is feasible (Complete- ness Case) • At least ǫS many of the constraints need to be removed (or flipped) for the system to be feasible (Soundness Case). This is not exactly a LP-Type problem since we do not have an optimization function ϕ. (Note that if ϕ was an indicator function for a subset of constraints being feasible then ϕ would break the locality condition in 6 Definition 2.1). However, we perform a slight modification of Algorithm 1 to create a new algorithm for this problem. Our algorithm for this testing problem, LINEAR FEASIBILITY TESTER, uses the fact that if we pick any arbitrary x ∈ Rd, then x will violate 'many' of the linear constraints in S in the completeness case. In the soundness case, we use ideas from LP-TYPE TESTER and show that if we introduce an arbitrary linear optimization function (thus turning our problem into an instance of linear programming), then a solution that optimizes a small subset of the constraints will not violate 'too many' of the other constraints. We present our algorithm below along with Theorem 4.1 that proves its correctness. Algorithm 2: LINEAR FEASIBILITY TESTER : d, ǫ, query access to constraints of S Input Output: Accept or Reject 1 r ← ⌈10d/ǫ⌉ 2 R ← random sample of size r of constraints from S 3 Create the linear program L: max x1 subject to the constraints in R 4 x ← solution of L 5 if L is not feasible then Reject and abort 6 7 for 2/ǫ rounds do 8 y ← uniformly random constraint of S if x does not satisfy y then Output reject and abort. 9 10 11 Output accept. Theorem 4.1 (Correctness of LINEAR FEASIBILITY TESTER). Given a set S of linear inequalities in Rd, the following statements hold with probability at least 2/3: • Completeness case: LINEAR FEASIBILITY TESTER outputs accept if there exists x ∈ Rd that satis- fies all of the constraints in S. • Soundness Case: LINEAR FEASIBILITY TESTER outputs reject if at least ǫS constraints need to be removed from S for S to be feasible. Remark 4.2. Note that the query complexity of Algorithm 1 is O(d/ǫ) which is independent of S, the number of constraints. Proof. The proof of the soundness case follows similarly to Theorem 3.1 using the fact that for any x, there are at least ǫS constraints in x such that x violates these constraints. Then the probability that LINEAR FEASIBILITY TESTER outputs reject in this case can be calculated to be at least 2/3 using the same bound as Eq. (1) in the proof of Theorem 3.1. For the completeness case, we note that if we introduce the optimization function ϕ(S) = max x1 sub- ject to the constraints in S, then (S, ϕ) is an LP-Type problem of dimension d (assuming that the constraints are non degenerate which can be assumed by perturbing the constraints and then taking the limit of the per- turbation to 0. For more details, see [Cla95, Sei91]). Now let x be the solution to the linear program that we solved in Step 4 of LINEAR FEASIBILITY TESTER. Using Corollary 3.7, we know that if R = 10⌈d/ǫ⌉, then the number of constraints vr in S that satisfy ϕ(R ∪ {y}) 6= ϕ(R) is at most vr ≤ dS r ≤ ǫS 10 7 in expectation. Knowing that x not satisfying y implies that y is a violator of R, the probability that x does not satisfy a randomly chosen y is at most ǫ/10. Thus, using the exact calculation as in Eq.(2) of Theorem 3.1, we have that LINEAR FEASIBILITY TESTER outputs accept in the completeness case with probability at least 2/3, as desired. 4.1.1 Testing if Labeled Points can be Linearly Separated As a direct consequence of the Theorem 4.1, we can test if a set of points in d dimensions labeled {+1,−1} can be linearly separated. More formally, we have the following corollary. Corollary 4.3. Given a set S of points in Rd with labels in {+1,−1}, the following statements hold with probability at least 2/3: • Completeness case: LINEAR FEASIBILITY TESTER outputs accept if there exists a hyperplane that separates the two sets of labeled points. • Soundness Case: LINEAR FEASIBILITY TESTER outputs reject if at least ǫS points need to be removed (or relabeled) for S to be linearly sepearable. Proof. The proof follows directly from the fact that we can write a linear inequality that represents a sep- arating hyperplane. For example, if p ∈ S is labeled 1, we want to find x such that pT x ≥ 1 and if p is labeled −1, we want to find x such that pT x ≤ −1. We consider generalizations of this problem where we wish to separate labelled points by arbitrary functions, rather than just linear hyperplanes, and where points can have multiple labels. Separating labeled points using arbitrary functions: We can generalize our result by separating labeled points using arbitrary functions: given a family of functions F , we can ask if there is a f ∈ F such that f (p) > 0 for all points with a particular label and f (p) < 0 for all the points with the other label. We now translate this problem to a setting with linear inequalities. Our approach is standard in machine learning and is known as feature maps. If the family F has a finite basis f1,··· , fk, meaning that every f ∈ F is a linear combination of f1,··· , fk, then we can create a system of linear inequalities as follows. For each point p ∈ S, we can make a new constraint which is (f1(p),··· , fk(p))x ≥ 1 (note there that x is a column vector of variables) if p has one particular label or ≤ −1 if p has another label. Then this system of linear constraints is feasible iff there are scalars a1,··· , ak such thatPi aifi(p) ≥ 0 for all p with one label and Pi aifi(p) ≤ 0 for all p with the other label. Then our separating function is precisely f = Pi aifi. As an example, we consider the case that F is the family of polynomials in d variables with degree ≤ t. d where the ti are non-negative and add d (cid:1). For constant t, this to at most t. By a standard balls and bins argument, the number of these terms is(cid:0)t+d is O(dt), which means that our system of linear constraints has O(dt) variables. Thus, the query complexity is O(dt/ǫ). Note that in this formulation, we have k variables. Thus, the query complexity is O(k/ǫ). The basis of this family is all the possible terms of the form xt1 1 ··· xtd Separating points with multiple labels Suppose that instead of assigning each point one of 2 labels, we instead chose to assign it one of ℓ ≥ 2 labels. One common interpretation of separability for this setup is to check if each of the(cid:0)ℓ Definition 4.4. S is ǫ-far from linearly separable if at least ǫS many labels in S have to be changed for S to be separable. 2(cid:1) pairs of label sets are separable. We modify our notion of ǫ-far to reflect this. 8 far from separable. As such, we can consider an algorithm that runs Algorithm LINEAR FEASIBILITY TESTER on each pair of labels with ǫ′ = ǫ/(cid:0)ℓ If such a data set is ǫ-far from separable, then some subset with consisting of two labels must be ǫ/(cid:0)ℓ 2(cid:1)- 2(cid:1) and outputs accept if all these tests output accept. We need to reduce the error probability for each pair such that the overall error probability of outputting the incorrect answer (acquired by a union bound) is still at most 1/3. This can be done by using a stronger version of the original algorithm where we run it 108 log ℓ = O(log ℓ) times and taking the majority answer. By a standard Chernoff bound argument, the probability this process gives the wrong answer is at most e−( 1 3 ∗108 log ℓ/3 ≤ 1/ℓ3. Thus, we can distinguish separability in this case by running this stronger version over all pairs of distinct labels, resulting in O(ℓ2 log ℓ) instances of LINEAR FEASIBILITY TESTER, 2 )2 1 using ǫ′ = ǫ/(cid:0)ℓ 2(cid:1). So, the total query complexity will be O(dℓ4 log ℓ/ǫ). Additionally, the completeness case has error at most(cid:0)l Clearly, the soundness case has error at most 1/ℓ3, since there is one pair of distinct labels which is ǫ′-far from separable. 2(cid:1) ∗ 1/ℓ3 = o(1) by a Union Bound argument. 4.2 Upper Bounds for Canonical LP-Type Problems We now give direct applications of LP-TYPE TESTER to some canonical LP-Type problems. The correct- ness of these applications follows directly from Theorem 3.1. Our list is not exhaustive and we only consider some of the more well known LP-Type problems. In all of the following problems, Theorem 3.1 tells us that the following statements hold with probability at least 2/3: • LP-TYPE TESTER outputs accept if ϕ(S) ≤ k (Completeness Case) • LP-TYPE TESTER outputs reject if at least ǫS constraints need to be removed from S for ϕ(S) ≤ k to hold (Soundness Case). Our results are the following: • Smallest enclosing ball: In this problem, ϕ(S) is the radius of the smallest enclosing ball of a set of points S in Rd. It is known that the dimension of this LP-Type problem is d + 1 (see [GW96]) so we can test if ϕ(S) ≤ k with query complexity O(d/ǫ) queries. • Smallest intersecting ball: In this problem, ϕ(S) is the smallest radius ball that intersects a set of closed convex bodies S in Rd. The dimension of this LP-Type problem is O(d) ([GW96]) so we can test if ϕ(S) ≤ k with query complexity O(d/ǫ) queries. • Smallest volume annulus: In this problem, ϕ(S) is the volume of the smallest annulus that contains a set of points S in Rd. Again, the dimension of this LP-Type problem is O(d) ( [GW96]) so we can test if ϕ(S) ≤ k with query complexity O(d/ǫ). 5 Lower Bounds In this section, we give matching lower bounds for all the testing problems that we considered in Section 4. 5.1 Lower Bound for Testing Feasibility of Linear Constraints Since linear separability is a special case of feasibility of linear constraints, we can lower bound the nec- essary query complexity of the latter by providing one for the former. In particular, we aim to show that 9 Ω(d/ǫ) queries are needed to determine if a set of points in d dimensions is linearly separable. By the re- duction of linear separability to feasibility of linear constraints, this implies that Ω(d/ǫ) constraint queries are needed to test feasibility of a system of linear constraints, which matches our upper bound. Our overall approach is to first introduce a set of O(d) points in Rd that have the property that if we do not look at a large enough collection of these points, they can be separated by a hyperplane even with arbitrary labels. However, there will exist a labeling of all of the points such that 'many' of the points will have to be removed or relabeled for this labeling to be separated. The existence of these points is given in Lemma 5.1 (and is inspired by the moment curve). Then, repeating these points with carefully chosen multiplicities allows us to construct our set S of points. Then a coupon collector argument gives us our desired lower bound on the query complexity. This argument is formalized in the proof of Theorem 5.2. Lemma 5.1. There exists a set S of 3d + 1 points in Rd that satisfy the following conditions: 1. There exists a labeling of the points of S such that at least d points have to be relabeled for the points to be linearly separable. 2. Any subset of points of S of size d + 1 with arbitrary labels in {−1, 1} is linearly separable. Proof. We construct our set S as follows. Let xi be the point (i1,··· , id) ∈ Rd for 1 ≤ i ≤ 3d + 1 (note that this set of points is referred to as the moment curve). We prove the first claim using a standard relationship between the moment curve and polynomials. Assign the point xi to the label (−1)i. Let k be the number of relabeled points such that S is linearly separable. Then there exists w ∈ Rd and w0 ∈ R such that Sign(xT i w + w0) matches the label of every point xi ∈ S. In other words, there exists a polynomial P (x) = cjxj d Xj=0 (3) such that Sign(P (i)) matches the label of xi. Now note that if there are two consecutive indices i and i + 1 that have different labels, then P must have a root in the interval (i, i + 1). Originally, there are 3d such alternating intervals. Now note that the relabeling of any point can decrease the total number of such alternating intervals by at most 2. Hence after k relabelings, there must be at least 3d − 2k alternating intervals. However, since P is a d degree polynomial, it must have at most d roots which means 3d− 2k ≤ d and therefore, k ≥ d, as desired. We now prove the second claim. Let xa1,··· , xad+1 be a subset of d + 1 points of S. Without loss of generality, suppose that a1 < ··· < ad+1. We now show that for every labelings of these d + 1 points, there exists a polynomial of degree d such that the sign of P (ai) matches the label of xai . Towards this goal, pick t elements b1,··· , bt of the set {a2,··· , ad+1} where t ≤ d. Consider the t + 1 intervals We can then find a polynomial of degree d such that [a1, b1), [b1, b2),··· , [bt−1, bt), [bt, ad+1 + 1). • the sign of P is constant on I ∩ {a1, a2,··· , ad+1} where I is any of the t + 1 intervals above, • the sign of P alternates between consecutive intervals. 10 This is possible since we are only specifying the value of P on d + 1 locations. Now the total number of labelings described by all possible choices of P is given by 2 d Xt=0(cid:18)d t(cid:19) = 2d+1 where the factor of 2 comes from specifying the sign of P on the first interval. Note that 2d+1 is exactly the total number of different ways to label d + 1 points, which proves the second claim. With Lemma 5.1 on hand, we can prove our desired lower bound on the query complexity. Theorem 5.2. Any algorithm that tests if a set S of labeled points in d dimensions can be linearly separated requires Ω(d/ǫ) queries. Proof. Let S = n. We create two families of n points in Rd with a specific labeling such that any S from one family can be linearly separated while any S from the other family is ǫ-far from being linearly separable. First, consider the set of 3d + 1 points supplied by Lemma 5.1 and the labeling from part 1 of the lemma. The first family F1 consists of picking a subset of d + 1 of these points (with the labeling above), repeating d of these points nǫ/d times, and repeating the remaining point (1− ǫ)n times. The second family F2 (again with the same labeling) consists of picking all of the 3d + 1 points from Lemma 5.1, repeating some 3d of these points with multiplicity nǫ/(3d), and repeating the last point with multiplicity (1 − ǫ)n. By Lemma 5.1, we know that if S is from F1 then S is linearly separable while if S is from F2, then S is at least ǫ/(3d) · d = O(ǫ)-far from separable. Any algorithm that queries points randomly must discover at least d + 1 unique points out of the points that were repeated nǫ/d time from any S in F2 to discover that this S is O(ǫ)-far from separable (otherwise, the points look separable). Call points that are identical 'groups'. Now given a random point from S, the probability of hitting any one group is ǫ/(3d). Therefore by coupon collector, the expected number of queries required to hit at least d + 1 of these 3d groups is at least 1 ǫ (cid:18)3d 3d + 3d 3d − 1 + ··· + 3d 3d − d(cid:19) = 3d ǫ (H3d − H2d−1) = Θ(cid:18)d ǫ(cid:19) , as desired. As a corollary, we have the following lower bound as well. This is due to the reduction from linear separability to linear program feasibility from the proof of Corollary 4.3. Theorem 5.3. Any algorithm that tests if n linear inequalities in d dimensions are feasible requires Ω(d/ǫ) queries. We now give matching query complexity lower bounds for the LP-Type problems that we considered in Section 4. 5.2 Lower bound for Testing Smallest Enclosing Ball We first give a lower bound for property testing the radius of the smallest enclosing ball of a set of points. Our approach is to first construct a set of points in Rj, for any j, whose smallest enclosing ball can be calculated exactly. This set of points will have the property that a small enough subset of the points will have a significantly smaller enclosing ball. Therefore, if an algorithm does not query enough points, it will incorrectly believe that this set of points can be covered by a ball of small radius. Our construction for this case will be a regular simplex and explained below. Lemma 5.4. The radius of the circumcircle of a unit simplex in Rj is √j/(p2(j + 1)). 11 Proof. Note that we can embed a regular j-simplex in Rj+1 using the coordinates {ei}j+1 i=1 where ei is the all zero vector with a single 1 in the ith coordinate. This simplex has edge length √2 so we can scale appropriately to find the circumcircle of a unit simplex. Now the centroid of this simplex is easily seen to be located at (1/(j + 1),··· , 1/(j + 1)) which means that the circumcircle has radius 1 j + s(cid:18)1 − j + 1(cid:19)2 Now scaling by 1/√2 gives us the desired value. Theorem 5.5. Any algorithm that tests if a set of n points in Rd can be enclosed by a ball of radius k, where k is given, requires Ω(d/ǫ) queries. (j + 1)2 =s j . j + 1 Proof. Let k be fixed. We construct two families of points in RO(d) such that any S from one family can be enclosed by a ball of radius k while any S from the second family is ǫ-far from being enclosed by a ball of radius k. Before constructing these families, we first pick ℓ such that the regular simplex of side length ℓ in Rd+1 has circumradius k. Now to create the first family F1, we first pick any d + 1 points of the regular simplex with side length ℓ in R3d+1. Then we repeat one of these points with multiplicity (1 − ǫ)n and we repeat the other d points with multiplicity nǫ/d each. To create the second family F2, we pick a point of the regular simplex with side length ℓ in R3d+1, repeat it with multiplicity (1 − ǫ)n, and repeat the other 3d points with multiplicity nǫ/(3d). Finally, let S be a set of n points from F2. We can check that the circumradius of a regular unit simplex is an increasing function of the dimension and that any subset of the vertices of a regular simplex is a regular simplex itself. Therefore, the smallest radius of the points in S is much larger than k and S is O(ǫ)-far from being encloseable by a ball of radius k. However, similar to the argument in Theorem 5.2, any algorithm that rejects S must have discovered at least d + 1 distinct 'groups' of repeated points. By the same coupon collector argument as in the proof of Theorem 5.2, we have that this task takes at least Ω(d/ǫ) queries in expectation. As a simple application of Theorem 5.5, we get the following lower bounds as well. Corollary 5.6. Any algorithm for testing the smallest intersecting ball for n convex bodies in Rd requires Ω(d/ǫ) queries. Proof. The proof follows from the fact that a set of singleton points is also a set of convex bodies. In this case, the smallest intersecting ball is equivalent to the smallest ball that encloses these points. Therefore, the same lower bound as in Theorem 5.5 holds. Appendices A Tolerant Tester for Testing Feasibility of Linear Constraints We generalize our argument in Section 4.1 by giving a tolerant tester for testing feasibility of a system of linear constraints. In the tolerant version, we output accept if there only 'few' constraints need to be removed for a set of linear inequalities to be feasible. More formally, we wish to distinguish the following two cases with probability at least 2/3: • At most cǫS many inequalities in S need to be removed for S (or flipped) for S to be feasible, i.e., S is cǫ-close to being feasible for some fixed c < 1 (Completeness Case). 12 • At least ǫS many of the constraints need to be removed (or flipped) for the system to be feasible (Soundness Case). Our approach is a slightly modified version of LINEAR FEASIBILITY TESTER, Algorithm 2, that we presented in Section 4.1. The challenge here is the completeness case where we must accept if we only have a 'few' bad constraints. To accomplish this, we carefully select a solution to a small linear program that we run. For more details, see Algorithm 3. Our main theorem in this section, Theorem A.1 shows that we can perform tolerant testing using the same query complexity we used for the one-sided tester in Section 4.1, namely O(d/ǫ). However, as we will explain below, the running time of Algorithm 3, TOLERANT LINEAR FEASIBILITY TESTER, is exponential in the running time of Algorithm 2. Our algorithm, TOLERANT LINEAR FEASIBILITY TESTER, is presented below. Algorithm 3: TOLERANT LINEAR FEASIBILITY TESTER : d, ǫ, query access to constraints of LP Input Output: Accept or Reject 1 r ← ⌈10d/ǫ⌉ 2 R ← random sample of size r of constraints from S 3 x ← solution of the largest subset R′ of R such that the linear program L: max x1 subject to the constraints in R′ is feasible 4 if No L is not feasible then 5 Reject and abort 6 for 2/ǫ rounds do 7 y ← uniformly random constraint of S if x does not satisfy y then Output reject and abort. 8 9 10 Output accept. Unlike LINEAR FEASIBILITY TESTER where we run a linear program, we solve a slightly different program given in step 3 of TOLERANT LINEAR FEASIBILITY TESTER. The step determines the largest feasible subset of these constraints. Note that this step is clearly exponential in the number of constraints (which is O(d/ǫ)). Therefore, the overall runtime of TOLERANT LINEAR FEASIBILITY TESTER will be exponential in the runtime of LINEAR FEASIBILITY TESTER. The correctness of TOLERANT LINEAR FEASIBILITY TESTER is proven in Theorem A.1. Theorem A.1 (Correctness of TOLERANT LINEAR FEASIBILITY TESTER). Given a set S of linear in- equalities in Rd, there exists a constant c < 1 such that the following statements hold with probability at least 2/3: • Completeness case: TOLERANT LINEAR FEASIBILITY TESTER outputs accept if there exists x ∈ Rd that satisfies (1 − cǫ)S of the constraints in S. • Soundness Case: TOLERANT LINEAR FEASIBILITY TESTER outputs reject if at least ǫS con- straints need to be removed from S for S to be feasible. Remark A.2. Note that the query complexity of Algorithm 3 is O(d/ǫ) which is independent of S, the number of constraints. Proof. Note that the proof of the soundness case is identical to the proof of the soundness case in Theorem 4.1 since for any x we find in step 3 of TOLERANT LINEAR FEASIBILITY TESTER, there exists at least ǫS 13 choices of y in step 7 such that x does not satisfy the constraint y. Then a similar calculation as in Eq. (1) implies that we reject with probability at least 2/3. We now focus on the completeness case where we know there is a subset of (1 − cǫ)S constraints that are feasible. We call this the good set, and the rest, the bad set. Consider the sample R from step 2 of TOLERANT LINEAR FEASIBILITY TESTER. The expected number of constraints from the good set in R is (1 − cǫ)r. This means at most cǫr constraints in R come from the bad set in expectation. Hence with probability at least 9/10, we know that the number of constraints from the bad set is at most 10cǫr by Markov's inequality, which means the number of constraints coming from the good set is at least (1−10cǫ)r. We condition on this event. Now note that one valid subset R′ to use in step 3 of TOLERANT LINEAR FEASIBILITY TESTER is to take all the constraints coming from the good set only. This results in R′ ≥ (1 − 10cǫ). Since we are maximizing R′, this means that at most 10cǫr of the constraints coming from the good set that are in R will not be included in R′. Thus, x satisfies at least (1− 20cǫ)r constraints in the good set with probability at least 9/10. Now we proceed similarly as the proof of Theorem 4.1. By Corollary 3.7, the probability that x violates any other constraint in the good set is at most d(n′ − r + 1) n′(r − d) ≤ dn′ 10dn′/ǫ = ǫ 10 where n′ is the size of the good set. Furthermore, x can possibly violate any constraint in the bad set which means that the probability x violates any other constraint is at most ǫ/10 + cǫ < ǫ/6 for sufficiently small c. Then, the probability that we find such a constraint in 2/ǫ rounds is at most 1 −(cid:16)1 − ǫ 6(cid:17)2/ǫ ≤ 1 −(cid:18)1 − 1 3(cid:19) = 1 3 . Therefore, we accept with probability at least 2/3, as desired. Note that we can take any c < 1/15 in the statement of the Theorem for instance. Acknowledgements We would like to thank Ronitt Rubinfeld, Piotr Indyk, Bertie Ancona, and Rikhav Shah for helpful feedback. References [ADPR00] N. Alon, S. Dar, M. Parnas, and D. Ron. Testing of clustering. In Proceedings 41st Annual Symposium on Foundations of Computer Science, pages 240 -- 250, Nov 2000. [BG09] [Cla95] Yves Brise and Bernd Gartner. Clarksons algorithm for violator spaces. CoRR, abs/0906.4706, 2009. Kenneth L. Clarkson. Las vegas algorithms for linear and integer programming when the di- mension is small. J. ACM, 42(2):488 -- 499, March 1995. [CVY16] H. Chen, M. Valeriote, and Y. Yoshida. Testing assignments to constraint satisfaction problems. In 2016 IEEE 57th Annual Symposium on Foundations of Computer Science (FOCS), pages 525 -- 534, Oct 2016. [GGR98] Oded Goldreich, Shari Goldwasser, and Dana Ron. Property testing and its connection to learning and approximation. J. ACM, 45(4):653 -- 750, July 1998. 14 [GMR S06] Bernd Gartner, Jir´ı Matousek, Leo R ust, and Petr Skovron. Violator spaces: Structure and algorithms. In Yossi Azar and Thomas Erlebach, editors, Algorithms -- ESA 2006, pages 387 -- 398, Berlin, Heidelberg, 2006. Springer Berlin Heidelberg. [Gol17] Oded Goldreich. Introduction to Property Testing. Cambridge University Press, 2017. [GR98] Oded Goldreich and Dana Ron. A sublinear bipartiteness tester for bounded degree graphs. In Proceedings of the Thirtieth Annual ACM Symposium on Theory of Computing, STOC '98, pages 289 -- 298, New York, NY, USA, 1998. ACM. [GR02] Oded Goldreich and Dana Ron. Property testing in bounded degree graphs. Algorithmica, 32(2):302 -- 343, 2002. [GW96] Bernd Gartner and Emo Welzl. Linear programming -- randomization and abstract frameworks. In Claude Puech and R udiger Reischuk, editors, STACS 96, pages 667 -- 687, Berlin, Heidelberg, 1996. Springer Berlin Heidelberg. [GW01] B. Gartner and E. Welzl. A simple sampling lemma: Analysis and applications in geometric optimization. Discrete & Computational Geometry, 25(4):569 -- 590, Apr 2001. [MSW96] J. Matousek, M. Sharir, and E. Welzl. A subexponential bound for linear programming. Algo- rithmica, 16(4):498 -- 516, Oct 1996. [Ona08] [Ras03] Krzysztof Onak. Testing properties of sets of points in metric spaces. In Automata, Languages and Programming, 35th International Colloquium, ICALP 2008, Reykjavik, Iceland, July 7- 11, 2008, Proceedings, Part I: Tack A: Algorithms, Automata, Complexity, and Games, pages 515 -- 526, 2008. In Sanjeev Arora, Klaus Sofya Raskhodnikova. Approximate testing of visual properties. Jansen, Jos´e D. P. Rolim, and Amit Sahai, editors, Approximation, Randomization, and Combi- natorial Optimization.. Algorithms and Techniques, pages 370 -- 381, Berlin, Heidelberg, 2003. Springer Berlin Heidelberg. [Ron10] Dana Ron. Algorithmic and analysis techniques in property testing. Foundations and Trends in Theoretical Computer Science, 5(2):73 -- 205, 2010. [Sei91] [SW92] Raimund Seidel. Small-dimensional linear programming and convex hulls made easy. Discrete & Computational Geometry, 6(3):423 -- 434, Sep 1991. Micha Sharir and Emo Welzl. A combinatorial bound for linear programming and related problems. In Alain Finkel and Matthias Jantzen, editors, STACS 92, pages 567 -- 579, Berlin, Heidelberg, 1992. Springer Berlin Heidelberg. 15
1204.5853
3
1204
2015-06-19T07:55:46
Simultaneous Embedding of Planar Graphs
[ "cs.DS", "cs.DM" ]
Simultaneous embedding is concerned with simultaneously representing a series of graphs sharing some or all vertices. This forms the basis for the visualization of dynamic graphs and thus is an important field of research. Recently there has been a great deal of work investigating simultaneous embedding problems both from a theoretical and a practical point of view. We survey recent work on this topic.
cs.DS
cs
Simultaneous Embedding of Planar Graphs∗ Thomas Bläsius1), Stephen G. Kobourov2), Ignaz Rutter1) 1) Karlsruhe Institute of Technology (KIT) {blaesius,rutter}@kit.edu 2) University of Arizona [email protected] Abstract Simultaneous embedding is concerned with simultaneously representing a series of graphs sharing some or all vertices. This forms the basis for the visualization of dynamic graphs and thus is an important field of research. Recently there has been a great deal of work investigating simultaneous embedding problems both from a theoretical and a practical point of view. We survey recent work on this topic. 1 Introduction Traditional problems in graph drawing involve the layout of a single graph, whereas in simultaneous graph drawing we are concerned with the layout of multiple related graphs. In particular, consider the problem of drawing a series of graphs that share all, or parts of the same vertex set. The graphs may represent different relations between the same set of objects, or alternatively, the graphs may be the result of a single relation that changes through time. In this chapter we survey efforts to address the following problem: Given a series of graphs that share all, or parts of the same vertex set, what is a natural way to layout and display them? The layout and display of the graphs are different aspects of the problem, but also closely related, as a particular layout algorithm is likely to be matched best with a specific visualization technique. As stated above, however, the problem is too general and it is unlikely that one particular layout algorithm will be best for all possible scenarios. Consider the case where we only have a pair of graphs in the series, and the case where we have hundreds of related graphs. The "best" way to layout and display the two series is likely going to be different. Similarly, if the graphs in the sequence are very closely related or not related at all, different layout and display techniques may be more appropriate. ∗Submitted as a chapter about simultaneous embedding to the GD Handbook edited by Roberto Tamas- sia. 1 For the layout of the graphs, there are two important criteria to consider: the readability of the individual layouts and the mental map preservation in the series of drawings. The readability of individual drawings depends on aesthetic criteria such as display of symmetries, uniform edge lengths, and minimal number of crossings. Preservation of the mental map can be achieved by ensuring that vertices that appear in consecutive graphs in the series, remain in the same positions. These two criteria are often contradictory. If we individually layout each graph, without regard to other graphs in the series, we may optimize readability at the expense of mental map preservation. Conversely, if we fix the vertex positions in all graphs, we are optimizing the mental map preservation but the individual layouts may be far from readable. In simultaneous graph embedding, vertices are placed in the exact same locations in all the graphs, while the layout of the edges may differ. Visualization of related graphs, that is, graphs that are defined on the same set of vertices, arise in many different settings. Software engineering, databases, and social network analysis, are all examples of areas where multiple relationships on the same set of objects are often studied. In evolutionary biology, phylogenetic trees are used to visualize the ancestral relationship among groups of species. Depending on the assumptions made, different algorithms produce different phylogenetic trees. Comparing the outputs and determining the most likely evolutionary hypothesis can be difficult if the drawings of the trees are laid out independently of each other. While in some of the above examples the graphs are not necessarily planar, solving the planar case can provide intuition and ideas for the more general case. With this in mind, here we concentrate on the problem of simultaneous embedding of planar graphs. Simultaneous embedding of planar graphs generalizes the notion of traditional graph planarity and is motivated by its relationship with problems of graph thickness, geometric thickness, and applications such as the visualization of graphs that evolve through time. The thickness of a graph is the minimum number of planar subgraphs into which the edges of the graph can be partitioned; see [77] for a survey. Thickness is an important concept in VLSI design, since a graph of thickness k can be embedded in k layers, with any two edges drawn in the same layer intersecting only at a common vertex and vertices placed in the same location in all layers. A related graph property is geometric thickness, defined to be the minimum number of layers for which a drawing of G exists having all edges drawn as straight-line segments [34]. Finally, the book thickness of a graph G is the minimum number of layers for which a drawing of G exists, in which edges are drawn as straight-line segments and vertices are in convex position [9]. It has been shown that the book thickness of planar graphs is no greater than four [94]. 1.1 Problem Definitions This chapter is structured along three basic simultaneous embedding results for planar graphs, Simultaneous Geometric Embedding (SGE), Simultaneous Embedding with Fixed Edges (SEFE), and Simultaneous Embedding (SE), Figure 1 illustrates the three cases. For all three problems the input always consists of two planar graphs G1 = (V1, E1) and G2 = (V2, E2) sharing a common subgraph G = (V, E) = (V1∩V2, E1∩ 2 1 2 G1 5 8 7 2 3 6 8 5 G2 4 2 1 3 1 4 6 7 3 SGE SEFE SE 5 6 4 7 2 1 3 5 6 2 1 8 4 7 8 4 5 3 8 7 6 Figure 1. Two graphs G1 and G2 together with an SGE, a SEFE and an SE. In the SGE all edges are straight line segments while some edges in the SEFE are not. The SE contains common edges ({3, 7} and {5, 6}) that are drawn differently with respect to G1 and G2. E2). The most strict variant is Simultaneous Geometric Embedding (SGE), which asks for planar straight-line drawings of G1 and G2 such that common vertices have the same coordinates in both drawings. The requirements of SGE are very strict, and as we will see in Section 2 there exist a lot of examples that do not admit such an embedding. While the problem Simultaneous Embedding with Fixed Edges still requires com- mon vertices to have the same coordinates, it relaxes the straight-line requirement by allowing arbitrary curves for representing edges. To maintain the mental map, common edges are still required to be represented by the same curves. Finally, Simultaneous Embedding drops the constraints on the curves altogether and just requires common vertices to have the same coordinates. For all these problems it is common to also use the problem name to denote a corre- sponding embedding, that is we also say that G1 and G2 have an SGE, SEFE or SE if they admit solutions to these problems. Moreover, all these problems readily generalize to k > 2 input graphs G1, . . . , G, by requiring that the conditions hold for each pair of graphs. In this case a common restriction is to require that all input graphs share exactly the same graph G, that is G = Gi ∩ Gj for i 6= j. We call this behavior sunflower intersection. We note that simultaneous embedding problems are closely related to constrained embedding problems. For example if the planar embedding of one of the two graphs of an instance of SEFE is already fixed, the problem of finding a SEFE is equivalent to finding an embedding of the second graph respecting a prescribed embedding for a subgraph, namely the common graph. This constrained embedding problem is known as Partially Embedded Planarity. Angelini et al. [4] show that this problem can be solved in linear time and, in the spirit of Kuratowski's theorem, Jelínek et al. [66] characterize the yes-instances by forbidden substructures. A similar tie to constrained embedding problems exists in the case of SE. After fixing the drawing of one of the two input graphs it remains to draw a single graph without crossings at prescribed vertex positions. This problem is known as Point Set Embedding and Pach and Wenger show that this is always possible [79]. There are other, less obvious relations between simultaneous embedding and constrained embedding problems, which will be described 3 later. 1.2 Overview and Outline This chapter starts with the three simultaneous embedding problems SGE, SEFE, and SE, and we discuss each of them in one of the following sections. There are three major classes of results on simultaneous embedding problems. The first class contains algo- rithms that, for given graphs with certain properties, always produce a simultaneous embedding, perhaps with additional quality guarantees. These results show the exis- tence of simultaneous embeddings for the corresponding graph classes. The second class contains counterexamples that do not admit a simultaneous embedding. The third class contains algorithms and complexity results for the problem of testing whether a given instance admits a simultaneous embedding. We present a survey of the results on SGE in Section 2. Due to the strong requirements of SGE results of the first type, which identify classes of graphs that always admit a simultaneous embedding, exist only for very few and strongly restricted graph classes. For example, even a path and a tree of depth 4 may not have an SGE [5]. Moreover, it is NP-hard to decide SGE and there are no further results of the third type, that is algorithms testing whether an instance has an SGE or not, even for restricted instances. Section 3 presents the SEFE problem, which turns out to be much less restrictive than SGE. For example a tree and a path do always admit a SEFE although they do not have an SGE [49]. On the other hand, examples not having a SEFE are also counterexamples for SGE. Moreover, it is still open whether SEFE can be tested in polynomial time for two graphs, whereas it is NP-complete for three or more graphs [54]. However, for two graphs, there exist several results of the third type, that is testing algorithms, for restricted inputs. For example, it is possible to decide in linear time whether a pair of graphs admits a SEFE or not, if the common graph is biconnected [2, 60]. In Section 4, we consider the least restrictive simultaneous embedding problem, SE, which only requires common vertices to have the same coordinates in all drawings. As every planar graph can be drawn without crossings even if the position of every vertex is fixed [79], there are no counterexamples for SE and it is not necessary to have a testing algorithm. The results on SE focus on creating simultaneous embeddings such that edges have few bends and the resulting drawings use small area. Sections 5 -- 8 presents several variants of approaches to simultaneous embedding that do not quite fall into the categories of the three main problems. The problem variants discussed in Section 5 relax the requirement of having a fixed mapping between the ver- tices of G1 and G2. They rather ask whether a suitable mapping can be found such that a SEFE exists [15]. Colored SGEs are somewhere between and allow the mapping to identify only vertices having the same color [13]. Section 6 deals with matched drawings requiring straight-line drawings of the two input graph such that each common vertex has only the same y-coordinate in both drawings. Other work, discussed in Section 7, deals with the problem of simultaneously representing a planar graph and its dual [92] and considers different types of simultaneous representations, such as simultaneous in- tersection representations, as introduced by Jampani and Lubiw [64]. Section 8 presents 4 several practical approaches to simultaneous embedding problems. In Section 9 results on morphing between different planar drawings of the same graph are presented. A morph aims to preserve the mental map between different drawings of the same graph, which can be seen as the opposite to drawing different graphs such that the common part is drawn the same. Finally, in Section 10, we present a list of open questions. The list contains questions that have been open for several years, as well as questions that are motivated by recent research results. 2 Simultaneous Geometric Embedding In this section we consider the most desirable (and most restrictive) kind of simultaneous drawings, the SGEs. Most results on that problem are summarized in Table 1. Figure 3 illustrates the relation between these results. Before we describe the results in more detail we start with a small example. While it may be tempting to say that if the union of two graphs contains a subdivision of K5 or K3,3 then the two graphs have no simultaneous geometric embedding, this is not the case; see Figure 2. In fact, while planarity testing for a single graph can be done in linear time [63], Estrella-Balderrama et al. [42] show that the decision problem SGE is NP-hard. Other results concerning the complexity of SGE (for example for restricted graph classes) are not known. In the following we describe the results illustrated in Figure 3. We start with algorithms always creating an SGE when the input is restricted to special graph classes. We then continue with graph classes containing counterexamples. Finally, we consider the results not fitting in one of these two cases. 2 4 5 5 4 2 2 4 5 1 3 1 3 1 3 Figure 2. The union of the graph on the left and the graph on the right is a K5, but the middle drawing shows a simultaneous geometric embedding of the two graphs. 2.1 Graph Classes with SGE Brass et al. [15] give several algorithms for different restricted graph classes always creat- ing an SGE. In the simplest case G1 and G2 are both required to be paths. This result is easy to prove and also provides good intuition for most of the positive results: Theorem 1. For two paths P1 and P2 on the same vertex set V of size n an SGE on a grid of size n × n can be found in linear time. 5 SGE Instance Existence G1 & G2 paths G1 path & G2 extended star G1 caterpillar & G2 path G1 & G2 caterpillar 2 stars k stars G1 & G2 cycles G1 & G2 have maximum degree 2 G1 wheel & G2 cycle G1 tree & G2 matching G1 outerpath & G2 matching G1 tree of depth 2 & G2 path G1 level-planar w.r.t. path G2 G1 & G2 planar G1 path & G2 planar G1 path & G2 edge disjoint three paths G1 matching & G2 planar six matchings G1 & G2 outerplanar G1 & G2 trees G1 depth-4 tree & G2 edge disj. path O(n2) × O(n) Area n × n n × 2n 3n × 3n 3 × (n − 2) 4n × 4n O(ck√n) × O(ck√n) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Ref. [15] [15] [15] [15] [15] [15] [15] [35] [19] [19] [19] [5] [21] [15] [15, 36] [50] [15] [19] [19] [15] [56] [5] Table 1. A list of classes of graphs that are either known to always have an SGE or that contain counterexamples. For the positive cases, the area consumption is given, provided that it is known. Proof. For each vertex u ∈ V , we embed u at the integer grid point (p1, p2), where pi ∈ {1, 2, . . . , n} is the vertex's position in the path Pi, i ∈ {1, 2}. Then, P1 is embedded as an x-monotone polygonal chain, and P2 is embedded as a y-monotone chain. Thus, neither path is self-intersecting; see Figure 4 for an example. Brass et al. [15] also consider more general graph classes, such as caterpillars (trees being paths after the removal of all leaves), stars (trees with at most one inner vertex called center), and extended stars (collection of stars with an additional special root and paths from the special root to the centers of all stars). They show that a caterpillar and a path admit an SGE on a grid of size n× 2n, which can be extended to two caterpillars on a grid of size 3n × 3n. Moreover, they can simultaneously embed two stars on a 3 × (n − 2) grid and extend it to the case of k stars on an O(ck√n) × O(ck√n)-grid, where c is a constant. Finally, the pairs path plus extended star and cycle plus cycle can be embedded on O(n2) × O(n) and 4n × 4n grids, respectively. The latter two results 6 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ [15] [15] [15] G1 & G2 path G1 caterpillar & G2 path G1 & G2 caterpillar n × n [15] n × 2n [15] G1 & G2 cycle G1 path & G2 ext. star 4n × 4n [19] O(n2) × O(n) [35] G1 wheel & G2 cycle G1 & G2 max-deg 2 3n × 3n [15] [15] 2 stars 3 × (n − 2) k stars O(ck√n) × O(ck√n) [19] [5] G1 outerpath & G2 matching G1 depth-2 tree & G2 path [19] [21] G1 tree & G2 matching G1 level-planar w.r.t. path G2 [50] [5] G1 path, G2 edge disj. G1 depth-4 tree & G2 edge disj. path [15, 36] G1 path [15] [19] [56] [19] G1 matching G1 & G2 tree six matchings [15] [15] G1 & G2 planar G1 & G2 outerplanar three paths E G S n a g n i v a h s y a w l a s e c n a t s n i E G S n a t u o h t i w s e l p m a x e Figure 3. Overview over the so far known results on SGE. Each box represents one result and an arrow highlights that the source-result is extended by the target-result. The arrowheads are empty for the cases in which this is only true if the grid size is neglected. Note that transitive arrows are omitted. both extend the case of two paths (when neglecting the grid size). The result for two cycles was further extended by Duncan et al. [35] and Cabello et al. [19]. Duncan et al. [35] show that a graph with maximum degree 4 has geometric thickness 2. To this end, they show that two graphs with maximum degree 2 always admit a simultaneous geometric embedding. However, their algorithm computes drawings with 7 1 2 3 4 5 6 7 2 5 1 4 3 6 7 7 6 3 4 5 1 2 Figure 4. Two paths simultaneously embedded such that one path is x-monotone and the other is y-monotone. potentially large area. Cabello et al. [19] show the existence of an SGE for a wheel (union of a star and a cycle on its leaves) and a cycle. They moreover give algorithms for the pairs tree plus matching (graph with maximum degree 1) and outerpath (outerplanar graph whose weak dual is a path) plus matching. The former algorithm uses only two slope for the matching edges, for the latter one slope suffices. Given a planar graph and a path on the same vertices, the order of the vertices in the path induces a layering on the vertices. Cappos et al. [21] give a linear-time algorithm that computes an SGE of a planar graph and a path if the planar graph is level-planar with respect to the layering induced by the path. Angelini et al. [5] show that every tree of depth 2 has an SGE with every path. 2.2 Examples Without SGE In contrast to the positive results, Brass et al. [15] give several examples not admitting an SGE. They show the existence of two planar graph without a simultaneous embedding and extended this result to two outerplanar graphs. Two results we present in more detail are the counterexample for a planar graph and a path by Brass et al. [15] and Erten and Kobourov [36] and the counterexample of three paths by Brass et al. [15]. Theorem 2. There exists a planar graph G and a path P not admitting an SGE. Proof Sketch. Consider the graph G and the path P as shown in Figure 5. Let G′ be the subgraph of G induced on the vertices {1, 2, 3, 4, 5}, and let G′′ be the subgraph of G induced on the vertices {2, 6, 7, 8, 9}. Since G is triconnected fixing the outer face fixes an embedding for G. With the given outer face of G, the path P contains two crossings: one involving (2, 4), and the other one involving (6, 8). Graph G′ has six faces and unless we change the outer face of G′ such that it contains the edge (1, 3) or (3, 5), the edge (2, 4) is involved in a crossing in the path. Similarly for G′′, unless we change its outer face such that it contains (2, 7) or (7, 9), the edge (6, 8) is involved in a crossing in the path. However G′ and G′′ do not share any faces and removing both crossings depends on taking two different outer faces, which is impossible. 8 6 7 8 4 2 3 9 1 6 7 8 9 2 2 3 5 1 4 5 Figure 5. A planar graph G and a path P that do not allow an SGE. Thus, regardless of the choice for the outer face of G, path P contains a crossing. (cid:3) Theorem 3. There exist three paths P1, P2 and P3 not admitting an SGE. Proof. A path of n vertices is simply an ordered sequence of n numbers. The three paths we consider are: 714269358, 824357169 and 758261439. For example, the sequence 714269358 represents the path (v7, v1, v4, v2, v6, v9, v3, v5, v8). We will write ij for the edge connecting vi to vj. The union of these paths contain the following twelve edges. E = {14, 16, 17, 24, 26, 28, 34, 35, 39, 57, 58, 69} It is easy to see that the graph G consisting of these edges is a subdivision of K3,3 and therefore non-planar: collapsing 1 and 7, 2 and 8, 3 and 9 yields the classes {1, 2, 3} and {4, 5, 6}. It follows that there are two nonadjacent edges of G that cross each other. It is easy to check that every pair of nonadjacent edges from E appears in at least one of the paths given above. Therefore, at least one path will cross itself which completes the proof. Cabello et al. [19] extend the counterexample for the case that G1 is a path to the case where G1 is a matching. Moreover, they give an example of six matchings not admitting an SGE. Note that this does not directly follow by dividing three paths without an SGE into six matchings, as the resulting matchings allow crossings that were not allowed before. Another extension of the case where G1 is a path was given by Frati et al. [50] who give a counterexample where G1 is a path and G is a set of isolated vertices, that is G1 and G2 are edge disjoint. The question of whether two trees always admit an SGE was open for several years, before it was answered in the negative by Geyer et al. [56] with a construction involving two very large trees. This of course extends the result of two outerplanar graphs not having an SGE by Brass et al. [15]. Angelini et al. [5] further extended it to the case of a tree and a path without an SGE. More precisely, they give an example of a tree of 9 depth 4 and an edge disjoint path not having an SGE. Recall that a tree of depth 2 does always admit a simultaneous embedding with a path, thus in this case the gap between positive and negative results is quite small. 2.3 Related Work Frati et al. [50] consider the restricted case where each input graph has a prescribed combinatorial embedding. They show that the pair path plus star admits an SGE even if the embedding of the star is fixed. They can extend this result to a double-star (tree with up to two inner vertices) if it is edge disjoint to the path. On the other hand they show that fixing the embedding of two caterpillars may lead to an counterexample, whereas they admit an SGE if the embedding is not fixed. Another counterexample is the pair outerplanar graph with fixed embedding plus edge-disjoint path. An interesting additional restriction to SGEs was considered by Argyriou et al. [7], combining SGE with the RAC drawing convention (RAC -- Right-Angular Crossing). They try to find an SGE such that crossings between exclusive edges of different graphs are restricted to right-angular crossings. Argyriou et al. consider only the case where the edge sets of both graphs are disjoint. They present one negative and one positive result for this problem. The negative result consists of a wheel and a cycle not admitting an SGE with right-angular crossings. On the other hand they show the existence of such a drawing on a small integer grid for the case that one of the graphs is a path or a cycle and the other is a matching. Moreover, they give a linear-time algorithm to compute such a drawing. 3 Simultaneous Embedding with Fixed Edges In this section we drop the requirement that edges have to be straight line segments and consider the SEFE problem. Figure 6 shows a SEFE of the graph and the path from Figure 5 not admitting an SGE. Figure 7 and Table 2 illustrate the results on the problem SEFE classified in the three categories described before. 6 7 8 4 2 3 1 6 7 8 9 2 9 3 4 5 1 5 Figure 6. A graph and a path not admitting an SGE but a SEFE. 10 SEFE Instance Exist. Area Bends Ref. G1 tree & G2 path G1 outerplanar & G2 path G1 outerplanar & G2 cycle G1, G2 outerpl. & G collection of paths G1 tree & G2 planar G1 pseudoforest, G2 planar & G forest G1 has disj. cycles, G2 planar & G forest characterization of G characterization of G1 characterization of G1 (G1, G2 outerpl.) G1 outerplanar & G2 planar k outerplanar graphs three paths G1 & G2 outerplanar ✓ / ✗ ✓ / ✗ ✓ / ✗ 1 & 0 1 & 0 1 1 O(n) × O(n2) O(n) × O(n2) O(n2) × O(n2) O(n2) × O(n2) -- -- -- -- -- -- -- -- -- -- [36] [32] [32] [32] [49] [49] [47] [67] [48] [48] [15] [15] [15] [49] SEFE Instance Complexity Ref. three planar graphs G1 pseudoforest & G2 planar G1 has ≤ 2 cycles, G2 planar & G pseudoforest G star G consists of disjoint cycles G consists of components with fixed embeddings G has maximum degree 3 G1 subdiv. of triconnected components & G2 planar G biconnected G biconnected G consists of biconnected components G1, G2 biconnected & G connected NP-complete O(n) O(n) O(n) O(n) O(n2) polynomial polynomial O(n) O(n) polynomial O(n2) [54] [47] [47] [2] [11] [11] [83] [83] [60] [2] [83] [12] Table 2. A list of graph classes that are either known to always have a SEFE or that contain counterexamples (table at the top). For the positive examples bounds on the required area and number of bends per edge are given, provided that they are known. The symbol ✓ / ✗ denotes that a complete characterization of positive and negative instances is given. The table at the bottom shows results concerning the computational complexity of SEFE. 11 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✗ ✗ ✗ ✗ E F E S a g n i v a h s y a w l a s e c n a t s n i E F E S a t u o h t i w s e l p m a x e E F E S g n i t s e t [32] [32] G1 outerplanar & G2 path 1 & 0 bends; O(n) × O(n2) G1 outerplanar & G2 cycle 1 bend; O(n2) × O(n2) [36] [32] G1 tree & G2 path 1 & 0 bends; O(n) × O(n2) G1, G2 outerpl. & G paths 1 bend; O(n2) × O(n2) [49] G1 tree [49] [47] G1 pseudoforest & G forest G1 has disjoint cycles & G forest [48] characterization of G1 [48] characterization of G1 for G1, G2 outerplanar [67] characterization of G [15] [49] G1 outerplanar G1 & G2 outerplanar [15] [15] k outerplanar graphs three paths [11] [11] [54] G cycles (O(n)) G fixed edge-orders (O(n2)) three graphs NP-complete [83] [83] [83] G max-deg 3 G biconn. components G1 subdiv. of triconn. components [2] [2, 60] [12] G star (O(n)) G biconn. (O(n)) G1 & G2 biconn. & G conn. (O(n2)) [47] [47] G1 pseudoforest (O(n)) G1 has ≤ 2 cycles & G pseudoforest (O(n)) Figure 7. Overview over the so far known results on SEFE. Each box represents one result and an arrow highlights that the source-result is extended by the target-result. The arrowheads are empty for the cases in which this is only true, if the number of bends per edge, the consumed grid size or the necessary running time is neglected. Note that transitive arrows are omitted. 12 3.1 Positive and Negative Examples We start with instances that always admit a SEFE. Erten and Kobourov [36] show that a tree and a path can always be embedded simultaneously. They additionally give an algorithm finding a simultaneous embedding in O(n) time on a grid of size O(n)× O(n2) such that the edges of G1 and G2 have at most one and zero bends per edge, respectively. Note that a grid of size O(n2)× O(n3) is necessary if the bends are required to be drawn on grid points. Di Giacomo and Liotta [32] extend this result to the case of an outerplanar graph and a path with the same grid and bend requirements. They extend it further to the case where G1 and G2 are outerplanar and the common graph G is a collection of paths and to the case where G1 is outerplanar and G2 is a cycle. However, in both cases a grid of size O(n2) × O(n2) and up to one bend per edge are required. If the grid and bend requirements are completely neglected, the results considering the pairs tree plus path and outerplanar graph plus path can be extended to the case where one of the two graphs is a tree. Frati [49] shows how a tree G1 can be simultaneously embedded with an arbitrary planar graph G2. This algorithm still works if G1 contains one additional edge that is not a common edge, yielding the result that every graph with at most one cycle (a pseudoforest) can be embedded simultaneously with every other planar graph if the common graph does not contain this cycle. Fowler et al. [47] extend this result further to the case where G1 contains only disjoint cycles and the common graph G does not contain a cycle. Aside from instances always having a SEFE, there are also examples that cannot be simultaneously embedded. Brass et al. [15] give examples for k outerplanar graphs, three paths and an outerplanar graph plus a planar graph not having a SEFE. The results concerning outerplanar graphs can be extended to the case where both graphs are outerplanar [49]. In between the positive and negative results there are some characterizations stating which instances have a SEFE and which do possibly not. Fowler et al. [48] give a characterization of the graphs G1 having a SEFE with every other planar graph. This of course extends all results concerning only G1. In particular, the results that a tree can be simultaneously embedded with every other graph, whereas an outerplanar graph cannot, are extended. This characterization essentially requires that G1 must not contain a subgraph homeomorphic to K3 (a triangle) and an edge not attached to this K3; see Figure 8 for an example. The considerations made for this characterization additionally yield a characterization for the biconnected outerplanar graphs G1 having a simultaneous embedding with every other outerplanar graph G2. This of course extends the result that two outerplanar graphs possibly do not have a SEFE. Another characterization, in terms of the common graph, is given by Jünger and Schulz [67]. They show that two graphs can be simultaneously embedded if the common graph G has only two embeddings, whereas in all other cases graphs G1 and G2 with the common graph G not having a SEFE can be constructed. They additionally show that finding a SEFE is equivalent to finding combinatorial embeddings of G1 and G2 inducing the same combinatorial embedding, that is the same orders of edges around 13 (a) 1 4 2 (b) 1 5 (c) 1 4 5 2 4 5 2 3 3 3 Figure 8. G1 (a) and G2 (b) do not admit a SEFE (c) as G2 forces the vertices 4 and 5 to different sides of the triangle ∆123. vertices and the same relative positions of connected components to one another, on the common graph G [67, Theorem 4]. Note that it is not obvious and not even true for more than two graphs [3]. As this result is heavily used in most algorithms solving the decision problem SEFE, we state it as a theorem. Theorem 4. Two graphs G1 and G2 with common subgraph G admit a SEFE if and only if they admit combinatorial embeddings inducing the same embedding on G. 3.2 Testing SEFE Since SEFE has positive and negative instances, it would be nice to have an algorithm deciding for given graphs, whether they can be embedded simultaneously. If more than two graphs are allowed, this problem is known to be NP-complete [54], whereas the complexity for two graphs is still open. However, there are several results solving SEFE for special cases. Fowler at al. [47] show how to test SEFE, if G1 is a pseudoforest, that is a graph with at most one cycle. Note that, as mentioned above, such an instance always has a SEFE if this single cycle is not contained in G. This result can be extended to the case where G1 contains up to two cycles, if G does not contain the second cycle, that is G is a pseudoforest. To achieve this result the following auxiliary problem was solved. Given a planar graph G with a designated cycle C and a partition P = {P1, . . . , Pk} of the vertices not contained in C, does G admit a planar embedding, such that all vertices in Pi are on the same side of the cycle for every set Pi? Note that this again is a constrained embedding problem, showing that constrained and simultaneous embedding are closely related. Despite early effort [48], testing SEFE for two outerplanar graphs remains open. Haeupler et al. [60] give a linear-time algorithm to solve SEFE for the case that the common graph is biconnected. Their solution is an extension of the planarity testing algorithm by Haeupler and Tarjan [61]. This planarity testing algorithm starts with a completely unembedded graph and adds vertices iteratively, such that the unembedded part is always connected, ensuring that it can be assumed to lie in the outer face of all embedded components. While inserting vertices, they keep track of the possible embeddings of the embedded parts by representing the possible orders of half-embedded edges around every component with a PQ-tree having these edges as leaves. In a PQ-tree every inner node is either a Q-node fixing the order of edges incident to it up to a flip or a P-node allowing arbitrary orders. In this way a PQ-tree represents a set of possible 14 orders of its leaves. A completely different approach is used by Angelini et al. [2] to solve SEFE in linear time if the common graph is biconnected. They choose an order for the common graph bottom up in its SPQR-tree such that the private edges can be added. Another approach by Bläsius and Rutter [12] also uses PQ-trees. They use that the possible orders of edges around every vertex of a biconnected planar graph can be repre- sented by a PQ-tree, yielding a set of PQ-trees, one for each vertex. To obtain a planar embedding, the orders for the PQ-trees have to be chosen consistently. Bläsius and Rut- ter define the problem Simultaneous PQ-Ordering asking for orders in PQ-trees that are chosen consistently, which can, among other applications, be used to represent all planar embeddings of a biconnected graph. This extends to the case of two biconnected planar graphs enforcing shared edges to be ordered the same and thus yields a quadratic time algorithm for SEFE if G1 and G2 are biconnected and G is connected. The latter requirement comes from the fact that only orders of edges around vertices are taken into account, relative positions of connected components to one another are neglected. Note that this result extends the case where G is biconnected for the following reason. If G is biconnected, then G is completely contained in a single block (maximal biconnected component) of G1 and G2. Thus, even if G1 or G2 are not biconnected, they contain only one block that is of interest, all other blocks can simply be attached to this block. The result by Bläsius and Rutter can be slightly extended to the case where the graphs G1 and G2 contain cut-vertices incident to at most two non-trivial blocks (blocks not consisting of a single edge), including the special case where both graphs have maximum degree 5. The Simultaneous PQ-Ordering approach again shows the strong relation between simultaneous and constrained embedding as in an instance of SEFE the two input graphs constrain the possible orders of some of the edges around vertices of one another with PQ-trees. Angelini et al. [2] show the equivalence between SEFE and a constrained version of the Partitioned 2-Page Book Embedding problem. An instance of Partitioned 2-Page Book Embedding is a graph and a partition of its edges into two subsets. It asks whether all vertices can be arranged on a straight line (the spine) such that each of the edge partitions can be embedded without crossings in one of the two incident half- planes (pages of the book). Partitioned T -Coherent 2-Page Book Embedding additionally has a tree as input with the vertices of the graph as leaves. It is then required that the tree admits an embedding such that the order of its leaves is equal to the order of vertices on the spine. In other words, the allowed orders of vertices on the spine is constrained by a PQ-tree containing no Q-nodes. Angelini et al. [2] prove the following theorem and we sketch their proof here. Theorem 5. The problems SEFE for two graphs with connected intersection and Parti- tioned T -Coherent 2-Page Book Embedding have the same time complexity. Proof Sketch. Angelini et al. [2] first show that an instance of SEFE where the com- mon graph is connected can be modified (yielding an equivalent instance) such that the common graph is a tree. Moreover, each private edge is incident to leaves of this tree. They then show the equivalence to an instance of Partitioned T -Coherent 2-Page 15 (a) 3 2 4 5 8 9 7 1 10 6 (b) (c) (d) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 Figure 9. Equivalence of an instance of SEFE and the corresponding instance of Parti- tioned T -Coherent 2-Page Book Embedding. Book Embedding where the common graph is the constraining tree, the leaves of this tree are the vertices that need to be placed on the spine and the private edges of each of the graphs is one of the partitions. In the following we sketch this construction using the example in Figure 9. The instance in (a) having a tree T as common graph such that each private edge is incident to a leaf admits a SEFE. All private edges are embedded outside the dashed cycle around T in (b) containing all its leaves. Choosing another face as outer face and cutting the cycle at an arbitrary position yields a SEFE where all leaves of T are embedded on a straight line (c) with all private edges on the same side. This directly yields the Partitioned T -Coherent 2-Page Book Embedding in (d) of the private edges respecting the tree T . This shows the equivalence of SEFE and Partitioned T -Coherent 2-Page Book Embedding as the constructions works the same in the opposite direction. (cid:3) For the restricted case that T is a star, Partitioned T -Coherent 2-Page Book Embedding reduces to the problem Partitioned 2-Page Book Embedding that can be solved in linear time [62]. Thus the above result directly implies that SEFE can be solved in linear time if the common graph is a star. All results mentioned thus far require G to be connected and most results also require G1 and G2 to be connected. Bläsius and Rutter [11] consider the case where this does not hold. They show that it can be assumed without loss of generality that both graphs G1 and G2 are connected. In the case that G is connected, one only has to deal with orders of edges around ver- tices and can neglect relative positions of connected components to one another. Bläsius and Rutter approach SEFE from the opposite direction, caring only about the relative positions, neglecting the orders of edges around vertices. More precisely, they give a linear-time algorithm solving SEFE if the common graph is a set of disjoint cycles. They can extend this result to a quadratic-time algorithm for the case where G consists of arbitrary connected components, each with a fixed planar embedding. Both results ex- tend to an arbitrary number of graphs with sunflower intersection. Recall that sunflower intersection means that all graphs intersect in the same common subgraph. Moreover, they give a succinct representation of all simultaneous embeddings. A completely different, algebraic approach is presented by Schaefer [83]. It is based 16 on the Hanani-Tutte theorem [24, 90] stating that a graph is planar if and only if its independent odd crossing number is 0. The independent odd crossing number of a drawing is the number of pairs of non-adjacent edges whose number of crossings is odd. The independent odd crossing number of a graph is its minimum over all drawings. Thus, by the Hanani-Tutte theorem, testing planarity is equivalent to testing whether this crossing number is 0. The latter condition can be formulated as a system of linear equations over the field of two elements, leading to a simple polynomial-time planarity algorithm. Schaefer extends this result to other notions of planarity. In particular, it is shown that SEFE can be solved in polynomial time for three interesting cases, namely (1) if the common graph G consists of disjoint biconnected components and isolated vertices, (2) if the common graph has maximum degree 3, and (3) if G1 is the disjoint union of subdivisions of triconnected graphs. When neglecting the slower running time, this extends several of the results known before; see Figure 7. 3.3 Related Work A result not really fitting in one of the three above classes by Duncan et al. [35] considers the restricted case of SEFE where each edge has to be a sequence of horizontal and vertical segments with at most one bend per edge. They show that two graphs with maximum degree 2 always admit such a SEFE on a grid of size O(n)× O(n) by adapting their linear-time algorithm computing an SGE for these types of graphs (on a larger grid). Angelini et al. [3] consider the case where the embedding of each of the input graphs is already fixed. With this restriction SEFE becomes trivial for two graphs since it remains to test whether the two graphs induce the same embedding on the common graph. They show that it can also be decided efficiently for three graphs. However, it becomes NP- hard for at least fourteen graphs. They also consider the problem SGE for the case that the embedding of each graph is fixed and show that it is NP-hard for at least thirteen graphs. Schaefer [83] shows that several other notions of planarity are related to SEFE. In particular, the well-studied cluster planarity problem reduces to SEFE, providing further incentive to study its complexity. 4 Simultaneous Embedding In the most restricted version of the problem, SGE, we insist that vertices are placed in the same position, and edges must be straight-line segments. The SEFE setting relaxes the straight-line condition but maintains that edges common to multiple graphs are realized the same way in each. In the least restrictive setting, SE, we allow the same edge to be realized differently in different graphs. It has already been mentioned that simultaneous embedding of multiple graphs can be thought of as a generalization of the notion of planarity. A classical result about planar graphs connects the notion of a planar graph with that of a straight-line, crossing- free drawing thereof. Specifically, Wagner in 1936 [93], Fáry in 1948 [43], and Stein 17 (a) 1 (b) 2 5 3 4 6 6 5 4 5 6 4 1 3 2 3 2 1 δ δ′ Figure 10. (a) The cycle H2 (gray) with the path P2 (not dashed) and the graph G1 containing the Hamiltonian cycle H1 (bold) and the Hamiltonian path P1 (bold, not dashed). (b) The drawing of G1 and P2 according to the construction of Theorem 6. in 1951 [84] independently show that if a graph has a drawing without crossings, using arbitrary curves as edges, then there exists a drawing of the graph also without crossings, but with edges drawn as straight-line segments. For multiple graphs, however, this result does not hold. That is, given several graphs on the same n vertices, we can surely realize each graph without crossings, using arbitrary curves as edges and the same vertex positions for each graph. But (except in very special circumstances such as the positive examples in the Section 2) we cannot guarantee that there exist vertex positions that allow the realization of each graph with straight-line segments and without crossings. If this were true, then the vertex positions would be a universal pointset for graphs on n vertices, and it is known that universal pointsets of linear size do not exist [27]. Pach and Wenger [79] show that every planar graph can be drawn without crossings with a prespecified position for every vertex. Thus, for every pair of planar graphs an SE can be created by drawing the first graph arbitrarily and the second graph to the vertex positions specified by the first drawing. Thus, there are neither negative examples nor is it necessary to have testing algorithms. However, the drawing of the second graph may have linearly many bends per edge, thus it is of interest to find an SE with fewer bends. Erten and Kobourov [36] show that every two graphs can be drawn simultaneously in O(n) time with at most three bends per edge on an O(n2) × O(n2) grid (O(n3) × O(n3) To if bends need to be placed on grid points), where n is the number of vertices. achieve this result, they combine the construction of Brass et al. [15] to create an SGE of two paths (see Theorem 1 in Section 2) with a technique by Kaufmann and Wiese [69], who show that every planar graph can be drawn with at most two bends per edge if the allowed vertex positions are restricted to a set of points. We include the main result from this paper along with a proof sketch. Theorem 6. For two planar graphs G1 and G2 an SE with at most three bends per edge on an O(n2) × O(n2) grid can be found in linear time. Proof Sketch. removed later using the technique of Kaufmann and Wiese. Initially, assume that G1 and G2 are 4-connected. This assumption is 18 We can compute Hamiltonian cycles H1 and H2 of G1 and G2, respectively, using the algorithm of Chiba and Nishizeki [22]. Let P1 and P2 be Hamiltonian paths contained in H1 and H2, respectively; see Figure 10(a) for an example. As in the proof of Theorem 1, we can construct an SGE of P1 and P2 such that P1 is y-monotone, while P2 is x- monotone. We show how to add the remaining edges of G1 and the construction is similar for G2. We consider the absolute values of the slopes the edges in P1 have and define δ to be their minimum. Let further δ′ be slightly smaller. We first close the cycle H1 by adding the missing edge using two straight-line segments with slopes δ′ and −δ′; see Figure 10(b). Similarly, all remaining edges of G1 are drawn with two straight-line segments with slopes appropriately chosen between δ′ and δ and between −δ and −δ′. Dealing similarly with the remaining edges of G2 yields an SE with at most one bend per edge on a grid of size O(n2) × O(n2). For the case that G1 and G2 are not 4-connected, Kaufmann and Wiese [69] showed how they can be augmented to 4-connected planar graphs by adding new edges and subdividing every edge at most once. Drawing these augmented graphs as described above, removing the additional edges and replacing each subdivision vertex with a bend yields an SE of G1 and G2 with at most three bends per edge on an O(n2) × O(n2) grid. (cid:3) The result of Erten and Kobourov was improved by Di Giacomo and Liotta [31,32] to at most two bends per edge in general and one bend per edge, if G1 and G2 are both sub-Hamiltonian. That is, they can be augmented to become Hamiltonian maintaining planarity, and an augmentation together with a Hamiltonian cycle is given with the input. Similar results were obtained by Kammer [68]. As series-parallel graphs [29], trees and outerplanar graphs [9, 25] are always sub-Hamiltonian and an augmentation together with a Hamiltonian cycle can be computed in linear-time this result yields a linear time algorithm to compute an SE of G1 and G2 with one bend per edge on a grid of size O(n2) × O(n2) if each of the graphs G1 and G2 is series-parallel, a tree or outerplanar. Cappos et al. [21] show that a path and an outerplanar graph can be simultaneously embedded in linear time such that edges in the outerplanar graph are straight-line seg- ments and each edge in the path consists of a single circular arc. Alternatively, the path edges may be piecewise linear with at most two bends per edge. 5 Colored Simultaneous Embedding Since SGE can be too restrictive, various relaxations have been considered. The two relaxed versions already mentioned, SEFE and SE relax the requirement of straight-line edges, and even the requirement that common edges are drawn the same way in both drawings. Another way to relax the constraints of the original SGE problem is to allow changes in vertex positions in different graphs. Until this point we had assumed that multiple input graphs have labeled vertices and thus the mapping between the vertices of the graphs is part of the input. In simultaneous embedding without mapping we are interested in computing plane drawings for each of 19 1 5 3 6 a b c 2 7 g 4 d e f 5c 7b 3g 6a 4e 2f 1d 7b 5c 2d 1f 3e 4g 6a Figure 11. Two 2-colored graphs with two CSEs corresponding to different mappings. the given graphs on the same set of points, where any vertex can be placed at any of the points in the point set. This setting of the problem was investigated in the very first paper on SGE [15] and is the source of one of the longest standing open problems in the area. A common generalization of the problems above is Colored Simultaneous Em- beddings (CSE), which was introduced by Brandes et al. [13], and contains both, the version with and without mapping. Formally, the problem of CSE is defined as follows. The input is a set of planar graphs G1 = (V, E1), G2 = (V, E2), ..., G = (V, ) on the same vertex set V and a partition of V into c classes, which we refer to as colors. The goal is to find plane straight-line drawings Di of Gi using the same V points in the plane for all i = 1, . . . k, where vertices mapped to the same point are required to be of the same color. We call such graphs c-colored graphs; see Figure 11 for an example. Given the above definition, simultaneous embeddings with and without mapping correspond to colored simultaneous embeddings with c = V and c = 1, respectively. Thus, when a set of input graphs allows for a simultaneous embedding without mapping but does not allow for a simultaneous embedding with mapping, there must be a threshold for the number of colors beyond which the graphs can no longer be embedded simultaneously. Colored simultaneous embeddings provide a way to obtain near-simultaneous embed- dings, where we place corresponding vertices nearly, but not necessarily exactly, at the same locations. Relaxing the constraint on the size of the pointset allows for a way to more easily obtain near-simultaneous embeddings, where we attempt to place correspond- ing vertices relatively close to one another in each drawing. For example, if each cluster of points in the plane has a distinct color, then even if a red vertex v placed at a red point p ∈ G1 has moved to another red point q ∈ G2, the movement is limited to the area covered by the red points. Brandes et al. [13] show several positive and negative results about CSE. In particular they show that there exist universal pointsets of size n for 2-colored paths and spiders as well as 3-colored paths and caterpillars. It is also shown that a 2-colored tree (or even a 2-colored outerplanar graph) and any number of 2-colored paths can be simultaneously embedded. In the negative direction, there exist a 2-colored planar graph and pseudo- forest, three 3-colored outerplanar graphs, four 4-colored pseudo-forests, three 5-colored pseudo-forests, five 5-colored paths, two 6-colored biconnected outerplanar graphs, three 6-colored cycles, four 6-colored paths, and three 9-colored paths that cannot be simulta- 20 1 4 2 2 3 3 5 6 1 4 6 5 Figure 12. A matched drawing: corresponding vertices have the same y-coordinate. neously embedded. Frati et al. [50] continue the investigation of near-SGE's, that is they try to find straight-line drawings of the input graphs with a small distance between every pair of common vertices in different drawings. As a negative result, they present a pair of graphs such that in every pair of drawings there exists a common vertex with distance linear in the size of the input. On the other hand, they present positive results for a sequence of paths and a sequence of trees for the case that every two consecutive graphs in the sequence are similar with respect to a parameter measuring their similarity. It can then be shown that the distance of a common vertex in two consecutive drawings depends linearly on this parameter. 6 Matched Drawings Another approach to relax requirements of SGE are the so-called matched drawings introduced by Di Giacomo et al. [30]. A matched drawing of a pair of graphs is a planar straight-line drawing of each of the graphs such that each common vertex has the same y-coordinate in both drawings (instead of the same y- and x-coordinate as required for SGE); see Figure 12 for an example. Di Giacomo et al. [30] give a small counterexample consisting of two small triconnected planar graphs not admitting a matched drawing. Moreover, they give a larger example (620 vertices) of a biconnected graph and a tree not having a matched drawing. Apart from that they also have some results on the positive side. They show that two trees are always matched drawable. Moreover, they observe that any planar graph has a matched drawing with a so-called unlabeled level planar (ULP) graph, that is a graph that admits a planar straight-line drawing even if the y-coordinate of each vertex is prespecified such that no two vertices have the same y-coordinate. A characterization of ULP graphs is given by Fowler and Kobourov [46]. Di Giacomo et al. [30] moreover show for a graph class containing non-ULP graphs (the carousel graphs) that they admit matched drawings with arbitrary planar graphs. A special cases of a carousel graphs is a graph consisting of a single vertex v0 and a set of disjoint subgraphs S1, . . . , Sk, each Si connected to v0 over a single edge {v0, vi} such that Si is either a caterpillar with vi on its spine, a radius-2 star with vi as center or a cycle. Grilli et al. [59] present further positive results on matched drawings. They show 21 how to draw the pairs outerplane plus wheel, wheel plus wheel, outerplane plus maximal outerpillar (outerplane graph with triangulated inner faces and caterpillar as weak dual), and outerplane plus generalized outerpath (outerpath where some edges on the outer face may be replaced by some small subgraphs). Moreover, they consider matched drawings for graph triples and give algorithms creating matched drawings of three cycles, and a caterpillar and two ULP graphs. 7 Other Simultaneous Representations Apart from simultaneously drawing two graphs sharing some common parts there are other ways to represent graphs simultaneously. In this section we describe how a plane graph and its dual can be represented simultaneously, and what is known about simulta- neous intersection representations of (not necessarily planar) graphs. 7.1 A Plane Graph and its Dual In a simultaneous drawing of a planar graph and its dual each vertex in the dual graph is required to be placed inside the corresponding face of the primal graph. Moreover, no crossings are allowed except for crossings between a dual and its corresponding primal edge. Tutte [92] first considered this problem and showed that every triconnected planar graph admits a simultaneous straight-line drawing with its dual. However, the resulting drawings may have exponentially large area. Erten and Kobourov [38] provide a linear- time algorithm simultaneously embedding a triconnected planar graph and its dual on a grid of size (2n − 2) × (2n − 2) such that all edges are drawn as straight-line segments. Zhang and He [95] improved this result to a grid of size (n − 1) × n. Brightwell and Scheinerman [18] show the existence of a simultaneous straight-line drawing of a triconnected planar graph and its weak dual such that the crossings between dual and the corresponding primal edges are right-angular crossings. A circle packing of a planar graph represents the vertices as non-crossing circles such that two vertices are adjacent if and only if their corresponding circles touch. Given a circle packing of a planar graph, one obtains a planar straight-line drawing by placing each vertex at the center of its corresponding circle. Mohar [75] shows that every triconnected planar graph has a simultaneous circle packing with its dual such that in the corresponding straight- line drawings primal and dual edges have right-angular crossings. Argyriou et al. [7] give a simple example of a graph that is not triconnected not admitting such a drawing. On the positive side they give an algorithm that creates such drawings for the case that the primal graph is outerplanar. Another way of simultaneously representing a planar graph and its dual is the tessel- lation representation introduced by Tamassia and Tollis [88]. In a tessellation represen- tation, every edge, every vertex and every face is represented by a (maybe degenerated) rectangle, a so called tile, such that the interiors of these tiles are pairwise disjoint, that their union forms a rectangle, and that the incidences in the graph are represented by side contacts of the tiles in the following way. Two tiles share a horizontal line segment if and only if they represent an edge and an incident face, and two tiles share a vertical 22 line segment if and only if they represent an edge and an incident vertex. Tamassia and Tollis [88] in particular showed that every biconnected planar graph admits a tessellation representation where the tiles representing vertices and faces are vertical and horizontal line segments, respectively. The textbook by Di Battista et al. [28, Sections 4.3 & 4.4] contains a short description of the algorithm computing tessellation representations and of the relation to visibility representations. Moreover, tessellation representations were also considered on other surfaces such as the torus [76]. 7.2 Intersection Representations Jampani and Lubiw [64] introduce the concept of simultaneous graph representations for other representations than drawings. An intersection representation of a graph assigns a geometric object to each vertex such that two vertices are adjacent if and only if their corresponding geometric objects intersect. Two graphs sharing a common subgraph are simultaneous intersection graphs if each of them has an intersection representation such that the common vertices are represented by the same objects. Note that every planar drawing of a graph can be interpreted as intersection representation, each vertex is represented by the union of its edges. This shows that deciding SEFE as a special case of recognizing simultaneous intersection graphs. Other popular intersection representations are the following. In an interval represen- tation of a graph each vertex is represented by an interval on the real line. A graph is chordal if each induced cycle has length three. Gavril [55] shows that chordal graphs are exactly the intersection graphs of subtrees in a tree. This shows that the class of interval graphs is contained in the class of chordal graphs. Permutation graphs are the intersection graphs that can be represented by a set of line segments connecting two par- allel lines. Jampani and Lubiw [64] give O(n3)-time algorithms recognizing simultaneous permutation graphs and simultaneous chordal graphs. The algorithm for simultaneous permutation graphs can be extended to more than two graphs with sunflower intersection. On the other hand, it is NP-hard to recognize simultaneous chordal graphs of this kind (for a constant number k of graphs, the complexity is still open). In a follow-up paper Jampani and Lubiw [65] give an algorithm recognizing simulta- neous interval graphs in O(n2 log n) time. As interval graphs can be characterized in terms of PQ-trees, recognizing simultaneous interval graphs leads to a problem of finding orders in several PQ-trees simultaneously. Bläsius and Rutter [12] consider this kind of problem in a more general leading to a O(n)-time algorithm recognizing simultaneous interval graphs. Related to simultaneous intersection graphs are simultaneous comparability graphs also introduced by Jampani and Lubiw [64]. A comparability graph is a graph that can be oriented transitively where transitively means that a directed path implies the exis- tence of a directed edge. Two graphs are simultaneous comparability graphs if each of them can be oriented transitively such that common edges are oriented the same in both. Jampani and Lubiw give an O(nm)-time algorithm recognizing simultaneous comparabil- ity graphs. It can also be used to recognize an arbitrary number of comparability graphs with sunflower intersection. Comparability graphs are related to intersection graphs as 23 comparability graphs are exactly the graphs whose complement is a function graph, that is the intersection graph with respect to continuous functions on an interval [57]. As for the problem SEFE, finding simultaneous representations is related to extending a representation of a subgraph to one of the whole graph. For interval graphs Klavík et al. [70] give a O(nm)-time algorithm testing whether a partial interval representation can be extended. Bläsius and Rutter [12] were able to improve the running time to O(m) by constructing a second graph such that both graphs are simultaneous interval graphs if and only if the partial interval representation can be extended. 8 Practical Approaches to Dynamic Graph Drawing The majority of the results reviewed above focused on the theoretical aspects of dynamic graph drawing. In this section we review practical approaches to this problem. As we have seen in the previous sections, numerous negative results show that in many of the interesting settings we cannot guarantee simultaneous embeddings. On the other hand, several efficient algorithms for different variants of the problem do exists, but they usually place additional restrictions on the number of input graphs, or limit the graphs to special sub-classes of planar graphs. As discussed in the introduction, the problem is well-motivated in practice. Of partic- ular interest are applications to visualization of dynamic graphs and the related issues of mental map preservation and good graph readability. With this in mind we mention several more practical results here. First we focus on drawing algorithms that aim to produce simultaneous embeddings or layouts that are in some sense close to being a simultaneous embedding. Afterwards, we briefly discuss other approaches to dynamic graph drawing. Erten et al. [39] adapt force-directed algorithms to create drawings of a series of graphs sharing subgraphs finding a tradeoff between nice drawings and similarities of common parts. Kobourov and Pitta [71] describe an interactive system which allows multiple users to interactively modify a pair of graphs simultaneously using a multi-user, touch-sensitive input device. While those two approaches focus on straight-line drawings (corresponding to SGE), the GraphSET system by Estrella-Balderrama et al. [41] also allows edges to have bends. GraphSET is a tool helping the user to investigate the theoretical problems SGE and SEFE and it contains implementations of several testing and drawing algo- rithms. Chimani et al. [23] create simultaneous drawings of graphs by drawing the union of the graphs. Their objective is to minimize the number of crossings in the drawing, where crossings between edges of different graphs do not count, yielding a simultaneous embedding if and only if the number of crossings is zero. Misue et al. [74] initiated the study of drawing dynamically changing graphs and first proposed several models to capture the notion of preserving the user's mental map. In particular they suggested preservation of orthogonal orderings, proximity relations, or the topology as a formalization. Bridgeman and Tamassia [16] describe and evaluate difference metrics that are specialized to orthogonal graph drawings. Purchase et al. [80] provide empirical evidence that preserving the user's mental map indeed assists in com- 24 prehending the evolving graph. Purchase and Samra [81] argue that for minimizing the node movement, finding a trade-off is worse than either keeping the exact node positions or just layouting the next graph from scratch for memorizing tasks. In a recent study, Archambault and Purchase [6] observed positive effects of mental map preservation for localization tasks, both in terms of speed and accuracy. Sallaberry et al. [82] consider mental map preservation for large graphs and argue that restricting node movements to small distances is not sufficient for this case. They propose to cluster nodes into groups that perform the same movement in order to increase the stability of the drawing. Bridgeman et al. [17] present InteractiveGiotto, a bend-minimization algorithm for orthogonal drawings that is designed for dynamic and interactive scenarios. Their algo- rithm supports arbitrary graph changes and preserves the embedding, all edge crossings, and the bends of edges. Brandes and Wagner [14] suggest a Bayesian framework for dynamic graph drawing that can in principal we applied to all layout styles and allows to choose a trade-off between quality and stability. Diel and Görg [33] introduce foresighted layouts, where the basic idea is to layout the union of the graph over all time steps and to combine vertices and edges whose life times are disjoint, in order to reduce the size of the drawing. This automatically guarantees a high stability of the layout, but possibly incurs a negative impact on the quality of individual drawings. Görg et al. [58] enhance this method by an additional step that improves the quality of the individual layouts while keeping them close to the foresighted layout. North and Woodhull [78] propose a heuristic for online hierarchical graph drawing by dynamizing the classical Sugiyama algorithm [85]. Collberg et al. [26] describe a system for visualizing the evolution of software based on force-directed methods applied to so- called time-sliced graphs. A time-sliced graph consists of disjoint copies of the graph at each point in time together with time-slice edges, which connect corresponding vertices from different points in time. The algorithm attempts to place vertices that are connected by a time-slice edge in roughly the same position. Frishman and Tal [53] describe an algorithm for online dynamic graph drawing that can be implemented to run on a GPU. 9 Morphing Planar Drawings The main motivation for simultaneously embedding different (but related) graphs is to preserve the mental map between the unchanged parts by drawing them the same. As opposed to this, morphing tries to match different drawings of the same graph. More precisely, let Γ1 and Γ2 be two drawings of the same graph G, a morph between them is a motion of the vertices along trajectories starting at the vertex positions in Γ1 and ending at their positions in Γ2. The simplest possible morph between two drawings Γ1 and Γ2 is the linear morph where each vertex moves at constant speed along a line segment from its origin in Γ1 to its destination in Γ2. However, the intermediate drawings of linear morphs may be pretty bad, in fact, it may even happen that the whole graph collapses to a single point. To resolve this problem Cairns [20] introduced the notion of morphing planar graphs, 25 requiring that every intermediate drawing is also planar. He showed that two planar drawings of a triangulated plane graph with an equally drawn outer face can be morphed into each other in a planar way using a sequence of linear morphs. However, this sequence of linear morphs has exponential size. Thomassen [89] extends this to drawings of general (not necessarily triangulated) pla- nar graphs with an equally drawn outer face and convex faces by augmenting the drawings to compatible triangulations, that is one must be able to add all new vertices and edges to both given drawings without violating the planarity or straight-line requirement. Com- patible triangulations were further investigated by Aronov et al. [8] who show that two drawings admit compatible triangulations with only O(n2) new vertices. They moreover show that Θ(n2) new vertices are sometimes necessary. This result has the following gen- eral implication. If there exist planar morphs between drawings of triangulated graphs using O(f (n)) linear morphing steps, then there are morphs between drawings of arbi- trary plane graphs using O(f (n2)) steps. To be able to morph with a polynomial number (O(n6)) of linear steps Lubiw and Petrick [72] relaxed the straight-line requirement and showed how to morph between two planar drawings when edges are allowed to be bent during the morph. However, this result can also be achieved without this relaxation. Alamdari et al. [1] show that for every pair of planar straight-line drawings of a triangulated graph with an equally drawn outer face there exists a planar morph consisting of a sequence of O(n2) linear morphs. This is the first result showing that a polynomial number of morphing steps is sufficient. Using the results on compatible triangulations mentioned above [8] this yields a morph with O(n4) linear steps for general plane graphs. Floater and Gotsman [45] introduced a completely different approach to planar mor- phing of triangulations. They make use of the fact that in a planar drawing the position of each vertex is a convex combination of the neighboring vertices and that conversely fixing the coefficients of the convex combinations and fixing the outer face yields a planar drawing. This was shown by Floater [44] extending the results by Tutte [91,92]. Floater and Gotsman [45] create a morph between two planar drawings by transforming the co- efficients of the corresponding convex combinations into one another, yielding a sequence of coefficients and thus a sequence of planar drawings. Surazhsky and Gotsman [86, 87] improve this approach further to obtain aesthetically more appealing morphs. The approach based on convex combinations has the disadvantage that the trajectories are not explicitly computed and that it is not clear how many linear morphing steps are necessary to obtain a planar and smooth morph. Despite its theoretical shortcomings, in practice this algorithm leads to nice morphs, as shown by Erten et al. [37, 40], who combine this approach with rigid motion (translation, rotation, scaling and shearing) and the triangulation algorithm by Aronov et al. [8]. Moreover, they are able to morph edges with bends to straight-line edges and vice versa. Biedl et al. [10] consider a related problem of morphing so called parallel straight-line drawings, that is straight-line drawings such that for every edge e, the slope of e is the same in both drawings. Moreover, the edge slopes have to be preserved throughout the whole morph. They show that for orthogonal drawings (without bends) such a morph always exists. On the other hand, testing for the existence of such a morph 26 becomes NP-hard if the edges are allowed to have three or more slopes. Lubiw et al. [73] investigate morphs between general orthogonal drawings of planar graphs where edges may have bends. They show that for every pair of drawings there is a morph preserving planarity and orthogonality consisting of polynomial many steps, where each step is either a movement of vertices or a "twist" around a vertex that introduces new bends at the edges incident to this vertex. Of course, problems similar to planar morphing can be considered for non-planar graphs. Examples are the results by Friedrich and Eades [51] and Friedrich and Houle [52]. 10 Open Problems There are many interesting problems, some of which have been open for a decade and have resisted efforts to address them. Here we list several of the current open problems. 1. Given two arbitrary planar graphs G1 = (V1, E1) and G2 = (V2, E2) with the same number of vertices, V1 = V2, does there always exist a mapping from the vertex set of the first graph onto the vertex set of the second graph V1 → V2 such that the two graphs have a SGE? That is, do pairs of planar graphs always have an SGE without mapping? 2. Given two graphs of max-degree 2, G1 = (V1, E1) and G2 = (V2, E2) with the same number of vertices, an SGE with mapping does always exist. Unlike most other results where the pair of graphs has an SGE the area of the necessary grid is not bounded. Is it possible to guarantee polynomial integer grid for the simultaneous embedding? 3. What is the complexity of SGE for two graphs with fixed planar embeddings? 4. Is it possible to decide SGE for restricted cases, for example if the common graph is highly connected? 5. What is the complexity of the decision problem SEFE for two graphs? 6. Are there interesting parameters for which SEFE or SGE are FPT? For example, tree-distance of G? What about maximum degree ∆? 7. What is the complexity of SEFE for more than two graphs with sunflower inter- section? 8. What is the complexity of SEFE for four graphs, each with a fixed planar embed- ding? 9. What is the complexity of the optimization version of SEFE where one asks for drawings such that as many common edges as possible are drawn the same? 10. Let G1 and G2 be two planar graphs with given combinatorial embeddings inducing the same embedding on their intersection G, that is a SEFE is given with the input. 27 What is the complexity of minimizing the number of crossings in a corresponding drawing? 11. Let G1 and G2 be two planar graphs with given combinatorial embeddings inducing the same embedding on their intersection G, that is a SEFE is given with the input. Do G1 and G2 admit drawings with few bends on a small grid respecting the given SEFE? 12. There are many open problems in the CSE setting. A particularly interesting one concerns pairs of trees. It is known that two n-vertex trees without mapping (1- colored) have a simultaneous geometric embedding (any set of n points in convex position suffices). It is also known that at the other extreme when the mapping is given (n-colored) such geometric embedding may not exist. However, the problem is open for any number of colors c ∈ {2, . . . , n − 1}. 13. Similarly to the previous problem, the status of the tree-path CSE problem is open for any number of colors c ∈ {3, . . . , n − 1}. References [1] S. Alamdari, P. Angelini, T. M. Chan, G. Di Battista, F. Frati, A. Lubiw, M. Patrig- nani, V. Roselli, S. Singla, and B. T. Wilkinson. Morphing planar graph drawings with a polynomial number of steps. In Proceedings of the twenty-fourth annual ACM-SIAM symposium on Discrete algorithm, SODA '13. ACM, 2013. To appear. [2] P. Angelini, G. D. Battista, F. Frati, M. Patrignani, and I. Rutter. Testing the simultaneous embeddability of two graphs whose intersection is a biconnected or a connected graph. Journal of Discrete Algorithms, 14(0):150 -- 172, 2012. [3] P. Angelini, G. Di Battista, and F. Frati. Simultaneous embedding of embedded planar graphs. In T. Asano, S.-i. Nakano, Y. Okamoto, and O. Watanabe, editors, Algorithms and Computation, volume 7074 of Lecture Notes in Computer Science, pages 271 -- 280. Springer Berlin / Heidelberg, 2011. [4] P. Angelini, G. Di Battista, F. Frati, V. Jelínek, J. Kratochvíl, M. Patrignani, and I. Rutter. Testing planarity of partially embedded graphs. In Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '10, pages 202 -- 221. Society for Industrial and Applied Mathematics, 2010. [5] P. Angelini, M. Geyer, M. Kaufmann, and D. Neuwirth. On a tree and a path with no geometric simultaneous embedding. Journal of Graph Algorithms and Applications, 16(1):37 -- 83, 2012. [6] D. Archambault and H. Purchase. Mental map preservation helps user orientation in dynamic graphs. In Graph Drawing, Lecture Notes in Computer Science. Springer Berlin / Heidelberg, 2013. To appear. 28 [7] E. Argyriou, M. Bekos, M. Kaufmann, and A. Symvonis. Geometric RAC simulta- neous drawings of graphs. In J. Gudmundsson, J. Mestre, and T. Viglas, editors, Computing and Combinatorics, volume 7434 of Lecture Notes in Computer Science, pages 287 -- 298. Springer Berlin Heidelberg, 2012. [8] B. Aronov, R. Seidel, and D. Souvaine. On compatible triangulations of simple polygons. Computational Geometry, 3(1):27 -- 35, 1993. [9] F. Bernhart and P. C. Kainen. The book thickness of a graph. Journal of Combi- natorial Theory, Series B, 27(3):320 -- 331, 1979. [10] T. Biedl, A. Lubiw, and M. Spriggs. Morphing planar graphs while preserving edge directions. In P. Healy and N. Nikolov, editors, Graph Drawing, volume 3843 of Lecture Notes in Computer Science, pages 13 -- 24. Springer Berlin / Heidelberg, 2006. [11] T. Bläsius and I. Rutter. Disconnectivity and relative positions in simultaneous embeddings. In Graph Drawing, Lecture Notes in Computer Science. Springer Berlin / Heidelberg, 2013. To appear. [12] T. Bläsius and I. Rutter. Simultaneous PQ-ordering with applications to constrained embedding problems. In Proceedings of the twenty-fourth annual ACM-SIAM sym- posium on Discrete algorithm, SODA '13. ACM, 2013. To appear. [13] U. Brandes, C. Erten, A. Estrella-Balderrama, J. J. Fowler, F. Frati, M. Geyer, C. Gutwenger, S.-H. Hong, M. Kaufmann, S. G. Kobourov, G. Liotta, P. Mutzel, and A. Symvonis. Colored simultaneous geometric embeddings and universal pointsets. Algorithmica, 60(3):569 -- 592, 2011. [14] U. Brandes and D. Wagner. A bayesian paradigm for dynamic graph layout. In G. D. Battista, editor, Proceedings of the 5th International Symposium on Graph Drawing (GD'97), volume 1353 of Lecture Notes in Computer Science, pages 236 -- 247. Springer, 1997. [15] P. Brass, E. Cenek, C. A. Duncan, A. Efrat, C. Erten, D. Ismailescu, S. G. Kobourov, A. Lubiw, and J. S. B. Mitchell. On simultaneous planar graph embeddings. Com- putational Geometry: Theory and Applications, 36(2):117 -- 130, 2007. [16] S. Bridgeman and R. Tamassia. Difference metrics for interactive orthogonal graph drawing algorithms. In S. H. Whitesides, editor, Proceedings of the 6th International Symposium on Graph Drawing (GD'98), volume 1547 of Lecture Notes in Computer Science, pages 51 -- 71. Springer, 1998. [17] S. S. Bridgeman, J. Fanto, A. Garg, R. Tamassia, and L. Vismara. Interactivegiotto: An algorithm for interactive orthogonal graph drawing. In G. D. Battista, editor, Proceedings of the 5th International Symposium on Graph Drawing (GD'97), volume 1353 of Lecture Notes in Computer Science, pages 303 -- 308. Springer, 1997. 29 [18] G. R. Brightwell and E. R. Scheinerman. Representations of planar graphs. SIAM Journal on Discrete Mathematics, 6(2):214 -- 229, 1993. [19] S. Cabello, M. J. van Kreveld, G. Liotta, H. Meijer, B. Speckmann, and K. Verbeek. Geometric simultaneous embeddings of a graph and a matching. Journal of Graph Algorithms and Applications, 15(1):79 -- 96, 2011. [20] S. S. Cairns. Deformations of plane rectilinear complexes. The American Mathe- matical Monthly, 51(5):247 -- 252, 1944. [21] J. Cappos, A. Estrella-Balderrama, J. J. Fowler, and S. G. Kobourov. Simultaneous graph embedding with bends and circular arcs. Computational Geometry: Theory and Applications, 42(2):173 -- 182, 2009. [22] N. Chiba and T. Nishizeki. The hamiltonian cycle problem is linear-time solvable for 4-connected planar graphs. Journal of Algorithms, 10(2):187 -- 211, 1989. [23] M. Chimani, M. Jünger, and M. Schulz. Crossing minimization meets simultaneous drawing. In IEEE Pacific Visualisation Symposium, pages 33 -- 40, 2008. [24] C. Chojnacki (Haim Hanani). Über wesentlich unplättbare kurven im dreidimen- sionalen raume. Fundamenta Mathematicae, 23:135 -- 142, 1934. [25] F. R. K. Chung, F. T. Leighton, and A. L. Rosenberg. Embedding graphs in books: a layout problem with applications to VLSI design. SIAM Journal on Algebraic and Discrete Methods, 8(1):33 -- 58, 1987. [26] C. Collberg, S. Kobourov, J. Nagra, J. Pitts, and K. Wampler. A system for graph- based visualizations of the evolution of software. In Proccedings of the Symposium on Visualization, pages 77 -- 86, 212 -- 213. ACM, 2003. [27] H. de Fraysseix, J. Pach, and R. Pollack. How to draw a planar graph on a grid. Combinatorica, 10(1):41 -- 51, 1990. [28] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, 1999. [29] E. Di Giacomo, W. Didimo, G. Liotta, and S. K. Wismath. Book embeddability of series-parallel digraphs. Algorithmica, 45(4):531 -- 547, 2006. [30] E. Di Giacomo, W. Didimo, M. van Kreveld, G. Liotta, and B. Speckmann. Matched drawings of planar graphs. Journal of Graph Algorithms and Applications, 13(3):423 -- 445, 2009. [31] E. Di Giacomo and G. Liotta. A note on simultaneous embedding of planar graphs. In EuroCG, pages 207 -- 210, 2005. [32] E. Di Giacomo and G. Liotta. Simultaneous embedding of outerplanar graphs, paths, International Journal of Computational Geometry and Applications, and cycles. 17(2):139 -- 160, 2007. 30 [33] S. Diel and C. Görg. Graphs, they are changing -- dynamic graph drawing for a sequence of graphs. In M. T. Goodrich and S. G. Kobourov, editors, Proceedings of the 10th International Symposium on Graph Drawing (GD'02), volume 2528 of Lecture Notes in Computer Science, pages 23 -- 31. Springer, 2002. [34] M. B. Dillencourt, D. Eppstein, and D. S. Hirschberg. Geometric thickness of com- plete graphs. Journal of Graph Algorithms and Applications, 4(3):5 -- 17, 2000. [35] C. A. Duncan, D. Eppstein, and S. G. Kobourov. The geometric thickness of low In Proceedings of the 20th annual symposium on Computational degree graphs. geometry, SCG '04, pages 340 -- 346. ACM, 2004. [36] C. Erten and S. Kobourov. Simultaneous embedding of planar graphs with few bends. In J. Pach, editor, Graph Drawing, volume 3383 of Lecture Notes in Computer Science, pages 195 -- 205. Springer Berlin / Heidelberg, 2005. [37] C. Erten, S. Kobourov, and C. Pitta. Intersection-free morphing of planar graphs. In G. Liotta, editor, Graph Drawing, volume 2912 of Lecture Notes in Computer Science, pages 320 -- 331. Springer Berlin / Heidelberg, 2004. [38] C. Erten and S. G. Kobourov. Simultaneous embedding of a planar graph and its dual on the grid. Theory of Computing Systems, 38(3):313 -- 327, 2005. [39] C. Erten, S. G. Kobourov, V. Le, and A. Navabi. Simultaneous graph drawing: Layout algorithms and visualization schemes. Journal of Graph Algorithms and Applications, 9(1):165 -- 182, 2005. [40] C. Erten, S. G. Kobourov, and C. Pitta. Morphing planar graphs. In Proceedings of the twentieth annual symposium on Computational geometry, SCG '04, pages 451 -- 452. ACM, 2004. [41] A. Estrella-Balderrama, J. J. Fowler, and S. G. Kobourov. GraphSET, a tool for simultaneous graph drawing. Software: Practice and Experience, 40(10):849 -- 863, 2010. [42] A. Estrella-Balderrama, E. Gassner, M. Jünger, M. Percan, M. Schaefer, and M. Schulz. Simultaneous geometric graph embeddings. In Graph Drawing, vol- ume 4875 of Lecture Notes in Computer Science, pages 280 -- 290. Springer Berlin / Heidelberg, 2008. [43] I. Fáry. On straight lines representation of planar graphs. Acta Scientiarum Math- ematicarum, 11:229 -- 233, 1948. [44] M. S. Floater. Parametrization and smooth approximation of surface triangulations. Computer Aided Geometric Design, 14:231 -- 250, 1997. [45] M. S. Floater and C. Gotsman. How to morph tilings injectively. Journal of Com- putational and Applied Mathematics, 101(1 -- 2):117 -- 129, 1999. 31 [46] J. Fowler and S. Kobourov. Characterization of unlabeled level planar graphs. In S.-H. Hong, T. Nishizeki, and W. Quan, editors, Graph Drawing, volume 4875 of Lecture Notes in Computer Science, pages 37 -- 49. Springer Berlin / Heidelberg, 2008. [47] J. J. Fowler, C. Gutwenger, M. Jünger, P. Mutzel, and M. Schulz. An SPQR-tree approach to decide special cases of simultaneous embedding with fixed edges. In Graph Drawing, volume 5417 of Lecture Notes in Computer Science, pages 157 -- 168. Springer Berlin / Heidelberg, 2009. [48] J. J. Fowler, M. Jünger, S. G. Kobourov, and M. Schulz. Characterizations of restricted pairs of planar graphs allowing simultaneous embedding with fixed edges. Computational Geometry: Theory and Applications, 44(8):385 -- 398, 2011. [49] F. Frati. Embedding graphs simultaneously with fixed edges. In Graph Drawing, volume 4372 of Lecture Notes in Computer Science, pages 108 -- 113. Springer Berlin / Heidelberg, 2007. [50] F. Frati, M. Kaufmann, and S. G. Kobourov. Constrained simultaneous and near- simultaneous embeddings. Journal of Graph Algorithms and Applications, 13(3):447 -- 465, 2009. [51] C. Friedrich and P. Eades. Graph drawing in motion. Journal of Graph Algorithms and Applications, 6(3):353 -- 370, 2002. [52] C. Friedrich and M. Houle. Graph drawing in motion ii. In P. Mutzel, M. Jünger, and S. Leipert, editors, Graph Drawing, volume 2265 of Lecture Notes in Computer Science, pages 122 -- 125. Springer Berlin / Heidelberg, 2002. [53] Y. Frishman and A. Tal. Onlyne dynamic graph drawing. IEEE Transactions on Visualizations and Computer Graphics, 14(4):727 -- 740, 2008. [54] E. Gassner, M. Jünger, M. Percan, M. Schaefer, and M. Schulz. Simultaneous graph embeddings with fixed edges. In F. Fomin, editor, Graph-Theoretic Concepts in Computer Science, volume 4271 of Lecture Notes in Computer Science, pages 325 -- 335. Springer Berlin / Heidelberg, 2006. [55] F. Gavril. The intersection graphs of subtrees in trees are exactly the chordal graphs. Journal of Combinatorial Theory, Series B, 16(1):47 -- 56, 1974. [56] M. Geyer, M. Kaufmann, and I. Vrto. Two trees which are self-intersecting when drawn simultaneously. Discrete Mathematics, 309(7):1909 -- 1916, 2009. [57] M. C. Golumbic, D. Rotem, and J. Urrutia. Comparability graphs and intersection graphs. Discrete Mathematics, 43(1):37 -- 46, 1983. [58] C. Görg, P. Birke, M. Pohl, and S. Diel. Dynamic graph drawing of sequences of orthogonal and hierarchical graphs. In J. Pach, editor, Proceedings of the 12th International Symposium on Graph Drawing (GD'04), volume 3383 of Lecture Notes in Computer Science, pages 228 -- 238. Springer, 2004. 32 [59] L. Grilli, S.-H. Hong, G. Liotta, H. Meijer, and S. Wismath. Matched drawability of graph pairs and of graph triples. In WALCOM: Algorithms and Computation, volume 5431 of Lecture Notes in Computer Science, pages 322 -- 333. Springer Berlin / Heidelberg, 2009. [60] B. Haeupler, K. Jampani, and A. Lubiw. Testing simultaneous planarity when the common graph is 2-connected. In O. Cheong, K.-Y. Chwa, and K. Park, editors, Algorithms and Computation, volume 6507 of Lecture Notes in Computer Science, pages 410 -- 421. Springer Berlin / Heidelberg, 2010. [61] B. Haeupler and R. E. Tarjan. Planarity algorithms via PQ-trees (extended abstract). Electronic Notes in Discrete Mathematics, 31:143 -- 149, 2008. The International Con- ference on Topological and Geometric Graph Theory. [62] S.-H. Hong and H. Nagamochi. Two-page book embedding and clustered graph pla- narity. Technical Report 2009-004, Department of Applied Mathematics & Physics, Kyoto University, 2009. [63] J. Hopcroft and R. E. Tarjan. Efficient planarity testing. Journal of the ACM, 21(4):549 -- 568, 1974. [64] K. Jampani and A. Lubiw. The simultaneous representation problem for chordal, comparability and permutation graphs. In F. Dehne, M. Gavrilova, J.-R. Sack, and C. Tóth, editors, Algorithms and Data Structures, volume 5664 of Lecture Notes in Computer Science, pages 387 -- 398. Springer Berlin / Heidelberg, 2009. [65] K. Jampani and A. Lubiw. Simultaneous interval graphs. In O. Cheong, K.-Y. Chwa, and K. Park, editors, Algorithms and Computation, volume 6506 of Lecture Notes in Computer Science, pages 206 -- 217. Springer Berlin / Heidelberg, 2010. [66] V. Jelínek, J. Kratochvíl, and I. Rutter. A Kuratowski-type theorem for planarity of partially embedded graphs. In Proceedings of the 27th Annual ACM Symposium on Computational Geometry (SoCG'11), pages 107 -- 116. ACM, 2011. [67] M. Jünger and M. Schulz. Intersection graphs in simultaneous embedding with fixed edges. Journal of Graph Algorithms and Applications, 13(2):205 -- 218, 2009. [68] F. Kammer. Simultaneous embedding with two bends per edge in polynomial area. In L. Arge and R. Freivalds, editors, Algorithm Theory -- SWAT 2006, volume 4059 of Lecture Notes in Computer Science, pages 255 -- 267. Springer Berlin / Heidelberg, 2006. [69] M. Kaufmann and R. Wiese. Embedding vertices at points: Few bends suffice for planar graphs. Journal of Graph Algorithms and Applications, 6(1):115 -- 129, 2002. [70] P. Klavík, J. Kratochvíl, and T. Vyskočil. Extending partial representations of inter- val graphs. In Proceedings of the 8th annual conference on Theory and applications of models of computation, TAMC'11, pages 276 -- 285. Springer-Verlag, 2011. 33 [71] S. G. Kobourov and C. Pitta. An interactive multi-user system for simultaneous In Graph Drawing, volume 3383 of Lecture Notes in Computer graph drawing. Science, pages 492 -- 501. Springer Berlin / Heidelberg, 2005. [72] A. Lubiw and M. Petrick. Morphing planar graph drawings with bent edges. Elec- tronic Notes in Discrete Mathematics, 31(0):45 -- 48, 2008. [73] A. Lubiw, M. Petrick, and M. Spriggs. Morphing orthogonal planar graph draw- ings. In Proceedings of the seventeenth annual ACM-SIAM symposium on Discrete algorithm, SODA '06, pages 222 -- 230. ACM, 2006. [74] K. Misue, P. Eades, W. Lai, and K. Sugiyama. Layout adjustment and the mental map. Journal of Visual Languages and Computing, 6:183 -- 210, 1995. [75] B. Mohar. Circle packings of maps in polynomial time. European Journal of Com- binatorics, 18(7):785 -- 805, 1997. [76] B. Mohar and P. Rosenstiehl. Tessellation and visibility representations of maps on the torus. Discrete & Computational Geometry, 19:249 -- 263, 1998. [77] P. Mutzel, T. Odenthal, and M. Scharbrodt. The thickness of graphs: A survey. Graphs and Combinatorics, 14:59 -- 73, 1998. [78] S. C. North and G. Woodhall. Online hierarchical graph drawing. In P. Mutzel, M. Jünger, and S. Leipert, editors, Proceedings of the 9th International Symposium on Graph Drawing (GD'01), volume 2265 of Lecture Notes in Computer Science, pages 232 -- 246. Springer, 2002. [79] J. Pach and R. Wenger. Embedding planar graphs at fixed vertex locations. In S. Whitesides, editor, Graph Drawing, volume 1547 of Lecture Notes in Computer Science, pages 263 -- 274. Springer Berlin / Heidelberg, 1998. [80] H. C. Purchase, E. Hoggan, and C. Görg. How important is the "mental map"? -- an empirical investigation of a dynamic graph layout algorithm. In M. Kaufmann and D. Wagner, editors, Proceedings of the 14th International Symposium on Graph Drawing (GD'06), volume 4372 of Lecture Notes in Computer Science, pages 184 -- 195. Springer, 2007. [81] H. C. Purchase and A. Samra. Extremes are better: Investigating mental map In G. Stapleton, J. Howse, and J. Lee, editors, preservation in dynamic graphs. Proceeding of the 5h International Symposium on Diagrammatic Representation and Inference (DIAGRAMS'08), volume 5223 of Lecture Notes in Artifical Intelligence, pages 60 -- 73. Springer, 2008. [82] A. Sallaberry, C. Muelder, and K.-L. Ma. Clustering, visualizing, and navigating for large dynamic graphs. In Graph Drawing, Lecture Notes in Computer Science. Springer Berlin / Heidelberg, 2013. To appear. 34 [83] M. Schaefer. Toward a theory of planarity: Hanani-tutte and planarity variants. In Graph Drawing, Lecture Notes in Computer Science. Springer Berlin / Heidelberg, 2013. To appear. [84] S. K. Stein. Convex maps. Proceedings of the American Mathematical Society, 2(3):464 -- 466, 1951. [85] K. Sugiyama, S. Tagawa, and M. Toda. Methods for visual understanding of hier- archical system structures. IEEE Transactions on Systems, Man and Cybernetics, 11(2):109 -- 125, 1981. [86] V. Surazhsky and C. Gotsman. Controllable morphing of compatible planar trian- gulations. ACM Transactions on Graphics, 20(4):203 -- 231, 2001. [87] V. Surazhsky and C. Gotsman. Intrinsic morphing of compatible triangulations. International Journal of Shape Modeling, 9(2):191 -- 201, 2003. [88] R. Tamassia and I. G. Tollis. Tessellation representations of planar graphs. In Proceedings of the 27th Annual Allerton Conference on Communication, Control, and Computing, pages 48 -- 57, 1989. [89] C. Thomassen. Deformations of plane graphs. Journal of Combinatorial Theory, Series B, 34(3):244 -- 257, 1983. [90] W. Tutte. Toward a theory of crossing numbers. Journal of Combinatorial Theory, 8(1):45 -- 53, 1970. [91] W. T. Tutte. Convex representations of graphs. Proceedings of the London Mathe- matical Society, 10:304 -- 320, 1960. [92] W. T. Tutte. How to draw a graph. Proceedings of the London Mathematical Society, 13:743 -- 768, 1963. [93] K. Wagner. Bemerkungen zum Vierfarbenproblem. Jahresbericht der Deutschen Mathematiker-Vereinigung, 46:26 -- 32, 1936. [94] M. Yannakakis. Embedding planar graphs in four pages. Journal of Computer and System Sciences, 38(1):36 -- 67, 1989. [95] H. Zhang and X. He. On simultaneous straight-line grid embedding of a planar graph and its dual. Information Processing Letters, 99(1):1 -- 6, 2006. 35
1410.0589
2
1410
2015-10-08T07:16:23
An Algorithmic Metatheorem for Directed Treewidth
[ "cs.DS", "cs.CC", "cs.FL", "cs.LO" ]
The notion of directed treewidth was introduced by Johnson, Robertson, Seymour and Thomas [Journal of Combinatorial Theory, Series B, Vol 82, 2001] as a first step towards an algorithmic metatheory for digraphs. They showed that some NP-complete properties such as Hamiltonicity can be decided in polynomial time on digraphs of constant directed treewidth. Nevertheless, despite more than one decade of intensive research, the list of hard combinatorial problems that are known to be solvable in polynomial time when restricted to digraphs of constant directed treewidth has remained scarce. In this work we enrich this list by providing for the first time an algorithmic metatheorem connecting the monadic second order logic of graphs to directed treewidth. We show that most of the known positive algorithmic results for digraphs of constant directed treewidth can be reformulated in terms of our metatheorem. Additionally, we show how to use our metatheorem to provide polynomial time algorithms for two classes of combinatorial problems that have not yet been studied in the context of directed width measures. More precisely, for each fixed $k,w \in \mathbb{N}$, we show how to count in polynomial time on digraphs of directed treewidth $w$, the number of minimum spanning strong subgraphs that are the union of $k$ directed paths, and the number of maximal subgraphs that are the union of $k$ directed paths and satisfy a given minor closed property. To prove our metatheorem we devise two technical tools which we believe to be of independent interest. First, we introduce the notion of tree-zig-zag number of a digraph, a new directed width measure that is at most a constant times directed treewidth. Second, we introduce the notion of $z$-saturated tree slice language, a new formalism for the specification and manipulation of infinite sets of digraphs.
cs.DS
cs
An Algorithmic Metatheorem for Directed Treewidth Mateus de Oliveira Oliveira Institute of Mathematics, Academy of Sciences of the Czech Republic [email protected] 5 1 0 2 t c O 8 ] S D . s c [ 2 v 9 8 5 0 . 0 1 4 1 : v i X r a Abstract The notion of directed treewidth was introduced by Johnson, Robertson, Seymour and Thomas [Journal of Combinatorial Theory, Series B, Vol 82, 2001] as a first step towards an algorithmic metatheory for digraphs. They showed that some NP-complete properties such as Hamiltonicity can be decided in polynomial time on digraphs of constant directed treewidth. Nevertheless, despite more than one decade of intensive research, the list of hard combinatorial problems that are known to be solvable in polynomial time when restricted to digraphs of constant directed treewidth has remained scarce. In this work we enrich this list by providing for the first time an algorithmic metatheorem connecting the monadic second order logic of graphs to directed treewidth. We show that most of the known positive algorithmic results for digraphs of constant directed treewidth can be reformulated in terms of our metatheorem. Additionally, we show how to use our metatheorem to provide polynomial time algorithms for two classes of combinatorial problems that have not yet been studied in the context of directed width measures. More precisely, for each fixed k, w ∈ N, we show how to count in polynomial time on digraphs of directed treewidth w, the number of minimum spanning strong subgraphs that are the union of k directed paths, and the number of maximal subgraphs that are the union of k directed paths and satisfy a given minor closed property. To prove our metatheorem we devise two technical tools which we believe to be of independent interest. First, we introduce the notion of tree-zig-zag number of a digraph, a new directed width measure that is at most a constant times directed treewidth. Second, we introduce the notion of z-saturated tree slice language, a new formalism for the specification and manipulation of infinite sets of digraphs. Keywords: Combinatorial Slice Theory, Directed Treewidth, Tree-Zig-Zag Number, Monadic Second Order Logic of Graphs, Algorithmic Metatheorems 1. Introduction Since the introduction of directed treewidth in [32, 28] much effort has been devoted into trying to identify algorithmically useful digraph width measures. Such a width measure should ideally satisfy two properties. First, it should be small on several interesting instances of digraphs. Second, many combinatorial problems should become polynomial time tractable on digraphs of constant width. While the first property is satisfied by most of the digraph width measures introduced so far [6, 7, 8, 9, 26, 27, 32, 34], the goal of identifying large classes of problems that can be solved in polynomial time when these measures are bounded by a constant has proven to be extremely hard to achieve. On the positive side, Johnson, Robertson, Seymour and Thomas showed already in their seminal paper [28] that certain linkage problems, such as Hamiltonicity and k-disjoint paths (for constant k), can be solved in polynomial time on digraphs of constant directed treewidth. Subsequently, It was shown in [18] that for each constant k ∈ N, one can decide in polynomial time the existence of a spanning tree with at most k leaves on digraphs of constant directed treewidth. More recently, it was shown in [7] that determining the winner for some classes of parity games can be solved in polynomial time on digraphs of constant DAG-width [7]. In this work we enrich the list of problems that can be solved in polynomial time on digraphs of constant directed treewidth. More precisely, we devise the first algorithmic metatheorem connecting directed treewidth to the monadic second order logic of graphs with edge set quan- tifications (MSO2 logic). We show that most of the positive algorithmic results obtained so far on digraphs of constant directed treewidth can be reformulated in terms of our metatheorem. Additionally we show how to use our metatheorem to provide polynomial time algorithms for a parameterized version of the minimum spanning strong subgraph problem, and for a parame- terized version of the problem of counting subgraphs satisfying a given minor closed property. We note that celebrated results due to Courcelle [15] and Arnborg, Lagergren and Seese [3] state that any problem expressible in MSO2 logic can be solved in linear time on graphs of con- stant undirected treewidth. Additionally, an equally famous result due to Courcelle, Makowsky and Rotics states that any problem expressible in MSO logic (without edge set quantifications) can be solved in linear time on graphs of constant clique-width [17]. However, we observe that there are families of digraphs of constant directed treewidth, but simultaneously unbounded undi- rected treewidth and clique-width [17]. For instance, the n×n grid, in which all horizontal edges are oriented to the right and all vertical edges are oriented upwards, has directed treewidth 0, but undirected treewidth Θ(n) and clique-width Θ(n). Thus our algorithmic metatheorem is not implied by the results in [15, 3, 17]. On the other hand, the fact that 3-colorability is MSO expressible implies that a complete analog of Courcelle’s is theorem for digraphs of constant directed treewidth cannot be achieved unless P=NP, since 3-colorability is already NP-complete on DAGs. Before stating our main theorem we will introduce some notation. An edge-weighting func- tion for a digraph G = (V, E) is a function µ : E → Ω where Ω is a finite commutative semigroup of size polynomial in V . We will always assume that Ω has an identity ele- ment. We define the size of G as G = V + E. The weight of a subgraph H = (V ′, E′) of G is defined as µ(H) = Pe∈E ′ µ(e). We say that H is the union of k directed paths if there exist directed simple paths p1, p2, ..., pk with pi = (Vi, Ei) for i ∈ {1, ..., k} such that H = p1 ∪ p2 ∪ ... ∪ pk = (∪k i=1Ei). We note that the unions we consider are not neces- sarily vertex-disjoint nor edge-disjoint. i=1Vi, ∪k Theorem 1 (Main Theorem). Let ϕ be an MSO2 sentence and let k, w ∈ N. There is a computable function f (ϕ, w, k) such that, given a weighted digraph G = (V, E, µ : E → Ω) of directed treewidth w, a positive integer l < V , and an element α ∈ Ω, one can count in time f (ϕ, w, k) · GO(k·(w+1)) the number of subgraphs H of G simultaneously satisfying the following four properties: (i) H = ϕ, (ii) H is the union of k directed paths, (iii) H has l vertices, (iv) H has weight µ(H) = α. We note that in [20] we proved an analog theorem for digraphs of constant directed pathwidth. Nevertheless it can be shown that there exist families of digraphs of constant directed treewidth but unbounded directed pathwidth [7]. Therefore, Theorem 1 is a strict generalization of the results in [20]. To prove Theorem 1 we will introduce two new technical tools which may be of independent interest. The first, the tree-zig-zag number of a digraph, is a new directed width measure that is at most a constant times directed treewidth. The second, the notion of z-saturated tree slice languages, is a new framework for the manipulation of infinite families of digraphs. 2 1.1. Applications The parameters l and α in Theorem 1 are upper bounded by V O(1). By varying these parameters we can consider different flavours of optimization problems. For instance, we can choose to count the number of subgraphs of G that are the union of k directed paths, satisfy ϕ and have maximal/minimal number of vertices, or maximal/minimal weight. In this section we provide a list of natural combinatorial problems that can be solved in polynomial time on digraphs of constant directed treewidth using Theorem 1. In Subsection 1.1.1, we show how to use Theorem 1 to rederive three known positive algorithmic results for digraphs of constant directed treewidth. In Subsection 1.1.2, we show how Theorem 1 can be used to solve in polynomial time two interesting classes of combinatorial problems which have not yet been studied in the context of digraph width measures. Concerning the first class of problems, we show how to count the number of minimum spanning strong subgraphs that are the union of k directed paths. Concerning the second class, we show how to count the number of maximal subgraphs that are the union of k directed paths and satisfy some given minor closed property. 1.1.1. First Examples In order to use Theorem 1 to solve a counting problem in polynomial time, we need to exhibit an MSO2 sentence ϕ specifying a suitable class of digraphs to be counted, and to specify values for the parameters l and α which respectively determine the number of vertices and the weight of the subgraphs being counted. We observe that the class of digraphs specified by ϕ is fixed and does not vary with the input digraph. The parameters l and α on the other hand, may vary with the input. Counting Hamiltonian Cycles. We set ϕ to be an MSO2 sentence defining cycles, i.e., con- nected digraphs in which each vertex has precisely one incoming edge and one outgoing edge. We set l = V since we are only interested in counting sub-cycles of G that span all of its vertices. Finally, since any cycle is the union of 2 directed paths, we set k = 2. We observe that counting Hamiltonian cycles on digraphs of constant directed treewidth can also be done via an adaptation of the techniques in [28]. Counting σ-Linkages. Given a sequence σ = (s1, t1, s2, t2, ..., sk, tk) of 2k not necessarily distinct vertices, a σ-linkage is a set of internally disjoint directed paths p1, p2, ..., pk where for each i ∈ {1, ..., k}, the path pi connects si to ti. To count the number of σ-linkages on a digraph G we first assign a distinct color to each vertex in the set {s1, ..., sk, t1, ..., tk} and assume that all other vertices of G are uncolored. Then we define an MSO2 sentence ϕσ that is true in a digraph H whenever it consists of the union of k internally disjoint paths p1, ..., pk where for each i, the path pi connects a vertex of color c(si) to a vertex of color c(ti) in such a way that all internal vertices of pi are uncolored. For each l ∈ {1, ..., V } we can use Theorem 1 to count the number of σ-linkages of size l. We observe that counting σ-linkages can also be done by via an adaptation of the results in [28]. Counting Spanning-Out Trees with at most k-leaves. A spanning-out tree is a spanning tree in which all edges are directed towards the leaves. To count the number of spanning-out trees with at most k-leaves we set ϕ to be an MSO2 sentence defining trees with at most k-leaves. In other words, ϕ defines connected digraphs without cycles in which at most k vertices have no out-going edge. Since the tree has to span all vertices of G, we set l = V . Finally, we note that any spanning-out tree with at most k leaves is the union of k directed paths. We observe that counting spanning-out trees can also be done via an adaptation of the results in in [18]. 3 1.1.2. New Applications In this section we exhibit two natural classes of counting problems that can be solved in polynomial time on digraphs of constant directed treewidth using Theorem 1. To the best of our knowledge these problems cannot be addressed in polynomial time using previously existing techniques. Minimum Spanning Strong Subgraph. The classic Minimum Spanning Strong Subgraph (MSSS) problem is defined as follows. Given a strongly connected digraph G, find a spanning strongly connected subgraph of G with the minimum number of edges. This problem is in general NP complete since it generalizes the Hamiltonian cycle problem. Even though the MSSS problem has received a considerable amount of attention [1, 4, 10, 5, 22, 37], the connections between this problem and directed width measures are, to the limit of our knowledge, unexplored. Here we show that a parameterized version of the MSSS problem can be solved in polynomial time on digraphs of constant directed treewidth. A k-MSSS is a minimum spanning strong subgraph that is the union of k directed paths. We note that determining the existence of a k-MSSS on general digraphs is still NP-complete for each constant k ≥ 2, since any Hamiltonian cycle is a 2-MSSS. Using Theorem 1 we can not only determine the existence of a k-MSSS on digraphs of constant directed treewidth, but also count in polynomial time the number of occurrences of such subgraphs. All we need to do is to set l = V , since the subgraphs we are counting are spanning, and to set ϕstr as the monadic second order sentence that is true in a digraph if and only if it is strongly connected. We observe that the techniques in [28] cannot be directly applied to solve the k-MSSS problem in polynomial time due to the fact that the k paths covering a k-MSSS need not to be internally disjoint. For instance, in Figure 1 we show a family H1, H2, ... of digraphs where for each n ∈ N, Hn is the union of 2 paths. Note however that one needs 2n internally disjoint paths to cover all vertices and edges of Hn. H 1 H 2 H 3 Figure 1: For each n ∈ N, the digraph Hn is the union of 2 paths. On the other hand, 2n internally disjoint paths are necessary to cover all vertices and edges of Hn. Subgraphs Excluding a Minor. An undirected graph H is a minor of an undirected graph G if H can be obtained from a subgraph of G by a sequence of edge contractions. A family of undirected graphs F is said to be minor closed if whenever a graph G belongs to F, any minor of G is also in F. Many interesting graph families are minor closed, such as, planar graphs, outerplanar graphs, graphs of bounded genus, forests, series-parallel graphs, graphs of bounded undirected treewidth, etc. Given a minor closed family F and a graph G it is often NP-complete to find a maximal subgraph of G that belongs to the family F. For instance, the following problems are NP-complete: finding a maximal outerplanar subgraph [13, 31], finding a maximal planar subgraph [29, 12] and finding a maximal subgraph of a given genus g [11]. By the celebrated graph minor theorem of Robertson and Seymour [33], for any minor closed family of undirected graphs F there exists a finite set of undirected graphs F , such that for each graph H, H ∈ F if and only if none of the graphs in F is a minor of H. Thus, using the finite set F one can define an MSO2 sentence ϕF such that ϕF is true in a graph H if and only if H ∈ F (see for instance [16]). This fact implies that Theorem 1 can be used to count in polynomial time, on digraphs of constant directed treewidth, the number of subgraphs that are the union of k directed paths and whose underlying undirected graph satisfy a minor ↔ closed property. More precisely, if H is a directed graph, let H denote the undirected graph obtained from H by forgetting the directions of the edges in H. We have the following corollary of Theorem 1. 4 Corollary 1. Let F be a minor closed family of undirected graphs, G be a digraph of directed treewidth w, and let k ∈ N. Then one can count in time f (ϕF , k, w) · GO(k·(w+1)) the number of (maximal) subgraphs H of G subject to the following restrictions: 1. H is the union of k directed paths. ↔ H belongs to F. 2. For instance, Corollary 1 implies that we can count in polynomial time, on digraphs of constant directed treewidth, maximal planar subgraphs that are the union of k directed paths, or maximal subgraphs that are the union of k directed paths and can be embedded on a torus. In our opinion it is rather surprising that the problems addressed in Corollary 1 can be solved in polynomial time, in view of the complexity of the subgraphs that are being counted, and in view of the fact that digraphs of constant directed treewidth may have simultaneously unbounded undirected treewidth and clique-width. 1.2. Hardness Results We argue briefly that under the assumption that the W hierarchy does not collapse to FPT, a widely believed assumption in parameterized complexity theory [21], the dependence on w and on k on the exponent of the running time f (ϕ, w, k) · GO(k·(w+1)) of Theorem 1 cannot be removed. Concerning the dependence on k, we note that the problem of determining whether there exists k disjoint paths on DAGs from prescribed pairs of nodes is W[1] hard with respect to k [36]. Since any DAG has directed treewidth 0, we have that the existence of k-disjoint paths is already W[1]-hard even for digraphs of directed treewidth 0. Concerning the dependence on w, we note that it can be shown [30] that finding Hamiltonian paths on digraphs is W[2] hard with respect to the cycle-rank of the digraph in question. Since constant directed treewidth is more expressive than constant cycle rank, the hardness results in [30] extends to directed treewidth. Thus the dependence on w in the exponent of the running time f (ϕ, w, k) · GO(k·(w+1)) cannot be removed even if k = 1. 1.3. Proof Techniques and Organization of the Paper We will prove Theorem 1 using slice theoretic techniques. The notion of slice language was introduced in [19] and used to solve several problems in the partial order theory of concurrency. Subsequently, slice languages were lifted to the context of digraphs and used to provide the first algorithmic metatheorem for digraphs of constant directed pathwidth [20]. In this work we extend the results in [20] by introducing the notions of tree slice language and slice tree automata. We use tree slice-languages to provide the first algorithmic metatheorem for digraphs of constant directed treewidth (Theorem 1). More precisely, we will show that the problem of counting the number of subgraphs satisfying the conditions (i)-(iv) of Theorem 1 can be reduced to the problem of counting the number of terms accepted by a suitable deterministic slice tree- automaton. We note that the results in this work strictly generalize the results in [20], since there are families of digraphs of constant directed treewidth but unbounded directed pathwidth. Below we give a brief description of the main technical tools used in this paper and how they fit together to yield a proof of Theorem 1. All notions introduced in the following paragraphs will be re-defined more carefully along the paper. A unit slice of arity r is a digraph S whose vertex set is partitioned into a center C, an out-frontier F0 and r in-frontiers F1, ..., Fr in such a way that the center C has at most one vertex and each frontier vertex is incident with precisely one edge of S (Figure 3). Intuitively a slice S can be glued to a slice S′ at frontier j if the out-frontier of S can be matched with the j-th in-frontier of S′. A finite set Σ of slices with possibly distinct arities is called a slice alphabet. In this paper we will only be interested in slices of arity 0, 1 and 2. A term over Σ 5 is a tree-like expression T in which each node p is labeled with a slice T[p] whose arity is equal to the number of children of p. We say that T is a unit decomposition if for each position pj the slice T[pj] can be glued to the slice T[p] at its j-th frontier (Figure 4). ◦ Each unit decomposition T gives rise to a digraph T which is intuitively obtained by glueing each two adjacent slices in T along their matching frontiers. Conversely, for each digraph G there is a suitable slice alphabet Σ and unit decomposition T over Σ such that T is isomorphic to G. We can represent infinite families of digraphs via tree-automata over slice alphabets. We say that such an automaton A is a slice tree-automaton if all terms generated by A are unit decompositions. With a slice tree-automaton A one can associate two types of languages. The first, the slice language L(A), is simply the set of all unit decompositions accepted by A. The second, the graph language LG(A) is the set of all digraphs represented by unit decompositions in L(A). ◦ ◦ We say that a unit decomposition T has tree-zig-zag number z if each simple path in the digraph T represented by T crosses each frontier of each slice in T at most z times (Figure 4). A slice tree-automaton A has tree-zig-zag number z if each unit decomposition T ∈ L(A) has tree-zig-zag number z. Finally, we say that a slice tree-automaton A is z-saturated over a slice alphabet Σ if the presence of a digraph H in the graph language LG(A) implies that each unit decomposition T of tree-zig-zag number z representing H belongs to L(A). The importance of the notion of saturation stems from the following fact. Given a slice tree-automaton A of tree-zig-zag number z and a slice tree-automaton A′ that is z-saturated, it is possible to show that LG(A ∩ A′) = LG(A) ∩ LG(A′). In other words, the set of digraphs represented by the intersection A ∩ A′ is equal to the intersection of the sets of digraphs represented by A and A′ separately. We note that this crucial property is not satisfied by general slice tree-automata. Within this framework, the proof of Theorem 1 can be divided into the following steps. 1. In the first step, we will show that given a digraph G of directed treewidth w one can construct a unit decomposition T of G of tree-zig-zag number z ≤ 9w + 18. This con- struction will follow from a combination of Theorem 3 with Proposition 8. Subsequently, we will show that using T one can construct a slice tree-automaton A(T, k · z) of tree-zig- zag number z whose graph language contains all subgraphs of G that are the union of k directed paths. The construction of A(T, k · z) will be given in the proof of Lemma 5. 2. In the second step we will show that given an MSO2 sentence ϕ and an integer k, one can automatically construct a z-saturated slice tree-automaton A(ϕ, k, z) whose graph language LG(A(ϕ, k, z)) consists precisely of the digraphs which at the same time satisfy ϕ and are the union of k directed paths (Theorem 5). Additionally, given a positive integer k ∈ N and a weight α ∈ Ω, we can use A(ϕ, k, z) to construct another z-saturated tree- automaton A(ϕ, k, z, l, α) whose graph language contains only those digraphs generated by A(ϕ, k, z) which have l vertices and weight α (Lemma 8). 3. Finally, in the third step we will show that the slice language of the tree-automaton A(T, k · z) ∩ A(ϕ, k, z, l, α) has precisely one unit decomposition T for each subgraph of G that is the union of k directed paths, satisfy ϕ and have prescribed length l and weight α. This claim will follow from Lemma 6 using the fact that A(T, k · z) has tree-zig-zag number z and that A(ϕ, k, z, l, α) is z-saturated. At this point, the problem of counting subgraphs of G satisfying these four properties boils down to the problem of counting the number of unit decompositions accepted by A(T, k · z) ∩ A(ϕ, k, z, l, α). Since the latter automaton is deterministic, this counting process can be carried in polynomial time. This step will be carried in Theorem 6 via an application of Theorem 4. The remainder of this paper is organized as follows. Next, in Section 2 we recall the definition of directed treewidth [28]. Subsequently, in Section 3, we introduce the tree-zig-zag number of a 6 digraph, a new directed width measure. In Section 4, we show that the tree-zig-zag number of a digraph is at most a constant times its directed treewidth. In Section 5 we recall some of the main definitions of tree-automata theory. In Section 6 we introduce tree slice languages and slice tree-automata. In Section 7 we introduce the notion of z-saturation and state a slice theoretic metatheorem (Theorem 4). In Section 8 we will show that for any MSO2 sentence ϕ and any k, z ∈ N one can construct a z-saturated slice automaton A(ϕ, k, z) whose graph language consists of all digraphs that are the union of k directed paths and satisfy ϕ. In Section 9 we will show how to restrict A(ϕ, k, z) into an automaton A(ϕ, k, z, l, α) whose graph language consists precisely of the digraphs that, at the same time, are the union of k paths, satisfy ϕ, have l vertices and weight α. In the same section we prove our main theorem, Theorem 1. Finally, in Section 10 we make some final remarks and discuss some future directions. 2. Directed Treewidth In this section we recall the definitions of arboreal decomposition and directed treewidth. For a matter of uniformity with other notions of tree decompositions encountered in this paper, our notation slightly differs from the notation used in [28]. Let {1, ..., r}∗ denote the set of all strings over {1, ..., r} and let λ denote the empty string. A subset N ⊆ {1, ..., r}∗ is prefix closed if for every p ∈ {1, ..., r}∗ and every j ∈ {1, ..., r}, pj ∈ N implies that p ∈ N . We note that the empty string λ is an element of any prefix closed subset of {1, ..., r}∗. We say that N ⊆ {1, ..., r}∗ is well numbered if for every p ∈ {1, ..., r}∗ and every j ∈ {1, ..., r}, the presence of pj in N implies that p1, ..., p(j − 1) also belong to N . An r-ary tree is a pair T = (N, F ) whose set of nodes N is a finite prefix closed, well numbered subset of {1, ..., r}∗, and whose set of arcs F is defined as F = {(p, pj) p, pj ∈ N, j ∈ {1, ..., r}}. Observe that by our definition, the root of an r-ary tree is the empty string λ. A binary tree is an r-ary tree in which r = 2. If pj ∈ N , then we say that pj is a child of p, or interchangeably, that p is the parent of pj. A leaf is a node p ∈ N without children. If pu ∈ N for u ∈ {1, ..., r}∗, then we say that pu is a descendant of p. For a node p ∈ N we let N (p) = {pu ∈ N u ∈ {1, ..., r}∗} denote the set of all descendants of p. Note that p is a descendant of itself and therefore p ∈ N (p). Let G = (V, E) be a digraph and let Z and K be two disjoint subsets of vertices of G. We say that K is Z-normal if there is no directed walk in V \Z with first and last vertex in K that uses a vertex of V \(Z ∪ K). In other words, K is Z-normal if every walk which starts and ends in K is either wholly contained in K or uses a vertex of Z. An arboreal decomposition of a digraph G = (V, E) is a four-tuple D = (N, F, W, Z) where (N, F ) is an r-ary tree for some r ∈ N, W : N → 2V is a function that associates with each node p ∈ N a non-empty set of vertices W (p) ⊆ V , and Z : F → 2V is a function that associates with each arc (p, pj) ∈ F , a set of vertices Z(p, pj). In the sequel, we may refer to the sets W (p) as the bags of D. For a node p ∈ N we let V (p, D) =Su∈N (p) W (u) denote the set of all vertices of G that belong to some bag associated with a descendant of p. The functions W and Z satisfy the following two properties. 1) {W (p) p ∈ N } is a partition of V into non-empty sets. 2) For each (p, pj) ∈ F , the set V (pj, D) is Z(p, pj)-normal. Intuitively, Condition 2 says that for each (p, pj) ∈ F , the set of all vertices of G that belong to bags associated with descendants of pj is Z(p, pj) normal. If e is an arc in F and p is a node in N then we write e ∼ p to indicate that p is incident with e. In other words, e ∼ p means that either e = (p, p′) or e = (p′, p) for some p′ ∈ N . The width w(D) of the arboreal decomposition D is the least integer w such that for every node p ∈ N , W (p) ∪Se∼p Z(e) ≤ w + 1. The directed treewidth of G is the least integer w such that there is an arboreal decomposition of G 7 of width w. An arboreal decomposition D = (N, F, W, Z) of a digraph G is good if additionally the following condition is satisfied. 3) For each position p ∈ N , if pi ∈ N and pj ∈ N with i < j, then there is no edge in G with source in V (pj, D) and target in V (pi, D). A haven of order w in a digraph G = (V, E) is a function β that assigns to each set Z ⊆ V with Z < w, the vertex-set of a strongly connected component of the digraph G\Z, in such a way that for each two sets of vertices Z, Z ′ ⊆ V , if Z ′ ⊆ Z with Z < w, then β(Z) ⊆ β(Z ′). It can be shown that if G has a haven of order w then its directed treewidth is at least w − 1. Theorem 3.3 of reference [28] states that a digraph G either has directed treewidth at most 3w − 2, or it has a haven of order w. The proof of this theorem is algorithmic. The algorithm either constructs a good arboreal decomposition of G of width 3w − 2 or declares that G has a haven of order w. Since a haven of order w is a certificate that the directed treewidth of G is at least w − 1, one can be sure that if the directed treewidth of G is at most w − 2, a good arboreal decomposition of G of width at most 3w − 2 will be found. Equivalently, if G has directed treewidth at most w then one can always find an arboreal decomposition for G of width at most 3w + 4. Theorem 2 ([28]). Let G be a digraph of directed treewidth at most w. One can construct in time GO(w) a good arboreal decomposition of G of width at most 3w + 4. 3. Olive-Tree Decompositions and the Tree-Zig-Zag Number of a Digraph In this section we will introduce the tree-zig-zag number of a digraph, a new directed width measure. Next, in Section 3 we will show that the tree-zig-zag number of a digraph is at most a constant times its directed treewidth. Definition 1. An olive-tree decomposition of a digraph G = (V, E) is a triple T = (N, F, m) where (N, F ) is a binary tree and m : V → N is an injective map from vertices of G to nodes of T . The notion of olive-tree decomposition is similar to the notion of carving decomposition introduced by Seymour and Thomas in [35]. The only difference is that in a carving decomposi- tion, as defined in [35], the vertices of the digraph G are bijectively mapped to the leaves of the tree, while in our definition these vertices can also be mapped to the internal nodes of the tree, and the mapping is required to be injective, but not necessarily bijective. If T = (N, F, m) is an −1(N (p)) denote the olive-tree decomposition of a digraph G = (V, E) then we let V (p, T ) = m set of all vertices of G that are mapped to some descendant of p. If V1, V2 ⊆ V are two subsets of vertices of G with V1 ∩ V2 = ∅, then we let E(V1, V2) denote the set of all edges of G with one endpoint in V1 and another endpoint in V2. The width w(p) of a node p ∈ N is defined as w(p) = E(V (p, T ), V \V (p, T )). The width w(T ) of T is defined as the maximum width of a node in N . More precisely, w(T ) = max{w(p) p ∈ N }. We observe that an olive-tree decomposition of a digraph G = (V, E) has width at most E. In this work we will not be interested in olive-tree decompositions of minimum width. Rather, we will be concerned with decompositions having small tree-zig-zag number, a digraph width measure that will be defined below. Let T = (N, F, m) be an olive-tree decomposition of a digraph G = (V, E), H = (V ′, E′) be a subgraph of G, and mV ′ : V ′ → N be the restriction of m to V ′. We say that the triple T ′ = (N, F, mV ′) is the olive-tree decomposition of H induced by T . A simple path in a digraph G is an alternated sequence p = v1e1v2e2....vn−1en−1vn of vertices and edges of G such that for each i ∈ {1, ..., n − 1}, the edge ei has vi as source and vi+1 as target, and such that 8 vi 6= vj for each i, j with i 6= j. We view p as a subgraph of G by setting p = (Vp, Ep) where Vp = {v1, v2, ..., vn} and Ep = {e1, e2, ..., en−1}. We let w(T , p) = max u∈N Ep ∩ E(V (u, T ), V \V (u, T )) be the width of the path p along the olive-tree decomposition T . Intuitively, w(T , p) quantifies the amount of times the path p enters or leaves the set V (u, T ) for each u ∈ N . Definition 2 (Tree-Zig-Zag Number). Let G = (V, E) be a digraph and T = (N, F, m) be an olive-tree decomposition of G. The tree-zig-zag number of T is defined as tzn(T ) = max{w(T , p) p is a simple path in G}. The tree-zig-zag number of G is defined as the minimum tree-zig-zag number of an olive-tree decomposition of G: tzn(G) = min{tzn(T ) T is an olive-tree decomposition of G}. In Equation 1 below we compare the tree-zig-zag number of a digraph with several other directed width measures. In [20] we defined the zig-zag number zn(G) of a digraph G as a measure that quantifies the amount of times a directed path is allowed enter or leave any initial segment of a total ordering of the vertices of G. The tree-zig-zag number tzn(G) may be regarded as an analog of zn(G) which quantifies the amount of times a directed path is allowed to enter or leave any sub-tree of an olive-tree decomposition of G. If G is a digraph, we write dtw (G) for its directed treewidth [28], Dw (G) for its D-width [25], dagw (G) for its DAG-width [7], dpw (G) for its directed path-width [6], Kelw (G) for its Kelly-width [23], ddp(G) for its DAG-depth [23], Kw (G) for its K-width [23], s(G) for its weak separator number [25] and cr (G) for its cycle rank [25]. A dashed arrow A 99K B from measure A to measure B indicates that A is at least as expressive as B. More precisely, there exist constants α1, α2 ∈ N such that for every digraph G, A(G) ≤ α1 · B(G) + α2. A full arrow A → B indicates that the measure A is strictly more expressive than measure B. More precisely, A is at least as expressive as B, and there exists an infinite class of digraphs in which A is bounded by a constant, but B is unbounded. zn(G) ❙ ✸ ❙ [20] ❙ ❙ ❙ [23] ◗ ◗ Kelw (G) ◗ ✑✑✸ ❙ ❙ ◗◗s ❙❙✇ dpw (G) ✲[7] tzn(G) ✲Th. 3 dtw (G) ✲[7] dagw (G) ✑ [27] ✑ ✑ ◗ ◗ [2] ◗ ◗◗s ✲[25] Dw (G) ✑✑✸ ✑ [34, 20] ✑ ✑ (1) Kw (G) ✻ [24] ✲[25] cr (G) [24] ❄ ddp(G) cr (G) log G ✲[25] s(G) The numbers above each arrow A → B (A 99K B) in Equation 1 refer to the works in which the corresponding relation between the measures A and B was established. All relations listed above can be inferred from the literature, except for the relation tzn(G) 99K zn(G), which is immediate, and the relation tzn(G) 99K dtw(G), which will be formally stated in Theorem 9 3 below and proved in Section 4. The fact that DAG-width, Kelly-width and D-width are strictly more expressive than directed pathwidth follows from the fact that the width of the complete undirected1 binary tree on n leaves is bounded with respect to these three measures, but unbounded (Ω(log n)) with respect to directed pathwidth [20]. It is worth noting that the precise statement of our main theorem (Theorem 1) holds if the parameter w corresponds to the width of the digraph G with respect to any measure reachable from dtw (G) in Equation 1. More Precisely, Theorem 1 also holds when w is the Kelly width, DAG-width, D-width, directed pathwidth, cycle rank, K-width or DAG-depth of G. Theorem 1 can also be applied if the parameter w is the tree-zig-zag number of G. However, in this particular case, an explicit olive-tree decomposition of G of tree-zig-zag number O(w) must be given in the input. For directed tree-width and less expressive measures, such an olive- tree decomposition of width O(w) can be automatically constructed in time GO(w). This construction will be carried in Section 4 together with the proof of Theorem 3. Theorem 3. Let G be a digraph, tzn(G) be its tree-zig-zag number and dtw(G) be its directed treewidth. Then tzn(G) ≤ 9 · dtw(G) + 18. 4. Tree-Zig-Zag Number vs Directed Treewidth In this section we will prove Theorem 3. First we will state a couple of propositions con- cerning Z-normal sets. Proposition 1. Let G = (V, E) be a digraph and K, Z ⊆ V be such that K is Z-normal. Then for each subset X ⊆ K, K\X is Z ∪ X-normal. Proof. The proof is by contradiction. Assume that there is an X ⊆ K such that K\X is not Z ∪ X-normal. Then there is a walk in G\(Z ∪ X) that starts and ends in K\X, but that uses a vertex from V \((Z ∪ X) ∪ (K\X)) = V \(Z ∪ K). This contradicts the assumption that K is Z-normal. If G = (V, E) is a digraph, Z is a subset of V and p = v1e1v2....vn−1en−1vn = (Vp, Ep) is a path on G then we say that p is internally disjoint from Z if Z ∩ Vp ⊆ {v1, vn}. In other words, p is internally disjoint from Z if none of its internal vertices belongs to Z. The next proposition says that if K is a Z-normal subset of V and p is a path that is internally disjoint from Z, then p can enter or leave K at most 2 times. Proposition 2. Let G = (V, E) be a digraph and K, Z ⊆ V be subsets of V such that K is Z-normal. Let p = (Vp, Ep) be a path in G that is internally disjoint from Z. Then Ep ∩ E(K, V \K) ≤ 2. Proof. The proof is by contradiction. Assume that Ep ∩ E(K, V \K) ≥ 3. Let e1, e2 and e3 be the first three edges of p that have one endpoint in K and other endpoint in V \K. Then p = p0e1p1e2p2e3p3 where for each i ∈ {1, 2, 3}, the source of ei is the last vertex of pi−1 and the target of ei is the first vertex of pi. Since the path p is internally disjoint from Z, we have that either p1 is entirely contained in K and p2 is entirely contained in V \(K ∪ Z), or p1 is entirely contained in V \(K ∪ Z) and p2 is entirely contained in K. Therefore either e1p1e2 or e2p2e3 is a path that starts and finishes at K and uses a vertex of V \(K ∪ Z). This contradicts the assumption that K is Z-normal. The next proposition says that if p is a path of G, then the number of edges of p crossing a Z-normal set is upper bounded by 2 · Z + 2. 1In this setting each undirected edge is represented by two directed edges in opposite directions. 10 Proposition 3. Let G = (V, E) be a digraph and K, Z ⊆ V be subsets of V such that K is Z-normal. Then for each path p = (Vp, Ep) in G, Ep ∩ E(K, V \K) ≤ 2 · Z + 2. Proof. Let p = (Vp, Ep) be a path in G and assume that Vp ∩ Z = {v1, ..., vk}. We may assume without loss of generality that for each i ∈ {1, ..., k − 1}, vi occurs before vi+1 in p. In other words we may assume that p = p0 ∪ p1 ∪ ... ∪ pk where p0, p1, ..., pk are internally disjoint paths in which for each i ∈ {1, ..., k}, vi is the last vertex of pi−1 and the first vertex of pi. We note that for each i ∈ {1, ..., k} the path pi = (Vpi , Epi) is internally disjoint from Z. Therefore, from Proposition 2 we have that Epi ∩ E(K, V \K) ≤ 2. This implies that Ep ∩ E(K, V \K) ≤Pk i=0 Epi ∩ E(K, V \K) ≤ 2k + 2 ≤ 2Z + 2. The next proposition says that if G is a digraph and K1 and K2 are disjoint subsets of vertices of G such that no edge has source in K2 and target in K1, then any path crossing K1 ∪ K2 at most 2 times, crosses K2 at most 3 times. Proposition 4. Let G = (V, E) be a digraph and K1, K2 be subsets of vertices of G such that K1 ∩ K2 = ∅ and such that there is no edge with source in K2 and target in K1. Let p = (Vp, Ep) be a path in G such that Ep ∩ E(K1 ∪ K2, V \(K1 ∪ K2)) ≤ 2. Then Ep ∩ E(K2, V \K2) ≤ 3. Proof. Let p = (Vp, Ep) be a path in G. If Ep ∩ E(K1 ∪ K2, V \(K1 ∪ K2)) = 0 then p is either entirely contained in K1 ∪ K2 or entirely contained in V \(K1 ∪ K2) and the proposition holds trivially. Now let Ep ∩ E(K1 ∪ K2, V \(K1 ∪ K2)) = 1 and let e1 be the unique edge with one endpoint in K1 ∪ K2 and another endpoint in V \(K1 ∪ K2). Then p = p0e1p1 where the source of e1 is the last vertex of p0 and the target of e1 is the first vertex of p1. Note that for each i ∈ {0, 1}, either pi is entirely contained in K1 ∪ K2 or entirely contained in V \(K1 ∪ K2). Since there is no edge with source in K2 and target in K1, we have that p0 and p1 can each cross K2 at most one time. In other words, Epi ∩ E(K2, V \K2) ≤ 1. Therefore p0, e1 and p1 together cross K2 at most three times and the proposition holds in this case. Finally, let Ep ∩ E(K1 ∪ K2, V \(K1 ∪ K2)) = 2. Let e1 and e2 be the only edges of p with one endpoint in K1 ∪ K2 and the other endpoint in V \(K1 ∪ K2), and assume that e1 is visited before e2. Then there are paths p1, p2, p3 such that p = p0e1p1e2p2 and for i ∈ {1, 2}, the source of ei is the last vertex of pi−1 and the target of ei is the source of pi. Note that for i ∈ {0, 1, 2}, pi is either entirely contained in K1 ∪ K2 or entirely contained in V \(K1 ∪ K2). Note also that each pi crosses K2 at most one time, since there is no edge with source in K2 and target in K1. This already implies that p can cross K2 at most 5 times. We claim that with further analysis it can be shown that the number of crossings is at most 3, which is optimal. The analysis is as follows. If the source of e1 belongs to V \(K1 ∪ K2), then the target of e2 is also in V \(K1 ∪ K2). In this case both p0 and p2 are entirely contained in V \(K1 ∪ K2), and therefore only e1, e2 and p1 have the possibility of crossing K2. If the source of e1 belongs to K1 ∪ K2, then the target of e2 also belongs to K1 ∪ K2. This implies that p1 is entirely contained in V \(K1 ∪ K2). In this situation there are two sub-cases to be analysed. If the target of e2 belongs to K2 then p2 is entirely contained in K2 and only e1, e2 and p0 have the possibility of crossing K2. On the other hand, if the target of e2 is in K1 then e2 does not cross K2 and thus only e1, p0 and p2 have the possibility to cross K2. Using Proposition 4 we can show that if K1 and K2 are disjoint subsets of vertices of a digraph G such that K1 ∪ K2 is a Z-normal and such that there is no edge with source in K2 and target in K1, then each path in G crosses K2 at most 3Z + 3 times. 11 Proposition 5. Let G = (V, E) be a digraph and K1, K2, Z ⊆ V be subsets of vertices of G such that K1 ∪ K2 is Z-normal, K1 ∩ K2 = ∅, and such that there is no edge with source in K2 and target in K1. Then for each path p = (Vp, Ep) in G we have that Ep ∩ E(K2, V \K2) ≤ 3 · Z + 3. Proof. Analogously to the proof of Proposition 3 we let Vp ∩ Z = {v1, ..., vk}, and assume that p = p0∪p1∪...∪pk where p1, p2, ..., pk are internally disjoint paths such that for each i ∈ {1, ..., k}, vi is the last vertex of pi−1 and the first vertex of pi. We note that for each i ∈ {1, ..., k} the path pi is internally disjoint from Z. Therefore, since K1 ∪ K2 is Z-normal, by Proposition 2 we have that Epi ∩ E(K1 ∪ K2, V \(K1 ∪ K2)) ≤ 2. Now, since there is no edge with source in K2 and target in K1, we can apply Proposition 4 to infer that Epi ∩ E(K2, V \K2) ≤ 3. This i=0 Epi ∩ E(K2, V \K2) ≤ 3k + 3 ≤ 3Z + 3. implies that Ep ∩ E(K2, V \K2) ≤Pk The main technical lemma of this section states that each good arboreal decomposition D of width w can be transformed into an olive-tree decomposition T of tree-zig-zag number at most 3w + 6. Lemma 1. Let G = (V, E) be a digraph and D = (N, F, W, Z) be a good arboreal decomposition of G of width w. One can construct in time O(w·N ) an olive-tree decomposition T = (N ′, F ′, m) of G of tree-zig-zag number at most 3w + 6. Proof. We start by defining the sets of nodes and arcs of the olive-tree decomposition T . In- tuitively, T is obtained by replacing each node p of D, labeled with a bag W (p) and having r children, with a line Lp ≡ a0 p as depicted in Figure 2. p...aW (p) p...br b1 pb2 pa1 p ( ) W p 0 ap 1 ap L p Wp W p( ) ap 1 bp 2 bp r bp Wp1 Wp2 Wpr W p1 W ( ) ( )p2 W ( )pr Figure 2: From a good arboreal decomposition of width w to an olive-tree decomposition of tree-zig-zag number at most 3w + 6. Each vertex in W (p) is mapped by m to a node in {a1 } in such a way that no two distinct vertices in W (p) are mapped to the same node. No vertex of G is mapped to the node p nor to the nodes b1 a0 p. These nodes are used to connect the line Lp corresponding to the node p of D to lines corresponding to other positions. In particular for each j ∈ {1, ..., r}, bj p is connected to a0 p is connected to the first vertex of the line Lpj. We will show below that the olive-tree decomposition defined in this way has width at most 3w + 6. First however we formally define the sets N ′ and F ′ and the mapping function m. pj. In other words, bj p, ..., br p, b2 p, ..., aW (p) p N ′ = {ai p p ∈ N, 0 ≤ i ≤ W (p)} ∪ {bj p (p, pj) ∈ F } (2) 12 F ′ = {(ai p, ai+1 p ) p ∈ N, 0 ≤ i ≤ W (p) − 1} ∪ {(aW (p) p , b1 p) p ∈ N } ∪ (3) {(bi p, bi+1 p ) p ∈ N, 1 ≤ i ≤ r − 1} ∪ {(bj p, a0 pj) (p, pj) ∈ F } Finally, the labeling function m : V → N ′ is chosen arbitrarily as long as it satisfies the following condition for each node p ∈ N . m(W (p)) = {a1 p, ..., aW (p) p }. (4) p, ..., aW (p) In other words we choose m in such a way that for each position p ∈ N , the vertices in W (p) are bijectively mapped to the nodes in {a1 }. We argue that T is indeed an olive-tree decomposition of tree-zig-zag number at most 3w + 6. Recall that if G = (V, E) is a digraph and D is an arboreal decomposition of G, then for each node p of D, V (p, D) denotes the set of vertices of G that belong to some bag associated with a descendant of p (including p itself). Analogously, if T is an olive-tree decomposition of G then for each node u of T , V (u, T ) denotes the set of vertices of G that are mapped to some descendant of u. To show that T has tree-zig-zag number at most 3w + 6 we need to show that for each node u ∈ N ′, and each path p in G, p Ep ∩ E(V (u, T ), V \V (u, T )) ≤ 3w + 6. There are two cases to be considered, depending on whether u = ai analyse each of these cases below. p or whether u = bj p. We 1. (u = ai p) We start by noting that for each node p ∈ N , V (p, D) = V (a0 p, T ). If p is the root of D then V (p, D) = V and thus both V (p, D) and V (a0 p, T ) are ∅-normal. If p is not the root of D then p has a parent p′. In this case by definition of arboreal decomposition we have that V (p, D) is Z(p′, p)-normal. Thus V (a0 p, T ) is also Z(p′, p)-normal. We let Xp be equal to ∅ if p is the root of D, and equal to Z(p′, p) if p′ is the parent of p. Thus we can simply say that V (p, D) is Xp-normal. Now let j ∈ {1, ..., W (p)}. Then V (aj words, V (aj to some node in {a1 p, ..., aj−1 Xp ∪ m In other p, T ) minus the vertices of G that are mapped by m p, T ) is }. This implies, by Proposition 1 that the set V (aj p, T ) is equal to V (a0 p, T ) = V (a0 p, ..., aj−1 p, ..., aj−1 })-normal. p, T )\m −1({a1 −1({a1 }). p p p Since by the construction of T , m width w, we have that Xp ∪ m for each j ∈ {0, ..., W (p)}, −1({a1 −1({a1 p, ..., aj−1 p, ..., aj−1 p p }) ⊆ W (p) (Equation 4), and since D has }) ≤ w + 1. Therefore, by Proposition 3, Ep ∩ E(V (aj p, T ), V \V (aj p, T )) ≤ 2(w + 1) + 2 ≤ 3w + 6. 2. (u = bj p) Let u = bj p, we have that V (bj p, T ) = V (p, D) for each p ∈ N , we have that V (bj p, T ) ⊆ V (b1 p for some p ∈ N and j ∈ {1, ..., r}. Since by the construction of T , no vertex of G is mapped to bj pk, T ). Additionally, since V (a0 k=j V (pk, D). Note that V (bj p, T ) for each j ∈ {1, ..., r}. Since D is a good arboreal decomposition, we have that for i, j ∈ {1, ..., r} with i < j there is no edge with source in V (pj, D) and target in V (pi, D). This implies that for each j ∈ {1, ..., r}, there is no edge with source in V (bj p, T ). Now let Xp be equal to ∅ if p is the root of D, and equal to Z(p′, p) if p′ is the parent of p. We note that V (a0 p, T ) = V (p, D) is Xp-normal, and that V (b1 p, T ) p, T )\W (p). Therefore, by Proposition 1, V (b1 p, T ) = Sr p, T ) =Sr p, T ) and target in V (b1 p, T ) = V (a0 p, T )\V (bj k=j V (a0 13 is Xp ∪ W (p)-normal. Now, we can apply Proposition 5 with K1 = V (b1 K2 = V (bj p, T ), and Z = Xp ∪ W (p) to infer that p, T )\V (bj p, T ), Ep ∩ E(V (bj p, T ), V \V (bj p, T )) ≤ 3Z + 3 ≤ 3(w + 1) + 3 = 3w + 6. The inequality 3Z+3 ≤ 3(w +1)+3 follows from the fact that Z = Xp ∪W (p) ≤ w +1, since D has width w. Finally we are in a position to prove Theorem 3. Proof of Theorem 3. By Lemma 2, given a digraph G of directed treewidth w one can construct in time GO(w) a good arboreal decomposition D of G of width at most 3w + 4. By Lemma 1 one can transform D into an olive-tree decomposition T of G of tree-zig-zag number at most 3(3w + 4) + 6 = 9w + 18. (cid:3) 5. Tree Automata In this section we recall some of the main concepts of tree-automata theory. For an extensive treatment of the subject we refer the reader to the standard reference [14]. As two non-standard applications, we consider the problem of counting the number of terms of depth d accepted by a deterministic tree-automaton, and the problem of generating terms having a prescribed weight. A ranked alphabet is a finite set Σ = Σ0 ∪ Σ1 ∪ ... ∪ Σr of function symbols where the elements of Σi are function symbols of arity i. Intuitively, the arity of a function symbol specifies its number of inputs. Constants are regarded as function symbols of arity 0. If f is a function symbol in Σ then we let a(f ) denote the arity of f . In other words a(f ) = i if and only if f ∈ Σi. The set Ter (Σ) of all terms2 over Σ is inductively defined as follows: • if f ∈ Σ0 then f is a term in Ter (Σ), • if f ∈ Σa(f ) and t1, ..., ta(f ) are terms in Ter (Σ) then f (t1, t2, ..., ta(f )) is a term in Ter (Σ). Let t = f (t1, ..., ta(f )) be a term over the ranked alphabet Σ. Then we define ls(t) = f as the leading symbol of t. We denote by Pos(t) the set of positions of t, which is a prefix closed subset of {1, ..., r}∗ used to index the subterms of t. More precisely, if t = f (t1, ..., ta(f )) then Pos(t) = {λ} ∪ [j∈{1,...,a(f )} {jp p ∈ Pos(tj)}. We note that if t is a constant, i.e., a function symbol of arity 0, then Pos(t) = {λ}. If t ∈ Ter (Σ) then we let t = Pos(t). The subterm tp of t at position p is inductively defined as follows: tλ = t; if t = f (t1, t2, ..., ta(f )), then for each j ∈ [a(f )] and each position jp ∈ Pos(t), tjp = tjp. If t is a term and p ∈ Pos(t) then t[p] = ls(tp) denotes the leading symbol of the subterm of t at position p. A tree-language over a ranked alphabet Σ is any subset L ⊆ Ter (Σ). In particular the empty set ∅ is a tree-language. A bottom-up tree-automaton over Σ is a tuple A = (Q, Σ, QF , ∆) where Q is a set of states, QF ⊆ Q a set of final states and ∆ = ∆0 ∪ ∆1 ∪ .... ∪ ∆r is a transition relation where ∆0 ⊆ Σ0 × Q and ∆i ⊆ Qi × Σi × Q for each i ∈ {1, ..., r}. The size of A, which is defined as A = Q + ∆, measures the number of states in Q plus the number of transitions 2In this work we will not be interested in terms containing variables. In other words, all terms considered here are ground terms. 14 in ∆. The set L(A, q, i) of all terms reaching a state q ∈ Q in depth at most i is inductively defined as follows. L(A, q, 1) = {a ∈ Σ0 (a, q) ∈ ∆0} L(A, q, i) = L(A, q, i − 1) ∪ {f (t1, ..., ta(f )) (q1, ..., qa(f ), f, q) ∈ ∆a(f ), tj ∈ L(A, qj , i − 1)} We denote by L(A) the set of all terms reaching a final state in QF at any finite depth. L(A) = [q∈QF ,i∈N L(A, q, i) (5) (6) We say that the set L(A) is the language generated by A. Let A = (Q, Σ, QF , ∆) be a tree-automaton. We say that A is deterministic if for every function symbol f ∈ Σ and every tuple (q1, ..., qa(f )) ∈ Qa(f ) there exists at most one q ∈ Q such that (q1, ..., qa(f ), f, q) ∈ ∆a(f ). We say that A is complete if for every function symbol f and every tuple (q1, ..., qa(f )) ∈ Qa(f ) there exists at least one q ∈ Q for which (q1, ..., qa(f ), f, q) ∈ ∆a(f ). Observe that from any tree-automaton A one can derive a complete tree-automaton A′ generating the same language by adding a dead state qdead , and creating a transition (q1, ..., qa(f ), f, qdead ) whenever there is no transition in A whose left side is (q1, ..., qa(f ), f ). If t is a term in Ter (Σ), then the depth of t is defined as max{p : p ∈ Pos(t)}. In other words, the depth of a term t is the size of the longest path from the root of t to one of its If A is a tree-automaton and t ∈ L(A) is a leaves. We denote by depth(t) the depth of t. term of depth d, then we say that A accepts t in depth d. The next lemma says that for any deterministic tree-automaton A and any d ∈ N, one can count in polynomial time the number of terms accepted by A in depth at most d. Lemma 2. Let A be a deterministic tree-automaton and let d ∈ N. One can count in time dO(1) · AO(1) the number of terms accepted by A in depth at most d. Proof. The proof follows by a standard dynamic programming argument. First we write a recursive formula that counts the number of terms that reach a given state q in depth i: L(A, q, 1) = {(f, q) f ∈ Σ0, q ∈ Q} L(A, q, i) = X(q1,...,qa(f ),f,q)∈∆ a(f ) Yj=1 L(A, qj , i − 1) (7) (8) Now the number of terms accepted by A in depth d is the number of terms that reach a final state at depth d. L(A) = Xq∈QF ,i≤d L(A, q, i). (9) Thus to determine L(A), one can use Equation 7 to compute and store in memory the value L(A, q, 1) for each q ∈ Q. Subsequently, using the values stored in memory, one can use Equation 8 to compute and store in memory the values L(A, q, 2) and so on. We repeat this process until we have computed all values L(A, q, d). At this point, we apply Equation 9 to determine the number of terms that reach a final term in depth at most d. Since in this work, a(f ) is bounded by a constant (indeed in our applications a(f ) ≤ 2), this counting process can clearly be done in time dO(1) · AO(1). 15 5.1. Properties of Tree-Automata If L is a tree language over a ranked alphabet Σ then the complement of L is defined as L = Ter (Σ)\L. A projection between ranked alphabets Σ and Σ′ is any arity preserving total mapping π : Σ → Σ′. By arity preserving we mean that if f is a function symbol of arity r in Σ, then π(f ) is a function symbol of arity r in Σ′. Recall that if t is a term and p ∈ Pos(t) then t[p] = ls(tp) denotes the leading symbol of the subterm of t rooted at position p. A projection π : Σ → Σ′ can be homomorphically extended to a mapping π : Ter (Σ) → Ter (Σ′) between terms by setting π(t)[p] = π(t[p]) for each position p ∈ Pos(t). Additionally, such mapping π can be further extended to tree languages L ⊆ Ter (Σ) by setting π(L) = {π(t) t ∈ Ter (Σ)}. Finally, given a projection π : Σ → Σ′ and a tree language L over Σ′, the inverse homomorphic image of L under π is defined as π−1(L) = {t ∈ Ter (Σ) π(t) ∈ L}, i.e., the set of all terms over Ter (Σ) which are mapped to some term in L. In Lemma 3 below we list several well known closure properties of tree languages recognizable by tree-automata (see for instance [14]). Lemma 3 (Properties of Tree Automata). Let A be an arbitrary tree-automaton over a ranked alphabet Σ and let A1 and A2 be deterministic complete tree-automata over Σ. (i) There exists a unique minimal deterministic complete tree-automaton det(A) such that L(det (A)) = L(A). Additionally, det(A) can be constructed in time 2O(A). (ii) One can construct in time O(A1) a deterministic complete tree-automaton A1 such that L(A1) = L(A1). (iii) One can construct in time O(A1 · A2) deterministic complete tree-automata A1 ∪ A2 and A1 ∩ A2 such that L(A1 ∪ A2) = L(A1) ∪ L(A2) and L(A1 ∩ A2) = L(A1) ∩ L(A2). (iv) Let t ∈ Ter (Σ) be a term over Σ. Then one may determine in time O(A · t) whether t ∈ L(A). (v) Let π : Σ → Σ′ be a projection. Then one can construct in time O(A) a tree-automaton π(A) over Σ′ such that L(π(A)) = π(L(A)). (vi) Let π : Σ′ → Σ be a projection. One can construct in time O(Σ′ · A) a tree-automaton π−1(A) over Σ′ such that L(π−1(A)) = π−1(L(A)). Additionally, if A is deterministic, then π−1(A) is also deterministic. 5.2. Weighted Terms Let Σ be a ranked alphabet, Ξ be a finite semigroup, and let w : Σ → Ξ be a function that associates with each symbol f ∈ Σ, a weight w(f ) ∈ Ξ. The weight of a term t ∈ Ter (Σ) is inductively defined as follows. w(t) =( w(f ) if t = f for f ∈ Σ0 if t = f (t1, ..., ta(f )) and a(f ) ≥ 1 (10) w(f ) +Pa(f ) i=1 w(ti) The following lemma says that given an alphabet Σ, a weighting function w : Σ → Ξ, and a weight a ∈ Ξ, one can construct a tree-automaton A(Σ, w, a) generating precisely the terms in Ter (Σ) with weight a. Lemma 4. Let Σ = Σ0 ∪ ... ∪ Σr be a ranked alphabet and w : Σ → Ξ be a weighting function on Σ. Then for each weight a ∈ Ξ, one can construct in time Σ · ΞO(r) a tree-automaton A(Σ, w, a) such that L(A(Σ, w, a)) = {t ∈ Ter (Σ) w(t) = a}. 16 Proof. Let A = (Q, Σ, QF , ∆) where Q = {qb b ∈ Ξ} QF = {qa} a(f ) ∆ = {(f, qw(f )) f ∈ Σ0} ∪ {(qb1 , ..., qba(f ) , f, qb) f ∈ Σ, a(f ) ≥ 1, b = w(f ) + bi} Xi=1 We will show that A generates precisely the terms in Ter (Σ) of weight a. First, we claim that for each b ∈ Ξ and each i ∈ N, L(A, qb, i) = {t ∈ Ter (Σ) w(t) = b, t has depth i}. (11) The proof of this claim follows by induction on i. Equation 11 is true for i = 1, since in this case L(A, qb, 1) = {f ∈ Σ0 (f, qb) ∈ ∆, w(f ) = b}. Assume that Equation 11 holds for i ∈ N. We show that it also holds for i + 1. By Equation 5, we have that L(A, qb, i + 1) = L(A, qb, i) ∪ {f (t1, ..., ta(f )) (qb1 , ..., qba(f ) , f, qb) ∈ ∆′ a(f ), tj ∈ L(A, qbj , i) } By the induction hypothesis, w(tj) = bj for each tj ∈ L(A, qbj , i). Therefore the weight of j=1 bj. Since (qb1 , ..., qba(f ) , f, qb) ∈ ∆a(f ) if and j=1 bj, our claim is proved. Note that qa is the only final state in QF . j=1 w(ti) = w(f ) +Pa(f ) f (t1, ..., ta(f )) is w(f ) +Pa(f ) only if b = w(f ) +Pa(f ) Therefore the language accepted by A is L(A) = [i∈N L(A, qa, i). (12) Since for each i ∈ N the language L(A, qa, i) consists of all terms of weight a accepted in depth i, we have that L(A) is the set of all terms of weight a accepted in any finite depth, proving in this way the lemma. 6. Tree Slice Languages As mentioned in the introduction, the proof of Theorem 1 is based on the framework of tree slice languages. We dedicate this section to the introduction of this framework. We start by defining, in Subsection 6.1, the notion of slice of arity r. Intuitively, a slice of arity r is a digraph whose vertex set is partitioned into a center C, an out-frontier F0 and r in-frontiers F1, ..., Fr. Each such a slice should be regarded as a function symbol of arity r. Within this point of view, a finite set Σ of slices with possibly distinct arities can be regarded as a ranked alphabet (Subsection 6.2). In Subsection 6.3 we introduce a notion of gluability for slices. A slice S can be glued to a slice S′ at frontier j if the out-frontier of S can be matched with the j-th in-frontier of S′. In Subsection 6.4 we define unit decompositions, and tree slice languages. A unit decomposition is a term T over a slice alphabet Σ satisfying the property that each two slices associated with consecutive positions of T can be glued along their matching frontiers. A tree slice language L is a tree language over a slice alphabet Σ such that each term T ∈ L is a unit decomposition. A slice tree automaton is a tree automaton A generating a tree slice language L(A). In Subsection 6.5 we show how to associate with each unit decomposition T, a digraph T which is intuitively obtained by gluing each two consecutive slices of T. We can extend this association to slice languages. Namely, the graph language LG derived from a slice language L is the set of all digraphs associated to unit decompositions in L. In Subsection 6.6 we will introduce the notion of sub-decompositions of unit decompositions. Sub-decompositions should be regarded as a slice theoretic analog of the notion of subgraph. A key idea of this ◦ 17 paper is to reduce the problem of counting subgraphs of a digraph to the problem of counting sub-decompositions of a unit decomposition. In Subsection 6.7 we show that given any slice alphabet Σ, one can construct a slice automaton A(Σ) whose slice language consists of all unit decompositions over Σ. Finally, in Subsection 6.8 we introduce the notion of slice projection, which will be used in many places along this paper. Our main application for slice languages will be given in Section 7 where we will introduce the notion of z-saturated tree slice language. We will use this notion to count subgraphs satis- fying interesting properties on digraphs of constant tree-zig-zag number. Since the tree-zig-zag number of a digraph is at most a constant times its directed treewidth, we will also be able to count subgraphs satisfying interesting properties on digraphs of constant directed treewidth. 6.1. Slices A slice of arity r ≥ 0 is a digraph S = (V, E, s, t, ρ, ξ, [C, F0, F1, ..., Fr]) with vertex set V = C ∪ F0 ∪ ... ∪ Fr and edge set E. The function s : E → V associates with each edge e ∈ E a source vertex es, while the function t : E → V associates with each edge e ∈ E a target vertex et. We say that es and et are the endpoints of e. The function ρ : C → Γ1 labels each vertex in C with an element from a finite set of labels Γ1, and ξ : E → Γ2 labels each edge in E with an element from a finite set of labels Γ2. We say that C is the center of S, F0 is the out-frontier of S, and for each j ∈ {1, ..., r}, Fj is the j-th in-frontier of S. A slice is subject to the following restrictions. s1) The sets C, F0, ..., Fr are pairwise disjoint. For concreteness, we assume that C is either empty or C = {1, ..., n} for some n ∈ N, and that for each j ∈ {0, ..., r}, the frontier Fj is either empty or Fj = {[j, ij,1], ..., [j, ij,cj ]} for some cj ∈ N, and ij,1 < ... < ij,cj ∈ N. s2) No edge in E has both endpoints in the same frontier. s3) Each frontier vertex v ∈ F0 ∪ F1 ∪ ... ∪ Fr is the endpoint of a unique edge e. We say that S is a unit slice if the center C has at most one vertex. In other words in a unit slice the center is either empty or the singleton {1}. In this work we will only be interested in unit slices. We say that a frontier Fj is normalized if ij,k = k for each k ∈ {1, ..., cj }. A slice S is normalized if all of its frontiers are normalized. Non-normalized slices will play an important role in Subsection 6.6 when considering the notion of sub-slice. A slice of arity 0 is a slice with no in-frontier. In this case S = (V, E, s, t, ρ, ξ, [C, F0]) with V = C ∪ F0. A slice of arity 0 should not be confused with a slice in which all in-frontiers are empty. Rather, in such a slice the in-frontiers simply do not exist. In Figure 3 we depict three examples of unit slices. 1 2 3 1 2 1 2 3 1 2 3 2 4 5 2 1 Figure 3: S is a slice of arity 0, S′ is a slice of arity 1 and S′′ is a slice of arity 2. The out-frontier F0 is always drawn on the top. The in-frontiers F1, ..., Fr are drawn at the bottom and in increasing order from left to right. For each frontier vertex [j, i] we draw a black dot at frontier j and write the number i near from it. Within each frontier, the black dots are drawn in increasing order from left to right. The center vertex, if any, is drawn in the center of each box. The edges are drawn in red. The slices S and S′ are normalized. The slice S′′ is not normalized because F1 = {[1, 2], [1, 4], [1, 5]}, instead of {[1, 1], [1, 2], [1, 3]}. 18 6.2. Slice Alphabets A slice alphabet is simply a finite set Σ of slices, possibly with different arities. Slice alphabets will be used to define terms over slices and to provide sliced representations of digraphs. Let S be a slice with frontiers Fj = {[j, ij,1], ..., [j, ij,cj ]} for j ∈ {0, ..., r}. The width w(S) of S is the size of its largest frontier, i.e., w(S) = maxj{cj}. The extra-width ew(S) of S is the greatest number occurring in a frontier of S. More precisely, ew(S) = maxj{ij,cj }. For instance, in Figure 3 the extra-width of the slice S′′ is 5. For any c, q, r ∈ N with q ≥ c, and any finite sets of labels Γ1 and Γ2, we let Σr(c, q, Γ1, Γ2) denote the set of all unit slices of arity r, width at most c, extra-width at most q, whose center vertex (if any) is labelled with an element of Γ1, and whose edges are labelled with elements of Γ2. Now consider the set Σ(c, q, Γ1, Γ2) = Σ0(c, q, Γ1, Γ2) ∪ Σ1(c, q, Γ1, Γ2) ∪ ... ∪ Σr(c, q, Γ1, Γ2). We can view Σ(c, q, Γ1, Γ2) as a ranked alphabet by regarding each slice in Σj(c, q, Γ1, Γ2) as a function symbol of arity j. We let Σj(c, Γ1, Γ2) denote the subset of Σj(c, c, Γ1, Γ2) consisting only of normalized slices and set Σ(c, Γ1, Γ2) = Σ0(c, Γ1, Γ2) ∪ Σ1(c, Γ1, Γ2) ∪ ... ∪ Σr(c, Γ1, Γ2). In this work we are only interested in slices of arity at most 2. Therefore, when considering the slice alphabets Σ(c, q, Γ1, Γ2) and Σ(c, Γ1, Γ2) defined above, we assume that r = 2. 6.3. Gluability of Slices 1 2 3 1 2 3 1 1 3 3 1 1 2 2 3 3 2 2 1 1 1 1 3 3 2 2 1 1 1 1 2 2 1 1 2 2 3 3 1 1 3 3 Figure 4: G is a digraph, T = (N, F, m) is an olive-tree decomposition of G and T is a unit-decomposition of G. Note that m(a1) = 111, m(a2) = 11, m(a3) = λ, m(a4) = 12 and m(a1) = 112. The unit decomposition T is compatible with T since the map defined by a1 → v111, a2 → v11, a3 → vλ, a4 → v12 and a5 → v112 is an isomorphism from G to T. The unit decomposition T′ is a sub-decomposition of T. ◦ If S is a slice and [j, i] is a vertex in the j-th frontier of S, then we denote by e(S, j, i) the unique edge of S that has [j, i] as endpoint. Let S = (V, E, ρ, ξ, [C, F0 , F1, ..., Fr]) and S′ = (V ′, E′, ρ′, ξ′, [C ′, F ′ r]) be two slices in Σ(c, q, Γ1, Γ2). We say that S can be glued to S′ at frontier j, for 1 ≤ j ≤ r, if the out-frontier of S can be coherently matched with 1, ..., F ′ 0, F ′ 19 the j-th in-frontier of S′. Formally, S can be glued to S′ at frontier j if the following conditions are satisfied. g1. For each i ∈ {1, ..., q}, [0, i] ∈ F0 if and only if [j, i] ∈ F ′ j. g2. ξ(e(S, 0, i)) = ξ(e(S′, j, i)). g3. Either [0, i] is the target of e(S, 0, i) and [j, i] is the source of e(S′, j, i) or [0, i] is the source of e(S, 0, i) and [j, i] is the target of e(S′, j, i). Intuitively, Condition g1 says that the vertex [0, i] in the out-frontier of S is matched with the vertex [j, i] in the j-th in-frontier of S′. Condition g2 says that the unique edge of S having [0, i] as endpoint has the same label as the unique edge of S′ having [j, i] as endpoint. Finally, Condition g3 says that these edges must also agree in direction. For instance, in Figure 4, the slice T[11] can be glued to the slice T[1] at frontier 1. While T[12] can be glued to T[1] at frontier 2. 6.4. Terms over Slices, Unit Decompositions and Tree Slice Languages As observed in Subsection 6.2, a slice alphabet Σ can be regarded as a ranked alphabet where each slice S ∈ Σ of arity r is a function symbol of arity r. In this paper Σ will be typically the slice alphabet Σ(c, q, Γ1, Γ2) or the normalized slice alphabet Σ(c, Γ1, Γ2), both defined in Subsection 6.2. We let Ter (Σ) denote the set of all terms formed with slices from Σ. In this work however we will be only interested on terms over Σ that can give rise to digraphs. These terms are called unit decompositions. Definition 3 (Unit Decomposition). Let Σ be an alphabet of unit slices. A term T ∈ Ter (Σ) is a unit pre-decomposition if for each two consecutive positions p, pj ∈ Pos(T), the slice T[pj] can be glued to the slice T[p] at frontier j. A term T is a unit decomposition if it is a unit pre-decomposition in which the slice T[λ] at the root of T has empty out-frontier. The width w(T) of a unit decomposition T is the maximum width of a slice occurring in it. A unit decomposition is normalized if for each position p ∈ Pos(T) the slice T[p] is normalized. For instance, the unit decomposition T in Figure 4 is normalized while the unit decomposition T′ in the same figure is not. We let L(Σ) be the set of all unit decompositions in Ter (Σ). A tree slice language over Σ is any subset L of L(Σ). We say that a tree slice language L ⊆ L(Σ) is normalized if all unit decompositions in L are normalized. We will see in the next subsection that with each unit decomposition T one can associate a digraph T which is intuitively obtained by gluing each two consecutive slices in T. Thus with any slice language L one can associate a graph language LG consisting of all digraphs that correspond to unit decompositions in L. ◦ Of particular importance to us are the slice languages that can be effectively represented via tree-automata over slice alphabets. We call these automata slice tree-automata. Definition 4 (Slice Tree-Automaton). Let Σ be a slice alphabet. We say that a tree-automaton A = (Q, Σ, QF , ∆) over Σ is a slice tree-automaton if for each term T ∈ L(A), T is a unit decomposition over Σ. In other words, A is a slice tree-automaton if L(A) ⊆ L(Σ). In this case we say that L(A) is the slice language generated by A. We say that a slice tree automaton A is normalized if the slice language L(A) is normalized. 20 6.5. Digraphs associated with Unit Decompositions Each unit decomposition T ∈ L(Σ(c, q, Γ1, Γ2)) can be associated with a digraph T which is intuitively obtained by gluing together each two consecutive slices in T. For instance, gluing the slices of the unit decomposition T of Figure 4 we get the digraph G. To make this notion of gluing more precise, it will be convenient to define the notion of sliced edge sequence. Intuitively, each edge e of the digraph T will be defined with basis on a sliced edge sequence that contains all ”sliced parts” of e. Below, support (T) denotes the set of all positions in Pos(T) for which the slice T[p] has non-empty center. ◦ ◦ Definition 5 (Sliced Edge Sequence). Let T be a unit decomposition over a slice alphabet Σ. Let p, p′ be two positions in support (T). A sliced edge sequence from p to p′ is a sequence K ≡ (p1, a1, e1, b1)(p2, a2, e2, b2)...(pn, an, en, bn) (13) where p1 = p, pn = p′, and the following conditions are satisfied. 1. For each i ∈ {1, ..., n}, ei is an edge in T[pi] with source ai and target bi. 2. a1 is the center vertex of T[p1] and bn is the center vertex of T[pn]. 3. For each i ∈ {1, ..., n − 1}, there is a j such that either pi = pi+1j or pi+1 = pij. 4. If pi = pi+1j then for some k ∈ {1, ..., q}, bi = [0, k] and ai+1 = [j, k]. 5. If pi+1 = pij then for some k ∈ {1, ..., q}, bi = [j, k] and ai+1 = [0, k]. ◦ We note that Conditions 1-5 of Definition 5 together with the fact that T is a unit decom- position ensures that the pi 6= pj for i 6= j. To illustrate Definition 5 we note that in the unit decomposition T of Figure 4 there is a sliced edge sequence from position λ to position 12, a sliced edge sequence from 12 to 112 and so on. Intuitively, each sliced edge sequence K gives rise to an edge eK in the digraph T that is obtained by gluing all of its sliced parts e1, ..., en. Condition 1 says that ei is the sliced part of eK lying at the slice T[pi]. Condition 2 says that the source of the first sliced part of eK is the center vertex of T[p1] and the target of the last sliced part of eK is the center vertex of T[pn]. Condition 3 says that for each i ∈ {1, ..., n − 1}, ei and ei+1 lie in neighboring slices of T. If pi+1 = pij then the edge ei is intuitively directed towards the j-th in-frontier of T[pi]. In this case, Condition 4, says that the target of ei lies in the j-th in-frontier of T[pi] while the source of ei+1 lies in the out-frontier of T[pi+1]. On the other hand, if pi = pi+1j then the edge ei is intuitively directed towards the out-frontier of T[pi]. In this case, Condition 5 says that the target of ei lies in the out-frontier of T[pi] and the source of ei+1 lies in the j-th in frontier of T[pi+1]. ◦ Let T be a unit decomposition and for each p ∈ Pos(T) let T[p] = (Vp, Ep, ρp, ξp) be the slice of T at position p. The digraph T= (V, E, ρ, ξ) associated with T is defined as follows. First, for each position p ∈ support (T), we add a vertex vp to the vertex set V . Subsequently, for each two positions p, p′ ∈ Pos(T) and each sliced edge sequence K from p to p′ we add an edge eK to E and set its source as es K = vp′. Observe that multiple edges T since for some pair of positions p, p′ there may exist more than one sliced edge are allowed in sequence from p to p′. For each p ∈ Pos(T), the vertex vp receives the same label as the center vertex of T[p]. In other words, ρ(vp) = ρp(1) 3. We note that if K is a sliced edge sequence as defined in Equation 13 then Conditions 4 and 5 of Definition 5 together with Condition g2 (of Subsection 6.3) guarantee that all edges e1, e2, ..., en have the same label. Thus the label of the edge eK is set as ξ(eK ) = ξp1(e1) = ... = ξpn(en). K = vp and its target as et ◦ 3We recall that if the center of a unit slice is not empty then the center is the singleton {1}. 21 If G = (V, E, ρ, ξ) is a digraph where ρ : V → Γ1 and ξ : E → Γ2 are vertex and edge labeling functions respectively, then for each two vertices v, v′ ∈ V and each label b ∈ Γ2, −→ E (v, v′, b) = {e es = v, et = v′, ξ(e) = b} denote the set of all edges in E which we let have v as source vertex, v′ as target vertex and b as label. An isomorphism from a digraph G1 = (V1, E1, ρ1, ξ1) to a digraph G2 = (V2, E2, ρ2, ξ2) is a bijection φ : V1 → V2 from V1 to V2 such that for each v ∈ V1, ρ1(v) = ρ2(φ(v)), and such that for each two vertices v, v′ ∈ V1 −→ E 2(φ(v), φ(v′), b). A canonization function for finite and each label b ∈ Γ2, digraphs is a function [ · ] satisfying two properties. First, for every digraph G, [G] is a digraph isomorphic to G. Second, for every two digraphs G1 and G2, G1 is isomorphic to G2 if and only if [G1] = [G2]. We say that [G] is the canonical form of G. In this paper we let [ · ] be an arbitrary but fixed canonization function for finite digraphs. −→ E 1(v, v′, b) = ◦ We say that a term T is a unit decomposition of a digraph G if the digraph T is isomorphic to G. Since with any unit decomposition T one can associate a digraph T, with any tree slice language L one can associate a possibly infinite family of digraphs. If L is a tree slice language over an alphabet Σ of unit slices, then the graph language derived from L is the set LG of canonical forms of digraphs obtained by composing the slices of each unit decomposition in L. Formally, ◦ ◦ LG = {[ T] T ∈ L}. (14) For convenience, in some places we may simply say that a digraph H belongs to LG instead of saying that [H] belongs to LG. If A is a slice tree automaton then we denote by LG(A) the graph language derived from L(A). 6.6. Sub-slices and Sub-Decompositions 0, F ′ 1, ..., F ′ In this subsection we introduce the notions of sub-slice and of sub-decomposition. Intu- itively, the notion of sub-decomposition is a sliced version of the notion of subgraph. Let S = (V, E, ρ, ξ, [C, F0 , F1, ..., Fr]) be a slice of arity r. We say that a slice S′ is a sub-slice of S r]) where V ′ ⊆ V , E′ ⊆ E, ρ′ = ρV ′, ξ′ = ξE ′, C ′ ⊆ C and if S′ = (V ′, E′, ρ′, ξ′, [C ′, F ′ F ′ j ⊆ Fj for each j ∈ 0, 1, ..., r. In other words, a sub-slice of S is a subgraph of S that is also a slice. Labels of vertices and edges in a sub-slice are inherited from the original slice. We note that even if S is a normalized slice, a sub-slice S′ of S may not be normalized. For instance, in Figure 4, the slice T′[1] is a sub-slice of T[1]. Note that T′[1] is not normalized even though T[1] is. We also call attention to the fact that a sub-slice has always the same arity as the original slice, and that the empty slice εr of arity r is a sub-slice of any slice of arity r. Definition 6 (Sub-decomposition). Let Σ be a slice alphabet and let T and T′ be unit decom- positions in L(Σ). We say that T′ is a sub-decomposition of T if the following conditions are satisfied. i) Pos(T) = Pos(T′), ii) for each p ∈ Pos(T) the unit slice T′[p] is a sub-slice of T[p], iii) for each two consecutive positions p, pj ∈ Pos(T) the slice T′[pj] can be glued to the slice T′[p] at frontier j. ◦ ◦ T′ is a subgraph of T. We emphasize that Conditions i-iii of Definition 6 guarantee that if T′ is a sub-decomposition of T then the T and not digraph T there is a merely isomorphic to a subgraph of T. Conversely, for each subgraph H of sub-decomposition T′ of T for which T′= H. Again at this point we are speaking about strict equality, and not merely isomorphism. Thus each sub-decomposition of T unequivocally corresponds to a subgraph of T. A crucial step towards the proof of Theorem 1 will consist in reducing the problem of counting subgraphs of a digraph to the problem of counting sub- decompositions of a unit decomposition. T′ is an actual subgraph of ◦ ◦ ◦ ◦ ◦ ◦ 22 6.7. Initial Slice Tree-Automata In this section we will show that for each slice alphabet Σ one can construct a deterministic slice tree-automaton A(Σ) whose slice language consists of all unit decompositions that can be formed with elements from Σ. We say that A(Σ) is the initial tree-automaton for Σ. Before proceeding, we define the notion of identity slice, which will be used below in the proof of Proposition 6, and later, in the proof of Lemma 5. An identity slice in Σ(c, q, Γ1, Γ2) is a slice I = (V, E, ρ, ξ, [C, F0, F1]) of arity 1 with empty center (C = ∅) in which all edges are ”parallel”. In other words for each e ∈ E, there exists a k ∈ {1, ..., q} such that either es = [0, k] and et = [1, k] or es = [1, k] and et = [0, k]. 2 4 5 2 4 5 2 4 5 2 2 4 4 5 5 1 2 1 2 3 2 2 4 4 5 5 2 4 5 1 2 3 1 2 3 2 1 2 2 4 4 5 5 2 1 1 2 21 3 Figure 5: An identity slice I and two other slices S and S′. A slice S can be glued to S′ at frontier j if and only if there is a unique identity slice I such that S can be glued to I, and such that I can be glued to S′ at frontier j. In this case I = I(S). Our only interest in identity slices stems from the fact that for each slice S of arity r there is a unique identity slice I for which S can be glued to I. We denote this unique identity slice by I(S). Additionally, for each j ∈ {1, ..., r} there exists a unique identity slice Ij such that Ij can be glued to S at frontier j. This implies that a slice S can be glued to a slice S′ at frontier j if and only if I(S) can be glued to S′ at frontier j (See Figure 5). We observe that we consider ε1, the empty slice of arity one, as an identity slice. Proposition 6 (Initial Slice Tree-Automaton). Let Σ be a slice alphabet and let r be the maximum arity of a slice in Σ. Then one can construct in time O(Σ) a slice tree-automaton A(Σ) whose slice language L(A(Σ)) is the set of all unit decompositions over Σ. Proof. We construct the automaton A(Σ) = (Q, Σ, QF , ∆) explicitly. First, we define the set I(Σ) = {I(S) S ∈ Σ} which consist of all identity slices I for which some slice in Σ can be glued to I. The set of states Q has one state qI for each identity slice I in I(Σ). The set of final states is the singleton QF = {qε1 }. The transition relation ∆ has one transition (qI1 , ..., qIr , S, qI(S)) for each slice S of arity r in Σ, where for each j ∈ {1, ..., r}, Ii is the unique identity slice that can be glued to S at frontier j. Observe that since the states qI1 , ..., qIr and qI(S) are completely determined by S, the relation ∆ has Σ transitions. By the construction of the transition relation ∆ we have that for each term T accepted by A(Σ) and each two consecutive positions p, pj in Pos(T), the slice T[pj] can be glued to the slice T[p] at frontier j. Since the unique accepting state is qε1 we also have that T[λ] has empty out-frontier. This implies that each such term T is a unit decomposition. For the converse, let T be a unit pre-decomposition over Σ. We will show by induction on the height of T that T reaches the state qI(T[λ]). This implies in particular that if T is a unit decomposition, then T reaches the unique accepting state qε1 , since in this case T[λ] can be glued to ε1. In the base case, let T be a unit pre-decomposition of height 0. Then T consists of a single slice S of arity 0. By definition of ∆, we have that there is a transition (S, qI(S)) ∈ ∆ and therefore S reaches the state qI(S). Now suppose that the claim is valid for every unit pre-decomposition of height at most h and let T be a unit pre-decomposition of height h + 1. Let the slice T[λ] at the root of T have arity r. By the induction hypothesis, for each i ∈ {1, ..., r}, the subterm Ti 23 rooted at position i, reaches the state qIi where Ii = I(Ti[λ]). Since by the construction of ∆ the transition (qI1 , ..., qIr , T[λ], qI(T[λ])) belongs to ∆, we have that T reaches the state qI(T[λ]). This proves the inductive step. 6.8. Normalizing Projection and Unweighting Projection We say that a mapping π : Σ → Σ′ between slice alphabets is a slice projection if π is arity preserving, gluing preserving, and empty-frontier preserving. By arity preserving we mean that a(S) = a(π(S)). By gluing preserving we mean that if S can be glued to S′ at frontier j then π(S) can be glued to π(S′) at frontier j. And by empty-frontier preserving we mean that if a frontier Fi is empty in S then the corresponding frontier in π(S) is also empty. Two classes of slice projections will be of particular importance to us. The normalizing projections, and the unweighting projections which are defined below. 3 6 η 3,6 1 2 2 4 5 1 2 3 1 1 ζ 2 2 1 1 2 2 Figure 6: The normalizing projection ηc,q normalizes each frontier of a slice in such a way that the order of the vertices in each frontier is preserved. In this example c = 3 and q = 6. The unnormalized slice S1 has frontiers F0 = {[0, 3], [0, 6]} and F1 = {[1, 2], [1, 4], [1, 5]}. After the normalization the frontiers become F ′ 0 = {[0, 1], [0, 2]} and F ′ 1 = {[1, 1], [1, 2], [1, 3]}. The unweighting projection ζ simply erases the weights associated to each edge of the slice. In this example, the weights α1, α2, α3 attached to the edges of the slice S2 are erased by ζ. The normalizing projection ηc,q : Σ(c, q, Γ1, Γ2) → Σ(c, Γ1, Γ2) acts on each slice S in Σ(c, q, Γ1, Γ2) by renumbering the frontier vertices of S in such a way that the new resulting slice ηc,q(S) is normalized and in such a way that the ordering of the vertices inside each frontier is preserved. More precisely, for each j ∈ {0, ..., r}, let Fj = {[j, ij,1], [j, ij,2], ..., [j, ij,cj ]} where cj ≤ c and ij,1 < ij,2 < ... < ij,cj ≤ q. Then the slice ηc,q(S) is obtained from S by replacing each frontier vertex [j, ij,k] with the vertex [j, k]. After the application of the normalizing projection ηc,q the j-th frontier of S becomes F ′ j = {[j, 1], ..., [j, cj ]} (Figure 6). We note that if T is a unit decomposition over Σ(c, q, Γ1, Γ2), then ηc,q(T) is a normalized unit decomposition over Σ(c, Γ1, Γ2) representing the same digraph. In other words, if T′ = ηc,q(T) then T′= ◦ ◦ T. If Γ2 is a set of edge labels and Ω is a set of edge weights, then the set Γ2 ×Ω can be regarded as a new set of edge labels. The unweighting projection ζΩ : Σ(c, q, Γ1, Γ2 ×Ω) → Σ(c, q, Γ1, Γ2) is a function that takes a slice S ∈ Σ(c, q, Γ1, Γ2 × Ω) and erases the weight coordinate from the label of each edge. More precisely, if S = (V, E, ρ, ξ × µ, [C, F0 , ..., Fj ]) where ξ × µ : E → Γ2 × Ω, then ζΩ(S) = (V, E, ρ, ξ, [C, F0, ..., Fj ]) where ξ : E → Γ2 is the projection of ξ × µ to its first coordinate. Unweighting projections and normalizing projections will be used in Section 9 to construct the slice tree-automaton A(ϕ, k, z, l, a) mentioned in the introduction (Section 1.3). 7. z-Saturated Tree Slice Languages In this section we will define the notion of tree-zig-zag number of a unit decomposition and the notion of z-saturated tree slice language. We will show that given a z-saturated tree slice language L generated by a slice tree-automaton A and a unit decomposition T of tree-zig-zag number z, we can count in polynomial time the number of subgraphs of T that are isomorphic to some digraph in LG. This seemingly abstract result is a crucial step towards the proof of our main theorem (Theorem 1). The next crucial step, which will be carried in Section 8, consists in showing that for any MSO2 logic sentence ϕ and any k, z ∈ N, one can define a z-saturated slice tree-automaton generating precisely the set of digraphs that at the same time are the union of k directed paths and satisfy ϕ. ◦ 24 7.1. z-Saturation ◦ Let T be a unit decomposition over Σ(c, q, Γ1, Γ2) and let T= (V, E, ρ, ξ) be the digraph represented by T. We say that T is compatible with an olive-tree decomposition T = (N, F, m) of a digraph G = (V ′, E′, ρ′, ξ′) if both T and T have the same tree-structure (i.e. N = Pos(T)), and the map β : V ′ → V given by β(u) = vm(u) is an isomorphism from G to T. For instance, in Figure 4, the unit decomposition T is compatible with the olive-tree decomposition T . Note that for each unit decomposition T there is a unique olive-tree decomposition T = (N, F, m) of T such that T is compatible with T . In this olive-tree decomposition, N = Pos(T) the digraph and m is defined by setting m(vp) = p for each position p ∈ Pos(T). ◦ ◦ We say that a unit decomposition T has tree-zig-zag number tzn(T) = z if T is compati- ble with an olive-tree decomposition of tree-zig-zag number z. Intuitively, T has tree-zig-zag number z if each simple path of T crosses each frontier of each slice in T at most z times. For instance, in Figure 4, the unit decomposition T has tree-zig-zag number 2. Note that the olive-tree decomposition T in Figure 4 that is compatible with T has also tree-zig-zag number 2. We say that a slice language L has tree-zig-zag number z if each unit decomposition in L has tree-zig-zag number z. Let H be a digraph, Σ be a slice alphabet and ◦ ud(Σ, H, z) = {T ∈ L(Σ) ◦ T≃ H, tzn(T) ≤ z}. We say that a tree slice language L over Σ is z-saturated with respect to Σ, if for every digraph H, the fact that [H] ∈ LG implies that ud(Σ, H, z) ⊆ L. In other words L is z-saturated if whenever a canonical form [H] belongs to the graph language LG, all unit decompositions of tree-zig-zag number z of H belong to the slice language L. If the alphabet Σ is clear from the context we may say simply that L is z-saturated, instead of saying that L is z-saturated with respect to Σ. A slice tree-automaton A is z-saturated if L(A) is z-saturated. Proposition 7 below justifies our interest in the concept of z-saturation. Proposition 7. Let L and L′ be tree slice languages over Σ such that L has tree-zig-zag number z and such that L′ is z-saturated with respect to Σ. Then (L ∩ L′)G = LG ∩ L′ G. G holds for any two slice languages L and L′ irrespectively Proof. The inclusion (L∩L′)G ⊆ LG∩L′ of whether they are saturated or not. To see this, let H be a digraph and let [H] ∈ (L ∩ L′)G. Then H has a unit decomposition T in L ∩ L′. Since T ∈ L, [H] ∈ LG and, since T ∈ L′, [H] ∈ L′ G. Now we prove that if L has tree-zig-zag number z and L′ is z-saturated, the converse inclusion also holds. Let H be a digraph and let [H] ∈ LG ∩ L′ G. Since L has tree-zig-zag number z, H has a unit decomposition T of tree-zig-zag number z in L. Since L′ is z-saturated with respect to Σ, each unit-decomposition of H over Σ of tree-zig-zag number z is in L′, and in particular T ∈ L′. Therefore T ∈ L ∩ L′ and [H] ∈ (L ∩ L′)G. G. Thus (L ∩ L′)G ⊆ LG ∩ L′ In other words, whenever L has tree-zig-zag number z and L′ is z-saturated, the intersection LG ∩ L′ G of their graph languages is precisely the graph language of the intersection L ∩ L′. It is worth noting that Proposition 7 would not be true if none of the slice languages L and L′ were saturated. For instance if L = {T} and L′ = {T′} for two distinct unit decomposition T and T′ of a digraph H then LG = L′ G = {[H]} but L ∩ L′ = ∅! Proposition 8 below says that any olive-tree decomposition T of a digraph G can be efficiently converted into a unit decomposition T of G that is compatible with T . Note that there may be several unit decompositions of G compatible with T . In the proof of Proposition 8 we provide an algorithm for computing one of these unit decompositions. Proposition 8. Let T be an olive-tree decomposition of a digraph G = (V, E, ρ, ξ) of width q = w(T ). Then one can construct in time O(T · E) a normalized unit decomposition T over Σ(q, Γ1, Γ2) compatible with T . 25 ◦ ◦ Proof. Let T = (N, F, m) be an olive-tree decomposition of G = (V, E, ρ, ξ). First we tag each edge e ∈ G with a number τ (e) ∈ {1, ..., E} in such a way that no two edges are tagged with the same number. We will construct a non-normalized unit decomposition T′ T′≃ G. A normalized unit decomposition T over Σ(q, Γ1, Γ2) over Σ(q, E, Γ1, Γ2) such that T≃ G can be obtained from T′ by an application of the normalizing projection such that ηq,E : Σ(q, E, Γ1, Γ2) → Σ(q, Γ1, Γ2). To construct T′ it is enough to specify the slice T′[p] for each position p ∈ Pos(T′) = N . Instead of specifying each such slice T′[p] separately we will proceed in a more intuitive way. Namely, we will first define which unit slices of T′ have a center vertex, and subsequently, for each edge e in G and each p ∈ Pos(T′) we will specify which sliced part of e (if any) belongs to T′[p]. The first part is easy. A slice T′[p] has a center vertex if and only if some vertex of G is mapped by m to the position p ∈ N in the olive-tree decomposition T . For simplicity, let vp be the vertex of G for which m(vp) = p. We label the center vertex of T′[p] with the same label as the vertex vp in G. For each edge e ∈ E with source es = vp and target et = vp′ we create a sliced edge sequence K ≡ (p1, a1, e1, b1)(p2, a2, e2, b2)...(pn, an, en, bn) where p1 = p, p2 = p′, p1p2...pn is the unique minimum path from p to p′ in the tree (N, F ). For each i ∈ {1, ..., n}, the vertices ai and bi and the edge ei belong to the slice T′[pi]. The vertex a1 is the center vertex of T′[p1] and bn is the center vertex of T′[pn]. For each i ∈ {1, ..., n − 1}, if pi+1 = pij then bi is the vertex [j, τ (e)] at the j-th in-frontier of T′[pi] and ai+1 is the vertex [0, τ (e)] at the out-frontier of T′[pi]. On the other hand, if pi = pi+1j then bi = [0, τ (e)] and ai+1 = [j, τ (e)]. Finally we label each edge ei of the sliced edge sequence K with the same label as the edge e in G. One can readily check that the sequence K defined in this way is T′= G. As a final step, we obtain the unit indeed a sliced edge sequence, and therefore that decomposition T by an application of the normalizing projection ηq,E to T′. In other words, T = ηq,E(T′). ◦ 7.2. Counting Subgraphs via z-Saturated Slice Languages ◦ In this Subsection we will introduce the main technical tool of this paper. We will show that given a z-saturated tree-automaton A representing digraphs that are the union of k paths, and a unit decomposition T of tree-zig-zag number z, one can count in polynomial time the number T that are isomorphic to some digraph in LG(A). The proof will proceed in two of subgraphs of steps. First, we will show that from a normalized unit decomposition T one can construct a (non- normalized) deterministic slice tree-automaton A(T, k · z) whose slice language L(A(T, k · z)) consists of all sub-decompositions of T of width at most k · z. Each such sub-decomposition of T unequivocally identifies a subgraph of T that is the union of k directed paths has a representative unit decomposition in L(A(T, k · z)). Note that L(A(T, k · z)) still may contain unit decompositions of digraphs that are not the union of k directed paths. However these undesired unit decompositions are irrelevant, since they will be eliminated in the next step. In our second step, we will show that the intersection A ∩ A(T, k · z) is a deterministic slice tree-automaton whose graph language consists precisely of the subgraphs T that are isomorphic to some digraph in LG(A). Note that A ∩ A(T, k · z) accepts a finite of number of terms, and that the depth of each such accepted term is equal to the depth of T. At T that are isomorphic to digraphs in LG(A) this point, the problem of counting subgraphs of boils down to counting the number of terms accepted by A ∩ A(T, k · z) in depth depth(T). We can count these terms in polynomial time using Lemma 2. T. As a partial converse, each subgraph of ◦ ◦ ◦ ◦ Lemma 5 below says that given any unit decomposition T of width q, and any c ≤ q, one can construct a slice tree-automaton whose slice language consists of all sub-decompositions of T of width at most c. Lemma 5. Let T be a normalized unit decomposition in L(Σ(q, Γ1, Γ2)) and let c ≤ q. Then one may construct in time T · qO(c) a slice tree-automaton A(T, c) over Σ(c, q, Γ1, Γ2) with T · qO(c) states satisfying the following properties. 26 1. A(T, c) is deterministic. 2. L(A(T, c)) = {T′ ∈ L(Σ(c, q, Γ1, Γ2)) T′ is a sub-decomposition of T} Proof. Let T be a unit decomposition in L(Σ(c, Γ1, Γ2)). We will construct a slice tree- automaton A = A(T, c) = (Q, Σ, QF , ∆) over Σ = Σ(c, q, Γ1, Γ2) whose slice language consists of all sub-decompositions of T of width at most c. The set of states Q has one state qp,I for each position p ∈ Pos(T) and each identity slice I in Σ1(c, q, Γ1, Γ2). We note that since the empty slice of arity one, ε1, is also an identity slice, the state qp,ε1 belongs to Q for each p ∈ Pos(T). The set of final states is the singleton QF = {qλ,ε1 }. Now we will construct the transition relation ∆ = ∆0 ∪ ∆1 ∪ ∆2. First we recall that for each position p ∈ Pos(T), if T[p] is a slice of arity r then any sub-slice S of T[p] has also arity r. Recall that if S is a slice, then I(S) denotes the unique identity slice such that S can be glued to I(S). For each r ∈ {0, 1, 2}, and each position p ∈ Pos(T) such that T[p] has arity r, the relation ∆r has one transition (qp1,I1 , ..., qpr,Ir , S, qp,I(S)) for each sub-slice S of T[p] satisfying the following conditions: (i) S has width at most c, i.e., S ∈ Σ(c, q, Γ1, Γ2), (ii) for each j ∈ {1, ..., r}, Ij is the unique identity slice that can be glued to S at frontier j. To see that A is deterministic, note that for each slice S there is a unique identity slice I such that S can be glued to I. Therefore, for each tuple (qp1,I1 , qp2,I2 , ..., qpj,Ir , S) there is a unique state qp,I such that (qp1,I1 , qp2,I2 , ..., qpr,Ir , S, qp,I) belongs to ∆r. This also implies that each term T′ accepted by A is a unit pre-decomposition, i.e., each two consecutive positions of T′ can be glued. Additionally, the fact that qλ,ε1 is the unique accepting state of A implies that the slice at the root of T′ has empty-frontier, since this slice must be glueable to ε1. Therefore each such term T′ is a unit decomposition. It remains to show that a unit decomposition T′ is accepted by A if and only if T′ is a sub-decomposition of T of width at most c. 1. (if direction) Let T′ be a sub-decomposition of T of width at most c. We claim that for each position p ∈ Pos(T′) = Pos(T) the subterm T′p of T′ rooted at p reaches the state qp,I(T′[p]). This claim implies in particular that the whole term T′ = T′λ reaches the unique accepting state qλ,ε1. The proof is by induction on the height of the position p. In the base case, p is a leaf of the set Pos(T). In this case, the slice T[p] has arity zero, and thus the sub-slice T′[p] has also arity zero. By the construction of the transition relation ∆0 given above, the transition (T′[p], qp,I(T′[p])) belongs to ∆0 and thus T′p reaches the state qp,I(T′[p]). Now assume by induction that the claim is valid for every position p′ of height h. Let p be a position in Pos(T) of height h + 1 with children are p1, ..., pr for some r ∈ {1, 2}. By the induction hypothesis, for each i ∈ {1, ..., r} the term T′pi reaches the state qpi,I(T′[pi]). By the definition of the transition relation ∆r, we have that the transition (qp1,I(T′[p1]), ..., qpr,I(T′[pr]), T′[p], qp,I(T′[p])) belongs to ∆r, and thus T′p reaches the state qp,I(T′[p]). This proves our claim. 2. (only if direction) For the converse, let T′ be a unit decomposition accepted by A. We will prove that T′ is a sub-decomposition of T by showing that Pos(T) = Pos(T′) and that for each position p ∈ Pos(T′), T′[p] is a sub-slice of T[p]. We claim that for each p ∈ Pos(T′), the subterm T′p of T′ rooted at p reaches the state qp,I(T′[p]). By the construction of the transition relation ∆ this claim implies both that T′[p] is a sub-slice of T[p] for each p ∈ Pos(T′) and that Pos(T′) = Pos(T), as desired. The proof of this claim is by induction on the depth of p. In the base case, p = λ. In this case, T′λ = T′ reaches the unique accepting state qλ,ε1 = qλ,I(T′[λ]). Now assume that for every position p of depth at most d, the term T′p reaches the state qp,I(T′[p]). We will show that the claim 27 holds for every position p of depth d + 1. Let p ∈ Pos(T′) be a position of depth d. By the induction hypothesis, T′p reaches the state qp,I(T′[p]). Let T′[p] have arity r for some r ∈ {1, 2}. Since T′p reaches qp,I(T′[p]), there exist states q1, ..., qr such that the transition (q1, ..., qr, T′[p], qp,I(T′[p])) belongs to ∆ and T′pj reaches qj for each j ∈ {1, ..., r}. By the definition of ∆, for each j ∈ {1, ..., r}, qj = qpj,Ij where Ij is the unique identity slice that can be glued to T′[p] at frontier j. Since T′ is a unit decomposition, T′[pj] can be glued to T′[p] at frontier j. Therefore Ij = I(T′[pj]). Thus qj = qpj,I(T′[pj]) and T′pj reaches qpj,I(T′[pj]). This proves our inductive step. Proposition 9 below establishes a relation between the minimum number of paths necessary to cover all edges and vertices of a digraph H, and the width of a unit decomposition of H of tree-zig-zag number z. Intuitively, if T is a unit decomposition of tree-zig-zag number z of a digraph H, then each directed simple path p in H crosses each frontier of a slice in T at most z times. Therefore, if H is the union of k directed simple paths p1, ..., pk, then all such paths together cross each frontier of each slice of T at most k · z times. Proposition 9. Let H be a digraph that is the union of k-paths and Σ be a slice alphabet. Then any unit decomposition T ∈ L(Σ) of H of tree-zig-zag number z has width at most k · z. Proof. Let H = (V, E) be a digraph that is the union of k directed paths p1, ..., pk where for each i ∈ {1, ..., k}, pi = (Vpi , Epi). Let T ∈ L(Σ) be a unit decomposition of tree-zig-zag number z of a digraph H. Then T is compatible with an olive-tree decomposition T = (N, F, m) of tree-zig-zag number z. Additionally, the width of T is equal to the width of T . Since T has tree-zig-zag number z, for each position p ∈ N and each i ∈ {1, ..., k} we have that E(V (p, T ), V \V (p, T )) ∩ Epi ≤ z. This implies that k E(V (p, T ), V \V (p, T )) ∩ Epi ≤ k · z. [i=1 But since E = ∪k most k · z, implying in this way that T has also width at most k · z. i=1Epi, we have that E(V (p, T ), V \V (p, T )) ≤ k · z. Thus T has width at Next we state the main lemma of this section. Intuitively Lemma 6 below says that if T is a unit decomposition of tree-zig-zag number z of a digraph G, and if A is a z-saturated tree-automaton representing only digraphs that are the union of k directed paths, then the slice language L(A(T, k · z) ∩ A) has precisely one unit decomposition for each subgraph of T that is isomorphic to a digraph in LG(A). In this sense, the problem of counting the number of T that are isomorphic to a digraph in LG(A) boils down to counting the number subgraphs of of unit-decompositions in L(A(T, k · z) ∩ A). This counting step will be detailed in Theorem 4. ◦ ◦ Lemma 6. Let T be a unit decomposition of tree-zig-zag number z over Σ(q, Γ1, Γ2). Let A be a deterministic z-saturated slice automaton over Σ(k · z, q, Γ1, Γ2) such that each digraph in LG(A) is the union of k directed paths. 1. The tree-automaton A(T, k·z)∩A is deterministic and all its accepted unit decompositions have depth at most depth(T). 2. H is a subgraph of T such that [H] ∈ LG(A) if and only if there exists a unit decomposition ◦ T′ ∈ L(A(T, k · z) ∩ A) such that T′= H. ◦ 28 Proof. Item 1 is straightforward. The automaton A(T, k · z) ∩ A is deterministic because both A(T, k · z) and A are deterministic (Lemma 3.iii). Since by construction the construction of A(T, k · z), all unit decompositions accepted by A(T, k · z) have depth depth(T), we have that all unit decompositions accepted by A(T, k · z) ∩ A also have depth depth(T). Now we proceed to prove item 2. (a) (if direction) Let T′ be a unit decomposition in L(A(T, k · z) ∩ A) such that T′= H. Since T′ ∈ L(A(T, k·z)), by Lemma 5, T′ is a sub-decomposition of T. Therefore H is a subgraph of T. Additionally, since T′ ∈ L(A), [H] ∈ LG(A). ◦ ◦ ◦ ◦ (b) (only if direction) Let H be a subgraph of T, there is a sub-decomposition T′ of T such that T such that [H] ∈ LG(A). Since H is a subgraph T′= H. We will show that T′ belongs of to L(A(T, k · z) ∩ A). Since T has tree-zig-zag number z, T′ has tree-zig-zag number at most z. Now, since H ∈ LG(A), we have that H is the union of k directed paths. By Proposition 9, each unit decomposition of H of tree-zig-zag number at most z has width at most k · z. Thus T′ has width at most k · z. Finally, since A is z-saturated with respect to Σ(k · z, q, Γ1, Γ2) we have that T′ belongs to L(A). Thus T′ ∈ L(A(T, k · z) ∩ A). ◦ The next Theorem is the main application for Lemma 6. Intuitively, given a unit decom- position T of tree-zig-zag number z, and a z-saturated tree-automaton A representing only digraphs that are the union of k directed paths, where z and k are constants, one can count in T that are isomorphic to some digraph in L(A). polynomial time the number of subgraphs of The idea is that Lemma 6 allow us to reduce this counting problem to the problem of counting the number of accepted unit decompositions in the tree-automaton A(T, k · z) ∩ A. ◦ Theorem 4 (Slice Theoretic Metatheorem). Let T be a unit decomposition over Σ(q, Γ1, Γ2) and let A be a deterministic z-saturated slice tree-automaton over Σ(k · z, q, Γ1, Γ2) satisfying the property that each digraph in LG(A) is the union of k directed paths. Then one can count in time TO(1) · qO(k·z) · AO(1) the number of subgraphs of T that are isomorphic to a digraph in LG(A). ◦ Proof. First, we construct in time T · qO(k·z) the tree-automaton A(T, k · z) of Lemma 5 whose slice language consists of the set of all sub-decompositions of T of width at most k · z. Subsequently, using Lemma 3.iii, we construct the tree-automaton A(T, k · z) ∩ A in time T · qO(k·z) · A. By Lemma 6 a subgraph of T is isomorphic to some digraph in LG(A) if and only if there exists a sub-decomposition T′ of T in L(A(T, k · z) ∩ A) for which T′= H. T that are isomorphic to some digraph in LG(A) amounts Therefore, counting the subgraphs of to counting the number of unit decompositions of depth depth(T) in L(A(T, k · z)∩ A). In other words, this problem is equivalent to the problem of counting the number of terms accepted by A ∩ A(T, k · z) in depth depth(T). Since depth(T) ≤ T, by Lemma 2, this counting process can be done in time TO(1) · qO(k·z) · AO(1). ◦ ◦ ◦ Next, in Section 8 we will show that for each MSO2 sentence ϕ and each k, z ∈ N, one can construct a z-saturated tree-automaton A(ϕ, k, z) representing the set of all digraphs that at the same time are the union of k directed paths and satisfy ϕ. Subsequently, in Section 9 we will show how to restrict A(ϕ, k, z) into a z-saturated slice tree-automaton A(ϕ, k, z, l, α) representing only the digraphs in LG(A(ϕ, k, z)) which have a prescribed number l of vertices and a prescribed weight a ∈ Ω. The proof of Theorem 1 will follow by plugging the tree-automaton A(ϕ, k, z, l, α) into Theorem 4. 29 8. MSO2 Logic and Tree Slice Languages Defining interesting families of digraphs via z-saturated tree-automata is a difficult task. The difficulty relies on the fact that to construct a z-saturated tree-automaton we have to make sure that for each digraph H in the graph language LG(A), all unit decompositions of H with tree-zig-zag number at most z are in the slice language L(A). In this section we will introduce a suitable way of circumventing this difficulty by using the monadic second order logic of graphs with edge set quantifications, or MSO2 logic for short. This logic, which extends first order logic by incorporating quantification over sets of vertices and over sets of edges, is able to express a large variety of natural graph properties [16]. We will show that for any MSO2 sentence ϕ and any k, z ∈ N we can automatically construct a z-saturated slice tree-automaton A(ϕ, k, z) whose graph language consists of all digraphs that at the same time satisfy ϕ and are the union of k directed paths (Theorem 5). Let Γ1 be a set of vertex labels and Γ2 be a set of edge labels. A (Γ1, Γ2)-labeled digraph is a relational structure G = (V, E, s, t, ρ, ξ) comprising a set of vertices V , a set of edges E, source and target relations s, t ⊆ E × V , a vertex-labeling relation ρ ⊆ V × Γ1 and an edge-labeling relation ξ ⊆ E × Γ2. The language of MSO2 logic for (Γ1, Γ2)-labeled digraphs includes the connectives ∨, ∧, ¬, variables for vertices, edges, sets of vertices and sets of edges, the quantifier ∃ that can be applied to these variables, and the following predicates: 1. x ∈ X where x is a vertex variable and X a vertex set variable, 2. y ∈ Y where y is an edge variable and Y an edge set variable, 3. Equality, =, of variables representing vertices, edges, sets of vertices and sets of edges. 4. s(y, x) where y is an edge variable, x a vertex variable, and the interpretation is that x is the source of y. 5. t(y, x) where y is an edge variable, x a vertex variable, and the interpretation is that x is the target y. 6. For each a ∈ Γ1, a predicate ρ(x, a) where x is a vertex variable, and the interpretation is that x is a vertex labeled with a. 7. For each b ∈ Γ2, a predicate ξ(x, b) where x is an edge variable, and the interpretation is that x is an edge labeled with b. Let X be a set of free first order variables and second order variables. An interpretation of X in G is a function M : X → (V ∪ E) ∪ (2V ∪ 2E) that associates with each vertex variable x ∈ X , a vertex in V , with each edge variable y ∈ X , an edge in E, with each vertex set variable X ∈ X a set of vertices and with each edge set variable Y ∈ X , a set of edges. The semantics of a formula ϕ with free variables X being true under interpretation M is the standard one. An MSO2 sentence is an MSO2 formula without free variables. If G = (V, E, s, t, ρ, ξ) is a (Γ1, Γ2)-labeled digraph and ϕ is an MSO2 sentence then we write G = ϕ to indicate that G satisfies ϕ. Let Σ(c, Γ1, Γ2) = Σ0(c, Γ1, Γ2) ∪ Σ1(c, Γ1, Γ2) ∪ Σ2(c, Γ1, Γ2) be the ranked slice alphabet defined in Section 6.2 (with r = 2). Lemma 7 below, which will be proved in Section 8.1, establishes a connection between MSO2 logic and slice tree-automata. Lemma 7. For every MSO2 sentence ϕ over (Γ1, Γ2)-labeled digraphs and every c ∈ N, one can construct a normalized deterministic slice tree-automaton A(ϕ, c) over Σ(c, Γ1, Γ2) generating the following tree slice language: L(A(ϕ, c)) = {T ∈ L(Σ(c, Γ1, Γ2)) ◦ T= ϕ}. (15) 30 In other words, Lemma 7 says that given an MSO2 sentence ϕ and a number c ∈ N we can construct a slice tree-automaton whose tree slice language consists of all unit decompositions of width at most c representing a digraph that satisfies ϕ. Another way of interpreting Lemma 7 is as a ”sliced” version of Courcelle’s celebrated model checking theorem [15]. Recall that Courcelle’s theorem states that graphs of constant undirected treewidth can be model checked in linear time against MSO2 sentences. In analogy with Courcelle’s theorem, Lemma 7 says that digraphs admitting unit decompositions of constant width can be model checked in linear time against MSO2 sentences. In order to verify whether a digraph G admitting a unit decomposition of width at most c satisfies an MSO2 sentence ϕ, all one needs to do is to find a normalized unit decomposition T of G of width at most c, and then check in linear time if T is accepted by A(ϕ, c). In this work however we will not be interested in model checking properties on digraphs admitting unit decompositions of constant width. Instead we will use Lemma 7 to construct z-saturated slice tree-automata representing families of digraphs that are the union of k directed paths and satisfy a given prescribed MSO2 property. These automata, which will be constructed in the proof of Theorem 5 below, can be coupled to Theorem 4 to provide a way of counting subgraphs satisfying interesting properties on digraphs of constant tree-zig-zag number, and hence, on digraphs of constant directed treewidth. At this point our approach differs substan- tially from Courcelle’s theorem [15] as well as from the approaches in [3, 17] in the sense that, as mentioned in the introduction, digraphs of constant directed treewidth may have simultaneously unbounded undirected treewidth and unbounded clique-width. Theorem 5. For every MSO2 sentence ϕ and every k, z ∈ N, one can effectively construct a normalized deterministic z-saturated slice tree-automaton A(ϕ, k, z) over the slice alphabet Σ(k · z, Γ1, Γ2) representing the following graph language. LG(A(ϕ, k, z)) = {[H] H = ϕ, H is the union of k directed paths}. (16) ◦ Proof. Let γ(k) be the MSO2 sentence that is true in a digraph H if and only if H is the union of k directed paths. Using Lemma 7 we construct a normalized deterministic tree-automaton A(k · z, ϕ ∧ γ(k)) generating the set of all unit decompositions T over Σ(k · z, Γ1, Γ2) for which T′ satisfies ϕ ∧ γ(k). In other words if [H] ∈ LG(A(k · z, ϕ ∧ γ(k))) then H satisfies the digraph ϕ and is the union of k directed paths. For the converse, suppose that H is a digraph that is the union of k directed paths and satisfies ϕ. Then by Proposition 9, each unit decomposition T of H of tree-zig-zag number at most z has width at most k · z. Therefore, T ∈ L(A(ϕ, k, z)). This implies not only that [H] ∈ LG(A(ϕ, k, z)) but also that L(A(ϕ, k, z)) is z-saturated. 8.1. Proof of Lemma 7 To prove Lemma 7 we need to translate each MSO2 sentence ϕ expressing a property of (Γ1, Γ2)-labeled digraphs into an MSO2 sentence ψ expressing a property of unit decompositions over Σ(c, Γ1, Γ2) in such a way that for each unit decomposition T over Σ(c, Γ1, Γ2), T satisfies ψ if and only if the digraph T represented by T satisfy ϕ. With this goal in mind we need to define a new MSO2 vocabulary which is suitable for expressing properties of unit decompositions. The language of MSO2 logic for unit decompositions over Σ(c, Γ1, Γ2) has the connectives ∨, ∧, ¬, vertex variables, edge variables, vertex set variables and edge set variables, the quantifier ∃ that can be applied to these variables, and the following predicates: ◦ 1. x ∈ X where x is a vertex variable and X a vertex set variable, 2. y ∈ Y where y is an edge variable and Y an edge set variable, 3. Equality, =, of variables representing vertices, edges, sets of vertices and sets of edges. 31 4. s(y, x) where y is an edge variable, x a vertex variable, and the interpretation is that for some position p ∈ Pos(T), x is a vertex of T[p], y is an edge of T[p] and x is the source of y. 5. t(y, x) where y is an edge variable, x a vertex variable, and the interpretation is that for some position p ∈ Pos(T), x is a vertex of T[p], y is an edge of T[p] and x is the target of y. 6. For each a ∈ Γ1, a predicate ρ(x, a) where x is a vertex variable, and the interpretation is that for some p ∈ Pos(T), x is a vertex of T[p] labeled with a. 7. For each b ∈ Γ2, a predicate ξ(y, b) where y is an edge variable, and the interpretation is that for some p ∈ Pos(T), y is an edge of T[p] labeled with b. 8. For each j ∈ {0, 1, 2} and each i ∈ {1, ..., c}, the predicate Fj,i(x) where x is a vertex variable and the interpretation is that for some position p ∈ Pos(T), x is the frontier vertex [j, i] of the slice T[p]. 9. The predicate C(x) where x is a vertex variable and the interpretation is that for some position p ∈ Pos(T), x is the unique center vertex of the slice T[p]. 10. The predicate Neighbors(x1, x2) where x1, x2 are vertex variables and the interpretation is that for some position p ∈ Pos(T) and some j ∈ {1, 2}, x1 is a vertex of T[p] and x2 a vertex of T[pj]. Recall from Section 6.5 that if T is a unit decomposition then the digraph ◦ T has an edge eK with source es K = vp and target et K = vp′ if and only if there exists a sliced edge sequence K ≡ (p1, a1, e1, b1)(p2, a2, e2, b2)...(pn, an, en, bn) from p1 = p to pn = p′. We note that each edge of each slice occurring in T belongs to a unique sliced edge sequence. In particular, each sliced edge sequence K is unequivocally determined by its first edge e1. Using conditions 1-5 of Definition 5, it is straightforward to write an MSO2 formula θ(u, y, v) in the vocabulary of unit decompositions with free vertex variables u, v and free edge variable y, which is true in a unit decomposition T if and only if there exist positions p and p′ in T such that u is the center vertex of T[p], y is an edge in T[p] with source u, v is the center vertex of T[p′], and there exists a sliced edge sequence from p to p′ whose first edge is y. Using the formula θ(u, y, v) we can map formulas in the vocabulary of (Γ1, Γ2)-labeled digraphs to formulas in the vocabulary of unit decompositions over Σ(c, Γ1, Γ2), as done below in Proposition 10. Proposition 10. Let ϕ be an MSO2 formula in the vocabulary of (Γ1, Γ2)-labelled graphs. There is a formula ψ in the vocabulary of unit decompositions over Σ(c, Γ1, Γ2) such that for each unit decomposition T over Σ(c, Γ1, Γ2), T = ψ if and only if T= ϕ. ◦ Proof. As mentioned above, using the predicates C(x), Fj,i(x), Neighbors(x1, x2), s(y, x) and t(y, x) we can define a formula θ(u, y, v) that is true in a unit decomposition T if and only if there is a sliced edge sequence with first vertex u, first edge y and last vertex v. The translation from ϕ to ψ proceeds as follows. We replace each occurrence of the predicate ρ(x, a) in ϕ with the predicate ρ(x, a), each occurrence of ξ(x, a) with ξ(x, a), each occurrence of s(y, x) with (∃v)θ(x, y, v) where v is a new variable not occurring in ϕ, and each occurrence of t(y, x′) with (∃u)θ(u, y, x′), where u is a new variable not occurring in ϕ. Now it is straightforward to prove by induction of the structure of ϕ that for each given unit decomposition T ∈ Σ(c, Γ1, Γ2), T = ψ if and only if T= ϕ. ◦ 32 In the last step of the proof of Lemma 7 we will show that for each MSO2 sentence ψ in the vocabulary of unit decompositions over Σ(c, Γ1, Γ2), it is possible to construct a slice tree-automaton A = A(ψ, Σ(c, Γ1, Γ2)) such that T ∈ L(A) if and only if T satisfies ψ. Let X be a set of variables, and S ∈ Σ(c, Γ1, Γ2) be a unit slice with r vertices and r′ edges (including the frontier vertices). We represent an interpretation of X in S as a X × (r + r′) boolean matrix I whose rows are indexed by the variables in X and the columns are indexed by the vertices and edges of S. Intuitively, if x is a vertex (edge) variable and u is a vertex (edge) in S then we set Ix,u = 1 if and only if u is assigned to x. On the other hand, if X is a vertex (edge) set variable then IX,u = 1 if and only if u belongs to the set of vertices (edges) assigned to X. If T is a unit decomposition in L(Σ(c, Γ1, Γ2)) then an interpretation of X in T is a function I that associates with each position p ∈ Pos(T), an interpretation I(p) of X in the slice T[p]. We define the X -interpreted extension of Σ(c, Γ1, Γ2) as the following set. Σ(c, Γ1, Γ2, X ) = [S∈Σ(c,Γ1,Γ2) SX where for each slice S ∈ Σ(c, Γ1, Γ2), SX = {(S, I) I is an interpretation of X in S}. (17) If T is a unit decomposition in L(Σ(c, Γ1, Γ2)) and I is an interpretation of X in T then we write TI to denote the term in L(Σ(c, Γ1, Γ2, X )) in which TI[p] = (T[p], I(p)) for each position p ∈ Pos(T). We say that TI is an interpreted term. Now we are in a position to prove Lemma 7. For each MSO2 formula ψ in the vocabulary of unit decompositions over Σ(c, Γ1, Γ2) with free variables X we will construct a tree-automaton A(ψ, Σ(c, Γ1, Γ2, X )) over Σ(c, Γ1, Γ2, X ) whose slice language L(A(ψ, Σ(c, Γ1, Γ2, X ))) consists of all interpreted terms TI ∈ L(Σ(c, Γ1, Γ2, X )) for which T = ψ(X ) with interpretation I. The tree-automaton A(ψ, Σ(c, Γ1, Γ2, X )) is constructed inductively with respect to the structure of the formula ψ. Base Case. In the base case the formula ψ is one of the predicates x ∈ X, x1 = x2, C(x), Fj,i(x) for j ∈ {0, 1, 2}, Neighbors(x1, x2), s(y, x), t(y, x), ρ(x, a) or ξ(y, b). Below, we describe the behavior of the tree-automaton A = A(ψ, Σ(c, Γ1, Γ2, X )) when ψ is each of these predicates. If x is a vertex (edge) variable in ψ, then we say that an interpreted term TI passes the singleton test with respect to x if there exists a unique position p ∈ Pos(T) and a unique vertex (edge) u in T[p] such that I(p)x,u = 1. We note that this condition can be easily checked by a tree- automaton over Σ(c, Γ1, Γ2, X ). Intuitively, TI passes the singleton test with respect to x if precisely one vertex (edge) of some slice of T is assigned to x. 1. If ψ ≡ (x1 = x2) where x1 and x2 are vertex (edge) variables, then A accepts TI if and only if TI passes the singleton test with respect to both x1 and x2, and for each position p ∈ Pos(T), and each vertex (edge) u ∈ T[p], I(p)x1,u = I(p)x2,u. 2. If ψ ≡ (X1 = X2) where X1 and X2 are vertex (edge) set variables, then A accepts TI if and only if I(p)x1,u = I(p)x2,u for each position p ∈ Pos(T), and each vertex (edge) u ∈ T[p]. 3. If ψ ≡ x ∈ X where x is a vertex (edge) variable and X is a vertex (edge) set variable then A accepts TI if and only if TI passes the singleton test with respect to x and for each position p ∈ Pos(T), and each vertex (edge) u ∈ T[p], I(p)x,u = 1 implies that I(p)X,u = 1. 33 4. If ψ ≡ s(y, x) (resp. ψ = t(y, x)) then A accepts TI if and only if TI passes the singleton test with respect to both y and x, and there exists a position p ∈ Pos(T), a vertex v ∈ T[p] and an edge e in T[p] such that v is the source (target) of e and I(p)x,v = 1 and I(p)y,e = 1. 5. If ψ ≡ ρ(x, a) then A accepts TI if and only if TI passes the singleton test with respect to x and there is a position p ∈ Pos(T) and a vertex v ∈ T[p] such that I(p)x,v = 1 and v is labeled with a. 6. If ψ ≡ ξ(y, b) then A accepts TI if and only if TI passes the singleton test with respect to y and there is a position p ∈ Pos(T) and an edge e ∈ T[p] such that I(p)y,e = 1 and e is labeled with b. 7. If ψ ≡ C(x) (resp. ψ ≡ Fi,j(x)) then A accepts TI if and only if TI passes the singleton test with respect to x and there exists a position p ∈ Pos(T) and a vertex v ∈ T[p] such that I(p)x,v = 1 and v is the center vertex of T[p] (resp. v is the vertex [j, i] at the j-th frontier of T[p]). 8. If ψ ≡ Neighbors(x1, x2) then A accepts TI if and only if TI passes the singleton test with respect to both x1 and x2, and there exists a position p ∈ Pos(T), a number j ∈ {1, 2}, a vertex v ∈ T[p] and a vertex v′ ∈ T[pj] such that I(p)x1,v = 1 and I(pj)x2,v′ = 1. Disjunction, conjunction and negation. The three boolean operations ∨, ∧, ¬ are handled using the fact that tree-automata are effectively closed under union, intersection and complement (Lemma 3). Below we let A(Σ(c, Γ1, Γ2, X )) be the slice tree-automaton generating the tree slice language L(Σ(c, Γ1, Γ2, X )), i.e., the set of all unit decompositions over Σ(c, Γ1, Γ2, X ). A(ψ ∨ ψ′, Σ(c, Γ1, Γ2, X )) = A(ψ, Σ(c, Γ1, Γ2, X )) ∪ A(ψ′, Σ(c, Γ1, Γ2, X )) A(ψ ∧ ψ′, Σ(c, Γ1, Γ2, X )) = A(ψ, Σ(c, Γ1, Γ2, X )) ∩ A(ψ′, Σ(c, Γ1, Γ2, X )) (18) A(¬ψ, Σ(c, Γ1, Γ2, X )) = A(ψ, Σ(c, Γ1, Γ2, X )) ∩ A(Σ(c, Γ1, Γ2, X )) Observe that in the definition of A(¬ψ, Σ(c, Γ1, Γ2, X )), the intersection with the tree- automaton A(Σ(c, Γ1, Γ2, X )) guarantees that the language generated by A(¬ψ, Σ(c, Γ1, Γ2, X )) has no term that is not an unit decomposition. Existential Quantification. To eliminate existential quantifiers we proceed as follows: For each variable X, define the slice projection Proj X : Σ(c, Γ1, Γ2, X ) → Σ(c, Γ1, Γ2, X \{X}) that sends each interpreted slice (S, I) ∈ Σ(c, Γ1, Γ2, X ) to the interpreted slice (S, I\X) in the slice alphabet Σ(c, Γ1, Γ2, X \{X}) where I\X denotes the matrix I with the row corresponding to the variable X deleted. Subsequently, we extend Proj X homomorphically to terms by setting Proj X(T)[p] = Proj X(T[p]) to each position p in Pos(T). Finally, we extend Proj X to tree slice languages by applying the projection to each term of the language. Then we set A(∃Xψ(X ), Σ(c, Γ1, Γ2, X \{X})) = Proj X(A(ψ(X ), Σ(c, Γ1, Γ2, X ))). We note that if ψ is a sentence, i.e., a formula without free variables, then by the end of this inductive process all variables occurring in ψ will have been projected. In this way, the slice language L(A(ψ, Σ(c, Γ1, Γ2))) will consist precisely of the unit decompositions T over Σ(c, Γ1, Γ2) for which T = ψ. To finalize the proof of Lemma 7, let ϕ be a sentence in the vocabulary of (Γ1, Γ2)-labeled digraphs. We apply Proposition 10 to translate ϕ into a sentence ψ in the vocabulary of unit decompositions over Σ(c, Γ1, Γ2) such that T = ψ if and only if T= ϕ. By setting ◦ 34 A(ϕ, c) = A(ψ, Σ(c, Γ1, Γ2)) we have that A(ϕ, c) accepts T if and only if T = ψ if and only if T= ϕ. This concludes the proof of Lemma 7. (cid:3) ◦ 9. Proof of Theorem 1 In this section we will prove Theorem 1, which states that given an MSO2 sentence ϕ, a digraph G of directed treewidth w and a number k ∈ N one can count in polynomial time the number of subgraphs of G that are the union of k directed paths, satisfy ϕ, and have prescribed size l and weight α. First, in Subsection 9.1 we will show how to construct slice tree-automata representing digraphs of a prescribed size. Subsequently, in Subsection 9.2 we will show how to construct slice tree-automata representing digraphs of a prescribed weight. In Subsection 9.3 we will define a suitable notion of inverse homomorphic image for slice languages. Using the results in these three subsections in conjunction with the tree-automaton A(ϕ, k, z) of Theorem 5, we will show, in Subsection 9.4, how to construct a z-saturated slice tree-automaton A(ϕ, k, z, l, α) representing all digraphs that are the union of k directed paths, satisfy ϕ, and have prescribed size l and weight α. The proof of Theorem 1, which will be detailed in Subsection 9.5, will follow by plugging A(ϕ, k, z, l, α) into Theorem 4. 9.1. Generating Digraphs of a Prescribed Size In this subsection we will show that given an arbitrary slice alphabet Σ of unit slices, and a number l, one can construct a deterministic tree-automaton generating precisely the unit decompositions in L(Σ) that give rise to digraphs with l vertices. Let Zm denote the integers with addition modulo m. Consider the following weighting function wZm : Σ → Zm: wZm(S) =(cid:26) 0 if S has empty center, 1 if S has a center vertex. Recall from Section 5.2 that given a term T ∈ Ter (Σ), the weight of T is defined as wZm(T) = Xp∈Pos(T) wZm(T[p]). (19) (20) In other words, the weight of T is simply the sum of the weights of all slices occurring in T. One can readily check that T has weight wZm(T) = l if and only there are l (mod m) slices in T with non-empty center. In particular, if T is a unit decomposition in L(Σ), then wZm(T) is the number of vertices in the digraph T represented by T, modulo m. ◦ Observation 1. Let T be a unit decomposition in L(Σ). Then wZm(T) = ◦ T (mod m). Recall from Lemma 4 that if Σ is a slice alphabet, w : Σ → Ξ is a weighting function on Σ and a ∈ Ξ, then the automaton A(Σ, w, a) generates precisely the set of terms T ∈ Ter (Σ) whose weight is w(T) = a. By setting Ξ = Zm, w = wZm and a = l, the tree-automaton A(Σ, wZm , l) generates the set of all terms over Σ which have l (mod m) slices with non-empty center. Let A(Σ) be the slice tree-automaton generating the set of all unit decomposition over Σ. Then for each l ∈ {0, ..., m − 1}, L(A(Σ, wZm , l) ∩ A(Σ)) = {T ∈ L(Σ) ◦ T = l (mod m)}. In other words A(Σ, wZm , l) ∩ A(Σ) generates all unit decompositions over Σ whose corre- sponding digraph has l (mod m) vertices. 35 9.2. Generating Digraphs of a Prescribed Weight Let G = (V, E, ρ, ξ) be a (Γ1, Γ2)-labeled digraph and µ : E → Ω be a function that weights the edges in E with elements from a finite semigroup Ω. We say that the pair (G, µ) is a weighted digraph. Alternatively, we can view (G, µ) as the digraph (V, E, ρ, ξ×µ) where ξ×µ : E → Γ2×Ω is a function that labels each edge e ∈ E, with the element [ξ × µ](e) = (ξ(e), µ(e)). In this way we consider that unit decompositions of weighted digraphs are formed with elements of the slice alphabet Σ(c, q, Γ1, Γ2 × Ω). We insist in having two label sets Γ2 and Ω because while we consider that the set Γ2 is fixed, the set Ω may vary with the input digraph. ◦ For a unit decomposition T over Σ(c, q, Γ1, Γ2 × Ω) we let µ( T) be the sum of the weights T. Let S be a slice in Σ(c, q, Γ1, Γ2 × Ω) and let E be the edge of all edges in the digraph set of S. We denote by Eout the set of all edges that have an endpoint in the out-frontier of S and the other endpoint in the center of S. We denote by Ein the set of edges whose endpoints lie in distinct in-frontiers of S. Let wΩ : Σ(c, q, Γ1, Γ2 × Ω) → Ω be a weighting function on Σ(c, q, Γ1, Γ2 × Ω) that associates with each slice S ∈ Σ(c, q, Γ1, Γ2 × Ω) the value ◦ wΩ(S) = Xe∈Eout µ(e) − Xe∈Ein µ(e). Note that edges that have only one endpoint at an in-frontier of S do not have their weights counted neither positively, nor negatively. The weight of a unit decomposition T over the slice alphabet Σ(c, q, Γ1, Γ2 × Ω) is defined as wΩ(T) = Xp∈Pos(T) wΩ(T[p]). (21) The next proposition says that the weight wΩ(T) of T is equal to the weight µ( T) of the ◦ digraph T represented by T. ◦ Proposition 11. Let T be a unit decomposition in L(Σ(c, q, Γ1, Γ2 × Ω)). Then wΩ(T) = µ( T). ◦ (22) ◦ ◦ Proof. Recall that each edge eK in the digraph T represented by T is specified by a sliced edge sequence K ≡ (p1, a1, e1, b1)(p2, a2, e2, b2)...(pn, an, en, bn), where ei is the sliced part of eK lying at slice T[pi]. Recall that by definition, for each i ∈ {1, ..., n}, the weight of ei in T[pi] is equal to the weight of eK in T. We claim that the overall contribution of the weights of the edges in K to the sum in Equation 21 is equal to the weight of eK . This claim implies Equation 22. There are three cases to be considered. If p1 is a descendant of pn, then e1 is the only sliced part of eK whose weight contributes positively to the sum in Equation 21. The weights of all other sliced parts e2, ..., en are not counted at all. This happens because, in this case, e1 is the only edge of K that has a center vertex and an out-frontier vertex as endpoints. All other edges of K have one endpoint in some in-frontier and another endpoint in the center or out-frontier, and for this reason their weights are not counted. Analogously, if pn is a descendant of p1, then en is the only sliced part of eK that has its weight contributed positively to the sum in Equation 21. The weights of all other sliced parts e1, ...en−1 are not counted at all. Finally, if neither p1 is a descendant of pn, nor pn is a descendant of p1, then both sliced parts e1 and en have their weights contributed positively to the sum in Equation 21. Nevertheless, in this case there exists some k, with 1 < k < n such that ek has both of its endpoints in distinct in-frontiers of T[pk]. Indeed, pk is the position farthest away from the root with the property that both p1 and pn are descendants of pk. Therefore we have that the weight of ek is counted negatively. The weights of all other edges e2...ek−1 and ek+1...en−1 are not counted at all, since each of these edges have one endpoint in some in-frontier and another endpoint at an out-frontier. This proves our claim. 36 In view of Proposition 11, if A(Σ, wΩ, α) is the tree-automaton of Lemma 4 in which w = wΩ and a = α, then the slice language of A(Σ, wΩ, α) ∩ A(Σ) is the set of all unit decompositions over Σ which represent a digraph of weight α. More precisely, L(A(Σ, wΩ, α) ∩ A(Σ)) = {T ∈ L(Σ) µ( T) = α}. ◦ (23) 9.3. Inverse Homomorphic Image of Slice Languages Let π : Σ → Σ′ be a slice projection such as defined in Section 6.8. If L is a slice language over Σ′ then the inverse homomorphic image π−1(L), as defined in Section 5.1, is not necessarily a slice language since for a unit decomposition T ∈ L, the inverse set π−1(T) consisting of all terms whose image is T may have some terms over Σ that are not unit decompositions. To fix this we intersect π−1(T) with the slice language L(Σ) of all unit decompositions over Σ. More precisely, if T is a unit decomposition over Σ′ then we define inv(π, T) = π−1(T) ∩ L(Σ). Going further, if L is a slice language over Σ′ then inv(π, L) = [T∈L inv(π, T) = π−1(L) ∩ L(Σ). (24) For instance, if ηc,q : Σ(c, q, Γ1, Γ2) → Σ(c, Γ1, Γ2) is a normalizing projection and T is a unit decomposition over Σ(c, Γ1, Γ2), then inv(ηc,q, T) consists of all unit decompositions that are obtained from T by renumbering the vertices on each frontier of each slice of T with numbers from {1, ..., q} in such a way that the order in each frontier is preserved. Therefore inv(ηc,q, L) is the maximal unnormalized slice language whose image under ηc,q is L. Note that if L is a z-saturated slice language over Σ(c, Γ1, Γ2) then inv(η, L) is a z-saturated slice language over Σ(c, q, Γ1, Γ2). Analogously, if ζΩ : Σ(c, q, Γ1, Γ2 ×Ω) → Σ(c, q, Γ1, Γ2) is an unweighting projection, and T is a unit decomposition over Σ(c, q, Γ1, Γ2), then inv(ζΩ, T) consists of all unit decompositions over Σ(c, q, Γ1, Γ2 × Ω) that are obtained from T by weighting the edges of each slice in T with elements from Ω in such a way that gluability of slices is preserved. Thus inv(ζΩ, L) is a slice language consisting of all weighted versions of unit decompositions in L. We note that if L is a z-saturated slice language over Σ(c, q, Γ1, Γ2) then inv(ζΩ, L) is a z-saturated slice language over Σ(c, q, Γ1, Γ2 × Ω). 9.4. Restricting A(ϕ, k, z) In Theorem 5 we showed that given any MSO2 sentence ϕ in the vocabulary of (Γ1, Γ2)-labeled digraphs, and any z, k ∈ N one can construct a normalized z-saturated slice tree-automaton A(ϕ, k, z) over the slice alphabet Σ(k · z, Γ1, Γ2) whose graph language LG(A(ϕ, k, z)) consists precisely of the digraphs that are the union of k directed paths and satisfy ϕ. In this section we show how to construct a z-saturated tree-automaton A(ϕ, k, z, l, α) over the slice alphabet Σ(c, q, Γ1, Γ2 × Ω) whose graph LG(A(ϕ, k, z, l, α)) contains only the digraphs in LG(A(ϕ, k, z)) that have a prescribed size l and prescribed weight α ∈ Ω. If ϕ is an MSO2 sentence in the vocabulary of (Γ1, Γ2)-labeled digraphs, G = (V, E) is a (Γ1, Γ2)-labeled digraph and µ : E → Ω is a weighting function, then we say that the weighted digraph (G, µ) satisfies ϕ if G satisfies ϕ. In other words, a weighted digraph satisfies an MSO2 sentence if its unweighted version does. Lemma 8. Let ϕ be an MSO2 sentence over (Γ1, Γ2)-labeled digraphs, q, k, z, l, m ∈ N be positive integers with l < m, q ≥ k · z, and let α ∈ Ω. For some computable function g, one can construct in time g(ϕ, k, z, Γ1, Γ2) · qO(k·z) · ΩO(k·z) · mO(1) a z-saturated slice tree-automaton A(ϕ, k, z, l, α) over Σ(k · z, q, Γ1, Γ2 × Ω) such that L(A(ϕ, k, z, l, α)) = {T ∈ Σ(k · z, q, Γ1, Γ2 × Ω) 37 ◦ ◦ T is the union of k directed paths, T= ϕ, T has l (mod m) vertices, ◦ ◦ T has weight α}. Proof. Let ηk·z,q : Σ(k · z, q, Γ1, Γ2) → Σ(k · z, Γ1, Γ2) be a normalizing projection and let ζΩ : Σ(k · z, q, Γ1, Γ2 × Ω) → Σ(k · z, q, Γ1, Γ2) be an unweighting projection. By the discussion in Section 9.3, the slice tree-automaton inv(ζΩ , inv(ηk·z,q, A(ϕ, k, z))) (25) is a deterministic z-saturated tree-automaton over Σ(k · z, q, Γ1, Γ2 × Ω) whose graph language consists of all weighted versions of digraphs in A(ϕ, k, z). We will restrict the tree-automaton in Equation 25 so that it represents only digraphs with weight α and l mod m vertices. For simplicity of notation, let Σ = Σ(k · z, q, Γ1, Γ2 × Ω). Recall that the deterministic tree- automaton A(Σ, wZm , l) ∩ A(Σ) constructed in Section 9.1 generates precisely the set of unit decompositions over Σ that give rise to a digraph with l mod m vertices. Recall also that the deterministic tree-automaton A(Σ, wΩ, α)∩A(Σ) constructed in Section 9.2 generates precisely the unit decompositions over Σ which give rise to digraphs of weight α. Therefore, the slice tree-automaton A(ϕ, k, z, l, α) = inv(ζΩ, inv(η, A(ϕ, k, z))) ∩ A(Σ, wZm , l) ∩ A(Σ, wΩ, α) ∩ A(Σ) is a z-saturated, deterministic slice tree-automaton over the alphabet Σ whose graph language LG(A(ϕ, k, z, l, α)) consists of all digraphs that are the union of k directed paths, satisfy ϕ, have l (mod m) vertices and weight α. To finalize the proof, we need to estimate the size of A(ϕ, k, z, l, α). By Lemma 3.vi the automaton in Equation 25 can be constructed in time A(ϕ, k, z) · ΣO(1). By Proposition 6, the automaton A(Σ) can be constructed in time O(Σ). By Lemma 4 the automaton A(Σ, wZm , l) can be constructed in time Σ · ZmO(1) and the automaton A(Σ, wΩ, α) can be constructed in time Σ · ΩO(1). Therefore, given A(ϕ, k, z), the tree automaton A(ϕ, k, z, l, α) can be constructed in time A(ϕ, k, z) · ΣO(1) · ΩO(k·z) · mO(1). Note that the size of the alphabet Σ(k · z, q, Γ1, Γ1 × Ω) is bounded by 2O(k·z log k·z) · Γ1 · Γ2O(k·z) · ΩO(k·z) · qO(k·z). Thus, the tree-automaton A(ϕ, k, z, l, α) can be constructed in time g(ϕ, k, z, Γ1, Γ2) · qO(k·z) · ΩO(k·z) · mO(1), where g(ϕ, k, z, Γ1, Γ2) is the time necessary to construct A(ϕ, k, z) times 2O(k·z log k·z). 9.5. Proof of Theorem 1 The proof of Theorem 1 will follow as a corollary of the following theorem, whose proof is obtained by plugging the automaton A(ϕ, k, z, l, α), constructed in Lemma 8, into Theorem 4. Theorem 6. Let T ∈ L(Σ(q, Γ1, Γ2 × Ω)) be a normalized unit decomposition of width q and tree-zig-zag number z. Let ϕ be an MSO2 sentence in the vocabulary of (Γ1, Γ2)-labeled digraphs. Then for each k, l ∈ N and each α ∈ Ω one can count in time f (ϕ, k, z) · TO(1) · qO(k·z) · ΩO(k·z) the number of subgraphs H of T simultaneously satisfying the following four properties: ◦ 1. H = ϕ, 2. H is the union of k directed paths, 3. H has l vertices, 4. H has weight µ(H) = α. Proof. The proof follows by a combination of Theorem 4 with Lemma 8. First, Theorem 4 says that given a z-saturated slice tree automaton A over Σ(k · z, q, Γ1, Γ2 × Ω), we can count in time TO(k·z) · AO(1) the number of subgraphs of T which are isomorphic to some digraph in LG(A). ◦ 38 ◦ Second by Lemma 8, we can construct a z-saturated slice tree-automaton A(ϕ, k, z, l, α) such that a digraph H belongs to the graph language LG(A(ϕ, k, z, l, α)) if and only if H satisfies ϕ, is the union of k directed paths, has l (mod m) vertices, and weight α. Since any subgraph T has at most T vertices, if we set m = T + 1 and A = A(ϕ, k, z, l, α), then Theorem 4 of provides us with an algorithm for counting all the subgraphs of T that satisfy Conditions 1-4 of the present theorem. Since A(ϕ, k, z, l, α) ≤ g(ϕ, k, z, Γ1, Γ2) · qO(k·z) · ΩO(k·z) · mO(1), and since the label sets Γ1 and Γ2 are fixed, the algorithm runs in time ◦ f (ϕ, k, z) · TO(1) · qO(k·z) · ΩO(k·z), where f (ϕ, k, z) = g(ϕ, k, z, Γ1, Γ2)O(1) and Γ1 and Γ2 are treated as constants. Finally, the proof of our main theorem (Theorem 1) follows as an application of Theorem 6. ◦ Proof of Theorem 1. Let G = (V, E, ρ, ξ × µ) be a (Γ1, Γ2 × Ω)-labeled digraph of directed treewidth w. By Theorem 2, we can construct in time GO(w) a good arboreal decomposition D of G of width O(w). By Theorem 3, from D we can construct an olive-tree decomposition T of tree-zig-zag number z for some z ≤ 9w + 18. Using Proposition 8 we can use T to construct a normalized unit decomposition T over Σ(q, Γ1, Γ2 × Ω) such that T has tree-zig-zag number T= G. Therefore given an MSO2 sentence ϕ, and positive integers k, z ∈ N, we can z and apply Theorem 6 to count in time f (ϕ, k, z) · TO(1) · qO(k·z) · ΩO(k·z), the number of subgraphs of T that are the union of k directed paths, satisfy ϕ, have l vertices and weight α. Since T ≤ GO(1), q ≤ E, and by assumption Ω ≤ GO(1), we have that the total running time of the algorithm is f (ϕ, k, z) · GO(k·z). Since z ≤ 9w + 18, the running time of the algorithm stated in terms of directed treewidth is f (ϕ, k, z) · GO(k(w+1)). Here we write w + 1 in the exponent, to emphasize that the treewidth of G can be 0. (cid:3) ◦ 10. Conclusion In this work we devised the first algorithmic metatheorem for digraphs of constant directed treewidth. We showed that most of the previously known positive algorithmic results for this class of digraphs can be re-stated in terms of our metatheorem. Additionally, we showed how to use our metatheorem to provide polynomial time algorithms for two classes of counting problems whose polynomial-time solvability is not implied by previously existing techniques. Namely, for each fixed k, we showed how to count in polynomial time on digraphs of constant directed treewidth, the number of minimum spanning strong subgraphs that are the union of k directed paths, and the number of subgraphs that are the union of k directed paths and satisfy a given minor closed property. To prove our main theorem we introduced two new theoretical tools which in our opinion are of independent interest. The first, the tree-zig-zag number of a digraph, is a new directed width measure that is at most a constant times its directed treewidth. Concerning this measure, we leave open the problem of determining whether there exist families of digraphs of constant tree-zig-zag number but unbounded directed treewidth, or whether the directed treewidth of a digraph is always bounded by a function of its tree-zig-zag number. The second theoretical tool we have introduced is the notion of z-saturated tree-automata. By Theorem 4, given a digraph G of constant directed treewidth, and a z-saturated tree-automaton A generating only digraphs that are the union of k directed paths, one can count the number of subgraphs of G that are isomorphic to some digraph in LG(A). It would be interesting to study ways of constructing z-saturated tree-automata without the help of MSO2 logic. Such a construction would open the possibility of using Theorem 4 to solve counting problems, on digraphs of constant directed treewidth, that may not be approachable via Theorem 1. 39 11. Acknowledgements. The author is currently supported by the European Research Council, ERC grant agreement 339691, within the context of the project Feasibility, Logic and Randomness (FEALORA). References [1] A. V. Aho, M. R. Garey, and J. D. Ullman. The transitive reduction of a directed graph. SIAM Journal on Computing, 1(2):131–137, 1972. [2] S. A. Amiri, L. Kaiser, S. Kreutzer, R. Rabinovich and S. Siebertz. Graph searching games and width measures for directed graphs. In Proc. of Symposium on Theoretical Aspects of Computer Science, pages 34–47, 2015. [3] S. Arnborg, J. Lagergren, and D. Seese. Easy problems for tree-decomposable graphs. Journal of Algorithms, 12(2):308–340, 1991. [4] J. Bang-Jensen, J. Huang, and A. Yeo. Strongly connected spanning subdigraphs with the minimum number of arcs in quasi-transitive digraphs. SIAM Journal on Discrete Mathematics, 16(2):335–343, 2003. [5] J. Bang-Jensen and A. Yeo. The minimum spanning strong subdigraph problem for extended semicomplete digraphs and semicomplete bipartite digraphs. Journal of Algorithms, 41(1):1–19, 2001. [6] J. Bar´at. Directed path-width and monotonicity in digraph searching. Graphs and Combinatorics, 22(2):161– 172, 2006. [7] D. Berwanger, A. Dawar, P. Hunter, S. Kreutzer, and J. Obdrz´alek. The DAG-width of directed graphs. Journal of Combinatorial Theory, Series B, 102(4):900–923, 2012. [8] D. Berwanger and E. Gradel. Entanglement - A measure for the complexity of directed graphs with applica- tions to logic and games. In Proc. of Logic Programming and Automated Reasoning (LPAR), volume 3452 of LNCS, pages 209–223, 2004. [9] D. Berwanger, E. Gradel, L. Kaiser, and R. Rabinovich. Entanglement and the complexity of directed graphs. Theoretical Computer Science, 463:2–25, 2012. [10] S. Bessy and S. Thomass´e. Every strong digraph has a spanning strong subgraph with at most n+2 alpha-2 arcs. Journal of Combinatorial Theory, Series B, 87(2):289–299, 2003. [11] G. Calinescu and C. G. Fernandes. Finding large planar subgraphs and large subgraphs of a given genus. In Computing and Combinatorics, pages 152–161. Springer, 1996. [12] G. Calinescu, C. G. Fernandes, U. Finkler, and H. Karloff. A better approximation algorithm for finding planar subgraphs. Journal of Algorithms, 27(2):269–302, 1998. [13] R. Cimikowski and D. Coppersmith. The sizes of maximal planar, outerplanar, and bipartite planar sub- graphs. Discrete Mathematics, 149(1):303–309, 1996. [14] H. Comon, M. Dauchet, R. Gilleron, C. Loding, F. Jacquemard, D. Lugiez, S. Tison, and M. Tommasi. Tree automata techniques and applications. Available at http://www.grappa.univ-lille3.fr/tata, 2007. Release October, 12th 2007. [15] B. Courcelle. The monadic second-order logic of graphs. I. Recognizable sets of finite graphs. Information and Computation, 85(1):12–75, 1990. [16] B. Courcelle and J. Engelfriet. Graph structure and monadic second-order logic. A language-theoretic ap- proach. Vol. 138. Cambridge University Press, 2012. [17] B. Courcelle, J. A. Makowsky, and U. Rotics. Linear time solvable optimization problems on graphs of bounded clique-width. Theory of Computing Systems, 33(2):125–150, 2000. [18] P. Dankelmann, G. Gutin, and E. J. Kim. On complexity of minimum leaf out-branching problem. Discrete Applied Mathematics, 157(13):3000–3004, 2009. [19] M. de Oliveira Oliveira. Hasse diagram generators and Petri nets. Fundamenta Informaticae, 105(3):263–289, 2010. [20] M. de Oliveira Oliveira. Subgraphs satisfying MSO properties on z-topologically orderable digraphs. In Proc. of Parameterized and Exact Computation (IPEC), volume 8246 of LNCS, pages 123–136. Springer, 2013. [21] R. G. Downey and M. R. Fellows. Fixed parameter tractability and completeness. In Proc. of Complexity Theory: Current Research, Dagstuhl Workshop, pages 191–225, 1992. [22] H. N. Gabow. Special edges, and approximating the smallest directed k-edge connected spanning subgraph. In Proc. of Symposium on Discrete Algorithms (SODA), pages 234–243, 2004. [23] R. Ganian, P. Hlinen´y, J. Kneis, A. Langer, J. Obdrz´alek, and P. Rossmanith. Digraph width measures in parameterized algorithmics. Discrete Applied Mathematics, 168:88–107, 2014. [24] R. Ganian, P. Hlinen´y, J. Kneis, D. Meister, J. Obdrz´alek, P. Rossmanith, and S. Sikdar. Are there any good digraph width measures? In Proc. of Parameterized and Exact Computation (IPEC), pages 135–146, 2010. [25] H. Gruber. Digraph complexity measures and applications in formal language theory. Discrete Mathematics & Theoretical Computer Science, 14(2):189–204, 2012. 40 [26] H. Gruber and M. Holzer. Finite automata, digraph connectivity, and regular expression size. In Proc. of International Colloquium on Automata, Languages, and Programming (ICALP), volume 5126 of LNCS, pages 39–50, 2008. [27] P. Hunter and S. Kreutzer. Digraph measures: Kelly decompositions, games, and orderings. Theoretical Computer Science, 399(3):206–219, 2008. [28] T. Johnson, N. Robertson, P. D. Seymour, and R. Thomas. Directed tree-width. Journal of Combinatorial Theory, Series B, 82(1):138–154, 2001. [29] M. Junger and P. Mutzel. Maximum planar subgraphs and nice embeddings: Practical layout tools. Algo- rithmica, 16(1):33–59, 1996. [30] M. Lampis, G. Kaouri, and V. Mitsou. On the algorithmic effectiveness of digraph decompositions and complexity measures. Discrete Optimization, 8(1):129–138, 2011. [31] T. Poranen. Heuristics for the maximum outerplanar subgraph problem. Journal of Heuristics, 11(1):59–88, 2005. [32] B. A. Reed. Introducing directed tree width. Electronic Notes in Discrete Mathematics, 3:222–229, 1999. [33] N. Robertson and P. D. Seymour. Graph minors XX. Wagner’s conjecture. Journal of Combinatorial Theory, Series B, 92(2):325–357, 2004. [34] M. A. Safari. D-width: A more natural measure for directed tree width. In Proc. of Mathematical Foundations of Computer Science (MFCS), volume 3618 of LNCS, pages 745–756, 2005. [35] P. D. Seymour and R. Thomas. Call routing and the ratcatcher. Combinatorica, 14(2):217–241, 1994. [36] A. Slivkins. Parameterized tractability of edge-disjoint paths on directed acyclic graphs. In Proc. of European Symposium on Algorithms (ESA), volume 2832 of LNCS, pages 482–493, 2003. [37] A. Vetta. Approximating the minimum strongly connected subgraph via a matching lower bound. In Proc. of Symposium on Discrete Algorithms (SODA), volume 1, pages 417–426, 2001. 41
1201.4459
1
1201
2012-01-21T10:39:34
An efficient parallel algorithm for the longest path problem in meshes
[ "cs.DS" ]
In this paper, first we give a sequential linear-time algorithm for the longest path problem in meshes. This algorithm can be considered as an improvement of [13]. Then based on this sequential algorithm, we present a constant-time parallel algorithm for the problem which can be run on every parallel machine.
cs.DS
cs
An efficient parallel algorithm for the longest path problem in meshes Fatemeh Keshavarz-Kohjerdia Department of Computer Engineering, Islamic Azad University, North Tehran Branch, Tehran, Iran. Alireza Bagherib Department of Computer Engineering & IT, Amirkabir University of Technology, Tehran, Iran. aCorresponding author: [email protected] b ar [email protected] Abstract In this paper, first we give a sequential linear-time algorithm for the longest path problem in meshes. This algorithm can be considered as an improve- ment of [13]. Then based on this sequential algorithm, we present a constant- time parallel algorithm for the problem which can be run on every parallel machine. Keywords: grid graph, longest path, meshes, sequential and parallel algorithms. MSC: 05C 45; 05C 85; 05C 38. 1. Introduction The longest path problem, i.e. the problem of finding a simple path with the maximum number of vertices, is one of the most important problems in graph theory. The well-known NP-complete Hamiltonian path problem, i.e. deciding whether there is a simple path that visits each vertex of the graph exactly once, is a special case of the longest path problem and has many applications [5, 7]. Only few polynomial-time algorithms are known for the longest path problem for special classes of graphs. This problem for trees began with the work of Dijkstra around 1960, and was followed by other people [2, 9, Preprint submitted to Elsevier December 21, 2013 16, 18, 22]. In the area of approximation algorithms it has been shown that the problem is not in APX, i.e. there is no polynomial-time approximation algorithm with constant factor for the problem unless P=NP [9]. Also, it has been shown that finding a path of length n − nǫ is not possible in polynomial- time unless P=NP [12]. For the backgrround and some known result about approximation algorithms, we refer the reader to [1, 6, 24]. A grid graph is a graph in which vertices lie only on integer coordinates and edges connect vertices that are separated by a distance of once. A solid grid graph is a grid graph without holes. The rectangular grid graph R(n, m) is the subgraph of G∞ (infinite grid graph) induced by V (m, n) = {υ 1 ≤ vx ≤ m, 1 ≤ vy ≤ n}, where vx and vy are respectively x and y coordinates of v (see Figure 1). A mesh M (m, n) is a rectangular grid graph R(m, n). Grid graphs can be useful representation in many applications. Myers [19] suggests modeling city blocks in which street intersection are vertices and streets are edges. Luccio and Mugnia [17] suggest using a grid graph to represent a two- dimensional array type memory accessed by a read/write head moving up, down or across. The vertices correspond to the center of each cell and edges connect adjacent cells. Finding a path in the grid corresponds to accessing all the data. Itai et al. [11] have shown that the Hamiltonian path problem for general grid graphs, with or without specified endpoints, is NP-complete. The prob- lem for rectangular grid graphs, however, is in P requiring only linear-time. Later, Chen et al. [3] improved the algorithm of [11] and presented a parallel algorithm for the problem in mesh architecture. There is a polynomial-time algorithm for finding Hamiltonian cycle in solid grid graphs [15]. Also, the authors in [23] presented sufficient conditions for a grid graph to be Hamilto- nian and proved that all finite grid graphs of positive width have Hamiltonian line graphs. Recently the Hamiltonian cycle (path) and longest path problem of a grid graph has received much attention. Salman et al. [21] introduced a family of grid graphs, i.e. alphabet grid graphs, and determined classes of alphabet grid graphs that contain Hamiltonian cycles. Islam et al. [10] showed that the Hamiltonian cycle problem in hexagonal grid graphs is NP-complete. Also, Gordon et al. [8] proved that all connected, locally connected triangular grid graphs are Hamiltonian, and gave a sufficient condition for a connected graph to be fully cycle extendable and also showed that the Hamiltonian cycle problem for triangular grid graphs is NP-complete. Moreover, Zhang and Liu [25] gave an approximation algorithm for the 2 Figure 1: The rectangular grid graph R(8, 7). longest path problem in grid graphs and their algorithm runs in quadratic time. Also the authors in [13] has been studied the longest path problem for rectangular grid graphs and their algorithm is based on divide and con- quer technique and runs in linear time. Some results of the grid graphs are investigated in [14, 20]. In this paper, we present a sequential and a parallel algorithms for finding longest paths between two given vertices in rectangular grid graphs (meshes). Our algorithm has improved the previous algorithm [13] by reducing the number of partition steps from O(m + n) to only a constant. The organization of the paper as follow: In Section 2, we review some necessary definitions and results that we will need. A sequential algorithm for the longest path problem is given in Section 3. In Section 4, a parallel algorithm for the problem is introduced which is based on the mentioned sequential algorithm. Conclusions is given in Section 5. 2. Preliminary results In this section, we give a few definitions and introduce the correspond- ing notations. We then gather some previously established results on the Hamiltonian and the longest path problems in grid graphs which have been presented in [3, 11, 13]. The two-dimensional integer grid G∞ is an infinite graph with vertex set of all the points of the Euclidean plane with integer coordinates. In this graph, there is an edge between any two vertices of unit distance. For a vertex v of this graph, let vx and vy denote x and y coordinates of its correspond- ing point (sometimes we use (vx , vy ) instead of v ). We color the vertices of the two-dimensional integer grid as black and white. A vertex υ is colored white if υx + υy is even, and it is colored black otherwise. A grid graph Gg is a finite vertex-induced subgraph of the two-dimensional integer grid. In a grid graph Gg , each vertex has degree at most four. Clearly, there is no 3 Figure 2: A Hamiltonian cycle for the rectangular grid graph R(5, 4). edge between any two vertices of the same color. Therefore, Gg is a bipartite graph. Note that any cycle or path in a bipartite graph alternates between black and white vertices. A rectangular grid graph R(m, n) (or R for short) is a grid graph whose vertex set is V (R) = {υ 1 ≤ υx ≤ m, 1 ≤ υy ≤ n}. In the figures we assume that (1, 1) is the coordinates of the vertex in the upper left corner. The size of R(m, n) is defined to be mn. R(m, n) is called odd-sized if mn is odd, and it is called even-sized otherwise. In this paper without loss of generality, we assume m ≥ n and all rectangular grid graphs considered here are odd×odd, even×odd and even×even. R(m, n) is called a n-rectangle. The following lemma states a result about the Hamiltonicity of even-sized rectangular graphs. Lemma 2.1. [3] R(m, n) has a Hamiltonian cycle if and only if it is even- sized and m, n > 1. Figure 2 shows a Hamiltonian cycle for an even-sized rectangular grid graph, found by Lemma 2.1. Every Hamiltonian cycle found by this lemma contains all the boundary edges on the three sides of the rectangular grid graph. This shows that for an even-sized rectangular graph R, we can always find a Hamiltonian cycle, such that it contains all the boundary edges, except of exactly one side of R which contains an even number of vertices. Two different vertices υ and υ ′ in R(m, n) are called color-compatible if either both υ and υ ′ are white and R(m, n) is odd-sized, or υ and υ ′ have different colors and R(m, n) is even-sized. Let (R(m, n), s, t) denote the rectangular grid graph R(m, n) with two specified distinct vertices s and t. Without loss of generality, we assume sx ≤ tx . (R(m, n), s, t) is called Hamiltonian if there exists a Hamiltonian path be- tween s and t in R(m, n). An even-sized rectangular grid graph contains the same number of black and white vertices. Hence, the two end-vertices of any Hamiltonian path in the graph must have different colors. Similarly, in an odd-sized rectangular grid graph the number of white vertices is one more than the number of black vertices. Therefore, the two end-vertices of 4 any Hamiltonian path in such a graph must be white. Hence, the color- compatibility of s and t is a necessary condition for (R(m, n), s, t) to be Hamiltonian. Furthermore, Itai et al. [11] showed that if one of the following conditions hold, then (R(m, n), s, t) is not Hamiltonian: (F1) R(m, n) is a 1-rectangle and either s or t is not a corner vertex (Figure 3(a)) (F2) R(m, n) is a 2-rectangle and (s, t) is a nonboundary edge, i.e. (s, t) is an edge and it is not on the outer face (Figure 3(b)). (F3) R(m, n) is isomorphic to a 3-rectangle grid graph R′ (m, n) such that s and t is mapped to s′ and t′ and all of the following three conditions hold: 1. m is even, 2. s′ is black, t′ is white, y 6= 2 and s′ x − 1 (Figure 3. s′ x (Figure 3(c)) or s′ y = 2 and s′ x < t′ x < t′ 3(d)). Also by [11] for a rectangular graph R(m, n) with two distinct vertices s and t, (R(m, n), s, t) is Hamiltonian if and only if s and t are color-compatible and R(m, n), s and t do not satisfy any of conditions (F 1), (F 2) and (F 3). In the following we use P (R(m, n), s, t) to indicate the problem of finding a longest path between vertices s and t in a rectangular grid graph R(m, n), L(R(m, n), s, t) to show the length of longest paths between s and t and U (R(m, n), s, t) to indicate the upper bound on the length of longest paths between s and t. The authors in [13] showed that the longest path problem between any two given vertices s and t in rectangular grid graphs satisfies one of the following conditions: (C0) s and t are color-compatible and none of (F1)- (F3) hold. (C1) Neither (F1) nor (F2∗) holds and either 1. R(m, n) is even-sized and s and t are same-colored or 2. R(m, n) is odd-sized and s and t are different-colored. (C2) 1. R(m, n) is odd-sized and s and t are black-colored and neither (F1) nor (F2∗) holds, or 5         a b   d Figure 3: Rectangular grid graph in which there is no Hamiltonian path between s and t. 2. s and t are color-compatible and (F3) holds. Where (F2∗) is defined as follows: (F2∗) R(m, n) is a 2-rectangle and sx = tx or (sx = tx − 1 and sy 6= ty ). U (R(m, n), s, t) = if (F 1), if (F 2∗), if (C 0), if (C 1), if (C 2). tx − sx + 1, max(tx + sx , 2m − tx − sx + 2), mn, mn − 1, mn − 2, They also proved some upper bounds on the length of longest paths as fol- lowing:   Theorem 2.1. [13] Let U (R(m, n), s, t) be the upper bound on the length of longest paths between s and t in R(m, n) and let L(R(m, n), s, t) be the length of longest paths between s and t. In a rectangular grid graph R(m, n), a longest path between any two vertices s and t can be found in linear time and its length (i.e., L(R(m, n), s, t)) is equal to U (R(m, n), s, t). 3. The sequential algorithm In this section, we present a sequential algorithm for finding a longest path between two vertices in rectangular grid graphs. This algorithm is the base of our parallel algorithm which is introduced in Section 4. First, we solve the problem for 1-rectangles and 2-rectangles. Lemma 3.1. [13] Let P (R(m, n), s, t) be a longest path problem with n = 1 or n = 2, then L(R(m, n), s, t) = U (R(m, n), s, t). 6
1511.07263
2
1511
2016-10-06T22:48:49
Input Sparsity Time Low-Rank Approximation via Ridge Leverage Score Sampling
[ "cs.DS", "cs.LG" ]
We present a new algorithm for finding a near optimal low-rank approximation of a matrix $A$ in $O(nnz(A))$ time. Our method is based on a recursive sampling scheme for computing a representative subset of $A$'s columns, which is then used to find a low-rank approximation. This approach differs substantially from prior $O(nnz(A))$ time algorithms, which are all based on fast Johnson-Lindenstrauss random projections. It matches the guarantees of these methods while offering a number of advantages. Not only are sampling algorithms faster for sparse and structured data, but they can also be applied in settings where random projections cannot. For example, we give new single-pass streaming algorithms for the column subset selection and projection-cost preserving sample problems. Our method has also been used to give the fastest algorithms for provably approximating kernel matrices [MM16].
cs.DS
cs
Input Sparsity Time Low-Rank Approximation via Ridge Leverage Score Sampling Michael B. Cohen Cameron Musco Christopher Musco∗ Massachusetts Institute of Technology, EECS Cambridge, MA 02139, USA Email: {micohen,cnmusco,cpmusco}@mit.edu October 10, 2016 Abstract We present a new algorithm for finding a near optimal low-rank approximation of a matrix A in O(nnz(A)) time. Our method is based on a recursive sampling scheme for computing a representative subset of A's columns, which is then used to find a low-rank approximation. This approach differs substantially from prior O(nnz(A)) time algorithms, which are all based on fast Johnson-Lindenstrauss random projections. It matches the guarantees of these methods while offering a number of advantages. Not only are sampling algorithms faster for sparse and structured data, but they can also be applied in settings where random projections cannot. For example, we give new single-pass streaming algorithms for the column subset selection and projection-cost preserving sample prob- lems. Our method has also been used to give the fastest algorithms for provably approximating kernel matrices [MM16]. 6 1 0 2 t c O 6 ] S D . s c [ 2 v 3 6 2 7 0 . 1 1 5 1 : v i X r a ∗Part of this work was completed while the author interned at Yahoo Labs, NYC. 1 Introduction Low-rank approximation is a fundamental task in statistics, machine learning, and computational science. The goal is to find a rank k matrix that is as close as possible to an arbitrary input matrix A ∈ Rn×d, with distance typically measured using the spectral or Frobenius norms. Traditionally, the problem is solved using the singular value decomposition (SVD), which takes O(nd2) time to compute. This high cost can be reduced using iterative algorithms like the power method or Krylov methods, which require just O(nnz(A) · k) time per iteration, where nnz(A) is the number of non-zero entries in A1. More recently, the cost of low-rank approximation has been reduced even further using sketching methods based on Johnson-Lindenstrauss random projection [Sar06]. Remarkably, so-called "sparse random projections" [CW13, MM13, NN13, BDN15, Coh16] give algorithms that run in time2: O(nnz(A)) + O (n · poly(k, ǫ)) . These methods output a low-rank approximation within a (1 + ǫ) factor of optimal when error is measured using the Frobenius norm. They are typically referred to as running in "input sparsity time" since the O(nnz(A)) term is considered to dominate the runtime. Input sparsity time algorithms for low-rank approximation were an important theoretical achieve- ment and have also been influential in practice. Implementations are now available in a variety of languages and machine learning libraries [Liu14, Oka10, IBM14, PVG+11, HRZ+09, VM15]. 1.1 Our Contributions We give an entirely different approach to obtaining input sparsity time algorithms for low-rank approximation. Random projection methods are based on multiplying A by a sparse random matrix Π ∈ Rd×poly(k,ǫ) to form a smaller matrix AΠ that contains enough information about A to compute a near optimal low-rank approximation. Our techniques on the other hand are based on sampling O(k/ǫ) columns from A, and computing a low-rank approximation using this sample. Sampling itself is simple and extremely efficient. However, to obtain a good approximation to A, columns must be sampled with non-uniform probabilities, carefully chosen to reflect their relative importance. It is known that variations on the standard statistical leverage scores give probabilities that are provably sufficient for low-rank approximation [Sar06, DMM08, CEM+15]. Unfortunately, computing any of these previously studied "low-rank leverage scores" is as dif- ficult as low-rank approximation itself, so sampling did not yield fast algorithms3. We address this issue for the first time by introducing new importance sampling probabilities which can be approximated efficiently using a simple recursive algorithm. In particular, we adapt the so-called ridge leverage scores to low-rank matrix approximation. These scores have been used as sampling probabilities in the context of linear regression and spectral approximation [LMP13, KLM+14, AM15] but never for low-rank approximation. By showing that ridge leverage scores display a unique monotonicity property under perturba- tions to A, we are able to prove that, unlike any prior low-rank leverage scores, they can be approx- imated using a relatively large uniform subsample of A's columns. While too large to use directly, the size of this subsample can be reduced recursively to give an overall fast algorithm. This approach 1The number of iterations depends on the accuracy ǫ and/or spectral gap conditions. See [MM15] for an overview. 2 O(·) hides logarithmic factors, including a failure probability dependence. 3ℓ2 norm sampling does yield very fast algorithms [FKV04, DKM06a, BJS15], but cannot give relative error guarantees matching those of random projection or leverage score methods without additional assumptions on A. 1 resembles work on recursive methods for computing standard leverage scores, which were recently used to give the first O(nnz(A)) time sampling algorithms for linear regression [LMP13, CLM+15]. Our main algorithmic result, which nearly matches the state-of-the-art in [NN13] follows: Theorem 1. For any θ ∈ (0, 1], there exists a recursive column sampling algorithm that, in time O(cid:0)θ−1 nnz(A)(cid:1) + O(cid:16) n1+θk2 ǫ4 (cid:17), returns Z ∈ Rn×k satisfying: (1) kA − ZZT Ak2 F ≤ (1 + ǫ)kA − Akk2 F . Here Ak is the best rank k approximation to A. To prove Theorem 1, we show how to compute a sampling matrix S such that AS ∈ Rn× O(k/ǫ2) satisfies a projection-cost preservation guarantee (formalized in Section 2). This property ensures that it is possible to extract a near optimal low- rank approximation from the sample. It also allows AS to be used to approximately solve a broad class of constrained low-rank approximation problems, including k-means clustering [CEM+15]. With a slightly smaller sample, we also prove that AS satisfies a standard (1 + ǫ) error col- umn subset selection guarantee. Ridge leverage score sampling is the first algorithm, efficient or otherwise, that obtains both of these important approximation goals simultaneously. 1.2 Why Sampling? Besides the obvious goal of obtaining alternative state-of-the-art algorithms for low-rank approxi- mation, we are interested in sampling methods for a few specific reasons: Sampling maintains matrix sparsity and structure. Without additional assumptions on A, our recursive sampling algorithms essentially match random projection methods. However, they have the potential to run faster for sparse or structured data. Random projection linearly combines all columns in A to form AΠ ∈ Rn×poly(k,ǫ), so this sketched matrix is usually dense and unstructured. On the other hand, AS will remain sparse or structured if A is sparse or structured, in which case it can be faster to post-process. Potential gains are especially important when the O(n · poly(k, ǫ)) runtime term is not dominated by O(nnz(A)). We note that the ability to maintain sparsity and structure motivated similar work on recur- sive sampling algorithms for fast linear regression [CLM+15]. While these techniques only match random projection for general matrices, they have been important ingredients in designing faster al- gorithms for highly structured Laplacian and SDD matrices [LPS15, KLP+16, JK16]. We hope our sampling methods for low-rank approximation will provide a foundation for similar contributions. Sampling techniques lead to natural streaming algorithms. In data analysis, sampling itself is often the primary goal. The idea is to select a subset of columns from A whose span contains a good low-rank approximation for the matrix and hence represents important or influential features [PZB+07, MD09]. Computing this subset in a streaming setting is of both theoretical and practical interest [Str14]. Unfortunately, while random projection methods adapt naturally to data streams [CW09], impor- tance sampling is more difficult. The leverage score of one column depends on every other column, including those that have not yet appeared in the stream. While random projections can be used to approximate leverage scores, this approach inherently requires two passes over the data. Fortunately, the same techniques used in our recursive algorithms apply naturally in the stream- ing setting. We can compute coarse approximations to the ridge leverage scores using just a small number of columns and refine these approximations as the stream is revealed. By rejection sampling columns as the probabilities are adjusted, we obtain the first space efficient single-pass streaming algorithms for both column subset selection and projection-cost preserving sampling (Section 6). 2 Sampling offers additional flexibility for non-standard matrices. In recent follow up work, the techniques in this paper are adapted to give the most efficient, provably accurate algorithms for kernel matrix approximation [MM16]. In nearly all settings this well-studied problem cannot be solved efficiently by random projection methods. The goal in kernel approximation is to replace an n × n positive semidefinite kernel matrix K with a low-rank approximation that takes less space to represent [AMS01, WS01, FS02, MD05, RR07, BW09a, BW09b, Bac13, GM13, HI15, LJS16]. However, unlike in the standard low-rank ap- proximation problem, K is not represented explicitly. Its entries can only be accessed by evaluating a "kernel function" between each pair of the n points in a data set. Sketching K using random projection requires computing the full matrix first, using Θ(n2) kernel evaluations. On the other hand, with recursive ridge leverage score sampling this is not necessary – it is possible to compute entries of K 'on the fly', only when they are required to compute ridge scores with respect to a subsample. [MM16] shows that this technique gives the first provable algorithms for approximating kernel matrices that only require time linear in n. In other words, the methods only evaluate a tiny fraction of the dot products required to build K. Notably they do not require any coherence or regularity assumptions to achieve this runtime. Aside from kernel approximation, we note that in [BJS15] the authors present a low-rank approximation algorithm based on elementwise sampling that they show can be applied to the product of two matrices without ever forming this product explicitly. This result again highlights the flexibility of sampling-based methods for non-standard matrices. Without access to an efficiently computable leverage score distribution for elementwise sampling, [BJS15] applies an approximation based on ℓ2 sampling. This approximation only performs well under additional assumptions on A and an interesting open question is to see if our techniques can be adapted to their framework in order to eliminate such assumptions. 1.3 Techniques and Paper Layout Sampling Bounds (Sections 2, 3): In Section 2 we review technical background and introduce ridge leverage scores. In Section 3 we prove that sampling by ridge leverage scores gives solutions to the projection-cost preserving sketch and column subset selection problems. These sections do not address algorithmic considerations. While the proofs are technical, we reduce both problems to a simple "additive-multiplicative spectral guarantee," which resembles the ubiquitous subspace embedding guarantee [Sar06]. This approach greatly simplifies prior work on low-rank approximation bounds for sampling methods [CEM+15] and we hope that it will prove generally useful in studying future sketching methods. Ridge Leverage Score Monotonicity (Section 4): In Section 4 we prove a basic theorem regarding the stability of ridge leverage scores. Specifically, we show that the ridge leverage score of a column cannot increase if another column is added to the matrix. This fact, which do not hold for any prior "low-rank leverage scores", is essential in proving the correctness of our recursive sampling procedure and streaming algorithms. Recursive Sampling Algorithm (Section 5): In Section 5, we describe and prove the correct- ness of our main sampling algorithm. We show how a careful implementation of the algorithm gives O(nnz(A)) running time for computing ridge leverage scores, and accordingly for solving the low-rank approximation problem. Application to Streaming (Section 6): We conclude with an application of our results to low-rank sampling algorithms for single-pass column streams that are only possible thanks to the stability result of Section 4. 3 2 Technical Background 2.1 Low-rank Approximation Using the singular value decomposition (SVD), any rank r matrix A ∈ Rn×d can be factored as A = UΣVT . U ∈ Rn×r and V ∈ Rd×r are orthonormal matrices whose columns are the left and right singular vectors of A. Σ is a diagonal matrix containing A's singular values σ1 ≥ σ2 ≥ . . . ≥ σr > 0 in decreasing order from top left to bottom right. When quality is measured with respect to the Frobenius norm, the best low-rank approximation for A is given by Ak = UkΣkVT k where Uk ∈ Rn×k, Vk ∈ Rd×k, and Σk ∈ Rk×k contain the just the first k components of U, V, and Σ respectively. In other words, Ak = arg min B:rank(B)≤k kA − BkF . Since U has orthonormal columns, we can rewrite Ak = UkUT k A. That is, the best rank k approximation can be found by projecting A onto the span of its top k singular vectors. Throughout, we will use the shorthand A\k to denote the residual A − Ak. U\k ∈ Rn×r−k, V\k ∈ Rd×r−k, and Σ\k ∈ Rr−k×r−k denote U, V, and Σ restricted to just their last k components. When solving the low-rank approximation problem approximately, our goal is to find an or- thonormal span Z ∈ Rn×k satisfying kA − ZZT AkF ≤ (1 + ǫ)kA − UkUT k AkF . 2.2 Sketching Algorithms Like many randomized linear algebra routines, our low-rank approximation algorithms are based on "linear sketching". Sketching algorithms use a typically randomized procedure to compress A ∈ Rd×n into an approximation (or "sketch") C ∈ Rd′×n with many fewer columns (d′ ≪ d). Random projection algorithms construct C by forming d′ random linear combinations of the columns in A. Random sampling algorithms construct C by selecting and possibly reweighting a d′ columns in A. After compression, a post-processing routine, which is often deterministic, is used to solve the original linear algebra problem with just the information contained in C. In our case, the post- processing step needs to extract an approximation to the span of A's top left singular vectors. If C is much smaller than A, the cost of post-processing is typically considered a low-order term in comparison to the cost of computing the sketch to begin with. When analyzing sketching algorithms it is common to separate the post-processing step from the dimensionality reduction step. Known post-processing routines give good approximate solutions to linear algebra problems under the condition that C satisfies certain approximation properties with respect to A. The challenge then becomes proving that a specific dimensionality reduction algorithm produces a sketch satisfying these required guarantees. 2.3 Sampling Guarantees for Low-rank Approximation For low-rank approximation, most algorithms aim for one of two standard approximation guaran- tees, which we describe below. Since we will be focusing on sampling methods, from now on we assume that C is a subset of A's columns. Definition 2 (Rank k Column Subset Selection). For d′ < d, a subset of A's columns C ∈ Rn×d′ is a (1 + ǫ) factor column subset selection if there exists a rank k matrix Q ∈ Rd′×d with kA − CQk2 F ≤ (1 + ǫ)kA − Akk2 F . (2) 4 In other words, the column span C contains a good rank k approximation for A. Algorithmically, we can recover this low-rank approximation via projection to the column subset [Sar06, CW13]. Beyond sketching for low-rank approximation, the column subset selection guarantee is used as a metric in feature selection for high dimensional datasets [PZB+07, MD09]. With columns of A interpreted as features and rows as data points, (2) ensures that we select d′ features that span the feature space nearly as well as the top k principal components. The guarantee is also important in algorithms for CUR matrix decomposition [DKM06b, MD09, BW14] and Nystrom approximation [WS01, MD05, BW09b, BW09a, GM13, HI15, MM16]. In addition to Definition 2, we consider a stronger guarantee for weighted column selection, which has a broader range of algorithmic applications: Definition 3 (Rank k Projection-Cost Preserving Sample). For d′ < d, a subset of rescaled columns C ∈ Rn×d′ is a (1 + ǫ) projection-cost preserving sample if, for all rank k orthogonal projection matrices X ∈ Rn×n, (1 − ǫ)kA − XAk2 F ≤ kC − XCk2 F ≤ (1 + ǫ)kA − XAk2 F (3) Definition 3 is formalized in two recent papers [FSS13, CEM+15], though it appears implicitly in prior work [DFK+04, BZMD15]. It ensures that C approximates the cost of any rank k column projection of A. C can thus be used as a direct surrogate of A to solve low-rank projection problems. Specifically, it's not hard to see that if we use a post-processing algorithm that sets Z equal to the top k left singular vectors of C, it will hold that kA−ZZT AkF ≤ (1+ǫ)kA−UkUT k AkF [CEM+15]. Definition 3 also ensures that C can be used in approximately solving a variety of constrained low-rank approximation problems, including k-means clustering of A's rows (see [CEM+15]). 2.4 Leverage Scores It is well known that sketches satisfying Definitions 2 and 3 can be constructed via importance sampling routines which select columns using carefully chosen, non-uniform probabilities. Many of these probabilities are modifications on traditional "statistical leverage scores". The statistical leverage score of the ith column ai of A is defined as4: τi def = aT i (AAT )+ai. (4) τi measures how important ai is in composing the range of A. It is maximized at 1 when ai is linearly independent from A's other columns and decreases when many other columns approximately align with ai or when kaik2 is small. Leverage scores are used in fast sketching algorithms for linear regression and matrix precondi- tioning [DMM06, Sar06, CLM+15]. They have also been applied to convex optimization [LSW15], linear programming [LS14, LS15], matrix completion [CBSW15], multi-label classification [BK13], and graph sparsification, where they are known as effective resistances [SS11]. 2.5 Existing Low-rank Leverage Scores For low-rank approximation problems, leverage scores need to be modified to only capture how important each column ai is in composing the top few singular directions of A's range. 4+ denotes the Moore-Penrose pseudoinverse of a matrix. When AAT is full rank (AAT )+ = (AAT )−1 5 In particular, it is known that a sketch C satisfying Definition 2 can be constructed by sampling d′ = O(k log k + k/ǫ) columns according to the so-called rank k subspace scores [Sar06, DMM08]: ith rank k subspace score: ss(k) i def= aT i (AkAT k )+ai. (5) These scores are exactly equivalent to standard leverage scores computed with respect to Ak, an optimal low-rank approximation for A. The stronger projection-cost preservation guarantee of Definition 3 can be achieved by sampling O(k log k/ǫ2) columns using a related, but somewhat more complex, leverage score modification [CEM+15]. 2.6 Ridge Leverage Scores Notably, prior low-rank leverage scores are defined in terms of Ak, which is not always unique and regardless can be sensitive to matrix perturbations5. As a result, the scores can change drastically when A is modified slightly or when only partial information about the matrix is known. This largely limits the possibility of quickly approximating the scores with sampling algorithms, and motivates our adoption of a new leverage score for low-rank approximation. Rather than use scores based on Ak, we employ regularized scores called ridge leverage scores, which have been used for approximate kernel ridge regression [AM15] and in work on iteratively computing standard leverage scores [LMP13, KLM+14]. We extend their applicability to low-rank approximation. For a given regularization parameter λ, define the λ-ridge leverage score as: τ λ i (A) def = aT i (AAT + λI)+ai. (6) F /k and thus, for simplicity, use "ith ridge leverage score" to refer We will always set λ = kA− Akk2 I(cid:17)+ i (cid:16)AAT + kA−Akk2 to ¯τi(A) = aT k F ai. For prior low-rank leverage scores, Ak truncates the spectrum of A, removing all but its top k singular values. Regularization offers a smooth alternative: adding λI to AAT 'washes out' small singular directions, causing them to be sampled with proportionately lower probability. This paper proves that regularization can not only replace truncation, but is more natural and F , it does not depend on a specific F changes predictably under stable. In particular, while ¯τi depends on the value of kA − Akk2 low-rank approximation. This is sufficient for stability since kA− Akk2 matrix perturbations even when Ak itself does not. Before showing our sampling guarantees for ridge leverage scores, we prove that the sum of these scores is not too large. Thus, when we use them for sampling, we will achieve column subsets and projection-cost preserving samples of small size. Specifically we have: Lemma 4. Pn i=1 ¯τi(A) ≤ 2k. Proof. We rewrite (6) using A's singular value decomposition: ¯τi(A) = aT F i UΣ2UT + kA\kk2 i (cid:0)U ¯Σ2UT(cid:1)+ ai = aT ai UUT!+ i (cid:0)U ¯Σ−2UT(cid:1) ai, k = aT 5It is often fine to use a near-optimal low-rank approximation in place of Ak, but similar instability issues remain. 6 where ¯Σ2 i,i = σ2 i (A) + kA−Akk2 F k . We then have: n Xi=1 ¯τi(A) = tr(cid:0)AT U ¯Σ−2UT A(cid:1) = tr(cid:0)VΣ ¯Σ−2ΣVT(cid:1) = tr(Σ2 ¯Σ−2) (Σ2 ¯Σ−2)i,i = σ2 i (A) kA−Ak k2 F k σ2 i (A)+ tr(Σ2 ¯Σ−2) = k + n Xi=k+1 . For i ≤ k we simply upper bound this by 1. So: = k + Pn i + kA−Akk2 σ2 kA−Akk2 ≤ k + σ2 i σ2 i n F F k k i=k+1 σ2 i kA−Akk2 F k Xi=k+1 ≤ k + k. 3 Core Sampling Results Before considering how to efficiently compute ridge leverage scores, we prove that they can be used to construct sketches satisfying the guarantees of Definitions 2 and 3. To do so, we introduce a natural intermediate guarantee (Theorem 5), from which our results on column subset selection and projection-cost preservation follow. This approach is the first to treat these guarantees in a unified way and we hope it will be useful in future work on sketching methods for low-rank approximation. Specifically, we will show that our selected columns spectrally approximate A up to additive error depending on the ridge parameter λ = kA− AkkF /k. This approximation is akin to the ubiquitous subspace embedding guarantee [Sar06] which is used as a primitive for full rank problems like linear regression and generally requires sampling Θ(d) columns. Intuitively, sampling by ridge leverage scores is equivalent to sampling by the standard leverage scores of [A,√λIn×n]. A matrix Chernoff bound can be used to show that sampling by these scores will yield C satisfying the subspace embedding property: (1 − ǫ)CCT (cid:22) AAT + λI (cid:22) (1 + ǫ)CCT . (Recall that M (cid:22) N indicates that sT Ms ≤ sT Ns for every vector s.) However, we do not actually sample columns of the identify, only columns of A. Subtracting off the identity yields the mixed additive-multiplicative bound of Theorem 5. Theorem 5 (Additive-Multiplicative Spectral Approximation). For i ∈ {1, . . . , d}, let τi ≥ ¯τi(A) be an overestimate for the ith ridge leverage score. Let pi = τi ǫ2 Pi τi for some Pi τi sufficiently large constant c. Construct C by sampling t columns of A, each set to probability pi. With probability 1 − δ, C satisfies: . Let t = c log(k/δ) ai with 1√tpi ǫ kkA − Akk2 (1 − ǫ)CCT − F In×n By Lemma 4, if each τi is within a constant factor of ¯τi(A) then C has O(cid:16) k log(k/δ) F In×n (cid:22) AAT (cid:22) (1 + ǫ)CCT + Note that Theorem 5 and our other sampling results hold for independent sampling without re- placement. A proof is included in Appendix B. (cid:17) columns. (7) ǫ2 ǫ kkA − Akk2 Proof. Following Lemma 4, we have ¯τi(A) = aT Let Y = ¯Σ−1UT (cid:0)CCT − AAT(cid:1) U ¯Σ−1. We can write t Y = Xj=1(cid:20) ¯Σ−1UT (cid:18)cjcT j − i,i = σ2 i (A) + kA\kk2 F k . i (cid:0)U ¯Σ−2UT(cid:1) ai, where ¯Σ2 AAT(cid:19) U ¯Σ−1(cid:21) def Xj=1 1 t = t [Xj] . 7 For each j ∈ 1, . . . , t, Xj is given by: t · ¯Σ−1UT (cid:18) 1 Xj = 1 pi aiaT i − AAT(cid:19) U ¯Σ−1 with probability pi. E Y = 0 since Eh 1 pi aiaT i − AATi = 0. Furthermore, CCT = U ¯ΣY ¯ΣU + AAT . Showing F kYk2 ≤ ǫ gives −ǫI (cid:22) Y (cid:22) ǫI, and since U ¯Σ2UT = AAT + kA\kk2 k I would give: (1 − ǫ)AAT − ǫkA\kk2 F k I (cid:22) CCT (cid:22) (1 + ǫ)AAT + ǫkA\kk2 F k I. After rearranging and adjusting constants on ǫ, this statement is equivalent to (7). To prove that kYk2 is small with high probability we use a stable rank (intrinsic dimension) matrix Bernstein inequality from [Tro15] that was first proven in [Min13] following work in [HKZ12]. This inequality requires upper bounds on the spectral norm of each Xj and on variance of Y. We use the fact that, for any i, I. This is a well known property of leverage scores, shown for example in the proof of Lemma 11 in [CLM+15]. It lets us bound: 1 ¯τi(A) aiaT i (cid:22) AAT + kA\kk2 k F 1 ¯τi(A) · ¯Σ−1UT aiaT i U ¯Σ−1 (cid:22) ¯Σ−1UT AAT + kA\kk2 k F I! U ¯Σ−1 = I. So we have: Xj + 1 t ¯Σ−1UT AAT U ¯Σ−1 (cid:22) Additionally, · ¯τi(A) · I (cid:22) ǫ2 c log(k/δ) I. 1 tpi · ¯τi(A) · I (cid:22) ǫ2 τi c log(k/δ)Pi τi · Pi τi c log(k/δ)Pi τi · ¯Σ−2Σ2 (cid:22) ǫ2 ǫ2 c log(k/δ) I, ¯Σ−1UT AAT U ¯Σ−1 = 1 t where the inequality follows from the fact that: Xi τi ≥Xi ¯τi(A) = tr(cid:0)AT U ¯Σ−2UT A(cid:1) = tr(cid:0)U ¯Σ−2Σ2UT(cid:1) = tr(cid:0) ¯Σ−2Σ2(cid:1) ≥ k ¯Σ−2Σ2k2. ǫ2 c log(k/δ) . Next we bound the variance of Y. Overall this gives kXjk2 ≤ 1 E(Y2) = t · E(X2 j ) = ¯Σ−1UT aiaT 1 −2 pi 1 t X(cid:20)P τi τi ǫ2 c log(k/δ) ǫ2 c log(k/δ) (cid:22) (cid:22) (cid:22) p2 i i U ¯Σ−1 ¯Σ−1UT aiaT i U ¯Σ−2UT aiaT t X pi ·(cid:18) 1 i U ¯Σ−2UT AAT U ¯Σ−1 + ¯Σ−1UT AAT U ¯Σ−2UT AAT U ¯Σ−1(cid:19) · ¯τi(A) · ¯Σ−1UT aiaT ¯Σ−1UT AAT U ¯Σ−2UT AAT U ¯Σ−1 1 t i U ¯Σ−1(cid:21) − ¯Σ−1UT AAT U ¯Σ−1 Σ2 · ¯Σ−2 (cid:22) ǫ2 c log(k/δ) D, 8 (8) where we set Di,i = 1 for i ∈ 1, . . . , k and Di,i = rank matrix Bernstein inequality given in Theorem 7.3.1 of [Tro15], for ǫ < 1, \k k2 F k σ2 i + for all i ∈ k + 1, ..., n. By the stable σ2 i kA P [kYk ≥ ǫ] ≤ 4 tr(D) kDk2 (cid:18) · e −ǫ2/2 ǫ2 c log(k/δ) (kDk2+ǫ/3)(cid:19) . (9) Clearly kDk2 = 1. Furthermore, following Lemma 4, tr(D) ≤ 2k. Plugging into (9), we see that if we choose the constant c large enough. So we have established (7). P [kYk ≥ ǫ] ≤ 8ke− c log(k/δ) 2 ) ≤ δ/2, 3.1 Projection-Cost Preserving Sampling We now use Theorem 5 to prove that sampling by ridge leverage scores is sufficient for construct- ing projection-cost preserving samples. The following theorem is a basic building block in our O(nnz(A)) time low-rank approximation algorithm. Theorem 6 (Projection-Cost Preservation). For i ∈ {1, . . . , d}, let τi ≥ ¯τi(A) be an overestimate for the ith ridge leverage score. Let pi = τi ǫ2 Pi τi for any ǫ < 1 and some Pi τi sufficiently large constant c. Construct C by sampling t columns of A, each set to probability pi. With probability 1 − δ, for any rank k orthogonal projection X, F ≤ (1 + ǫ)kA − XAk2 F . (1 − ǫ)kA − XAk2 F ≤ kC − XCk2 . Let t = c log(k/δ) ai with 1√tpi Note that the theorem also holds for independent sampling without replacement, as shown in Appendix B. By Lemma 4, when each approximation τi is within a constant factor of the true ridge leverage score ¯τi(A), we obtain a projection-cost preserving sample with t = O(k log(k/δ)/ǫ2). To simplify bookkeeping, we only worry about proving a version of Theorem 6 with (1 ± aǫ) error for some constant a, and assume ǫ ≤ 1/2. By simply adjusting our constant oversampling parameter, c, we can recover the result as stated. The challenge in proving Theorem 6 comes from the mixed additive-multiplicative error of Theorem 5. Pure multiplicative error, e.g. from a subspace embedding, or pure additive error, e.g. from a "Frequent Directions" sketch [GLPW15], are easily converted to projection-cost preservation results [Mus15], but merging the analysis is intricate. To do so, we split AAT and CCT into their projections onto the top "head" singular vectors of A and onto the remaining "tail" singular vectors. Restricted to the span of A's top singular vectors, Theorem 5 gives a purely multiplicative bound. Restricted to vectors spanned by A's lower singular vectors, the bound is purely additive. Proof. For notational convenience, let Y denote I − X, so kA − XAk2 XCk2 3.1.1 Head/Tail Split F = tr(YAAT Y) and kC − F = tr(YCCT Y). Let m be the index of the smallest singular value of A such that σ2 denote UmUT m and P\m denote U\mUT \m = I − Pm. We split: m ≥ kA − Akk2 F /k. Let Pm tr(YAAT Y) = tr(YPmAAT PmY) + tr(YP\mAAT P\mY) + 2 tr(YPmAAT P\mY) = tr(YAmAT mY) + tr(YA\mAT \mY). (10) 9 The "cross terms" involving PmA and P\mA equal 0 since the two matrices have mutually orthog- onal rows (spanned by VT m and VT \m, respectively). Additionally, we split: tr(YCCT Y) = tr(YPmCCT PmY) + tr(YP\mCCT P\mY) + 2 tr(YPmCCT P\mY) (11) In (11) cross terms do not cancel because, in general, PmC and P\mC will not have orthogonal rows, even though they have orthogonal columns. Regardless, while these terms make our analysis more difficult, we proceed with comparing corresponding parts of (10) and (11). 3.1.2 Head Terms We first bound the terms involving Pm, beginning by showing that: 1 − ǫ 1 + ǫ PmCCT Pm (cid:22) AmAT For any vector x, let y = Pmx. Note that xT AmAT and since PmPm = Pm. So, using (7) we can bound: m (cid:22) PmCCT Pm. 1 + ǫ 1 − ǫ (12) mx = yT AAT y since AmAT m = PmAAT Pm (1 − ǫ)yT CCT y − ǫkA\kk2 k F yT y ≤ xT AmAT mx ≤ (1 + ǫ)yT CCT y + ǫkA\kk2 k F yT y. (13) By our definition of m, y is orthogonal to all singular directions of A except those with squared singular value greater than or equal to kA\kk2 F /k. It follows that xT AmAT mx = yT AAT y ≥ kA\kk2 k F yT y, and accordingly, from the left side of (13), that (1− ǫ)yT CCT y ≤ (1 + ǫ)xT AmAT mx. Additionally, from the right side of (13), we have that (1 + ǫ)yT CCT y ≥ (1 − ǫ)xT AmAT mx. Since yT CCT y = xT PmCCT Pmx, these inequalities combine to prove (12). From (12) we can bound the diagonal entries of YAmAT mY in terms of the corresponding diagonal entries of YPmCCT PmY, which are all positive, and conclude that: 1 − ǫ 1 + ǫ tr(YPmCCT PmY) ≤ tr(YAmAT mY) ≤ 1 + ǫ 1 − ǫ tr(YPmCCT PmY). Assuming ǫ < 1/2, this is equivalent to: (1 − 4ǫ) tr(YAmAT mY) ≤ tr(YPmCCT PmY) ≤ (1 + 4ǫ) tr(YAmAT m). (14) 3.1.3 Tail Terms For the lower singular directions of A, Theorem 5 does not give a multiplicative spectral approxi- mation, so we do things a bit differently. Specifically, we start by noting that: tr(YA\mAT \mY) = tr(A\mAT \m) − tr(XA\mAT \mX) and tr(YP\mCCT P\mY) = tr(P\mCCT P\m) − tr(XP\mCCT P\mX). We handle tr(A\mAT via an unbiased sampling of A's columns, E(cid:2)kP\mCk2 F and tr(P\mCCT P\m) = kP\mCk2 F(cid:3) = kA\mk2 \m) = kA\mk2 F first. Since C is constructed F and a scalar Chernoff bound 10 is sufficient for showing that this value concentrates around its expectation. Our proof is included as Lemma 20 in Appendix A and implies the following bound: F ≤ tr(A\mAT −ǫkA\kk2 \mX) to tr(XP\mCCT P\mX). We first claim that: Next, we compare tr(XA\mAT 4ǫ 4ǫ k kA\kk2 k kA\kk2 \m) − tr(P\mCCT P\m) ≤ ǫkA\kk2 F . \m (cid:22) P\mCCT P\m + P\mCCT P\m − F I (cid:22) A\mAT F I. (15) (16) The argument is similar to the one for (12). For a vector x, let y = P\mx. xT A\mAT yT AAT y since A\mAT \m = P\mAAT P\m and since P\mP\m = P\m. Applying (7) gives: \mx = (1 − ǫ)yT CCT y − ǫkA\kk2 \mx ≤ (1 + ǫ)yT CCT y + ǫkA\kk2 k Noting that yT y ≤ xT x and assuming ǫ ≤ 1/2 gives the following two inequalities: yT y ≤ xT A\mAT k F F yT y. F k yT CCT y − 2ǫkA\kk2 (1 − 2ǫ)xT A\mAT \mx ≤ kA\kk2 xT x ≤ (1 + 2ǫ)xT A\mAT \mx, \mx ≤ yT CCT y + 2ǫkA\kk2 xT x. So, substituting y with P\mx and rearranging Now, since X is a rank k projection matrix, it can be written as X = ZZT where Z ∈ Rn×k is By our choice of m, xT A\mAT (17) and (18) gives (16). a matrix with k orthonormal columns, z1, . . . , zk. By cyclic property of the trace, xT x. (17) (18) k F F k tr(XA\mAT \mX) = tr(ZT A\mAT \mZ) = k Xi=1 zT i A\mAT \mzi. Similarly, tr(XP\mCCT P\mX) =Pk tr(XP\mCCT P\mX) − 4ǫkA\kk2 i=1 zT i P\mCCT P\mzi and we conclude from (16) that: \mX) ≤ tr(XP\mCCT P\mX) + 4ǫkA\kk2 F , F ≤ tr(XA\mAT which combines with (15) to give the final bound: tr(YA\mAT \mY) − 5ǫkA\kk2 F ≤ tr(YP\mCCT P\mY) ≤ tr(YA\mAT \mY) + 5ǫkA\kk2 F . (19) 3.1.4 Cross Terms Finally, we handle the cross term 2 tr(YPmCCT P\mY). We do not have anything to compare this term to, so we just need to show that it is small. To do so, we rewrite: tr(YPmCCT P\mY) = tr(YAAT (AAT )+PmCCT P\m), (20) which is an equality since the columns of PmCCT P\m fall in the span of A's columns. We eliminate the trailing Y using the cyclic property of the trace. hM, Ni = tr(M(AAT )+NT ) is a semi-inner 11 product since AAT is positive semidefinite. Thus, by the Cauchy-Schwarz inequality, tr(YAAT (AAT )+PmCCT P\m) ≤ To bound the second term, we separate: qtr(YAAT (AAT )+AAT Y) · tr(P\mCCT Pm(AAT )+PmCCT P\m) =qtr(YAAT Y) · tr(P\mCCT UmΣ−2 mCCT P\m) =qtr(YAAT Y) ·qkP\mCCT UmΣ−1 m k2 F . m UT kP\mCCT UmΣ−1 m k2 F = kP\mCCT uik2 2σ−2 i . m Xi=1 (21) (22) (23) We next show that the summand is small for every i. Take pi to be a unit vector in the direction of CCT ui's projection onto P\m. I.e. pi = P\mCCT ui/kP\mCCT uik2. Then: kP\mCCT uik2 Now, suppose we construct the vector m =(cid:16)σ−1 (1 − ǫ)mT CCT m − which expands to give: 2 = (pT i CCui)2. i ui + ǫkA\kk2 F k √k pi(cid:17). From (7) we know that: kA\kkF mT m ≤ mT AAT m, (1 − ǫ)σ−2 i uT σ−2 i uT i AAT ui + k i CCT ui + (1 − ǫ) ǫkA\kk2 k + F F kA\kk2 mT m = 1 + kA\kk2 F k k kA\kk2 F i CCT pi + (1 − ǫ) pT i CCT ui ≤ pT 2√k σikA\kkF pT i AAT pi + mT m. (24) ǫkA\kk2 F k There are no cross terms on the right side because pi lies in the span of U\m and is thus orthogonal to ui over AAT . Now, from (12) we know that uT i . From (16) we also know that pT i AAT ui ≥ (1− 2ǫ)σ2 i CCT ui ≥ (1− 2ǫ)uT . Plugging into (28) gives: F i AAT pi − 4ǫkA\kk2 k pT i AAT pi − 4ǫ + (1 − ǫ) 2√k σikA\kkF pT i CCT ui (25) i CCT pi ≥ pT i AAT ui + (1 − ǫ) i uT (1 − 3ǫ)σ−2 k ≤ 1 + F pT i AAT pi + kA\kk2 i AAT pi ≤ kA\kk2 2√k k F k F kA\kk2 ǫkA\kk2 F k mT m. (1 − ǫ) σikA\kkF i CCT ui ≤ 8ǫ + pT The second inequality follows from the fact that σ−1 again that ǫ ≤ 1/2 gives our final bound: i ≤ Noting that pT since pi lies in the column span of U\m, rearranging (25) gives: ǫkA\kk2 F k √k kA\kkF mT m ≤ 12ǫ. so kmk2 2 ≤ (cid:16) 2√k kA\kkF(cid:17)2 . Assuming (26) √k σikA\kkF (piCCT uT i )2 ≤ 144ǫ2 σ2 piCCT uT i ≤ 12ǫ i kA\kk2 F . k 12 Plugging into (22) gives: m kP\mCCT UmΣ−1 m k2 F ≤ Xi=1 144ǫ2 σ2 i kA\kk2 F k σ−2 i ≤ 288ǫ2kA\kk2 F . (27) (28) Note that we get an extra factor of 2 because m ≤ 2k. Returning to (21), we conclude that: tr(YAAT (AAT )+PmCCT P\m) ≤qtr(YAAT Y) ·q288ǫ2kA\kk2 F ≤ 17ǫ tr(YAAT Y). The last inequality follows from the fact that kA\kk2 approximation to A. tr(YAAT Y) = kA−XAk2 3.1.5 Final Bound F ≤ tr(YAAT Y) since A\k is the best rank k F is the error of a suboptimal rank k approximation. Ultimately, from(11), (14), (19), and (28), we conclude: (1 − 4ǫ) tr(YAmAT mY) + tr(YA\mAT ≤ (1 + 4ǫ) tr(YAmAT \mY) − 5ǫkA\kk2 m) + tr(YA\mAT F − 34ǫ tr(YAAT Y) ≤ tr(YCCT Y) F + 34 tr(YAAT Y). \mY) + 5ǫkA\kk2 Applying the fact that kA\kk2 3.2 Column Subset Selection F ≤ tr(YAAT Y) proves Theorem 6 for a constant factor of ǫ. Although not required for our main low-rank approximation algorithm, we also prove that ridge leverage score sampling can be used to obtain (1 + ǫ) error column subsets (Definition 2). The column subset selection problem is of independent interest and the following result allows ridge leverage scores to be used in our single-pass streaming algorithm for this problem (Section 6). Theorem 7. For i ∈ {1, . . . , d}, let τi ≥ ¯τi(A) be an overestimate for the ith ridge leverage score. (cid:17)Pi τi for ǫ < 1 and some sufficiently large constant c. Let pi = τi Pi τi Construct C by sampling t columns of A, each set to ai with probability pi. With probability 1 − δ: . Let t = c(cid:16)log k + log(1/δ) ǫ kA −(cid:0)CC+A(cid:1)k k2 F ≤ (1 + ǫ)kA − Akk2 F . Furthermore, C contains a subset of O (Pi τi/ǫ) columns that satisfies Definition 2 and can be identified in polynomial time. Note that (CC+A)k is a rank k matrix in the column span of C, so Theorem 7 implies that C is a (1 + ǫ) error column subset according to Definition 2. By Lemma 4, if each τi is within a constant factor of ¯τi(A), the approximate ridge leverage scores sum to O(k) so Theorem 7 gives a column subset of size O (k log k + k/ǫ), which contains a near optimally sized column subset with O (k/ǫ) columns. Again, the theorem also holds for sampling without replacement (see Appx. B). Our proof relies on establishing a connection between ridge leverage sampling and well known adaptive sampling techniques for column subset selection [DRVW06, DV06]. We start with the following lemma on adaptive sampling for column subset selection: Lemma 8 (Theorem 2.1 of [DRVW06]). Let C be any subset of A's columns and let Z be If we sample an additional set S of an orthonormal matrix whose columns span those of C. 2, then O(cid:16) k log(1/δ) [S ∪ C] is a (1 + ǫ) error column subset for A with probability (1 − δ). 6 (cid:17) columns from A with probability proportional to k(A − ZZT A)ik2 · kA−ZZT Ak2 kA\kk2 F F ǫ 6Theorem 2.1 was originally stated as an expected error result, but it can be seen to hold with constant probability via Markov's inequality and accordingly with (1 − δ) probability when oversampling by a factor of log(1/δ) 13 When C is a constant error column subset, then kA − ZZT Ak2 F = O(kA\kk2 F ) and accordingly we only need O(k log(1/δ)/ǫ) additional adaptive samples. So one potential algorithm for column subset selection is as follows: apply Theorems 5 and 6, sampling O(k log(k/δ)) columns by ridge leverage score to obtain a constant error projection-cost preserv- ing sample, will also be a constant error column subset. Then sample O(k log(1/δ)/ǫ) additional columns adaptively against C. F ≤ kA − (ZZT A)kk2 However, it turns out that ridge leverage scores well approximate adaptive sampling probabil- ities computed with respect to any constant error additive-multiplicative spectral approximation satisfying Theorem 5! That is, surprisingly, they achieve the performance of adaptive sampling without being adaptive at all. Simply sampling O(k log(1/δ)/ǫ) more columns by ridge leverage score and invoking Lemma 8 suffices to achieve (1 + ǫ) error. Proof of Theorem 7. We formally prove that C is itself a good column subset before showing our stronger guarantee, that it also contains a column subset of optimal size, up to constants. 3.2.1 Primary Column Subset Selection Guarantee We split our sample C, into C1, which contains the first c log(k/δ)Pi τi columns and C2, which contains the next c log(1/δ)/ǫPi τi columns. Note that in our final sample complexity the log(1/δ) factor in the size of C1 is not shown as it is absorbed into the larger size of C2 when log(1/δ) > log(k) and into the log(k) otherwise. By Theorem 6, we know that, appropriately reweighted, C1 is a constant error projection-cost preserving sample of A. This means that C1 is also a constant error column subset. Let Z be an orthonormal matrix whose columns span the columns of C1. To invoke Lemma 8 to boost C1 to a (1 + ǫ) column subset, we need to sample columns with probabilities proportional to k(A − ZZT A)ik2 i ai − 2aT i ZZT )(ai − ZZT ai) = aT (aT i − aT 2. This is equivalent to sampling proportional to: i ZZT ai + aT i ZZT ZZT ai = aT i (cid:0)I − ZZT(cid:1) ai. We can assume kA\kk2 F > 0 or else C1 must fully span A's columns and we're done. Scaling ¯τi(A): kA\kk2 F k ¯τi(A) = aT i k kA\kk2 F AAT + I!+ ai. Since C1 satisfies Theorem 5 with constant error, for large enough constant c1, F k kA\kk2 AAT + I (cid:22) c1 k kA\kk2 Furthermore, I − ZZT (cid:22)(cid:0)I + cZZT(cid:1)+ AAT + I!+ c1 k kA\kk2 F F C1CT 1 + I! (cid:22) c1 I + kkC1CT 1 k2 kA\kk2 F ZZT! . for any positive c so, (cid:23) I + kkC1CT 1 k2 kA\kk2 F ZZT!+ (cid:23) I − ZZT . So c1kA\kk2 F k ¯τi(A) ≥ k(A − ZZT A)ik2 2 for all i and hence c1kA\kk2 F k τi ≥ k(A − ZZT A)ik2 2. C2 is a set of c log(1/δ)/ǫ·Pi τi columns sampled with probability proportional to approximate ridge leverage scores. Consider forming C′2 by setting (C2)i = 0 with probability: k(A − ZZT A)j(i)k2 2 , c1kA\kk2 F k τj(i) 14 where j(i) is just the index of the column of A that (C2)i is equal to. Clearly, if not equal to 0, each column of C′2 is equal to ai with probability proportional to the adaptive sampling probability k(A − ZZT A)ik2 2. Additionally, in expectation, the number of nonzero columns will be: c log(1/δ)/ǫ ·Xi τi! ·Xj   τj Pi τi k(A − ZZT A)jk2 2 c1kA\kk2 F k τj = ck log(1/δ) c1ǫ · kA − ZZT Ak2 kA\kk2 F F .   By a Chernoff bound, with probability 1 − δ/2 at least half this number of columns will be nonzero, and by Lemma 8, for large enough c, conditioning on the above column count bound holding, [C1 ∪ C′2] is a (1 + ǫ) error column subset for A with probability 1− δ/2. Just noting that span([C1 ∪ C′2]) ⊆ span([C1 ∪ C2]) and union bounding over the two possible fail conditions, gives that [C1 ∪ C2] = C is a (1 + ǫ) column subset with probability at least 1 − δ. 3.2.2 Stronger Containment Guarantee It now remains to show the second condition of Theorem 7: C contains a subset of O(Pi τi/ǫ) columns that also satisfies Definition 2. This follows from noting that we can apply, for example, the polynomial time deterministic column selection algorithm of [CEM+15] to produce a matrix C′1 with O(k) columns that is both a constant error additive-multiplicative spectral approximation and a constant error projection-cost preserving sample for C1. If C′1 has constant error for C1, it does for A as well and so is a constant error column subset. C2 contains O(log(1/δ)) sets of O(Pi τi/ǫ) columns, C1 above, for each Ci probability 1− δ, at least one [C′1, Ci columns, giving the theorem. 2, [C′1, Ci . By our argument 2] is a (1+ ǫ) error column subset of A with constant probability. So with 2, . . . , CO(log(1/δ)) 2, C2 2 2] is good. This set contains just O(k +Pi τi/ǫ) = O(Pi τi/ǫ) 4 Monotonicity of Ridge Leverage Scores With our main sampling results in place, we focus on the algorithmic problem of how to efficiently approximate the ridge leverage scores of a matrix A. In the offline setting, we will show that these scores can be approximated in O(nnz(A)) time using a recursive sampling algorithm. We will also show how to compute and sample by the scores in a single-pass column stream. Both of these applications will require a unique stability property of the ridge leverage scores: Lemma 9 (Ridge Leverage Score Monotonicity). For any A ∈ Rn×d and vector x ∈ Rn, for every i ∈ 1, . . . , d we have: ¯τi(A) ≤ ¯τi(A ∪ x), where A ∪ x is simply A with x appended as its final column. This statement is extremely natural, given that leverage scores are meant to be a measure of importance. It ensures that the importance of a column can only decrease when additional columns are added to A. While it holds for standard leverage scores, surprisingly no prior low-rank leverage scores satisfy this property. We begin by defining the generalized ridge leverage score as the ridge leverage score of a column estimated using a matrix other than A itself. 15 Definition 10 (Generalized Ridge Leverage Score). For any A ∈ Rn×d and M ∈ Rn×d′ generalized ridge leverage score of A with respect to M is defined as: , the ith ¯τ M i (A) = i (cid:16)MMT + kM−Mkk2 aT ∞  k F ai I(cid:17)+ for ai ∈ span(cid:16)MMT + kM−Mkk2 otherwise. k F I(cid:17) This definition is the intuitive one. Since our goal is typically to compute over-estimates of ¯τi(A) using M, if ai does not fall in the span of MMT + kM−Mkk2 I we conservatively set its generalized leverage score to ∞ instead of 0. Note that this case only applies when M is rank k and thus kM−Mkk2 I is 0. k F F k We now prove a general monotonicity theorem, from which Lemma 9 follows immediately by setting M = A and A = A ∪ x. Theorem 11 (Generalized Monotonicity Bound). For any A ∈ Rn×d and M ∈ Rn×d′ AAT we have: with MMT (cid:22) Proof. We first note that kM − Mkk2 top k column singular vectors of A, by the optimality of Mk we have: F since, letting Pk be the projection onto the i (A). ¯τi(A) ≤ ¯τ M F ≤ kA − Akk2 kM − Mkk2 F ≤ k(I − Pk)Mk2 F ≤ k(I − Pk)Ak2 F = kA − Akk2 F . Accordingly, MMT + kM − Mkk2 F k I (cid:22) AAT + kA − Akk2 k F I. Let R be a projection matrix onto the column span of MMT + kM−Mkk2 matrices B and C with the same column span, B (cid:22) C implies B+ (cid:23) C+ (see [MA77]) we have: I. Since for any PSD k F R(cid:18)MMT + kM − Mkk2 I(cid:19)+ For any ai not lying in span(cid:16)MMT + kM−Mkk2 Otherwise, we have Rai = ai and so: k F k ¯τi(A) = aT i R(cid:18)AAT + kA − Akk2 k F I(cid:19)+ Rai ≤ aT I(cid:19)+ R. F F k R (cid:23) R(cid:18)AAT + kA − Akk2 I(cid:17), ¯τ M i R(cid:18)MMT + kM − Mkk2 k F I(cid:19)+ Rai = ¯τ M i (A). i (A) = ∞ and the theorem holds trivially. This gives the theorem. 5 Recursive Ridge Leverage Score Approximation With Theorem 11 in place, we are ready to prove that ridge leverage scores can be approximated in O(nnz(A)) time. Our work closely follows [CLM+15], which shows how to approximate traditional leverage scores via recursive sampling. 16 5.1 Intuition and Preliminaries The central idea behind recursive sampling is as follows: if we uniformly sample, for example, 1/2 of A's columns to form C and compute ridge leverage score estimates with respect to just these columns, by monotonicity, the estimates will upper bound A's true ridge leverage scores. While some of these upper bounds will be crude, we can show that their overall sum is small. Accordingly, we can use the estimates to sample O(k log k) columns from A to obtain a constant factor additive-multiplicative spectral approximation by Theorem 5, as well as a constant factor projection-cost preserving sample by Theorem 6. This approximation is enough to obtain constant factor estimates of the ridge leverage scores of A. C may still be relatively large (e.g. half the size of A), but it can be recursively approximated via the same sampling scheme, eventually giving our input sparsity time algorithm. We first give a foundational lemma showing that an approximation of the form given by Theo- rems 5 and 6 is enough to give constant factor approximations to ridge leverage scores. Lemma 12. Assume that, for an ǫ ≤ 1/2, we have C satisfying equation (7) from Theorem 5: ǫ kkA − Akk2 along with equation (3) from Definition 3: (1 − ǫ)CCT − F I (cid:22) AAT (cid:22) (1 + ǫ)CCT + ǫ kkA − Akk2 F I, (1 − ǫ)kA − XAk2 F ≤ kC − XCk2 F ≤ (1 + ǫ)kA − XAk2 F , ∀ rank k X. Then for all i, (1 − 4ǫ)¯τi(A) ≤ ¯τ C i (A) ≤ (1 + 4ǫ)¯τi(A). Proof. Let Pk be the projection onto A's top k column singular vectors. By the optimality of Ck in approximating C and the projection-cost preservation condition, we know that kC − Ckk2 F ≤ F . Also, letting Pk be the projection onto C's top k column singular kC−PkCk2 vectors, we have (1 − ǫ)kA − Akk2 F ≤ (1 − ǫ)kA − PkAk2 F ≤ (1+ǫ)kA−Akk2 F ≤ kC − Ckk2 F . So overall: (1 − ǫ)kA − Akk2 F ≤ kC − Ckk2 F ≤ (1 + ǫ)kA − Akk2 F . (29) Using the guarantee from Theorem 5 we have: (1 − ǫ)kA − Akk2 (1 − ǫ)CCT + Combining with our bound on kC − Ckk2 k F I (cid:22) AAT + kA − Akk2 k F F gives: (1 − ǫ)CCT + (1−ǫ) (1+ǫ)kC − Ckk2 F k I (cid:22) AAT + kA − Akk2 k F and when ǫ ≤ 1/2, we can simplify to: (1 − 4ǫ)(cid:18)CCT + kC − Ckk2 If kA− Akk2 k F I(cid:19) (cid:22) AAT + kA − Akk2 k F I (cid:22) (1 + ǫ)CCT + I (cid:22) (1 + ǫ)CCT + (1 + ǫ)kA − Akk2 F k I. (1+ǫ) (1−ǫ)kC − Ckk2 F k I, I (cid:22) (1 + 4ǫ)(cid:18)CCT + kC − Ckk2 k F I(cid:19) . F = 0, then A and C must have the same column span or else it could not hold that (1 − 4ǫ)CCT (cid:22) AAT (cid:22) (1 + 4ǫ)CCT . On the other hand, if F = 0, and thus by (29) kC− Ckk2 17 kA − Akk2 k span all of Rn. Either way, the two matrices have the same span and so by [MA77] we have: F > 0, and thus by (29) kC − Ckk2 F > 0, both AAT + kA−Akk2 I and CCT + kC−Ckk2 k F F I (1 − 4ǫ) AAT + kA\kk2 k F I!+ (cid:22) CCT + kC\kk2 k F I!+ (cid:22) (1 + 4ǫ) AAT + kA\kk2 k F I!+ , which gives the lemma. Our next lemma, which is analogous to Theorem 2 of [CLM+15], shows that by reweighting a small number of columns in A, we can obtain a matrix with all ridge leverage scores bounded by a small constant, which ensures that it can be well approximated by uniform sampling. Lemma 13 (Ridge Leverage Score Bounding Column Reweighting). For any A ∈ Rn×d and any score upper bound u > 0, there exists a diagonal matrix W ∈ Rd×d with 0 (cid:22) W (cid:22) I such that: and ∀i, ¯τi (AW) ≤ u, {i : Wii 6= 1} ≤ 3k u . (30) (31) Proof. This result follows from Theorem 2 of [CLM+15], to which we refer the reader for details. To show the existence of a reweighting W satisfying (30) and (31), we will argue that a simple iterative process (which we never actually need to implement) converges on the necessary reweighting. 1AT + k(AW1)\kk2 Specifically, if a column has too high of a leverage score, we simply decrease its weight until ¯τi(AW) ≤ u. We want to argue that, given AW0 with ¯τi(AW0) > u, we can decrease the weight on ai to produce W1 with ¯τi(AW1) ≤ u. By Lemma 5 of [CLM+15] we can always decrease the weight on ai to ensure τi(AW1) ≤ u, where τi(·) is the traditional leverage score. And since (cid:16)AW2 , ¯τi(AW1) ≤ τi(AW1), so an equivalent or smaller Furthermore, we can see that ¯τi(AW) is continuous with respect to W. This is due to the fact that both the traditional leverage scores of AW (shown in Lemma 6 of [CLM+15]) and k(AW)\kk2 F are continuous in W. From Theorem 2 of [CLM+15], continuity implies that iteratively reweighting individual columns converges, and thus there is always exists a reweighting satisfying (30). weight decrease suffices to decrease ¯τi(AW1) below u. (cid:22) (cid:0)AW2 1AT(cid:1)+ I(cid:17)+ k F It remains to show that this reweighting satisfies (31). By continuity, we can always decrease ¯τi(AW0) to exactly u unless ¯τi(AW) = 1, in which case the only option is to set the weight on the column to 0 and hence set ¯τi(AW) = 0. However, if kA\kk2 F > 0, then every ridge leverage score is strictly less than 1. If kA\kk2 F = 0, then A has rank k, the ridge leverage scores are the same as the true leverage scores, and the number of columns with leverage score 1 is at most k. Therefore, by Theorem 2 of [CLM+15], monotonicity, and the fact that Pi ¯τi(AW) ≤ 2k for any W, we have the lemma. 5.2 Uniform Sampling for Ridge Leverage Score Approximation Using Lemmas 12 and 13 we can prove the key step of our recursive sampling method: if we uniformly sample columns from A and use them to estimate ridge leverage scores, these scores can be used to resample a set of columns that give constant factor ridge leverage scores approximations. 18 Theorem 14 (Ridge Leverage Score Approximation via Uniform Sampling). Given A ∈ Rn×d, construct Cu by independently sampling each column of A with probability 1 2 . Let τi = minn1, ¯τ Cu i (A)o . If we form C by sampling each column of A independently with probability pi = min{1, τic1 log(k/δ)} and reweighting by 1/√pi if selected, then for large enough constant c1, with probability 1 − δ, C will have just O(k log(k/δ)) columns and will satisfy the conditions of Lemma 12 for some constant error. Accordingly, we have: 1 2 ¯τi(A) ≤ ¯τ C i (A) ≤ 2¯τi(A). Proof. Clearly CuCT u (cid:22) AAT , so by the monotonicity shown in Theorem 11 we have ¯τ Cu (A) ≥ ¯τi(A). Since ¯τi(A) is always ≤ 1, it follows that τi = minn1, ¯τ Cu (A)o ≥ ¯τi(A). Then we can just use the τi's obtained from Cu in independent sampling versions of Theorems 5 and 6, which can be proven from Lemmas 21 and 22 in Appendix B. Accordingly, with probability 1 − δ/3, C gives a constant factor additive-multiplicative spectral approximation and projection-cost preserving sample of A. Hence by Lemma 12, ¯τ C i (A) is a constant factor approximation to ¯τi(A). Its To prove the theorem, we still have to show that C does not have too many columns. i i expected number of columns is: Xi pi =Xi min{1, τic1 log(k/δ)} . By Lemma 13 instantiated with u = with only 3k · 2c2 log(k/δ) entries not equal to 1 such that ¯τi(AW) ≤ 2c2 log(k/δ) , we know that there is some reweighting matrix W 2c2 log(k/δ) for all i. We have: 1 1 Xi i pi pi + Xi:Wii=1 pi = Xi:Wii6=1 ≤ 6kc2 log(k/δ) + Xi:Wii=1 c log(k/δ) · ¯τ Cu = 6kc2 log(k/δ) + c1 log(k/δ) · Xi:Wii=1 ¯τ Cu i ≤ 6kc2 log(k/δ) + c1 log(k/δ) · Xi:Wii=1 ≤ 6kc2 log(k/δ) + c1 log(k/δ) ·Xi ¯τ CuW i (A) (AW) ¯τ CuW i (AW) (AW). (32) Now, since every ridge leverage score of AW is bounded by 2c2 log(k/δ) , if c2 is set large enough, the uniformly sampled CuW is a proper ridge leverage score oversampling of AW, except that its columns were not reweighted by a factor of 2 (they were each sampled with probability 1/2). 1 12 for AW with ǫ = 1/2. Thus, for all i, 1 Accordingly, with probability 1 − δ/3, 2CuW satisfies the approximation conditions of Lemma (AW) ≤ 3¯τi(AW). By Lemma 4, Pi ¯τi(AW) ≤ 2k so overall Pi ¯τ CuW (AW) ≤ 12k. Plugging back in to (32), we conclude that C has O(k log(k/δ)) columns in expectation, and actually with probability 1 − δ/3 by a Chernoff bound. Union bounding over our failure probabilities gives the theorem. (AW) = ¯τ 2CuW 2 ¯τ CuW i i i 19 5.3 Basic Recursive Algorithm Theorem 14 immediately proves correct Algorithm 1 for ridge leverage score approximation: Algorithm 1 Repeated Halving input: A ∈ Rn×d output: A reweighted column sample C ∈ Rn×O(k log(k/δ)) satisfying the guarantees of Theorems 5 and 6 with constant error. 1: Uniformly sample d 2: If Cu has > O(k log k) columns, recursively apply Repeated Halving to compute a constant 2 columns of A to form Cu factor approximation Cu for Cu with O(k log k) columns. 3: Compute generalized ridge leverage scores of A with respect to Cu 4: Use these estimates to sample columns of A to form C 5: return C Note that, by Lemma 12, generalized ridge leverage scores computed with respect to Cu are constant factor approximations to generalized ridge leverage scores computed with respect to Cu. Accordingly, by Theorem 14, we conclude that C is a valid ridge leverage score sampling of A. Before giving our full input sparsity time result, we warm up with a simpler theorem that obtains a slightly suboptimal runtime. Lemma 15. A simple implementation of Algorithm 1 that succeeds with probability 1 − δ runs in O (nnz(A) log(d/δ)) + O(nk2) time. For clarity of exposition, we use O(·) to hide log factors in k, d, and 1/δ on the lower order term. Proof. The algorithm has log(d/k) levels of recursion and, since we sample our matrix uniformly, nnz(A) is cut approximately in half at each level, with high probability. It thus suffices to show that the work done at the top level is O (nnz(A) log(d/δ)) + O(nk2). To compute the generalized ridge leverage scores of A with respect to Cu we must (approxi- mately) compute, for each ai, aT i Cu CT u + k Cu − ( Cu)kk2 F k I!+ ai. (33) We are going to ignore that (cid:16) Cu CT thus ideal for iterative solvers) and use direct methods for simplicity. Let λ denote k Cu−( Cu)kk2 F k singular vectors of Cu. We can rewrite: F k u + k Cu−( Cu)kk2 I(cid:17) could be sparse and well conditioned (and and let R ∈ Rn× O(k) be an orthonormal basis containing the left (cid:16) Cu CT u + λI(cid:17) = Cu CT u + λRRT + λ(cid:0)I − RRT(cid:1) , and accordingly, using the fact that RRT and (I − RRT ) are orthogonal, λ(cid:0)I − RRT(cid:1) . u + λRRT(cid:17)+ u + λI(cid:17)+ =(cid:16) Cu CT (cid:16) Cu CT + 1 20 Now, using an SVD of Cu, which can be computed in O(nk2) time, we compute λ and then O(k)× O(k). Accordingly, to write (cid:16) Cu CT evaluate (33), we need just need to compute: u + λRRT(cid:17)+ i (cid:18)RΣ−2RT + aT as RΣ−2RT for some diagonal matrix Σ ∈ R λ(cid:0)I − RRT(cid:1)(cid:19) ai = k(cid:18)RT Σ−1RT + 1 1 √λ(cid:0)I − RRT(cid:1)(cid:19) aik2 2. Since R has O(k) columns, naively evaluating this norm for all of A's columns would require a total of O(nnz(A)k) time. However, we can accelerate the computation via a Johnson-Lindenstrauss embedding technique that has become standard for computing regular leverage scores [SS11]. Specifically, denoting (cid:16)RT Σ−1RT + 1√λ(cid:0)I − RRT(cid:1)(cid:17) as M, we can embed M's columns into O(log(d/δ)) × n dimensions by multiplying on the left by a matrix Π ∈ RO(log(d/δ)×n with scaled random Gaussian or random sign entries. Even though M is n×n, we can perform the multiplication in O(nk log(d/δ)) by working with our factored form of the matrix. 2 will be within a constant factor of kMaik2 2 for all ai in O (nnz(A) log(d/δ)) total time. Our final cost for approximating all ridge leverage scores is thus O (nnz(A) log(d/δ)) + O(cid:0)nk2(cid:1) time, which gives the lemma. 2 for all i with probability 1 − δ. Furthermore, we can evaluate kΠMaik2 By standard Johnson-Lindenstrauss results, kΠMaik2 5.4 True Input-Sparsity Time Sharpening Lemma 15 to eliminate log factors on the nnz(A) runtime term requires standard optimizations for approximating leverage scores with respect to a subsample [LMP13, CLM+15]. In particular, we can actually apply a Johnson-Lindenstrauss embedding matrix to M with just θ−1 rows for some small constant θ. Doing so will approximate each ridge leverage score to within a factor of dθ with high probability (see Lemma 4.5 of [LMP13] for example). This level of approximation is sufficient to resample O(cid:0)kdθ log(k/δ)(cid:1) columns from A to form an approximation C′ that satisfies the guarantees of Theorems 5 and 6. To form C, we further sample C′ down to O(k log(k/δ)) columns using its ridge leverage scores, which takes O(nk2d2θ) time. Finally, under the reasonable assumption that ǫ and δ are poly(n), we can also assume d = poly(n). Otherwise, nnz(A) ≥ d dominates the O(nk2d2θ) term. This yields the following: Lemma 16. An optimized implementation of Algorithm 1, succeeding with probability 1 − δ, runs in time O(cid:0)θ−1 nnz(A)(cid:1) + O(n1+θk2) time, for any θ ∈ (0, 1]. Once we have used Algorithm 1 to obtain C satisfying the guarantees of Theorems 5 and 6 with constant error, we can approximate A's ridge leverage scores and resample one final time to obtain an ǫ error projection-cost preserving sketch. This immediately yields our main algorithmic result: Theorem 1. For any θ ∈ (0, 1], there exists an iterative column sampling algorithm that, in time O(cid:0)θ−1 nnz(A)(cid:1) + O(cid:16) n1+θk2 ǫ4 (cid:17), returns Z ∈ Rn×k satisfying: (34) kA − ZZT Ak2 F ≤ (1 + ǫ)kA − Akk2 F . All significant linear algebraic operations of the algorithm involve matrices whose columns are sub- sets of those of A, and thus inherit any structure from the original matrix, including sparsity. Proof. We use the same technique as Lemma 16, but in the last round of sampling we select O(cid:16) knθ/2 log(k/δ) to the top k column singular vectors of C, which takes O(n1+θk2/ǫ4) time, gives (34) [CEM+15]. (cid:17) columns to obtain an O(ǫ) factor projection-cost preserving sample, C. Setting Z ǫ2 21 6 Streaming Ridge Leverage Score Sampling We conclude with an application of our results to novel low-rank sampling algorithms for single- pass column streams. While random projection algorithms work naturally in the streaming set- ting, the study of single-pass streaming column sampling has been limited to the "full-rank" case [KL13, CMP15, KLM+14]. Column subset selection algorithms based on simple norm sampling are adaptable to streams, but do not give relative error approximation guarantees [DKM06a, FKV04]. Relative error algorithms are obtainable by combining our projection-cost preserving sampling procedures with the "merge-and-reduce" framework for coresets [BS80, AHPV04, HPM04]. This approach relies on the composability of projection-cost preserving samples: a (1 + ǫ) error sample for A unioned with a (1 + ǫ) error sample for B gives a (1 + ǫ) error sample for [A, B] [FSS13]. However, merge-and-reduce requires storage of O(log4 dk/ǫ2) scaled columns from A, where d is the length of our stream (and its value is known ahead of time). Our algorithms eliminate the logc d stream length dependence, storing a fixed number of columns that only depends on ǫ and k. We note that our space bounds are given in terms of the number of real numbers stored. We do not bound the required precision of these numbers, which would include at least a single logarithmic dependence on d. In particular, we employ a Frequent Directions sketch that requires words with at least Θ(log(nd)) bits of precision. Rigorously bounding maximum word- size required for Frequent Directions and our algorithms could be an interesting direction for future work. 6.1 General Approach The basic idea behind our algorithms is quite simple and follows intuition from prior work on standard leverage score sampling [KL13]. Suppose we have some space budget t for storing a column sample C. As soon as we have streamed in t columns, we can downsample by ridge leverage scores to say t/2 columns. As more columns are received, we will eventually reach our storage limit and need to downsample columns again. Doing so naively would compound error: if we resampled r times, our final sample would have error (1 + ǫ)r. However, we can avoid compounding error by exploiting Lemma 9, which ensures that, as new columns are added, the ridge leverage scores of columns already seen only decrease. Whenever we add a column to C, we can record the probability it was kept with. In the next round of sampling, we only discard that column with probability equal to the proportion that its ridge leverage score decreased by (or keep the column with probability 1 if the score remained constant). New columns are simply sampled by ridge leverage score. This process ensures that, at any point in the stream, we have a set of columns sampled by true ridge scores with respect to the matrix seen so far. Accordingly, we will have a (1 + ǫ) error column subset or projection-cost preserving sample at the end of the stream. This overview hides a number of details, the most important of which is how to compute ridge leverage scores at any given point in the stream with respect to the columns of A observed so far. We do not have direct access to these columns since we have only stored a subset of them. We could use the fact that our current sample is projection-cost preserving and can be used to approximate ridge leverage scores (see Lemma 12). However, this approach would introduce sampling dependencies between columns and would require a logarithmic dependence on stream length to ensure that our approximation does not fail at any round of sampling. 22 6.2 Frequent Directions for Approximating Ridge Leverage Scores Instead, we use a constant error deterministic "Frequent Directions" sketch to estimate ridge lever- age scores. Introduced in [Lib13] and further analyzed in a series of papers culminating with [GLPW15], Frequent Directions sketches are easily maintained in a single-pass column stream of A. The sketch always provides an approximation B ∈ Rn×(ℓ+1)k guaranteeing: BBT (cid:22) AAT (cid:22) BBT + 1 ℓ kA\kk2 F k . (35) B does not contain columns from A, so it could be dense even for a sparse input matrix. However, we will only be setting ℓ to a small constant. Precise information about A will be stored in our column sample C, which maintains sparsity. We first show that B can be used to compute constant factor approximations to the ridge leverage scores of A. Lemma 17. For every column ai ∈ A, define def= aT τi i (cid:18)BBT + kAk2 F − kBkk2 F k I(cid:19)+ ai. If B ∈ Rn×3k is a Frequent Directions sketch for A with accuracy parameter ℓ = 2, then 1 2 ¯τi(A) ≤ τi ≤ 2¯τi(A). kAk2 F is obviously computable in a single-pass column stream, so τi can be evaluated in the streaming setting as long as we have access to ai. F −kBkk2 F ≥ 0. In this case, since BBT (cid:22) AAT , kAk2 Proof. By the Frequent Directions guarantee, either BBT = AAT giving the lemma trivially, or kA\kk2 I and BBT + kAk2 the lemma it suffices to show: F − kBkk2 F > 0. So both AAT + kA\kk2 I(cid:17)+ i (cid:16)AAT + kA\kk2 F − kBkk2 I(cid:19) . I(cid:19) (cid:22) AAT + kA\kk2 I (cid:22) 2(cid:18)BBT + kAk2 I span all of Rn. Recalling that ¯τi(A) = aT 2(cid:18)BBT + kAk2 F − kBkk2 ai, to prove (36) k k k 1 F F F k k k F F F Recall that the squared Frobenius norm of a matrix is equal to the sum of its squared singular values. Additionally, a standard property of the relation M (cid:22) N is that, for all i, the ith singular value σi(M) ≤ σi(N). From the right hand side of (35) it follows that, when ℓ = 2, σ2 i (B) ≥ i (A) − kA\kk2 σ2 F is the sum of the top k singular values of B, . Accordingly, since kBkk2 2k F kAk2 F − kBkk2 F ≤ kA\kk2 Since BBT (cid:22) AAT , it follows that that (cid:16)BBT + kAk2 k more than tight enough to give the left hand side of (36). F + kkA\kk2 F 2k F −kBkk2 ≤ 1.5kA\kk2 F . I(cid:17) (cid:22) AAT + 1.5kA\kk2 F , and since ℓ = 2, BBT (cid:23) AAT − kA\kk2 2k k F F F I, which is . Overall, Furthermore , kAk2 F ≥ kA\kk2 F − kBkk2 (cid:18)BBT + kAk2 k F − kBkk2 F I(cid:19) (cid:23) AAT + kA\kk2 2k F , which is more than tight enough to give the right hand side of (36). 23 6.3 Streaming Column Subset Selection Lemma 17 gives rise to a number of natural algorithms for rejection sampling by ridge leverage score. The simplest approach is to emulate sampling columns from A independently without replacement (see Lemmas 21 and 22). However, since sampling without replacement produces a variable number of samples, this method would require a log d dependence to ensure that our space remains bounded throughout the algorithm's execution with high probability. Instead, we apply our "with replacement" bounds, which sample a fixed number of columns, t. We start by describing Algorithm 2 for column subset selection. The constant c used below is the necessary oversampling parameter from Theorem 7. C ∈ Rn×t stores our actual column subset and D ∈ Rn×t stores a queue of new columns. B is a Frequent Directions sketch with parameter ℓ = 2. Algorithm 2 Streaming Column Subset input: A ∈ Rn×d, accuracy ǫ, success probability (1 − δ) output: C ∈ Rn×t such that t = 32c(k log k + k log(1/δ)/ǫ) and each column ci is equal to column aj with probability pj ∈h 1 i and 0 otherwise, where τj ≥ 2¯τj(A) for all j and Pn 1: count := 1, C := 0n×t, D := 0n×t, f robA := 0 2: [τ old 3: for i := 1, . . . , d do 4: ⊲ Initialize storage ⊲ Initialize sampling probabilities ⊲ Process column stream , τj c(k log k+k log(1/δ)/ǫ) j=1 τj ≤ 16k. τj c(k log k+k log(1/δ)/ǫ) , ..., τ old ] := 1 2 1 t t t B := FreqDirUpdate(B, ai) if count ≤ t then dcount := ai. f robA := f robA + kaik2 count := count + 1 2 else ⊲ Collect t new columns ⊲ Update kAk2 ⊲ Prune columns F 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 2: 3: 4: 5: ] := ApproximateRidgeScores(B, D, f robA) ], ApproximateRidgeScores(B, C, f robA)(cid:9) t 1 , ..., τ old 1 , ..., τ D t [τ1, ..., τt] := min(cid:8)[τ old [τ D for j := 1, . . . , t do if cj 6= 0 then With probability (cid:16)1 − τj/τ old Otherwise set τ old := τj. j j (cid:17) set cj := 0 and set τ old j ⊲ Rejection sample := 1. end if if cj = 0 then for ℓ := 1, . . . , t do With probability τℓc(k log k+k log(1/δ)/ǫ) t end for end if end for count := 0 ⊲ Sample from new columns in D set cj := dℓ and set τ old j := τℓ end if 24: 25: end for 1: function ApproximateRidgeScores(B, M ∈ Rn×t, f robA) for i := t + 1, . . . , d do τk:= 4mT i (cid:16)BBT + f robA−kBkk2 k F end for return [τ1, ..., τt] mi I(cid:17)+ 24 6: end function 0 column (in fact, since Pn j=1 τj ≤ 16k, by our choice of t that probability is greater than 1 To prove the correctness of Algorithm 2, we first note that, if our output C has columns belonging to the claimed distribution, then with probability (1 − δ), C is a (1 + ǫ) error column subset for A satisfying the guarantees of Theorem 7. Our procedure is not quite equivalent to the sampling procedure from Theorem 7 because we have some positive probability of choosing a 2 for each column). However, Algorithm 2 samples from a distribution that is equivalent to sampling from A with an all zeros column 0 tacked on and assigned a high ridge leverage score overestimate. Furthermore, by inspecting Algorithm 2, we can see that each column is sampled independently, as all ridge leverage score estimates are computed using the deterministic sketch B. Thus, we obtain a column subset for [A ∪ 0], which is clearly also a column subset for A. So, we just need to argue that we obtain an output according to the claimed distribution. Consider the state of the algorithm after each set of t "Process column stream" iterations, or equivalently, after each time the "Prune columns" else statement is entered. Denote A's first t columns as A(1), its first 2t columns as A(2), and in general, its first m · t columns as A(m). These submatrices represent the columns of A processed by the end of each epoch of t "Process column stream" iterations. Let's take as an inductive assumption that after every prior set of t steps, each column in C equals: t t c =(aj ∈ [A(m)] with probability pj ∈h 1 where τj ≥ 2¯τj(A(m)) for all j and Pj τj ≤ 16k. This is simply equivalent to our claimed output 0 with probability (1 −Pj pj), property of C once all columns have been processed. , τj c(k log k+k log(1/δ)/ǫ) τj c(k log k+k log(1/δ)/ǫ) i , (37) 2 (37) holds for A(1) because all of its columns are initially stored in the buffer D and each c is set to dj with probability pj = τj c(k log k+k log(1/δ)/ǫ) (see line 19). From Lemma 17 and our chosen scaling by 4 (line 3 of ApproximateRidgeScores), we know that τj ≥ 2¯τj(A(1)). Additionally, τj ≤ 8¯τj(A(1)), so it follows from Lemma 4 that Pj τj ≤ 16k. For future iterations, A(m) equals [A(m−1), D]. Consider the columns in A(m−1) first. By our inductive assumption each column in C has already been set to aj ∈ A(m−1) with probability pj ∈ (cid:20) 1 (cid:21). Our "Rejection sample" step additionally , meaning that in total aj is sampled with is trivially ≤ 1 since τj was set to the and the ridge leverage score of aj computed with respect to our updated Frequent filters out any column sampled with probability τj/τ old the desired probability from (37). We note that τj/τ old minimum of τ old Directions sketch (see line 10). c(k log k+k log(1/δ)/ǫ) c(k log k+k log(1/δ)/ǫ) τ old j τ old j 2 , j j j t t t If it was set based on the updated Frequent Directions sketch, then the argument that τj ≥ , then we can apply j ≥ 2¯τj(A(m−1)) and ¯τj(A(m−1)) ≥ ¯τj(A(m)) 2¯τj(A(m)) is the same as for A(1). On the other hand, if τj was set to equal τ old Lemma 9: from the inductive assumption, τj = τ old from the monotonicity property so τj ≥ 2¯τj(A(m)). Next consider any aj ∈ D. Each column c is set to aj with the correct probability for (37), but only conditioned on the fact that c = 0 before the "Sample from new columns in D" if statement is reached. This conditioning should mean that we effectively sample each aj ∈ D with lower probability. However, the probability cannot be much lower: by our choice of t and the inductive assumption on Pj τj, every column is set to 0 with at minimum 1/2 probability. j 25 Accordingly, c is available at least half the time, meaning that we at least sample aj with probability pj = 1 2 , which satisfies (37). τjc(k log k+k log(1/δ)/ǫ) t All that is left to argue is thatPj τj ≤ 16k for A(m). The argument is the same as for A(1), the only difference being that for some values of j, we could have set τj = τ old , which only decreases the total sum. We conclude by induction that (37) holds for A itself, and thus C is a (1 + ǫ) error column subset (Theorem 7). Algorithm 2 requires O(nk) space to store B and maintains at most t = O(k log k + k log(1/δ)/ǫ) sampled columns. It thus proves Theorem 18: j Theorem 18 (Streaming Column Subset Selection). There exists a streaming algorithm that uses just a single-pass over A's columns to compute a (1 + ǫ) error column subset C with O(k log k + k log(1/δ)/ǫ) columns. The algorithm uses O(nk) space in addition to the space required to store C and succeeds with probability 1 − δ. We note that, by using the stronger containment condition of Theorem 7 and the streaming projection-cost preserving sampling algorithm described below we can easily modify the above algorithm to output an optimally sized column subset with O(k/ǫ) columns. In order to select this subset, we require a Frequent Directions sketch with ǫ error, so that we can evaluate each O(k/ǫ) sized subset in our set of O(k log(1/δ)/ǫ) 'adaptively sampled' columns and return one giving ǫ error. The higher accuracy Frequent Directions sketch incurs space overhead O(nk/ǫ). 6.4 Streaming Projection-Cost Preserving Samples Our single-pass streaming procedure for projection-cost preserving samples is similar to Algorithm 2, although with one important difference. When constructing column subsets, we sampled new columns in the buffer D while ignoring the fact that "available slots" in C (i.e. columns currently set to 0) had already been consumed with some probability. This decision was deliberate, rather than a convenience for analysis. We could not account for the probability of slots being unavailable because calculating that probability precisely would require knowing the ridge leverage scores of already discarded columns. Fortunately, the probability of a column not being set to 0 was bounded by 1/2 and our procedure hits its sampling target up to this factor. However, while a constant factor approximation to sampling probabilities is also sufficient for our Theorem 6 projection-cost preservation result, the fact that columns need to be reweighted by the inverse of their sampling probability adds a complication: we do not know the true probability with which we sampled each column! Unfortunately, approximating the reweighting up to a constant factor is insufficient. We need to reweight columns by a factor within p(1 ± ǫ) of 1/√tpi for Theorem 5 and Lemma 20 to hold (which are both required for Theorem 6). This is easily checked by noting that such a reweighting is equivalent to replacing CCT with CWCT where (1 − ǫ)Id×d (cid:22) W (cid:22) (1 + ǫ)Id×d. We achieve this accuracy by modifying our algorithm so that it maintains an even higher "open rate" within C. Specifically, we choose t so that each column c has at least a (1 − ǫ) probability of equaling 0 at any given point in our stream. The procedure is given as Algorithm 3. The constant c is the required oversampling parameter from Theorem 7. Algorithm 3 Streaming Projection-Cost Preserving Samples input: A ∈ Rn×d, accuracy ǫ, success probability (1 − δ) output: C ∈ Rn×t such that t = 1 √τj ck log(k/δ)/ǫ2 aj with probability pj ∈h(1 − ǫ) τj ck log(k/δ)/ǫ2 where τj ≥ 2¯τj(A) for all j and Pn j=1 τj ≤ 16k. 1 t 26 16ǫ ck log(k/δ)/ǫ2 and each column ci is equal to column , τj ck log(k/δ)/ǫ2 t i and 0 otherwise, , ..., τ old 1: count := 1, C := 0n×t, D := 0n×t, f robA := 0 2: [τ old 3: for i := 1, . . . , d do 4: ] := 1 1 t B := FreqDirUpdate(B, ai) if count ≤ t then dcount := ai. f robA := f robA + kaik2 count := count + 1 2 else ⊲ Initialize storage ⊲ Initialize sampling probabilities ⊲ Process column stream ⊲ Collect t new columns ⊲ Update kAk2 ⊲ Prune columns F ] := ApproximateRidgeScores(B, D, f robA) ], ApproximateRidgeScores(B, C, f robA)(cid:9) t 1 , ..., τ old 1 , ..., τ D t [τ1, ..., τt] := min(cid:8)[τ old [τ D for j := 1, . . . , t do if cj 6= 0 then With probability (cid:16)1 − τj/τ old Otherwise set τ old j end if if cj = 0 then for ℓ := 1, . . . , t do With probability τℓck log(k/δ)/ǫ2 t end for end if end for count := 0 j (cid:17) set cj := 0 and set τ old j := τj and multiply cj by qτ old j /τj. ⊲ Rejection sample := 1. ⊲ Sample from new columns in D set cj := 1 √τℓck log(k/δ)/ǫ2 dℓ and set τ old j := τℓ 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 2: 3: 4: end if 24: 25: end for 1: function ApproximateRidgeScores(B, M ∈ Rn×t, f robA) for i := t + 1, . . . , d do τk:= 4mT i (cid:16)BBT + f robA−kBkk2 k F mi I(cid:17)+ end for return [τ1, ..., τt] 5: 6: end function The analysis of Algorithm 3 is equivalent to that of Algorithm 2, along with the additional observation that our true sampling probability, pj, is within an ǫ factor of the sampling probability used for reweighting, τj ck log(k/δ)/ǫ2 . Note that while C contains just O(k log(k/δ)/ǫ2) non-zero columns in expectation, during the course of a the column stream it could contain as many as O(k log(k/δ)/ǫ3) columns. Regardless, it is always possible to resample from C after running Algorithm 3 to construct an optimally sized sample for A with error (1 + 2ǫ). Overall we have: t Theorem 19 (Streaming Projection-Cost Preserving Sampling). There exists a streaming algo- rithm that uses just a single-pass over A's columns to compute a (1 + ǫ) error projection-cost preserving sample C with O(k log(k/δ)/ǫ2) columns. The algorithm requires a fixed O(nk) space overhead along with space to store O(k log(k/δ)/ǫ3) columns of A. It succeeds with probability 1− δ. 27 References [AHPV04] Pankaj K. Agarwal, Sariel Har-Peled, and Kasturi R. Varadarajan. Approximating extent measures of points. J. ACM, 51(4):606–635, 2004. [AM15] Ahmed El Alaoui and Michael W. Mahoney. Fast randomized kernel methods with sta- tistical guarantees. In Advances in Neural Information Processing Systems 28 (NIPS), 2015. Full version at arXiv:1411.0306v1. [AMS01] Dimitris Achlioptas, Frank Mcsherry, and Bernhard Scholkopf. Sampling techniques for kernel methods. In Advances in Neural Information Processing Systems 14 (NIPS), 2001. [Bac13] Francis Bach. Sharp analysis of low-rank kernel matrix approximations. In Proceedings of the 26th Annual Conference on Computational Learning Theory (COLT), 2013. [BDN15] [BJS15] [BK13] Jean Bourgain, Sjoerd Dirksen, and Jelani Nelson. Toward a unified theory of sparse di- mensionality reduction in euclidean space. Geometric and Functional Analysis (GAFA), 25(4):1009–1088, 2015. Preliminary version in the 47th Annual ACM Symposium on Theory of Computing (STOC). Srinadh Bhojanapalli, Prateek Jain, and Sujay Sanghavi. Tighter low-rank approxima- tion via sampling the leveraged element. In Proceedings of the 26th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), 2015. Wei Bi and James Kwok. Efficient multi-label classification with many labels. In Proceedings of the 30th International Conference on Machine Learning (ICML), pages 405–413, 2013. [BS80] Jon Louis Bentley and James B. Saxe. Decomposable searching problems I: Static-to- dynamic transformation. Journal of Algorithms, 1(4):301–358, 1980. [BW09a] Mohamed-Ali Belabbas and Patrick J. Wolfe. On landmark selection and sampling in high-dimensional data analysis. Philosophical Transactions of the Royal Society A, 367:4295–4312, 2009. [BW09b] Mohamed-Ali Belabbas and Patrick J. Wolfe. Spectral methods in machine learning: New strategies for very large datasets. Proceedings of the National Academy of Sciences of the USA, 106:369–374, 2009. [BW14] Christos Boutsidis and David P. Woodruff. Optimal CUR matrix decompositions. In Proceedings of the 46th Annual ACM Symposium on Theory of Computing (STOC), pages 353–362, 2014. [BZMD15] Christos Boutsidis, Anastasios Zouzias, Michael W. Mahoney, and Petros Drineas. Randomized dimensionality reduction for k-means clustering. IEEE Transactions on Information Theory, 61(2):1045–1062, Feb 2015. [CBSW15] Yudong Chen, Srinadh Bhojanapalli, Sujay Sanghavi, and Rachel Ward. Coherent matrix completion. Journal of Machine Learning Research, 2015. Preliminary version in the 31st International Conference on Machine Learning (ICML). 28 [CEM+15] Michael B. Cohen, Sam Elder, Cameron Musco, Christopher Musco, and Madalina Persu. Dimensionality reduction for k-means clustering and low rank approximation. In Proceedings of the 47th Annual ACM Symposium on Theory of Computing (STOC), pages 163–172, 2015. [CLM+15] Michael B. Cohen, Yin Tat Lee, Cameron Musco, Christopher Musco, Richard Peng, and Aaron Sidford. Uniform sampling for matrix approximation. In Proceedings of the 6th Conference on Innovations in Theoretical Computer Science (ITCS), pages 181– 190, 2015. [CMP15] Michael B. Cohen, Cameron Musco, and Jakub Pachocki. Online row sampling. In Pro- ceedings of the 19th International Workshop on Approximation Algorithms for Combi- natorial Optimization Problems (APPROX), 2015. [Coh16] [CW09] [CW13] Michael B. Cohen. Nearly tight oblivious subspace embeddings by trace inequalities. In Proceedings of the 27th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 278–287, 2016. 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), pages 205–214, 2009. Kenneth L. Clarkson and David P. Woodruff. Low rank approximation and regression in input sparsity time. In Proceedings of the 45th Annual ACM Symposium on Theory of Computing (STOC), pages 81–90, 2013. [DFK+04] Petros Drineas, Alan Frieze, Ravi Kannan, Santosh Vempala, and V Vinay. Clustering large graphs via the singular value decomposition. Machine Learning, 56(1-3):9–33, 2004. Preliminary version in the 10th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA). [DKM06a] Petros Drineas, Ravi Kannan, and Michael W. Mahoney. Fast Monte Carlo algorithms for matrices II: Computing a low-rank approximation to a matrix. SIAM J. Comput., 36(1):158–183, 2006. [DKM06b] Petros Drineas, Ravi Kannan, and Michael W. Mahoney. Fast Monte Carlo algorithms for matrices III: Computing a compressed approximate matrix decomposition. SIAM J. Comput., 36(1):184–206, 2006. Preliminary version in the 14th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA). [DMM06] Petros Drineas, Michael W. Mahoney, and S. Muthukrishnan. Sampling algorithms In Proceedings of the 17th Annual ACM-SIAM for ℓ2 regression and applications. Symposium on Discrete Algorithms (SODA), pages 1127–1136, 2006. [DMM08] Petros Drineas, Michael W. Mahoney, and S. Muthukrishnan. Relative-error CUR matrix decompositions. SIAM Journal on Matrix Analysis and Applications, 30(2):844– 881, 2008. [DRVW06] Amit Deshpande, Luis Rademacher, Santosh Vempala, and Grant Wang. Matrix ap- proximation and projective clustering via volume sampling. Theory of Computing, 2(1):225–247, 2006. Preliminary version in the 17th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA). 29 [DV06] [FKV04] [FS02] [FSS13] Amit Deshpande and Santosh Vempala. Adaptive sampling and fast low-rank matrix approximation. In Proceedings of the 10th International Workshop on Randomization and Computation (RANDOM), pages 292–303, 2006. Alan Frieze, Ravi Kannan, and Santosh Vempala. Fast Monte-Carlo algorithms for finding low-rank approximations. J. ACM, 51(6):1025–1041, November 2004. Prelimi- nary version in the 39th Annual IEEE Symposium on Foundations of Computer Science (FOCS). Shai Fine and Katya Scheinberg. Efficient SVM training using low-rank kernel repre- sentations. The Journal of Machine Learning Research, 2:243–264, 2002. Dan Feldman, Melanie Schmidt, and Christian Sohler. Turning big data into tiny data: Constant-size coresets for k-means, PCA, and projective clustering. In Proceedings of the 24th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1434–1453, 2013. [GLPW15] Mina Ghashami, Edo Liberty, Jeff M. Phillips, and David P. Woodruff. Frequent Directions: Simple and deterministic matrix sketching. arXiv:1501.01711, 2015. [GM13] [HI15] [HKZ12] [HPM04] Alex Gittens and Michael Mahoney. Revisiting the Nystrom method for improved large-scale machine learning. In Proceedings of the 30th International Conference on Machine Learning (ICML), pages 567–575, 2013. John T. Holodnak and Ilse C. F. Ipsen. Randomized approximation of the Gram matrix: Exact computation and probabilistic bounds. SIAM Journal on Matrix Analysis and Applications, 36(1):110–137, 2015. Daniel Hsu, Sham Kakade, and Tong Zhang. Tail inequalities for sums of random matrices that depend on the intrinsic dimension. Electron. Commun. Probab., 17:1–13, 2012. Sariel Har-Peled and Soham Mazumdar. On coresets for k-means and k-median clus- tering. In Proceedings of the 36th Annual ACM Symposium on Theory of Computing (STOC), pages 291–300, 2004. [HRZ+09] David Hall, Daniel Ramage, Jason Zaugg, Alexander Lehmann, Jonathan Merritt, Keith Stevens, Jason Baldridge, Timothy Hunter, Dave DeCaprio, Daniel Duckworth, Eric Christiansen, Marc Millstone, M´ero L´aszl´o, Alexey Noskov, Devon Bryant, Ken- taroh Takagaki, Sam Halliday, Chris Stucchio, and Xiangrui Meng. ScalaNLP: Breeze. http://www.scalanlp.org/, 2009. [IBM14] IBM Reseach Division, Skylark Team. Computations for Machine Learning. IBM Corporation, Armonk, NY, 2014. libskylark: Sketching-based Distributed Matrix [JK16] [KL13] Gorav Jindal and Pavel Kolev. An efficient parallel algorithm for spectral sparsification of laplacian and SDDM matrix polynomials. arXiv:1507.07497, 2016. Jonathan A. Kelner and Alex Levin. Spectral sparsification in the semi-streaming setting. Theory of Computing Systems, 53(2):243–262, 2013. Preliminary version in the 28th International Symposium on Theoretical Aspects of Computer Science (STACS). 30 [KLM+14] Michael Kapralov, Yin Tat Lee, Cameron Musco, Christopher Musco, and Aaron Sid- ford. Single pass spectral sparsification in dynamic streams. In Proceedings of the 55th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 561–570, 2014. [KLP+16] Rasmus Kyng, Yin Tat Lee, Richard Peng, Sushant Sachdeva, and Daniel A. Spielman. Sparsified cholesky and multigrid solvers for connection laplacians. In Proceedings of the 48th Annual ACM Symposium on Theory of Computing (STOC), pages 842–850, 2016. [Lib13] [Liu14] [LJS16] Edo Liberty. Simple and deterministic matrix sketching. In Proceedings of the 19th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), pages 581–588, 2013. Antoine Liutkus. Randomized SVD. http://www.mathworks.com/matlabcentral/fileexchange/47835 2014. MATLAB Central File Exchange. Chengtao Li, Stefanie Jegelka, and Suvrit Sra. Fast DPP sampling for nystrom with application to kernel methods. In Proceedings of the 33rd International Conference on Machine Learning (ICML), 2016. [LMP13] Mu Li, Gary L. Miller, and Richard Peng. Iterative row sampling. In Proceedings of the 54th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 127–136, 2013. Preliminary version at arXiv:1211.2713v1. [LPS15] [LS14] Yin Tat Lee, Richard Peng, and Daniel A. Spielman. Sparsified cholesky solvers for SDD linear systems. arXiv:1506.08204, 2015. 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. In Proceedings of the 55th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 424–433, 2014. [LS15] Yin Tat Lee and Aaron Sidford. Efficient inverse maintenance and faster algorithms for linear programming. In Proceedings of the 56th Annual IEEE Symposium on Foun- dations of Computer Science (FOCS), 2015. [LSW15] Yin Tat Lee, Aaron Sidford, and Sam Chiu-wai Wong. A faster cutting plane method and its implications for combinatorial and convex optimization. In Proceedings of the 56th Annual IEEE Symposium on Foundations of Computer Science (FOCS), 2015. [MA77] [MD05] George A. Milliken and Fikri Akdeniz. A theorem on the difference of the general- ized inverses of two nonnegative matrices. Communications in Statistics - Theory and Methods, 6(1):73–79, 1977. Michael W. Mahoney and Petros Drineas. On the Nystrom method for approximat- ing a gram matrix for improved kernel-based learning. Journal of Machine Learning Research, 6:2153–2175, 2005. Preliminary version in the 18th Annual Conference on Computational Learning Theory (COLT). [MD09] Michael W. Mahoney and Petros Drineas. CUR matrix decompositions for improved data analysis. Proceedings of the National Academy of Sciences of the USA, 106(3):697– 702, 2009. 31 [Min13] [MM13] [MM15] [MM16] [Mus15] [NN13] [Oka10] Stanislav Minsker. On some extensions of Bernstein's inequality for self-adjoint opera- tors. arXiv:1112.5448, 2013. Michael W. Mahoney and Xiangrui Meng. Low-distortion subspace embeddings in input-sparsity time and applications to robust linear regression. In Proceedings of the 45th Annual ACM Symposium on Theory of Computing (STOC), pages 91–100, 2013. Cameron Musco and Christopher Musco. Randomized block krylov methods for stronger and faster approximate singular value decomposition. In Advances in Neu- ral Information Processing Systems 28 (NIPS), 2015. Full version at arXiv:1504.05477. Cameron Musco and Christopher Musco. Provably useful kernel matrix approximation in linear time. arXiv:1605.07583, 2016. Cameron Musco. Dimensionality reduction for k-means clustering. Master's thesis, Massachusetts Institute of Technology, 2015. Jelani Nelson and Huy L. Nguyen. OSNAP: Faster numerical linear algebra algorithms via sparser subspace embeddings. In Proceedings of the 54th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 117–126, 2013. Daisuke https://code.google.com/p/redsvd/, 2010. Okanohara. redsvd: RandomizED SVD. [PVG+11] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011. [PZB+07] Peristera Paschou, Elad Ziv, Esteban G. Burchard, Shweta Choudhry, William Rodriguez-Cintron, Michael W. Mahoney, and Petros Drineas. PCA-correlated SNPs for structure identification in worldwide human populations. PLoS Genet, 3(9):1672– 1686, 2007. [RR07] [Sar06] [SS11] [Str14] [Tro15] Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. In Advances in Neural Information Processing Systems 20 (NIPS), pages 1177–1184, 2007. T´amas Sarl´os. Improved approximation algorithms for large matrices via random pro- jections. In Proceedings of the 47th Annual IEEE Symposium on Foundations of Com- puter Science (FOCS), pages 143–152, 2006. Daniel A. Spielman and Nikhil Srivastava. Graph sparsification by effective resistances. SIAM Journal on Computing, 40(6):1913–1926, 2011. Preliminary version in the 40th Annual ACM Symposium on Theory of Computing (STOC). Martin Tobias Strauch. Column subset selection with applications to neuroimaging data. PhD thesis, Universitat Konstanz, 2014. Joel A. Tropp. An introduction to matrix concentration inequalities. Founda- tions and Trends in Machine Learning, 8(1-2):1–230, 2015. Preliminary version at arXiv:1501.01571. 32 [VM15] [WS01] Sergey Voronin and Per-Gunnar Martinsson. RSVDPACK: Subroutines for computing partial singular value decompositions via randomized sampling on single core, multi core, and GPU architectures. arXiv:1502.05366, 2015. Christopher K. I. Williams and Matthias Seeger. Using the Nystrom method to speed up kernel machines. In Advances in Neural Information Processing Systems 13 (NIPS), pages 682–688, 2001. A Trace Bound for Ridge Leverage Score Sampling ǫ2 . Let t = c log(k/δ) singular value with σ2 Lemma 20. For i ∈ {1, . . . , d}, let τi ≥ ¯τi(A) be an overestimate for the ith ridge leverage score. Let pi = τi ·Pi τi, for some sufficiently large constant c. Construct C by Pi τi sampling t columns of A, each set to . With probability 1 − δ, C satisfies: \m) − tr(U\mUT \m, we can rewrite (38) as: m ≥ kA\kk2 tr(A\mAT Proof. Letting P\m = U\mUT ai with probability pi. Let m be the index of the smallest \m) ≤ ǫkA\kk2 F . \mCCT U\mUT 1√tpi (38) k F We can write kP\mCk2 kP\mCk2 F − kA\mk2 F as a sum over column norms: F ≤ ǫkA\kk2 F . kP\mCk2 F = t Xj=1 kP\mcjk2 2. Now, for some i ∈ {1, . . . , d} and recalling our definition ¯Σ2 i (A) + kA\kk2 F k we have: ǫ2 i,i = σ2 c log(k/δ) · kP\maik2 c log(k/δ) · ǫ2 aT 2 ǫ2 c log(k/δ) · ǫ2 c log(k/δ) · 2 2 ¯τi(A) kP\maik2 i (cid:0)U ¯Σ−2UT(cid:1) ai kP\maik2 i P\m(cid:0)U ¯Σ−2UT(cid:1) P\mai i P\m(cid:16)U\m kP\maik2 kP\maik2 2 ¯Σ−2UT 2 aT aT \m(cid:17) P\mai kP\mcik2 2 = 1 tpikP\maik2 2 ≤ = ≤ = ≤ ≤ ǫ2 k c log(k/δ) · F kP\maik2 2kA\kk2 c log(k/δ) · kA\kk2 F , 2ǫ2 2 where the second to last inequality follows from the fact that ¯Σ2 i ≥ m. Therefore, U\m ¯Σ−2UT P\m. \m (cid:23) 2kA\kk2 k F i,i = σ2 i (A) + kA\kk2 F k 2kA\kk2 F k for ≤ 33 So, bound: c log(k/δ) 2ǫ2kA\kk2 F · kP\mcik2 2 ∈ [0, 1]. We have EhPt P(cid:2)kP\mCk2 F ≥ kA\mk2 = P Xj=1  ≤ e−c log(k/δ)/4 ≤ δ/2, F + ǫkA\kk2 F(cid:3) 2 ≥ 1 + kP\mcik2 c log(k/δ) 2ǫ2kA\kk2 F t j=1 kP\mcik2 2i = kA\mk2 F so by a Chernoff F ǫkA\kk2 kA\mk2 F ! c log(k/δ)kA\mk2 2ǫ2kA\kk2 F F   if we set c sufficiently large. In the second to last step we use the fact that kA\kk2 kA\mk2 F F ≥ 1 2 by the definition of m. We can similarly prove that P(cid:2)kP\mCk2 bounding gives the result. F ≤ kA\mk2 F − ǫkA\kk2 F(cid:3) ≤ δ/2. Union B Independent Sampling Bounds In this section we give analogies to Theorem 5 and Lemma 20 when columns are sampled indepen- dently using their ridge leverage scores rather than sampled with replacement. some sufficiently large constant c. Construct C by independently sampling each column ai from , 1o for Lemma 21. For i ∈ {1, . . . , d}, given τi ≥ ¯τi(A) for all i, let pi = minnτi · c log(k/δ) A with probability pi and scaling selected columns by 1/√pi. With probability 1 − δ, C has O(cid:0)log(k/δ)/ǫ2 ·Pi τi(cid:1) columns and satisfies: ǫ2 (1 − ǫ)CCT − ǫ kkA − Akk2 F In×n (cid:22) AAT (cid:22) (1 + ǫ)CCT + ǫ kkA − Akk2 F In×n. (7) Proof. Again we rewrite the ridge leverage score definition using A's singular value decomposition: ¯τi(A) = aT F i UΣ2UT + kA\kk2 i (cid:0)U ¯Σ2UT(cid:1)+ ai = aT UUT!+ i (cid:0)U ¯Σ−2UT(cid:1) ai, ai k = aT where ¯Σ2 i,i = σ2 F k i (A) + kA\kk2 Xi =((cid:16) 1 . For each i ∈ 1, . . . , d define the matrix valued random variable: pi − 1(cid:17) ¯Σ−1UT aiaT − ¯Σ−1UT aiaT i U ¯Σ−1 with probability pi i U ¯Σ−1 with probability (1 − pi) Let Y =P Xi. We have E Y = 0. Furthermore, CCT = U ¯ΣY ¯ΣU + AAT . Showing kYk2 ≤ ǫ gives −ǫI (cid:22) Y (cid:22) ǫI, and since U ¯Σ2UT = AAT + kA\kk2 I would give: k F (1 − ǫ)AAT − ǫkA\kk2 F k I (cid:22) CCT (cid:22) (1 + ǫ)AAT + ǫkA\kk2 F k I. After rearranging and adjusting constants on ǫ, this statement is equivalent to (7). 34 To prove that kYk2 is we use the same stable rank matrix Bernstein inequality used for our with replacement results [Tro15]. If pi = 1 (i.e. τi · c log(k/δ)/ǫ2 ≥ 1) then Xi = 0 so kXik2 = 0. Otherwise, we use the fact that I, which lets us bound: F I! U ¯Σ−1 = I. ǫ2 c log(k/δ) . 1 τi · ¯Σ−1UT aiaT 1 k F k i (cid:22) AAT + kA\kk2 ¯τi(A) aiaT i U ¯Σ−1 (cid:22) ¯Σ−1UT AAT + kA\kk2 i U ¯Σ−1 (cid:22) c log(k/δ) I and hence kXik2 ≤ + (1 − pi)# · ¯Σ−1UT aiaT i ) (cid:22)X"pi(cid:18) 1 (cid:22)X 1 i U ¯Σ−1 (cid:22) pi · ¯τi(A) · ¯Σ−1UT aiaT ǫ2 ǫ2 pi − 1(cid:19)2 ǫ2 ǫ2 (cid:22) c log(k/δ) Σ2 ¯Σ−2 (cid:22) c log(k/δ) D. So we have Xi (cid:22) 1 pi ¯Σ−1UT aiaT Next we bound the variance of Y. E(Y2) =X E(X2 i U ¯Σ−2UT aiaT i U ¯Σ−1 c log(k/δ) ¯Σ−1UT AAT U ¯Σ−1 (39) where again we set Di,i = 1 for i ∈ 1, . . . , k and Di,i = stable rank matrix Bernstein inequality given in Theorem 7.3.1 of [Tro15], for ǫ < 1, F /k for all i ∈ k + 1, . . . , n. By the σ2 i +kA\kk2 σ2 i P [kYk ≥ ǫ] ≤ 4 tr(D) kDk2 −ǫ2/2 (cid:18) e ǫ2 c log(k/δ) (kDk2+ǫ/3)(cid:19) . (40) Clearly kDk2 = 1. Furthermore, tr(D) = k + d Xi=k+1 σ2 i i + kA\kk2 σ2 k F ≤ k + d Xi=k+1 σ2 i kA\kk2 F k = k + Pd i=k+1 σ2 i kA\kk2 F k ≤ k + k. Plugging into (9), we see that if we choose the constant c large enough. So we have established (7). P [kYk ≥ ǫ] ≤ 8ke− c log(k/δ) 2 ) ≤ δ/2, standard Chernoff bound. Union bounding over failure probabilities gives the lemma. All that remains to note is that, the expected number of columns in C is at most c log(k/δ) · i=1 τi. Accordingly, C has at most O(cid:16) log(k/δ) ·Pi τi(cid:17) columns with probability > 1 − δ/2 by a Pd , 1o for Lemma 22. For i ∈ {1, . . . , d}, given τi ≥ ¯τi(A) for all i, let pi = minn¯τi(A) · c log(k/δ) some sufficiently large constant c. Construct C by independently sampling each column ai from A with probability pi and scaling selected columns by 1/√pi. Let m be the index of the smallest singular value with σ2 ǫ2 ǫ2 ǫ2 F k m ≥ kA\kk2 tr(A\mAT . With probability 1 − δ, C satisfies: \m) − tr(U\mUT \mCCT U\mUT \m) ≤ ǫkA\kk2 F . (41) 35 Proof. We need to show tr(A\mAT U\mUT \m, we can rewrite this as: \m) − tr(U\mUT \mBBT U\mUT \m) ≥ −ǫkA\mk2 F . Letting P\m = We can write kP\mBk2 kP\mBk2 F − kA\mk2 F as a sum over column norms: F ≤ ǫkA\mk2 F . kP\mBk2 F = 1 pikP\maik2 2, Ii d Xi=1 where Ii is an indicator random variable equal to 1 with probability pi and 0 otherwise. We have: 1 pikP\maik2 2 = ǫ2 c log(k/δ) · kP\maik2 2 τi ≤ ≤ = ≤ ≤ ǫ2 c log(k/δ) · ǫ2 c log(k/δ) · ǫ2 c log(k/δ) · aT aT aT 2 2 kP\maik2 i (cid:0)U ¯Σ−2UT(cid:1) ai kP\maik2 i P\m(cid:0)U ¯Σ−2UT(cid:1) P\mai i P\m(cid:16)U\m kP\maik2 kP\maik2 2 ¯Σ−2UT 2 \m(cid:17) P\mai ǫ2 k c log(k/δ) · F kP\maik2 2kA\kk2 c log(k/δ) · kA\kk2 F , 2ǫ2 2 where the second to last inequality follows from the fact that ¯Σ2 i ≥ m. Therefore, U\m P\m. k ¯Σ−2UT pikP\maik2 2kA\kk2 \m (cid:23) 2 ∈ [0, 1] and by a Chernoff bound we have: F So c log(k/δ) 2ǫ2kA\mk2 F · 1 i,i = σ2 i (A) + kA\kk2 F k 2kA\kk2 F k for ≤ P(cid:2)kP\mBk2 F ≥ (1 + ǫ)kA\mk2 d F(cid:3) = P" c log(k/δ) Xi=1 ≤ e−c log(k/δ)/4 ≤ δ/2, 2ǫ2kA\mk2 F Ii 1 pikP\maik2 2 ≥ (1 + ǫ) c log(k/δ) 2ǫ2 # if we set c sufficiently large. 36
1407.2575
4
1407
2016-02-27T09:38:05
Balanced Allocation on Graphs: A Random Walk Approach
[ "cs.DS", "cs.DM", "math.PR" ]
In this paper we propose algorithms for allocating $n$ sequential balls into $n$ bins that are interconnected as a $d$-regular $n$-vertex graph $G$, where $d\ge3$ can be any integer.Let $l$ be a given positive integer. In each round $t$, $1\le t\le n$, ball $t$ picks a node of $G$ uniformly at random and performs a non-backtracking random walk of length $l$ from the chosen node.Then it allocates itself on one of the visited nodes with minimum load (ties are broken uniformly at random). Suppose that $G$ has a sufficiently large girth and $d=\omega(\log n)$. Then we establish an upper bound for the maximum number of balls at any bin after allocating $n$ balls by the algorithm, called {\it maximum load}, in terms of $l$ with high probability. We also show that the upper bound is at most an $O(\log\log n)$ factor above the lower bound that is proved for the algorithm. In particular, we show that if we set $l=\lfloor(\log n)^{\frac{1+\epsilon}{2}}\rfloor$, for every constant $\epsilon\in (0, 1)$, and $G$ has girth at least $\omega(l)$, then the maximum load attained by the algorithm is bounded by $O(1/\epsilon)$ with high probability.Finally, we slightly modify the algorithm to have similar results for balanced allocation on $d$-regular graph with $d\in[3, O(\log n)]$ and sufficiently large girth.
cs.DS
cs
Balanced Allocation on Graphs: A Random Walk Approach Ali Pourmiri Institute for Research in Fundamental Sciences (IPM), Tehran, Iran [email protected] January 11, 2018 Abstract log d + O(1). The standard balls-into-bins model is a process which randomly allocates m balls into n bins where each ball picks d bins independently and uniformly at random and the ball is then allocated in a least loaded bin in the set of d choices. When m = n and d = 1, it is well known that at the end of process the maximum number of balls at any bin, the maximum load, is (1 + o(1)) log n log log n with high probability1. Azer et al. [4] showed that for the d-choice process, d (cid:62) 2, provided ties are broken randomly, the maximum load is log log n In this paper we propose algorithms for allocating n sequential balls into n bins that are interconnected as a d-regular n-vertex graph G, where d (cid:62) 3 can be any integer. Let l be a given positive integer. In each round t, 1 (cid:54) t (cid:54) n, ball t picks a node of G uniformly at random and performs a non-backtracking random walk of length l from the chosen node. Then it allocates itself on one of the visited nodes with minimum load (ties are broken uniformly at random). Suppose that G has a sufficiently large girth and d = ω(log n). Then we establish an upper bound for the maximum number of balls at any bin after allocating n balls by the algorithm, called maximum load, in terms of l with high probability. We also show that the upper bound is at most an O(log log n) factor above the lower bound that is proved for the algorithm. In particular, we show that if we set l = (cid:98)(log n) 2 (cid:99), for every constant  ∈ (0, 1), and G has girth at least ω(l), then the maximum load attained by the algorithm is bounded by O(1/) with high probability. Finally, we slightly modify the algorithm to have similar results for balanced allocation on d-regular graph with d ∈ [3,O(log n)] and sufficiently large girth. 1+ 1 Introduction log log n with high probability. Azer et al. The standard balls-into-bins model is a process which randomly allocates m balls into n bins where each ball picks d bins independently and uniformly at random and the ball is then allocated in a least loaded bin in the set of d choices. When m = n and d = 1, it is well known that at the end of process the maximum number of balls at any bin, the maximum load, is (1 + o(1)) log n [4] showed that for the d-choice process, d (cid:62) 2, provided ties are broken randomly, the maximum load is log log n a complete survey on the standard balls-into-bins process we refer the reader to [13]. Many subsequent works consider the settings where the choice of bins are not necessarily independent and uniform. For instance, Vocking [15] proposed an algorithm called always-go-left that uses + O(1) whp, exponentially smaller number of choices and achieve a maximum load of log log n where 1 (cid:54) φd (cid:54) 2 is an specified constant. In this algorithm, the bins are partitioned into d groups of size n/d and each ball picks one random bin from each group. The ball is then allocated in a least loaded bin among the chosen bins and ties are broken asymmetrically. log d + O(1). For dφd In many applications selecting any random set of choices is costly. For example, in peer- to-peer or cloud-based systems balls (jobs, items,...) and bins (servers, processors,...) are randomly placed in a metric space (e.g., R2) and the balls have to be allocated on bins that are close to them as it minimizes the access latencies. With regard to such applications, Byer et al. [7] studied a model, where n bins (servers) are uniformly at random placed on a geometric space. Then each ball in turn picks d locations in the space and allocates itself on a nearest neighboring bin with minimum load among other d bins. In this scenario, the probability that a location close to a server is chosen depends on the distribution of other servers in the space and hence there is no a uniform distribution over the potential choices. Here, the authors 1With high probability refers to an event that holds with probability 1 − 1/nc, where c is a constant. For simplicity, we sometimes abbreviate it as whp. 1 log d + O(1) whp. Later on, Kenthapadi and Panigrahy [11] allocation algorithm results in a maximum load of log log n + O(cid:16) showed the maximum load is log log n proposed a model in which bins are interconnected as a ∆-regular graph and each ball picks a random edge of the graph. It is then placed at one of its endpoints with smaller load. This + O(1). Peres et al. [14] also considered a similar model where number of balls m can be much larger than n (i.e., m (cid:29) n) and the graph is not necessarily regular. Then, they established upper bound O(log n/σ) for the gap between the maximum and the minimum loaded bin after allocating m balls, where σ is the edge expansion of the graph. Following the study of balls-into-bins with correlated choices, Godfrey [10] generalized the model introduced by Kenthapadi and Panigrahy such that each ball picks an random edge of a hypergraph that has Ω(log n) bins and satisfies some mild conditions. Then he showed that the maximum load is a constant whp. log(∆/ log4 n) (cid:17) log n Recently, Bogdan et al. [6] studied a model where each ball picks a random node and performs a local search from the node to find a node with local minimum load, where it is finally placed on. They showed that when the graph is a constant degree expander, the local search guarantees a maximum load of Θ(log log n) whp. Our Results. In this paper, we study balls-into-bins models, where each ball chooses a set of related bins. We propose allocation algorithms for allocating n sequential balls into n bins that are organized as a d-regular n-vertex graph G. Let l be a given positive integer. A non-backtracking random walk (NBRW) W of length l started from a node is a random walk in l steps so that in each step the walker picks a neighbor uniformly at random and moves to that neighbor with an additional property that the walker never traverses an edge twice in a row. Further information about NBRWs can be found in [1] and [2]. Our allocation algorithm, denoted by A(G, l), is based on a random sampling of bins from the neighborhood of a given node in G by a NBRW from the node. The algorithm proceeds as follows: In each round t, 1 (cid:54) t (cid:54) n, ball t picks a node of G uniformly at random and performs a NBRW W = (u0, u1 . . . , ul), called l-walk. After that the ball allocates itself on one of the visited nodes with minimum load and ties are broken randomly. Our result concerns bounding the maximum load attained by A(G, l), denoted by m∗, in terms of l. Note that if the balls are allowed to take NBRWs of length l = Ω(log n) on a graph with girth at least l, then the visited nodes by each ball generates a random hyperedge of size l + 1. Then applying the Godfrey's result [10] implies a constant maximum load whp. So, for the rest of the paper we focus on NBRWs of sub-logarithmic length (i.e., l = o(logd n)). We also assume that l = ω(1) and G is a d-regular n-vertex graph with girth at least ω(l log log n) and d = ω(log n). However, when l = (cid:98)(log n) 2 (cid:99), for any constant  ∈ (0, 1), G with girth at least ω(l) suffices as well. It is worth mentioning that there exist several explicit families of n-vertex d-regular graph with arbitrary degree d (cid:62) 3 and girth Ω(logd n) (see e.g. [9]). 1+ In order to present the upper bound, we consider two cases: I. If l (cid:62) 4γG, where γG =(cid:112)logd n, then we show that whp, (cid:19) (cid:18) log log n ∗ m = O log(l/γG) . 2 (cid:99), for any Thus, for a given G satisfying the girth condition, if we set l = (cid:98)(logd n) constant  ∈ (0, 1), then we have l/γG (cid:62) (log n)/2 and by applying the above upper bound we have m∗ = O(1/) whp. 1+ ∗ m = O (cid:19) . (cid:18) logd n · log log n (cid:18) logd n (cid:19) l2 ∗ m = Ω l2 II. If ω(1) (cid:54) l (cid:54) 4 · γG, then we show that whp, In addition to the upper bound, we prove that whp, (for a proof see Appendix F). If G is a d-regular graph with d ∈ [3,O(log n)], then we slightly modify allocation algorithm A(G, l) and show the similar results for m∗ in l. The algorithm A(cid:48)(G, l) for sparse graphs proceeds as follows: Let us first define parameter For each ball t, the ball takes a NBRW of size l · rG, say (u0, u1,··· , ulrG ), and then a subset of visited nodes, {uj·rG 0 (cid:54) j (cid:54) l}, called potential choices, is selected and finally the ball rG = (cid:100)2 · logd−1 log n(cid:101). 2 is allocated on a least-loaded node of potential choices (ties are broken randomly). Provided G has sufficiently large girth, we show the similar upper and lower bounds as the allocation algorithm A(G, l) on d-regular graphs with d = ω(log n) (see Appendix E ). 1+ Comparison with Related Works. The setting of our work is closely related to [6]. In this paper in each step a ball picks a node of a graph uniformly at random and performs a local search to find a node with local minimum load and finally allocates itself on it. They showed that with high probability the local search on expander graphs obtains a maximum load of Θ(log log n). In comparison to the mentioned result, our new protocol achieves a further reduction in the maximum load, while still allocating a ball close to its origin. Our result suggests a trade off between allocation time and maximum load. In fact we show a constant 2 , for any constant  ∈ (0, 1)). Our upper bound for sufficient long walks (i.e., l = (log n) work can also be related to the one by Kenthapadi and Panigrahy where each ball picks a random edge from a nΩ(1/ log log n)-regular graph and places itself on one of the endpoints of the edge with smaller load. This model results into a maximum load of Θ(log log n). Godfrey [10] considered balanced allocation on hypergraphs where balls choose a random edge e of a hypergraph satisfying some conditions, that is, first the size of each edge s is Ω(log n) and Pr [u ∈ e] = Θ( s n ) for any bin u. The latter one is called balanced condition. Berenbrink [5] simplified Godfrey's proof and slightly weakened the balanced condition but since et al. both analysis apply a Chernoff bound, it seems unlikely that one can extend the analysis for hyperedges of size o(log n). Our model can also be viewed as a balanced allocation on hypergraphs, because every l-walk is a random hyperedge of size l + 1 that also satisfies the balanced condition (see Lemma A.4). By setting the right parameter for l = o(log n), we show that the algorithm achieves a constant maximum load with sub-logarithmic number of choices. In a different context, Alon and Lubetzky [2] showed that if a particle starts a NBRW of length n on n-vertex graph with high-girth then the number of visits to nodes has a Poisson distribution. In particular they showed that the maximum visit to a node is at most (1 + o(1)) · log n log log n . Our result can be also seen as an application of the mathematical concept of NBRWs to task allocation in distributed networks. l + 1 choices and hence, by pigeonhole principle there is a node with load at least Ω(cid:0)logd n/l2(cid:1), Techniques. To derive a lower bound for the maximum load we first show that whp there is a path of length l which is traversed by at least Ω (logd n/l) balls. Also, each path contains which is a lower bound for m∗. We establish the upper bound based on witness graph tech- niques. In our model, the potential choices for each ball are highly correlated, so the technique for building the witness graph is somewhat different from the one for standard balls-into-bins. Here we propose a new approach for constructing the witness graph. We also show a key property of the algorithm, called (α, n1)-uniformity, that is useful for our proof technique. We say an allocation algorithm is (α, n1)-uniform if the probability that, for every 1 (cid:54) t (cid:54) n1, ball t is placed on an arbitrary node is bounded by α/n, where n1 = Θ(n) and α = O(1). Using this property we conclude that for a given set of nodes of size Ω(log n), after allocating n1 balls, the average load of nodes in the set is some constant whp. Using witness graph method we show that if there is a node with load larger than some threshold then there is a collection of nodes of size Ω(log n) where each of them has load larger than some specified constant. Putting these together implies that after allocating n1 balls the maximum load, say m∗ 1, is bounded as required whp. To derive an upper bound for the maximum load after allocation n balls, we divide the allocation process into n/n1 phases and show that the maximum load at the end of each phase increases by at most m∗ 1 and hence m∗ (cid:54) (n/n1)m∗ 1 whp. Discussion and Open Problems. In this paper, we proposed balls-into-bins model, where each ball picks a set of nodes that are visited by a NBRW of length l and place itself on a visited node with minimum load. One may ask whether it is possible to replace a NBRW of length l by several parallel random walks of shorter length (started from the same node) and get the similar results? In our result we constantly use the assumption that the graph locally looks like a d-ary tree. It is also known that cycles in random regular graph are restively far from each other (e.g, see [8]), so we believe that our approach can be extended for balanced allocation on random regular graphs. Many works in this area (see e.g.[6, 11]) assumed that the underlying networks is regular, it would be interesting to investigate random walk-based algorithms for irregular graphs. Outline. In Section 2, we present notations and some preliminary results that are required for the analysis of the algorithm. In Section 3 we show how to construct a witness graph and 3 then in Section 4 by applying the results we the upper bound for the maximum load. 2 Notations, Definitions and Preliminaries In this section we provide notations, definitions and some preliminary results. A non-backtracking random walk (NBRW) W of length l started from a node is a simple random walk in l steps so that in each step the walker picks a neighbor uniformly at random and moves to that neighbor with an additional property that the walker never traverses an edge twice in a row. Through- out this paper we assume that l ∈ [ω(1), o(logd n)] is a given parameter and G is a d-regular graph with girth 10 · l · log log n. Note that we will see that the condition on the girth can be relaxed to ω(l), for any l higher than (logd n) 2 , where  ∈ (0, 1) is a constant. 1+ It is easy to see that the visited nodes by a non-backtracking walk of length l on G induces a path of length l, which is called an l-walk. For simplicity, we use W to denote both the l-walk and the set of visited nodes by the l-walk. Also, we define f (W ) to be the number of balls in a least-loaded node of W . The height of a ball allocated on a node is the number balls that are placed on the node before the ball. For every two nodes u, v ∈ V (G), let d(u, v) denote the length of shortest path between u and v in G. Since G has girth at least ω(l), every path of length at most l is specified by its endpoints, say u and v. So we denote the path by interval [u, v]. Note that for any graph H, V (H) denotes the vertex set of H. Definition 1 (Interference Graph). For every given pair (G, l), the interference graph I(G, l) is defined as follows: The vertex set of I(G, l) is the set of all l-walks in G and two vertices W and W (cid:48) of I(G, l) are connected if and only if W ∩ W (cid:48) (cid:54)= ∅. Note that if pair (G, l) is clear from the context, then the interference graph is denoted by I. Now, let us interpret allocation process A(G, l) as follows: For every ball 1 (cid:54) t (cid:54) n, the algorithm picks a vertex of I(G, l), say Wt, uniformly at random and then allocates ball t on a least-loaded node of Wt (ties are broken randomly). Let 1 (cid:54) n1 (cid:54) n be a given integer and assume that A(G, l) has allocated balls until the n1-th ball. We then define Hn1 (G, l) to be the induced subgraph of I(G, l) by {Wt : 1 (cid:54) t (cid:54) n1} ⊂ V (I). Definition 2. Let λ and µ be given positive integers. We say rooted tree T ⊂ I(G, l) is a (λ, µ)-tree if T satisfies: 1) V (T ) = λ, 2) ∪W∈V (T ) W (cid:62) µ. Note that the latter condition is well-defined because every vertex of T is an (l + 1)-element subset of V (G). A (λ, µ)-tree T is called c-loaded, if T is contained in Hn1 (G, l), for some 1 (cid:54) n1 (cid:54) n, and every node in ∪W∈V (T )W has load at least c. 2.1 Appearance Probability of a c-Loaded (λ, µ)-Tree In this subsection we formally define the notion of (α, n1)-uniformity for allocation algorithms, and then present our key lemma concerning the uniformity of A(G, l). By using this lemma we establish an upper bound for the probability that a c-loaded (λ, µ)-tree contained in Hn1 exists. The proof of the following lemmas can be found in Appendix A. Definition 3. Suppose that B be an algorithm that allocates n sequential balls into n bins. Then we say B is (α, n1)-uniform if, for every 1 (cid:54) t (cid:54) n1 and every bin u, after allocating t balls we have that Pr [ball t + 1 is allocated on u ] (cid:54) α n , where α is some constant and n1 = Θ(n). Lemma 2.1 (Key Lemma). A(G, l) is an (α, n1)-uniform allocation algorithm, where n1 = (cid:98)n/(6eα)(cid:99). In the next lemma, we derive an upper bound for the appearance probability a c-loaded (λ, µ)-tree, whose proof is inspired by [11, Lemma 2.1]. Lemma 2.2. Let λ, µ and c be positive integers. Then the probability that there exists a c-loaded (λ, µ)-tree contained in Hn1 (G, l) is at most n · exp(4λ log(l + 1) − cµ). 4 Figure 1: The Partition step on W for k = 4 and the Branch step for P2 that gives WP2 , shown by dashed line. 3 Witness Graph In this section, we show that if there is a node whose load is larger than a threshold, then we can construct a c-loaded (λ, µ)-tree contained in Hn1 (G, l). Our construction is based on an iterative application of a 2-step procedure, called Partition-Branch. Before we explain the construction, we draw the reader's attention to the following remark: Remark. The intersection (union) of two arbitrary graphs is a graph whose vertex set and edge set are the intersection (union) of the vertex and edge sets of those graphs. Let ∩g and ∪g denote the graphical intersection and union. Note that we use ∩ (∪) to denote the set intersection (union) operation. Moreover, since G has girth ω(l), the graphical intersection of every two l-walks in G is either empty or a path (of length (cid:54) l). Recall that W denotes both an l-walk and the set of nodes in the l-walk. Partition-Branch. Let k (cid:62) 1 and ρ (cid:62) 1 be given integers and W be an l-walk with f (W ) (cid:62) ρ + 1. The Partition-Branch procedure on W with parameters ρ and k, denoted by P B(ρ, k), proceeds as follows: Partition: It partitions W into k edge-disjoint subpaths: Pk(W ) = {[ui, ui+1] ⊂ W, 0 (cid:54) i (cid:54) k − 1}, where d(ui, ui+1) ∈ {(cid:98)l/k(cid:99),(cid:100)l/k(cid:101)}. Branch: For a given Pi = [ui, ui+1] ∈ Pk(W ), it finds (if exists) another l-walk WPi intersecting Pi that satisfies the following conditions: (C1) ∅ (cid:54)= WPi ∩ W ⊆ Pi \ {ui, ui+1}. (C2) f (WPi ) (cid:62) f (W ) − ρ. We say procedure P B(ρ, k) on a given l-walk W is valid, if for every P ∈ Pk(W ), WP exists. We usually refer to W as the father of WP . For a graphical view of the Partition- Branch procedure see Figure 1. Definition 4 (Event Nδ). For any given 1 (cid:54) δ (cid:54) l, we say that event Nδ holds, if after allocating at most n balls by A(G, l), every path of length δ is contained in less than 6 logd−1 n/δ l-walks that are randomly chosen by A(G, l). For the sake of construction, let us define a set of parameters, depending on d, n, and l, which are used throughout the paper k := max{4,(cid:98)l/(cid:112)logd n(cid:99)}, δ := (cid:98)(cid:98)l/k(cid:99)/4(cid:99), ρ := (cid:100)6 logd n/δ2(cid:101). Lemma 3.1. Suppose that event Nδ holds and W be an l-walk with f (W ) (cid:62) ρ + 1. Then the procedure P B(ρ, k) on W is valid. For a proof see Appendix B. 5 u0u1u2u3u4WWP2P1P3P4P2 Figure 2: The first level L1 = {WP1 , WP2 , WP3 , WP4} and the Branch step for free subpaths of Pk(WP1 ). 3.1 Construction of Witness Graph In this subsection, we show how to construct a c-loaded (λ, µ)-tree contained in Hn1 . Let Un1,l,h denote the event that after allocating at most n1 (cid:54) n balls by A(G, l) there is a node with load at least hρ + c + 1, where c = O(1) and h = O(log log n) are positive integers that will be fixed later. Suppose that event Un1,l,h conditioning on Nδ happens. Then there is an l-walk R, called root, that corresponds to the ball at height hρ + c and has f (R) (cid:62) hρ + c. Applying Lemma 3.1 shows that P B(ρ, k) on R is valid. So, let us define which is called the first level and R is the father of all l-walks in L1. (C2) in the Partition-Branch procedure ensures that for every W ∈ L1, L1 := {WP , P ∈ Pk(R)}, f (W ) (cid:62) (h − 1)ρ + c. Once we have the first level we recursively build the i-th level from the (i − 1)-th level, for every 2 (cid:54) i (cid:54) h. We know that each W except R is created by the Branch step on its father. Let us fix W ∈ Li−1 and its father W (cid:48). We then apply the Partition step on W and get Pk(W ). We say P ∈ Pk(W ) is a free subpath if it does not share any node with W (cid:48). By (C1), we have that ∅ (cid:54)= W ∩ W (cid:48) = [u, v] ⊂ P (cid:48), for some P (cid:48) ∈ Pk(W (cid:48)) and hence d(u, v) (cid:54) (cid:100)l/k(cid:101). So, [u, v] shares node(s) with at most 2 subpaths in Pk(W ) and thus Pk(W ) contains at least k − 2 free subpaths. Let P 0 k (W ) ⊂ Pk(W ) denote an arbitrary set of free subpaths of size k − 2. By (C2) and the recursive construction, we have that f (W ) (cid:62) (h− i + 1)ρ + c, for each W ∈ Li−1. Therefore, by Lemma 3.1, P B(ρ, k) on W is valid. Now we define the i-th level as follows, (cid:91) W∈Li−1 Li = {WP , P ∈ P 0 k (W )}. pens.Then there exists a c-loaded (λ, µ)-tree T ⊂ Hn1 , where λ = 1 + k(cid:80)h−1 For a graphical view see Figure 2. The following lemma guarantees that our construction gives a c-loaded (λ, µ)-tree in Hn1 with desired parameters (for a proof see Appendix C). Lemma 3.2. Suppose that G has girth at least 10hl and Un1,l,h conditioning on Nδ hap- j=0 (k − 2)j and µ = (l + 1) · k(k − 2)h−1. 4 Balanced Allocation on Dense Graphs In this section we show the upper bound for the maximum load attained by A(G, l) for d- regular graph with d = ω(log n). Let us recall the set of parameters for given G and l as follows, k := max{4,(cid:98)l/(cid:112)logd n(cid:99)}, δ := (cid:98)(cid:98)l/k(cid:99)/4(cid:99), ρ := (cid:100)8 logd n/δ2(cid:101), 6 WP1RWP4freesubpathsWP2WP3 and Un1,l,h is the event that at the end of round n1, there is a nodes with load at least hρ+c+1, where c is a constant and (cid:24) log log n log(k − 2) (cid:25) . h := Note that when l = (log n) (cid:108) log log n log(k−2) (cid:109) Thus, h = 1+ 2 with constant  ∈ (0, 1), then k = (cid:98)l/(cid:112)logd n(cid:99) (cid:62) l/(cid:112)log3 n (cid:62) (log n)/3. is a constant. Therefore, in order to apply Lemma 3.2 for this case, it is sufficient that G has girth at least 10hl or ω(l). Also we have the following useful lemma whose proof appears in Appendix D. Lemma 4.1. With probability 1 − o(1/n), Nδ holds. Theorem 4.2. Suppose that G is a d-regular graph with girth at least 10hl and d = ω(log n). Then, with high probability the maximum load attained by A(G, l), denoted by m∗, is bounded from above as follows: I. If ω(1) (cid:54) l (cid:54) 4γG, where γG =(cid:112)logd n. Then we have (cid:18) logd n · log log n (cid:19) (cid:18) log log n II. If l (cid:62) 4γG, then we have = O ∗ m l2 (cid:19) . ∗ m = O log(l/γG) . Note that when l = Θ(γG), we get the maximum load O(log log n). Proof. By Lemma 2.1 we have that A(G, l) is an (α, n1)-uniform, where n1 = (cid:98)n/(6eα)(cid:99). Let us divide the allocation process into s phases, where s is the smallest integer satisfying sn1 (cid:62) n. We now focus on the maximum load attained by A after allocating n1 balls in the first phase, which is denoted by m∗ 1. Let us assume that Un1,l,h happens. Now, in order to apply Lemma 3.2, we only need that G has girth at least 10hl. By Lemma 3.2, if Un1,l,h conditioning on Nδ happens, then there is a c-loaded (λ, µ)-tree T contained in Hn1 , where j=0 (k − 2)j and µ = (l + 1) · k(k − 2)h−1. Thus, we get λ = 1 + k(cid:80)h−1 Pr [Un1,l,h Nδ] Pr [Nδ] (cid:54) Pr [T exists Nδ] Pr [Nδ] = Pr [T exists and Nδ] (cid:54) Pr [T exists] . Therefore using the law of total probability and the above inequality we have Pr [Un1,l,h] = Pr [Un1,l,h Nδ] Pr [Nδ] + Pr [Un1,l,h ¬Nδ] Pr [¬Nδ] (cid:54) Pr [T exists] + Pr [¬Nδ] = Pr [T exists] + o(1/n). (1) where the last inequality follows from Pr [¬Nδ] = o(1/n) by Lemma 4.1. By definition of h, we get λ = 1 + k(1 + (k − 2)h) (cid:54) 2k log n and µ = (l + 1)k(k − 2)h−1 (cid:62) (l + 1)(k − 2)h (cid:62) (l + 1) log n. It only remains to bound Pr [T exists]. By applying Lemma 2.2 and substituting µ and λ, we conclude that Pr [T exists] (cid:54) n exp(4λ log(l + 1)) − cµ) (cid:54) n exp{−z log n}, where z = c(l + 1) − 8k log(l + 1). Depending on k we consider two cases: First, k = 4. Then it is easy to see there exists a constant c such that z (cid:62) 2. Second, k = (cid:98)l/γG(cid:99). We know that l < logd n, so we have l (cid:54) γ2 G and hence, z (cid:62) cl − 8l log l/γG (cid:62) l(c − 16 log γG/γG) = l(c − o(1)). This yields that for some integer c > 0, z = l(c − o(1)) > 2 and hence in both cases we get 1 (cid:54) hρ + c + 1 with probability Pr [T exists] = o(1/n). Now, by Inequality (1) we infer that m∗ 1 − o(1/n). In what follows we show the sub-additivity of the algorithm and concludes that 7 in the second phase the maximum load increases by at most m∗ 1 whp. Assume that we have a copy of G, say G(cid:48), whose nodes have load exactly m∗ 1. Let us consider the allocation process of a pair of balls (n1 + t, t), for every 0 (cid:54) t (cid:54) n1, by A(G, l) and A(G(cid:48), l). Let X n1+t and Y t u , t (cid:62) 0 denote the load of u ∈ V (G) = V (G(cid:48)) after allocating balls n1 + t and t by A(G, l) and A(G(cid:48), l), respectively. Now we show that for every integer 0 (cid:54) t (cid:54) n1 and u ∈ V (G) we have that u X n1+t u (cid:54) Y t u . u = m∗ (2) When t = 0, clearly the inequality holds because Y 0 1. We couple the both allocation processes A(G, l) and A(G(cid:48), l) for a given pair of balls (n1 + t, t), t (cid:62) 0, as follows. For every 1 (cid:54) t (cid:54) n1, the coupled process first picks a one-to-one labeling function σt : V (G) → {1, 2, . . . , n} uniformly at random. (Note that σt is also defined for G(cid:48) as V (G) = V (G(cid:48)).) Then it applies A(G, l) and selects l-walks Wn1+t and its copy, say W (cid:48) t , in G(cid:48). After that, balls n1 + t and t are allocated on least loaded nodes of Wn1+t and W (cid:48) t , respectively, and ties are broken in favor of nodes with minimum label. It is easily checked that the defined process is a coupling. Let us assume that Inequality (2) holds for every t0 (cid:54) t, then we show it for t + 1. Let v ∈ Wn1+t+1 and v(cid:48) ∈ W (cid:48) t+1 denote the nodes that are the destinations of pair (n1 + t + 1, t + 1). Now we consider two cases: 1. X n1+t v < Y t v . Then allocating ball n1 + t + 1 on v implies that v (cid:54) Y t+1 (cid:54) Y t So, Inequality (2) holds for t + 1 and every u ∈ V (G). + 1 = X n1+t+1 X n1+t . v v v 2. X n1+t v = Y t v . Since Wn1+t+1 = W (cid:48) t+1, v ∈ W (cid:48) t+1 and v(cid:48) ∈ Wn1+t+1. Also we know that v and v(cid:48) are nodes with minimum load contained in Wn+t+1 and Wt+1, So we have, Since Y t v = X n1+t v X n1+t v (cid:54) X n1+t v(cid:48) (cid:54) Y t v(cid:48) (cid:54) Y t v . , we have v(cid:48) = Y t Y t v = X n1+t v . If v (cid:54)= v(cid:48) and σt+1(v(cid:48)) < σt+1(v), then it contradicts the fact that ball n1 + t + 1 is allocated on v. Similarly, if σt+1(v(cid:48)) > σt+1(v), it contradicts that ball t is allocated on v(cid:48). So, we have v = v(cid:48) and X n1+t v + 1 = X n+t+1 v = Y t v + 1 = Y t+1 v . So in both cases, Inequality (2) holds for every t (cid:62) 0. If we set t = n1, then the maximum load attained by A(G(cid:48), l) is at most 2m∗ 1 is an upper bound for the maximum load attained by A(G, l) in the second phase as well. Similarly, we apply the union bound and conclude that after allocating the balls in s phases, the maximum load m∗ is at most sm∗ 1 whp. Therefore, by Inequality (2), 2m∗ 1 with probability 1 − o(s/n) = 1 − o(1/n). Acknowledgment. problem and several helpful discussions. The author wants to thank Thomas Sauerwald for introducing the References [1] Noga Alon, Itai Benjamini, Eyal Lubetzky, and Sasha Sodin. Non-backtracking random walks mix faster. Communications in Contemporary Mathematics, 9:585–603, 2007. [2] Noga Alon and Eyal Lubetzky. Poisson approximation for non-backtracking random walks. Israel J. Math., 174(1):227–252, 2009. [3] Anne Auger and Benjamin Doerr. Theory of Randomized Search Heuristics: Foundations and Recent Developments. World Scientific Publishing Co., Inc., River Edge, NJ, USA, 2011. [4] Yossi Azar, Andrei Z. Broder, Anna R. Karlin, and Eli Upfal. Balanced allocations. SIAM J. Comput., 29(1):180–200, 1999. [5] Petra Berenbrink, Andr´e Brinkmann, Tom Friedetzky, and Lars Nagel. Balls into bins with related random choices. J. Parallel Distrib. Comput., 72(2):246–253, 2012. [6] Paul Bogdan, Thomas Sauerwald, Alexandre Stauffer, and He Sun. Balls into bins via local search. In Proc. 24th Symp. Discrete Algorithms (SODA), pages 16–34, 2013. 8 [7] John W. Byers, Jeffrey Considine, and Michael Mitzenmacher. Geometric generaliza- tions of the power of two choices. In Proc. 16th Symp. Parallelism in Algorithms and Architectures (SPAA), pages 54–63, 2004. [8] Colin Cooper, Alan M. Frieze, and Tomasz Radzik. Multiple random walks in random regular graphs. SIAM J. Discrete Math., 23(4):1738–1761, 2009. [9] Xavier Dahan. Regular graphs of large girth and arbitrary degree. Combinatorica, 34(4):407–426, 2014. [10] Brighten Godfrey. Balls and bins with structure: balanced allocations on hypergraphs. In Proc. 19th Symp. Discrete Algorithms (SODA), pages 511–517, 2008. [11] Krishnaram Kenthapadi and Rina Panigrahy. Balanced allocation on graphs. In Proc. 17th Symp. Discrete Algorithms (SODA), pages 434–443, 2006. [12] Donald Knuth. The Art of Computer Programming, Vol. 1: Fundamental Algorithms. Adison-Wesley, third edition, 1997. [13] Micheal Mitzenmacher, Andr´ea W. Richa, and Ramesh Sitaraman. The power of two ran- dom choices: A survey of technique and results. In Handbook of Randomized Computation Volume 1, pages 255–312, 2001. [14] Yuval Peres, Kunal Talwar, and Udi Wieder. Graphical balanced allocations and the (1 + β)-choice process. Random Struct. Algorithms, DOI: 10.1002/rsa.20558, 2014. [15] Berthold Vocking. How asymmetry helps load balancing. J. ACM, 50(4):568–589, 2003. A Omitted Proofs of Section 2 In this section we show some useful results about interference graph I(G, l) and present the omitted proofs of Section 2. Lemma A.1. Suppose that V (I) and ∆(I) denote the vertex set and the maximum degree of interference graph I(G, l), respectively. Then we have, (i) V (I) = nd(d − 1)l−1/2, (ii) ∆(I) (cid:54) (l + 1)2d(d − 1)l−1. Furthermore, the number of rooted λ-vertex trees contained in I is bounded by 4λ · V (I) · ∆(I)λ−1. Proof. It is easy to see that in a graph with girth at least ω(l), the number of l-walks is exactly nd(d− 1)l−1/2, (without ordering) which is the size of V (I). Since the graph locally looks like a d-ary tree, the total number of l-walks including v as j-th visited node is at most d(d − 1)j−2(d − 1)l−j−1 = d(d − 1)l−1. Index j varies from 0 to l, so v can be an element of at most (l + 1)d(d − 1)l−1 l-walks. Also, every l-walk contains l+1 elements and hence every l-walk intersects at most (l+1)2d(d−1)l−1 other l-walks. Thus we get ∆(I) (cid:54) (l + 1)2 · d(d − 1)l−1. Let us now bound the total number of rooted λ-vertex trees contained in I. It was shown that the total number of different shape rooted trees on λ vertices is 4λ (For example see [12]); we say two rooted trees have different shapes if they are not isomorphic. For any given shape, there are V (I) ways to choose the root. As soon as the root is fixed, each vertex in the first level can be chosen in at most ∆(I) many ways. By selecting the vertices of the tree level by level we have that each vertex except the root can be chosen in at most ∆(I) ways. So the total number of rooted λ-vertex trees in I is bounded by 4λ · V (I) · ∆(I)λ−1. Corollary A.2. The size of family of (λ, µ)-trees is bounded by 4λV (I)∆(I)λ−1. Proof. We know that every (λ, µ)-tree T is a rooted λ-vertex subtree of I with the additional property that ∪W∈V (T ) W (cid:62) µ. This implies that the size of family of rooted λ-vertex subtrees of I is an upper bound for the size of family of (λ, µ)-trees and hence by applying Lemma A.1, we reach the upper bound 4λV (I)∆(I)λ−1. 9 A.1 Proof of the Key Lemma In this subsection we first present several useful lemmas and then show the key lemma 2.1. Before that let us define some notations. For every S ⊆ V (G), Emptyt(S) denotes the number of empty nodes contained in S after allocating t balls. Let N (v) denote the set of neighbors of v. Note that to avoid a lengthy case analysis we do not optimize the constants. Lemma A.3 (Deviation bounds for moderate independency). Let X1,··· , Xn be arbitrary 2 ,··· , X∗ binary random variables. Let X∗ 1 , X∗ n be binary random variables that are mutually i , is independent of X1,··· , Xi−1. Assume that for all independent and such that for all i, X∗ i and all x1, ..., xi−1 ∈ {0, 1}, Pr [Xi = 1X1 = x1,··· , Xi−1 = xi−1] (cid:62) Pr [X ∗ i = 1] . Then for all a (cid:62) 0, we have Pr (cid:34) n(cid:88) (cid:35) (cid:34) n(cid:88) Xi (cid:54) a (cid:54) Pr ∗ i (cid:54) a X (cid:35) and the latter term can be bounded by any deviation bound for independent random variables. i=1 i=1 The proof of the above lemma can be found in [3, Lemma 1.18]. Lemma A.4. Suppose that A(G, l) has allocated the balls until the (t + 1)-th ball, for some 0 (cid:54) t (cid:54) n. Then, for every given v ∈ V (G) we have l(cid:88) Pr [v ∈ Wt+1] = Pr [Ci] = (l + 1)/n, where Ci, 0 (cid:54) i (cid:54) l, is the event that for Wt+1 = (u0, u1, . . . , ul), we have v = ui. Furthermore, for every 0 (cid:54) i (cid:54) l, we have i=0 Pr [Ci] = 1/n. Proof. Let us fix an arbitrary 0 (cid:54) i (cid:54) l and any v ∈ V (G). Since G has girth at least ω(l) and locally looks like a d-regular tree, we can easily compute the number of l-walks visiting v in the i-th step, that is d(d − 1)i−2 × (d − 1)l−(i−1) = d(d − 1)l−1. On the other hand in each round, A(G, l) picks an l-walk randomly from nd(d− 1)l−1 possible l-walks. Thus, we get Pr [Ci] = d(d − 1)l−1 nd(d − 1)l−1 = 1 n and l(cid:88) i=0 l(cid:88) i=0 Pr [Ci] = 1 n = l + 1 n . Lemma A.5. Suppose that with probability 1 − o(n−2), for every u ∈ V (G), Then for every v ∈ V (G), Emptyt(N (u)) (cid:62) N (u)/2 = d/2. Pr [ball t + 1 is allocated on v by A ] (cid:54) α n , where α is a constant. Proof. Let Et+1,v be the event that ball t + 1 is placed on a given node v ∈ V (G) and Ft+1 be the event that at least l/10 of nodes in Wt+1 are empty. Let ¬Ft+1 denote the negation of Ft+1. Using the law of total probability, for every v ∈ V (G) we have Pr [Et+1,v] = Pr [Et+1,vv /∈ Wt+1] · Pr [v /∈ Wt+1] (cid:124) (cid:124) (cid:124) (cid:123)(cid:122) =0 (cid:123)(cid:122) (cid:54)1 (cid:125) (cid:123)(cid:122) (cid:125) (cid:54)(10/l) Pr[v∈Wt+1] + Pr [Et+1,vv ∈ Wt+1 and Ft+1] · Pr [v ∈ Wt+1 and Ft+1] (cid:125) + Pr [Et+1,uv ∈ Wt+1 and ¬Ft+1] · Pr [v ∈ Wt+1 and ¬Ft+1] (cid:54) 10 l · Pr [v ∈ Wt+1] + Pr [v ∈ Wt+1 and ¬Ft+1] 10 where the first summand follows since if v /∈ Wt+1, then ball t + 1 cannot be placed on v and the second one follows because ties are broken uniformly at random. Now, by applying Lemma A.4 and and Bayse' rule we have, Pr [Et+1,v] (cid:54) 10(l + 1) ln = 10(l + 1) ln + + Pr [ ¬Ft+1and Ci] Pr [ ¬Ft+1 Ci] (1/n). (3) l(cid:88) l(cid:88) i=0 i=0 In what follows we will show that for every i, Pr [¬Ft+1Ci] (cid:54) 12/l. Plugging the above bound in Inequity (3) yields that for every v ∈ V (G), Pr [Et+1,v] (cid:54) 22(l + 1) ln , where 22(l + 1)/l is indeed a constant and hence the statement is proved. Conditioning on event Ci, we only know that node v is the i-th visited node in Wt+1, for some 0 (cid:54) i (cid:54) l. Clearly, Wt+1 can be viewed as the union of two edge-disjoint NBRWs of lengths (i − 1) and l − (i − 1) started from v, namely W 1 v . Without loss of generality, assume that V (W 1 v and W 2 v ) = s (cid:62) 2 and let W 1 v = (v = u1, u2, . . . , us), where d(v, uj) < d(v, uj(cid:48) ) for every 1 < j < j(cid:48) (cid:54) s. Clearly, every uj ∈ W 1 v , 2 (cid:54) j (cid:54) s, is randomly chosen from a subset of N (uj−1), say Sj ⊆ N (uj−1) (because we run a NBRW from uj−1 to reach uj). If it happens that the NBRW has already traversed edge {w, uj−1}, for some node w, then the walk cannot take this edge again and hence Sj ∈ {d, d − 1}. Let us define an indicator random variable Xuj for every uj, 2 (cid:54) j (cid:54) s, which takes one whenever uj is empty and zero otherwise. Thus we have Pr(cid:2)Xuj = 1(cid:3) = Empty(Sj) Sj . Let Kj, 2 (cid:54) j (cid:54) s, denote the event that the number of empty nodes of N (uj−1) is at least d/2. By the assumption, we have Pr [Kj] = 1 − o(n−2). So, for every uj, 2 (cid:54) j (cid:54) s, we get (cid:3) Pr [Kj] + Pr(cid:2)Xuj = 1 ¬Kj Pr(cid:2)Xuj = 1(cid:3) = Pr(cid:2)Xuj = 1 Kj (cid:26) d/2 (cid:62) 1/2((d − 2)/(d − 1))(1 − o(n −2)) + o(n Empty(Sj) (cid:27) −2) (cid:62) 1/3, d/2 − 1 d − 1 , d d − 2 2(d − 1) = (cid:62) min Sj (cid:3) Pr [¬Kj] where the first inequality follows from Since the above lower bound is independent of any Xuj , 2 (cid:54) j(cid:48) (cid:54) j, we have that for every 2 (cid:54) j (cid:54) s, Pr(cid:2)Xuj = 1 Xu1 = x1,··· , Xuj−1 = xj−1 for every u ∈ Wt+1 \ {v}. Let Y = (cid:80) A similar argument also works for the nodes visited by W 2 t+1 and we get Pr [Xu = 1] (cid:62) 1/3, u∈Wt+1\{v} Xu be the number of empty nodes in Wt+1 \ {v}. Then, we have that E [Y ] (cid:62) l/3. Let Y ∗ be the summation of l independent Bernoulli random variables with success probability 1/3. By applying Lemma A.3 we get, (cid:3) (cid:62) 1/3. Pr [¬Ft+1Ci] (cid:54) Pr [Y < l/6] < E [Y (cid:54) Pr [Y ∗ ∗ We know that Var [Y ∗] (cid:54) E [Y ∗], so applying Chebychev's bound results into ] /2] (cid:54) Pr [Y ] (cid:62) E [Y ∗ − E [Y ∗ ∗ ] /2] . Pr [Y ∗ − E [Y ∗ ] (cid:62) E [Y ∗ ] /2] (cid:54) Var [Y ∗] (E [Y ∗] /2)2 (cid:54) 4 E [Y ∗] . Thus, we get Pr [¬Ft+1Ci] (cid:54) 4/E [Y ∗ ] (cid:54) 12/l. 11 In order to prove our key lemma, we apply a potential function argument which is similar to [6, Theorem 1.4 ]. Proof of Key Lemma 2.1. Let us define potential function (cid:88) u∈V (G) Φ(t) = exp(at(u)), where at(u) denotes the number of nonempty nodes of N (u) after allocating t balls. It is clear that Φ(0) = n. Let us assume that after allocating t balls we have Φ(t) (cid:54) n · ed/4. Since d = ω(log n), we get eat(u) (cid:54) Φ(t) (cid:54) elog n+d/4. at(u) (cid:54) log n + d/4 < d/2 and consequently Emptyt(N (u)) (cid:62) d variable It+1(u) for every u ∈ V (G) as follows: 2 , for every u ∈ V (G). Let us define indicator random It+1(u) := if ball t + 1 is placed on an empty node in N (u), otherwise. Applying Lemma A.5 shows that if Emptyt(N (u)) (cid:62) d 2 , then for every u ∈ V (G), (cid:26) 1 0 where α is a constant. So we get Pr [It+1(u) = 1] (cid:54) α · Emptyt(N (u)) n (cid:54) α · d n , E (cid:104) Φ(t + 1) Φ(t) (cid:54) n · ed/4(cid:105) (cid:54) (cid:88) (cid:19) (cid:54) (cid:88) (cid:110) Pr [It+1(u) = 1] · eat(u)+1 + Pr [It+1(u) = 0] · eat(u)(cid:111) (cid:18) α · e · d α · e · d u∈V (G) (cid:18) (cid:19) · eat(u) = Φ(t). 1 + 1 + u∈V (G) n n (cid:19) α · e · d (cid:18) Let us define Ψ(t) := min{Φ(t), n · e∆/4}. By using above recursive inequality we have that E [Ψ(t + 1)] (cid:54) 1 + Thus, inductively we have that E [Ψ(t)] (cid:54)(cid:0)1 + α·e·d Ψ(n1) (cid:62) n · ed/4(cid:105) (cid:54) applying Markov's inequality implies that (cid:104) Pr n n Ψ(t). (cid:1)t Ψ(0). Let us define n1 = n/(6eα). Then (cid:0)1 + α·e·d (cid:1)n1 −d/12 (cid:54) e n ed/4 So with probability 1 − n−ω(1), we have Φ(n1) = Ψ(n1) < n · ed/4. Since Φ(t) is an increasing function in t, we have that Φ(t) (cid:54) n · ed/4, for every 0 (cid:54) t (cid:54) n1, and hence with probability 1 − o(n−2), for every u ∈ V (G), Emptyt(N (u)) (cid:62) d/2. So, applying Lemma A.5 shows that for every 0 (cid:54) t (cid:54) n1 and u ∈ V (G), Pr [ball t + 1 is placed on u by A(G, l)] (cid:54) α n . 12 A.2 Proof of Lemma 2.2 Proof. Let us fix an arbitrary (λ, µ)-tree T ⊆ I(G, l) and p1 be the probability that using λ balls T is built and contained in Hn1 . There are at most n1 (cid:54) n ways to choose one ball per vertex of T and hence at most nλ ways to choose λ balls that are going to pick the vertices of T . On the other hand, every ball picks a given vertex of T with probability 1/V (I). Thus we get, p1 (cid:54) nλ · (1/V (I))λ. Now, we have to add c additional balls for very node in ∪W∈V (T )W , where ∪W∈V (T ) W = µ + q, for some integer q (cid:62) 0. Let p2 denote the probability that such a event happens. Since A(G, l) is (α, n1)-uniform with n1 = (cid:98)n/(6eα)(cid:99), we get p2 (cid:54) (cid:54) c · (µ + q) n1 (cid:32) (cid:18) e · n1 (cid:16) n1 · α · e c · (µ + q) (cid:33)(cid:18) α · (µ + q) (cid:19)c·(µ+q) · (cid:17)c·(µ+q) n q=0 ∞(cid:88) ∞(cid:88) ∞(cid:88) q=0 (cid:54) n · c (cid:54) 2 · (1/6c)cµ, q=0 (cid:19)c·(µ+q) (cid:18) α · (µ + q) ∞(cid:88) (cid:1) (cid:54) ( eb q=0 n = (1/6c)cµ (1/6c)cq (cid:19)c·(µ+q) where we use the fact that for integers 1 (cid:54) a (cid:54) b,(cid:0)b from (cid:80)∞ a )a and the last inequality follows q=0(1/6c)cq (cid:54) 2. Since balls are mutually independent, p1 · p2 is an upper bound for the probability that c-loaded (λ, µ)-tree T appears in Hn1 . By Corollary A.2 we have an upper bound for the size of family of all (λ, µ)-trees. Hence, taking the union bound over all (λ, µ)-trees gives an upper bound for appearance probability of a c-loaded (λ, µ)-tree in Hn1 . Thus we get, a 4λV (I) · ∆λ−1 · p1 · p2 (cid:54) 2 · 4λV (I) · ∆λ−1 (cid:19)c·µ (cid:19)λ · (cid:18) n (cid:18) 1 (cid:19)λ−1 · (cid:19)c·µ (cid:18) 1 V (I) . 6c 6 · c (cid:18) ∆(I) V (I) (cid:54) 2n · 4λ · By Lemma A.1 we have V (I) = nd(d − 1)l−1/2, ∆(I) (cid:54) (l + 1)2d(d − 1)l−1. So the above bound is simplified as follows, 2n · 4λ(cid:0)2(l + 1)2(cid:1)λ−1(cid:18) 1 (cid:19)c·µ (cid:54) n(l + 1)4λ6 6 −cµ (cid:54) n exp(4λ log(l + 1) − cµ), where the first inequality follows from 2 · 4λ · 2λ−1(l + 1)2(λ−1) = 8λ(l + 1)2(λ−1) (cid:54) (l + 1)4λ, which is true for every l (cid:62) 2. B Proof of Lemma 3.1 Proof. Let us fix an arbitrary subpath Pi = [ui, ui+1] ∈ Pk(W ) and partition it into 3 edge- disjoint subpaths, say Pi = [ui, u] ∪g [u, v] ∪g [v, ui+1], such that where δ = (cid:98)(cid:98)l/k(cid:99)/4(cid:99). By the Partition step in P B(ρ, k), we know that d(ui, u) = d(v, ui+1) = δ, d(ui, ui+1) ∈ {(cid:98)l/k(cid:99),(cid:100)l/k(cid:101)}. So we have d(u, v) = d(ui, ui+1) − 2δ (cid:62) 4δ − 2δ = 2δ. Let S = W ∩ V ([u, v]) and B(S) denotes the set of all balls allocated on nodes of S at height at least f (W ) − ρ. Let Wt denote the chosen l-walk by ball t ∈ B(S). Since each ball t ∈ B(S) was allocated on a node of S at height at least f (W )−ρ, we have that Wt intersects [u, v] ⊂ Pi, 13 f (Wt) (cid:62) f (W )− ρ and Wt ∩ W (cid:54)= ∅. So each Wt satisfies (C2). Now, among all Wt, t ∈ B(S), we find an l-walk that satisfies (C1) as well. We have S (cid:62) 2δ, Every node in S has load at least f (W ) (cid:62) ρ + 1. So, every node in S has at least ρ balls at height at least f (W ) − ρ (cid:62) 1. Therefor we have, B(S) (cid:62) Sρ (cid:62) (2δ)ρ (cid:62) (2δ)(6 logd−1 n/δ2) = 12 logd−1 n/δ. By using the above inequality we have, {Wt, t ∈ B(S)} = B(S) (cid:62) 12 logd−1 n/δ. Recall that Pi = [ui, u]∪ [u, v]∪ [v, ui+1]. If for some t ∈ B(S), Wt contains ui (or ui+1), then it also contains subpath [ui, u] (or [v, ui+1]), because Wt intersects [u, v] and G has girth ω(l). Conditioning on Nδ, [ui, u] and [v, ui+1] are contained in less than 12 logd−1 n/δ l-walks. So the above inequality shows that there is at least one ball, say t0 ∈ B(S), whose corresponding l-walk Wt0 contains neither ui nor ui+1 and thus it satisfies (C1). Therefore we conclude that, for each Pi ∈ Pk(W ), WPi exists and P B(ρ, k) on W is valid. C Proof of Lemma 3.2 Before we present the proof of Lemma 3.2, we need to show some lemmas about the properties of the recursive construction of the witness tree. Suppose that Hj ⊂ G, 0 (cid:54) j (cid:54) h, be the graphical union of all l-walks up to j + 1-the level (i.e., Lj+1). Then we have the following lemma. Lemma C.1. If G has girth at least 10hl, then, for every 0 (cid:54) j (cid:54) h, Hj is a tree. Proof. When j = 0, clearly H0 = R, where R is the root. So the diameter of H0 is l. Assume that for some j0, 0 (cid:54) j0 < h, the diameter of Hj0 is at most (2j0 + 1)l. We know that every l-walk in the (j0 + 1)-th level intersects a path in Hj0 so the distance between any two nodes of Hj0+1 increases by at most 2l and thus the diameter of Hj0+1 is at most (2j0 + 1)l + 2l = (2(j0 + 1) + 1)l. So we inductively conclude that, for every 0 (cid:54) j (cid:54) h, Hj has diameter at most (2j + 1)l. If for some j, 0 (cid:54) j (cid:54) h, Hj contains a cycle, then the length of the cycle is at most 2 · diam(Hi) (cid:54) 2(2j + 1)l (cid:54) 6hl which contradicts the fact that Hj ⊂ G and G has girth at least 10hl. Lemma C.2. For every 1 (cid:54) j (cid:54) h, the j-th level contains k(k − 2)j−1 disjoint l-walks. Moreover every l-walk in the j-the level only intersects one l-walk in the previous levels, which is its father. Proof. Let us begin with j = 1. For the sake of a contradiction, assume that WPi , WPi(cid:48) ∈ L1 intersect each other. Recall that the l-walks are created by the Branch step over the edge- disjoint paths, say Pi = [ui1 , ui+1] and Pi(cid:48) = [ui(cid:48) , ui(cid:48)+1] ∈ Pk(R). Clearly, WPi ∪g WPi(cid:48) is a connected graph as they intersect each other. So, by Condition (C1), in the Partition-Branch procedure, we choose two arbitrary nodes z ∈ V (Pi) ∩ WPi and z(cid:48) ∈ V (Pi(cid:48) ) ∩ WPi(cid:48) . Also, let {ui, ui+1} and {ui(cid:48) , ui(cid:48)+1} be the boundary of Pi and Pi(cid:48) , respectively. Since H0 is a tree, there is a unique path, say Qz,z(cid:48) , in H0 = R connecting z to z(cid:48). Nodes z and z(cid:48) have degree 2 in H0, so Qz,z(cid:48) contains nodes from boundaries of Pi and Pi(cid:48) . By (C1), WPi and WPi(cid:48) excludes the boundaries. Thus we get a path from z to z(cid:48) via WPi ∪g WPi(cid:48) ⊂ H1 that excludes the boundaries. This contradicts the fact that there is a unique path in H1 ⊃ H0, because H1 is a tree by Lemma C.1. So we infer that there are k disjoint l-walks in L1 and they only intersect their father (i.e., R). Recall that P ∈ Pk(W ) is a free subpath if it does not share any node with W 's father. Since W 's, W ∈ L1, are mutually disjoint, the nodes contained in the set of free subpaths, P 0 k (W ), for each W ∈ L1, have degree at most 2 in H1, which we call it D1 property. In other word, D1 property says that any path in H1 between nodes of two free subpaths in the first level includes nodes from boundaries of the subpaths (see Figure 2). Suppose that for some j0, 1 (cid:54) j0 (cid:54) h, the statement of the lemma and Dj0 hold. Then we show them for the next level as well. 14 Similar to case j = 1, toward a contradiction assume that two l-walks WP , WP (cid:48) ∈ Lj0+1 intersect each other. Then, by (C2) we get a path in WP ∪g WP (cid:48) ⊂ Hj0+1 excluding the boundaries of P and P (cid:48) that connects a node, say x, from P to another node, say y, in P (cid:48). By Dj0 property, the path in Hj0 connecting x to y uses nodes from the boundaries, while we get a path in Hj0+1 that exclude boundaries. This is a contradiction because Hj0+1 ⊃ Hj0 is a tree by Lemma C.1. So the l-walls in Lj0+1 are disjoint and by the construction we have Lj0+1 = (k − 2)Lj0 and hence Lj0+1 = k(k − 2)j0 . It only remains to prove every l-walk only intersect its father in previous levels. Toward a contradiction assume that WP ∈ Lj0+1 intersects a path, say W , in previous levels that is not its father. Let z(cid:48) ∈ WP ∩ W and z ∈ WP ∩ V (P ) ⊂ V (P ) where P = [u, v] ∈ P 0 k (W (cid:48)) and W (cid:48) is the father of WP . By (C2), z is neither u nor v. We now get a new path from z to z(cid:48) in Hj0+1 excluding u and v (via Wp ∪g W ) that contradicts the fact that there is only one path from z to z(cid:48) in Hj0 including a node from the boundary of P , as Dj0 property holds. We showed that every two l-walks in Lj0+1 are disjoint, so the Dj0+1 holds as well. (cid:83)h Proof of Lemma 3.2. Let us consider a graph T whose nodes are the set of all l-walks in j=0 Lj, where L0 = {R}. And two nodes are connected, if and only if the corresponding l-walks intersect each other or vice versa. By Lemma C.2 for every 1 (cid:54) j (cid:54) h, the j-th, level contains k(k − 2)j−1 disjoint l-walks and they intersect either their fathers or their k − 2 children. This implies that T is a subtree of interference graph Hn1 with h−1(cid:88) V (T ) = λ = 1 + k (k − 2)j. If we only consider the h-th level, then we get (cid:12)(cid:12)∪W∈V (T )W(cid:12)(cid:12) (cid:62) µ = (l + 1) · k(k − 2)h−1. j=0 By (C2) in the Partition-Branch procedure we have that for every W ∈ Lj, 1 (cid:54) j (cid:54) h, Hence every node in ∪W∈V (T )W has load at least c. f (W ) (cid:62) (h − j)ρ + c. D Proof of Lemma 4.1 Proof. Let us fix an arbitrary path [u, v] of length δ, where δ = (cid:98)(cid:98)l/k(cid:99)/4(cid:99) = min{(cid:98)l/16(cid:99),(cid:98)(cid:112)logd n/4(cid:99)}. The latter equality is true because we set k = max{4,(cid:98)l/(cid:112)logd n(cid:99)}. Clearly, if W be an l-walk and [u, v] ⊆ W = [u0, ul], then d(u0, u) + d(v, ul) = l − δ. Moreover, G is a d-regular graph with girth at least ω(l), so the total number of different paths of length l containing [u, v] is(cid:88) a+b=l−δ (d − 1)a(d − 1)b = (l − δ + 1) · (d − 1)l−δ. On the other hand the total number of different paths of length l is n · d · (d − 1)l−1/2. So the probability that in some round t, 1 (cid:54) t (cid:54) n, we get [u, v] ⊆ Wt is at most 2(l − δ + 1)(d − 1)l−δ n · d · (d − 1)l−1 2(l − δ + 1)(d − 1) n · d · (d − 1)δ = (cid:54) 2l n(d − 1)δ . Let uδ = (cid:100)6 logd−1 n/δ(cid:101) and {t1, t2, . . . , tuδ} ⊂ [n] be a sequence of distinct rounds of size uδ. ([u, v]), which takes one if [u, v] ⊆ Wti , for We define indicator random variable Xt1,t2,...,tuδ every 1 (cid:54) i (cid:54) uδ, and zero otherwise. Thus we get (cid:104) Pr Xt1,t2...,tuδ ([u, v]) = 1 (cid:105) (cid:54)(cid:16) 2l/n(d − 1)δ(cid:17)uδ −uδ (d − 1)(logd−1(2l)−δ)uδ −uδ (d − 1) −uδ n −uδ·δ/2 = n = n (cid:54) n −3, 15 where the last inequality follows from l ∈ [ω(1), o(log n)] and hence, logd−1(2l) (cid:54) δ/2. There are at most nuδ sequences of rounds of size uδ and at most n(d − 1)δ−1 paths of length δ. Thus, by using the previous upper bound and the union bound over all sequences of rounds and paths of length δ we have (cid:88) (cid:88) (cid:104) (cid:104) Pr Xt1,t2...,tuδ ([u, v]) = 1 δ-path t1,t2,...,tuδ (cid:54) nd(d − 1)δ−1nuδ Pr (cid:54) o(n2)nuδ Pr (cid:104) Xt1,t2...,tuδ ([u, v]) = 1 Xt1,t2...,tuδ ([u, v]) = 1 = o(1/n), (cid:105) (cid:105) (cid:105) where the last inequality follows from δ (cid:54) l = o(logd n). This implies that with probability 1 − o(1/n) there is no path of length δ contained in at least uδ l-walks or equivalently Nδ holds. E Balanced Allocation on Sparse Graphs In this section we present allocation algorithm A(cid:48)(G, l) for d-regular graphs, with d ∈ [3,O(log n)]. The algorithm proceeds as follows: In each round, every ball picks a node uniformly at random and it takes a NBRW of length l· rG from the chosen node, where rG = (cid:100)2 logd−1 log n(cid:101). After that the ball collects the load information every rG-th visited node, called the potential choice, and place itself on a least-loaded potential choice (ties are broken randomly). We now present the following theorem for the maximum load attained by A(cid:48)(G, l). Theorem E.1. Suppose that G is a d-regular graph with girth at least 10l(log log n)2 and d ∈ [3,O(log n)]. Then, with high probability the maximum load attained by A(cid:48)(G, l), denoted by m∗, is bounded from above as follows: I. If ω(1) (cid:54) l (cid:54) 4γ(cid:48) G, where γ(cid:48) G =(cid:112)logd n/rG, then we have (cid:18) logd n · log log n (cid:19) (cid:18) log log n (cid:19) = O ∗ m rGl2 ∗ m = O . . log(l/γG) II. If l (cid:62) 4γ(cid:48) G, then we have The analysis of allocation algorithm A(cid:48)(G, l) is almost the same as the algorithm for dense graphs so we only outline parts of the proof and notations that are slightly different. Let us start by defining an interference graph and show some of its properties (similar to Section 2) Definition 5. (Interference graph ) For any given pair (G, l), interference graph I(cid:48)(G, l) is a graph whose nodes are the set of potential choices in each l · rG-walk on G and two sets are connected if and only if they intersect each other. Lemma E.2. We have that V (I(cid:48) ∆(I(cid:48) ) = nd(d − 1)l·rG−1/2, ) (cid:54) (l + 1)2d(d − 1)l·rG−1. Proof. Since G has girth at least l · rG, each l · rG-walk determines a unique set of potential choices and hence V (I(cid:48)) is the number of all lrG-walks, that is, V (I(cid:48) ) = nd(d − 1)l·rG−1/2. It is easy to show that, for every 0 (cid:54) i (cid:54) l, each node can be the (irG)-th visited node of d(d − 1)lrG−1 lrG-walks. So every node is contained in at most (l + 1)d(d − 1)lrG−1 many walks. On the other hand, each set contains l + 1 nodes and hence, ∆(I(cid:48) ) (cid:54) (l + 1)2d(d − 1)l·rG−1. 16 Similar to Section 2, we can define the (λ, µ)-trees contained in I(cid:48) and get the similar results in terms of V (I(cid:48)) and ∆(I(cid:48)). The shown results for dense graph including appearance probability of a c-loaded (λ, µ)- tree (Section 2) and witness graphs (Section 3) are based on the local properties of a regualr graph with degree at ω(log n) and girth 10lh. We also know that allocation algorithm A(cid:48)(G, l) samples nodes from a neighborhood of radius l · rG. It only collects the load information every rG-th visited node and ignore rest of the visited nodes. Now if we sort potential choices according to their distance from the starting node, say (u0, u1 ··· , ul). It is easy to see that each ui, 1 (cid:54) i (cid:54) l, is chosen from a set of nodes of size at least (d − 1)rG = ω(log n), as the graph locally looks like a tree. Roughly speaking, A(cid:48)(G, l) reduces sparse d-regular graph G to a regular graph with degree ω(log n) and hence the results also hold for A(cid:48). F A Lower Bound In this section we derive a lower bound for the maximum load attained by allocation algorithms on dense and sparse graphs. Define (cid:26) 1 rG := (cid:100)2 logd−1 log n(cid:101) if d = ω(log n) , otherwise. Consider the generic balanced allocation A(G, l) that proceeds af follows: each ball takes a NBRW of length l · rG, and then it places itself on a least-loaded node among every rG-th visited node. When rG = 1, it means every visited node is considered as a potential choice. It is easy to see that the algorithm covers both classes of graph. Now we show the following lower bound for the maximum load. least ω(l), where l ∈ [32rG,O(γG)] is an integer and γG =(cid:112)logd n/rG. Then with probability Theorem F.1 (Lower Bound). Suppose that G be a d-regular n-vertex graph with girth at 1 − n−Ω(1) the maximum load attained by A(G, l) is at least (cid:19) (cid:18) logd n rG · l2 . Ω Proof. We know in each round the algorithm picks a random path of length l · rG. Let us define indicator random variable XP for every path of length l · rG as follows, (cid:26) 1 0 XP := if P is chosen at least τ times by A, otherwise, where τ will be specified later. The total number of paths of length l · rG, say s, is nd(d − 1)l·rG−1/2 (cid:54) ndl·rG /2. Let P be an arbitrary path of length l · rG in G. Thus we get (cid:32) n(cid:88) (cid:18) 2 i=τ n i (cid:33)(cid:18) 1 (cid:19)i(cid:18) (cid:19)τ(cid:18) s dlrG · τ 1 − 1 s (cid:19)n−i (cid:62)(cid:16) n (cid:19)s (cid:62) d s · τ 1 − 1 s −(lrG+logd τ )τ /e, (cid:19)n (cid:17)τ(cid:18) 1 − 1 s Pr [XP = 1] = (cid:62) (4) where the second inequality follows from n (cid:54) s (cid:54) n · dlrG /2. By setting τ = logd n 6l · rG , and using the fact that logd τ < logd logd n (cid:54) rG (cid:54) l we get (lrG + logd τ )τ (cid:54) logd n/6 + logd n/6 = logd n/3. By substituting the above upper bound in (4), we get Let us define the random variable Y =(cid:80) Pr [XP = 1] = Ω(n −1/3). all paths XP . By linearity of expectation we have E [Y ] = s · Pr [XP = 1] = (n · d · (d − 1)lrG−1/2)Ω(n −1/3) = Ω(n2/3). (5) 17 It is easily seen that the random variables XP and XP (cid:48) are negatively correlated, which means for every P and P (cid:48), E [XP · XP (cid:48) ] (cid:54) E [XP ] · E [XP (cid:48) ] . (E [XP XP (cid:48) ] − E [XP ] E [XP (cid:48) ]) (cid:125) (cid:123)(cid:122) (cid:54)0 This implies that Var [Y ] = (cid:88) (E(cid:2)X 2 (cid:54)(cid:88) E(cid:2)X 2 P P P (cid:3) − (E [XP ])2) + (cid:3) = E [Y ] . (cid:88) (cid:124) P(cid:54)=P (cid:48) P Applying Chebychev's inequality and above inequality yield that Pr [Y = 0] (cid:54) Pr [Y − E [Y ] (cid:62) E [Y ]] = Var [Y ] (E [Y ])2 (cid:54) 1 E [Y ] . By equality (5) we have that E [Y ] = Ω(n2/3). Therefore with probability at least 1 − O(n−2/3) we have Y (cid:62) 1, which means there exists a path P that is chosen at least τ times. Since every P contains l + 1 choices, by the pigeonhole principle there is a node with load at least (cid:16) τ (cid:17) l (cid:18) logd n (cid:19) rGl2 Ω = Ω . 18
1308.5256
1
1308
2013-08-23T22:19:33
Multireference Alignment using Semidefinite Programming
[ "cs.DS", "math.ST", "math.ST" ]
The multireference alignment problem consists of estimating a signal from multiple noisy shifted observations. Inspired by existing Unique-Games approximation algorithms, we provide a semidefinite program (SDP) based relaxation which approximates the maximum likelihood estimator (MLE) for the multireference alignment problem. Although we show that the MLE problem is Unique-Games hard to approximate within any constant, we observe that our poly-time approximation algorithm for the MLE appears to perform quite well in typical instances, outperforming existing methods. In an attempt to explain this behavior we provide stability guarantees for our SDP under a random noise model on the observations. This case is more challenging to analyze than traditional semi-random instances of Unique-Games: the noise model is on vertices of a graph and translates into dependent noise on the edges. Interestingly, we show that if certain positivity constraints in the SDP are dropped, its solution becomes equivalent to performing phase correlation, a popular method used for pairwise alignment in imaging applications. Finally, we show how symmetry reduction techniques from matrix representation theory can simplify the analysis and computation of the SDP, greatly decreasing its computational cost.
cs.DS
cs
Multireference Alignment using Semidefinite Programming Afonso S. Bandeira∗ Moses Charikar† Amit Singer‡ Andy Zhu§ May 11, 2014 Abstract The multireference alignment problem consists of estimating a signal from multiple noisy shifted observations. Inspired by existing Unique-Games approximation algorithms, we provide a semidefi- nite program (SDP) based relaxation which approximates the maximum likelihood estimator (MLE) for the multireference alignment problem. Although we show that the MLE problem is Unique- Games hard to approximate within any constant, we observe that our poly-time approximation algorithm for the MLE appears to perform quite well in typical instances, outperforming existing methods. In an attempt to explain this behavior we provide stability guarantees for our SDP under a random noise model on the observations. This case is more challenging to analyze than traditional semi-random instances of Unique-Games: the noise model is on vertices of a graph and translates into dependent noise on the edges. Interestingly, we show that if certain positivity constraints in the SDP are dropped, its solution becomes equivalent to performing phase correlation, a popular method used for pairwise alignment in imaging applications. Finally, we show how symmetry re- duction techniques from matrix representation theory can simplify the analysis and computation of the SDP, greatly decreasing its computational cost. Keywords: Multireference Alignment, Semidefinite Relaxation, Phase Correlation, Unique-Games 3 1 0 2 g u A 3 2 ] S D . s c [ 1 v 6 5 2 5 . 8 0 3 1 : v i X r a ([email protected]). Princeton, NJ USA ∗Program in Applied and Computational Mathematics (PACM), Princeton University, Princeton, NJ 08544, USA †Department of Computer Science, Princeton University, Princeton, NJ 08544, USA ([email protected]). ‡Department 08544, §Department of Mathematics, Princeton University, Princeton, NJ 08544, USA ([email protected]). Princeton University, of Mathematics and PACM, ([email protected]). 1 1 Introduction The multireference alignment problem is the following: suppose there is a template vector x ∈ RL, from which are sampled N cyclically-shifted copies with white additive Gaussian noise yi = Rlix + ξi ∈ RL, ξi = (ξik)L k=1 ∼ N (0, σ2IL) i.i.d. (1) for i = 1, 2, . . . , N . Rl is the index cyclic shift operator (x1, . . . , xL) (cid:55)→ (x1−(cid:96), . . . , xL−(cid:96)) and σ is a parameter controlling the signal-to-noise (SNR) ratio. Both the template x and the shifts l1, . . . , ln are unknown. Furthermore, no model is presumed a-priori for their distribution. From this model we would like to deduce an accurate estimate for x (up to a global cyclic shift). Such an estimate can be obtained by first estimating the shifts, and then averaging the unshifted observations. For this reason we will focus on the problem of estimating the shifts l1, . . . , ln. This problem has a vast list of applications. Alignment is directly used in structural biology [Dia92] [TS12]; radar [ZvdHGG03] [PZAF05]; crystalline simulations [SSK13]; and image registration in a number of important contexts, such as in geology, medicine, and paleontology [DM98] [FZB02]. Various methods to solve this problem are used in these communities (see Appendix A). A naıve approach to estimate the shifts in (1) would be to fix one of the observations, say yi, as a reference template and align every other yj with it by the shift ρij minimizing their distance ρij = argmin l∈ZL (cid:107)yj − Rlyi(cid:107)2. (2) This solution works well at a high signal-to-noise ratio (SNR), but performs poorly at low SNR. A more democratic approach would be to calculate all of the pairwise relative shift estimates ρij before attempting to recover the shifts {li}. This can be done by solving the minimization problem (cid:12)(cid:12)(cid:12)e2πıli/L − e2πıρij /Le2πılj /L(cid:12)(cid:12)(cid:12)2 N(cid:88) i,j=1 min l1,...,lN∈ZL . (3) This problem is known as angular synchronization [Sin11, BSS12] and the solution can be approximated via a SDP-based relaxation. The issue with attempting to solve the alignment problem using either (2) or (3) is that one is evaluating the performance of a given choice of li, lj for a pair (i, j) by how far li − lj is from ρij, but not taking into account the cost associated with other possible relative shifts. Relating R−liyi and R−liyj, for example, would take into account information about all possible shifts instead of just the best one. The quasi maximum likelihood estimator (Section 2) attempts to do exactly that by solving the minimization problem: (cid:13)(cid:13)R−liyi − R−lj yj (cid:13)(cid:13)2 . N(cid:88) i,j=1 min l1,...,lN∈ZL (4) Finding the MLE (4) is a non-trivial computational task because the parameter space is of expo- nential size, and the likelihood function is non-convex. While one can apply optimization methods such as gradient descent, simulated annealing, and expectation-maximization (EM), these are only guaranteed to find local minima of (4), but not the global minimum. In this paper we take a different approach and propose a semidefinite relaxation for the quasi maximum likelihood problem (4). This particular SDP is inspired by an approximation algorithm designed to solve the Unique Games problem [CMM06] (Section 3). 2 Convex relaxations of hard combinatorial problems have seen many successes in applied mathe- matics. They became particularly popular in the last decade with the introduction of Compressed Sensing, in the seminal work of Donoho, Candes, Tao, and others [CRT06, Don06]. This idea has since been applied to a vast list of problems. Semidefinite programming (SDP) has served as a con- vex surrogate for problems arising in applications such as low-rank matrix completion [CR09], phase retrieval [CSV11], Robust PCA [LMTZ12], multiple-input multiple-output (MIMO) channel detec- tion [MCS10], and many others. In many of these applications the same phenomenon is present: for typical instances, solving the convex problem is often equivalent to solving the original combinatorial problem [ALMT13]. Convex relaxations (and, in particular SDP based relaxations) also play a central role in the design of approximation algorithms in theoretical computer science. Almost two decades ago, Goemans and Williamson [GW95] proposed a SDP based approximation algorithm for the MAX-CUT problem with approximation ratio αGW ≈ 0.878. That is, for any instance of the problem, the computed solution is guaranteed to provide performance (in this case, a cut) at least αGW of the optimum. Many semidefinite relaxations have since been proposed as approximation algorithms for a long list of NP- hard problems [WS11]. In order to better understand the theoretical limitations of approximation algorithms, substantial work has been done to establish limits on the approximation ratios achievable by poly-time algo- rithms for certain NP-hard problems (hardness of approximation). The Unique Games conjecture by Khot [Kho02] is central to many recent developments: For δ, ε > 0, it is impossible for a polynomial- time algorithm to distinguish between δ-satisfiable and (1 − ε)-satisfiable Unique-Games instances. A Unique-Games instance consists of a graph along with a permutations for each edge. The problem is to choose the best assignment of labels to each vertex such that as many of the edge permutations are sat- isfied. The validity of the UGC would imply the optimality of certain poly-time approximation ratios, in particular the Goemans-Williamson constant αGW for the MAX-CUT problem [GW95, KKMO07]. The best known polynomial time approximation to the unique games problem [CMM06] is based on an SDP relaxation of a formulation that uses indicator variables. It is quite different from SDPs normally used in applications (such as those described above). In particular, the variable matrix has size N L × N L and Ω(cid:0)N 2L2(cid:1) constraints. We adapt this SDP to approximate the quasi maximum likelihood problem (4). As we show that it is Unique-Games hard to approximate (4) within any constant (see Section 2) it is hopeless to aim for good guarantees for general instances. However worst case analysis is often too pessimistic and not indicative of performance observed in practice. In fact, under the random noise model we have for the observations, numerical simulations suggest that the SDP relaxation performs remarkably well, seeming to outperform existing methods. In an attempt to explain this phenomenon we show that our SDP is stable at high SNR levels and that it is tight at extremely high SNR levels. By stability, we mean that with high probability the solution to the SDP does not deviate much from the true solution (see Theorem 4.2). The stability for this SDP is particularly interesting as it is more challenging to analyze than random instances of Unique-Games [AKK+08, KT07], since our noise model is on the vertices, which translates into dependent noise on the edges. Still, these results fall short of properly explaining the remarkable performance that we see in simulations and more research is needed towards understanding the typical behavior of this SDP. In order to simplify the SDP we also study a version with fewer constraints. Interestingly, this weaker SDP can be solved explicitly and is equivalent to the pairwise alignment method called phase correlation [HG84]. This method does not take into account information between all pairs of mea- surements, which suggests that the full complexity of the Unique-Games SDP [CMM06] is needed to 3 obtain a good approximation to (4). The fact that a global shift does not affect the solution to (4) creates symmetries in our SDP relaxation. In fact, we leverage such structure by using symmetry reduction techniques from matrix representation theory to simplify the analysis and computation of the SDP, greatly decreasing its com- putational cost. This is quite useful given the high computational cost of semidefinite programming. Contributions: Our main contribution is applying techniques from theoretical Computer Science to a problem in applied Math. We introduce an Unique Games style SDP relaxation for the alignment problem that is novel for the applied Math community. From the theoretical Computer Science point of view, we introduce a new problem that has a similar flavor to the Unique Games problem – in fact we show that the worst case version is at least as hard as Unique Games. We introduce a natural average case version of this alignment problem - aligning several shifted copies of a signal corrupted by independent Gaussian noise. Existing analyses of semi-random models of Unique Games do not seem to apply to this problem. We show that for sufficiently high SNR, the SDP solution is close to an integer solution – this is a first step to establishing a signal recovery result which we leave as an open problem. We believe that future investigations into this problem will yield interesting insights into the Unique Games SDP and on dealing with correlated noise in average case analysis. 2 Quasi Maximum Likelihood Estimator The log likelihood function for the model (1) is (cid:88) L(x, l1, . . . , lN y1, . . . , yN ) = N 2 log(2π) − 1 2σ (cid:107)R−liyi − x(cid:107)2. (5) li’s, the minimal value of L occurs at the average x = 1 i=1 R−liyi. Making the tame assumption that (cid:107)x(cid:107)2 is estimable (the norm is shift-invariant), maximizing (5) is thus equivalent to maximizing Maximizing L is equivalent to minimizing the sum of squared residuals(cid:80)(cid:107)R−liyi − x(cid:107)2. Fixing the (cid:11) across all pairs (i, j). Thus we consider the estimator the sum of the inner products(cid:10)R−liyi, R−lj yj (cid:88) (cid:98)(cid:96) = argmax (cid:104)R−liyi, R−lj yj(cid:105) (cid:80)N i∈[N ] (6) N (cid:96)∈ZN L i,j∈[N ] Unfortunately, the search space for this optimization problem has exponential size. Indeed, assuming no model for the vectors {yi}, it is NP-hard to find the shifts which maximize (6), or even estimate it within a close constant factor. Theorem 2.1 It is NP-hard (under randomized reductions) to find a set of labels approximating (6) within 16/17 + ε of its optimum value. It is UG-hard (under randomized reductions) to approximate (6) within any constant factor. Proof. (outline) We give a randomized reduction from the class of Γ-MAX-2LIN(q) instances consisting of a set of 2 variable linear equations of the form xi − xj ≡ cij (mod q), with the goal of choosing an assignment for the variables which maximizes the number of satisfied equations. We construct a vector yk for every variable xk such that shifts of yk correspond to an assignment to xk. We pick a random vector zij corresponding to a constraint on variables xi, xj and place a copy of zij at specific locations in yi and yj. Shifts of yi, yj corresponding to satisfying assignments of the constraint results in a superposition of the copies of zij. We choose parameters so that the only non-trivial contributions 4 to the objective function (6) come from such superposition. The value of the objective is (within small error) a scaled version of the number of constraints of the Γ-MAX-2LIN(q) instance satisfied by the assignment corresponding to the shifts. Thus hardness results for Γ-MAX-2LIN(q) directly translate to hardness results for the alignment problem. The details are given in Appendix C. The discrete optimization problem (6) may be formulated using indicator variables as an integer programming problem N(cid:88) (cid:88) i,j=1 k,l∈ZL argmax {uik} uikujl(cid:104)R−kyi, R−lyj(cid:105), (7) where uik ∈ {0, 1} is the indicator variable uik = δ{li ≡ k}. View Uik;jl = uikujl as an entry of the Gram matrix U ∈ RN L×N L, and Cik;jl = (cid:104)R−kyi, R−lyj(cid:105) as an entry of the data Gram matrix C ∈ RN L×N L. (7) can be written as the maximization problem tr(CU ) subject to rank(U ) = 1, and any other constraints needed to enforce that U is a Gram matrix of indicator variables. This suggests the possibility of a spectral rounding algorithm, where we try to determine the indicator variables by examining the top eigenvectors of C. Lemma 2.2 The data Gram matrix C with entries Cik;jl = (cid:104)R−kyi, R−lyj(cid:105) satisfies: 1. C (cid:23) 0 and has rank L, with non-zero eigenvalues λk = L(cid:80)N i=1 F(Yi, k)2 . 2. There is a unitary matrix P for which PCP∗ = diag(C0, . . . ,CL−1) is block diagonal, where each Ck ∈ CN×N is a rank 1 matrix. Proof. Refer to Lemma B.1. (cid:80) For random signals x, Lemma 2.2 indicates that the spectral gap between the top L eigenvalues i F(Yi, k)2 = Ω(LN ). Hence and the remaining eigenvalues of C will be large, on the order of mink we may want to try and recover a solution to 7 by examining the eigenvectors associated with the top eigenvalues in the spectrum of C. In particular, in the noiseless case with σ = 0, the indicator vector 1{ik : k ≡ li} ∈ RN L lies in the span of the top L eigenvectors of C. Unfortunately, this spectral gap will not be apparent for a large class of signals. As long as a single power spectra F(x, k)2 of x is near zero, the corresponding eigenvalue λk will separate less from the small eigenvalues of C, and hence the space of the top L eigenvectors of C will contain less relevant information. For this reason, it would only be meaningful for us to characterize the SNR by the spectral gap mink F(x, k)2. Furthermore, our simulations suggest that recovery from a spectral relaxation performs worse than the semidefinite relaxation we are about to propose. 3 Semidefinite relaxation The quadratic form constraints (cid:88) k,l∈ZL uikujl = 1, i, j ∈ [N ] uikuil = 0, uikujl ≥ 0, i ∈ [N ], k (cid:54)= l ∈ ZL i, j ∈ [N ], k, l ∈ ZL. 5 on uik ∈ R enforce that the uik’s are indicator variables (up to global sign, which cannot be fixed by quadratic constraints). The global shift ambiguity of the problem guarantees the existence of L different solutions. In fact, we will attempt to find a candidate solution in the span of lifted versions of these. This can be more succintly written as an optimization problem for a rank L matrix V : max V tr(CV ) (cid:88) subject to C, V ∈ RN L×N L, Cik;jl = (cid:104)R−kyi, R−lyj(cid:105) Vik;jl = 1, Vik;il = 0, V ≥ 0 for k (cid:54)= l, V (cid:23) 0. (8) k,l Of the imposed constraints on V , the only non-convex constraint is that of rank deficiency, which ob- structs the use of convex programming techniques. Removing this rank constraint yields a semidefinite program. This SDP is extremely similar to (and motivated by) SDPs commonly used to approximate solutions to certain constraint satisfaction problems (CSPs), notably Unique-Games instances. An Unique-Games instance consists of a graph G = ([N ], E), a label set ZL, and a set of permutations πij : ZL → ZL. The problem is to choose the best assignment of labels to each vertex such that as many of the permutations (πij)(i,j)∈E are satisfied. Γ-MAX-2LIN(L) is special case where the permutations πij are cyclic. In our notation, the SDP studied for Unique-Games is usually of the form max V tr(CV ) 1 2 (cid:88) subject to C, V ∈ RN L×N L, Cik;jl = δ{l = πij(k)}, Vik;ik = 1, Vik;il = 0 for k (cid:54)= l, V ≥ 0, V (cid:23) 0. (9) k This formulation attempts to count the number of satisfied edge constraints for an Unique-Games instance. One can treat the SDP (8) as an instance of Γ-MAX-2LIN(L) on a weighted complete graph, with each cyclic permutation weighted by Cik;jl = (cid:104)R−liyi, R−lj yj(cid:105). In this context, the matrix C is dubbed the label-extended adjacency matrix [Kol10]. Thus the significant body of literature conducted on Unique-Games may be useful in understanding (8). Another common feature of the aligment SDP with Γ-MAX-2LIN(L) instances is that the assigned labels may be chosen upto cyclic symmetry. This induces a block circulant symmetry in the semidefinite program (see Lemma D.5). For example, this symmetry will allow us to presume that Vik;ik = 1/L from the constraint(cid:80) k Vik;ik = 1. A major feature of (8) which does not feature in the study of Unique-Games is the structure of the data coefficient matrix C. While Unique-Games specifies constraints on edges of a graph (there are N 2 pieces of information), the alignment problem only specifies information on its vertices (N pieces of information). This does assist our understanding of the semidefinite program, since it enables us to apply more symmetry conditions, but it also significantly complicates our analysis. An interpretation of the constraint V ≥ 0 is that it enforces triangle inequality constraints (cid:107)vik − 0(cid:107) +(cid:107)0− vjl(cid:107) ≥ (cid:107)vik − vjl(cid:107) [CMM06]. As we see in the next section, as well as from empirical results, the constraint V ≥ 0 causes the SDP solution matrix to stabilize more around integral instances. Interestingly, without this positivity constraint, the SDP may be solved in closed form, and is effectively equivalent to pairwise phase correlation. Theorem 3.1 Let V be a solution of (9) without the positivity constraints. Then, V has rank L, corresponding to one eigenspace of eigenvalue N/L. This eigenspace contains the vector vphase ∈ RN L 6 satisfying (cid:110) vphase il (cid:111) l = F∗(cid:26) F(y1, l)F∗(yi, l) F(y1, l)F∗(yi, l) (cid:27) l which is the concatenation of phase correlation vectors (see Appendix A) between y1 and yi. Proof. By symmetry, assume without loss of generality that V is block circulant (see Lemma D.5). Let P be the unitary matrix defined in Lemma 2.2 and e(cid:0) kl l=0 e(cid:0) kl e(x) = e2πix. Then, PV P∗ = diag(V0, . . . ,VL−1) where Vk = (cid:80)L−1 (cid:88) semidefinite. The SDP constraints V ∈ RN L×N L, Vik;il = 0 for k (cid:54)= l, (cid:1) denote the classical Fourier basis function (cid:1) Vl ∈ CN×N is positive V (cid:23) 0, Vik;jl = 1 L L are respectively equivalent to the Fourier side constraints k,l Vk = VL−k, Vk (cid:23) 0, (Vk)ii = 1/L, (V0)ij = 1/L. (10) Since Vk (cid:23) 0, the absolute value of each entry is bounded by the maximum of its diagonal entries, so each entry has magnitude at most 1/L. Hence tr(CV ) = tr(CkVk) ≤ 1 L (Ck)ij, (11) (cid:88) k∈ZL (cid:88) (cid:88) k∈ZL ij∈[N ] with equality occuring when Vk has the entries of Ck, normalized to magnitude 1/L. Then (Vk)ij = F (yi,l)F∗(yj ,l) F (yi,l)F∗(yj ,l) , and a basis of the non-trivial eigenspace of V is given by Note the selection of the observation 1 is arbitrary. The vector vphase ∈ RN L given by W := P∗ ((Vk)i,1)i,k =(cid:0)e(−kl L )(Vk)i,1 (cid:1) (cid:34) F∗(cid:26) F(y1, l)F∗(yi, l) F(y1, l)F∗(yi, l) ik;l vphase ik := (W 1N×1)ik = (cid:27)L−1 (cid:35) l=0 k lies in the image of W and it is easy to see that the L vectors W phase ∈ RN L×L generated by circulating the N blocks of L entries of vphase are linearly independent. Indeed, the top L × L block of W phase is the identity matrix IL. From the SDP solution, one must round back to a solution in the original search space. There is a significant body of literature on the topic of rounding the solutions to various SDPs for Unique Games. The analysis and guarantees for these rounding schemes are in terms of the number of constraints satisfied by the solution produced and do not immediately give a result about signal recovery in our setting. In their study of semi-random instances of Unique-Games, the authors of [KMM11] give a rounding technique that uses both SDP and LP solutions when the SDP is known to be somewhat sparse – this is similar to a condition we obtain in the following stability section. Exploiting these ideas to establish an exact signal recovery guarantee is an interesting open problem. 7 4 Stability For simplicity, without loss of generality align the ground truth shifts of the observations, so that yi = x + ξi, where ξi ∼ N (0, σ2IL) i.i.d. The ground truth integral instance for the SDP will be (upto block cyclic symmetry) the indicator matrix V int ∈ RN L×N L, defined as V int ik;jl = δk=l/L. If there is a set of labels (cid:96) = (li)i which are pairwise optimal, in the sense that (cid:104)R−liyi, R−lj yj(cid:105) = maxk(cid:104)yi, R−kyj(cid:105) for all pairs (i, j), the SDP (8) will produce the integral instance. While this may be likely in a very high signal-to-noise setting, it is a rather stringent condition. We relax this condition and show that the SDP solution must still resemble the integral instance at a reasonably high SNR. The exact definition for the SNR will be deferred for later, but will be characterized in terms of the gap ∆ = (cid:107)x(cid:107)2 − max l(cid:54)=0 (cid:104)x, Rlx(cid:105). (12) For any V ∈ RN L×N L lie in the SDP feasibility region, we can characterize the distance of V from the integral instance by the differences (cid:88) Vik;jl = 1 − (cid:88) k∈ZL Dij = k(cid:54)=l∈ZL Vik;jk ∈ [0, 1]. Dij is a measure of how much the SDP would weight shift preferences other than the ground truth. When all Dij = 0 we obtain the integral instance. For convenience, we make the definitions ξ0 = 2x and ηij = 2 maxl (cid:104)Rlξi, ξj(cid:105) ≥ 0 for i, j = 0, 1, . . . , N . The following lemma demonstrates that the ηij’s can be treated as worst-case bounds on the noise terms of the entries of the data Gram matrix C. Lemma 4.1 If tr(CV ) ≥ tr(CV int), then(cid:80) without loss of generality presume V is block circulant. Hence(cid:80) i(cid:54)=j(∆ − ηij − ηj0)Dij ≤ 0. Proof. We can find a block circulant matrix which attains the same SDP objective value as V , so k Vik;j0 = 1/L and Dij = 1− LVi0;j0. Expanding, 0 ≥ tr(CV int) − tr(CV ) = (cid:104)R−kyi, yj(cid:105) (δk=0 − LVik;j0) (cid:88) (cid:88) i,j k (cid:19) (cid:104)yi, yj(cid:105)(1 − LVi0;j0) − max l(cid:54)=0 (cid:104)yi, yj(cid:105) − max l(cid:54)=0 (cid:104)Rlyi, yj(cid:105) Dij. (cid:18) (cid:18) ≥(cid:88) (cid:88) i,j = i,j (cid:104)Rlyi, yj(cid:105)(cid:88) k(cid:54)=0 (cid:19) LVik;j0 The second inequality requires the SDP constraint V ≥ 0. The pessimistic bound (cid:104)yi, yj(cid:105) − max l(cid:54)=0 (cid:104)Rlyi, yj(cid:105) ≥ (cid:107)x(cid:107)2 + (cid:104)x, ξi(cid:105) + (cid:104)x, ξj(cid:105) + (cid:104)ξi, ξj(cid:105) − max l(cid:54)=0 (cid:104)Rlx, ξj(cid:105) − max l(cid:54)=0 (cid:104)Rlx, ξi(cid:105) − max l(cid:54)=0 ≥ ∆ − (ηi0/2 + ηj0/2 + ηij), − max l(cid:54)=0 (cid:104)x, Rlx(cid:105) (cid:104)Rlξi, ξj(cid:105) and rearrangement gives the desired inequality. 8 Theorem 4.2 With probability 1 − e−N +o(N ), the solution to the SDP satisfies (cid:88) i,j √ Dij ≤ ((cid:107)x(cid:107) + σ2 L) · 12 log eL ∆ · N 2. Proof. For sufficiently high SNR, we would expect that the inequality in Lemma 4.1 would fail to hold. Indeed, by Lemma E.2, the inequality (ηij + ηj0)Dij ≤ O(log L) · 2(cid:107)x(cid:107) + 1 N (cid:107)ξi(cid:107) N 2, (13) (cid:18) (cid:19) (cid:88) i (cid:88) i(cid:54)=j holds with probability at least 1 − e−N +O(log N ). It arises from tail bounds on the sum of slightly dependent random variables, and is independent of the structure of the SDP (as opposed to Lemma 4.1). Combined with Lemma 4.1, we can obtain a guarantee on the deviation between the SDP solution and the integral instance. The full proof may be found following Theorem E.3. Theorem 4.2 indicates that at a sufficiently high SNR, the UG-based SDP will produce a matrix V , of which each L× L block will have high small values outside of the main diagonal. A rounding scheme would likely interpret this as the identity shift being the optimal shift. This motivates us to choose a definition for the SNR to be along the lines of SN R = ∆/[((cid:107)x(cid:107) + σ2 L) log L] (for reference, for random signals x, we would expect that ∆ = L−O( L)). This characterization of SNR is significantly more lenient than that for spectral relaxation, in Section 2. For example, a sum of a few sinusoids will have several small power spectra, but if the least common multiple of their periods does not divide L, then ∆ will still be large. Note furthermore that we may be more flexible in our definition for ∆: for example, suppose there is a set of shifts (cid:96)∗ (including the identity element) of size (cid:96)∗ = O(1) for which maxl∈(cid:96)∗(cid:104)x, Rlx(cid:105) > ∆ + minl /∈(cid:96)∗(cid:104)x, Rlx(cid:105). The above results may be modified to describe the concentration of the SDP solution on the entries of the shifts in (cid:96)∗ (not just along the identity shift) for each pair of observations yi, yj. This result may be strengthened in other manners. For constants 0 < δ, ε (cid:28) 1, we can attain a √ √ tighter concentration condition of the form (cid:88) (cid:113)(cid:88) instead of the current condition (cid:80) Dij ≥ N 2/SN R. The argument is based on the analysis of the ij/SN R + 2εN 2 Dij ≥ (1 + δ)2N (14) D2 SDP for adversarial semi-random Unique-Games instances by [KMM11]. However, the proof must be more nuanced in our case, due to correlations in the noise model of C, caused by the smaller source of randomness available to us. Hence we omit the full details, but provide a sketch below. Any SDP feasible matrix V can alternatively be represented as Vik;jl = (cid:104)vik, vjl(cid:105)/L for a set of unit vectors vik ∈ RN L. With this notation, 2Dij = 2(1 − LVi0;j0) = (cid:107)vi0 − vj0(cid:107)2. The space of these unit vectors can be approximately discretized by a random projection due to the Johnson-Lindenstrauss such that the set of unit vectors {vi0}N N -tuple in N. Specifically, if Dϕ this ball being defined as {D : α−1 lemma. Precisely, Lemma E.4 provides a set of unit vectors N of size N = exp(cid:0)O(cid:0)δ−2 log2(1/ε)(cid:1)(cid:1) i=1 can be approximated under a random projection ϕ by an ij = (cid:107)ϕ(vi0) − ϕ(vj0)(cid:107)2/2, then the Dij’s lie within an αJL-ball of Dϕ ij, JL(Dϕ) ≤ D ≤ αJL(Dϕ)} for αJL(D) = (1 + δ)D + ε. Instead of finding a global tail bound in Lemma E.2, we can derive a local tail bound for each αJL- ij’s, each tail bound holding with probability at least 1 − 2N e−t2N . For 0 < δ, ε = ε(cid:48) (cid:28) 1 ball of Dϕ constants, the number of N -tuples of vectors in N is of size exp(O(N )). With a sufficiently large 9 constant t, the local tail bound may be union bounded across all balls of vectors in NN , and thus will hold for all SDP-feasible V . With some care, this argument would yield a concentration condition of the form (14). 5 Numerical Results Figure 1: Averages of errors of several alignment methods across 500 iterations, with parameters σ = 1, L = 5. We implemented several baseline methods discussed thus far, and plotted their average error performance across 500 iterations in Figure 1. For each iteration, we chose a signal x randomly from the distribution N (0, IL), as well as N i.i.d noise vectors ξi ∼ N (0, σ2IL), and apply each of our methods. These simulations confirm our intuition that the UG-based SDP performs better than other benchmark methods. In particular, they suggest that the UG-based SDP is highly stable around integral instances. The implementation using bispectrum-like invariants is discussed in Appendix A. For each of the other procedures, we construct a N L × L matrix W recording alignment preferences. For cross- or phase correlation, let Wik;l be the (k − l)th entry of the cross- or phase correlation vector between y1 and yi. For the spectral rounding off the Gram matrix C, and the solution of the semidefinite program V , let W be the top L eigenvectors of the respective matrix. The shifts are read off this matrix, and the un-shifted yi are averaged to produce an estimate for x. The first plot (a) shows the difference between this estimate and x. An important problem not very elaborated in this paper is how to determine the best shifts from W . A natural method is to identify an indicator vector 1{ik : li ≡ k} lying close to the column span of W , for some labelling (cid:96) = (li)i. Currently, our procedure is to apply a linear transformation to W such that the top L × L block of W is the identity matrix IL (although there is no reason to believe this rounding is robust, it is sufficient for the purpose of having an easy benchmark between multiple methods). Then, for each i, the maximal entry in the first column of W gives the choice of shift for yi. The second plot shows the distance this indicator vector lies from the column span of W . Let W ⊥ ∈ RN L−L×N L be the matrix whose rows form the orthogonal complement of the rows of W T , and u ∈ RN L denote our indicator vector. Then u should be a sparse vector near the nullspace of W ⊥. If we knew one of the non-zero coordinates of u, say coordinate i, we could recover the rest of u 10 −iu−i = −W ⊥ −i is the submatrix obtained from W ⊥ by removing as a sparse solution to W ⊥ the column W ⊥ i . The problem can then be solved by (cid:96)1-minimization, as suggested by the theory of sparse recovery. Although normally, we would be required to run this procedure for every coordinate (to make sure we pick an active one) the symmetries in W imply the existence of L such indicator variables and that any coordinate we pick will be active in one of them. i , where W ⊥ 6 Generalizations and Future Work It is worth noting that the discrete multireference alignment problem naturally generalizes from shifts over ZL to actions of finite groups G over finite spaces S. In this case, the analogue of phase correlation [Lon10] is defined in terms of the generalized Fourier transform FG,S(·, ρ) : CS → Cdρ×dρ, where ρ : G → Cdρ×dρ are irreducible matrix representations. The Unique Games SDP may also be generalized in a natural manner, in rough analogy with SDP variants studied for Γ-MAX-2LIN instances. In the case of an abelian group G = S, the proof of Theorem 3.1 follows in the same fashion, and hence the alignment UG-based SDP without positivity constraints will remain equivalent to phase correlation. The symmetry of the SDP in this case can be described naturally by the theory of C∗-matrix algebras (refer to Appendix D). Symmetries in semidefinite programs can be written with respect to linear combinations of {0, 1} matrices, which form a basis of a ∗-matrix algebra. Under sufficiently nice conditions, this basis can be block diagonalized, for example by Wedderburn’s decomposition or by regular ∗-representations [Mur07]. Hence, the ∗-matrix algebra can be represented by a lower- dimensional block diagonalized version. From a computational perspective, this can make highly symmetric SDPs much more amenable to sparse SDP solvers [DdK11]. In our case, diagonalization by the block DFT allows the SDP to be rewritten as an optimization problem across L PSD matrices of size N × N instead of one PSD matrix of size N L × N L. It would be interesting to see how the performance of the SDP changes when we study the alignment problem across more difficult groups, especially non-abelian ones, which arise in several applications. The numerical simulations in Section 5 suggest that the UG-based SDP achieves exact recovery with high probability for sufficiently high SNR. That is, the resulting SDP matrix is integral, so by solving the SDP we are indeed obtaining the solution to the quasi-ML estimator. Indeed, as the SNR decreases, there appears to be a phase transition during which the SDP almost always recovers an integral solution. Our analysis of the stability of the semidefinite program does not fully explain this phenomenon. The authors believe this to be an interesting direction for future work, especially since guarantees of exact recovery are attainable in high SNR settings for a few semidefinite relaxations, for example for the MIMO problem [MCS10]. Another important question is to understand the sample complexity of our approach to the align- ment problem. Since the objective is to recover the underlying signal x, having a larger number of observations N should give us better recovery. The question can be formalized as: for a given value of L and σ, how large does N need to be in order to have reasonably accurate recovery? The sample complexity of methods like the bispectral invariants would be expected to require N = Ω(σ2L2 log L) observations. We would hypothesize on the strength of our numerical results that the UG-based SDP requires fewer observations for meaningful recovery, and establishing this is an interesting open problem. Along with expanding the domain of the alignment problem, it would be interesting to attempt the style of analysis discussed in this paper for other maximum likelihood problems. Maximum likeli- hood estimators play an important role in many estimation problems, but often (as in our problem) 11 computing or approximating the MLE is a challenging problem and semidefinite programming could provide a tractable alternative in an average case setting. Acknowledgements The authors thank Yutong Chen for valuable assistance with the implementation of our algorithm. A. S. Bandeira was supported by AFOSR Grant No. FA9550-12-1-0317. M. Charikar was supported by NSF grants CCF 0832797, AF 0916218 and AF 1218687. A. Singer was partially supported by Award Number FA9550-12-1-0317 and FA9550-13-1-0076 from AFOSR, by Award Number R01GM090200 from the NIGMS, and by Award Number LTR DTD 06-05-2012 from the Simons Foundation. Parts of this work have appeared in A. Zhu’s undergraduate thesis at Princeton University. References [AKK+08] S. Arora, S. A. Khot, A. Kolla, D. Steurer, M. Tulsiani, and N. K. Vishnoi. Unique games on expanding constraint graphs are easy: extended abstract. In Proceedings of the 40th annual ACM symposium on Theory of computing, STOC ’08, pages 21–28, New York, NY, USA, 2008. ACM. [ALMT13] D. Amelunxen, M. Lotz, M. B. McCoy, and J. A. Tropp. Living on the edge: A geometric theory of phase transitions in convex optimization. Available online at arXiv:1303.6672 [cs.IT], 2013. [BSS12] A. S. Bandeira, A. Singer, and D. Spielman. A Cheeger inequality for the graph con- nection laplacian. available online, 2012. [CMM06] M. Charikar, K. Makarychev, and Y. Makarychev. Near-optimal algorithms for unique games. Proceedings of the 38th ACM Symposium on Theory of Computing, 2006. [CR09] [CRT06] [CSV11] E. Cands and B. Recht. Exact matrix completion via convex optimization. Foundations of Computational Mathematics, 9(6):717–772, 2009. E. J. Cand`es, J. Romberg, and T. Tao. Stable signal recovery from incomplete and inaccurate measurements. Comm. Pure Appl. Math., 59:1207–1223, 2006. E. J. Candes, T. Strohmer, and V. Voroninski. Phaselift: exact and stable signal recovery from magnitude measurements via convex programming. Communications on Pure and Applied Mathematics, 2011. [DdK11] C. Dobre and E. de Klerk. Semidefinite programming approaches for structured combi- natorial optimization problems, 2011. [Dia92] [DM98] R. Diamond. On the multiple simultaneous superposition of molecular structures by rigid body transformations. Protein Science, 1(10):12791287, October 1992. I. Dryden and K. Mardia. Statistical shape analysis. Wiley series in probability and statistics. Wiley, Chichester [u.a.], 1998. [Don06] D. L. Donoho. Compressed sensing. IEEE Trans. Inform. Theory, 52:1289–1306, 2006. 12 [FZB02] [GW95] [HG84] [KDM95] [Kho02] [KI93] H. Foroosh, J. B. Zerubia, and M. Berthod. Extension of phase correlation to subpixel registration. IEEE Transactions on Image Processing, 11(3):188–200, 2002. M. X. Goemans and D. P. Williamson. Improved apprximation algorithms for maximum cut and satisfiability problems using semidefine programming. Journal of the Association for Computing Machinery, 42:1115–1145, 1995. J. L. Horner and P. D. Gianino. Phase-only matched filtering. Appl. Opt., 23(6):812–816, Mar 1984. P. Kosir, R. DeWall, and R. Mitchell. A multiple measurement approach for feature alignment. In Aerospace and Electronics Conference, 1995. NAECON 1995., Proceedings of the IEEE 1995 National, volume 1, pages 94–101 vol.1, 1995. S. Khot. On the power of unique 2-prover 1-round games. Proceedings of the 34th Annual ACM Symposium on Theory of Computing, pages 767–775, 2002. R. Kakarala and G. J. Iverson. Uniqueness of results for multiple correlations of periodic functions. J. Opt. Soc. Am. A, 10(7):1517–1528, Jul 1993. [KKMO07] S. Khot, G. Kindler, E. Mossel, and R. O’Donnell. Optimal inapproximability results for max-cut and other 2-variable csps? SIAM J. Comput., 37(1):319–357, 2007. [KMM11] A. Kolla, K. Makarychev, and Y. Makarychev. How to play unique games against a semi-random adversary: Study of semi-random models of unique games. Foundations of Computer Science, IEEE Annual Symposium on, pages 443–452, 2011. [Kol10] [KT07] [LM00] A. Kolla. Spectral algorithms for unique games. 25th Annual IEEE Conference on Computational Complexity, pages 122–130, 2010. A. Kolla and M. Tulsiani. Playing random and expanding unique games. Unpublished, 2007. B. Laurent and P. Massart. Adaptive estimation of a quadratic functional by model selection. Ann. Statist., 2000. [LMTZ12] G. Lerman, M. B. McCoy, J. A. Tropp, and T. Zhang. Robust computation of linear models, or how to find a needle in a haystack. CoRR, abs/1202.4044, 2012. [Lon10] [LXC04] [Mau03] [MCS10] A. Loneland. Non-commutative harmonic analysis: Generalization of phase correlation to the euclidean motion group. Master’s thesis, University of Bergen, June 2010. W. Ligong, L. Xueliang, and H. C. Eigenvalues of a special kind of symmetric block circulant matrices. Applied Math J. Chinese University Series B, 19(1):17–26, 2004. A. 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. A. Man-Cho So. Probabilistic analysis of the semidefinite relaxation detector in digital communications. In Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’10, pages 698–711, Philadelphia, PA, USA, 2010. Society for Industrial and Applied Mathematics. 13 [Mur07] [PZAF05] [SG92] [Sin11] [SSK13] [TS12] [WS11] K. Murota. A numerical algorithm for block-diagonal decomposition of matrix *-algebras with application to semidefinite programming. Japan Journal of Industrial and Applied Mathematics, 27(1), 2007. R. G. Pita, M. R. Zurera, P. J. Amores, and F. L. Ferreras. Using multilayer perceptrons to align high range resolution radar signals. In W. Duch, J. Kacprzyk, E. Oja, and S. Zadrozny, editors, Artificial Neural Networks: Formal Models and Their Applications - ICANN 2005, volume 3697 of Lecture Notes in Computer Science, pages 911–916. Springer Berlin Heidelberg, 2005. B. M. Sadler and G. B. Giannakis. Shift- and rotation-invariant object reconstruction using the bispectrum. J. Opt. Soc. Am. A, 9(1):57–69, Jan 1992. A. Singer. Angular synchronization by eigenvectors and semidefinite programming. Ap- plied and Computational Harmonic Analysis, 30(1):20 – 36, 2011. B. Sonday, A. Singer, and I. G. Kevrekidis. Noisy dynamic simulations in the presence of symmetry: Data alignment and model reduction. Computers & Mathematics with Applications, 65(10):1535 – 1557, 2013. D. L. Theobald and P. A. Steindel. Optimal simultaneous superpositioning of multiple structures with missing data. Bioinformatics, 28(15):1972–1979, 2012. D. P. Williamson and D. B. Shmoys. The Design of Approximation Algorithms. Cam- bridge University Press, New York, NY, USA, 1st edition, 2011. [ZvdHGG03] J. Zwart, R. van der Heiden, S. Gelsema, and F. Groen. Fast translation invariant classification of hrr range profiles in a zero phase representation. Radar, Sonar and Navigation, IEE Proceedings -, 150(6):411–418, 2003. A Phase correlation and the Bispectrum Many scientific fields have isolated discussions and solutions for the alignment problem, occasionally with slight context-specific adjustments. Such methods include iterative template aligning [KDM95], zero phase representations [ZvdHGG03], angular synchronization [SSK13], and machine learning [PZAF05]. Unfortunately, most of these are either do not fairly weight each observation, do not make full use of the available information, or do not have rigorous performance discussion. We outline just a couple of very well-studied alignment methods in this section. In the case of a pair of noisily shifted vectors (N = 2), several long-studied methods assign scores to each possible shift between the vectors, and estimate the shift as the one with the highest score. The most natural is to take the inner product between each possible shift of the vectors yi, yj, which gives the cross-correlation vector vcross . Another frequently used in practice is the phase correlation vector = (cid:104)yi, R−lyj(cid:105), with maximal entry(cid:98)l = argmax vcross l l vphase = F∗(cid:26) F(yi, k)F∗(yj, k) F(yi, k)F∗(yj, k) (cid:27)L−1 . k=0 (15) For human-friendly images, phase correlation tends to be more appealing, since it tends to have a single sharp peak. The relation between cross- and phase correlation can be seen from the convolution theorem: 14 Lemma A.1 Convolution theorem: {(cid:104)yi, R−lyj)(cid:105)}L−1 Proof. Let Ml denote the modulation operator (Mlx)k = xke(kl/L), defined such that FRlx = MlFx. By Parseval’s Theorem, l=0 = √ (cid:26) (cid:88) L · F {F(yi, k)F∗(yj, k)}L−1 k=0 . (cid:27) (cid:1)F(yi, k)F∗(yj, k) e(cid:0)−kl L {(cid:104)yi, R−lyj(cid:105)}l = {(cid:104)Fyi, M−lFyj(cid:105)}l = √ k∈ZL L · F {F(yi, k)F∗(yj, k)}k . = l (16) L−1(cid:88) Cross- and phase correlation can be used directly for the problem of multireference alignment, say by aligning all of the observations against the first one. However, this is certainly not a robust method. Another relevant notion for characterizing alignments are the moment spectra. These are properties of a signal which are invariant under shifts. The kth power spectrum of a real signal x ∈ RL is defined by F(x, k)2 = F(x, k)F∗(x, k). This can be extended to the d-th order bispectrum (or moment spectra) b(k1, k2, . . . , kd) = F(x, k1 + k2 + ··· + kd)F∗(x, k1)F∗(x, k2)···F∗(x, kd); (17) its shift invariance can be seen since it is the Fourier transform of the d-th order autocorrelation function a(k1, k2, . . . , kd) = xlxl−k1xl−k2 ··· xl−kd, (18) l=0 by the Wiener-Khinchin theorem. How much information do these invariants capture about the signal x? Sadler and Giannakis give iterative and least squares algorithms in [SG92] for reconstructing the Fourier phases from full knowledge of the bispectrum, and Kakarala in [KI93] show the uniqueness of real function given all of its higher order moment spectra. These arguments generally tend to be of a more number-theoretic flavor and may be tedious in practice. A simple special case occurs when we take k1 = k2 = . . . = kd = 1 for d = 1, . . . , L. This gives us the set of bispectral invariants F(x, d)F∗(x, 1)d. This quantity, as a shift invariant, can be consistently estimated from our observations yi. With an estimate for the phase of the first Fourier coefficient F(x, 1) (for example we can sample over a discretization of the unit circle), we can recover the remaining Fourier phases F(x, d) and thus the signal x. B Maximum Likelihood Lemma B.1 The data Gram matrix C with entries Cik;jl = (cid:104)R−kyi, R−lyj(cid:105) satisfies the following properties: 1. C (cid:23) 0 and has rank L, with non-zero eigenvalues λk = L(cid:80)N i=1 F(yi, k)2 . 2. There is a unitary matrix P for which PCP∗ = diag(C0, . . . ,CL−1) is block diagonal, where each Ck ∈ CN×N . 15 Proof. C has Cholesky decomposition C = (Ry)(Ry)T ∈ RLN×LN where Ry = , ... ...  − R−kyi −   where (Ck)ij = (cid:104)yi, R−kyj(cid:105), i,k so C (cid:23) 0 has rank L. Since (cid:104)R−kyi, R−lyj(cid:105) = (cid:104)R−k+myi, R−l+myj(cid:105), C is composed of N × N circulant blocks of size L× L. After permuting the rows and columns of C, one may write C as a block circulant matrix  C0 C1 CL−1 C0 ... C2 ... C1 ··· CL−1 ··· CL−2 . . . ··· ... C0 P T CP = and P is the appropriate permutation matrix. P T CP is block diagonalized by the block Discrete Fourier Transform matrix DF TL⊗IN [LXC04], where ⊗ denotes the Kronecker product. P = (DF TL⊗ IN )P T ∈ CN L×N L is thus a unitary transformation such that PCP∗ = diag(C0, . . . ,CL−1); Ck ∈ CN×N (19) is block diagonal. These block diagonals are componentwise Discrete Fourier Transforms of the “vec- tor” (C0, C1, . . . , CL−1): L−1(cid:88) l=0 Ck = e(cid:0) kl L (cid:1) Cl = L · [F∗(C0, C1, . . . , CL−1)]k =(cid:8)L(Yi)k(Y ∗ √ (cid:9) j )k ij by Lemma A.1. Note also that each Ck is Hermitian and rank 1 (C is of rank L, and each of the blocks Ck has positive rank). The unique nonzero eigenvalue λk of Ck is given by λk = tr(Ck) = L (Yi)k2 . (20) N(cid:88) i=1 C NP-hardness of Quasi MLE Theorem C.1 Consider the problem ALIGN(y1, . . . , yN ): for vectors y1, . . . , yN ∈ RL, find the shifts (cid:96) = (l1, . . . , lN ) which maximize A(l1, . . . , lN ) = (cid:104)R−liyi, R−liyj(cid:105). (cid:88) i,j∈[N ] Let A∗ = max(cid:96) A((cid:96)). It is NP-hard (under randomized reductions) to esimate A∗ within 16 17 + ε of its true value. It is UG-hard (under randomized reductions) to estimate A∗ within any constant factor. 16 1 We demonstrate this by a poly-time approximation preserving reduction from a special class of MAX-2LIN(q) instances called Γ-MAX-2LIN(q). Consider a (connected) MAX-2LIN(q) instance where each constraint has the form xi − xj ≡ cij (mod q), of which at most ρ∗ are satisfiable. Representing each variable as a vertex of a graph and each constraint as an edge, the instance is associated with a connected graph G = (V (G), E(G)), where V (G) = [N ] and E(G) = M . Let poly(M ) be the space of integer functions which are bounded by polynomial order, i.e. f ∈ poly(M ) iff there are constants C, k such that f (M ) ≤ CM k for all M ≥ 1. We say that an event occurs w.h.p if it occurs with probability 1− (q, G), where (q,G) /∈ poly(q ·E(G)). Notice under this definition that if poly(qM ) events occur w.h.p, then by an union bound the event that all occur will also be w.h.p. Construct a parameter s = s(q, M ) ∈ poly(qM ). We take the vectors y1, . . . , yN to be of length L = qM s. The indices of the vector yi can be expressed in mixed radix notation by elements of the tuple (Zq, E(G), [s]). For example, we would associate the tuple index (x, ek, t) of yi by the index x· qM + ek · M + t, where ek is the kth edge in some enumeration of E(G). Note that a shift by c· qM takes this tuple index to (x, ek, t) + c · qM → (x + c, ek, t). For each edge constraint xi − xj ≡ cij, let zij be a vector uniformly at random chosen from {±1}s. Assign the entries (0,{i, j},·) of yi to zij, and the entries (cij,{i, j},·) of yj to zij. Assign all of the remaining entries of the yi’s to i.i.d Rademacher random variables ({±1} with probability 1/2). Intuitively, a relative shift of cij · qM between yi and yj will produce a large inner product due to the overlapping of the zij’s, while any other shift between them would produce low inner products. Lemma C.2 Suppose γ ∈ poly(qM ). Consider two random vectors y1, y2 of length γ whose entries are i.i.d sampled from the Rademacher distribution. W.h.p, for any 0 <  (cid:28) 1, the inner product of every possible shift R(cid:96)y1 of y1 with y2 is bounded in absolute value by γ · m. √ Proof. By independence, each inner product is the sum of γ independent Bernoulli random variables which take values ±1 with probability 1/2. Hoeffding’s inequality indicates γ · (qM )) ≤ 2 exp{−(qM )/2} , Pr((cid:104)R(cid:96)y1, y2(cid:105) ≥ √ Pr((cid:104)R(cid:96)y1,y2(cid:105)≥√ so w.h.p all of the inner products are simultaneously bounded by γ(qM )) /∈ poly(qM ). Union bounding over all γ = poly(qM ) such inner products, γ · (qM ). √ 1 We say an edge {i, j} ∈ E(G) is cij-satisfied under a labelling (cid:96) if li − lj ≡ cijqM (mod L). From Lemma C.2, we observe that w.h.p, for any choices of shifts li, lj, (cid:104)R−liyi, R−lj yj(cid:105) − s · δ({i, j} ∈ E(G) is cij-satisfied) < (qM ) √ L. It follows that if the labelling (cid:96) induces exactly k cij-satisfied edges, w.h.p (cid:12)(cid:12)A((cid:96)) − 2ks(cid:12)(cid:12) < k(qM ) L +(cid:0)N 2 − k(cid:1) (qM ) √ √ L ≤ qM 2+ √ L. (21) q satisfying at least(cid:0)A((cid:96))− qM 2+ Theorem C.3 From a given labelling (cid:96), w.h.p one may in polynomial time construct (x1, . . . , xN ) ∈ ZN is a labelling (cid:96)max w.h.p satisfying A ((cid:96)max) > 2s · ρ∗M − qM 2+ L(cid:1)/(2s) edge-constraints xi− xj ≡ cij. Conversely, w.h.p there √ √ L. 17 Proof. Consider the subgraph H of G with vertex set V (G) and edge set comprising all edges cij- satisfied under (cid:96). For each connected component of H, arbitrarily choose a vertex i of the component to have xi = 0. Follow a spanning tree of each connected component and assign each neighbor j by xj ≡ xi − cij (mod q). The first implication of the lemma follows immediately by applying (21). i = xi · qM . This labelling induces at least ρ∗M Conversely, construct the labelling (cid:96)max by setting lmax cij-satisfied edges, and (21) completes the lemma. Corollary C.4 Take s > q2M 4. If (cid:96)max satisfies A((cid:96)max) ≥ (α + δ)A∗, then w.h.p, from (cid:96)max one may construct (x1, . . . , xN ) ∈ ZN in poly-time satisfying (α + δ(cid:48))ρ∗ fraction of Zq-MAX-2LIN con- straints, for some δ(cid:48) > 0. q Proof. Let ρ be the fraction of variable assignments satisfied by the construction of Theorem C.3 for the labelling (cid:96)max. W.h.p, A((cid:96)max) − qM 2+ε 2sM ρ > L > (α + δ)A∗ − q1/2+M 5/2+s1/2 2sM > (α + δ)ρ∗ − q1/2+M 3/2+ s1/2 . √ Assuming the Unique Games conjecture, it is NP-hard to approximate Γ-MAX-2LIN(q) to any constant factor [KKMO07]. Hence it is UG-hard (under randomized reductions) to approximate ALIGN within any constant factor. MAX-CUT is a special case of Γ-MAX-2LIN(q). Since it is NP-hard to approximate MAX-CUT within 16 17 + ε, it is NP-hard (under randomized reductions) to approximate ALIGN within 16 D ∗-matrix algebras 17 + ε. In this appendix section, we briefly sketch the ideas behind symmetry reduction in semidefinite pro- grams. Most of the details are deferred to other sources. For example, [DdK11] is a good reference on this topic. While the application of symmetry to the SDPs we are interested in is relatively straight- forward and can be explained without reference to ∗-matrix algebras, the notation and ideas behind the theory of ∗-matrix algebras make it especially clear to express. Definition D.1 A complex (or real) matrix ∗-algebra A is a set of n× n matrices in Cn×n (or Rn×n) such that for any X, Y ∈ A, αX + βY, X∗, XY ∈ A for all α, β ∈ C (or R). A coherent configuration is a set of matrices {A1, . . . , Ad} ⊂ {0, 1}n×n satisfying: • Some subset of the Ai’s sum to In. • (cid:80)d i=1 Ai = 1n×n. i ∈ A. • AT • AiAj is a linear combination of A1, . . . , Ad. The span of the Ai’s is a ∗-matrix algebra A. If the Ai’s commute and contain the identity matrix In, then this configuration is called an association scheme, and A is also known as a Bose-Mesner algebra. Treating A as a matrix vector space, a coherent configuration forms a basis for A. 18 For example, Cn×n is a matrix ∗-algebra. Another commonly considered matrix ∗-algebra is the space of G-invariant matrices. Let S be a finite set, and let G be a finite group acting on S. The space of G-invariant matrices are the matrices A ∈ CS×S for which P T g APg = A, where Pg is the permutation matrix associated with g ∈ G. The space of G-invariant matrices forms a matrix ∗-algebra generated by the coherent configuration {Pg}g∈G. In particular, the basis is closed under multiplication, since Pg1Pg2 = Pg2◦g1. Definition D.2 A ∗-homomorphism φ is a linear mapping of ∗-matrix algebras φ : A → B which additionally satisfies φ(A∗) = φ(A)∗, φ(AB) = φ(A)φ(B), and φ(IA) = IB if the identity matrix IA ∈ A. Lemma D.3 If φ is an injective ∗-homomorphism φ : A → B, then A ∈ A and φ(A) share the same set of eigenvalues (ignoring multiplicity), and A (cid:23) 0 ⇐⇒ φ(A) (cid:23) 0. To leverage symmetry in semidefinite programs, it will be useful to take the images of the objec- tive semidefinite matrix under dimension-reducing ∗-homomorphisms. Two such ∗-homomorphisms which may be systematically constructed are given by Artin-Wedderburn’s Theorem and regular ∗- representations [Mur07]. Consider a primal semidefinite problem of the form minimize subject to V (cid:23) 0 tr(C0V ) and tr(CiV ) = bi, (22) where V is the semidefinite matrix to optimize over, and Ci ∈ Rn×n are data matrix constraints and b = (b1, . . . , bm) are given, for i ∈ {1, 2, . . . , m}. Suppose the data matrices Ci are contained in a low-dimensional complex matrix ∗-algebra ASDP . Theorem D.4 Suppose the data matrices {Ci}m ∗-algebra with a real orthogonal basis containing all of the Ci’s. Then i=0 ⊂ Rn×n are real symmetric. Let ASDP be a complex 1. there is an optimal solution V to the primal SDP problem contained in ASDP 2. Re(V ) ∈ ASDP is also an optimal solution to the primal SDP problem. Proof. Refer to ([DdK11], Corollary 2.5.2). A special case of this is the result applies for the ∗-algebra of G-invariant matrices. Lemma D.5 In the semidefinite program (22), suppose the constraint matrices C0, C1, . . . , Cm are G-invariant. Then there is a solution V to the SDP which is also G-invariant. Proof. If V (cid:48) is a solution of (22), then the matrix V ∈ Cn×n given by V = RG(V ) = 1 G g V (cid:48)Pg P T (cid:88) g∈G is G-invariant, feasible, and has the same objective value as V (cid:48). The averaging map RG is known as the Reynolds operator. 19 and E Stability Lemma E.1 E[ηijξi] ≤ µη(cid:107)ξi(cid:107) and E[η2 1). Proof. Take ζ ∼ N (0, IL), and choose a unit vector z ∈ RL. Define η(z) = maxl ηl(z), where the distribution of ηl(z) = (cid:104)Rlz, ζ(cid:105) is independent of the choice of z. Union bounding, ijξi] ≤ ση(cid:107)ξi(cid:107)2, where µη = 2σ(log L+1) and σ2 η = 4σ2(log2 L+ Pr (η(z) ≥ t) ≤ (cid:88) l∈ZL (cid:1) ≤(cid:88) Pr(cid:0)(cid:104)el, ζ(cid:105) ≥ t (cid:1) = 2 l where el ∈ RL is a standard unit basis vector. Thus, for T > 1, (cid:26) (cid:1) ≤ min (cid:27) . 1, 2L t · e−t2/2√ 2π µη = E η(z) = Pr (η(z) ≥ t) dt ≤ T + 2L√ 2π te−t2/2 dt ≤ T + Le−T 2 l (cid:88) Pr(cid:0)ζl ≥ t (cid:90) ∞ (cid:90) ∞ T 2 Pr(cid:0)ηl(z) ≥ t (cid:90) ∞ (cid:90) ∞ 0 η = E η(z)2 = σ2 The lemma follows by taking T = log L, since ηij = 2σ(cid:107)ξi(cid:107) · η(cid:0)ξi/(cid:107)ξi(cid:107)(cid:1) conditional on ξi. 2t Pr (η(z) ≥ t) dt ≤ T 2 + te−t2/2 dt ≤ T 2 + Le−T . L√ 2π T 0 Lemma E.2 Let t > 0. With probability at least 1 − 2N e−t2N , 2(cid:107)x(cid:107) + 1 N (ηij + ηj0)Dij ≤ (µη + σηt) (cid:88) (cid:88) (cid:18) (cid:19) (cid:107)ξi(cid:107) N 2. i(cid:54)=j holds for all Dij ∈ [0, 1]. Proof. Define the random variables Zij = (ηij + ηj0)Dij ≤ ηij + ηj0. For fixed i, the ηij’s are independent positive random variables. The one-sided tail bound for independent positive random variables by Maurer [Mau03] gives i (23) E (ηij + ηj0) ≥ ti E (η2 ij + η2 j0) ≤ 2e−t2 i . (cid:19) Pr √ Choose ti = t (cid:18)(cid:88) (cid:88) j (ηij + ηj0) −(cid:88) Zij ≤(cid:88) j i,j i ≤ (µη + σηt) (cid:18) j (cid:115)(cid:88) (cid:113) (cid:88) (cid:19) (cid:88) t (cid:107)ξi(cid:107) i i 2(cid:107)x(cid:107) + 1 N N 2. N . By union bound, with probability at least 1 − 2N e−t2N , µη(2(cid:107)x(cid:107) + (cid:107)ξi(cid:107))N + N 2σ2 η(4(cid:107)x(cid:107)2 + (cid:107)ξi(cid:107)2) Theorem E.3 With probability 1 − e−N +o(N ), the solution to the SDP satisfies (cid:88) √ Dij ≤ ((cid:107)x(cid:107) + σ2 L) · 12 log eL ∆ · N 2. i,j 20 Proof. Let V be a solution matrix to the SDP, so that tr(CV ) ≥ tr(CV int). It follows from Lemma 4.1 that The χ2-tail bound of Laurent-Massart [LM00] states √ (cid:18) 1 σ2 Pr When t = N L this gives (cid:88) Dij ≤(cid:88) ij ij ∆ (ηij + ηj0)Dij. (cid:19) (cid:115) N (cid:88) i (cid:107)ξi(cid:107) ≤ (cid:107)ξi(cid:107)2 ≤ σN √ 5L. (cid:107)ξi(cid:107)2 ≤ N L + 2 N Lt + 2t ≥ 1 − exp{−t}. (24) (cid:88) (cid:88) i i (cid:18) with probability at least 1 − e−N L. Union bounding with the tail bound of Lemma E.2, and applying Lemma E.1, ∆ Dij ≤ (µη + ση) 2(cid:107)x(cid:107) + N 2 ≤ 12 log eL((cid:107)x(cid:107) + σ √ L)N 2 (cid:107)ξi(cid:107) (cid:88) (cid:19) (cid:88) i 1 N ij with probability at least 1 − e−N +o(N ). Lemma E.4 Let 0 < δ, ε, ε(cid:48) (cid:28) 1 be small constants, and define αJL(x) = (1 + δ)x + ε. There is a set of unit vectors N of size at most such that for any set of unit vectors {vi}, there is a map ϕ : {vi} → N satisfying the inequality exp(cid:0)O(cid:0)δ−2 log(1/ε) log(1/ε(cid:48))(cid:1)(cid:1) (cid:18) (cid:19) ≤ (cid:107)ϕ(vi) − ϕ(vj)(cid:107)2 ≤ αJL (cid:18) α−1 JL (cid:107)vi − vj(cid:107)2 (cid:19) (cid:107)vi − vj(cid:107)2 for at least 1 − ε(cid:48) fraction of the pairs (i, j) ∈ [N ] × [N ]. Proof. This lemma appears frequently in SDP literature, and in particular is used to analyze adversar- ial semi-random Unique-Games instances in [KMM11]. Notice that the size of the set N is independent of the number of vectors in the set {vi}. Construct a ε/32-net N of the unit hypersphere in a O(δ2 log(1/ε(cid:48)))-dimensional space L. By the (strong version of the) Johnson-Lindenstrauss lemma, there is a randomized mapping ϕ(cid:48) : {vi} → L satisfying (1 − δ/2)(cid:107)vi − vj(cid:107)2 ≤ (cid:107)ϕ(cid:48)(vi) − ϕ(cid:48)(vj)(cid:107)2 ≤ (1 + δ/2)(cid:107)vi − vj(cid:107)2 with probability at least 1 − ε(cid:48). Define ϕ(vi) to be the closest point to ϕ(cid:48)(vi) in N, and observe that (1 − δ/2)x − ε ≥ x − ε 1 + δ = α−1 JL(x), (1 + δ/2)x + ε ≤ αJL(x) for all x > 0, so ϕ satisfies the conditions of the lemma. 21
1709.01152
2
1709
2018-06-21T10:56:43
Pairing heaps: the forward variant
[ "cs.DS" ]
The pairing heap is a classical heap data structure introduced in 1986 by Fredman, Sedgewick, Sleator, and Tarjan. It is remarkable both for its simplicity and for its excellent performance in practice. The "magic" of pairing heaps lies in the restructuring that happens after the deletion of the smallest item. The resulting collection of trees is consolidated in two rounds: a left-to-right pairing round, followed by a right-to-left accumulation round. Fredman et al. showed, via an elegant correspondence to splay trees, that in a pairing heap of size $n$ all operations take $O(\log{n})$ amortized time. They also proposed an arguably more natural variant, where both pairing and accumulation are performed in a combined left-to-right round (called the forward variant of pairing heaps). The analogy to splaying breaks down in this case, and the analysis of the forward variant was left open. In this paper we show that inserting an item and deleting the minimum in a forward-variant pairing heap both take amortized time $O(\log{n} \cdot 4^{\sqrt{\log{n}}} )$. This is the first improvement over the $O(\sqrt{n})$ bound showed by Fredman et al. three decades ago. Our analysis relies on a new potential function that tracks parent-child rank-differences in the heap.
cs.DS
cs
Pairing heaps: the forward variant Dani Dorfman Blavatnik School of Computer Science, Tel Aviv University, Israel [email protected] Haim Kaplan1 Blavatnik School of Computer Science, Tel Aviv University, Israel [email protected] László Kozma2 Eindhoven University of Technology, The Netherlands [email protected] Uri Zwick3 Blavatnik School of Computer Science, Tel Aviv University, Israel [email protected] Abstract The pairing heap is a classical heap data structure introduced in 1986 by Fredman, Sedgewick, Sleator, and Tarjan. It is remarkable both for its simplicity and for its excellent performance in practice. The "magic" of pairing heaps lies in the restructuring that happens after the deletion of the smallest item. The resulting collection of trees is consolidated in two rounds: a left-to-right pairing round, followed by a right-to-left accumulation round. Fredman et al. showed, via an elegant correspondence to splay trees, that in a pairing heap of size n all heap operations take O(log n) amortized time. They also proposed an arguably more natural variant, where both pairing and accumulation are performed in a combined left-to-right round (called the forward variant of pairing heaps). The analogy to splaying breaks down in this case, and the analysis of the forward variant was left open. In this paper we show that inserting an item and deleting the minimum in a forward-variant log n). This is the first improvement over the √ n) bound showed by Fredman et al. three decades ago. Our analysis relies on a new potential pairing heap both take amortized time O(log n · 4 O( function that tracks parent-child rank-differences in the heap. √ 2012 ACM Subject Classification F.2.2 Nonnumerical Algorithms, E.1 Data Structures Keywords and phrases data structure, priority queue, pairing heap Introduction 1 A heap is an abstract data structure that stores a set of keys, supporting the usual operations of creating an empty heap, inserting a key, finding and deleting the smallest key, decreasing a key, and merging ("melding") two heaps. Heaps are ubiquitous in computer science, used, for instance, in Dijkstra's shortest path algorithm and in the Jarník-Prim minimum spanning tree algorithm (see e.g., [5]). Heaps are typically implemented as trees (binary or multiary), where each node stores a key, and no key may be smaller than its parent-key. 8 1 0 2 n u J 1 2 ] S D . s c [ 2 v 2 5 1 1 0 . 9 0 7 1 : v i X r a 1 Research supported by The Israeli Centers of Research Excellence (I-CORE) program (Center No. 4/11), Israel Science Foundation grant no. 1841-14. 2 Work done while at Tel Aviv University. Research supported by The Israeli Centers of Research Excellence (I-CORE) program (Center No. 4/11). 3 Research supported by BSF grant no. 2012338 and by The Israeli Centers of Research Excellence (I-CORE) program (Center No. 4/11). XX:2 Pairing heaps: the forward variant The pairing heap, introduced by Fredman, Sedgewick, Sleator, and Tarjan [9], is a popular heap implementation that supports all operations in O(log n) amortized time. It is intended to be a simpler, self-adjusting alternative to the Fibonacci heap [10], and has been observed to have excellent performance in practice [27, 23, 20, 22]. Despite significant research, the exact complexity of pairing heap operations is still not fully understood [9, 8, 14, 24, 6, 17, 18]. Self-adjusting data structures. Many of the fundamental heap- and tree- data structures in the literature are designed with a certain "good structure" in mind, which guarantees their efficiency. Binary search trees, for instance, need to be (more or less) balanced in order to support operations in O(log n) time. In the case of heaps, a reasonable goal is to keep node-degrees low, as it is costly to delete a node with many children. Maintaining a tree structure in such a favorable state at all times requires considerable book-keeping. Indeed, data structures of this flavor (AVL-trees [1], red-black trees [2, 11], Binomial heaps [29], Fibonacci heaps [10], etc.) store structural parameters in the nodes of the tree, and enforce strict rules on how the tree may evolve. By contrast, pairing heaps and other self-adjusting data structures store no additional information besides the keys and the pointers that represent the tree itself. Instead, they perform local re-adjustments after each operation, seemingly ignoring global structure. Due to their simplicity and low memory footprint, self-adjusting data structures are appealing in practice. Moreover, self-adjustment allows data structures to adapt to various usage patterns. This has led, in the case of search trees, to a rich theory of instance-specific bounds (see e.g., [26, 15]). The price to pay for the simplicity and power of self-adjusting data structures is the complexity of their analysis. With no rigid structure, self-adjusting data structures are typically analysed via potential functions that measure, informally speaking, how far the data structure is from an ideal state. The standard analysis of pairing heaps [9] borrows the potential function developed for splay trees by Sleator and Tarjan [26]. This technique is not directly applicable to other variants of pairing heaps. There is a large design space of self-adjusting heaps similar to pairing heaps, yet, we currently lack the tools to analyse their behavior (apart from isolated cases). We find it a worthy task to develop tools to remedy this situation. Description of pairing heaps. A pairing heap is built as a single tree with nodes of arbitrary degree. Each node is identified with a key, with the usual min-heap condition: every (non-root) key is larger than its parent key. The heap operations are implemented using the unit-cost linking primitive: given two nodes x and y (with their respective subtrees), link(x, y) compares x and y and lets the greater of the two become the leftmost child of the smaller. The delete-min operation works as follows. We first delete (and return) the root r of the heap (i.e., the minimum), whose children are x1, . . . , xk. We then perform a left-to-right pairing round, calling link(x2i−1, x2i) for all i = 1, . . . ,bk/2c. The resulting roots are denoted y1, . . . , ydk/2e. (Observe that if k is odd, the last root is not linked.) Finally, we perform a right-to-left accumulate round, calling link(pi, yi−1) for all i = dk/2e, . . . , 2, where pi is the minimum among yi, . . . , ydk/2e. We illustrate this process in Figure 1. The other operations are straightforward. In decrease-key, we cut out the node whose key is decreased (together with its subtree) and link it with the root. In insert, we link the new node with the root. In meld, we link the two roots. Fredman et al. [9] showed that the amortized time of all operations is O(log n). They also conjectured that, similarly to Fibonacci heaps, the amortized time of decrease-key is D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:3 in fact constant. This conjecture was disproved by Fredman [8], who showed that in certain sequences, decrease-key requires Ω(log log n) time. In fact, the result of Fredman holds for a more general family of heap algorithms. Iacono and Özkan [17, 16] gave a similar lower bound for a different generalization4 of pairing heaps. Assuming O(log n) time for decrease-key, Iacono [14] showed that insert takes constant amortized time. Pettie [24] proved that both log log n) time. Improving these trade-offs remains a decrease-key and insert take O(4 challenging open problem. √ Pairing heap variants. We refer to the pairing heap data structure described above as the standard pairing heap. Fredman et al. [9] also proposed a number of variants that differ in the way the heap is consolidated during a delete-min operation. We describe first the forward variant, which is the main subject of this paper (in the original pairing heap paper this is called the front-to-back variant). The pairing round in the forward variant is identical to the standard variant, resulting in roots y1, . . . , yt, where t = dk/2e, and k is the number of children of the deleted root. In the forward variant, however, we perform the second round also from left to right: for all i = 1, . . . , t − 1, we call link(pi, yi+1), where pi is the minimum among y1, . . . , yi. Occasionally we refer to pi as the current left-to-right minimum. See Figure 1 for an illustration. What may seem like a minor change causes the data structure to behave differently. Currently, the forward variant appears to be much more difficult to analyse than the standard variant. The implementation of the forward variant is arguably simpler. The two passes can be performed together in a single pass, using only the standard leftmost child and right sibling pointers. In fact, it is possible to implement the two rounds in one pass also in the standard variant. To achieve this, we need to perform both the pairing and accumulation rounds from right to left. As shown by Fredman et al. [9], this can be done with a slightly more complicated link structure, and the original analysis goes through essentially unchanged. Regardless of the low-level details, it remains the case that of the two most natural pairing heap variants one is significantly better understood than the other. Yet another variant described by Fredman et al. [8] is the multipass pairing heap. Here, instead of an accumulation round, repeated pairing rounds are executed, until a single root remains. For multipass pairing heaps, the bound of O(cid:0)log n · log log n/ log log log n(cid:1) was shown [9] on the cost of a delete-min.5 Fredman et al. [9] also describe what we could call the arbitrary pairing and linking variant. Here, before performing the initial pairing round, the roots may be arbitrarily reordered. After the pairing round, arbitrary pairs of roots (not necessarily neighbors) are linked, until there is a single root left. For this general case (that subsumes all previous √ variants) Fredman et al. [9] show a tight6 Θ( n) amortized bound for delete-min. Even in √ n) upper bound has never been improved. the special case of the forward variant, the O( Our main result is the following. (cid:73) Theorem 1. In the forward variant of pairing heaps, the amortized costs of delete-min and insert are O(log n · 4 log n), where n is the number of items in the heap when the operation is performed. √ 4 Both results are rather subtle, for instance, it is not clear whether decrease-key remains costly in an implementation where we cut an affected node only if its decreased key is smaller than that of its parent. 5 A recently claimed improvement by Pettie [25] would reduce this to an almost, but not quite, logarithmic bound. The result of Pettie has, in some sense, inspired our results. 6 It is not clear how efficient this strategy is if we only allow link operations between neighboring siblings. XX:4 Pairing heaps: the forward variant The result holds for sequences of insert and delete-min operations arbitrarily intermixed, starting from an empty heap. Note that an insert operation performs a single link, its worst-case cost is therefore constant. The quantity in the running time is asymptotically smaller than nε, for all ε > 0. We log n term grows much faster than the log n term, as for arbitrary constants √ remark that the 4 c, d > 1 it holds that c √ log n = ω(logd n). Besides the concrete result (heaps with proven logarithmic cost are known, afterall), the contribution of our paper is in the development of a new, fairly general potential function, that may have further applications. There has been significant further work in designing heap data structures, with the goal of finding a simpler alternative to Fibonacci heaps, matching, or almost matching their theoretical guarantees (e.g., [27, 19, 7, 12, 13, 4]). These heaps are typically more complicated than pairing heaps. Moreover, they are not self-adjusting, i.e., they store extra information at the nodes, are thus out of the scope of this paper. Splaying and sorting. There is a standard representation of multi-way rooted trees as binary trees ([21, § 2.3.2], [9]), by renaming the leftmost child and right sibling pointers as left child and right child. (See Figure 1.) In this binary tree representation, the restructuring performed when we delete the minimum from a pairing heap closely resembles the restructuring performed by an access to an item in a splay tree. The correspondence is sufficiently close that the proof of logarithmic access cost in splay trees [26] also goes through for the pairing heap. (We note that this correspondence is far from trivial: one has to relabel some nodes and swap their left and right children in the analysis to make it work; we refer to the original pairing heap paper [9] for details.) In case of the forward variant, the analogy with splay trees breaks down, with no apparent way to fix it. The reason is that the accumulation round of the forward variant may reverse the ordering of large groups of consecutive neighbors. In splay-view, this has the effect of turning long portions of the search path upside-down, something known to be notoriously hard to analyse, see [28, 3]. There is a close link between heaps and sorting. The ancestor-descendant relationship in a heap captures everything we know about the order of the keys at a certain time. A sequence of delete-mins in a pairing heap (or in any other heap, for that matter), can be seen as transitioning from the current partial order towards the total order, i.e., sorting. (More precisely, we have here a special kind of selection-sort, in which only candidate minima are ever compared.) It would then be natural for the potential function to capture some measure of "sortedness" of the heap, for example, the entropy of the partial order or some other quantity related to the number of linear extensions. In general, as observed by Pettie [24], this is far from being the case for the splay potential. The potential function in the classical analysis of splay trees is equal to the sum of the logarithms of subtree-sizes of all nodes in the tree. A subtree in the splay-view corresponds, in the heap-view, to the set of subtrees of a node and all of its right siblings (Figure 1). It is far from intuitive why such a quantity would be useful in analysing pairing heaps. In particular, this potential function does not distinguish between left and right children in the splay-view, even though, in the heap-view, they play different roles: one is a provably larger key, and the other is (so far) incomparable. It may seem that, implicitly, the splay potential assumes that the left-to-right ordering of siblings (in heap-view) is, to some extent, correlated with the sorted order. We argue that such an assumption is reasonable for the standard variant of pairing heaps, but not for the forward variant (since the accumulation round of the forward variant frequently reverses blocks of consecutive siblings). D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:5 Figure 1 Pairing heap delete-min operation. Left: heap-view, right: binary tree-view (splay- view). From top to bottom: (i) initial heap, (ii) deleting the root and a left-to-right pairing round, (iii) standard variant, resulting heap after right-to-left accumulation round, (iv) forward-variant, resulting heap after left-to-right accumulation round. Circled numbers are keys, letters indicate arbitrary subtrees. Observe that the forward variant (iv) reverses the ordering of the siblings with keys 2,6,5. XX:6 Pairing heaps: the forward variant As a simple example, consider either the standard or the forward variant, and look at a group of consecutive siblings x1, x2, . . . , xk, y (arbitrarily shuffled), of which y is the smallest. Suppose, for simplicity, that these nodes interact with each other only in pairing rounds, i.e., the minimum of the accumulation round always comes from "outside the group", and does not change within the group. Assume also that, in each pairing round following a deletion of the parent of the group, y gains one node from the group as its new leftmost child. If xi and xj both become children of y, and xi is to the left of xj, then xi became the child of y in a later round than xj, having "survived" more rounds (winning the links it took part in) at the same level as y. This fact is an indication that xi may be smaller than xj. When y is eventually deleted, the standard variant will preserve the order of its children, whereas the forward variant will reverse it (assuming again, that there is no minimum-change within the group during the accumulation round). There are limits to this intuition, and it is easy to construct examples that break it. Nonetheless, this interpretation suggests that we analyse the forward variant by somehow directly using the order-information, instead of trying to infer it from the tree structure. This motivates our potential function in § 2. The intuition described earlier also hints at why the standard variant of pairing heaps may in fact be faster than the forward variant. If the left-to-right ordering of siblings is indeed the increasing order, then a right-to-left accumulate round is vastly more efficient then a left-to-right round. (The former immediately achieves the sorted order, whereas the latter merely finds the minimum.) On the other hand, in this case, the left-to-right round also reverses the order of siblings, making it optimal for the subsequent round. This intuition is consistent with our experiments that show the forward-variant to be somewhat slower7 than the standard variant. However, the possibility that the forward-variant also has logarithmic cost has not been ruled out. It remains an interesting open question to determine the exact complexity of the forward variant, and to characterize the types of instances on which it may outperform the standard variant. We also leave open the question whether decrease-key may take o(log n) time in this variant, noting that the lower bound of Fredman [8] applies to this case, whereas the upper bound of Pettie [24] does not. More importantly, one can hope that new techniques for the analysis of pairing heaps will find their way to the analysis of splay trees and other dynamic search tree algorithms. Splaying and its variants pose some of the most intriguing and central open questions of the field, such as the dynamic optimality conjecture [26, 15]. 2 Analysis of the forward variant of pairing heaps Before proving our main result, as a warm-up, we look at the arbitrary pairing and linking variant of pairing heaps. First we introduce some terminology. We define the rank of a node x as the number of nodes in the heap with a smaller key,8 e.g., the rank of the root is 0. (For simplicity, we assume that the keys are unique.) We denote the rank of x by r(x). The rank-difference rd(x) of a node x is defined as rd(x) = r(x) − r(p(x)), where p(x) is the parent node of x. It is clear that rd(x) is positive for all non-root nodes x. For the root r, we define rd(r) = 0. 7 Experiments also suggest that multipass is somewhat slower than the standard variant [27]. 8 Contrary to many other ranks in the data structures literature, we use the word in its "original" meaning. D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:7 √ 2.1 Arbitrary pairing and linking We show that starting with an arbitrary initial heap of size n, the cost of n delete-mins using arbitrary pairing and linking is O(n n). This was already known, as a corollary of Fredman et al.'s result in the original pairing heap paper [9]. Our proof is different (and arguably simpler), and is intended to illustrate the use of rank-differences in the analysis. Consider a heap of size n. Let Φ denote the sum of rank-differences over all nodes of the heap. Observe that the ranks take all values 0, . . . , n − 1, and the rank-difference of a node is not more than its rank. It follows that 0 ≤ Φ ≤ n(n − 1)/2. For the purpose of the analysis, we slightly change the implementation of delete-min. Rather than deleting the root first, we first do the pairing and accumulation rounds on the children of the root, until the root has only one child. Only then, we actually delete the root. This modified algorithm is equivalent to the original. In this implementation, all link operations take place between children of the root. Consider a link between nodes x and y, whose rank-differences are a and b, respectively. Suppose x < y, and consequently a < b. After the operation, y becomes the leftmost child of x. The new rank-difference of y is b − a. Observe that the rank-differences of nodes other than y remain unchanged, therefore the potential Φ decreases by a. (cid:73) Theorem 2. The cost of n delete-min operations from an arbitrary initial heap of size n, using arbitrary pairing and linking, is O(n Proof. Consider a delete-min in which the root has k children. In the pairing round we perform bk/2c link operations. By the earlier observation, the potential Φ goes down by a1 + ··· + abk/2c, where ai is the rank-difference of the "winner" (i.e., smaller node) in the i-th link. The values ai are distinct (since all respective nodes have different ranks, and the same parent), and ai > 0 for all i. Thus, the entire pairing round reduces Φ by at least 1 + 2 + ··· + bk/2c ≥ (k2 − 1)/8 ≥ (k − 1)2/8. The remaining operations can only further decrease the potential. operation is at leastPn over all n operations is not more than n2/2. It follows thatP Let ki be the number of children of the root before the i-th delete-min operation. (This is also our estimate for the cost of the operation.) The total reduction in potential due to this i=1 (ki − 1)2 /8. On the other hand, the total reduction in potential i (ki − 1)2 ≤ 4n2. Under this √ condition, setting k1 = ··· = kn = 2 (cid:74) n + 1 maximizes the total real costP n). √ i ki. √ In its current form, the potential function is not well suited for analysing operations other than delete-min; a single insert, for example, may increase Φ by a linear term. We sketch a new analysis for sequences of insert and delete-min operations that foretells the technique used in § 2.2. Define the potential of a node x, denoted by φ(x), to be rd(x), if rd(x) ≤ √ n − 1, and √ n − 1 + rd(x)/ n otherwise. Call nodes of the first kind light, and nodes of the second kind heavy. The potential function Φ is now defined as the sum of φ(x) over all nodes x. Observe that for a heap of size n, the total potential is Φ < 2n Consider the pairing round in a delete-min operation. Since there are less than n light nodes among the children of the root, all but n of the link operations are between heavy nodes. It is easy to verify that a link between two heavy nodes reduces the potential by at least 1. The amortized O( n) cost of delete-min follows. Next we bound the amortized cost of an insert operation, considering the increase in potential that it may cause. √ First, we have to add the potential of the newly inserted key, which is at most 2 n. (In case the newly inserted key is the new minimum, it does not contribute to the potential.) √ √ √ n. √ XX:8 Pairing heaps: the forward variant The second, more subtle effect of insert is that it may cause a change in the rank- differences of other nodes. A given node y is affected by a newly inserted node x if the rank of x falls between the rank of y and that of its parent p(y). If the affected node y is a light node (before the insert), then its rank r(y) (before the insert) can be larger than r(x) by √ n − 2 (otherwise, the rank-difference of y would have been too large). There can at most √ n − 1 such nodes, and the potential of each may go up by 1. Otherwise, if y is be at most a heavy node, then φ(y) may go up only by 1/ n. Overall, the potential Φ increases by at √ most 2 √ n. The amortized O( n) cost of insert follows. The reader may observe that we ignored the change in potential due to the change in the value of n. We can deal with this technicality by keeping n unchanged, as long as it does not get too far away from the true number of elements. When that happens, n can be updated by a standard doubling-halving strategy, without affecting the claimed amortized costs. We discuss this issue in more detail in the context of our main result. √ 2.2 The main result (cid:73) Theorem 1. In the forward variant of pairing heaps, the amortized costs of delete-min and insert are O(log n · 4 log n), where n is the number of items in the heap when the operation is performed. √ To prove Theorem 1, we replace the simple potential function used in § 2.1 by one with a more fine-grained scaling. Again, first we present the tools necessary to analyse the heap in a sorting mode, i.e., we compute the cost of n delete-min operations on an arbitrary initial heap of size n, then we make the necessary changes to analyse both insert and delete-min. In the following, for the purpose of analysis, we assume that n is an upper bound on the number of nodes in the heap, not greater than four times the true value. (Except for the beginning, when the heap is empty, and we set n to a small constant value, say n = 4.) At the end, we describe how we update n, if, after a certain number of operations, the true value reaches n, or falls far below n. Let q = q(n) be the scaling factor for n, an integer that we optimize later; assume for now that 1 < q < n. The category of a (non-root) node x, denoted c(x) is defined as c(x) = blogq rd(x)c. Observe that c = c(x) is the unique integer for which qc ≤ rd(x) < qc+1. For all nodes x we have 0 ≤ c(x) < t, where t = t(n) = blogq (n − 1)c + 1, and t ≥ 2. For all non-root nodes x, we define the node potential of x as φ(x) = rd(x) − qc For the root r, we let φ(r) = 0. The total node potential is ΦN =P φ(x), where the sum qc − qc−1 + c · q, where c = c(x). ranges over all nodes x. Some observations about the node potential are in order. (cid:73) Lemma 3. With the previous definitions, we have: (i) If rd(y) = rd(x) + 1, and rd(x) ≥ 1, then φ(y) = φ(x) + 1/(qc − qc−1), where c = c(x). (ii) For every node x, it holds that 0 ≤ φ(x) ≤ t · q, and therefore ΦN ≤ n · t · q. (iii) If two nodes of the same category are linked, then ΦN decreases by at least 1. Proof. (i) Suppose c(y) = c(x) = c. Then, φ(y) − φ(x) = (rd(y) − rd(x)) /(qc − qc−1) = 1/(qc − qc−1). Otherwise, suppose c(y) = c(x) + 1. Let c = c(x). Then, rd(y) = qc+1, and rd(x) = qc+1−1. Thus, φ(y)− φ(x) = (c+1)· q−(qc+1−1− qc)/(qc− qc−1)− c· q = 1/(qc − qc−1). D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:9 (ii) From (i) it follows that φ(x) is maximal if rd(x) = n − 1. Then, c(x) = t − 1, and φ(x) ≤ (qt − qt−1)/(qt−1 − qt−2) + (t − 1) · q = t · q. (iii) Let us define the function f(·) that maps rd(x) to φ(x) for all x. It is easy to verify that f(·) is strictly increasing for rd(x) ≥ 1. Suppose that x < y, and c(x) = c(y) = c. Then, qc ≤ rd(x) < rd(y) < qc+1. Only the potential of y changes after the link operation, from f(rd(y)) to f(rd(y) − rd(x)). We want to show f(rd(y)) − f(rd(y) − rd(x)) ≥ 1. This quantity is minimized if rd(x) = qc. By (i), f(rd(y) − qc) ≤ f(rd(y)) − qc/(qc − qc−1) ≤ f(rd(y)) − 1. The (cid:74) result follows. Suppose that x1, . . . , xk are children of the same node in the heap, indexed in left-to-right order. A subset {xi, xi+1, . . . , xj} of these nodes, for 1 ≤ i < j ≤ k, is referred to as a contiguous group of siblings. Within the heap, we consider certain contiguous groups of siblings to be in a box; this is only for the purpose of the analysis, with no effect on the implementation. We define a second kind of potential to capture the current state of the boxes. Throughout the lifetime of the heap we maintain a number of invariants about the boxes, as follows. (A) The size of a box (i.e., the number of nodes in a box) is of the form 2b − 1, for some 2 ≤ b ≤ t. (B) Boxes are pairwise disjoint. (C) A box of size 2b − 1 can only contain nodes of category b − 2 or smaller. The box potential, denoted ΦB is a sum over all boxes of (b − t − 1)/t, where 2b − 1 is the size of the box. In particular, the largest possible box of size 2t − 1 contributes −1/t to the box potential, and the smallest possible box of size 3 contributes (1/t − 1). Observe that −n < ΦB ≤ 0. At the beginning of the operations there are no boxes, therefore ΦB = 0. The total potential Φ combines the node potential and the box potential, as Φ = ΦN +ΦB. We are ready to analyse the individual operations and their effect on the potential. Delete-min only. Again, assume that the delete-min operation performs the pairing and accumulation rounds first, and deleting the root afterwards. We need to account for the change of node and box potential in all steps. Consider an operation link(x, y), and assume w.l.o.g. that x < y, and therefore x becomes the parent of y. We say that the link is a good link if one of the following holds: (1) before the link x and y were of the same category, (2) the link occurs in the accumulation round, is not of type (1), and y is the left-to-right minimum before the link (being replaced by x in this role). At a high level, our strategy is to show that for every t · 2t link operations, one good link occurs. A good link of the type specified in case (1) decreases the node potential by at least 1. Therefore, by Lemma 3(ii), there are at most n · t · q such links. (In our current setting no action increases the node potential.) A good link of the type specified in case (2) can occur at most t − 1 times during a delete-min. To see that there are no more than t − 1 type-(2) good links in a delete-min, observe that such an event necessarily leads to a decrease in category of the current left-to-right minimum, and the number of possible categories is t. The link operations that we charge to a single good link may be scattered through multiple delete-min operations. The purpose of the boxes is to keep track of link operations that we have not yet accounted for. Let k denote the number of children of the deleted root, i.e., the real cost of the operation, up to a constant factor, and let us look in turn at the pairing round, accumulation round, and the deletion of the root. XX:10 Pairing heaps: the forward variant Figure 2 The evolution of a box. Numbers indicate categories of nodes. The losers of the comparisons drop out of the box. Pairing round. Consider the links involving nodes from a box of size 2b − 1. If at least one of these is a good link of type (1), we simply remove the box. The result is an increase in box potential by (t − b + 1)/t due to the deletion of the box, and a decrease in node potential by at least 1 due to the good link. This amounts to a decrease in total potential of (b− 1)/t ≥ 1/t. Observe that if the box size before the operation is 22 − 1 = 3 (i.e., minimal), then the link operation within the box is always a good link. This is because, by invariant (C), all nodes in the box are of category 0. Suppose that we process a box of size 2b − 1 for b > 2, and no good link occurs within the box. Then, the box continues to exist around the winners of the link operations where both nodes were in the same box, i.e., the losers of the link operations, and possibly the nodes "on the margin" leave the box. Observe that the size of the box goes from 2b − 1 to 2b−1 − 1. Due to the decrease of the box size, we have a decrease in box potential by 1/t, and consequently a decrease by 1/t in total potential. (See Figure 2 for illustration.) Now suppose we execute T = 2t − 1 consecutive non-good link operations without encountering a box. Then, we form a box around the 2t − 1 winners of these links. Due to the newly created box of maximum size, the total potential decreases by 1/t. Consider a sequence of T consecutive links. Then, either (i) one of the links is good, or (ii) we create a new box containing the T winners, or (iii) we encounter an existing box. In the latter case, we process the box until its end. Thus, in all cases, for at most 2T − 1 consecutive link operations, we achieve a saving in potential of at least 1/t. This yields (for the entire pairing round) a decrease in potential of at least 4 · t · 2t − 2 j bk/2c k · 1 2 · 2t − 3 ≥ k . t t We need to argue that in the cases described above, the box invariants are maintained. Condition (A) clearly holds in every case. When we create a new box, we only use nodes that are not in a box, therefore condition (B) holds. We never add new nodes to an existing box, thus (B) continues to hold. We next discuss the validity of invariant (C), which is the crucial ingredient of the proof. When a new box of size 2t − 1 is created, we claim that there cannot be any node of category t − 1 within the box. This is because, if any node in the box was of category t − 1, its "winning" of the linking would have happened against another node of category t − 1, a type-(1) good link that contradicts our condition for creating the box. Similarly, when shrinking an existing box from size 2b − 1 to 2b−1 − 1, if invariant (C) was true before the operation (i.e., there were only nodes of category 0, . . . , b − 2 in the box), then the nodes in the box after the operation can only be of category 0, . . . , b − 3. A node of category b − 2 could only have "won" against another node of category b − 2, a type-(1) good link that contradicts our condition for maintaining the box. This establishes the invariants. ............ D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:11 Accumulation round. By Lemma 3(i), the node potential can only further decrease. We need to argue that the box-structure is not destroyed by this round. Recall that we start with the leftmost node (the current minimum), and keep linking against the nodes from left to right. As long as there is no type-(2) good link, the nodes that we encounter left-to-right become the children of the current minimum in right-to-left order. The box invariants are clearly not affected by this reversal of order, the box, together with its parent node simply moves further down the tree. (Categories of nodes in the box can only decrease.) If there is a change in the minimum, i.e., a type-(2) event, while we are processing the nodes in a box, then we delete the box. By deleting the box, we may increase the box potential by 1− 1/t < 1. This is the only kind of potential-change we need to consider in this round, yield- ing an increase in total potential of at most t−1 (since there are at most t−1 type-(2) events). Deleting the root. The actual deletion of the root leaves the node potential unchanged, since at that time the root has only one child, its successor, which has rank-difference 1, and con- sequently, node potential 0. The box potential is unaffected, since the root cannot be in a box. To summarize, if the actual cost of delete-min is k, then, collecting the terms from the different rounds, the decrease in potential is at least k/(4t· 2t)− 2/t− (t− 1) ≥ k/(4t· 2t)− t. Denoting the actual costs of the n delete-min oparations by k1, . . . , kn, for the total potential decrease ∆Φ we have: 1 4t · 2t ! nX i=1 ∆Φ ≥ − n · t. ki From Lemma 3(i) it follows that Φ ≤ n·t·q, for an arbitrary heap. For the empty heap, we have Φ = 0. Thus, ∆Φ ≤ n· t· q. It follows that the total cost isP ki ≤ (n· t· q + n· t)·(4t·2t). √ Fixing t = b√ log nc, we have q = O(n1/ log n) = O(2 √ amortized cost of delete-min is O(log n · 4 log n). Let us now choose the scaling factor used in the analysis. Recall that t = blogq (n − 1)c. log n). Thus, we obtain that the √ Insert and Delete-min. Next, we consider sequences of insert and delete-min operations, arbitrarily intermixed. The amortised cost of an operation is defined as the true cost plus the increase in potential due to the operation. The analysis of delete-min is the same as before, yielding a decrease in total potential due to a delete-min of at least k/(4t · 2t) − t, where k is the actual cost of the operation. The true cost of insert is O(1), but we also need to consider the increase in potential. The box potential is not affected by insert, as we do not create any new boxes and neither the root, nor the newly inserted node are in a box. When a key x is inserted, its first contribution is its own node potential φ(x), in case it becomes the child of the root. (If x is smaller than the root, then, after the linking, both x and the old root have node potential zero.) By Lemma 3(ii), the resulting increase in the node potential is at most t · q. As in § 2.1, we need to deal with the fact that an insert operation may change the ranks of existing nodes, possibly increasing their rank-difference. We could proceed with an argument similar to the one in § 2.1, estimating the change in potential for nodes in each category. The argument gets complicated, however, because the increase in rank-difference may also cause an increase in category, invalidating the box invariants. XX:12 Pairing heaps: the forward variant To avoid9 the issue of updating ranks during an insert operation, we redefine rank to take into account not just the items currently in the heap, but also the items that will be inserted into the heap in the future. (Since we use ranks only in the analysis, we can assume that future operations are known to us.) In this way, an insert operation has no effect on ranks, rank-differences, or categories of existing items, since the rank of the newly inserted item has already been taken into consideration. Therefore, there is no further change in potential that we need to consider. There remains the issue, that we cannot afford to look too far into the future, as we want the value n to be, at all times, close to the current size of the heap. Therefore, we split the operations into epochs, and keep the value of n fixed throughout an epoch. If the heap is empty, e.g., in the beginning, we let n = 4. An epoch ends when the true size of the heap increases to n (after an insert), or decreases to bn/4c (after a delete-min), or if, within the epoch, n distinct keys have already been encountered (including those that were in the heap at the beginning of the epoch). In all three cases, we reset n to be twice the true size of the heap, remove all boxes, and start a new epoch. (We stress that epochs and boxes are used only in the analysis, with no effect on the actual operation of the data structure.) As mentioned, the ranks of the items are computed with respect to all items encountered during an epoch, they are therefore, fixed within the epoch. Clearly, all ranks and rank-differences are still upper bounded by n. We make four observations, all of which are easy to verify based on the preceding discussion: (1) The true size of the heap is between bn/4c and n. (2) Within a finished epoch there must have been at least dn/4e operations. (3) The increase in node potential due to the resetting of n is not more than n · t · q. (4) Since the boxes are disjoint, there are less than n boxes that we are removing, increasing the total potential by at most n. We distribute the increase in potential of at most n · t · q + n among the dn/4e operations in the finished epoch, obtaining that the increase in potential during an insert is at most 5·t·q+4, and the increase in potential during a delete-min is at most t−k/(4t·2t)+4·t·q+4. Scaling the potential by t · 2t, we obtain that the amortized cost of both insert and delete-min is O(t2 · q · 2t). Again, choosing t = b√ log nc, we obtain q = O(n1/ √ amortized costs of O(log n · 4 log n) follow. log n), and the √ √ log n) = O(2 Meld. A meld operation is similar to an insert, in that only one node changes its rank- difference, and thereby its node potential (the root with the larger key). Furthermore, meld also leaves the box potential unaffected, so its analysis goes through similarly to the analysis of insert, yielding the same amortized cost for meld as for insert and delete-min. Observe, however, that if we also include meld operations in a sequence of operations, then the value n that appears in the cost no longer denotes just the size of the affected heap, it is instead, the number of items in all heaps that we are currently working with. 9 We observe that our problem of maintaining the ranks under insertions is reminiscent of the well-studied ordered list maintenance problem, for which efficient (although quite involved) solutions exist. Luckily, we can get away with a simpler solution. D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:13 Other variants. The presented analysis is fairly general. It is not difficult to adapt it to the standard and multipass variants of pairing heaps, yielding similar upper bounds. For the standard variant the analysis is essentially the same as for the forward variant. For multipass, the analysis becomes simpler, since boxes need to be maintained only during individual delete-min operations. However, for these variants, stronger upper bounds are already known, as discussed in § 1. Recall that during a link operation, the larger of the two items is linked as the leftmost child of the smaller. The reader may observe that the different behaviors of the standard and forward variants depend on this particular way of implementing link. If we were to link by making the larger item the rightmost child of the smaller, then the situation would reverse, with the forward variant being easy, and the standard variant hard to analyse. We may modify the implementation of link, such as to link arbitrarily as the leftmost or rightmost child (i.e., deciding independently for every link operation whether to link at the left or at the right). Our analysis also extends to this more general class of pairing heap algorithms (that use the modified link implementation) with minimal changes. The only difficulty that arises in the new setting is that during the accumulation round, an existing box may split into two, one part going to the left, the other to the right side of the current minimum. To account for this loss, we need to start with a larger initial box (4t instead of 2t). The resulting bounds are still of the form 2O( log n). Improving (significantly) the bounds presented in the paper and extending the analysis to other operations should be possible but will likely require new ideas. √ XX:14 Pairing heaps: the forward variant References 1 G. M. Adelson-Velskiı and E. M. Landis. An algorithm for organization of information. Dokl. Akad. Nauk SSSR, 146:263–266, 1962. 2 Rudolf Bayer. Symmetric binary b-trees: Data structure and maintenance algorithms. Acta Informatica, 1(4):290–306, Dec 1972. Parinya Chalermsook, Mayank Goswami, László Kozma, Kurt Mehlhorn, and Thatchaphol Saranurak. Self-adjusting binary search trees: What makes them tick? In ESA 2015, pages 300–312, 2015. 3 4 Timothy M. Chan. Quake Heaps: A Simple Alternative to Fibonacci Heaps, pages 27–32. Springer Berlin Heidelberg, Berlin, Heidelberg, 2013. 5 Thomas H. Cormen, Clifford Stein, Ronald L. Rivest, and Charles E. Leiserson. Introduction to Algorithms. McGraw-Hill Higher Education, 2nd edition, 2001. 6 Amr Elmasry. Pairing heaps with O(log log n) decrease cost. In Proceedings of the Twentieth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2009, New York, NY, USA, January 4-6, 2009, pages 471–476, 2009. 7 Amr Elmasry. The violation heap: a relaxed fibonacci-like heap. Discrete Math., Alg. and Appl., 2(4):493–504, 2010. 8 Michael L. Fredman. On the efficiency of pairing heaps and related data structures. J. ACM, 46(4):473–501, 1999. 9 Michael L. Fredman, Robert Sedgewick, Daniel Dominic Sleator, and Robert Endre Tarjan. The pairing heap: A new form of self-adjusting heap. Algorithmica, 1(1):111–129, 1986. 10 Michael L. Fredman and Robert Endre Tarjan. Fibonacci heaps and their uses in improved network optimization algorithms. In 25th Annual Symposium on Foundations of Computer Science, West Palm Beach, Florida, USA, 24-26 October 1984, pages 338–346, 1984. Leonidas J. Guibas and Robert Sedgewick. A dichromatic framework for balanced trees. In 19th Annual Symposium on Foundations of Computer Science, Ann Arbor, Michigan, USA, 16-18 October 1978, pages 8–21, 1978. 11 12 Bernhard Haeupler, Siddhartha Sen, and Robert Endre Tarjan. Rank-pairing heaps. SIAM J. Comput., 40(6):1463–1485, 2011. 14 15 Improved upper bounds for pairing heaps. In pursuit of the dynamic optimality conjecture. 13 Thomas Dueholm Hansen, Haim Kaplan, Robert Endre Tarjan, and Uri Zwick. Hollow heaps. In Automata, Languages, and Programming - 42nd International Colloquium, IC- ALP 2015, Kyoto, Japan, July 6-10, 2015, Proceedings, Part I, pages 689–700, 2015. John Iacono. In Algorithm Theory - SWAT 2000, 7th Scandinavian Workshop on Algorithm Theory, Bergen, Norway, July 5-7, 2000, Proceedings, pages 32–45, 2000. John Iacono. In Space-Efficient Data Structures, Streams, and Algorithms, volume 8066 of Lecture Notes in Computer Science, pages 236–250. Springer Berlin Heidelberg, 2013. John Iacono and Özgür Özkan. A tight lower bound for decrease-key in the pure heap model. CoRR, abs/1407.6665, 2014. John Iacono and Özgür Özkan. Why some heaps support constant-amortized-time decrease- key operations, and others do not. In Automata, Languages, and Programming - 41st Inter- national Colloquium, ICALP 2014, Copenhagen, Denmark, July 8-11, 2014, Proceedings, Part I, pages 637–649, 2014. John Iacono and Mark Yagnatinsky. A Linear Potential Function for Pairing Heaps, pages 489–504. Springer International Publishing, Cham, 2016. 16 17 18 19 Haim Kaplan and Robert Endre Tarjan. Thin heaps, thick heaps. ACM Trans. Algorithms, 4(1):3:1–3:14, 2008. D. Dorfman, H. Kaplan, L. Kozma and U. Zwick XX:15 20 Irit Katriel, Peter Sanders, and Jesper Larsson Träff. A practical minimum spanning tree algorithm using the cycle property. In Algorithms - ESA 2003, 11th Annual European Symposium, Budapest, Hungary, September 16-19, 2003, Proceedings, pages 679–690, 2003. 21 Donald E. Knuth. The Art of Computer Programming, Volume 1 (3rd Ed.): Fundamental Algorithms. Addison Wesley Longman Publishing Co., Inc., Redwood City, CA, USA, 1997. 22 Daniel H. Larkin, Siddhartha Sen, and Robert Endre Tarjan. A back-to-basics empirical In 2014 Proceedings of the Sixteenth Workshop on Algorithm study of priority queues. Engineering and Experiments, ALENEX 2014, Portland, Oregon, USA, January 5, 2014, pages 61–72, 2014. 23 Bernard M. E. Moret and Henry D. Shapiro. An empirical analysis of algorithms for constructing a minimum spanning tree, pages 400–411. Springer Berlin Heidelberg, Berlin, Heidelberg, 1991. Seth Pettie. Towards a final analysis of pairing heaps. In 46th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2005), 23-25 October 2005, Pittsburgh, PA, USA, Proceedings, pages 174–183, 2005. Seth Pettie. Thirteen ways of looking at a splay tree. Unpublished lecture, 2014. 25 26 Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary search trees. J. 24 27 ACM, 32(3):652–686, 1985. John T. Stasko and Jeffrey Scott Vitter. Pairing heaps: Experiments and analysis. Com- mun. ACM, 30(3):234–249, March 1987. 28 Ashok Subramanian. An explanation of splaying. J. Algorithms, 20(3):512–525, 1996. 29 Jean Vuillemin. A data structure for manipulating priority queues. Commun. ACM, 21(4):309–315, 1978.
1805.04375
4
1805
2019-02-26T12:36:12
On the Parameterized Complexity of Graph Modification to First-Order Logic Properties
[ "cs.DS", "cs.CC" ]
We consider the problems of deciding whether an input graph can be modified by removing/adding at most k vertices/edges such that the result of the modification satisfies some property definable in first-order logic. We establish a number of sufficient and necessary conditions on the quantification pattern of the first-order formula \phi for the problem to be fixed-parameter tractable or to admit a polynomial kernel.
cs.DS
cs
On the Parameterized Complexity of Graph Modification to first-order logic Properties∗ Fedor V. Fomin† Petr A. Golovach† Dimitrios M. Thilikos‡ February 27, 2019 Abstract We establish connections between parameterized/kernelization complexity of graph modification problems and expressibility in logic. For a first-order logic formula ϕ, we consider the problem of deciding whether an input graph can be modified by re- moving/adding at most k vertices/edges such that the resulting modification has the property expressible by ϕ. We provide sufficient and necessary conditions on the struc- ture of the prefix of ϕ specifying when the corresponding graph modification problem is fixed-parameter tractable (parameterized by k) and when it admits a polynomial kernel. Keywords: First-order logic, graph modification, parameterized complexity, descriptive complexity, kernelization 1 Introduction A variety of algorithmic graph problems, called modification problems, can be formulated as problems of modifying a graph such that the resulting graph satisfies some fixed desired property. The study of graph modification problems is one of the most popular trends in graph algorithms, and in particular, in parameterized complexity. One of the classic results about graph modification problems is the work of Lewis and Yannakakis [16], which provides necessary and sufficient conditions (assuming P 6= NP) of polynomial time solvability of vertex-removal problems for hereditary properties. For other types of graph modification problems, like edge-removal problems [21], no such dichotomy is known. For the past 30 years graph modification problems served as a strong inspiration for developing new methods and techniques in parameterized/kernelization algorithms and complexity, see the books [6, 7, 9, 17] for an overview of the area. In this paper we approach graph modification problems from the perspective of de- scriptive complexity. Descriptive complexity is the field of logic which studies the relations between computational complexity and expressibility in logic. The classic example of a theorem in descriptive complexity is the theorem of Fagin [8] asserting that a property ∗The two first authors have been supported by the Research Council of Norway via the projects "CLAS- SIS" and "MULTIVAL". The third author has been supported by projects DEMOGRAPH (ANR-16-CE40- 0028) and ESIGMA (ANR-17-CE23-0010). All authors have been supported by the Research Council of Norway and the French Ministry of Europe and Foreign Affairs, via the Franco-Norwegian project PHC AURORA 2019. Emails of authors: {fedor.fomin, petr.golovach}@ii.uib.no, [email protected]. †Department of Informatics, University of Bergen, Norway. ‡AlGCo project team, CNRS, LIRMM, Universit´e de Montpellier, Montpellier, France. 1 of graphs is in NP if and only if it is definable by an existential second-order formula. We refer to the recent book of Grohe [12] for a modern overview of descriptive complex- ity. The significant amount of research in descriptive complexity is devoted to the study of prefix classes of certain logics. A prefix class is a syntactic fragment of first-order or second-order logic with formulas in prenex normal form and imposed constrains on the patterns of quantifiers in formulas. For example, the study of prefix classes of first-order logic is provided in the book of Borger, Gradel, and Gurevich [4], see also the work of Gottlob, Kolatis and Schwentick [11] on characterizing the computational complexity of prefix classes of second-order logic. Our results. Let φ be an FOL formula on (undirected) graphs in prenex normal form. In particular, φ = Q1x1Q2x2 ··· Qtxtχ, where t is some constant, each Qi ∈ {∀,∃} is a quantifier, xi is a variable, and χ is a quantifier-free part that depends on the variables x1, . . . , xt. We consider the following generic problems (we use "−" for the vertex/edge removal, "+" for the edge addition and "4" for the symmetric difference). Vertex-Removal to φ Parameter: k Input: A graph G and an integer k. Question: Does there exist a vertex set S ⊆ V (G) with S ‹ k such that G− S = φ? Edge-Removal to φ Parameter: k Input: A graph G and an integer k. Question: Does there exist an edge set F ⊆ E(G) with F ‹ k such that G−F = φ? Edge-Completion to φ Input: A graph G and an integer k. Question: Does there exist F ⊆(cid:0)V (G) Question: Does there exist F ⊆(cid:0)V (G) Edge-Editing to φ Input: A graph G and an integer k. 2 2 Parameter: k (cid:1) \ E(G) with F ‹ k such that G + F = φ? (cid:1) with F ‹ k such that G 4 F = φ? Parameter: k For example, for φ = ∀u∀v¬(u ∼ v), Vertex-Removal to φ is equivalent to Vertex Cover that is the graph modification problem asking whether one can remove at most k vertices such that the resulting graph has no edges (we use u ∼ v for the adjacency predicate). More generally, any vertex-removal problem to a graph class characterized by a finite set of forbidden subgraphs, can be expressed as Vertex-Removal to φ for some φ with only ∀ quantifications over variables, where the number of variables is the maximum number of vertices of a forbidden graph. Clearly, using FOL, we are able to express other properties. For example, the property that the diameter of a graph is at most two cannot be expressed using forbidden subgraphs but can easily be written as the FOL formula ∀u∀v∃w[(u = v)∨ (u ∼ v)∨ ((u ∼ w)∧ (v ∼ w))]. Similarly, the edge variants of modification problems to φ capture quite a few interesting and well-studied problems like Cluster Editing, where the task is to change at most k adjacencies in the graph resulting in a disjoint union of cliques. We consider modification problems, where the specification of a prefix class of for- mula φ is defined according to the arithmetic hierarchy (also known as Kleene-Mostowski hierarchy) used for classifications of the formulas in the first-order arithmetic language (see, e.g., [18]). We define prefix classes according to alternations of quantifiers, that is, switchings from ∀ to ∃ or vice versa in the prefix string of the formula. We allow a formula to have free, i.e., non-quantified, variables. Let Σ0 = Π0 be the classes of FOL-formulas 2 without quantifiers. For a positive integer s, the class Σs contains formulas that could be written in the form φ = ∃x1∃x2 ···∃xtψ, where ψ is a Πs−1-formula, t is some integer, and x1, . . . , xt are free variables of ψ. Re- spectively, Πs consists of formulas φ = ∀x1∀x2 ···∀xtψ, where ψ is a Σs−1-formula and x1, . . . , xt are free variables of ψ. Note that we allow t = 0, which implies that for s0 > s, Σs ∪ Πs ⊆ Σs0 ∩ Πs0. We establish a number of algorithmic results about modification problems where the target property is definable in FOL. We complement these results by lower bounds, which in combination provide a neat dichotomy theorems about the parameterized complexity of such problems. Hence we establish sufficient and necessary conditions on the prefix classes of FOL-formulas such that the corresponding graph modification problems are fixed-parameter tractable and/or admit a polynomial kernel. Our first result shows the following dichotomy (subject to W[2] 6= FPT) for Vertex- Removal to φ, depending on the structure of the prefix class of φ. Theorem 1. (i) For every φ ∈ Σ3 without free variables, Vertex-Removal to φ is FPT. (ii) There is φ ∈ Π3 without free variables such that Vertex-Removal to φ is W[2]- hard. In other words, if the prefix of an FOL-formula φ has at most two alternations of quantifiers and, in the case of exactly two alternations, if the first quantifier is ∃, then Vertex-Removal to φ is FPT. For each other type of quantifier alternations, there exists a formula for which the problem becomes W[2]-hard. For kernelization complexity of Vertex-Removal to φ, we establish the following dichotomy. Theorem 2. (i) For every φ ∈ Σ1 ∪ Π1 without free variables, Vertex-Removal to φ admits a polynomial kernel. (ii) There is φ ∈ Σ2 (φ ∈ Π2) without free variables such that Vertex-Removal to φ admits no polynomial kernel unless NP ⊆ coNP/poly. For edge-modification problems we prove the following. Theorem 3. (i) For every φ ∈ Σ2 without free variables, Edge-Removal to φ, Edge-Completion to φ, and Edge-Editing to φ are FPT. (ii) There exists φ ∈ Π2 without free varaibles such that Edge-Removal to φ (re- spectively, Edge-Completion to φ and Edge-Editing to φ) is W[2]-hard. We observe that if φ ∈ Σ1, then all considered problems can be solved in polynomial time. Clearly, this means that they are FPT and have trivial polynomial kernels. We complement this with lower bounds and summarize these results in the following theorem. 3 Theorem 4. (i) For every φ ∈ Σ1 without free variables, Edge-Removal to φ, Edge-Completion to φ, and Edge-Editing to φ admit polynomial kernels. (ii) There exists φ ∈ Π1 without free variables such that Edge-Removal to φ (respec- tively, Edge-Completion to φ and Edge-Editing to φ) admits no polynomial kernel unless NP ⊆ coNP/poly. This paper is organized as follows. In Section 2, we introduce basic notions and state some auxiliary results. In Section 3, we obtain the algorithmic upper bounds, that is, we show the claims (i) of Theorems 1 -- 4. In Section 4, we complement these results by the lower bounds given in the claims (ii) of Theorems 1 -- 4. We conclude with Section 5, where we discuss some possible extension of our results and mention some directions for further research. 2 Preliminaries Sets. We use N to denote the set of all non-negative numbers. Given some k ∈ N, we (cid:0)A denote [k] = [1, k]. Given a set A, we denote by 2A the set of all its subsets and we define (cid:1) := {e e ∈ 2A ∧ e = 2}. We denote by a = ha1, . . . , ari a sequence of elements of a 2 set A and call a an r-tuple of simply a tuple. Note that the elements of a not necessarily pairwise distinct. We denote by ab the concatenation of tuples a and b. Graphs. All graphs in this paper are undirected, loop-less, and without multiple edges unless it is explicitly specified to be different. Given a graph G, we denote by V (G) its vertex set and by E(G) its edge set. For an edge e = {x, y} ∈ E(G), we use instead the notation e = xy, that is equivalent to e = yx. We denote G = V (G). Throughout the paper we use n to denote G if it does not create confusion. For a vertex v, dG(v) denotes the degree of v. For any set of vertices S ⊆ V (G), we denote by G[S] the subgraph of G induced by the vertices from S. We also define G − S := G[V (G) \ S]. Given an edge set F is a set of pairs of vertices that are not edges of G, we define G+ F = (V (G), E(G)∪ F ), F ⊆ E(G), we denote G− F = (V (G), E(G)\ F ). Also, given a set F ⊆(cid:0)V (G and for F ⊆(cid:0)V (G (cid:1), we define G 4 F = (V (G), E(G) − E(G) ∩ F + F \ E(G)). (cid:1)\ E(G), i.e., 2 2 Formulas. In this paper we deal with logic formulas on graphs. In particular we will deal with formulas of first-order logic (FOL). The syntax of FOL-formulas on graphs includes the logical connectives ∨, ∧, ¬, variables for vertices, the quantifiers ∀, ∃ that are applied to these variables, the predicate u ∼ v, where u and v are vertex variables and the interpretation is that u and v are adjacent, and the equality of variables representing vertices. . It also convenient to assume that we have the logical connectives → and ↔. An FOL-formula φ is in prenex normal form if it is written as φ = Q1x1Q2x2 ··· Qtxtχ where each Qi ∈ {∀,∃} is a quantifier, xi is a varible, and χ is a quantifier-free part that depends on the variables x1, . . . , xt. Then Q1x1Q2x2 ··· Qtxt is referred as the prefix of φ. From now on, when we mention the term "FOL-formula", we mean an FOL-formula on graphs that is in prenex normal form. For an FOL-formula φ without free variables and a graph G, we write G = φ to denote that φ evaluates to true on G. For technical reasons, we extend FOL-formulas on graphs to structures of a special type. We say that a pair (G, v), where v = hv1, . . . , vri is an r-tuple of vertices of G, is an r-structure. Let φ be an FOL-formula without free variables and let x = hx1, . . . , xri be an 4 r-tuple of pairwise distinct variables of φ. We denote by φ[x] the formula obtained from φ by the deletion of the quantification over x1, . . . , xr, that is, these variables become the free variables of φ[x]. For an r-structure (G, v) with v = hv1, . . . , vri and φ[x], we write (G, v) = φ[x] to denote that φ[x] evaluates to true on G if xi is assigned vi for i ∈ [r]. If r = 0, that is, v and x are empty, then (G, v) = φ[x] is equivalent to G = φ. Parameterized Complexity. We refer to the books [6, 7, 9, 17] for the detailed intro- duction to the field. Here we only briefly review the basic notions. Parameterized Complexity is a bivariate framework for studying the computational complexity of computational problems. One variable is the input size n and the other is a parameter k associated with the input. The main goal is to confine the combinatorial explosion in the running time of an algorithm for an NP-hard problem to depend only on k. Thus, a parameterized problem is defined formally as a language L ⊆ Σ∗ × N, where Σ∗ is a set of string over a finite alphabet Σ. A parameterized problem is said to be fixed parameter tractable (or FPT) if it can be solved in time f(k) · nO(1) for some computable function f. Also, we say that a parameterized problem belongs in the class XP if it can be solved in time O(nf(k)) for some computable function f. The complexity class FPT consists of all fixed parameter tractable problems. Parameterized complexity theory also provides tools to disprove the existence of FPT algorithms under plausible complexity-theoretic assumptions. For this, Downey and Fellows introduced a hierarchy of parameterized com- plexity classes, namely FPT ⊆ W[1] ⊆ W[2] ⊆ W[3] ⊆ ··· ⊆ XP and conjectured that it is proper. This conjecture plays a central role in obtaining lower complexity bounds. The basic way to show that it is unlikely that a parameterized problem admit an FPT algorithm is to show that it is W[1] or W[2]-hard using a parameterized reduction form a known W[1] or W[2]-hard problem. A kernelization for a parameterized problem is a polynomial time algorithm that maps each instance (I, k) of a parameterized problem with the input I and parameter k to an instance (I0, k0) of the same problem such that (i) (I, k) is a yes-instance if and only if (I0, k0) is a yes-instance, and (ii) I0 + k0 is bounded by f(k) for some computable function f. The output (I0, k0) is called a kernel. The function f is said to be the size of the kernel. A kernel is polynomial if f is polynomial. While it can be shown that every decidable parameterized problem is FPT if and only if it admits a kernel, it is unlikely that every problem in FPT has a polynomial kernel. In particular, the now standard composition and cross-composition techniques [2,3] allow to show that certain problems have no polynomial kernels unless NP ⊆ coNP/poly. To solve all considered problems, we have to solve the Model Checking problem for first-order logic on graphs: Model Checking Input: A graph G and an FOL-formula φ. Question: Does G = φ? Model Checking is known to be PSPACE-complete [19]. The problem is also hard from the parameterized complexity viewpoint when parameterized by the size of the for- mula. It was proved by Frick and Grohe in [10] that the problem is AW[∗]-complete for this parametrization (see, e.g., the book [9] for the definition of the class). Thus, it is 5 unlikely that Model Checking is FPT when parameterized by the formula size. This immediately implies that the problem Vertex-Removal to φ as well as the problems Edge-Removal/Completion/Editing to φ are AW[∗]-hard when parameterized by the size of φ even for k = 0. However, Model Checking is in XP when parameterized by the number of variables. In particular, if φ has r variables and input size is n, then it can be solved in time O(nr) by exhaustive search. The currently best algorithm is given by Williams in [20] who proved the following. Theorem 5 ([20]). Model Checking can be solved in time O(nω) for formulas with 3 variables and if the number of variables r › 3, then it can be solved in time O(nr−3+ω) where ω is the matrix-multiplication exponent. Moreover, if r › 9, then Model Checking can be solved in time nr−1+o(1). Here O(f(n)) is used to denote an upper bound O(f(n) logc n) for some positive con- stant c. These algorithms are, in fact, asymptotically optimal up to the Strong Exponential Time Hypothesis (SETH) (see [6, 14] for the definition). It was shown by Williams [20] that if Model Checking for formulas with r › 4 can be solved in time O(nr−1−ε) for some ε > 0, then SETH is false. Because of these results, we assume throughout the paper that the FOL-formulas in the considered modification problems have a constant number of variables and, therefore, constant sizes. In particular, the exponents of polynomials in running times and the sizes of kernels should depend on the length φ of the formula φ. We conclude this section by observing that Theorems 3 and 4 claim the same complex- ity status for Edge-Removal to φ and Edge-Completion to φ. This is not surprising, because these problems are equivalent in the following sense. Denote by G the complement of a graph G, that is, the graph with the same vertex set such that every two distinct ver- tices are adjacent in G if and only if they are nonadjacent in G. For an FOL-formula φ, denote by φ the formula obtained from φ by replacing each adjacency predicate by the subformula expressing non-adjacency of distinct vertices, that is, u ∼ v is replaced by ¬(u = v) ∧ ¬(u ∼ v). Then we can make the following straightforward observation. Observation 1. For every FOL-formula φ, (G, k) is a yes-instance of Edge-Removal to φ if and only if (G, k) is a a yes-instance of Edge-Completion to φ. By Observation 1, it is sufficient to show Theorems 3 and 4 for Edge-Removal to φ and Edge-Editing to φ. 3 Upper bounds In this section we prove the claims (i) of Theorems 1 -- 4. First, we consider Vertex- Removal to φ. Lemma 1. For every φ ∈ Σ3 without free variables, Vertex-Removal to φ can be solved in time φk · nO(φ). Proof. Consider an instance (G, k) of Vertex-Removal to φ for φ = ∃x1 ···∃xr∀y1 ···∀ys∃z1 ···∃ztχ, where r, s, t › 0 and χ is quantifier-free. Let x = hx1, . . . , xri, y = hy1, . . . , ysi, and z = hz1, . . . , zti. 6 Assume that (G, k) is a yes-instance of Vertex-Removal to φ. This means that there is S ⊆ V (G) of size at most k such that G − S = φ. Observe that G − S = φ if and only if there is an r-tuple u = hu1, . . . , uri of vertices of G− S such that (G− S, u) = φ[x]. We use this observation, and for each r-tuple u of vertices of G, check whether there is S ⊆ V (G) of size at most k that has no common vertices with u and it holds that (G − S, u) = φ[x]. If we find such a set S, we return this solution for the considered instance of Vertex-Removal to φ. Otherwise, if we fail to find S for all r-tuples u, we conclude that (G, k) is a no-instance. From now we assume that u is given. Suppose that (G, u) = φ[x] does not hold. Then there is an s-tuple v = hv1, . . . , vsi of vertices of G such that (G, uv) = φ[xy] does not hold. Our algorithm is based on the following crucial claim. Claim 1.1. For every S ⊆ V (G) such that S is disjoint with u and (G − S, u) = φ[x], S contains at least one vertex of v. The proof is by contradiction. Assume that (G− S, u) = φ[x] but S and v are disjoint. Then (G − S, uv) = φ[xy]. By definition, this means that there is a t-tuple of vertices w of G − S such that (G − S, uvw) = φ[xyz]. In other words, χ evaluates to true if the x, y and z-variables are assigned to u, v and w respectively. This immediately implies that (G, uvw) = φ[xyz] and, therefore, (G, uv) = φ[xy]. This contradicts the assumption that (G, uv) 6= φ[xy]. Claim 1.1 leads to the following recursive algorithm that find a solution S for the given u (if such a solution exist). The algorithm receives as the input the current set S that is initially set to be empty and finds a solution S∗ ⊇ S as follows. 1. If (G − S, uv) = φ[xy] for all s-tuples v = hv1, . . . , vsi of vertices of G − S, then return S and stop. 2. Otherwise, for an s-tuple v = hv1, . . . , vsi of vertices of G − S such that (G − S, uv) 6= φ[xy], do the following: (i) if S = k or all the vertices of v are in u, then stop; (ii) else, for each vi ∈ v that is not in u, call the algorithm for S0 = S ∪ {vi}. The correctness of the algorithm follows from Claim 1.1. Concerning the running time of the algorithm. At each iteration we check at most ns s-tuples v and for each v we verify in time nO(φ) whether (G− S, uv) = φ[xv]. Hence, each iteration takes time nO(φ). Also at each iteration we branch into at most s subproblems and the depth of the search tree produced by the algorithm is at most k. Thus the running time is sk · nO(φ). Recall that we call the algorithm for each r-tuple u. Since there are nr such tuples, we have that the total running time is sk · nO(φ), which can be rewritten as φk · nO(φ). Lemma 1 immediately implies Theorem 1 (i). We move to Edge-Removal to φ and Edge-Editing to φ. Lemma 2. For every φ ∈ Σ2 without free variables, Edge-Removal to φ and Edge- Editing to φ can be solved in time φ2k · nO(φ). Proof. The proof is similar to the proof of Lemma 1. We show the claim for Edge- Removal to φ and then explain how it should be modified for Edge-editing to φ. Let (G, k) be an instance of Edge-Removal to φ for φ = ∃x1 ···∃xr∀y1 ···∀ysχ, 7 where χ is quantifier-free. Let x = hx1, . . . , xri and y = hy1, . . . , ysi. We observe that F ⊆ E(G) of size at most k is a solution for an instance (G, k) of Edge-Removal to φ if and only if there is an r-tuple u = hu1, . . . , uri of vertices of G such that (G − F, u) = φ[x]. Respectively, for each r-tuple u of vertices of G, we check whether there is F ⊆ E(G) of size at most k such that (G − F, u) = φ[x]. If we find such F , we return this solution and we obtain that (G, k) is a no-instance otherwise. Assume that u is given. If the property (G, u) = φ[x] is not fulfilled, then there is an s-tuple v = hv1, . . . , vsi of vertices of G such that it does not hold that (G, uv) = φ[xy]. We use the following claim. Claim 2.1. For every F ⊆ E(G) such that (G − F, u) = φ[x], F contains at least one edge with both end-vertices in uv. To obtain a contradiction, assume that (G − F, u) = φ[x] but every edge of F has at least one end-vertex outside the tuples u and v. This means that χ evaluates to true on G − F if the x any y-variables are assigned to u and v respectively. Notice that every two vertices of uv are adjacent in G − F if and only if they are adjacent in G. Hence, χ evaluates to true on G if the x any y-variables are assigned to u and v respectively. This means that (G, uv) = φ[xy]; a contradiction. We construct the following recursive branching algorithm that finds a solution F for the given u if it exists. The algorithm takes as the input the current set F that is initially empty and finds a solution F ∗ ⊇ F : 1. If (G− F, uv) = φ[xy] for all s-tuples v = hv1, . . . , vsi of vertices of G, then return F and stop. 2. Otherwise, for an s-tuple v = hv1, . . . , vsi of vertices of G such that (G− F, uv) 6= φ[xy], do the following: (i) set L ⊆ E(G) be the set of edges with both end-vertices in uv, (ii) if F = k or L = ∅, then stop; (iii) else, and for each e ∈ L, call the algorithm for F 0 = F ∪ {e}. L ‹(cid:0)r+s 2 (cid:1) branches and the depth of the search tree produced by the algorithm is at most The correctness of the algorithm follows from Claim 2.1. On each iteration we check at most ns s-tuples v, and for each v, verify in time nO(φ) whether (G − F, uv) = φ[xv]. Hence, each iteration can be done in time nO(φ). Also on each iteration we have at most k. This implies that the running time is (r + s)2k · nO(φ). Recall that we call the algorithm for each r-tuple u. Since there are nr such tuples, we have that the total running time is φ2k · nO(φ). For Edge-Editing to φ, the algorithm is essentially the same. The difference is that in addition to edge removal we allowed to add edges. Respectively, we replace G − F by G 4 F in the above algorithm and modify Steps 2 (i) -- (iii): (i) set L be the set of pairs of distinct vertices of uv, (ii) if F = k or L = ∅, then stop; (iii) else, and for each e ∈ L, call the algorithm for F 0 = F ∪ {e}. Notice that the variant of Claim 2.1 , where G − F is replaces by G 4 F , holds and this implies correctness. The time analysis is the same. 8 Lemma 2 together with Observation 1 implies Theorem 3(i). Our next aim is show kernelization upper bounds. First, we observe that for Σ1-formulas, our problems can be solved in polynomial time. Lemma 3. For every φ ∈ Σ1 without free variables, Vertex-Removal to φ, Edge- Removal to φ, and Edge-Editing to φ can be solved in time nO(φ). Proof. Assume that φ = ∃x1 ···∃xrχ where χ is quantifier-free. For Vertex-Removal to φ, it is sufficient to observe that (G, k) is a yes-instance of the problem if and only if G = φ. We can use Theorem 5 and solve the problem in time nOφ. For Edge-Removal to φ and Edge-Editing to φ, we can observe that (G, k) is a yes-instance if and only if there is a set of vertices U of size s = min{r, n} such that (G[U], k) is a yes-instance. We can check all such sets U in time nO(φ), and for each set, we use brute force to verify whether (G[U], k) is a yes-instance. Since the brute force checking of all subsets of edges or pairs of vertices of G[U] of size at most k0 = min{k,(cid:0)s , the total running time is s2s2 · nO(φ). Because s ‹ φ, we can write it (cid:1)} can be 2 done in time s2k0 as nO(φ). Because every problem that can be solved in polynomial time has a trivial polynomial kernel, Lemma 3 together with Observation 1 implies Theorem 4(i). Clearly, the lemma also implies the claim of Theorem 2 (i) for Σ1-formulas. It remains to prove it for Π1- formulas. For this, we need the classic result of Lewis and Yannakakis [16]. A graph property P is said to be hereditary if for each graph G satisfying P , it hold that P holds for every induced subgraph of G. A property P is nontrivial if it is true for infinitely many graphs and it is false for infinitely many graphs. Vertex-Removal to P asks, given a graph G and a positive integer k, whether it is possible to remove at most k vertices of G to obtain a graph satisfying P . It was proved by Lewis and Yannakakis [16] that the following dichotomy holds for a hereditary property P that can be tested in polynomial time: Vertex-Removal to P can be solved in polynomial time if P is trivial, and the problem is NP-complete otherwise. Lemma 4. For every φ ∈ Π1 without free variables, Vertex-Removal to φ admits a polynomial kernel. Proof. Let (G, k) be an instance of Vertex-Removal to φ for φ = ∀x1 ···∀xrχ where χ is quantifier-free. Let x = hx1, . . . , xri. Observe that the graph property G = φ is hereditary for Π1-formulas. If this property is trivial, we can solve Vertex-Removal to φ in polynomial time [16] and conclude that the problem admits a trivial polynomial kernel. Assume from now that the property G = φ is not trivial. By the result of Lewis and Yannakakis [16], Vertex-Removal to φ is NP-complete. For every tuple v of vertices of G, denote by Uv the set of vertices contained in v. Let U = {Uv v is an r-tuple of vertices of G such that (G, v) 6= φ[x]}. The crucial observation is that S ⊆ V (G) of size at most k is a solution for (G, k) if and only if S is a hitting set for U, that is, S ∩ Uv 6= ∅ for every Uv ∈ U. This observation is proved by the same arguments as Claim 1.1 assuming that u is empty. 9 The s-Hitting Set problem that asks, given a family of sets U of size at most s over some universe and a non-negative integer k, whether there is a hitting set S for U in known to have a polynomial kernel of size at most (2s − 1)ks−1 + k by the result of Abu-Khzam [1]. Apparently Hitting Set is in NP. Hence, there is a polynomial reduction from Hitting Set to the NP-complete problem Vertex-Removal to φ. This implies that Vertex-Removal to φ admits a polynomial kernel. 4 Lower bounds Here we prove the hardness claims of Theorems 1 -- 4. In Subsection 4.1, we give the tech- nical result about reducing Edge-Removal to φ to Vertex-Removal to ψ. In Sub- section 4.2, we show W[2]-hardness and in Subsection 4.3 we obtain kernelization lower bounds. 4.1 Reducing Edge Removal to Vertex Removal In this section we construct a generic reduction of Edge-Removal to φ to Vertex- Removal to ψ that we use twice in the proofs of our complexity lower bounds. We say that an FOL-formula φ is ∀-containing if the prefix of φ contains a ∀ quantifier. Lemma 5. For every ∀-containing FOL-formula φ ∈ Σs ∪ Πs without free variables for s › 1, there is formula ψ ∈ Σs+1 ∪ Πs+1 without free variables such that (i) ψ = poly(φ), (ii) if φ ∈ Σs (resp. φ ∈ Πs), then φ ∈ Σs+1 (resp. φ ∈ Πs+1), (iii) there is a polynomial reduction of Edge-Removal to φ to Vertex-Removal to ψ that transforms each instance (G, k) of Edge-Removal to φ to an equiv- alent instance (G0, k) of Vertex-Removal to ψ, i.e., the parameter k remains the same. Proof. Let (G, k) be an instance of Edge-Removal to φ. We construct the instance (G0, k) of Vertex-Removal to ψ from (G, k) and then we construct ψ. The main idea is to replace edge removals by vertex removals switching to the incidence graph of G or, equivalently, by subdividing edges of G. Then we have to "label" the vertices of the original graph that should not be removed. We do it by making them adjacent to sufficiently many pendant vertices. Formally, we construct G0 as follows. • Construct a copy of G and subdivide each edge, that is, for each e = xy ∈ E(G), delete e, construct a new vertex ve and make it adjacent to x and y. We say that the vertices of G are branching vertices and the vertices obtained by the edge subdivisions are called subdivision vertices. • For each branching vertex u, introduce k + 3 new vertices v1, . . . , vk+3 and make them adjacent to u; we call these vertices pendant. Notice that every subdivision vertex has degree 2 and every branching vertex has degree at least 3. Moreover, if H is obtained from G0 by the removal of at most k vertices, then still every remaining branching vertex has degree at least 3. Observe also that H has isolated vertices if and only if at least one branching vertex of G is removed in the construction of H. 10 Our next aim is to construct ψ from φ to ensure that (G, k) is a yes-instance of Edge- Removal to φ if and only if (G0, k) is a yes-instance of Vertex-Removal to ψ. Let φ = Q1x1 . . . Qpxpχ where Q1, . . . , Qp are quantifiers, x1, . . . , xp are variables and χ is quantifier-free. We also assume that χ is written in the conjunctive normal form. The construction of ψ is done in several steps. First, we take care of adjacencies in φ. Recall that two verices u and v are adjacent in G if and only if they have a common neighbor in G0. Respectively, we modify the adjacency predicates in χ. Let Π = {π1, . . . , πs} be the family (multiset) of all predicates of the form xi ∼ xj that occur in χ without negations. If the same predicate xi ∼ xj occurs several times, then for each occurrence, we include it in Π. Similarly, let ¯Π = {¯π1, . . . , ¯πt} be the family (multiset) of all predicates of the form ¬(xi ∼ xj) that occur in χ. Then we do the following. • Construct s new variables y1, . . . , ys and t variables z1, . . . , zt. • For each h ∈ {1, . . . , s}, consider πh = xi ∼ xj for some i, j ∈ {1, . . . , p} and replace it by ¬(xi = xj) ∧ (xi ∼ yh) ∧ (yh ∼ xj). • For each h ∈ {1, . . . , t}, consider ¯πh = ¬(xi ∼ xj) for some i, j ∈ {1, . . . , p} and replace it by (xi = xj) ∨ ¬(xi ∼ yh) ∨ ¬(yh ∼ xj). • Denote the formula obtained from χ by χ0. Then -- if Qp = ∃, set σ = ∃y1 . . .∃ys∀z1 . . .∀zt χ0, and -- if Qp = ∀, set σ = ∀z1 . . .∀zt∃y1 . . .∃ys χ0. Consider the formula α = Q1x1 . . . Qpxp σ. Observe that we added new quantified variables in the end of the prefix of φ in such a way that we obtain at most one additional alternation of quantifiers. That is, we obtain that α ∈ Σs+1 if φ ∈ Σs and α ∈ Πs+1 if φ ∈ Πs. The crucial property of the above construction is given in the following straightforward claim. Claim 5.1. G = φ if and only if G0 = β where β = Q1x1 . . . Qpxp σ with the domains of the variables x1, . . . , xp restricted to V (G). Moreover, for every set of pendant vertices X of size at most k, G = φ if and only if (G0 − X) = β. Notice that in the formula of Claim 5.1 we insist to restrict the domains of the variables x1, . . . , xp in β to V (G), that is, β is not an FOL-formula (and β 6= α). Our next aim is to express these additional constraints in the first-order logic. We do it using the property that the branching vertices of G0 have degrees at least 3 and all the other vertices have degrees at most 2. We consecutively construct the formulas ρn+1, . . . , ρ1. First, we set ρn+1 = σ. Note that x1, . . . , xp are free variable for ρn+1. Assume inductively that 1 ‹ i ‹ p and ρi+1 with free variables x1, . . . , xi is already constructed. Denote by Pi+1 the prefix and µi+1 the quantifier-free part of ρi+1 respectively, that is, ρi+1 = Pi+1µi+1. The construction of ρi depends on the quantifier Qi. • Introduce 3 new variables r1 i , r2 i , r3 i . 11 • If Qi = ∃, then set ρi = ∃xi∃r1 i ∃r2 i ∃r3 i Pi+1[(¬(r1 i = r2 ((xi ∼ r1 i ) ∧ ¬(r1 i ) ∧ (xi ∼ r2 i ) ∧ ¬(r2 i = r3 i ) ∧ (xi ∼ r3 i ))∧ i = r3 i )) ∧ µi+1]. • If Qi = ∀, then set ρi = ∀xi∀r1 i ∀r2 i ∀r3 i Pi+1[((¬(r1 (cid:0)((xi ∼ r1 i = r2 i ) ∧ ¬(r1 i ) ∧ (xi ∼ r2 i ) ∧ ¬(r2 i = r3 i ) ∧ (xi ∼ r3 i ))∧ i = r3 i )) → µi+1 (cid:1)]. Let γ = ρ1. Note that in our construction of γ, we do not create new alternations of quantifications, that is, γ ∈ Σs+1 or in Πs+1 depending on whether α ∈ Σs+1 or in Πs+1. The construction of γ implies the next claim. Claim 5.2. G = φ if and only if G0 = γ. Moreover, for every set of pendant vertices X of size at most k, G = φ if and only if (G0 − X) = γ. Recall that the removal of the edges in G corresponds to the removal of subdivision vertices of G0. Respectively, our next aim is to ensure that the removal of a branching vertex of G0 leads to the graph for which our formula is false. We use the property that for every set S of at most k vertices of G0, G0 − S has an isolated vertex if and only if S contains a branching vertex. We use the property that the condition that a graph has no an isolated can be expressed by the formula ∀s1∃s2 (s1 ∼ s2) and modify γ as follows. Let P be the prefix of γ and let µ be the quantifier-free part. We write P as the concatenation of 3 parts P1, P2 and P3 where P1 and/or P3 may be empty. Recall that the prefix of the original formula φ contains the ∀xi for some i ∈ {1, . . . , p} by the condition of the lemma. Hence, the same holds for γ. Let P1 be the first part of P until the first occurrence of the quantifier ∀. Then P2 is the next part until the first occurrence of the quantifier ∃ or until the end of P if such a quantifier does not exist. Respectively, P3 is the remaining part. We define ψ = P1∀s1P2∃s2P3 [(s1 ∼ s2) ∧ µ] using two new variables s1 and s2. Notice that the insertion of the new quantifications is done in such a way that we do not introduce new alternations of quantifiers unless P3 is empty. But if P3 is empty, then φ ∈ Π1 or φ ∈ Σ2 and the new alternations were not introduced in the construction of α from φ. We have that either φ, γ ∈ Σs and ψ ∈ Σs+1 or φ, γ ∈ Πs and ψ ∈ Πs+1. We show the following claim. Claim 5.3. The instance (G, k) is a yes-instance of Edge-Removal to φ if and only if (G0, k) is a yes-instance of Vertex-Removal to ψ. To show the claim, assume first that (G, k) is a yes-instance of Edge-Removal to φ. Then there is F ⊆ E(G) of size at most k such that (G − F ) = φ. We define S ⊆ V (G0) be the the set of the subdivision vertices of G0 corresponding to the edges of F , that is, S = {ve e ∈ F}. Clearly, S ‹ k. Notice that our reduction algorithm for graphs produces G0 − S from G − F . Hence, by Claim 5.2, (G0 − F ) = γ. Because G0 − S has no isolated vertices, we have that (G0 − S) = ψ. It means that (G0, k) is a yes-instance of Vertex-Removal to ψ. Suppose now that (G0, k) is a yes-instance of Vertex-Removal to ψ. Then there is S ⊆ V (G0) of size at most k such that (G0−S) = ψ. Since ψ = P1∀s1P2∃s2P3 [(s1 ∼ s2)∧µ], we have that G0 − S has no isolated vertices, that is, S contains only subdivision vertices 12 of G0 or pendants vertices. Also this immediately implies that (G0 − S) = γ. Let S0 be the set of subdivision vertices of S and let X be the set of pendant vertices in S. We define F to be the set of edges of G corresponding to the subdivision vertices in S0, that is, F = {e ∈ E(G) ve ∈ S0}. We have that F ‹ k. Let also X be the set of pendant vertices in S. Observe again that our reduction algorithm for graphs produces G0 − S0 from G − F . Then by Claim 5.2, we have that (G − F ) = φ. We conclude that (G, k) is a yes-instance of Edge-Removal to φ. To complete the proof of the lemma, observe that the size of ψ is polynomial in the size of φ by our construction of the formula and this shows (i). To show (ii), observe that ψ ∈ Σs+1 if φ ∈ Σs and ψ ∈ Πs+1 if φ ∈ Πs. The last claim (iii) of the lemma immediately follows from Claim 5.3. 4.2 W[2]-hardness In this subsection we show that there are formulas φ in Π2 and Π3 for which Edge- Removal (Editing) to φ and Vertex-Removal to ψ. respectively are W[2]-hard when parameterized by k. First, we show the claim for Edge-Removal to φ and Edge- Editing to φ. Lemma 6. There is an FOL-formula φ ∈ Π2 without free variables with 5 variables such that Edge-Removal to φ and Edge-Editing to φ are W[2]-hard. Proof. We define the formula φ as follows: φ = ∀x∃y1∃y2∃y3∃y4[(x ∼ y1) ∧ (x ∼ y2) ∧ (x ∼ y3) ∧ (x ∼ y4) ∧ (y1 ∼ y2) ∧ (y1 ∼ y3)∧ (y2 ∼ y3) ∧ (y2 ∼ y4) ∧ (y3 ∼ y4) ∧ ¬(y1 = y4) ∧ ¬(y1 ∼ y4)]. In terms of graphs, G = φ means that for every vertex x of G, there are vertices y1, y2, y3, y4 such that these vertices together with x induce the graph W shown in Fig. 1. We say that W is a φ-witness subgraph rooted in x. y1 y2 y3 y4 x Figure 1: The φ-witness graph W . We show hardness for Edge-Editing to φ by reducing the Set Cover problem: Set Cover Parameter: k Input: A family of sets S over the universe U and a positive integer k. Question: Is there a subfamily S∗ ⊆ S of size at most k that covers U, that is, every element of U is in one of the set of S∗? It is well-known that Set Cover is W[2]-hard when parameterized by k [7]. Let (U,S, k) be an instance Set Cover, S = {S1, . . . , Sm} and U = {u1, . . . , un}. We construct the graph G as follows. • For each i ∈ {1, . . . , m}, construct the graph Hi with 4 root vertices s1 i , s2 i , s3 as it is shown in Fig. 2 a). i , s4 i 13 y4 y3 y2 x y1 y1 y2 x y4 y3 s3 i s2 i s4 i s1 i Hi a) b) Figure 2: Construction of Hi and the witness subgraphs for the vertices of Hi. The witness subgraphs are shown by thick lines and the other edges are shown by dashed lines. • For each j ∈ {1, . . . , n}, construct 2k + 1 vertices u0 and make them adjacent to the root vertices of all the gadgets Hr such that the element uj of the universe U is in the set Sr ∈ S. j , . . . , u2k j j , s1 i , s2 i , s3 i=1 V (Hi), such subgraphs are shown in Fig. 2 b). Let x = uh We claim that (U,S, k) is a yes-instance Set Cover if and only if (G, k) is a yes- instance of Edge-Editing to φ. Suppose that (U,S, k) is a yes-instance Set Cover. Let S∗ ⊆ S be a family of size at most k that covers U. We construct the set of edges F of G as follows. For every Si ∈ S∗, i of the gadget Hi in F . Clearly, F ‹ k. Let G0 = G4 F = G− F . we include the edge s1 i s4 We show that G0 = φ. Recall that we have to show that for every x ∈ V (G0), there x ∈Sm are y1, y2, y3, y4, such that G[{x, y1, y2, y3, y3}] is a φ-witness subgraph rooted in x. For j for j ∈ {1, . . . , n} and h ∈ {0, . . . , 2k}. The element uj ∈ U is covered by some set Si ∈ S∗. Since s1 i ∈ F , we i s4 i ] is a φ-witness subgraph rooted in x. We conclude that G0 = φ Assume that (G, k) is a yes-instance of Edge-Editing to φ. Then there is F ⊆(cid:0)V (G) (cid:1) have that G[uh and, therefore, (G, k) is a yes-instance of Edge-Editing to φ. Q = (V (G), F ). For i ∈ {1, . . . , m}, let δi = P with F ‹ k such that for G0 = G4 F , it holds that G0 = φ. Consider the auxiliary graph i ‹ m, δi › 2}. Because F ‹ k, Pn v∈V (Hi) dQ(v). We define S∗ = {Si 1 ‹ i=1 δi ‹ 2k and, therefore, S∗ ‹ k. We claim that S∗ covers U. To obtain a contradiction, assume that there is j ∈ {1, . . . , n} such that uj is not covered by S∗. Since F ‹ k, there is h ∈ {0, . . . , 2k} such that the vertex uh is not incident to the pairs of F . Because G0 = φ, there is a φ-witness subgraph rooted j . Hence, there are y1, y2, y3, y4 ∈ V (G) such that G[{x, y1, y2, y3, y4}] is a φ- in x = uh witness subgraph. Notice that y1, y2, y3, y4 ∈ ∪m i=1V (Hi). Observe that if ys ∈ V (Hi), then for some i ∈ {1, . . . , m}, because it would mean that {y1, y2, y3, y4} = {s1 i} but i}] = K4, a contradiction. Therefore, there are distinct i, i0 ∈ {1, . . . , n} G0[{s1 such that V (Hi) ∩ {y1, y2, y3, y4} 6= ∅ and V (Hi0) ∩ {y1, y2, y3, y4} 6= ∅. Since δi, δi0 ‹ 1, there is a unique pair ab of F such that a ∈ V (Hi) and b ∈ V (Hi0). Moreover, ab is a bridge of G0[∪m s=1V (Hs)] and, therefore, ab is a bridge of G0[{y1, y2, y3, y4}]. This contradicts the fact that W − x is 2-connected. We conclude that S∗ covers U. Hence, (U,S, k) is a (cid:1) = ∅, because δi ‹ 1. Hence, it cannot happen that y1, y2, y3, y4 ∈ V (Hi) F ∩(cid:0)V (Hi) i , s3 i , s2 i , s3 i , s4 i , s2 i , s4 2 j i , s4 2 14 yes-instance Set Cover. This concludes the W[2]-hardness proof for Edge-Editing to φ. To show that Edge- Removal to φ is W[2]-hard when parameterized by k, we use the same reduction. Note that to show that if (U,S, k) is a yes-instance of Set Cover then (G, k) is a yes-instance of Edge-Editing to φ, we constructed F ⊆ E(G), that is, we proved that (G, k) is a yes-instance of Edge-Removal to φ. Lemma 6 and Observation 1 imply Theorem 3 (ii). To show the claim for Vertex- Removal to φ we combain Lemma 6 with Lemma 5 and obtain the following lemma that implies Theorem 1 (ii). Lemma 7. There is a constant c such that there is an FOL-formula φ ∈ Π3 without free variables that has at most c variables such that Vertex-Removal to φ is W[2]-hard. (cid:1) respectively) of size at most k such that 2 4.3 Kernelization lower bounds In this subsection we obtain the kernelization lower bounds for Edge-Removal (Edit- ing) to φ and Vertex-Removal to ψ. whether there is a set of edges F (a set F ⊆(cid:0)V (G) First, we show the lower bounds for Edge-Removal to φ and Edge-Editing to φ for Π1-formulas. To do it, we use the known results about kernelization lower bounds for the H-Free Edge Removal and H-Free Editing. Recall that for a graph H, H-Free Edge Removal (H-Free Editing) asks, given a graph G and a nonnegative integer k, G− F (G4 F respectively) does not contain an induced subgraph isomorphic to H. Since the property that a graph G has no induced subgraph isomorphic to H can be expressed by an FOL-formula φH ∈ Π1 that has V (H) variables, H-Free Edge Removal and H-Free Editing can be written as Edge-Removal to φH and Edge-Editing to φH respectively. The first kernelization lower bounds for H-Free Edge Removal and H-Free Editing were obtained by Kratsch and Wahlstrom in [15] who proved that there are graphs H for which these problems do not admit polynomial kernels unless NP ⊆ coNP/poly. Some further results were obtained by Guillemot et al. [13]. In [5] Cai and Cai completely characterized the cases when the problems have no polynomial kernels if H is a path or cycle or is 3-connected graph up to the conjecture that NP 6⊆ coNP/poly. In particular, they proved that H-Free Edge Removal and H-Free Editing do not have polynomial kernels if H = C4 unless NP ⊆ coNP/poly. This immediately yields the following lemma. Lemma 8. There is an FOL-formula φ ∈ Σ1 without free variables that has 5 variables such that Edge-Removal to φ and Edge-Editing to φ have no polynomial kernels unless NP ⊆ coNP/poly. Lemma 8 and Observation 1 prove Theorem 4 (ii). Using Lemma 5, we obtain the following lemma for Vertex-Removal to φ. Lemma 9. There is a constant c such that there is an FOL-formula φ ∈ Π2 without free variables that has at most c variables such that Vertex-Removal to φ is has no polynomial kernel unless NP ⊆ coNP/poly. Our final task is to show that it is unlikely that Vertex-Removal to φ has a polyno- mial kernel for Σ2-formulas. We do it by using the cross-composition technique introduced by Bodlaender, Jansen and Kratsch [3] (see also [6] for the introduction to the technique). Here we only briefly sketch the main notions that we need to apply it. 15 Let Σ be a finite alphabet. An equivalence relation R on the set of strings Σ∗ is called a polynomial equivalence relation if the following two conditions hold: i) there is an algorithm that given two strings x, y ∈ Σ∗ decides whether x and y belong to the same equivalence class in time polynomial in x + y, ii) for any finite set S ⊆ Σ∗, the equivalence relation R partitions the elements of S into a number of classes that is polynomially bounded in the size of the largest element of S. Let L ⊆ Σ∗ be a problem, let R be a polynomial equivalence relation on Σ∗, and let P ⊆ Σ∗ × N be a parameterized problem. An OR-cross-composition of L into P (with respect to R) is an algorithm that, given t instances I1, I2, . . . , It ∈ Σ∗ of L belonging i=1 Ii and outputs an instance (I, k) ∈ Σ∗ × N such that: to the same equivalence class of R, takes time polynomial in Pt i) the parameter value k is polynomially bounded in max{I1, . . . ,It} + log t, ii) the instance (I, k) is a yes-instance of P if and only there is i ∈ {1, . . . , t} such that Ii is a yes-instance of L. It is said that L OR-cross-composes into P if a cross-composition algorithm exists for a suitable relation R. Bodlaender, Jansen and Kratsch [3] proved the following theorem. Theorem 6 ([3]). If an NP-hard problem L OR-cross-composes into the parameterized problem P, then P does not admit a polynomial kernelization unless NP ⊆ coNP/poly. Lemma 10. There is φ ∈ Σ2 without free variables that has 3 variables such that Vertex- Removal to φ has no polynomial kernel unless NP ⊆ coNP/poly. Proof. We define the formula φ as follows: φ = ∃x∀y∀z[((x ∼ y) ∧ (x ∼ z)) → ((y = z) ∨ (y ∼ z))]. In terms of graphs, G = φ means that there is a vertex x whose neighborhood is a clique. We consider the Clique problem: Clique Input: A graph G and a positive integer k. Question: Is there a clique in G with at least k vertices? We say that two instances (G1, k1) and (G2, k2) of Clique are equivalent if V (G1) = and show that Clique OR-cross-composes into Vertex-Removal to φ. V (G2) and k1 = k2. We construct the instance (G0, k0) of Vertex-Removal to φ as follows. Let (G1, k), . . . , (Gt, k) be equivalent instances of Clique where graphs have n vertices. • Construct disjoint copies of G1, . . . , Gt. • For every i ∈ {1, . . . , t}, construct n−k +2 vertices u1 and make them i , . . . , un−k+2 i adjacent to the vertices of Gi. • Set k0 = n − k. 16 We claim that (G0, k0) is a yes-instance of Vertex-Removal to φ if and only if there is i ∈ {1, . . . , t} such that (Gi, k) is a yes-instance of Clique. Suppose that there is i ∈ {1, . . . , t} such that (Gi, k) is a yes-instance of Clique. Then Gi has a clique K of size k. Let S = V (G)\ K. Note that S = n− k = k0. Now for x = u1 i , we have that the neighborhood of x in G0 is the clique K, that is, (G0, k0) is a yes-instance of Vertex-Removal to φ. Assume that (G0, k0) is a yes-instance of Vertex-Removal to φ. Then there is a set of vertices S ⊆ V (G0) of size at most k0 such that (G0 − S) = φ. Let G00 = G0 − S. We have that there is x ∈ V (G00) such that the neighborhood of x in G00 is a clique. Then there is i ∈ {1, . . . , t} such that x ∈ V (Gi) or x ∈ {u1 }. Suppose that x ∈ V (Gi). Since i , . . . , un−k+2 S ‹ k0 = n − k, x is adjacent in G00 to at least two distinct vertices of {u1 } but these two verices are not adjacent. It implies that x ∈ {u1 } and the neighborhood of x in G00 is V (Gi)\ S, that is, K = V (Gi)− S is a clique. Because S ‹ k0, we have that K › n − k0 = k, that is, (Gi, k) is a yes-instance of Clique. Since V (G0) = O(nt) and k0 = O(n), we conclude that Vertex-Removal to φ has no polynomial kernel unless NP ⊆ coNP/poly by Theorem 6. i , . . . , un−k+2 i i , . . . , un−k+2 i i We have that Lemmata 9 and 10 imply Theorem 2 (ii). 5 Conclusion In this paper we have provided necessary and sufficient conditions (subject to some com- plexity assumptions) on the fixed-parameter tractability, as well as polynomial kerneliza- tion, of graph modification problems to the properties expressible by an FOL-formula from a certain prefix class. While we stated our results for undirected graphs, in fact, all our results could be rewritten for directed graphs. In particular, the FPT and kernelization algorithms work for directed graphs without any changes. For the hardness proofs, we need only a minor modification. Denote by arc(x, y) the predicate for variables x and y meaning that (x, y) is an arc of a directed graph. Denote by ~φ the FOL-formula on directed graphs obtained from an FOL-formula φ on undirected graphs by replacing every predicate x ∼ y with arc(x, y) ∨ arc(y, x). Then we have the following observation. Observation 2. Let G be the underlaying undirected graph of a directed graph D and let φ be an FOL-formula on undirected graphs without free variables. Then G = φ if and only if D = ~φ. Observation 2 immediately implies that whenever Vertex Removal to φ or Edge Removal/Completion/Editing to φ is hard (W[2]-hard or does not have a polynomial kernel unless NP ⊆ coNP/poly), the same holds for the variant of the problem on directed graphs. The straightforward reduction constructs a directed graph from an undirected graph G by turning its edges to arcs by assigning arbitrary orientations. Our results are for FOL-formulas. It would be very interesting to obtain a similar type of dichotomies for prefix classes of Monadic Second Order Logic (MSOL) formulas on graphs. MSOL is substantially richer and allows to express more interesting graph properties like connectivity that cannot be expressed in FOL. The crucial difference is that while Model Checking for FOL-formulas can be solved in polynomial time for formulas of bounded size (see Theorem 5), the problem for MSOL is well-known to be NP-complete even for formulas whose size is bounded by a constant. Acknowledgments. We are grateful to Pal Drange for his very helpful remarks. 17 References [1] F. N. Abu-Khzam, A kernelization algorithm for d-hitting set, Journal of Computer and System Sciences, 76 (2010), pp. 524 -- 531. [2] H. L. Bodlaender, R. G. Downey, M. R. Fellows, and D. Hermelin, On problems without polynomial kernels, J. Comput. Syst. Sci., 75 (2009), pp. 423 -- 434. [3] H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch, Kernelization lower bounds by cross-composition, SIAM J. Discrete Math., 28 (2014), pp. 277 -- 305. [4] E. Borger, E. Gradel, and Y. Gurevich, The classical decision problem, Springer Science & Business Media, 2001. [5] L. Cai and Y. Cai, Incompressibility of H-free edge modification problems, Algo- rithmica, 71 (2015), pp. 731 -- 757. [6] M. Cygan, F. V. Fomin, L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, and S. Saurabh, Parameterized Algorithms, Springer, 2015. [7] R. G. Downey and M. R. Fellows, Fundamentals of Parameterized Complexity, Texts in Computer Science, Springer, 2013. [8] R. Fagin, Generalized first-order spectra and polynomial-time recognizable sets, in Complexity of Computation, vol. 7, AMS, 1974, pp. 43 -- 74. [9] J. Flum and M. Grohe, Parameterized Complexity Theory, Texts in Theoretical Computer Science. An EATCS Series, Springer, 2006. [10] M. Frick and M. Grohe, The complexity of first-order and monadic second-order logic revisited, Ann. Pure Appl. Logic, 130 (2004), pp. 3 -- 31. [11] G. Gottlob, P. G. Kolaitis, and T. Schwentick, Existential second-order logic over graphs: Charting the tractability frontier, J. ACM, 51 (2004), pp. 312 -- 362. [12] M. Grohe, Descriptive complexity, canonisation, and definable graph structure the- ory, vol. 47, Cambridge University Press, 2017. [13] S. Guillemot, F. Havet, C. Paul, and A. Perez, On the (non-)existence of polynomial kernels for P'-free edge modification problems, Algorithmica, 65 (2013), pp. 900 -- 926. [14] R. Impagliazzo, R. Paturi, and F. Zane, Which problems have strongly exponen- tial complexity?, J. Comput. Syst. Sci., 63 (2001), pp. 512 -- 530. [15] S. Kratsch and M. Wahlstrom, Two edge modification problems without polyno- mial kernels, Discrete Optimization, 10 (2013), pp. 193 -- 199. [16] J. M. Lewis and M. Yannakakis, The node-deletion problem for hereditary prop- erties is NP-complete, J. Comput. Syst. Sci., 20 (1980), pp. 219 -- 230. [17] R. Niedermeier, Invitation to fixed-parameter algorithms, vol. 31 of Oxford Lecture Series in Mathematics and its Applications, Oxford University Press, 2006. 18 [18] C. Smorynski, The incompleteness theorems, in Handbook of mathematical logic, vol. 90 of Stud. Logic Found. Math., North-Holland, Amsterdam, 1977, pp. 821 -- 865. [19] M. Y. Vardi, The complexity of relational query languages (extended abstract), in Proceedings of the 14th Annual ACM Symposium on Theory of Computing, May 5-7, 1982, San Francisco, California, USA, ACM, 1982, pp. 137 -- 146. [20] R. Williams, Faster decision of first-order graph properties, in Joint Meeting of the Twenty-Third EACSL Annual Conference on Computer Science Logic (CSL) and the Twenty-Ninth Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), CSL-LICS '14, Vienna, Austria, July 14 - 18, 2014, ACM, 2014, pp. 80:1 -- 80:6. [21] M. Yannakakis, Edge-deletion problems, SIAM Journal on Computing, 10 (1981), pp. 297 -- 309. 19
1106.3037
1
1106
2011-06-15T17:48:52
Efficient algorithm for the vertex connectivity of trapezoid graphs
[ "cs.DS", "math.CO" ]
The intersection graph of a collection of trapezoids with corner points lying on two parallel lines is called a trapezoid graph. These graphs and their generalizations were applied in various fields, including modeling channel routing problems in VLSI design and identifying the optimal chain of non-overlapping fragments in bioinformatics. Using modified binary indexed tree data structure, we design an algorithm for calculating the vertex connectivity of trapezoid graph $G$ with time complexity $O (n \log n)$, where $n$ is the number of trapezoids. Furthermore, we establish sufficient and necessary condition for a trapezoid graph $G$ to be bipartite and characterize trees that can be represented as trapezoid graphs.
cs.DS
cs
Efficient algorithm for the vertex connectivity of trapezoid graphs Aleksandar Ili´c ‡ Faculty of Sciences and Mathematics, Visegradska 33, 18000 Nis, Serbia e-mail: [email protected] November 7, 2018 Abstract The intersection graph of a collection of trapezoids with corner points lying on two parallel lines is called a trapezoid graph. These graphs and their generalizations were applied in various fields, including modeling channel routing problems in VLSI design and identifying the optimal chain of non-overlapping fragments in bioinformatics. Using modified binary indexed tree data structure, we design an algorithm for calculating the vertex connectivity of trapezoid graph G with time complexity O(n log n), where n is the number of trapezoids. Furthermore, we establish sufficient and necessary condition for a trapezoid graph G to be bipartite and characterize trees that can be represented as trapezoid graphs. Keywords: trapezoid graphs; vertex connectivity; algorithms; binary indexed tree. AMS Classifications: 05C85, 68R10, 05C40. 1 Introduction A trapezoid diagram consists of two horizontal lines and a set of trapezoids with corner points lying on these two lines. A graph G = (V, E) is a trapezoid graph when a trapezoid diagram exists with trapezoid set T , such that each vertex i ∈ V corresponds to a trapezoid T [i] and an edge exists (i, j) ∈ E if and only if trapezoids T [i] and T [j] intersect within the trapezoid diagram. A trapezoid T [i] between these lines has four corner points a[i], b[i], c[i] and d[i] -- which represent the upper left, upper right, lower left and lower right corner points of trapezoid i, respectively. No two trapezoids share a common endpoint (see Figure 1). Trapezoid graphs were first investigated by Corneil and Kamula [6]. These graphs and their generalizations were applied in various fields, including modeling channel routing problems in VLSI design [8] and identifying the optimal chain of non-overlapping fragments in bioinfor- matics [1]. Given some labeled terminals on the upper and lower side of a two-sided channel, terminals with the same label will be connected in a common net. Each net can be modeled by a trapezoid that connects rightmost and leftmost terminals of that net on two horizontal lines. In the channel routing problem we want to connect all terminals of each net so that no two nets intersect. One can show [8] that two nets can be routed without intersection in the same layer if and only if their corresponding trapezoids do not intersect. Therefore, the number of colors needed to color the trapezoid graph is the number of layers needed to route the nets without intersection. Let n and m denote the number of vertices and edges of a trapezoid graph G. Ma and Spinrad [22] showed that trapezoid graphs can be recognized in O(n2) time, while Mertzios and Corneil [23] designed structural trapezoid recognition algorithm based on the vertex splitting method in 1 O(n(m + n)) time, which is easier for implementation. Trapezoid graphs are perfect, subclass of cocomparability graphs and properly contain both interval graphs and permutation graphs. If a[i] = b[i] and c[i] = d[i] then the corresponding trapezoid T [i] reduces to a straight line, and the trapezoid graph reduces to a permutation graph if the condition holds for all 1 ≤ i ≤ n. Similarly, the trapezoid graph reduces to the interval graph if a[i] = c[i] and b[i] = d[i] for all i. Figure 1: A trapezoid graph and its trapezoid representation (marked vertices represent 2 -- cut). Many common graph problems, such as minimum connected dominating sets [25], all-pair shortest paths [24], maximum weighted cliques [2], all cut vertices [13], chromatic number and clique cover [10], all hinge vertices [3] in trapezoid graphs, can be solved in polynomial time. For other related problems see [4, 7, 17, 18]. Recently, Lin and Chen [19] presented O(n2) algorithms for counting the number of vertex covers (VC), minimal VCs, minimum VCs and maximum minimal VCs in a trapezoid graph. Ili´c and Ili´c [14] improved algorithms for calculating the size and the number of minimum vertex covers (or independent sets), as well as the total number of vertex covers, and reduce the time complexity to O(n log n). Ghosh and Pal [11] presented an efficient algorithm to find the maximum matching in trapezoid graphs, which turns out to be not correct [14]. Let G = (V, E) be a simple undirected graph with V = n. A vertex cut or separating set of a connected graph G is a set of vertices whose removal disconnects G. The connectivity or vertex connectivity κ(G) (where G is not complete) is the size of a smallest vertex cut. A graph is called k -- connected or k -- vertex -- connected if its vertex connectivity is greater than or equal to k. A complete graph with n vertices, denoted by Kn, has no vertex cuts, but by convention κ(Kn) = n − 1. A connected graph is said to be separable if its vertex connectivity is one. In that case, a vertex which disconnects the graph is called a cut-vertex or an articulation point. The edge cut of G is a group of edges whose total removal disconnects the graph. The edge -- connectivity λ(G) is the size of a smallest edge cut. In the simple case in which cutting a single edge would disconnect the graph, that edge is called a bridge. Let δ(G) be minimum vertex degree of G, then κ(G) ≤ λ(G) ≤ δ(G). Since the strength of the network G is proportional to κ(G), graph connectivity is one of the most fundamental problem in graph theory. Even and Tarjan [9] have obtained O(κ · mn√n) time sequential algorithm for finding vertex connectivity of a general graph. The authors in 2 [21] obtained parallel algorithm for testing k -- vertex connectivity in interval graphs. Ghosh and Pal in [12] presented rather complicated algorithm with a lot of different cases to solve the vertex connectivity problem, which takes O(n2) time and O(n) space for a trapezoid graph. In this paper, we designed an algorithm with time complexity O(n log n) for calculating the vertex connectivity of a trapezoid graph. The rest of the paper is organized as follows. In Section 2 we introduce the modified binary indexed tree data structure. In Section 3 we design O(n log n) time algorithm for calculating the vertex connectivity of trapezoid graphs, improving the algorithm from [12]. In Section 4 we establish sufficient and necessary condition for a trapezoid graph G to be bipartite and characterize trees that can be represented as trapezoid graphs. We close the paper in Section 5 by proposing topics for the further research. 2 Modified binary indexed data structure The binary indexed tree (BIT) is an efficient data structure for maintaining the cumulative frequencies. We will modify this standard structure to work with minimal/maximal partial summations. Let A be an array of n elements. The modified binary indexed tree (MBIT) supports the following basic operations: (i) for given value x and index i, add x to the element A[i], 1 ≤ i ≤ n; (ii) for given interval [1, i], find the sum of values A[1], A[2], . . . , A[i], 1 ≤ i ≤ n. (iii) for given interval [1, i], find the minimum value among partial sums A[1], A[1]+A[2], A[1]+ A[2] + A[3], . . . , A[1] + A[2] + . . . + A[i], 1 ≤ i ≤ n. Naive implementation of these operations have complexities O(1), O(n) and O(n), respec- tively. We can achieve better complexity, if we speed up the second and third operation which will also affect the first operation. The main idea of the modified binary indexed tree structure is that sum of elements from the segment [1, i] can be represented as sum of appropriate set of subsegments. The MBIT structure is based on decomposition of the cumulative sums into segments and the operations to access this data structure are based on the binary representation of the index. This way the time complexity for all operations will be the same O(log n). The structure is a complete binary tree with the root node 1. Its leafs correspond to the elements from the array A, starting from left to right in the last level. Therefore, the elements of the array A are stored at the positions starting from 2p to 2p + n− 1, where p is the depth of the binary tree (defined as the smallest integer such that 2p ≥ n). The internal nodes store the cumulative values of the leafs in the subtrees rooted at these nodes. This implies that the value of the internal node i is just the cumulative value of its two children. The parent of the node i is ⌊ i 2⌋, while the left and the right child of the node i are lef t[i] = 2i and right[i] = 2i + 1, respectively. By definition, it follows that the number of nodes in MBIT is at most 2n, while the depth is ⌈log2 n⌉. In addition to the values of the array A, for each node we will keep two information: sum[x] will be the sum of the A[i] values of all nodes in x's subtree, and min sum[x] will be the minimum possible cumulative sum of A[i]'s in the subtree rooted at x (starting at the leftmost node in the subtree). We will demonstrate how to compute these fields using only information at each node and its children. The sum of the A[i]'s of the subtree rooted at node x will simply be sum[x] = sum[2x] + sum[2x + 1]. 3 The minimum cumulative sum can either be in the left subtree or in the right subtree. If it is in the left subtree, it is simply min sum[lef t[x]], while if it is in the right subtree, we have to add the cumulative sum up till the right subtree to the minimum value of the right subtree sum[lef t[x]] + min sum[right[x]]. Finally, we get min sum[x] = min(min sum[2x], sum[2x] + min sum[2x + 1]). For the update procedure, we just need to traverse the vertices from the leaf to the root and update the values in the parent vertices based on the above formulas. For the query procedure, we traverse the binary tree in a top-down manner starting from the root vertex 1. The important thing it to maintain the partial sums of the array A (starting from A[1]). If the leaf that stores A[index] belongs to the left child -- we just go left and do nothing; otherwise we update the partial sum of the left subtree and the index, and go right. For detailed implementation see Algorithms 1 and 2. The structure is space-efficient in the sense that it needs the same amount of storage as just a simple array of n elements. Furthermore we can use fast bitwise operations (xor, and, shift left) for more efficient implementation. Theorem 1 Calculating the sum of the elements from A[1] to A[i], calculating the minimum value among partial sums A[1], A[1] + A[2], . . . , A[1] + A[2] + . . . + A[i], and updating the element A[i] in the modified binary indexed tree is performed in O(log n) time, 1 ≤ i ≤ n. Algorithm 1: Updating the modified binary indexed tree. Input: The value value, the element index index and the parameters n and p = min{s : 2s ≥ n}. 1 i = index + 2p − 1; 2 sum[i] = value; 3 min sum[i] = value; 4 while i > 1 do 5 if i mod 2 = 1 then 6 7 8 9 10 i = i − 1; end sum[i/2] = sum[i] + sum[i + 1]; min sum[i/2] = min(min sum[i], sum[i] + min sum[i + 1]); i = i/2; 11 end This approach is very similar to the problem regarding calculating the point of maximum overlap among intervals (see [5] Problem 14-1), that can be solved using red-black trees. Example 2 Let n = 14 and p = 4. The elements of the array A will be stored on positions sum[16] to sum[29] and min sum[16] to min sum[29]. The node 5 will contain the following information sum[5] = sum[20] + sum[21] + sum[22] + sum[23] = A[5] + A[6] + A[7] + A[8] min sum[5] = min(A[5], A[5] + A[6], A[5] + A[6] + A[7], A[5] + A[6] + A[7] + A[8]). If we change the value A[6], we will start from the corresponding index i = 21 and change the following nodes of the modified binary index tree: 21, 10, 5, 2 and 1. If we want to calculate the minimum among partial sums with elements A[1], A[2], . . . , A[13], we calculate the following minimum min (min sum[2], sum[2] + min sum[6], sum[2] + sum[6] + min sum[28]) . 4 Algorithm 2: Calculating the minimal cumulative partial sum. Input: The index index. Output: The minimum among partial sums with elements A[1], A[2], . . . , A[index]. 1 min = ∞; 2 partial sum = 0; 3 i = 1; 4 pow = 2p−1; 5 while index > 0 do 6 if index ≥ pow then if min > partial sum + min sum[2 · i] then min = partial sum + min sum[2 · i]; end partial sum = partial sum + sum[2 · i]; i = 2 · i + 1; index = index − pow; 7 8 9 10 11 12 13 14 15 16 17 end else i = 2 · i; end pow = pow/2; 18 end 19 return min; 3 The algorithm for the vertex connectivity Let T = {1, 2, . . . , n} denote the set of trapezoids in the trapezoid graph G = (V, E). For simplicity, the trapezoid in T that corresponds to vertex i in V is called trapezoid T [i]. Without loss of generality, the points on each horizontal line of the trapezoid diagram are labeled with distinct integers between 1 and 2n. Trapezoid i lies entirely to the left of trapezoid j, denoted by i ≪ j, if b[i] < a[j] and d[i] < c[j]. It follows that ≪ is a partial order over the trapezoid set T and (T,≪) is a strictly partially ordered set. Lemma 3 [12] Two vertices T [i] and T [j] of a trapezoid graph are not adjacent iff either (i) b[i] < a[j] and d[i] < c[j] or (ii) b[j] < a[i] and d[j] < c[i]. Define a cut line as line p that passes through the intervals (x, x + 1) and (y, y + 1) on the upper and the bottom horizontal line, respectively, and does not contain the integer points x, x + 1, y, y + 1. For a such cut, let N (x, y) be the number of trapezoids that have common points with the line p. Define N (x, y) = ∞ if there are no trapezoids completely left and no trapezoids completely right of the line p. Lemma 4 Let G 6= Kn be a trapezoid graph. Then κ(G) = min 1≤x≤2n, 1≤y≤2n N (x, y). Let S be a vertex cut of the graph G with the minimum cardinality κ(G). The Proof. removal of S disconnects G, and consider the component C that contains a trapezoid with the smallest upper left corner a[i]. Let x be the maximum value among upper right corners in the component C, x = maxi∈C b[i], and let y be the maximum value among lower right corners in 5 the component C, y = maxi∈C d[i]. Since the right border of trapezoids from C form concave broken line -- the line p that passes through intervals (x, x + 1) and (y, y + 1) is one cut of a trapezoid graph. It follows that κ(G) ≥ N (x, y). The other inequality follows immediately, and this completes the proof. (cid:3) Note that in the above theorem the points x = 1 and x = 2n, as well as y = 1 and y = 2n, can be excluded from the consideration. Therefore, one can traverse all values x and y and compute the number of trapezoids that have non-empty intersection with the line p determined by the intervals (x, x + 1) and (y, y + 1). The important thing is to ensure that there are trapezoids lying entirely to the left and to the right of the line p. This can be easily done in O(n2). We will first precompute the leftmost and the rightmost trapezoids for each interval (x, x+1) from the upper line. Let lef tmost be the index of a trapezoid with b[lef tmost] ≤ x and minimal lower right corner d. Similarly let rightmost be the index of a trapezoid with a[rightmost] ≥ x+1 and maximal lower left corner c. If there are no such trapezoids, set the values of lef tmost and rightmost to −1. We need additional arrays index up and index bottom, such that index up[j] contains the index of the trapezoid with the left or right coordinate equal to j on the upper line, and similarly for the bottom line. This can be done in linear time O(n) as shown in Algorithm 3 (implementation for the rightmost array is similar and, thus, omitted). Algorithm 3: Calculating the leftmost trapezoids. Input: The trapezoids T and the array index up. Output: The array lef tmost. 1 lef tmost[1] = −1; 2 for j = 2 to 2n do i = index up[j]; 3 lef tmost[j] = lef tmost[j − 1]; if b[i] = j then 4 5 6 7 8 9 if (lef tmost[j] = −1) or (d[lef tmost[j]] > d[i]) then end lef tmost[j] = i; end 10 end 11 return lef tmost; We will traverse the coordinates on the upper line from x = 1 to x = 2n, and skip the values with lef tmost[x] = −1 or rightmost[x] = −1. For each value y between d[lef tmost[x]] and c[righmost[x]], we need to calculate the number of trapezoids N (x, y) that cut the line p. The trapezoid T [i] cuts the line p if • it contains the interval (x, x + 1); • it is left trapezoid with the lower right corner greater than y, i. e. if b[i] ≤ x and d[i] > y; • it is right trapezoid with the lower left corner less than or equal to y, i. e. if a[i] > x and c[i] ≤ y. Furthermore, we will maintain the binary array cut of length n that indicates whether the trapezoid T [i] contains the interval (x, x + 1). In other words, cut[i] = true if and only if a[i] ≤ x < x + 1 ≤ b[i]. Since no two trapezoids have a common corner, we can update this array in the constant time by traversing from x to x + 1. Therefore, for each trapezoid T [i] 6 with cut[i] = true we easily check whether this trapezoid is on the left of x or on the right of x. We can also keep the number of left and right trapezoids in the variables lef t and right (see Algorithm 5). In order to calculate the minimum value N (x, y) for the fixed x coordinate, we will traverse y coordinates, and count the number of trapezoids with cut[i] = f alse that intersect the line p. The idea is to calculate the cumulative sum by adding +1 for each coordinate c[i] of right trapezoids and by adding −1 for each coordinate d[i] of left trapezoids. The starting value of the cumulative sum is lef t. The number N (x, y) is equal to the number of trapezoids that contain the interval (x, x + 1) plus the cumulative sum. The pseudo-code of this approach is given in Algorithm 4. Algorithm 4: Calculating the minimum value N (x, y) for the given coordinate x. Input: The trapezoids T and the arrays lef tmost, rightmost, index bottom, cut and parameters x, lef t, right. Output: The minimum value N (x, y) for 1 ≤ y ≤ 2n. 1 sum = lef t; 2 min sum = −1; 3 for y = 1 to c[rightmost[x]] do 4 if (y ≥ d[lef tmost[x]]) and (y ≤ c[righmost[x]]) then if (min sum = −1) or (min sum > sum) then end min sum = sum; end i = index bottom[y]; if (b[i] ≤ x) and (y = d[i]) and (cut[i] = f alse) then end if (a[i] > x) and (y = c[i]) and (cut[i] = f alse) then sum = sum − 1; sum = sum + 1; end 5 6 7 8 9 10 11 12 13 14 15 16 end 17 if min sum > −1 then 19 end 20 else 18 return (n − lef t − right) + min sum; 21 22 end return −1; Example 5 The vertex connectivity of the graph G in Figure 1 is two. For x = 11, we have the following parameters lef t = 5, right = 2, cut[6] = true and cut[i] = f alse for 1 ≤ i ≤ 8 and i 6= 6. The execution of Algorithm 4 is presented in Table 1. From the above table, we conclude that the minimum value of cumulative sums from y = 3 to y = 13 equals 1 and it is achieved for y = 10, 11, 13. This shows that the vertex connectivity of G is less than or equal to 1 + (8 − 5 − 2) = 2. For the efficient implementation, we will use the modified binary indexed tree data structure. The array A will correspond to the lower coordinates from 1 to 2n. For each trapezoid T [i] with cut[i] = f alse, assign A[c[i]] = 0 and A[d[i]] = −1 if T [i] is a left trapezoid, and assign A[c[i]] = 1 and A[d[i]] = 0 if T [i] is a right trapezoid. In order to find the minimum value of 7 i lef tmost rightmost A sum 1 -1 7 0 5 2 -1 7 0 5 3 1 7 -1 4 4 1 7 -1 3 5 1 7 0 3 6 1 7 0 3 7 1 7 0 3 8 1 7 -1 2 9 1 7 0 2 10 11 12 13 14 15 16 1 7 -1 1 1 7 0 1 1 8 1 2 1 8 -1 1 1 -1 1 2 1 -1 0 2 1 -1 0 2 Table 1: Example of the algorithm execution. N (x, y) for 1 ≤ y ≤ 2n, we can just return Calculate(rightmost[x]). The only problem is to ensure that there is at least one left trapezoid for each unit interval (x, x + 1). We can solve this by setting −n2 − 1 for the value A[d[lef tmost[x]]] and taking this into account when calculating the minimum values. The number n2 + 1 is big enough and all partial sums before the index lef tmost[x] will be greater than n (we update the vertex connectivity only if N (x, y) is less than or equal to n). At the end we need to handle the special case -- when G is a complete graph. The pseudo-code of this algorithm is presented below. Since every trapezoid will be added and removed exactly once from the modified binary indexed tree data structure, the total time complexity is O(n log n). This modified data structure with variable left ends is a novel approach to the best of our knowledge and makes this problem very interesting. We conclude this section by summing the results in the following theorem. Theorem 6 The proposed algorithm calculates the vertex connectivity of a trapezoid graph with n vertices in time O(n log n) and space O(n). 4 Bipartiteness criteria and tree representation In this section we establish local test for bipartiteness of trapezoid graphs. Theorem 7 The trapezoid graph G is bipartite if and only if it does not contain a triangle. Proof. The first part directly follows from the well-known result: the graph G is bipartite if and only if it does not contain odd cycles. Let G be a triangle-free trapezoid graph and let C = T [1]T [2] . . . T [k] be the smallest odd cycle contained in G with k > 3. It can be easily seen that there are no chords in C, i. e. there are no edges of the form T [i]T [j] with i > j + 1 (otherwise we could find smaller odd cycle). Consider the intersection of the trapezoids T [1] and T [2]. If their intersection is a trapezoid with height equal to the distance of two parallel lines (see the first part of Figure 4), then all trapezoids T [3], T [4], . . . , T [k] must be on the right side of T [1] -- which is impossible, since T [k] must have common points with T [1]. Otherwise, the trapezoids T [1] and T [2] have intersection as shown in the second part of Figure 4. Without loss of generality we can assume that the trapezoids T [3] and T [k] are independent and positioned as shown in the figure. In order to connect the trapezoids T [3] and T [k] by a path of trapezoids T [4]T [5] . . . T [k − 1] -- some trapezoids of this path must intersect either T [1] or T [2], which is impossible. Therefore, the graph G does not contain cycles of odd length and it follows that G is bipartite. (cid:3) Note that from the above proof it follows that each cycle of length greater than four contains a chord (an edge joining two nodes that are not adjacent in the cycle). A caterpillar graph is a tree such that if all pendent vertices and their incident edges are removed, the remainder of the graph forms a path. Let Cn,d(a1, a2, . . . , ad−1) be a caterpillar 8 Algorithm 5: Calculating the vertex connectivity of a trapezoid graph. Input: The trapezoids T , the arrays lef tmost, rightmost and index up, and MBIT data structure. Output: The vertex connectivity number. 1 k = −1; 2 lef t = 0; 3 right = n; 4 for i = 1 to n do cut[i] = f alse; 5 U pdate(c[i], 1); U pdate(d[i], 0); 6 7 8 end 9 for x = 1 to 2n − 1 do i = index up[x]; if a[i] = x then cut[i] = true; right = right − 1; U pdate(c[i], 0); U pdate(d[i], 0); 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 end else cut[i] = f alse; lef t = lef t + 1; U pdate(c[i], 0); U pdate(d[i],−1); U pdate(d[lef tmost[x − 1]],−1); end if (x > 1) and (lef tmost[x − 1] 6= −1) then end if (lef tmost[x] 6= −1) then end if (rightmost[x] 6= −1) and (lef tmost[x] 6= −1) then U pdate(d[lef tmost[x]],−n · n − 1); N xy = Calculate(rightmost[x]) + n · n + (n − right); if N xy ≤ n then k = N xy; if (k = −1) or (k > N xy) then end end end 39 37 end 38 if k > −1 then 40 end 41 else // complete graph return k; 42 43 end return n − 1; 9 Figure 2: Two cases for Theorem 7. with n vertices obtained from a path Pd+1 = v0v1 . . . vd−1vd by attaching pi ≥ 0 pendent vertices to the vertex vi, 1 ≤ i ≤ d − 1, where n = d + 1 + Pd−1 i=1 pi. It can be easily seen that each caterpillar Cn,d(a1, a2, . . . , ad−1) has trapezoid representation as triangle-free interval graph [15]. Assume now that tree G is not a caterpillar and has trapezoid representation. Then it contains a vertex w with neighbors v1, v2, v3, such that each vertex vi has another neighbor ui different than w, i = 1, 2, 3. The trapezoids T [v1], T [v2] and T [v3] corresponding to the vertices v1, v2 and v3 are independent. Without loss of generality we can assume the order T [v1] ≪ T [v2] ≪ T [v3]. Since all trapezoids T [v1], T [v2] and T [v3] intersect the trapezoid T [w], it can be easily seen that all neighbors of T [v2] (trapezoid T [u2] in particular) also must intersect T [w]. This is a contradiction, and G does not have trapezoid representation. Therefore, we proved the following Theorem 8 A trapezoid graph G represents a tree if and only if it is a caterpillar. 5 Concluding remarks In this paper we presented an efficient algorithm for calculating the vertex connectivity number κ(G) of a trapezoid graph. We leave as an open problem to design efficient algorithm for finding the edge connectivity number λ(G) in trapezoid graphs. The k -- trapezoid graphs are an extension of trapezoid graphs to higher dimension orders. The k -- dimensional box representation (V, l, u) of a graph G = (V, E) consists of mappings l : V → Rk and u : V → Rk such that l[i] is the lower and u[i] the upper corner of a box box[i] where two vertices of the graph are joined by an edge iff their corresponding boxes are incomparable [10]. If a graph has such a representation, it is a k -- trapezoid graph. If we additionally have a weight w : V → R on the vertices of G then the k -- trapezoid graph is weighted. For the case k = 2, we have simple trapezoid graphs. Another generalization are circular trapezoid graphs -- the intersection graphs of circular trapezoids between two parallel (concentric) circles [20]. It seems that the presented approach can be modified and adapted for calculating the vertex connectivity number of k -- trapezoid graphs and circular trapezoid graphs. Acknowledgement. This work was supported by Research Grants 174010 and 174033 of Serbian Ministry of Education and Science. References [1] M. I. Abouelhoda, E. Ohlebusch, Chaining algorithms for multiple genome comparison, J. Discrete Algorithms 3 (2005) 321 -- 341. [2] D. Bera, M. Pal, T. K. Pal, An efficient algorithm to generate all maximal cliques on trapezoid graphs, Int. J. Comput. Math. 79 (2002) 1057 -- 1065. 10 [3] D. Bera, M. Pal, T. K. Pal, An Efficient Algorithm for Finding All Hinge Vertices on Trapezoid Graphs, Theory Comput. Systems 36 (2003) 17 -- 27. [4] F. Cheah, D. G. Corneil, On the structure of trapezoid graphs, Discrete Appl. Math. 66 (1996) 109 -- 133. [5] T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms, Second Edition, MIT Press, 2001. [6] D. G. Corneil, P. A. Kamula, Extensions of permutation and interval graphs, In: Proceed- ings of 18th Southeastern Conference on Combinatorics, Graph Theory and Computing, 1987, 267 -- 275. [7] C. Crespelle, P. Gambette, Unrestricted and complete Breadth First Search of trapezoid graphs in O(n) time, Inform. Process. Lett. 110 (2010) 497 -- 502. [8] I. Dagan, M. C. Golumbic, R. Y. Pinter, Trapezoid graphs and their coloring, Discrete Appl. Math. 21 (1988) 35 -- 46. [9] S. Even, R. E. Tarjan, Network flow and testing graph connectivity, Inform. Process. Lett. 4 (1975) 507 -- 518. [10] S. Felsner, R. Muller, L. Wernisch, Trapezoid graphs and generalizations, geometry and algorithms, Discrete Appl. Math. 74 (1997) 13 -- 32. [11] P. K. Ghosh, M. Pal, An efficient algorithm to find the maximum matching on trapezoid graphs, J. Korean Soc. Ind. Appl. Math. IT Series 9 (2) (2005) 13 -- 20. [12] P. K. Ghosh, M. Pal, An efficient algorithm to solve connectivity problem on trapezoid graphs, J. Appl. Math. & Computing 24 (2007) 141 -- 154. [13] M. Hota, M. Pal, T. K. Pal, Optimal sequential and parallel algorithms to compute all cut vertices on trapezoid graphs, Comput. Optim. Appl. 27 (1) (2004) 95 -- 113. [14] A. Ili´c, A. Ili´c, On vertex covers and matching number of trapezoid graphs, (2011), submit- ted. [15] E. Jurgen, Extremal interval graphs, J. Graph Theory 17 (1993) 117 -- 127. [16] R. M. Karp, Reducibility among combinatorial problems, In: R. E. Miller, J. W. Thatcher (Eds.), Complexity of Computer Computation, Plenum Press, New York, 1972, 85 -- 103. [17] Y. D. Liang, Domination in trapezoid graphs, Inform. Process. Lett. 52 (1994) 309 -- 315. [18] Y. D. Liang, Steiner set and connected domination in trapezoid graphs, Inform. Process. Lett. 56 (1995) 101 -- 108. [19] M. S. Lin, Y. J. Chen, Counting the number of vertex covers in trapezoid graph, Inform. Process. Lett. 109 (2009) 1187 -- 1192. [20] Y. L. Lin, Circular and circle trapezoid graphs, J. Sci. Eng. Tech. 2 (2006) 11 -- 17. [21] T. W. Kao, S. J. Horng, Computing k-Vertex Connectivity on an Interval Graph, Interna- tional Conference on Parallel Processing ICPP'94, Vol. 3 (1994) 218 -- 221. [22] T. H. Ma, J. P. Spinrad, On the 2-chain subgraph cover and related problems, J. Algorithms 17 (1994) 251 -- 268. 11 [23] G. B. Mertzios, D. G. Corneil, Vertex splitting and the recognition of trapezoid graphs, Technical Report AIB-2009-16, RWTH Aachen University, 2009. [24] S. Mondal, M. Pal, T. K. Pal, An optimal algorithm for solving all-pairs shortest paths on trapezoid graphs, Int. J. Comput. Eng. Sci. (IJCES) 3 (2002) 103 -- 116. [25] Y. T. Tsai, Y. L. Lin, F. R. Hsu, Efficient algorithms for the minimum connected domination on trapezoid graphs, Inform. Sci. 177 (2007) 2405 -- 2417. 12
1601.03095
3
1601
2016-11-04T21:33:37
Submodular Optimization under Noise
[ "cs.DS", "cs.AI", "cs.GT" ]
We consider the problem of maximizing a monotone submodular function under noise. There has been a great deal of work on optimization of submodular functions under various constraints, resulting in algorithms that provide desirable approximation guarantees. In many applications, however, we do not have access to the submodular function we aim to optimize, but rather to some erroneous or noisy version of it. This raises the question of whether provable guarantees are obtainable in presence of error and noise. We provide initial answers, by focusing on the question of maximizing a monotone submodular function under a cardinality constraint when given access to a noisy oracle of the function. We show that: - For a cardinality constraint $k \geq 2$, there is an approximation algorithm whose approximation ratio is arbitrarily close to $1-1/e$; - For $k=1$ there is an algorithm whose approximation ratio is arbitrarily close to $1/2$. No randomized algorithm can obtain an approximation ratio better than $1/2+o(1)$; -If the noise is adversarial, no non-trivial approximation guarantee can be obtained.
cs.DS
cs
Submodular Optimization under Noise Avinatan Hassidim∗ Bar Ilan University Yaron Singer† Harvard University [email protected] [email protected] Abstract We consider the problem of maximizing a monotone submodular function under noise. There has been a great deal of work on optimization of submodular functions under various constraints, resulting in algorithms that provide desirable approximation guarantees. In many applications, however, we do not have access to the submodular function we aim to optimize, but rather to some erroneous or noisy version of it. This raises the question of whether prov- able guarantees are obtainable in presence of error and noise. We provide initial answers, by focusing on the question of maximizing a monotone submodular function under a cardinality constraint when given access to a noisy oracle of the function. We show that: • For a cardinality constraint k ≥ 2, there is an approximation algorithm whose approxi- mation ratio is arbitrarily close to 1 − 1/e; • For k = 1 there is an algorithm whose approximation ratio is arbitrarily close to 1/2. No randomized algorithm can obtain an approximation ratio better than 1/2 + o(1); • If the noise is adversarial, no non-trivial approximation guarantee can be obtained. ∗Supported by ISF 1241/12; †Supported by NSF grant CCF-1301976, CAREER CCF-1452961, Google Faculty Research Award, Facebook Faculty Award. Contents 1 Introduction 1.1 Main result . 1.2 Extensions . . . 1.3 Applications . . . . . . . . . . . . . 1.4 Paper organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Optimization for Large k 2.1 The Smooth Greedy Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 The algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 Smoothing guarantees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 Approximation guarantee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Slick Greedy: Optimal Approximation for Sufficiently Large k . . . . . . . . . . . . . 2.2.1 The algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 4 4 5 6 6 6 8 8 9 9 2.2.2 Generalizing guarantees of smooth greedy . . . . . . . . . . . . . . . . . . . . 10 2.2.3 The smooth comparison procedure . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2.4 Approximation guarantee of SLICK GREEDY . . . . . . . . . . . . . . . . . . . 11 3 Optimization for Small k 12 3.1 Combinatorial averaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2 The Sampled Mean Greedy Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.3 Smoothing Guarantees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.4 Approximation Guarantee in Expectation . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.5 From Expectation to High Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 Optimization for Very Small k 16 4.1 Smoothing Guarantees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.2 An Approximation Algorithm for Very Small k . . . . . . . . . . . . . . . . . . . . . . 16 4.3 Information Theoretic Lower Bounds for Constant k . . . . . . . . . . . . . . . . . . . 16 5 Extensions 17 5.1 Additive Noise . 5.2 Marginal Noise . . . 5.3 Correlated Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5.4 Information Degradation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 5.5 Approximate Submodularity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6 Impossibility for Adversarial Noise 7 More related work 8 Acknowledgements Appendices A Combinatorial Smoothing B Optimization for Large k C Optimization for Small k D Optimization for Very Small k E Noise Distributions F Additional Examples 23 26 28 36 37 45 60 72 77 79 1 Introduction In this paper we study the effects of error and noise on submodular optimization. A function f : 2N → R defined on a ground set N of size n is submodular if for any S, T ⊆ N: f (S ∪ T ) ≤ f (S) + f (T ) − f (S ∩ T ) Equivalently, submodularity can be defined in terms of a natural diminishing returns property. For any A, B ⊆ N let fA(B) = f (A ∪ B) − f (A), then f is submodular if ∀S ⊆ T ⊆ N, a ∈ N \ T : fS(a) ≥ fT (a). In general, submodular functions may require a representation that is exponential in the size of the ground set and the assumption is that we are given access to a value oracle which given a set S returns f (S). It is well known that submodular functions admit desirable approximation guarantees and are heavily used in applications such as market design, data mining, and machine learning (see related work). For the classic problem of maximizing a monotone (i.e. S ⊆ T =⇒ f (S) ≤ f (T )) submodular function under a cardinality constraint, the greedy algorithm which iteratively adds the element with largest marginal contribution into the solution obtains a 1 − 1/e approximation [82] which is optimal unless using exponentially-many queries [81] or P=NP [35]. Since submodular functions can be exponentially representative, it may be reasonable to assume that there are cases where one faces some error in their evaluation. In market design where sub- modular functions often model agents' valuations for goods, it seems reasonable to assume that agents do not precisely know their valuations. Even with compact representation, evaluation of a submodular function may be prone to error. In learning and sketching submodular functions, the algorithms produce an approximate version of the function [48, 8, 7, 4, 42, 43, 30, 31, 41, 44, 6]. Can we retain desirable approximation guarantees in the presence of error? 1+ using(cid:0)n k (1 − )f (S) ≤ (cid:101)f (S) ≤ (1 + )f (S) For f : 2N → R and  > 0 we say that (cid:101)f : 2N → R is -erroneous if for every set S ⊆ N, it respects: (cid:1) queries with an -erroneous oracle by simply evaluating all possible subsets For the canonical problem of maxS:S≤k f (S), one can trivially approximate the solution within a factor of 1− and returning the best solution (according to the erroneous oracle). Is there a polynomial-time al- gorithm that can obtain desirable approximation guarantees for maximizing a monotone submod- ular function under a cardinality constraint given access to -erroneous oracles? In Appendix F we sketch an example showing that the celebrated greedy algorithm fails to obtain an approximation strictly better than O(1/k) for any constant  > 0 when given access to an -erroneous oracle (cid:101)f instead of f. It turns out that this is not intrinsic to greedy. No algorithm is robust to small errors. Theorem (6.1). No randomized algorithm can obtain an approximation strictly better than O(n−1/2+δ) to maximizing monotone submodular functions under a cardinality constraint using enδ /n queries to an -erroneous oracle, for any fixed , δ < 1/2, with high probability. 1 show for example, that additive functions (i.e. f (S) =(cid:80) Since desirable guarantees are generally impossible with erroneous oracles, we seek natural re- laxations of the problem. The first could be to consider stricter classes of functions. It is trivial to 1+ approx- imation when given access to -erroneous oracles. Unfortunately, it seems like there are not many interesting classes of submodular functions that enjoy these properties. In fact, our impossibility result applies to very simple affine functions, and even coverage functions like the example in Ap- pendix F. An alternative relaxation is to consider error models that are not necessarily adversarial. a∈S f (a)) allow us to obtain a 1− Noisy oracles. We can equivalently say that (cid:101)f : 2N → R is -erroneous if for every S ⊆ N we have that (cid:101)f (S) = ξSf (S) for some ξS ∈ [1 − , 1 + ]. The lower bound stated above applies to Definition. For a function f : 2N → R we say that (cid:101)f : 2N → R is a noisy oracle if there exists some distribution D s.t. (cid:101)f (S) = ξSf (S) where ξS is independently drawn from D for every S ⊆ N. the case in which the error multipliers ξS are adversarially chosen. A natural question is whether some relaxation of the adversarial error model can lead to possibility results. Note that the noisy oracle defined above is consistent: for any S ⊆ N the noisy oracle returns the same answer regardless of how many times it is queried. When the noisy oracle is in- consistent, mild conditions on the noise distribution allow the noise to essentially vanish after logarithmically-many queries, reducing the problem to standard submodular maximization (see e.g. [59, 91]). Consistency implies that the noise is arbitrarily correlated for a given set in different time steps, but i.i.d between different sets. In fact, we will later generalize the model to the case in which ξS and ξT are i.i.d only when S and T are sufficiently far, and arbitrarily correlated oth- erwise (see Section 1.3). At this point, we are interested in identifying a natural non worst-case model of corrupted or approximately submodular functions that is amendable to optimization. We will be interested in a class of distributions that avoids trivialities like D ⊆ {0} and is yet general enough to contain natural distributions. In this paper we define a class which we call generalized exponential tail distributions that contains Gaussian, Exponential, and distributions with bounded support which are independent of n (o.w. optimization is impossible, see Appendix E). Note that optimization in this setting always requires that n is sufficiently large. For example, if for every S the noise is s.t. ξS = 2100 with probability 1/2100 and 0 otherwise, but n = 50, it is likely that the noisy oracle will always return 0, in which case we cannot do better than selecting an element at random. Throughout the paper we assume that n is sufficiently large. Definition. A noise distribution D has a generalized exponential tail if there exists some x0 such that i aixαi. We do not assume that all the αi's are integers, but only that α0 ≥ α1 ≥ . . ., and that α0 ≥ 1. If D has bounded support we only require that either it has an atom at its supremum, or that ρ is continuous and non zero at the supremum. for x > x0 the probability density function ρ(x) = e−g(x), where g(x) =(cid:80) For simplicity, one can always consider the special case where D ⊆ [1 − , 1 + ], which implies that two sets whose true values are close will remain close in the noisy evaluation. Even when the noise distribution is uniform in [1 − , 1 + ] it is easy to show that the greedy algorithm fails (see Appendix F). The question is whether provable guarantees are achievable in this model. 2 1.1 Main result Our main result is that for the problem of optimizing a monotone submodular function under a cardinality constraint, near-optimal approximations are achievable under noise. Theorem. For any monotone submodular function there is a polynomial-time algorithm which optimizes the function under a cardinality constraint k > 2 and obtains an approximation ratio that is w.h.p arbitrar- ily close to 1 − 1/e using access to a generalized exponential tail noisy oracle of the function. This proof is a summary of three results, each for a different regime of k. For any  > 0 we show: • 1 − 1/e −  guarantee for large k: we say that k is large when k ∈ Ω(log log n/2). For k that is sufficiently larger than log log n/2 we give a deterministic algorithm which obtains a (1 − 1/e − ) approximation guarantee w.h.p over the noise distribution; • 1 − 1/e −  guarantee for small k: we say that k is small when k ∈ O(log log n) ∩ Ω(1/). In this regime the problem is surprisingly harder. We give a different deterministic algorithm which achieves the coveted (1 − 1/e − ) guarantee, w.h.p. over the noise distribution; • Guarantees for very small k: We say that k is very small when it is an arbitrarily small con- stant. For this case we give a randomized algorithm whose approximation ratio is 1− 1/k−  w.h.p. over the randomization of the algorithm and the noise distribution. Note that this gives 1− 1/e−  for any k > 2, and 1/2−  for k = 2. We also give a k/(k + 1) approximation which holds in expectation over the randomization of the algorithm. This achieves 1 − 1/e for k = 2 and 1/2 for k = 1. For k = 1 no randomized algorithm can obtain an approximation ratio better than 1/2 + O(1/ √ √ n) and (2k − 1)/2k + O(1/ n) for general k. At their core, the algorithms are variants of the classic greedy algorithm. In the presence of noise, sets H we can define a surrogate function F (S) = (cid:80) greedy fails since it cannot identify the set whose value is maximal in each iteration. To han- (cid:101)F (S) = (cid:80) dle noise, we apply a natural approach we call smoothing. In general, by selecting a family of H(cid:48)∈H (cid:101)f (S ∪ H(cid:48)) which we can evaluate. Intuitively, when H is sufficiently large and H(cid:48)∈H f (S ∪ H(cid:48)) and its noisy analogue chosen appropriately, submodularity and monotonicity can be used to argue that (cid:101)F (S) ≈ F (S). Thus, smoothing essentially makes the noise disappear and instead leaves us to deal with the implications of optimizing with the surrogate F rather than f. In that sense, a large part of the challenge is in using optimization over the surrogate F to approximate the optimum over f, i.e.: size log log n and runs the greedy algorithm with the surrogate (cid:101)F = (cid:80) • Large k. In this regime, we first define SMOOTH-GREEDY which takes an arbitrary set H of N \ H. In the analysis we show that its output together with H is arbitrarily close to 1 − 1/e of the optimal solution evaluated on fH (not f). The SLICK-GREEDY algorithm runs multiple instantiations of a slightly modified version of SMOOTH-GREEDY with different smoothing sets, and obtains a guarantee arbitrarily close to 1 − 1/e of the true optimum; H(cid:48)⊆H (cid:101)f (T ∪ H(cid:48)) on • Small k. In this regime, we use a modified version of greedy which adds a bundle of O(1/) elements in each iteration. For each such bundle B we define a surrogate (cid:101)F with a smoothing 3 iteration SM-GREEDY identifies the bundle A which maximizes (cid:101)F , but doesn't take it. Taking (cid:101)f (B), over all bundles B in the smoothing neighborhood of A. The analysis is then quite tech- neighborhood of elements which are at distance 2 on the {0, 1}n hypercube from B. In each a random bundle A from the smoothing neighborhood of A gives the 1 − 1/e guarantee but in expectation. To obtain the result w.h.p. SM-GREEDY takes the bundle A which maximizes nical and strongly leverages the properties of the noise distribution and that k ∈ O(log log n). It is for this reason it is crucial that SLICK-GREEDY applies to k ∈ Ω(log log n); • Very small k. In this case we consider bundles of size k and smoothing with singletons. 1.2 Extensions One of the appealing aspects of the noise model and the algorithms, is that they can easily be extended to a rich variety of related models. In Section 5 we discuss application to additive noise, marginal noise, correlated noise, information degradation, and approximate submodularity, . 1.3 Applications • Optimization under noise. When considering optimization under noise, queries can be in- dependent or correlated in time and in space. For f : 2N → R the noisy oracle is defined as (cid:101)f (S) = ξS(t)f (S) where ξS(t) ∼ D, for every step the oracle is queried t ∈ N and S ⊆ N. Definition. Noise is i.i.d in time if ξS(t) and ξS(t(cid:48)) are independent for any t (cid:54)= t(cid:48) ∈ N and S ⊆ N. Similarly, we can say that noise is i.i.d in in space if ξS(t) and ξT (t(cid:48)) for any S (cid:54)= T and t, t(cid:48) ∈ N. The noise distribution is correlated in time (space) if it is not independent in time (space). The case in which the oracle is inconsistent is one where the noise is i.i.d in time and in space. From an algorithmic perspective this problem is largely solved, as discussed above. From Theorem 6.1 we know that there is no poly-time approximation algorithm for the case in which the errors are arbitrarily correlated in time and in space, even when the support of the noise distribution is arbitrarily small. The model we describe assumes the noise is arbitrarily correlated in time, but i.i.d in space. In Section 5 we show how one can relax this assumption. In particular, we show how to generalize the algorithms to obtain approxima- tion ratios arbitrarily close to 1 − 1/e in a noise model where ξS(t) and ξT (t(cid:48)) are arbitrarily √ correlated in time and in space for any t, t(cid:48) ∈ N and S, T for which S(cid:52)T ∈ O( k) when k ∈ Ω(log log n) and S(cid:52)T ∈ O(1) when k ∈ O(log log n). To the best of our knowledge, this is the first step towards studying submodular optimization under any correlation. • Maximizing approximately submodular functions. There are cases where one may wish to optimize an approximately submodular function. Theorem 6.1 implies that being arbitrarily close to a submodular function is not sufficient. In statistics and learning theory, to model the fact that data is generated by a function that is approximately in a class of well behaved functions, the function generating the data (cid:101)f is typically assumed to be a noisy version of a function f from a well-behaved class of functions [53, 97, 88]: (cid:101)f (x) = f (x) + ξx, 4 stance, one assumes that the data is generated by (cid:101)f (x) = w (cid:124) where ξx is an i.i.d sample drawn from some distribution D. In regression problems for in- x + ξx. This model captures the idea that some phenomena may not exactly behave in a linear manner, but can be approxi- mated by such a model. Making a good prediction then involves optimizing the noisy model. This therefore seems like a natural model to study approximate submodularity, especially in light of Theorem 6.1. Notice that in this case we would be interested in the optimization problem: maxS:S≤k (cid:101)f (S). In Section 5 we describe a black-box reduction which allows one to use the algorithms described here to get optimal guarantees. • Active learning. In active learning one assumes a membership oracle that can be queried to obtain labeled data [3]. In noise-robust learning, the task is to get good approximations to the noise-free target f when the examples are corrupted by some noise. In this model the assumption is that noise is consistent and i.i.d, exactly as in our model. That is, we observe f (x) + ξx where x is drawn i.i.d from D and multiple queries return the same answer (see e.g. [49, 55, 89, 56, 13, 40]). Our results apply to additive noise, and thus apply to active learning with noisy membership queries of submodular functions. One example application of active learning where the function is submodular is experimental design [70, 69, 54]. • Learning and sketching. In learning and sketching the goal is to generate a surrogate func- tion which approximates the submodular function well (see e.g. [48, 8, 7, 4, 42, 43, 30, 31, 41, 44, 6]). Theorem 6.1 implies that a surrogate which approximates a submodular func- tion arbitrarily well may be inapproximable. Our main result shows that if when sets are sufficiently far the surrogate approximates the function via independent noise, then one can use the surrogate for optimization. This can therefore be used as a stricter benchmark for learning and sketching which allows optimizing a function learned or sketched from data. 1.4 Paper organization The main technical contribution of the paper is the algorithms for the three different regimes of k. The exposition of the algorithms is contained in sections 2, 3, and 4, which can be read inde- pendently from each other. For each algorithm, we suppress proofs and additional lemmas to the corresponding section in the appendix. All the algorithms employ smoothing arguments which can be found in Appendix A. The smoothing arguments are used as a black-box in the proofs of each algorithm, and are not required for reading the main exposition. In Section 5 we discuss ex- tensions of the algorithms to related models. In Section 6 we prove the result for adversarial noise. Discussion about additional related work is in Section 7. 5 2 Optimization for Large k In this section we describe the SLICK-GREEDY algorithm whose approximation guarantee is arbi- trarily close to 1 − 1/e for sufficiently large k. The algorithm is deterministic and for any desired degree of accuracy  > 0 can be applied when the cardinality constraint k is in Ω(log log n/2), or more specifically when k ≥ 3168 log log n/2. We first describe and analyze the SMOOTH-GREEDY algorithm. This algorithm is then used as a subroutine by the SLICK-GREEDY algorithm. 2.1 The Smooth Greedy Algorithm We begin by describing the smoothing technique used by SMOOTH-GREEDY. We select an arbitrary set H and for a given element a, the smoothing neighborhood is simply H = {H(cid:48) ⊆ H : H(cid:48) ∪ a}. Throughout the rest of this section we assume that H is an arbitrary set of size (cid:96), where (cid:96) depends on k. In the case where k ≥ 2400 log n we will use (cid:96) = 25 log n, and when k < 2400 log n we will use (cid:96) = 33 log log n 1. The precise choice for (cid:96) will become clear later in this section. Intuitively, (cid:96) is on the one hand small enough so that we can afford to sacrifice (cid:96) elements for smoothing the noise, and on the other hand (cid:96) is large enough so that taking all its subsets gives us a large smoothing neighborhood which enables applying concentration bounds. Definition. For a set S ⊆ N and some fixed set H ⊆ N of size (cid:96), we use H (1), . . . , H (t) to denote all the subsets of H and k(cid:48) = k − (cid:96). The smooth value, noisy smooth value and smooth marginal contribution are, respectively: (1) (2) (3) F (S ∪ a) := (cid:101)F (S ∪ a) := FS(a) := 2.1.1 The algorithm f (S ∪ (H (i) ∪ a) E(cid:104) E(cid:104)(cid:101)f (S ∪ (H (i) ∪ a) E(cid:104) fS((H (i) ∪ a)) (cid:105) (cid:105) (cid:105) 1 t 1 t = = = t(cid:88) t(cid:88) i=1 i=1 f (cid:16) (cid:16) (cid:101)f t(cid:88) i=1 1 t (cid:17) (cid:17) (cid:17) ; ; . S ∪ (H (i) ∪ a) S ∪ (H (i) ∪ a) H (i) ∪ a fS (cid:16) The smooth greedy algorithm is a variant of the standard greedy algorithm which replaces the procedure of adding argmaxa∈N f (S ∪ a) with its smooth analogue. The algorithm receives a set the smooth noisy value (cid:101)F (S ∪ a) is largest. A formal description is added below. of elements H of size (cid:96), initializes S = ∅ and at every stage adds to S the element a /∈ H for which Overview of the analysis. At a high level, the idea behind the analysis is to compare the per- formance of the solution returned by the algorithm against an optimal solution which ignores the 1W.l.o.g. we assume that k < n − 25 log n as for sufficiently large n this then implies that k ≥ (1 − )n and by submodularity optimizing with k(cid:48) = n − 25 log n suffices to get the 1 − 1/e −  guarantee for any fixed  > 0. 6 Algorithm 1 SMOOTH-GREEDY Input: budget k, set H 1: S ← ∅ 2: while S < k − H do 3: 4: end while 5: return S S ← S ∪ arg maxa /∈H (cid:101)F (S ∪ a) value of H and any of its partial substitutes. More specifically, let OPT denote the value of the optimal solution with k elements evaluated on f and OPTH denote the value of the optimal solu- tion with k(cid:48) = k − (cid:96) elements evaluated on fH, where fH (T ) = f (T ∪ H) − f (H). Essentially, we will show that at every step SMOOTH-GREEDY selects an element whose marginal contribution is larger than that of an element from the optimal solution evaluated on fH (we illustrate this idea in Figure 1). Together with an inductive argument this suffices for a constant factor approximation. ically, when we select an element that maximizes (cid:101)F (S ∪ a), our smoothing guarantee will be that Relevant iterations. One of the artifacts of noise is that our comparisons are not precise. Specif- this element respects FS(a) ≥ (1 − δ) maxb /∈H FS(b) for δ > 0 that depends on  and k. This can be guaranteed only for an iteration where two conditions are met: (i) there is at least a single element not yet selected (and not in H) whose marginal contribution is at least /k fraction of OPTH, and (ii) OPTH is sufficiently large in comparison to OPT. We call such iterations -relevant. Definition. For a given iteration of SMOOTH-GREEDY let S be the set of elements selected in previous iterations. The iteration is -relevant if (i) maxb /∈H fH∪S(b) ≥ ·OPTH and (ii) OPTH ≥ OPT e . k We will analyze SMOOTH-GREEDY in the case where the iterations are -relevant as it allows apply- ing the smoothing arguments. In the analysis we will then ignore iterations that are not -relevant at the expense of a negligible loss in the approximation guarantee. The main steps are: 1. In Lemma 2.1 we show that in each -relevant iteration the (non-noisy) smooth marginal contribution of the element selected in that iteration by the algorithm is w.h.p. an arbitrarily good approximation to maxb /∈H FS(b). To do so we need claims B.1, B.2 and B.3; 2. Next, in Claim 2.3 we show that the element a whose smooth marginal contribution FS(a) is maximal has true marginal contribution fS(a) that is roughly a k(cid:48)th fraction of the marginal contribution of the optimal solution over fH; 3. Finally, in Lemma 2.4 we apply a standard inductive argument to show that the fact that the algorithm selects an element with large smooth value in each step results in an approxima- tion arbitrarily close to 1 − 1/e to OPTH (not OPT). In Corollary B.4 we show that the bound against OPTH can already be used to give a constant factor approximation to OPT. To get ar- bitrarily close to 1 − 1/e, SLICK-GREEDY executes multiple instantiations of a generalization of SMOOTH-GREEDY as later described in Section 2.2. 7 Figure 1: An illustration of Claim B.1 applied on a coverage function. The set of all elements N and A, B, H ⊂ N are depicted as circles that illustrate the area of the universe they cover. Claim B.1 essentially says that if we select A rather than B this means that the total area A covers (white and grey) must be larger than the white-only (i.e. universe not covered by H) of B. Stated in these terms, we use this idea to analyze the performance of SMOOTH-GREEDY evaluated on the white and grey area against the optimal solution evaluated on the white-only area. 2.1.2 Smoothing guarantees mizes the (non-noisy) smooth marginal contribution FS, with high probability. The first step is to prove Lemma 2.1. This lemma shows that at every step as SMOOTH-GREEDY adds the element that maximizes the noisy value argmaxa /∈H (cid:101)F (S ∪ a), that element nearly maxi- set of elements selected in previous iterations and a ∈ arg maxb /∈H (cid:101)F (S ∪ b). Then for δ = 2/4k and Lemma 2.1. For any fixed  > 0, consider an -relevant iteration of SMOOTH-GREEDY where S is the sufficiently large n we have that w.p. ≥ 1 − 1/n4: FS(a) ≥ (1 − δ) max b /∈H FS(b). To prove the above lemma we use claims B.1, B.2, and B.3. The statements and proofs can be found in Appendix B and are best understood after reading the smoothing section in Appendix A. 2.1.3 Approximation guarantee Lemma 2.1 lets us forget about noise, at the analysis of SMOOTH-GREEDY. We can now focus on the consequences of selecting an element a which (up to factor 1 − δ) maximizes FS rather than the true marginal contribution fS. Claim 2.2. For any  > 0, b(cid:63) ∈ argmaxb /∈H fH∪S(b). If FS(a) ≥ (1 − δ)FS(b(cid:63)), then: let δ ≤ 2/4k. Suppose that the iteration is -relevant and let for the remainder of least fS(a) ≥ (1 − )fH∪S(b(cid:63)). The principle is similar to Claim B.1. In this version we have a weaker condition since FS(a) is not greater than FS(b(cid:63)) but rather (1 − δ)FS(b(cid:63)), but the claim is less general as it only needs to hold for b(cid:63). We therefore use a slightly different approach to prove this claim (see Appendix B). 8 HABN Claim 2.3. For any fixed  > 0, consider an -relevant iteration of SMOOTH-GREEDY with S as the elements selected in previous iterations. Let a ∈ argmaxb /∈H (cid:101)F (S ∪ b). Then, w.p. ≥ 1 − 1/n4: fS(a) ≥(cid:16) (cid:17)(cid:20) 1 (cid:16) k(cid:48) (cid:17)(cid:21) 1 −  OPTH − f (S) . The proof is in Appendix B. We can now state the main lemma of this subsection. Lemma 2.4. Let S be the set returned by SMOOTH-GREEDY and H its smoothing set. Then, for any fixed  > 0 when k ≥ 3(cid:96)/ with probability of at least 1 − 1/n3 we have that: f (S ∪ H) ≥ (1 − 1/e − /3) OPTH . To prove the lemma we show that if OPTH < OPT/e then H alone provides the approximation guarantee. Otherwise we can apply Claim 2.3 using a standard inductive argument to show that S ∪ H provides the approximation. The subtle yet crucial aspect of the proof is that the inductive argument is applied to analyze the quality of the solution against the optimal solution for fH and not against the optimal solution on f. The proof is in Appendix B. As we will soon see, Lemma 2.4 plays a key role in the analysis of the SLICK-GREEDY algorithm. It is worth noting that this lemma can also be used to show that SMOOTH-GREEDY alone provides a constant (≈ 0.387) albeit suboptimal approximation guarantee (Corollary B.4). 2.2 Slick Greedy: Optimal Approximation for Sufficiently Large k The reason SMOOTH-GREEDY cannot obtain an approximation arbitrarily close to 1 − 1/e is due to the fact that a substantial portion of the optimal solution's value may be attributed to H. This would be resolved if we had a way to guarantee that the contribution of H is small. The idea behind SLICK-GREEDY is to obtain this type of guarantee. Intuitively, by running a large albeit constant number of instances of SMOOTH-GREEDY with different smoothing sets, selecting the "best" solution will ensure the contribution of the smoothing set is relatively minor. 2.2.1 The algorithm We can now describe the SLICK-GREEDY algorithm which is the main result of this section. Given a constant  > 0 we set δ = /6 and generate arbitrary sets H1, . . . , H1/δ, each of size (cid:96) s.t. Hi ∩ Hj = ∅ for every i, j ∈ [1/δ]. We then run a modified version of SMOOTH-GREEDY 1/δ times: in each iteration j we initialize SMOOTH-GREEDY with Rj = ∪i(cid:54)=jHi 2 and use Hj to generate the smoothing neighborhood. We denote this as SMOOTH-GREEDY(k, Rj, Hj). We then compare the solution Tj = Sj ∪Hj to the best Ti = Si∪Hi we've seen so far using a procedure we call SMOOTH- COMPARE described below. The SMOOTH-COMPARE procedure compares Ti and Tj by using a set Hij s.t. Hij ∩ (Tj ∪ Ti) = ∅ and Hij = (cid:96). If Ti wins, the procedure returns Ti and otherwise returns Tj. The SLICK-GREEDY then returns the set Ti that survived the SMOOTH-COMPARE tournament. 2By initializing the SMOOTH-GREEDY with Rj we mean that the first iteration begins with S = Rj rather than S = ∅ and following the initialization the algorithm greedily adds k − Rj − Hj elements. 9 Algorithm 2 SLICK-GREEDY Input: budget k 1: Select (cid:96)/δ elements in N and partition them into disjoint sets of equal size H1 . . . , H1/δ 2: Ti ← ∅ 3: for j ∈ [1/δ] do 4: Rj ← ∪i(cid:54)=jHi 5: 6: Hij ← arbitrary set of (cid:96) elements disjoint from Ti ∪ Tj 7: 8: end for 9: return Ti Tj ← SMOOTH-GREEDY(k, Rj, Hj) ∪ Hj Ti ← SMOOTH-COMPARE({Ti, Tj}, Hij) Overview of the analysis. Consider the smoothing sets H1, . . . , H1/δ. Let Hl be the smoothing set whose marginal contribution to the others is minimal, i.e. Hl ∈ argmini∈[1/δ] fRi(Hi). Notice that from submodularity we are guaranteed that fRl(Hl) ≤ δf (Rl ∪ Hl). In this case, the fact that the marginal contribution of Hl to the rest of the smoothing sets Rl is small, together with the fact that the solution is initialized with Rl, enables the tight analysis. The two main steps are: 1. In Lemma 2.5 we show that w.h.p. Tl provides an approximation arbitrarily close to (1−1/e). Intuitively, this happens since the marginal contribution of Hl to the rest of the smoothing sets Rl = ∪iHi \ Hl is small, and since the solution to SMOOTH-GREEDY is initialized with Rl, losing the value of Hl is negligible. The proof relies on Claim B.5 and Lemma B.7 that generalize the guarantees of SMOOTH-GREEDY to the case it is initialized (see Appendix); 2. We then describe and analyze the SMOOTH-COMPARE procedure. In the absence of noise, one can simply select the set whose value is largest. To overcome noise, we run a tournament to extract the solution whose value is approximately largest, or at least arbitrarily close to (1− 1/e)OPT. Specifically, we prove that w.h.p. the set Ti that wins the SMOOTH-COMPARE tour- nament (i.e. the set Ti returned by SLICK-GREEDY) satisfies f (Ti) ≥ (1 − /3) min{f (Tl), (1− 1/e − 2/3)OPT}. Since f (Tl) is arbitrarily close to (1 − 1/e)OPT, this concludes the proof. 2.2.2 Generalizing guarantees of smooth greedy Lemma 2.5. Let Sl be the set returned by SMOOTH-GREEDY that is initialized with Rl and Hl its smooth- ing set. Then, for any fixed  > 0 when k ≥ 36(cid:96)/2 w.p. at least 1 − 1/n3 we have that: f (Sl ∪ Hl) ≥ (1 − 1/e − 2/3)OPT. 2.2.3 The smooth comparison procedure ij) with (cid:101)f (Tj ∪ H(cid:48) We can now describe the SMOOTH-COMPARE procedure we use in the algorithm. For a given set ij) for ij ⊂ Hij (breaking ties all H(cid:48) Hij ⊆ N of size (cid:96) and two sets Ti, Tj ⊆ N \ Hij, we compare (cid:101)f (Ti ∪ H(cid:48) lexicographically) we have that (cid:101)f (Ti ∪ H(cid:48) ij ⊂ Hij. We select Ti if in the majority of the comparisons with H(cid:48) ij), and otherwise we select Tj. ij) ≥ (cid:101)f (Tj ∪ H(cid:48) 10 Algorithm 3 SMOOTH-COMPARE Input: Ti, Tj, Hij ⊆ N \ (Ti ∪ Tj), 1: Compare (cid:101)f (Ti ∪ H(cid:48) ij) with (cid:101)f (Tj ∪ H(cid:48) ij) for all H(cid:48) ij ⊂ Hij 2: if Ti won the majority of comparisons return Ti otherwise return Tj Lemma 2.6. Assume k ≥ 96(cid:96)/2. Let Ti be the set that won the SMOOTH-COMPARE tournament. Then, with probability at least 1 − 1/n2: f (Ti) ≥(cid:16) (cid:17) (cid:26)(cid:18) (cid:19) 1 −  3 min 1 − 1 e − 2 3 OPT, max j∈[1/δ] f (Tj) (cid:27) The proof of this lemma has two parts. 1. First we show in Claim B.8 that if a set Ti has moderately larger value than another set Tj (more specifically, if the gap is 1 − δ/3) then as long as f (Tj) is not arbitrarily close to (1−1/e)OPT then f (Ti∪H(cid:48) ij ⊆ Hij. At a high level, this ij) is larger than f (Tj ∪H(cid:48) is because elements in H(cid:48) ij are candidates for SMOOTH-GREEDY and the fact that they are not selected indicates that their marginal contribution to Tj = Sj ∪ Hj is low. Thus, elements in ij cannot add much value, and since Hij (cid:28) k adding subsets of Hij does not distort the H(cid:48) comparison by much. If f (Tj) is arbitrarily close to (1 − 1/e)OPT, we may have that Tj beats Ti, but this would still ultimately result in an approximation arbitrarily close to 1 − 1/e; ij), for any H(cid:48) 2. The next step (Claim B.9) then shows that if for every H(cid:48) ij we have f (Ti ∪ H(cid:48) ij) ≥ f (Tj ∪ H(cid:48) ij) then with high probability Ti wins the comparison against Tj in SMOOTH-COMPARE. Using these two parts we then conclude since we are running the SMOOTH-COMPARE tournament between 1/δ sets, the winner is an (1 − δ/3)1/δ ≥ (1 − /3) approximation to the competing set with the highest value or a set whose approximation is arbitrarily close to 1 − 1/e. The claims and proofs can be found in Appendix B. 2.2.4 Approximation guarantee of SLICK GREEDY Finally, putting everything together, we can prove the main result of this section (see Appendix ??). Theorem 2.1. Let f : 2N → R be a monotone submodular function. For any fixed  > 0, when k ≥ 3168 log log n/2, then given access to a noisy oracle whose noise distribution has a generalized exponential tail, the SLICK-GREEDY algorithm returns a set which is a (1−1/e−) approximation to maxS:S≤k f (S), with probability at least 1 − 1/n. 11 3 Optimization for Small k When k is small we cannot use the smoothing technique from the previous section, since it requires including the smoothing set of size Θ(log log n) in the solution. In this section we describe the sampled mean method which can be applied to k ∈ Ω(1/) ∩ O(log log n) and results in a 1 − 1/e −  approximation. This result is obtained by applying a greedy algorithm on a surrogate function F : 2N → R+ which is what we call the sampled mean of f. The use of the surrogate function makes it relatively easy to obtain the 1 − 1/e −  approximation, albeit in expectation. The main technical challenge is the transition from a guarantee that holds in expectation to one that holds with high probability. This difficulty is what limits this method to be applicable only when k ranges between Ω(1/) and O(log log n), and heavily exploits the generalized exponential tail property. 3.1 Combinatorial averaging a noisy value oracle (cid:101)f : Rn → R which for each point x ∈ Rn returns (cid:101)f (x) = ξxf (x) where ξx ∼ D. The sampled-mean method is based on averaging sets to find elements whose marginal contri- bution is high, which can then be greedily added to the solution. The intuition for this method comes from continuous optimization. Consider optimizing a function f : Rn → R given access to A natural approach would be to sample t points x1, . . . , xt from an -ball B around x, for some small  > 0, and estimate the value of x using the sampled mean: (cid:101)F (x) := E(cid:104)(cid:101)f (x) (cid:105) (cid:88) xi∼B (cid:101)f (xi) = 1 t Under some smoothness assumptions on f, for sufficiently large t and small , concentration bounds kick in, and one can apply an optimization algorithm on (cid:101)F to optimize f. The method in this section translates this idea to a combinatorial domain. To do so effectively, rather than consid- ering singletons a ∈ N we obtain multidimensionality by considering bundles of size c ∈ O(1/). Definition. Let f : 2N → R. For a set S ⊆ N and bundle A ⊆ N of fixed size c, we define Aij := (A \ {ai}) ∪ {aj} for ai ∈ A and aj /∈ S ∪ A, and t = c(n − c − S). The mean value, noisy mean value, and mean marginal contribution of A given S are, respectively: (1) (2) (3) F (S ∪ A) := (cid:101)F (S ∪ A) := E [f (S ∪ Aij)] = E(cid:104)(cid:101)f (S ∪ Aij) (cid:105) = FS(A) := E [fS(Aij)] = 1 t 1 t 1 t f (S ∪ Aij); (cid:101)f (S ∪ Aij); fS(Aij). i∈A j /∈S∪A (cid:88) (cid:88) (cid:88) i∈A (cid:88) (cid:88) (cid:88) j /∈S∪A i∈A j /∈S∪A The above definition mimics the continuous case by considering a bundle of elements A of fixed size c (we will use c ≈ 1/) as a point, and the points in the -ball are modeled by all the sets Aij obtained by replacing an element from A with an element from N \ (S ∪ A). We illustrate this idea in Figure 2. Although the combinatorial analogue is not as well-behaved as the continuous case, the sampled mean approach defined here extracts some of its desirable properties. 12 3.2 The Sampled Mean Greedy Algorithm The SM-GREEDY begins with the empty set S and at every iteration considers all bundles of size c ∈ O(1/) to add to S. At every iteration, the algorithm first identifies the bundle A which max- imizes the noisy mean value. After identifying A, it then considers all possible bundles Aij and takes the one whose noisy mean value is largest. We describe the algorithm formally below. (cid:5) do c Algorithm 4 SM-GREEDY Input: budget k, precision  > 0, c ∈ O( 1  ) 1: S ← ∅ 2: while S < c ·(cid:4) k 3: A ← argmaxB:B=c (cid:101)F (S ∪ B) S ← S ∪ arg maxi∈A,j /∈S∪A (cid:101)f (S ∪ Aij) 4: 5: end while 6: return S At a high level, the major steps in the analysis can be described as follows. 1. We begin with smoothing guarantees. In Lemma 3.2 we apply Lemma 3.1 as well as other ar- guments to show that w.h.p. in each iteration A ∈ argmaxB:B=c (cid:101)F (S∪B) well approximates the bundle with maximal (non-noisy) mean marginal contribution argmaxB:B=c FS(B); 2. Lemma 3.3 argues that if the marginal contribution fS( A) of the set A we select at every itera- tion is close to the mean marginal contribution FS(A) we obtain an approximation arbitrarily close to 1 − 1/e. This suffices for an approximation guarantee that holds in expectation; 3. The last step is Lemma 3.4 which is the technical crux of this section. We show that taking A ∈ argmaxi,j (cid:101)f (S ∪ Aij) in line 4 of the algorithm gives us, with sufficiently high probability that the marginal contribution fS( A) is arbitrarily close to the mean marginal contribution FS(A). We can therefore invoke Lemma 3.3 and recover the optimal approximation guarantee. 3.3 Smoothing Guarantees We first show that the largest marginal contribution is well approximated by its mean contribution. Lemma 3.1. For any  > 0 and any set S ⊂ N, let A(cid:63) ∈ arg maxA:A=1/ fS(A). Then: (1 − ) fS(A(cid:63)) ≤ FS(A(cid:63)) ≤ fS(A(cid:63)). The proof is in Appendix C and exploits a natural property of submodular functions: the removal of a random element from a large set does not significantly affect its value, in expectation. Significant iterations. Similar to the previous section, we define an assumption on the iterations of the algorithm which allows us to employ the smoothing technique in this section. 13 Figure 2: An illustration of the smoothing neighborhood. In this example N = {a1, a2, a3}, and the bundle we wish to evaluate is A = {a1, a2}. We think of A as a point in R3 and the smoothing neighborhood of A = (1, 1, 0) is the points A1,3 = {a2, a3} = (0, 1, 1) and A2,3 = {a1, a3} = (1, 0, 1). The circle illustrates the ball surrounding A. Definition. Let B ∈ argmaxB:B=c fS(B). An iteration of SM-GREEDY is -significant if for the given set S selected before the iteration we have that fS(B) ≥ ·c·OPT . k The following lemma implies that at every step we add a bundle whose smooth marginal contri- bution is comparable with the largest smooth marginal contribution obtainable. Lemma 3.2. Let A ∈ argmaxB:B=c (cid:101)F (S∪B) where c ≥ 16 Then, with probability at least 1 − e−Ω(n1/10) we have that: FS(A) ≥ (1 − ) max B:B=c FS(B).  , and assume that the iteration is  4-significant. The proof relies on arguments from the smoothing framework (Appendix A). In this case, the application of smoothing is a bit subtle as we do not apply smoothing on the noisy version of F directly. The proof uses Lemma 3.1 above as well as Claim C.2 which bounds the variation in values of sets A(cid:63) ij, when A(cid:63) ∈ argmaxB:B=c fS(B). Details and proofs are in Appendix C. 3.4 Approximation Guarantee in Expectation Lemma 3.3. Let δ > 0 and assume k > 16/δ2, c = 16/δ. Suppose that in every δ/4-significant iteration of SM-GREEDY when S are the elements selected in previous iterations, A ∈ argmaxB:B=c (cid:101)F (S ∪ B), the bundle added A respects fS( A) ≥ (1− δ)FS(A). Let ¯S be the solution after (cid:98)k/c(cid:99) iterations. Then, w.p. ≥ 1 − 1/n2: f ( ¯S) = (1 − 1/e − 5δ)OPT. This lemma implicitly proves an approximation guarantee that holds in expectation. This is simply because we know that if we choose A = A \ {ai} ∪ {aj} uniformly at random over all choices of i ∈ [c], aj /∈ S ∪ A we get E[fS( A)] = FS(A) > (1 − δ)FS(A) in every iteration, and thus by Lemma 3.3 we would be arbitrarily close to 1 − 1/e, in expectation over all our choices. 14 A = {a1, a2}A1,3 = {a2, a3}A2,3 = {a1, a3} 3.5 From Expectation to High Probability From Lemma 3.2 we know that A ∈ argmaxB:B=c (cid:101)F (S ∪ B) has mean marginal contribution desired approximation guarantee, we need to show that when A ∈ argmaxi∈[c],j /∈S∪A (cid:101)f (S ∪ Aij) arbitrarily close to maxB:B=c FS(B), but for Lemma 3.3 to hold we need the true marginal con- tribution fS( A) to be arbitrarily close to maxB:B=c FS(B). Simply adding A can easily lead to an arbitrarily bad approximation (see Appendix F ). In order to prove that SM-GREEDY provides the then with sufficiently high probability fS( A) is arbitrarily close to FS(A) as required by Lemma 3.3. A ∈ argmaxB:B=c (cid:101)F (S ∪ B). We will define two kinds of sets in {Aij}i∈[c],j /∈S∪A, called good and High-level overview to show high probability guarantee. Let A(cid:63) ∈ argmaxB:B=c fS(B) and fS(B) ≤ (1 − 3)fS(A(cid:63)). Our goal is to prove argmax{(cid:101)f (S ∪ Aij) : ai ∈ A, aj /∈ S ∪ A} is w.h.p. not bad. A good set is a set G for which fS(G) ≥ (1 − 2)fS(A(cid:63)) and a bad set is a set B for which bad. Doing so implies that in every iteration w.h.p. we add a bundle whose true marginal value is at least (1− 3) of fS(A(cid:63)) which is an upper bound on maxB:B=c FS(B) (and thus also on FS(A)). Lemma 3.4. For any  > 0, suppose we run SM-GREEDY where in each iteration we add a bundle of size c = 16/. For any /8-significant iteration where the set previously selected is S : S ∈ O(log log n), let A ∈ argmax(cid:101)F (S ∪ A) and A = argmax(i,j)∈A×N\S∪A (cid:101)f (S ∪ Aij). Then, w.p. ≥ 1 − 3/ log n we have: fS( A) ≥ (1 − 3)FS(A). At a high level, the proof follows the following steps: 1. In Claim C.4 we show that for A ∈ argmaxB:B=c (cid:101)F (S ∪ B), at least half of the sets in {Aij}i∈A,j /∈S∪A are good, and at most half are bad; 2. Next, we define two thresholds: θg and θb. Intuitively, θg is a lower bound on the maximum of noise multipliers from the good sets, and θb is an upper bound on the maximum of noise multipliers from bad sets. We then show in Lemma C.8 that θg ≥ (1 − γ) θb, for any γ = Ω(1/ log log n). This lemma is quite technical, and it is where we fully leverage the property of the generalized exponential tail distribution and the fact that k ∈ O(log log n); 3. From θg ≥ (1 − γ) θb and Claim C.4 we can prove that w.h.p. there is at least one good set whose noisy value is sufficiently larger than the noisy value of a bad set. The fact that a bad set loses to a good set implies that the value of the set we end up selecting must at least be as high as that of a bad set, i.e. fS( A) ≥ (1− 3)fS(A(cid:63)). Notice that by definition fS(A(cid:63)) is an upper bound on FS(B) for any bundle B of size c which therefore completes the proof. Lemma 3.4 above essentially tells us that at every iteration we select the bundle whose marginal contribution is almost maximal. Together with previous arguments from this section, this proves our main theorem for the case in which k ∈ Ω(1/2) ∩ O(log log n). For k ∈ Ω( 1 2 ) we run a single iteration of SM-GREEDY with c = k (o.w. the approximation is ≈ 1/2, when k = 2c − 1). 2N → R and  > 0, when Theorem 3.5. For any monotone submodular function f k ∈ Ω(1/) ∩ O(log log n), there is a (1 − 1/e − ) approximation for maxS:S≤k f (S), with probability 1 − 4/ log n given access to a noisy oracle whose distribution has a generalized exponential tail.  ) ∩ O( 1 : 15 4 Optimization for Very Small k The smoothing guarantee from the previous section actually necessitates selecting bundles of size c ∈ Θ(1/) and does not apply to very small values of k ∈ O(1/)3. For small constants we propose a different algorithm that uses a different smoothing technique. The algorithm is simple and ap- plies the same principles as the ones from the previous section. We show that this simple algorithm obtains an approximation ratio arbitrarily close to 1 − 1/e w.h.p. when k > 2 and in expectation when k = 2. For k = 1 we get arbitrarily close to 1/2, which is tight. We show lower bounds for small values of k and in particular when k = 1 show that no algorithm can obtain an expected approximation ratio better than 1/2 + o(1). All proofs and details are in Appendix D. 4.1 Smoothing Guarantees The smoothing here is straightforward. For every set A consider the smoothing neighborhood H(A) = {A ∪ x : x /∈ A}, F (A) = EX∈H(A)[f (X)] and (cid:101)F (A) = EX∈H(A)[(cid:101)f (X)]. Lemma 4.1. Let A ∈ argmaxB:B=k (cid:101)F (B). Then, for any fixed  > 0 w.p. 1 − e−Ω(2(n−k)): F (A) ≥ (1 − ) max B:B=k F (B). 4.2 An Approximation Algorithm for Very Small k dom set of k elements from a random set of H(A) where A ∈ argmaxB:B=k (cid:101)F (B). For any constant Approximation guarantee in expectation. The algorithm will simply select the set A to be a ran- k and any fixed  > 0 this is a (k/(k + 1) − ) approximation in expectation (see Theorem D.1). High probability. To obtain a result that holds w.h.p. we will consider a modest variant of the algorithm above. The algorithm enumerates all possible subsets of size k− 1, and identifies the set A ∈ argmaxB:B=k−1 (cid:101)F (B). The algorithm then returns A ∈ argmaxX∈H(A) (cid:101)f (X). Theorem 4.2. For any submodular function f : 2N → R and any fixed  > 0 and constant k, there is a (1 − 1/k − )-approximation algorithm for maxS:S≤k f (S) which only uses a generalized exponential tail noisy oracle, and succeeds with probability at least 1 − 6/ log n. 4.3 Information Theoretic Lower Bounds for Constant k Surprisingly, even for k = 1 no algorithm can obtain an approximation better than 1/2, which proves a separation between large and small k. In Claim D.2 we show no randomized algorithm n) for maxa∈N f (a), and √ with a noisy oracle can obtain an approximation better than 1/2 + O(1/ in Claim D.3 approximation better than (2k − 1)/2k + O(1/ n) for the optimal set of size k. √ 3The dependency on  originates in Claim C.2 where we bound on the variation of c− 1 sets A-i, and thus smoothing depends on c ≥ 4/. 16 5 Extensions In this section we consider extensions of the optimization under noise model. In particular, we show that the algorithms can be applied to several related problems: additive noise, marginal noise, correlated noise, degradation of information, and approximate submodularity. 5.1 Additive Noise return (cid:101)f (S) = ξS·f (S). An alternative model is one where the noise is additive, i.e. (cid:101)f (S) = f (S)+ξS, Throughout this paper we assumed the noise is multiplicative, i.e. we defined the noisy oracle to where ξS ∼ D. The impossibility results for adversarial noise apply to the additive case as well. From a modeling perspective, the fact that the noise may be independent of the value of the set queried may be an advantage or a disadvantage, depending on the setting. From a technical per- spective, the problem remains non-trivial. Fortunately, all the algorithms described above apply to the additive noise model, modulo the smoothing arguments which become straightforward. That is, we still need to apply smoothing on the surrogate functions, but it is easy to show arguments like A ∈ argmaxB (cid:101)F (S∪B) implies w.h.p. FS(A) ≥ (1−δ) maxb FS(B). In the additive noise model: (cid:101)F (S ∪ A) = (cid:101)f (S ∪ X) = (cid:88) (f (S ∪ X) + ξS∪X ) = f (S ∪ X) + (cid:88) X∈H(A) X∈H(A) (cid:88) X∈H(A) (cid:88) ξS∪X X∈H(X) Thus, by applying a concentration bound we can show that a set A whose smooth value is maximal implies that its non-noisy smooth marginal contribution FS(A) is approximately maximal as well. 5.2 Marginal Noise An alternative noise model is one where the noise acts on the marginals of the distribution. In this model, a query to the oracle is a pair of sets S, T ⊆ N and the oracle returns ξS,T · fS(T ) in the multiplicative marginal noise model and fS(T ) + ξS,T in the additive marginal noise model. Adversarial additive marginal noise is generally impossible. If the error is adversarial, and the noise is additive, the lower bound of 6.1 follows for any magnitude of the noise. Letting  denote the maximal magnitude of the noise, we consider a function in which no element ever gives a contribution higher than , and then getting marginal information does not help. Adversarial multiplicative marginal noise is approximable. but multiplicative within factor α, it is well known one can obtain a 1 − 1/eα approximation. If the marginal error is adversarial Marginal i.i.d noise is approximable. If one is allowed to query the oracle on any two sets S, T and get ξS,T ·fS(T ) (or fS(T )+ξS,T ) where ξS,T is drawn i.i.d for any pair S, T , then one can simply apply all the algorithms and analysis as is, by always considering f∅(S ∪ T ). If one is only allowed 17 to query S, T where T = 1, the algorithms still work, but we need to be careful with the analysis, since we need to show that we are calling the oracle on different sets. It is easy to show that if the noise is weak and multiplicative (e.g. ξ ∈ [1− , 1 + ]) we can obtain a (1− 1/e− ) approximation. 5.3 Correlated Noise As discussed in the Introduction, Theorem 6.1 implies that no algorithm can optimize a monotone submodular function under a cardinality constraint given access to a noisy oracle whose noise multipliers are arbitrarily correlated across sets, even when the support of the distribution is ar- bitrarily small. In light of this, one may wish to consider special cases of correlated distributions. We first show that even very simple correlations can result in inapproxiability. We then show an interesting class of distributions we call d-correlated, for which optimal guarantees are obtainable. Impossibility result for correlated distributions. Having taken the first step showing algo- rithms for the i.i.d. in space model, a natural question is whether this assumption is necessary. Theorem 5.1. Even for unit demand functions there are simple space-correlated distributions for which no algorithm can achieve an approximation strictly better than 1/n. Proof. Consider a unit demand function f (S) = maxa∈S f (a) which operates on a ground set with n elements. There are n − 1 regular elements and one special element a(cid:63). The value of f on any regular element is 1, but f (a(cid:63)) = M for some arbitrarily large M. The noise distribution is such that it returns 1 on sets which do not contain a(cid:63), and 1/M on sets that contain a(cid:63). The best one can do in this case is to choose a random element without querying the oracle at all. Guarantees for d-correlated distributions. Our algorithms can be extended to a model in which querying similar sets may return results that are arbitrarily correlated, as long as querying sets which are sufficiently far from each other gives independent answers. Definition. We say that the noise distribution is d-correlated if for any two sets S and T , such that S \ T + T \ S > d we have that the noise is applied independently to S and to T . Notice that if a distribution is d-correlated, any two points on the hypercube at distance at most d can be arbitrarily correlated. For this model we show that when k ∈ Ω(log log n) then we can obtain an approximation arbitrarily close to 1 − 1/e for O( k)-correlated distributions. Alternatively, in this regime we can get this approximation guarantee for any distribution that is arbitrarily When k ∈ Ω(log log n) we can get arbitrarily close to 1 − 1/e for O(1)-correlated noise. correlated when querying two sets S, T whose symmetric difference is larger than(cid:112)max{T,S}. √ √ Modification of algorithms for large k for k-correlated noise. For large k, if we have that k (cid:29) d2, then the approximation guarantee we get is still arbitrarily close to 1 − 1/e even when D is d-correlated. To do this, we modify the smoothing neighborhood and the definition of smooth 18 values as follows. Recall that in SMOOTH-GREEDY, we select an arbitrary set of elements H of size (cid:96) for smoothing, and compute the noisy smooth value of S ∪ a by averaging all subsets of H: (cid:101)F (S ∪ a) = 1 2(cid:96) (cid:101)f(cid:0)S ∪(cid:0)a ∪ H(cid:48)(cid:1)(cid:1) . (cid:88) H(cid:48)⊂H In the d-correlated case, for each 1 ≤ i ≤ d and 1 ≤ j ≤ (cid:96) we choose a bundle h(i)j of d elements, such that every two bundles are disjoint. Denote H(i) = {h(i)1, . . . h(i)(cid:96), and H = (cid:100)i,jh(i)j the set of all elements we used. The noisy smooth value with smoothing set H(i) is now: (cid:101)F (i)(S ∪ a) = 1 2(cid:96) (cid:88) H(cid:48)⊂H(i) (cid:101)f (S ∪ a ∪ H(cid:48)) where we abuse notation and use S ∪ a ∪ H(cid:48) instead of S ∪ {a} ∪h(i)j∈H(cid:48) h(i)j. We will run SMOOTH-GREEDY with the smoothing sets H(1), . . . , H(d), where in each iteration i mod d we use H(i) as the smoothing set. Exactly as in the original algorithm, we generate S by iteratively adding k−H elements from N \ H that maximize the smooth value in every iteration, and we then return S ∪ H. As before, SLICK- GREEDY employs SMOOTH-GREEDY. To prove correctness of the algorithm we need to show that the evaluations of the surrogate func- tions are independent. We will first show by induction on S that between iterations, the oracle calls are independent. Claim 5.2. Any oracle call at iteration i is independent of any previous oracle call at iteration r < i. Proof. Let S(i) be the set of elements we have already committed to in stage i. Consider an eval- uation of (cid:101)f (S(i) ∪ a ∪ H(cid:48)) for some non empty H(cid:48) ⊂ H(i mod d) at iteration i, and an oracle evaluation (cid:101)f (S(r)∪ b∪ H(cid:48)(cid:48)) made at some iteration r < s with some non empty H(cid:48)(cid:48) ⊂ H(r mod d) and b /∈ S(r) ∪ H. If r ≤ i − d, then the symmetric difference between S(i) ∪ a and S(r) ∪ b is at least of size d. Since a, b /∈ H, and S(i) ∩ H = ∅, this means that the symmetric difference of S(i) ∪ a ∪ H(cid:48) and S(r) ∪ b ∪ H(cid:48)(cid:48) is at least of size d, for any H(cid:48)(cid:48) ⊂ H(r mod d), and thus the calls are independent. If r > s− d, then i mod d (cid:54)= r mod d, and hence S(i)∪ a∪ H(cid:48) and S(r)∪ b∪ H(cid:48)(cid:48) are independent because of the symmetric difference between H(cid:48) and H(cid:48)(cid:48). Claim 5.3. When evaluating (cid:101)F (i)(S ∪ a), all noise multipliers are independent. Proof. When evaluating (cid:101)F (i)(S ∪ a) we call the noisy oracle on sets of the form S ∪ a ∪ H(cid:48). Since each H(cid:48) corresponds to a different subset of H(i), and H(i) is a collection of (cid:96) bundles of size d, the symmetric difference between every two sets H(cid:48), H(cid:48)(cid:48) ⊆ H(i), is at least d. As in the original SMOOTH-GREEDY procedure, we can show that at every iteration, when S is the set of elements we selected in previous iterations, an element a added to S implies that w.h.p. F (S ∪ a) is arbitrarily close to maxb /∈H F (S ∪ b) (see Claim 5.3). Let a1, a2, . . . an−S−H denote the elements which are being considered. For each element ai, we have that if F (S ∪ ai) is non 19 inverse polynomially small and there are only n−S−H events, we can take a union bound and negligible then w.h.p (cid:101)F (S ∪ ai) approximates F (S ∪ ai), and if F (S ∪ ai) is negligible then so is (cid:101)F (S ∪ ai). While for ai, aj these events may well be correlated, since the probability of failure is say that with high probability for every i if F (S ∪ ai) is negligible so is (cid:101)F (S ∪ ai), and if F (S ∪ ai) is non negligible then it is well approximated by (cid:101)F (S ∪ ai). Thus, we know that at every iteration i when S is the set of elements selected in previous iterations, we have selected the element a that is arbitrarily close to maxb /∈H F (i)(S ∪ b). From the arguments in the paper we know that this implies that for an arbitrarily small γ > 0 we have: fS(a) ≥ (1 − γ)fS∪H(i)(b) ≥ (1 − γ)fS∪H (b) where the right inequality is due to submodularity and the fact that H(i) ⊆ H. The guarantees of SMOOTH-GREEDY therefore apply in this case as well. What remains to show is that SLICK- GREEDY is unaffected by this modification. This is easy to verify as SLICK-GREEDY takes 1/δ dis- joint sets H1, . . . , H1/δ, and the arguments discussed apply for every such set. Since we apply SMOOTH-COMPARE 1/δ times with sets of size (cid:96) it is easy to implement as well. Modification of algorithms for small k for O(1)-correlated noise. A similar idea works also for the small k case, assuming d is constant. In this case, we add c (cid:29) d/ elements at each phase of the algorithm. We modify the definition of (cid:101)F in the following way. First we take a an arbitrary partition P1, . . . P(n−S)/d on the elements not in S, in which each Pi is of size d, and a partition Q1 . . . Q(S+A)/d of the elements in S ∪ A. We estimate the value of a set A given S using: (cid:101)f (((S ∪ A) \ Qi) ∪ Pj) (cid:101)F (S ∪ A) = Qi ∈ A d2 (S + A)(N − S − A) (cid:88) (cid:88) Pj and modify the rest of the algorithm accordingly. Correctness relies on three steps: 1. First, when we are in iteration i of the algorithm (after we already added (i − 1)c elements to S), all the sets we apply the oracle on are of size c · i, and hence they are independent of any set of size c(i − 1) or less which were used in previous phases; 2. Second, when we evaluate (cid:101)F (S ∪ A) for a specific set A, we only use sets which are indepen- dent in the comparison. Here we rely on changing d elements in A each time, and replacing them by another set of d elements; 3. Finally, we treat each set A separately, and show that if its marginal contribution is negligible then w.h.p its mean smooth value is not too large, and if its marginal contribution is not negligible, then w.h.p. (cid:101)F (S ∪ A) approximates F (S ∪ A) well. Taking a union bound over all the bad events we get that the set A chosen has large (non-noisy) smooth mean value. 5.4 Information Degradation We have written the paper as if the algorithm gains no additional information for querying a point twice. The generalization to a case where the algorithm gets more information each time but there 20 is a degradation of information is simple: whenever the algorithms we presented here want to query a point just query it multiple times, and feed the expected value of the point given all the information one has to the algorithm. Hence it makes sense to focus on the extreme case where only the first query is helpful, as common in the literature of noisy optimization (e.g. [12]) 5.5 Approximate Submodularity In this paper our goal is to obtain near optimal guarantees as defined on the original function that was distorted through noise. That is, we assume that there is an underlying submodular function which we aim to optimize, and we only get to observe noisy samples of it. An alternative direction would be to consider the problem of optimizing functions that are approximately submodular: (cid:101)f (S) max S:S≤k The notion of approximate submodularity has been studied in machine learning [67, 23, 22, 33]. More generally, given the desirable guarantees of submodular functions, it is interesting to under- stand the limits of efficient optimization with respect to the function classes we aim to optimize. Impossibility for -adversarial approximation. If we assume that the function is an adversarial (1 ± ) approximation of a submodular function, our lower bound from Section 6 for erroneous oracles implies that no polynomial time algorithm can obtain a non-trivial approximation. Trivial reduction for noise in [1−, 1+]. When D ⊆ [1−, 1+], and the noise is i.i.d across sets, the algorithms in the paper obtain a solution arbitrarily close to (cid:1) of maxS:S≤k (cid:101)f (S). (cid:16) 1− 1+ (cid:17)(cid:0)1 − 1 e Impossibility for unbounded noise. If we assume that a noisy process of a distribution with unbounded support altered a submodular function, then there are trivial impossibility results. Suppose that the initial submodular function is the constant function that gives 1 to every set. If we apply (e.g.) Gaussian noise to it, then the optimal algorithm is just to try random sets and hope for the best, and no polynomial time algorithm can achieve a constant factor approximation. Optimal approximation via black-box reduction. First, note that there is an algorithm which runs in time nk and finds the optimal subset of size k: query (cid:101)f on all subsets of size at most k, √ and choose the maximal one. Notice that this is in contrast to the setting we study throughout the paper in which there is a lower bound of (2k − 1)/2k + O(1/ n). The interesting regime is k = ω(1), where there is a black-box reduction from the problem of maximizing a submod- ular function given an approximately submodular function, to the problem of maximizing an approximately submodular function. Since we can solve the original problem within a factor ar- bitrarily close to 1 − 1/e we get an optimal approximation guarantee in this case as well. Let maxD(t) = E[maxξ1,...ξt∼D{ξ1, . . . , ξt}] be the expected maximum value of t i.i.d samples of D. 21 Lemma 5.4. An algorithm which uses t ≤(cid:0)n k (cid:1) queries to (cid:101)f cannot achieve approximation ratio better than: maxD((cid:0)n maxD(t) (cid:1)) . k Proof. Suppose that f (S) = 1 for every set S. The best that the algorithm can do is query t sets with at most k elements, and output the maximal one. The approximation ratio of this is exactly maxD(t) (cid:1)) maxD((cid:0)n k If the algorithm queries sets with more than k elements, the approximation would deteriorate. Lemma 5.5. Suppose there exists an algorithm which given k ∈ ω(1) returns a solution S s.t. f (S) ≥ γ maxT :T≤k f (T ) using q queries to a noisy oracle. Then, for any t ∈ poly(n) there is an algorithm that uses q + t to a noisy oracle and returns a solution S(cid:48) s.t.: (cid:33) (cid:17)(cid:32) (cid:101)f (S(cid:48)) ≥(cid:16) (cid:1) ≥ t. Since t is polynomial in n, we have that r is constant. Run the maxD((cid:0)n (cid:1)) (cid:101)f (T ). maxD(t) γ − o(1) max T :T≤k k Proof. Let r be such that(cid:0)n−k algorithm to obtain a set G of size k − r. From submodularity and the fact that r is constant: r f (G) ≥ γ max f (S) ≥ (1 − r/k)γ max S:S≤k f (S) ≥ (1 − o(1))γ max S:S≤k S:S≤k−r For every set of r elements {x1, . . . , xr} where xi (cid:54)∈ G, the algorithm queries (cid:101)f on G ∪ {x1, . . . xr}, and chooses the set with maximum value. It is easy to see that the expected value of this set would be at least maxD(t)(1 − r/k)γ maxS:S≤k f (S), which gives the ratio. f (S) 22 6 Impossibility for Adversarial Noise In this section we show that there are very simple submodular functions for which no randomized algorithm with access to an -erroneous oracle can obtain a reasonable approximation guarantee with a subexponential number of queries to the oracle. Intuitively, the main idea behind this result is to show that a noisy oracle can make it difficult to distinguish between two functions whose values can be very far from one another. The functions we use are similar to those used to prove information theoretic lower bounds for submodular optimization and learning [79, 84, 36, 8, 95]. Theorem 6.1. No randomized algorithm can obtain an approximation strictly better than O(n−1/2+δ) to maximizing monotone submodular functions under a cardinality constraint using enδ /n queries to an -erroneous oracle, for any fixed , δ < 1/2. Proof. We will consider the problem of maxS:S≤k f (S) where k = n1/2+δ. Let X ⊆ N be a random set constructed by including every element from N with probability n−1/2+δ. We will use this set to construct two functions that are close in expectation but whose maxima have a large gap, and show that access to a noisy oracle implies distinguishing between these two functions. The functions are: (cid:110)S ∩ X · n1/2 + n1/2+δ (cid:110)S · nδ + n1/2+δ ,S · n1+δ(cid:111) ,S · n1+δ(cid:111)  • f1(S) = min • f2(S) = min  Notice that both functions are normalized monotone submodular: when S = ∅ both functions evaluate to 0, and otherwise are affine. By the Chernoff bound we know that X ≥ n1/2+δ/2 with probability 1 − e−Ω(n1/2+δ). Conditioned on this event we have that maxS:S≤k f1(S) = f1(X) ∈ O(n1+δ) whereas f2 is symmetric and maxS:S≤k f2(S) ∈ O(n1/2+2δ). Thus, an inability to distin- guish between these two functions implies there is no approximation algorithm with approxima- tion better than O(n−1/2+δ). We define the erroneous oracle as follows. If the function is f2, its oracle returns the exact same value as f2 for any given set. Otherwise, the function is f1 and its erroneous oracle is defined as: (cid:40) (cid:101)f (S) = f2(S), f1(S) if (1 − )f1(S) ≤ f2(S) ≤ (1 + )f1(S) otherwise Notice that this oracle is -erroneous, by definition. (cid:101)f can distinguish between f1 and f2, with exponentially high probability (equivalently, we will Suppose now that the set X is unknown to the algorithm, and the objective is maxS:S≤k f1(S). We will first show that no deterministic algorithm that uses a single query to the erroneous oracle show that a single query to the algorithm cannot find a set S for which f1(S) < (1 − )f2(S) or f1(S) > (1 + )f2(S) with exponentially high probability). For a single query algorithm, we can imagine that the set X is chosen after the algorithm chooses which query to invoke, and compute the success probability over the choice of X. In this case, all the elements are symmetric, and the function value is only determined by the size of the set that the single-query algorithm queries. 23 In case the query is a set S of cardinality smaller or equal to n1/2, by the Chernoff bound we have that S ∩ X ≤ (1 + β)nδ for any β < 1 with probability at least 1 − e−Ω(β2nδ). Thus: ≤ f1(S) ≤ (cid:16) ≤ f2(S) ≤ n1/2+δ  n1/2+δ  (cid:17) (cid:17) 1  1  1 + β + (cid:16) 1 + n1/2+δ n1/2+δ It is easy to verify that for β < /(1 − ): (1 − )f1(S) ≤ f2(S) ≤ (1 + )f1(S). Thus, for any query of size less or equal to n1/2 the likelihood of the oracle returning f1 is 1 − e−Ω(nδ). In case the oracle queries a set of size greater than n1/2 then again by the Chernoff bound, for any β < 1 we have that with probability at least 1 − e−Ω(β2n1/2): (cid:16) (cid:17) S n1/2−δ ≤ S ∩ X ≤(cid:16) 1 + β (cid:17) S n1/2−δ 1 − β For β ≤ /(1 − ), this implies that: (1 − )f1(S) ≤ f2(S) ≤ (1 + )f1(S) Therefore, for any fixed  ∈ (0, 1), the algorithm cannot distinguish between f1 and f2 with prob- ability 1 − e−Ω(nδ) by querying the erroneous oracle with a set larger than n1/2. To conclude, by a union bound we get that with probability 1− e−Ω(nδ) no algorithm can distinguish between f1 and f2 using a single query to the erroneous oracle, and the ratio between their maxima is O(n1/2−δ). To complete the proof, suppose we had an algorithm running in time enδ /n which can approxi- mate the value of a submodular function, given access to an -erroneous oracle with approxima- tion ratio strictly better than O(n−1/2+δ) which succeeds with probability 2/3. This would let us solve the following decision problem: Given access to an -erroneous oracle for either f1 or f2, determine which function is being queried. To solve the decision problem, given access to an erroneous oracle of unknown function, we would use the hypothetical approximation algorithm to estimate the value of the maximal set of size n1/2+δ. If this value is strictly more than n1/2+2δ, the function is f1 (since f1(X) = O(n1+δ)), and otherwise it is f2. The reduction allows us to show that distinguishing between the functions in time enδ /n and success probability 2/3 is impossible. For purpose of contradiction, suppose that there is a (ran- domized) algorithm for the decision problem, and let p denote the probability that it outputs f2 if it sees an oracle which is fully consistent with f2. To succeed with probability 2/3, it must be the case that whenever the algorithm gets f1 as an input, it finds a set S for which the noisy oracle returns f1(S) with probability at least 2/3− p/2 ≥ 1/6. Whenever it finds such a set, the algorithm is done, since it can compute f2(S) without calling the oracle, and hence it knows that f1 was chosen in the decision problem. In this case, we know that the algorithm makes up to enδ /n queries, until it sees a set for which it gets f1(S). But this means that there is an algorithm with success probability at least O(n/6enδ ) that makes a single query. This algorithm guesses some index i < enδ /n, and simulates the original algorithm for i− 1 steps (by feeding it with f2 without using the oracle), and then using the oracle 24 in step i. If the algorithm guesses i to be the first index in which the exponential time algorithm sees f1(S), then the single query algorithm would succeed. Hence, since we showed that no single query (randomized) algorithm can find a set S such that f1(S) < (1−)f2(S) or f1(S) > (1+)f2(S) with just one query this concludes the proof. The following remarks are worth mentioning: • The functions we used in the lower bound are very simple examples of coverage functions; • If one does not require the function to be normalized, then the lower bound holds for affine functions, i.e. f (S) =(cid:80) a∈S f (a) + C, where C independent of S; • The lower bound is tight: for any -erroneous oracle there is a 1− mation by simply partitioning the ground sets to arbitrary sets of size min{√ 1+ · max{n−1/2, 1/k} approxi- n, k}, and select the set whose value according to the erroneous oracle is maximal; • The lower bound applies to additive noise by simply applying an additive version of the Chernoff bound. classes of submodular functions such as additive functions (f (S) = (cid:80) Somewhat surprisingly, the above theorem suggests that a good approximation to a submodular function does not suffice to obtain reasonable approximation guarantees. In particular, guarantees from learning or sketching where the goal is to approximate a submodular function up to constant factors may not necessarily be meaningful for optimization. It is important to note that for some a∈S f (a)), we can obtain algorithms that are robust to adversarial noise. A very interesting open question is to characterize the class of submodular functions that are robust to adversarial noise. 25 7 More related work Submodular optimization. Maximizing monotone submodular functions under cardinality and matroid constraints is heavily studied. The seminal works of [80, 46] show that the greedy algo- rithm gives a factor of 1−1/e for maximizing a submodular function under a cardinality constraint and a factor 1/2 approximation for matroid constraints. For max-cover which is a special case of maximizing a submodular function under a cardinality constraint, Feige shows that no poly-time algorithm can obtain an approximation better than 1-1/e unless P=NP [35]. Vondrak presented the continuous greedy algorithm which gives a 1 − 1/e ratio for maximizing a monotone submodular function under matroid constraints [94]. This is optimal, also in the value oracle model [79, 61, 81]. It is interesting to note that with a demand oracle the approximation ratio is strictly better than 1 − 1/e [39]. When the function is not monotone, constant factor approximation algorithms are known to be obtainable as well [37, 73, 14, 15]. In general, in the past decade there has been a development in the theory of submodular optimization, through concave relaxations [1, 19], the multilinear relaxation [18, 94, 20], and general rounding technique frameworks [96]. In this paper, the techniques we develop arise from first principles: we only rely on basic properties of sub- modular functions, concentration bounds, and the algorithms are variants of the standard greedy algorithm. Submodular optimization in game theory. Submodular functions have been studied in game theory almost fifty years ago [90]. In mechanism design submodular functions are used to model agents' valuations [74] and have been extensively studied in the context of combinatorial auctions (e.g. [27, 28, 26, 79, 16, 25, 83, 32, 29]). Maximizing submodular functions under cardinality con- straints have been studied in the context of combinatorial public projects [84, 87, 17, 78] where the focus is on showing the computational hardness associated with not knowing agents valuations and having to resort to incentive compatible algorithms. Our adversarial lower bound implies that if agents err in their valuations, optimization may be hard, regardless of incentive constraints. Submodular optimization in machine learning. In the past decade submodular optimization has become a central tool in machine learning and data mining (see surveys [65, 66, 11]). Problems include identifying influencers in social networks [59, 86] sensor placement [75, 50], learning in data streams [92, 52, 71, 5], information summarization [76, 77], adaptive learning [51], vision [58, 57, 63], and general inference methods [64, 57, 24]. In many cases the submodular function is learned from data, and our work aims to address the case in which there is potential for noise in the model. Learning submodular functions. One of the main motivations we had for studying optimiza- tion under noise is to understand whether submodular functions that are learned from data can be optimized well. The standard framework in the literature for learning set functions is Probably Mostly Approximately Correct (PMAC) learnability due to Balcan and Harvey [9]. This framework nicely generalizes Valiant's notion of Probably Approximately Correct (PAC) learnability [93]. Infor- mally, PMAC-learnability guarantees that after observing polynomially-many samples of sets and 26 their function values, one can construct a surrogate function that is with constant probability over the distributions generating the samples, likely to be an approximation of the submodular func- tion generating the data. Since the seminal paper of Balcan and Harvey there has been a great deal of work on learnability of submodular functions [41, 7, 4, 43, 45, 6]. As discussed in the paper, our lower bounds imply that one cannot optimize the surrogate function PMAC learned from data. If the approximation is via i.i.d noise on sets sufficiently far, this may be possible. Approximate submodularity. The concept of approximate submodularity has been studied in machine learning for dictionary selection and feature selection in linear regression [67, 23, 22, 33]. Generally speaking, this line of work considers approximate submodularity by defining a notion of the submodularity ratio of a function, defined in terms of how close it is to have a diminishing returns property. This ratio depends on the instance, which in the worst-case may result in a func- tion that poorly approximates a submodular function. In practice however, these works show that in a broad range of applications the functions of interest are sufficiently close to submodular. Re- cently, the notion of approximate modularity (i.e. additivity) has been studied in [21] which give an optimal algorithm for approximating an approximately modular function via a modular func- tion. These notions of approximate modularity and approximate submodularity are the model in which we have noise on the marginals. As discussed in Section 5, if the error on the marginals is adversarial, there are regimes in which non-trivial guarantees are impossible. If one assumes the marginal approximations are i.i.d our positive results apply. Combinatorial optimization under noise. Combinatorial optimization with noisy inputs can be largely studied through consistent (independent noisy answers when querying the oracle twice) and inconsistent oracles. For inconsistent oracles, it usually suffices to repeat every query O(log n) times, and eliminate the noise. To the best of our knowledge, submodular optimization has been studied under noise only in instances where the oracle is inconsistent or equivalently small enough so that it does not affect the optimization [59, 68]. One line of work studies methods for reducing the number of samples required for optimization (see e.g. [38, 10]), primarily for sort- ing and finding elements. On the other hand, if two identical queries to the oracle always yield the same result, the noise can not be averaged out so easily, and one needs to settle for approximate solutions, which has been studied in the context of tournaments and rankings [60, 12, 2]. Convex optimization under noise. Maximizing functions under noise is also an important topic in convex optimization. The analogue of our model here is one where there is a zeroth-order noisy oracle to a convex function. As discussed in the paper, the question of polynomial-time algorithms for noisy convex optimization is straightforward and the work in this area largely aims at improving the convergence rate [34, 47, 62, 72, 85]. 27 8 Acknowledgements A.H. was supported by ISF 1241/12; Y.S. was supported by NSF grant CCF-1301976, CAREER CCF-1452961, a Google Faculty Research Award, and a Facebook Faculty Gift. We thank Vitaly Feldman who pointed out the application to active learning. We are deeply indebted to Lior See- man, who has carefully read previous versions of the manuscript and made multiple invaluable suggestions. 28 References [1] Alexander A. Ageev and Maxim Sviridenko. Pipage rounding: A new method of constructing algorithms with proven performance guarantee. J. Comb. Optim., 8(3), 2004. [2] Miklós Ajtai, Vitaly Feldman, Avinatan Hassidim, and Jelani Nelson. Sorting and selection with imprecise comparisons. In Automata, Languages and Programming, pages 37–48. Springer, 2009. [3] Dana Angluin. Queries and concept learning. Machine Learning, 2(4):319–342, 1988. [4] 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 2012, Kyoto, Japan, January 17-19, 2012, pages 1025–1035, 2012. [5] 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 '14, New York, NY, USA - August 24 - 27, 2014, pages 671–680, 2014. [6] Maria-Florina Balcan. Learning submodular functions with applications to multi-agent sys- tems. In Proceedings of the 2015 International Conference on Autonomous Agents and Multiagent Systems, AAMAS 2015, Istanbul, Turkey, May 4-8, 2015, page 3, 2015. [7] Maria-Florina Balcan, Florin Constantin, Satoru Iwata, and Lei Wang. Learning valuation In COLT 2012 - The 25th Annual Conference on Learning Theory, June 25-27, 2012, functions. Edinburgh, Scotland, pages 4.1–4.24, 2012. [8] Maria-Florina Balcan and Nicholas J. A. Harvey. Learning submodular functions. In Proceed- ings of the 43rd ACM Symposium on Theory of Computing, STOC 2011, San Jose, CA, USA, 6-8 June 2011, pages 793–802, 2011. [9] Maria-Florina Balcan and Nicholas J. A. Harvey. Learning submodular functions. In Proceed- ings of the 43rd ACM Symposium on Theory of Computing, STOC 2011, San Jose, CA, USA, 6-8 June 2011, pages 793–802, 2011. [10] Michael Ben Or and Avinatan Hassidim. The bayesian learner is optimal for noisy binary In Foundations of Computer Science, 2008. search (and pretty good for quantum as well). FOCS'08. IEEE 49th Annual IEEE Symposium on, pages 221–230. IEEE, 2008. [11] J. Bilmes. Deep mathematical properties of submodularity with applications to machine learning. Tutorial at the Conference on Neural Information Processing Systems (NIPS), 2013. [12] Mark Braverman and Elchanan Mossel. Noisy sorting without resampling. In Proceedings of the nineteenth annual ACM-SIAM symposium on Discrete algorithms, pages 268–276. Society for Industrial and Applied Mathematics, 2008. [13] Nader H. Bshouty and Vitaly Feldman. On using extended statistical queries to avoid mem- bership queries. Journal of Machine Learning Research, 2:359–395, 2002. 29 [14] Niv Buchbinder, Moran Feldman, Joseph Naor, and Roy Schwartz. A tight linear time (1/2)- approximation for unconstrained submodular maximization. In 53rd Annual IEEE Symposium on Foundations of Computer Science, FOCS 2012, New Brunswick, NJ, USA, October 20-23, 2012, pages 649–658, 2012. [15] Niv Buchbinder, Moran Feldman, Joseph Naor, and Roy Schwartz. Submodular maximiza- tion with cardinality constraints. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Sym- posium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1433–1452, 2014. [16] D. Buchfuhrer, S. Dughmi, H. Fu, R. Kleinberg, E. Mossel, C. H. Papadimitriou, M. Schapira, Y. Singer, and C. Umans. Inapproximability for VCG-based combinatorial auctions. In SIAM- ACM Symposium on Discrete Algorithms (SODA), pages 518–536, 2010. [17] D. Buchfuhrer, M. Schapira, and Y. Singer. Computation and incentives in combinatorial public projects. In EC, pages 33–42, 2010. [18] Gruia Calinescu, Chandra Chekuri, Martin Pál, and Jan Vondrák. Maximizing a submodular set function subject to a matroid constraint. In Integer programming and combinatorial optimiza- tion, pages 182–196. Springer, 2007. [19] Chandra Chekuri and Alina Ene. Approximation algorithms for submodular multiway par- tition. In IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS 2011, Palm Springs, CA, USA, October 22-25, 2011, pages 807–816, 2011. [20] Chandra Chekuri, T. S. Jayram, and Jan Vondrák. On multiplicative weight updates for con- cave and submodular function maximization. In Proceedings of the 2015 Conference on Inno- vations in Theoretical Computer Science, ITCS 2015, Rehovot, Israel, January 11-13, 2015, pages 201–210, 2015. [21] Flavio Chierichetti, Abhimanyu Das, Anirban Dasgupta, and Ravi Kumar. Approximate modularity. In IEEE 56th Annual Symposium on Foundations of Computer Science, FOCS 2015, Berkeley, CA, USA, 17-20 October, 2015, pages 1143–1162, 2015. [22] Abhimanyu Das, Anirban Dasgupta, and Ravi Kumar. Selecting diverse features via spectral regularization. In Advances in Neural Information Processing Systems 25: 26th Annual Conference on Neural Information Processing Systems 2012. Proceedings of a meeting held December 3-6, 2012, Lake Tahoe, Nevada, United States., pages 1592–1600, 2012. [23] Abhimanyu Das and David Kempe. Submodular meets spectral: Greedy algorithms for sub- set selection, sparse approximation and dictionary selection. In Proceedings of the 28th Inter- national Conference on Machine Learning, ICML 2011, Bellevue, Washington, USA, June 28 - July 2, 2011, pages 1057–1064, 2011. [24] J. Djolonga and A. Krause. From MAP to marginals: Variational inference in bayesian sub- modular models. In Advances in Neural Information Processing Systems (NIPS), 2014. [25] Shahar Dobzinski, Hu Fu, and Robert D. Kleinberg. Optimal auctions with correlated bidders are easy. In STOC, pages 129–138, 2011. 30 [26] Shahar Dobzinski, Ron Lavi, and Noam Nisan. Multi-unit auctions with budget limits. In FOCS, 2008. [27] Shahar Dobzinski, Noam Nisan, and Michael Schapira. Approximation algorithms for com- binatorial auctions with complement-free bidders. In STOC, pages 610–618, 2005. [28] Shahar Dobzinski and Michael Schapira. An improved approximation algorithm for com- binatorial auctions with submodular bidders. In Proceedings of the seventeenth annual ACM- SIAM symposium on Discrete algorithm, pages 1064–1073. Society for Industrial and Applied Mathematics, 2006. [29] Shahar Dobzinski and Jan Vondrák. The computational complexity of truthfulness in combi- natorial auctions. In EC, pages 405–422, 2012. [30] N. Du, Y. Liang, M. Balcan, and L. Song. Influence function learning in information diffusion networks. In Int. Conference on Machine Learning (ICML), pages 2016–2024, 2014. [31] N. Du, Y. Liang, M. Balcan, and L. Song. Learning time-varying coverage functions. In Advances in Neural Information Processing Systems (NIPS), pages 3374–3382, 2014. [32] Shaddin Dughmi, Tim Roughgarden, and Qiqi Yan. From convex optimization to random- ized mechanisms: toward optimal combinatorial auctions. In STOC, pages 149–158, 2011. [33] Ethan R. Elenberg, Rajiv Khanna, Alexandros G. Dimakis, and Sahand Negahban. Restricted strong convexity implies weak submodularity. In Preprint. [34] Clemens Elster and Arnold Neumaier. A grid algorithm for bound constrained optimization of noisy functions. IMA Journal of Numerical Analysis, 15(4):585–608, 1995. [35] Uriel Feige. A threshold of ln n for approximating set cover. Journal of the ACM (JACM), 45(4):634–652, 1998. [36] Uriel Feige, Vahab S. Mirrokni, and Jan Vondrák. Maximizing non-monotone submodular functions. SIAM J. Comput., 40(4):1133–1153, 2011. [37] Uriel Feige, Vahab S Mirrokni, and Jan Vondrak. Maximizing non-monotone submodular functions. SIAM Journal on Computing, 40(4):1133–1153, 2011. [38] Uriel Feige, Prabhakar Raghavan, David Peleg, and Eli Upfal. Computing with noisy infor- mation. SIAM Journal on Computing, 23(5):1001–1018, 1994. [39] Uriel Feige and Jan Vondrak. Approximation algorithms for allocation problems: Improv- ing the factor of 1-1/e. In Foundations of Computer Science, 2006. FOCS'06. 47th Annual IEEE Symposium on, pages 667–676. IEEE, 2006. [40] Vitaly Feldman. On the power of membership queries in agnostic learning. Journal of Machine Learning Research, 10:163–182, 2009. [41] Vitaly Feldman and Pravesh Kothari. Learning coverage functions and private release of In Proceedings of The 27th Conference on Learning Theory, COLT 2014, Barcelona, marginals. Spain, June 13-15, 2014, pages 679–702, 2014. 31 [42] Vitaly Feldman, Pravesh Kothari, and Jan Vondrák. Representation, approximation and In COLT 2013 - The 26th learning of submodular functions using low-rank decision trees. Annual Conference on Learning Theory, June 12-14, 2013, Princeton University, NJ, USA, pages 711–740, 2013. [43] Vitaly Feldman and Jan Vondrák. Optimal bounds on approximation of submodular and XOS functions by juntas. In 54th Annual IEEE Symposium on Foundations of Computer Science, FOCS 2013, 26-29 October, 2013, Berkeley, CA, USA, pages 227–236, 2013. [44] Vitaly Feldman and Jan Vondrák. Tight bounds on low-degree spectral concentration of sub- modular and XOS functions. CoRR, abs/1504.03391, 2015. [45] Vitaly Feldman and Jan Vondrák. Tight bounds on low-degree spectral concentration of sub- modular and xos functions. In Foundations of Computer Science (FOCS), 2015 IEEE 56th Annual Symposium on, pages 923–942. IEEE, 2015. [46] Marshall L Fisher, George L Nemhauser, and Laurence A Wolsey. An analysis of approximations for maximizing submodular set functions-II. Springer, 1978. [47] Torkel Glad and Allen Goldstein. Optimization of functions whose values are subject to small errors. BIT Numerical Mathematics, 17(2):160–169, 1977. [48] Michel X Goemans, Nicholas JA Harvey, Satoru Iwata, and Vahab Mirrokni. Approximating submodular functions everywhere. In Proceedings of the twentieth Annual ACM-SIAM Sympo- sium on Discrete Algorithms, pages 535–544. Society for Industrial and Applied Mathematics, 2009. [49] Sally A. Goldman, Michael J. Kearns, and Robert E. Schapire. Exact identification of circuits In Proceedings of the Third Annual using fixed points of amplification functions (abstract). Workshop on Computational Learning Theory, COLT 1990, University of Rochester, Rochester, NY, USA, August 6-8, 1990., page 388, 1990. [50] D. Golovin, M. Faulkner, and A. Krause. Online distributed sensor selection. In IPSN, 2010. [51] D. Golovin and A. Krause. Adaptive submodularity: Theory and applications in active learn- ing and stochastic optimization. JAIR, 42:427–486, 2011. [52] R. Gomes and A. Krause. Budgeted nonparametric learning from data streams. In Int. Con- ference on Machine Learning (ICML), 2010. [53] Trevor J. Hastie, Robert John Tibshirani, and Jerome H. Friedman. The elements of statistical learning : data mining, inference, and prediction. Springer series in statistics. Springer, New York, 2009. Autres impressions : 2011 (corr.), 2013 (7e corr.). [54] Thibaut Horel, Stratis Ioannidis, and S. Muthukrishnan. Budget feasible mechanisms for experimental design. In LATIN 2014: Theoretical Informatics - 11th Latin American Symposium, Montevideo, Uruguay, March 31 - April 4, 2014. Proceedings, pages 719–730, 2014. [55] Jeffrey C. Jackson. An efficient membership-query algorithm for learning DNF with respect In 35th Annual Symposium on Foundations of Computer Science, to the uniform distribution. Santa Fe, New Mexico, USA, 20-22 November 1994, pages 42–53, 1994. 32 [56] Jeffrey C. Jackson, Eli Shamir, and Clara Shwartzman. Learning with queries corrupted by classification noise. Discrete Applied Mathematics, 92(2-3):157–175, 1999. [57] S. Jegelka and J. Bilmes. Approximation bounds for inference using cooperative cuts. In Int. Conference on Machine Learning (ICML), 2011. [58] S. Jegelka and J. Bilmes. Submodularity beyond submodular energies: Coupling edges in graph cuts. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 1897– 1904, 2011. [59] D. Kempe, J. Kleinberg, and E. Tardos. Maximizing the spread of influence through a social network. In ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD), 2003. [60] Claire Kenyon-Mathieu and Warren Schudy. How to rank with few errors. In Proceedings of the thirty-ninth annual ACM symposium on Theory of computing, pages 95–103. ACM, 2007. [61] Subhash Khot, Richard J Lipton, Evangelos Markakis, and Aranyak Mehta. bility results for combinatorial auctions with submodular utility functions. Network Economics, pages 92–101. Springer, 2005. Inapproxima- In Internet and [62] André I Khuri and John A Cornell. Response surfaces: designs and analyses, volume 152. CRC press, 1996. [63] P. Kohli, A. Osokin, and S. Jegelka. A principled deep random field for image segmentation. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2013. [64] A. Krause and C. Guestrin. Nonmyopic active learning of gaussian processes. an exploration– exploitation approach. In Int. Conference on Machine Learning (ICML), 2007. [65] A. Krause and C. Guestrin. Submodularity and its applications in optimized information gathering. ACM Trans. on Int. Systems and Technology, 2(4), 2011. [66] A. Krause and S. Jegelka. Submodularity in Machine Learning: New directions. Tutorial at the International Conference on Machine Learning (ICML), 2013. [67] Andreas Krause and Volkan Cevher. Submodular dictionary selection for sparse represen- tation. In Proceedings of the 27th International Conference on Machine Learning (ICML-10), June 21-24, 2010, Haifa, Israel, pages 567–574, 2010. [68] Andreas Krause and Carlos Guestrin. A note on the budgeted maximization of submodular functions. In Technical Report, 2005. [69] Andreas Krause, H. Brendan McMahan, Carlos Guestrin, and Anupam Gupta. Selecting ob- servations against adversarial objectives. In Advances in Neural Information Processing Systems 20, Proceedings of the Twenty-First Annual Conference on Neural Information Processing Systems, Vancouver, British Columbia, Canada, December 3-6, 2007, pages 777–784, 2007. [70] Andreas Krause, Ajit Paul Singh, and Carlos Guestrin. Near-optimal sensor placements in Journal of Machine gaussian processes: Theory, efficient algorithms and empirical studies. Learning Research, 9:235–284, 2008. 33 [71] Ravi Kumar, Benjamin Moseley, Sergei Vassilvitskii, and Andrea Vattani. Fast greedy algo- rithms in mapreduce and streaming. In SPAA, 2013. [72] Harold J Kushner and Dean S Clark. Stochastic Approximation Methods for Constrained and Unconstrained Systems (Applied Mathematical Sciences, Vol. 26), volume 8. Springer, 1978. [73] Jon Lee, Vahab S. Mirrokni, Viswanath Nagarajan, and Maxim Sviridenko. Non-monotone submodular maximization under matroid and knapsack constraints. In Proceedings of the 41st Annual ACM Symposium on Theory of Computing, STOC 2009, Bethesda, MD, USA, May 31 - June 2, 2009, pages 323–332, 2009. [74] Benny Lehmann, Daniel Lehmann, and Noam Nisan. Combinatorial auctions with decreas- ing marginal utilities. In ACM conference on electronic commerce, 2001. [75] J. Leskovec, A. Krause, C. Guestrin, C. Faloutsos, J. VanBriesen, and N. Glance. Cost-effective outbreak detection in networks. In ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD), 2007. [76] H. Lin and J. Bilmes. A class of submodular functions for document summarization. In ACL/HLT, 2011. [77] H. Lin and J. Bilmes. Optimal selection of limited vocabulary speech corpora. In Proc. Inter- speech, 2011. [78] Brendan Lucier, Yaron Singer, Vasilis Syrgkanis, and Éva Tardos. Equilibrium in combinato- rial public projects. In WINE, pages 347–360, 2013. [79] Vahab S. Mirrokni, Michael Schapira, and Jan Vondrák. Tight information-theoretic lower bounds for welfare maximization in combinatorial auctions. In Proceedings 9th ACM Confer- ence on Electronic Commerce (EC-2008), Chicago, IL, USA, June 8-12, 2008, pages 70–77, 2008. [80] George L Nemhauser, Laurence A Wolsey, and Marshall L Fisher. An analysis of approxima- tions for maximizing submodular set functions-i. Mathematical Programming, 14(1):265–294, 1978. [81] George L Nemhauser and Leonard A Wolsey. Best algorithms for approximating the maxi- mum of a submodular set function. Mathematics of operations research, 3(3):177–188, 1978. [82] G.L. Nemhauser, L.A. Wolsey, and M.L. Fisher. An analysis of approximations for maximiz- ing submodular set functions-I. Mathematical Programming, 14(1):265–294, 1978. [83] Christos H. Papadimitriou and George Pierrakos. On optimal single-item auctions. In STOC, pages 119–128, 2011. [84] Christos H. Papadimitriou, Michael Schapira, and Yaron Singer. On the hardness of being truthful. In 49th Annual IEEE Symposium on Foundations of Computer Science, FOCS 2008, Oc- tober 25-28, 2008, Philadelphia, PA, USA, pages 250–259, 2008. [85] Boris T Polyak. Introduction to optimization. Optimization Software New York, 1987. 34 [86] M. Gomez Rodriguez, J. Leskovec, and A. Krause. Inferring networks of diffusion and influ- ence. ACM TKDD, 5(4), 2011. [87] Michael Schapira and Yaron Singer. Inapproximability of combinatorial public projects. In WINE, pages 351–361, 2008. [88] Shai Shalev-Shwartz and Shai Ben-David. Understanding Machine Learning: From Theory to Algorithms. Cambridge University Press, New York, NY, USA, 2014. [89] Eli Shamir and Clara Schwartzman. Learning by extended statistical queries and its relation In Computational Learning Theory: Eurocolt '95, pages 357–366. Springer- to PAC learning. Verlag, 1995. [90] L. S. Shapley. Cores of convex games. International Journal of Game Theory, 1(1):11–26, 1971. [91] Adish Singla, Sebastian Tschiatschek, and Andreas Krause. Noisy submodular maximization via adaptive sampling with applications to crowdsourced image collection summarization. In Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence, February 12-17, 2016, Phoenix, Arizona, USA., pages 2037–2043, 2016. [92] M. Streeter, D. Golovin, and A. Krause. Online learning of assignments. In Advances in Neural Information Processing Systems (NIPS), 2009. [93] Leslie G. Valiant. A Theory of the Learnable. Commun. ACM, 1984. [94] Jan Vondrák. Optimal approximation for the submodular welfare problem in the value oracle model. In STOC, pages 67–74, 2008. [95] Jan Vondrák. Symmetry and approximability of submodular maximization problems. SIAM J. Comput., 42(1):265–304, 2013. [96] Jan Vondrák, Chandra Chekuri, and Rico Zenklusen. Submodular function maximization via the multilinear relaxation and contention resolution schemes. In Proceedings of the Forty-third Annual ACM Symposium on Theory of Computing, STOC '11, pages 783–792, New York, NY, USA, 2011. ACM. [97] Larry Wasserman. All of Statistics: A Concise Course in Statistical Inference. Springer Publishing Company, Incorporated, 2010. 35 Appendix 36 A Combinatorial Smoothing In this section we illustrate a general framework we call combinatorial smoothing that we will use in the subsequent sections. Intuitively, combinatorial smoothing mitigates the effects of noise and enables finding elements whose marginal contribution is large. Some intuition. Recall from our earlier discussion that implementing the greedy algorithm re- quires identifying arg max f (S ∪ a) for a given set S of elements selected by the algorithm in previous iterations. Thus, if for some a, b ∈ N we can compare S ∪ a and S ∪ b and decide whether f (S ∪ a) > f (S ∪ b) or vice versa, we can implement the greedy algorithm. Put differently, viewing a set as a point on the hypercube, given two points in {0, 1}n we need to be able to tell which one has the larger true value, using a noisy oracle. In a world of continuous optimization, a reasonable approach to estimate the true value of a point in [0, 1]n with access to a noisy oracle is to take a small neighborhood around the point, sample values of points in its neighborhood, and average their values. Taking polynomially-many samples allows concentration bounds to kick in, and us- ing a small enough diameter can often guarantee that the averaged value is a reasonable estimate of the point's true value. Surprisingly, the spirit of this idea can used in submodular optimization. Smoothing neighborhood. For a given subset A ⊆ N a smoothing function is a method which assigns a family of sets H(A) called the smoothing neighborhood. The smoothing function will be used to create a smoothing neighborhood for a small set A. This set A whose marginal contribution we aim to evaluate, is essentially a candidate for a greedy algorithm. In the application in Section 2 the set A is simply be a single element, whereas in Section 3 the set A is of size O(1/). Definition A.1. For a given function f : 2N → R, A, S ⊆ N, and smoothing neighborhood H(A): • FS(A) := EX∈H(A) [fS(X)] (called the smooth marginal contribution of A), • F (S ∪ A) := EX∈H(A) [f (S ∪ X)] (called the smooth value of S ∪ A) • (cid:101)F (S ∪ A) := EX∈H(A) (called the noisy smooth value of S ∪ A). (cid:104)(cid:101)f (S ∪ X) (cid:105) The idea behind combinatorial smoothing is to select a smoothing neighborhood which includes sets whose value is in some sense close to the value of the set A whose marginal contribution we wish to evaluate. Intuitively, when the sets are indeed close, by averaging the values of the sets in H(A) we can mitigate the effects of noise and produce meaningful statistics (see Figure 3). Smoothing arguments In our model, the algorithm may only access (cid:101)F (S ∪ A). Ideally, given a set S and a smoothing smooth value is arbitrarily close to the non-noisy smooth value, i.e. F (S ∪ A) ≈ (cid:101)F (S ∪ A) or: neighborhood H(A) we would have liked to apply concentration bounds and show that the noisy (cid:88) f (S ∪ Xi) ≈ (cid:88) ξif (S ∪ Xi) i∈H(A) i∈H(A) 37 (cid:113)(cid:80) Figure 3: An illustration of smoothing. For every element in the ground set we associate an index i ∈ [n] and define i∈S i/2 − c for a constant c > 0. The blue dot depicts the true value of the the submodular function as f (S) = element a associated with the index i = 400 and the red dot depicts the true value of the element b associated with the index j = 900. The light blue and light red dots depict the noisy function values of elements associated with indices i and H(b) = {i : i− b ≤ 100} we depict (cid:101)F (S ∪ a) and (cid:101)F (S ∪ b) as the blue and red triangles, respectively. Intuitively, an in the range i − 400 ≤ 100 and i − 900 ≤ 100. For S = ∅, and smoothing neighborhoods H(a) = {i : i − a ≤ 100} algorithm which needs to decide whether a (blue point) is larger than b (red point) will decide by comparing (cid:101)F (S ∪ a) (blue triangle) and (cid:101)F (S ∪ b) (red triangle). If the values in {f (S ∪ Xi)}H(A) i=1 were arbitrarily close, we could simply apply a concentration bound by taking the value of any one of the sets, say S ∪ Xj, and for vj = f (S ∪ Xj), since all the values are close, we would be guaranteed that: (cid:88) ξif (S ∪ Xi) ≈ (cid:88) ξif (S ∪ Xj) = vj · (cid:88) i∈H(A) i∈H(A) ξi i∈H(A) In continuous optimization this is usually the case when averaging over an arbitrarily small ball around the point of interest, and concentration bounds apply. In our case, due to the combinatorial nature of the problem, the values of the sets in the smoothing neighborhood may take on very dif- ferent values. For this reason we cannot simply apply concentration bounds. The purpose of this section is to provide machinery that overcomes this difficulty. The main ideas can be summarized as follows: 1. In general, there may be cases in which we cannot perform smoothing well and cannot get 38 020040060080010001200051015202530ifunction valuesll the noisy smooth values to be similar to the true smooth values. We therefore define a more modest, yet sufficient goal. Since our algorithms essentially try to replace the step of adding the element a ∈ argmaxb f (S ∪ b) in the greedy algorithm with a(cid:48) ∈ argmaxb F (S ∪ b), it suffices to guarantee that for the set A which maximizes the noisy smooth values, that show that if for an arbitrarily small δ > 0 we have that A ∈ argmaxB (cid:101)F (S ∪ B) then set also well approximates the (non-noisy) smooth values. More precisely our goal is to F (S ∪ A) ≥ (1 − δ) maxB F (S ∪ B); 2. To show that A ∈ argmax(cid:101)F (S∪A) implies F (S∪A) ≥ (1−δ) maxB F (S∪B) for an arbitrarily small δ > 0, we prove two bounds. Lemma A.4 lower bounds the noisy smooth contribution of a set in terms of its (true) smooth contribution. Lemma A.5 upper bounds the smooth noisy contribution of any element against its smooth contribution. The key difference be- tween these lemmas is that Lemma A.4 lower bounds the value in terms the variation of the smoothing neighborhood. The variation of the neighborhood is the ratio between the set with largest value and that with lowest value in the neighborhood. Intuitively, for elements with large values the variation of the neighborhood is bounded, and thus we can show that the noisy smooth value of these elements is nearly as high as their true smooth values. 3. Together, these lemmas are used in subsequent sections to show that an element with the largest noisy smooth marginal contribution is an arbitrarily good approximation to the ele- ment with the largest (non-noisy) smooth marginal contribution. This is achieved by show- ing that the lower bound on the smooth value of an element with large (non-noisy) smooth marginal contribution beats the upper bound on the smooth (non-noisy) value of an element with slightly smaller smooth contribution. The first lemma gives us tail bounds on the upper and lower bounds of the value of the noise multiplier in any of the calls made by a polynomial-time algorithm. We later use these tail bounds in concentration bounds we use in the smoothing procedures. Lemma A.2. Let ωmax = max{ξ1, . . . , ξm} and ωmin = min{ξ1, . . . , ξm}, where ξi ∼ D and D is a noise distribution with a generalized exponential tail. For any δ > 0 and sufficiently large m, we have that: • Pr[ωmax < mδ] > 1 − e−Ω(mδ/ ln m) • Pr[ωmin > m−δ] > 1 − e−Ω(mδ/ ln m) Proof. As m tends to infinity, this lemma trivial for any noise distribution which is bounded, or has finite support. If the noise distribution is unbounded, we know that its tail is subexponential. Thus, at any given sample the probability of seeing the value mδ is at most e−O(mδ) where the constant in the big O notation depends on the magnitude of the tail. Iterating this a polynomial number of times gives the bound. The proof of the lower bound is equivalent. The definition below of the variation of the neighborhood quantifies the ratio between the largest possible value and the smallest possible value achieved by a set in the neighborhood. 39 Definition A.3. For given sets A, S ⊆ N, the variation of the neighborhood denoted vS(H(A)) is: vS(H(A)) = maxT∈H(A) fS(T ) minT∈H(A) fS(T ) . The following lemma gives a lower bound on the noisy smooth value in terms of the (non-noisy) smooth value and the variation. Intuitively, when an element has large value its variation is bounded, and the lemma implies that its noisy smooth value is close to its smooth value. Es- sentially, when the variation is bounded (cid:101)F (S) ≈ (1 − λ)(1 − )F (S) for λ and  that vanish as n grows large. tion. For  = min(cid:8)1, 2vS(H) · H(A)−1/4(cid:9) for any λ < 1 w.p 1 − e−Ω( λ2t1/4 Lemma A.4. Let f : 2N → R, A, S ⊂ N, ω = maxAi∈H(A) ξAi, and µ be the mean of the noise distribu- (cid:101)F (S ∪ A) > (1 − λ)µ · (f (S) + (1 − ) · FS(A)) . ) we have: ω Proof. Let A1, . . . , At be the sets in H(A) and let α1, . . . , αt denote the corresponding marginal contributions and ξ1 . . . , ξt denote their noise multipliers. In these terms the noisy smooth value is: (cid:101)F (S ∪ A) = t(cid:88) i=1 1 t ξi(f (S) + αi) = 1 t ξif (S) + 1 t ξiαi. (1) t(cid:88) i=1 t(cid:88) i=1 Let ω be the upper bound on the value of the noise multiplier. Applying the Chernoff bound, we get that for any λ < 1 with probability at least 1 − e−Ω(λ2t/ω): t(cid:88) i=1 1 t ξif (S) ≥ (1 − λ)µf (S). To complete the proof we need to argue about concentration of the second term in (1). To do so, in our analysis we will consider a fine discretization of {αi}i∈[t] and apply concentration bounds on each discretized value. Define αmax = maxi∈[t] αi and αmin = mini∈[t] αi. We can divide the set of values {αi}i∈[t] to t1/4 bins BIN1, . . . , BINt1/4, where a value αi is placed in the bin BINq if (q − 1) · αmaxt−1/4 ≤ αi ≤ q · αmaxt−1/4 Say a bin is dense if it contains at least t1/4 values and sparse otherwise. Consider some dense bin BINq and let αmin(q) = mini∈BINq αi and αmax(q) = maxi∈BINq αi. Since every bin is of width αmax · t−1/4 we know that: Applying concentration bounds as above, we get that(cid:80) αmin(q) ≥ αmax(q) − αmax · t−1/4 ξi ≥ (1−λ)µ·BINq with probability i∈BINq 40 Taking a union bound over all (at most t1/4) dense bins, we get that with probability 1 − BINq · αmax(q) (2) e−Ω(λ2t1/4/ω):(cid:88) i∈dense (cid:80)t at least 1 − e−Ω(λ2t1/4/ω) for any λ < 1. Thus, with this probability: (cid:88) i∈BINq i∈BINq ξiαmin(q) > (1 − λ)µ · BINq · (cid:110) 0, αmax(q) − αmax · t−1/4(cid:111)(cid:17) ≥ (1 − λ)µ · BINq · αmin(q) (cid:26) (cid:27)(cid:19) max (cid:27)(cid:19) (cid:26) 0, 1 − vS (H(A)) · t−1/4(cid:111)(cid:17) (cid:110) ξiαi ≥ (cid:88) ≥ (1 − λ)µ · BINq ·(cid:16) (cid:18) (cid:18) = (1 − λ)µ · BINq ·(cid:16) (cid:110) 0, vS (H(A)) · t−1/4(cid:111)(cid:17) (cid:88) (cid:110) 0, 1 − vS (H(A)) · t−1/4(cid:111)(cid:17) (cid:88) ≥ (1 − λ)µ · BINq · 0, 1 − αmax αmax(q) 0, 1 − αmax αmin ξiαi ≥ (1 − λ)µ ·(cid:16) ≥ (1 − λ)µ ·(cid:16) 1 − max · t−1/4 · t−1/4 BINq∈dense max max max max αi. i∈dense αmax(q) αmax(q) αmax(q) Let α = 1 i=1 αi. Since we have less than t1/4 elements in a sparse bin, and in total t1/4 bins, the t number of elements in sparse bins is at most t1/2. We can use this to effectively lower bound the values in sparse bins in terms of α:(cid:88) αi = i∈dense t(cid:88) i=1 0, αi i∈sparse (cid:41) αi − t1/2αmax αi − (cid:88) (cid:40) t(cid:88) (cid:110) (cid:19) (cid:18) (cid:26) 1 − vS(H) · t−1/2(cid:17) (cid:110) 0, t ·(cid:16) 0, tα − t1/2αmax 1 − αmax 0, t · αmin · t−1/2 (cid:111) i=1 ≥ max ≥ max > max = max (cid:27) (cid:111) α α (3) 41 Putting (2) and (3) we get that for any λ < 1, with probability 1 − e−Ω(λ2t1/4/ω): (cid:101)FS(A) = t(cid:88) (cid:88) i=1 i∈dense ξi · αi ξi · αi 1 t ≥ 1 t ≥ (1 − λ)µ · (max ≥ (1 − λ)µ · (max > (1 − λ)µ · (max = (1 − λ)µ · (max (cid:110) 0, 1 − vS (H(A)) · t−1/4(cid:111) (cid:110) 0, 1 − vS (H(A)) · t−1/4(cid:111) (cid:110) 0, 1 − 2vS (H(A)) · t−1/4(cid:111) (cid:110) 0, 1 − 2vS (H(A)) · t−1/4(cid:111) ) · 1 t )(max )α )FS(A) (cid:88) (cid:110) 0, 1 − vS (H(A)) · t−1/2(cid:111) αi i∈dense )α Taking a union bound we get that for any positive λ < 1 with probability 1 − e−Ω(λ2t1/4/ω): t(cid:88) i=1 1 t ξif (S) + ξiαi (cid:101)F (S ∪ A) = 1 t t(cid:88) > (1 − λ)µ ·(cid:16) = (1 − λ)µ ·(cid:16) i=1 (cid:110) (cid:110) f (S) + (max f (S) + (1 − min 0, 1 − 2vS(H(A)) · t−1/4) · FS(A) 1, 2vS(H(A)) · t−1/4) · FS(A) (cid:111)(cid:17) (cid:111)(cid:17) . small λ > 0 we have that (cid:101)F (S) ≈ (1 + λ)F (S) + 3t−1/4 · αmax. In our applications of smoothing The next lemma gives us an upper bound on the noisy smooth value. The bound shows that for sufficiently large t (the size of the smoothing neighborhood, which always depends on n), for αmax ≤ OPT, and t is large. Since we use this upper bound to compare against elements whose value is at least some bounded factor of OPT, the dependency of the additive term on αmax will be insignificant. Lemma A.5. Let f : 2N → R, A, S ⊆ N, ω = maxAi∈H(A) ξAi, αmax = maxAi∈H(A) fS(Ai) and µ be the mean of the noise distribution. For  = 3t−1/4αmax we have that for any λ < 1 with probability 1 − e−Ω(λ2t1/4/ω): (cid:101)F (S ∪ A) < (1 + λ)µ · (f (S) + FS(A) + ) . Proof. As in the proof of Lemma A.4 let A1, . . . , At denote the sets in H(A), and for each set Ai we will again use αi to denote the marginal value fS(Ai) and ξi to denote the noise multiplier ξS∪{Ai}. (cid:101)F (S ∪ A) = t(cid:88) i=1 1 t t(cid:88) i=1 ξif (S) + 1 t ξiαi. (4) As before, we will focus on showing concentration on the second term. Define αmax = maxi αi and αmin = mini αi. To apply concentration bounds on the second term, we again partition the values of {αi}i∈[t] to bins of width αmax · t−1/4 and call a bin dense if it has at least t1/4 values and sparse 42 otherwise. Using this terminology: t(cid:88) i=1 (cid:88) i∈dense ξiαi + (cid:88) i∈sparse ξiαi. ξiαi = Let BIN(cid:96) be the dense bin whose elements have the largest values. Consider the t1/4/2 largest values in BIN(cid:96) and call the set of indices associated with these values L. We have: t(cid:88) i=1 (cid:88) (cid:88) ξiαi = ξiαi + ξiαi i∈dense\L i∈L∪sparse The set L∪ sparse is of size at least t1/4/2 and at most t1/4/2 + t1/2. This is because L is of size exactly t1/4/2 and there are at most t1/2 values in bins that are sparse since there are t1/4 bins and a bin that has at least t1/4 is already considered dense. Thus, when ω is an upper bound on the value of the noise multiplier, from Chernoff, for any λ < 1 with probability 1 − e−Ω(λ2t1/4/ω): (cid:88) ξiαi ≤ (cid:88) i∈L∪sparse i∈L∪sparse ξiαmax (cid:32) (cid:33) < (1 + λ)µ · L ∪ sparse · αmax ≤ (1 + λ)µ · < (1 + λ)µ · 2t1/2αmax t1/4 2 + t1/2 αmax We will now use the same logic as in the proof of Lemma A.4 to apply concentration bounds on the values in the dense bins. For a dense bin BINq, let αmax(q) and αmin(q) be the maximal and minimal values in the bin, respectively. As in Lemma A.4, for any λ < 1 with probability 1 − e−Ω(λ2t1/4/ω): (cid:88) i∈BINq i∈BINq ξi · αmax(q) ≤ (1 + λ)µ · αmax(q) · BINq αmin(q) + αmax · t−1/4(cid:17) · BINq ξiαi ≤ (cid:88) ≤ (1 + λ)µ ·(cid:16) < (1 + λ)µ ·(cid:16)BINq · αmin(q) + BINqαmax · t−1/4(cid:17) (1 + λ)µ ·(cid:16)BINq · αmin(q) + BINqαmax · t−1/4(cid:17) (cid:88) ξiαi < (cid:88) i∈dense\L (cid:16) q < (1 + λ)µ · t Applying a union bound we get with probability 1 − e−Ω(λ2t1/4/ω): (cid:17) α + t−1/4αmax 43 Together we have: t(cid:88) i=1 1 t ξiαi = 1 t  (cid:88) < (1 + λ)µ ·(cid:16) < (1 + λ)µ ·(cid:16) < (1 + λ)µ ·(cid:16) i∈dense\L (cid:88) i∈L∪sparse ξiαi + ξiαi (cid:17) α + t−1/4αmax + 2t−1/2αmax α + 3t−1/4αmax FS(A) + 3t−1/4αmax  (cid:17) (cid:17) By a union bound we get that with probability 1 − e−Ω(λ2t1/4/ω): (cid:101)F (S ∪ A) = t(cid:88) i=1 1 t ξif (S) + 1 t t(cid:88) ξiαi ≤ (1 + λ)µ ·(cid:16) f (S) + FS(A) + 3t−1/4αmax (cid:17) . i=1 44 B Optimization for Large k The Smooth Greedy Algorithm Smoothing guarantees the set of elements selected in previous iterations and a ∈ arg maxb /∈H (cid:101)F (S ∪ b). Then for δ = 2/4k and Lemma (2.1). For any fixed  > 0, consider an -relevant iteration of SMOOTH-GREEDY where S is sufficiently large n we have that w.p. ≥ 1 − 1/n4: FS(a) ≥ (1 − δ) max b /∈H FS(b). To prove the above lemma we will need claims B.1, B.2 and B.3. After proving B.3 the proof will follow by verifying that the number of sets in the smoothing set is sufficient to obtain the desired approximation (1 − δ). Claim B.1. If FS(a) ≥ FS(b) then fS(a) ≥ fS∪H (b). Proof. Assume for purpose of contradiction that fS(a) < fS∪H (b). Since f is a submodular func- tion, fS(T ) = f (S ∪ T ) − f (S) is also submodular (hence also subadditive). Therefore ∀H(cid:48) ⊆ H: fS(H(cid:48) ∪ a) ≤ fS(H(cid:48)) + fS(a) < fS(H(cid:48)) + fS∪H (b) ≤ fS(H(cid:48)) + fS∪H(cid:48)(b) = fS(H(cid:48) ∪ b). (cid:88) H(cid:48)⊆H FS(a) = 1 t fS(H(cid:48) ∪ a) < 1 t subadditivity of fS by assumption submodularity of fS fS(H(cid:48) ∪ b) = FS(b). (cid:88) H(cid:48)⊆H Notice however, that this contradicts our assumption: The following claim bounds the variation (see Definition A.3) of the smoothing neighborhood of the element we selected. This is a necessary property for later applying the smoothing arguments. Claim B.2. Let  > 0. For an -relevant iteration of SMOOTH-GREEDY, let S be the set of elements selected in previous iterations. If a(cid:63) ∈ arg maxa /∈H FS(a) then vS (H(a(cid:63))) < 3k/. Proof. Let b(cid:63) ∈ argmaxb /∈H fH∪S(b). By the maximality of a(cid:63) we have that FS(a(cid:63)) ≥ FS(b(cid:63)), and thus by Claim B.1 we get fS(a(cid:63)) ≥ fH∪S(b(cid:63)). Since the iteration is -relevant we have that fH∪S(b(cid:63)) ≥  · OPTH /k, and from monotonicity of f we get: fS(H(cid:48) ∪ a(cid:63)) ≥ fS(a(cid:63)) ≥ fH∪S(b(cid:63)) ≥  · OPTH k min H(cid:48)⊆H and since every set in H(a(cid:63)) is of size at most k we know that maxH(cid:48)⊆H fS(H(cid:48)∪a(cid:63)) ≤ OPT. Together with the fact that OPT ≤ e · OPTH we get: vS (H(a(cid:63))) = maxH(cid:48)⊆H fS(H(cid:48) ∪ a(cid:63)) minH(cid:48)⊆H fS(H(cid:48) ∪ a(cid:63)) ≤ OPT OPTH · k  < 3k  . 45 We can now show that in -relevant iterations the value of the element which maximizes the noisy smooth value is comparable to that of the (non-noisy) smooth value, with high probability. Recall that we use t to denote the size of the smoothing neighborhood. Claim B.3. Given  > 0 assume t ≥(cid:16) 110k·log n S be the elements selected in previous iterations and a ∈ arg maxb /∈H (cid:101)F (S ∪ b). Then, w.p. ≥ 1 − 1/n4: . For an -relevant iteration of SMOOTH-GREEDY, let (cid:17)8 δ FS(a) ≥ (1 − δ) max b /∈H FS(b). Proof. Let a(cid:63) be the element which maximizes smooth marginal contribution: a(cid:63) ∈ argmaxb /∈H FS(a) We will show that for any element b whose smooth marginal contribution is a factor of (1 − δ) smaller than the smooth marginal contribution of a(cid:63), then w.h.p. its noisy value of is smaller than with probability at least Ω(1 − 1/n5). The result will then follow by taking a union bound over all that of a(cid:63). That is, for any b /∈ H for which FS(b) < (1 − δ)FS(a(cid:63)) we get that (cid:101)F (S ∪ b) < (cid:101)F (S ∪ a(cid:63)) comparisons. We will show that a(cid:63) likely beats b by lower bounding (cid:101)F (S∪a(cid:63)) and upper bounding (cid:101)F (S ∪ b) using the smoothing arguments from the previous section. We use ω to denote the value • Lower bound on (cid:101)F (S ∪ a(cid:63)): First, from Claim B.2 we know that vS(H(a(cid:63))) ≤ 3k/. Together of the largest noise multiplier realized throughout the iterations of the algorithm. We later argue that we can upper bound ω ≤ 6 log n as the noise distribution has an exponentially decaying tail. with Lemma A.4 we get that ∀λ < 1 with probability 1 − e−Ω(λ2t1/4/ω): (cid:101)F (S ∪ a(cid:63)) > (1 − λ)µ ·(cid:16) (cid:18) (cid:19) (cid:17) • Upper bound on (cid:101)F (S ∪ b): Letting βmax = maxX∈H(b) f (X), from Lemma A.5, we get that f (S) + 1 − 6k  · t−1/4 · FS(a(cid:63)) (5) ∀λ < 1 with probability 1 − e−Ω(λ2t1/4/ω): (cid:101)F (S ∪ b) < (1 + λ)µ ·(cid:16) f (S) + FS(b) + 3t−1/4βmax (6) We'll express this inequality in terms of f (S) and FS(a(cid:63)) as well. First, since all sets in H(b) are of size at most k we also know that βmax ≤ OPT. Thus: 3t−1/4βmax ≤ 3t−1/4 · OPT (7) We will now bound OPT in terms of FS(a(cid:63)). Since every set in H(a(cid:63)) includes a(cid:63), from mono- tonicity we get that FS(a(cid:63)) ≥ fS(a(cid:63)). Let b(cid:63) ∈ argmaxb /∈H fH∪S(b). Due to the maximality of a(cid:63) we have that FS(a(cid:63)) ≥ FS(b(cid:63)) and by Claim B.1 we know that fS(a(cid:63)) ≥ fS∪H (b(cid:63)). Since the iteration is -relevant we get: (cid:17) FS(a(cid:63)) ≥ fS(a(cid:63)) ≥ fS∪H (b(cid:63)) ≥ fS∪H (OH ) k ≥  · OPTH k  · OPT 3k > (8) 46 Putting (8) together with (7) we get: 3t−1/4βmax ≤ k  · 9t−1/4 · FS(a(cid:63)) Plugging into (6) and using the assumption that FS(b) < (1 − δ)FS(a(cid:63)) we get: (cid:101)F (S ∪ b) < (1 + λ)µ · (cid:18) (cid:18) f (S) + FS(b) + (cid:18) 9t−1/4 · k  + (1 − δ) FS(a(cid:63)) FS(a(cid:63)) < (1 + λ)µ · f (S) + 9t−1/4 · k  (cid:19) (cid:19) (9) (10) Putting (5) together with (10) we get that ∀λ < 1 with probability at least 1 − 2e−Ω(λ2t1/4/ω): (cid:101)F (S ∪ a(cid:63)) − (cid:101)F (S ∪ b) > µ · (cid:18) (cid:18) (cid:18) (cid:18) (cid:18) (cid:18) FS(a(cid:63)) FS(a(cid:63)) FS(a(cid:63)) FS(a(cid:63)) FS(a(cid:63)) FS(a(cid:63)) (cid:18) (cid:18) (cid:18) (cid:18) (cid:20) (cid:20) (cid:20) (cid:20) (cid:20) (cid:20) (1 − λ) (1 − λ) (1 − λ) (1 − λ) δ − 15k  (cid:16) δ − k  ≥ µ · > µ · = µ · = µ · > µ · 1 − 6k  1 − 6k  1 − 6k  1 − 6k  t−1/4 t−1/4 t−1/4 t−1/4 (cid:18) · t−1/4 − λ (2 − δ) + 15t−1/4 + 10λ − (1 + λ) t−1/4 + (1 − δ) − 2λf (S) − (1 + λ) t−1/4 + (1 − δ) − 2λOPT − (1 + λ) t−1/4 + (1 − δ) − 2λ FS(a(cid:63)) (cid:19)(cid:21) (cid:19)(cid:21) (cid:19)(cid:21) (cid:19) (cid:19) (cid:19) (cid:21)(cid:19) 3k  3k  (cid:19) − (1 + λ) t−1/4 + (1 − δ) − 2λ (cid:19)(cid:21)(cid:19)  · t−1/4 + 6k  3k  (cid:19) (cid:19) (cid:18) 9k (cid:18) 9k (cid:18) 9k (cid:18) 9k    (cid:18) (cid:19) (cid:19) (cid:19) (cid:19) (cid:17)(cid:21)(cid:19) The second inequality above is an application of (8) and the fact that f (S) ≤ OPT since S ≤ k. The third is from (8). For the result to hold we need the above difference to be strictly positive, and hold with probability Ω(1 − 1/n5). Thus, sufficient conditions would be: 2, and  · 15t−1/4 ≤ δ 2, and 1. k 2. 10λ ≤ δ 3. 1 − 2 exp(−λ2t1/4 ω ) ∈ Ω(1 − 1/n5). The first condition holds when t ≥ (30k/δ)4; the second condition holds when λ = δ/20k. For ω = 6 log n and λ = δ/20k, the third condition is satisfied when: rearranging: t ≥ 120004 (δ)2t1/4 202k2ω = (δ)2t1/4 ≥ 5 log n 202k26 log n (cid:18) k log n (cid:19)8 δ 47 Thus, since t in the lemma statement respects: (cid:18) 110k log n (cid:19)8 δ (cid:18) k log n (cid:19)8 δ > 120004 t ≥ we have that the first, second, and third conditions are met conditioned on ω ≤ 6 log n. That is, we have that the difference is positive with probability 1 − 2 exp(−λ2t1/4 ) ≥ 1 − 2/n5, conditioned on ω ≤ 6 log n. From lemma A.2 we know that the probability of ω > 6 log n is smaller than 1/n5 for sufficiently large n. Therefore, by taking a union bound on the probability of the event in which the difference is negative and the probability that ω > 6 log n, both occurring with probability smaller than 2/n5 we have that the probability of the difference being positive is at least 1− 4/n5 ∈ Ω(1 − 1/n5), as required. ω Proof of Lemma 2.1. By Claim B.3, when δ = 2/4k for any fixed  > 0 we need to verify that for sufficiently large n: (cid:18) 110k log n (cid:19)8 t > δ = (440k2 log n)8 3 In the case where k ≥ log n we use (cid:96) = 25 log n and thus t = 2(cid:96) = n25 and the above inequality holds. When k < log n we use (cid:96) = 33 log log n and thus t = log33 n and the above inequality holds in this case as well. We therefore have the result with probability at least 1 − 1/n4.4 Approximation guarantee Claim (2.2). For any  > 0, b(cid:63) ∈ argmaxb /∈H fH∪S(b). If FS(a) ≥ (1 − δ)FS(b(cid:63)), then: let δ ≤ 2/4k. Suppose that the iteration is -relevant and let fS(a) ≥ (1 − )fH∪S(b(cid:63)). Proof. First, we upper bound FS(a): H(cid:48)⊆H (cid:88) (cid:88) (cid:88) H(cid:48)⊆H H(cid:48)⊆H FS(a) = 1 t = 1 t ≤ 1 t = fS(a) + fS(H(cid:48) ∪ a) (cid:0)fS(H(cid:48)) + fS∪H(cid:48)(a)(cid:1) (cid:0)fS(H(cid:48)) + fS(a)(cid:1) (cid:88) fS(H(cid:48)) 1 t H(cid:48)⊆H by definition of FS by submodularity of f t = 2H 4Note that we could have used smaller values of (cid:96) to achieve the desired bound. The reason we exaggerate the values of (cid:96) is to be consistent with the analysis of SLICK-GREEDY which necessitates these slightly larger values of (cid:96). 48 H(cid:48)⊆H (cid:88) (cid:88) (cid:88) H(cid:48)⊆H H(cid:48)⊆H Next, we lower bound (1 − δ)FS(b(cid:63)): (1 − δ)FS(b(cid:63)) = (1 − δ) = (1 − δ) ≥ (1 − δ) 1 t 1 t 1 t fS(H(cid:48) ∪ b(cid:63)) (cid:0)fS(H(cid:48)) + fS∪H(cid:48)(b(cid:63))(cid:1) (cid:0)fS(H(cid:48)) + fS∪H (b(cid:63))(cid:1) = (1 − δ)fH∪S(b(cid:63)) − δ 1 t fS(H(cid:48)) + 1 t H(cid:48)⊆H Since FS(a) ≥ (1 − δ)FS(b(cid:63)) this implies that: fS(a) ≥ (1 − δ)fH∪S(b(cid:63)) − δ 1 t by definition of FS by submodularity of f fS(H(cid:48)) t = 2H (cid:88) H(cid:48)⊆H monotonicity of f t = H(cid:48) H ≤ k OPTH ≥ OPT/e -relevant iteration δ ≤ 2/4k (cid:88) (cid:88) (cid:88) H(cid:48)⊆H fS(H(cid:48)) fS(H) 1 t ≥ (1 − δ)fH∪S(b(cid:63)) − δ H(cid:48)⊆H ≥ (1 − δ)fH∪S(b(cid:63)) − δfS(H) ≥ (1 − δ)fH∪S(b(cid:63)) − δOPT ≥ (1 − δ)fH∪S(b(cid:63)) − eδOPTH ≥ (1 − δ)fH∪S(b(cid:63)) − eδ · k  (cid:19)(cid:19) 1 − δ = (cid:18) (cid:18) 4k 1 + e · k  (cid:19)(cid:19) (cid:18) (cid:18) fH∪S(b(cid:63)) 1 − δ ≥ = (1 − )fH∪S(b(cid:63)).  · fH∪S(b(cid:63)) fH∪S(b(cid:63)) Claim (2.3). For any fixed  > 0, consider an -relevant iteration of SMOOTH-GREEDY with S as the elements selected in previous iterations. Let a ∈ arg maxb /∈S∪H (cid:101)F (S ∪ b). Then, w.p. ≥ 1 − 1/n4: fS(a) ≥(cid:16) (cid:17)(cid:20) 1 (cid:16) k(cid:48) 1 −  OPTH − f (S) . (cid:17)(cid:21) Proof. Let O ∈ argmaxT :T≤k(cid:48)fH (T ), o(cid:63) ∈ argmaxo∈OfH∪S(o) and b(cid:63) ∈ argmaxb /∈H fH∪S(b). From Lemma 2.1 we know that with probability 1 − 1/n4 we have FS(a) ≥ (1 − δ)FS(b(cid:63)) for δ = 2/4k, and together with Claim 2.2 we get: fS(a) ≥ (1 − )fH∪S(b(cid:63)) ≥ (1 − )fH∪S(o(cid:63)) From subadditivity fH∪S(o(cid:63)) ≥ fH∪S(O)/k(cid:48) and thus: fS(a) ≥ (1 − )fH∪S(o(cid:63)) ≥ (cid:19)(cid:16) (cid:18) 1 −  k(cid:48) (cid:17) . fH (O) − f (S) (cid:18) 1 −  (cid:19) k(cid:48) fH∪S(O) ≥ 49 Lemma (2.4). Let S be the set returned by SMOOTH-GREEDY and H its smoothing set. Then, for any fixed  > 0 when k ≥ 3(cid:96)/ with probability of at least 1 − 1/n3 we have that: f (S ∪ H) ≥ (1 − 1/e − /3) OPTH . Proof. In case OPTH < OPT/e then H alone provides a 1− 1/e− /3 approximation. To see this, let O ∈ argmaxT :T≤k f (T ) and O(cid:48) ∈ argmaxT :T≤k(cid:48) f (T ), and OH ∈ argmaxT :T≤k(cid:48) fH (T ). We get: k(cid:48) = k − (cid:96) and k ≥ 3(cid:96)/ monotonicity (1 − /3)f (O) ≤ f (O(cid:48)) ≤ f (H ∪ O(cid:48)) = f (H) + fH (O(cid:48)) ≤ f (H) + fH (OH ) < f (H) + f (O)/e Thus: f (H) ≥ (cid:18) (cid:19) (cid:18) 1 − 1 e −  3 OPT ≥ 1 − 1 e −  3 OPTH optimality of OH eOPTH < OPT (cid:19) In case OPTH ≥ OPT/e we set γ = min{1/e, /6}. We will use the following notation. At every iteration i ∈ [k(cid:48)] of the while loop in the algorithm, we will use ai to denote the element that was added in that step, and Si := {a1, . . . , ai}. First, notice that if there exists an iteration i that is not γ-relevant, our bound trivially holds: fH∪Si(OH ) ≤ k(cid:48) · max o∈OH fH∪Si(o) ≤ k(cid:48) · max b /∈Si∪H fH∪Si(b) ≤ k(cid:48) · γOPTH k < γOPTH Since fH∪Si(OH ) = f (H ∪ Si ∪ OH ) − f (H ∪ Si), the above inequality implies that f (H ∪ Si) > f (H ∪ Si ∪ OH ) − γOPTH. But this implies: f (S ∪ H) ≥ f (Si ∪ H) > f (OH ∪ Si ∪ H) − γOPTH ≥ f (OH ) − γOPTH ≥ fH (OH ) − γOPTH = (1 − γ)OPTH ≥ (1 − 1/e)OPTH It remains to prove the approximation guarantee in the case that every iteration is γ-relevant. To do so, we can apply a standard inductive argument on Claim 2.3 to show that S alone provides a 1 − 1/e − /3 approximation. Claim 2.3 states that for γ-relevant iterations, at every stage i ∈ [k(cid:48)]: f (Si+1) − f (Si) ≥ (1 − γ) . (11) We will show that at every stage i ∈ [k(cid:48)]: f (Si) ≥ (1 − γ) (cid:32) 1 − (cid:20) 1 (cid:21) k(cid:48) (fH (OH ) − f (Si)) (cid:18) (cid:19)i(cid:33) fH (OH ). 1 − 1 k(cid:48) 50 (cid:18) (cid:18) 1 − 1 − 1 k(cid:48) (cid:19)(cid:19) The proof is by induction on i. For i = 1 we have that Si = {a1} and invoking Claim 2.3 with S = ∅ we get that f (ai) ≥ (1 − γ) 1 k(cid:48) fH (OH ). Therefore: fH (OH ). We can now assume the claim holds for i = l < k(cid:48) and show that it holds for i = l + 1: f (Sl+1) ≥ (1 − γ) > (1 − γ) + f (Sl) (cid:19) δ > 0 By (11) + f (S1) = f (a1) ≥ (1 − γ) 1 k(cid:48) fH (OH ) = (1 − γ) (cid:18) 1 (cid:19) (cid:18)(cid:18) 1 (cid:18) k(cid:48) (fH (OH ) − f (Sl)) (cid:18) 1 k(cid:48) fH (OH ) (cid:32) (cid:19) (cid:19) (cid:19)l+1(cid:33) 1 − 1 k(cid:48) 1 − 1 k(cid:48) (cid:19) (cid:19)(cid:32) k(cid:48) fH (OH ) + (1 − γ) (cid:18) (cid:18) 1 − f (Sl) (cid:18) (cid:19)l(cid:33) 1 − 1 k(cid:48) ≥ (1 − γ) = (1 − γ) 1 − 1 − 1 k(cid:48) fH (OH ) fH (OH ) inductive hypothesis Note that for any l > 1 we have that (1 − 1/l)l ≤ 1/e, and thus: f (S) = f (Sk(cid:48)) ≥ (1 − 1/e − γ)fH (OH ) > (1 − 1/e − /3)OPTH . by the induction γ = /6 Corollary B.4. Let S be the set returned by SMOOTH-GREEDY and H be its smoothing set. For any fixed  > 0 and k > 3(cid:96)/, we have that with probability at least 1 − 1/n3: (cid:18) e − 1 2e − 1 −  (cid:19) f (S ∪ H) > − 2 OPT. Proof. Let OH ∈ argmaxT :T≤k(cid:48)fH (T ). From Lemma 2.4, with probability at least 1 − 1/n3: (cid:18) (cid:19) (12) Let O(cid:48) ∈ argmaxT :T≤k−H f (T ). From submodularity and the fact that k ≥ 3(cid:96)/ > H/ we get that (1 − )OPT ≤ f (O(cid:48)). Putting everything together: f (OH ) f (S ∪ H) > 1 − 1 e −  3 (1 − )OPT ≤ f (O(cid:48)) e e − 1 −  ≤ f (OH ∪ H) ≤ f (OH ) + f (H) ≤ (cid:19) (cid:18) (cid:19) (cid:18) 2e − 1 −  (cid:16) e−1 (cid:17) e − 1 −  2e−1− − 2 ≤ f (S ∪ H) + f (H) f (S ∪ H). 51 Therefore f (S ∪ H) > OPT as required. submodularity of f monotonicity of f subadditivity of f by (12) monotonicity of f Slick Greedy: Optimal Approximation for Sufficiently Large k As described in the main body of the paper, in SLICK-GREEDY we apply a slightly more general version of SMOOTH-GREEDY where in each iteration i ∈ [1/δ] the algorithm SMOOTH-GREEDY is initialized with the set of elements Ri = ∪j(cid:54)=iHj and uses the smoothing set Hi. SMOOTH-GREEDY from the previous section is a special case in which Ri = ∅. As one might imagine, the guarantees from the previous section carry over, using the appropriate definitions. Generalizing guarantees of smooth greedy To make the transition to the case in which SMOOTH-GREEDY is being initialized with Ri of size (cid:96)/δ − (cid:96) and selects k(cid:48)(cid:48) = k − Ri − Hi = k − (cid:96)/δ elements, we extend our definitions (cid:80)t as follows. For a given set Ri used for initialization, it'll be convenient to consider the function i=1 g (S ∪ (Hi ∪ a)). When the smoothing set gi(T ) = fRi(T ), and its smooth value Gi(a) = 1 t is clear from context we will generally use R, H, g, G instead of Ri, Hi, gi, Gi. The value of the optimal solution here is OPT[G] = maxT :T≤k(cid:48)(cid:48) g(T ) where k(cid:48)(cid:48) = k − R − H. We can then also define OPT[G]H = maxT :T≤k(cid:48)(cid:48) gH (T ). For a given set S of elements selected by SMOOTH-GREEDY and b(cid:63) ∈ argmaxb /∈H gS∪H (b), an -relevant iteration is one in which gH∪S(b(cid:63)) ≥ OPT[G]H /k and OPT[G]H ≥ OPT[G]/e. Lower bounding the marginal contribution in each iteration. We first show that when SMOOTH-GREEDY is initialized with a set R and run with smoothing set H, then in every γ- relevant iteration the element a selected respects gS(a) ≥ (1 − γ)gH∪H (b(cid:63)). This claim is necessary for proving Lemma B.7 which shows the approximation guarantee of SMOOTH-GREEDY in each iteration of SLICK-GREEDY as well as for proving guarantees of SMOOTH-COMPARE in Lemma 2.6. Claim B.5. For a given set R ⊂ N, let g(T ) = fR(T ). For any fixed γ > 0 consider a γ-relevant iteration of SMOOTH-GREEDY initialized with some set R using smoothing set H s.t. H ∩ R = ∅, and let S be the set of elements selected before the iteration. If a ∈ argmaxb /∈H (cid:101)F (R ∪ S ∪ b) then w.p.≥ 1 − 1/n4: Proof. Let G denote the smooth value function of g, i.e. G(S ∪ a) = 1 proof in a chaining of four simple arguments. Let λ = γ2/4k and α = γλ/3k. We show: t gS(a) ≥ (1 − γ)gH∪S(b(cid:63)) (cid:80) H(cid:48)⊂H g(S ∪ H(cid:48) ∪ a). The 1. (cid:101)F (R ∪ S ∪ a) ≥ 2. 3. 4. FR∪S(a) ≥ (1 − α) G(S ∪ a) ≥ (1 − α) GS(a) ≥ (1 − λ) (cid:101)F (R ∪ S ∪ b(cid:63)) FR∪S(b(cid:63)) G(S ∪ b(cid:63)) GS(b(cid:63)) =⇒ =⇒ =⇒ =⇒ FR∪S(a) ≥ (1 − α) FR∪S(b(cid:63)) G(S ∪ a) ≥ (1 − α) G(S ∪ b(cid:63)) GS(b(cid:63)) gH∪S(b(cid:63)) GS(a) ≥ (1 − λ) gS(a) ≥ (1 − γ) The above arguments can be justified as follows: 52 1. To see (cid:101)F (R∪ T ∪ a) ≥ (cid:101)F (R∪ T ∪ b(cid:63)) implies FR∪T (a) ≥ (1− α)FR∪T (b(cid:63)), we invoke Claim B.3 on S = R ∪ T . To do so, since α ≤ γ3/24k2 for sufficiently large n we need to verify: (cid:18) 110k log n (cid:19)8 (cid:18) 2640k3 log n (cid:19)8 t > γα = γ3 In the case where k ≥ 2400 log n we use (cid:96) = 25 log n and thus t = 2(cid:96) = n25 and the above inequality holds. When k < 2400 log n we use (cid:96) = 33 log log n and thus t = log33 n and the above inequality holds in this case as well. We therefore have the result w.p. ≥ 1 − 1/n4. 2. Assuming that FR∪S(a) ≥ (1 − α)FR∪S(b(cid:63)) we will show that G(S ∪ a) ≥ (1 − α)G(S ∪ b(cid:63)): ≥(1 − α)FR∪S(b(cid:63)) ≥(1 − α) fR∪S(H(cid:48) ∪ a) (cid:0)f (R ∪ S ∪ H(cid:48) ∪ a) − f (R ∪ S)(cid:1) ≥(1 − α) (cid:0)f (R ∪ S ∪ H(cid:48) ∪ a) − f (R)(cid:1) ≥(1 − α) fR∪S(H(cid:48) ∪ b(cid:63)) (cid:0)f (R ∪ S ∪ H(cid:48) ∪ b(cid:63)) − f (R ∪ S)(cid:1) (cid:0)f (R ∪ S ∪ H(cid:48) ∪ b(cid:63)) − f (R)(cid:1) 3. G(S ∪ a) ≥ (1 − α)G(S ∪ b(cid:63)) =⇒ GS(a) ≥ (1 − λ)GS(b(cid:63)): We first argue GS(b(cid:63)) > γOPT[G] e·k(cid:48)(cid:48) : FR∪S(a) H(cid:48)⊂H H(cid:48)⊂H (cid:88) (cid:88) (cid:88) (cid:88) (cid:88) H(cid:48)⊂H H(cid:48)⊂H =⇒ 1 t =⇒ 1 t =⇒ 1 t =⇒ 1 t =⇒ 1 t H(cid:48)⊂H =⇒ G(S ∪ a) fR(S ∪ H(cid:48) ∪ a) g(S ∪ H(cid:48) ∪ a) (cid:88) (cid:88) (cid:88) H(cid:48)⊂H H(cid:48)⊂H H(cid:48)⊂H GS(b(cid:63)) = 1 t ≥ 1 t ≥ 1 t H(cid:48)⊂H H(cid:48)⊂H (cid:88) (cid:88) (cid:88) (cid:88) (cid:88) H(cid:48)⊂H H(cid:48)⊂H H(cid:48)⊂H 1 t 1 t 1 t 1 t 1 t ≥(1 − α) ≥(1 − α) fR(S ∪ H(cid:48) ∪ b(cid:63)) g(S ∪ H(cid:48) ∪ b(cid:63)) ≥(1 − α)G(S ∪ b(cid:63)) (cid:0)g(S ∪ b(cid:63) ∪ H(cid:48)) − g(S)(cid:1) (cid:0)g(S ∪ b(cid:63) ∪ H(cid:48)) − g(S ∪ H(cid:48))(cid:1) monotonicity of g (g(S ∪ b(cid:63) ∪ H) − g(S ∪ H)) submodularity of g = g(S ∪ b(cid:63) ∪ H) − g(S ∪ H) = gS∪H (b(cid:63)) ≥ γ k(cid:48)(cid:48) OPT[G]H γ e · k(cid:48)(cid:48) OPT[G] > γ-relevant iteration OPT[G]H > OPT[G]/e 53 Now, in a similar fashion to Claim 2.2: GS(a) = G(S ∪ a) − G(S) · GS(b(cid:63)) GS(b(cid:63)) > γOPT[G] e · k(cid:48)(cid:48) ≥ (1 − α) (G(S ∪ b(cid:63)) − G(S)) − αG(S) ≥ (1 − α) (G(S ∪ b(cid:63)) − G(S)) − αOPT[G] ≥ (1 − α) (G(S ∪ b(cid:63)) − G(S)) − α e · k(cid:48)(cid:48) γ · GS(b(cid:63)) (cid:18) (cid:18) = (1 − α) (GS(b(cid:63))) − α e · k(cid:48)(cid:48) γ 1 − α = 1 + = (1 − λ) GS(b(cid:63)) e · k(cid:48)(cid:48) γ (cid:19)(cid:19) GS(b(cid:63)) α = λ/3k and k ≥ k(cid:48)(cid:48) + 1 4. GS(a) ≥ (1 − λ)GS(b(cid:63)) =⇒ gS(a) ≥ (1 − γ)gH∪S(b(cid:63)): by direct application of Claim 2.2 Definition B.6. Given two disjoint sets H and R, let OPTH,R = f (H ∪ R ∪ OH,R) − fR(H) where: OH,R ∈ argmaxT :T≤k−H∪R f (H ∪ R ∪ T ). Notice that when R = ∅ we have that OH,R = OH ∈ argmaxT :T≤k−H fH (T ) as defined in the previous subsection. In that sense, the value of OH,R is that of the optimal solution evaluated on fH when initialized with R. In the same way Lemma 2.4 shows SMOOTH-GREEDY obtains a 1− 1/e− /3 approximation to OPTH, the following lemma shows that when SMOOTH-GREEDY is initialized with R it obtains the same guarantee against OPTH,R. Details are in Appendix ??. Lemma B.7. Let S be the set returned by SMOOTH-GREEDY that is initialized with a set R ⊆ N and has H as its smoothing set of size (cid:96), which is disjoint from R and S. Then, for any fixed  > 0 when k ≥ 3H ∪ R/ with probability of at least 1 − 1/n3 we have that: f (R ∪ S ∪ H) ≥ (1 − 1/e − /3) OPTH,R. Proof. Notice that the proof of Lemma 2.4 applies for the application of SMOOTH-GREEDY on any submodular function v where in every γ-relevant iteration vS(a) ≥ (1 − γ)vS∪H (b(cid:63)) with proba- bility 1 − 1/n4, for γ ∈ min{1/e, /6}, and S being the elements added in the previous iteration. From Claim B.5 we have that for any γ-relevant iteration gS(a) ≥ (1− γ)gS∪H (b(cid:63)) w.p. ≥ 1− 1/n4. We can therefore apply the exact same proof on g and get: (13) Let OH ∈ argmaxT :T≤k−R∪H g(T ) and let OH,R ∈ argmaxT :T≤k−H∪R f (H ∪ R ∪ T ). Observe that by definition of g(X) = fR(X) we have that: g(S ∪ H) ≥ (1 − 1/e − /3)OPT[G]H f (H ∪ R ∪ OH,R) = f (H ∪ R ∪ OH ) 54 and thus from (13) we get: f (R ∪ S ∪ H) − f (R) = fR(S ∪ H) = g(S ∪ H) ≥ (1 − 1/e − /3)gH (OH ) ≥ (1 − 1/e − /3) (g(OH ∪ H) − g(H)) = (1 − 1/e − /3) (fR(OH ∪ H) − fR(H)) ≥ (1 − 1/e − /3) (f (R ∪ OH ∪ H) − f (R) − fR(H)) ≥ (1 − 1/e − /3) (f (R ∪ OH,R ∪ H) − fR(H)) − (1 − 1/e − /3)f (R) and we therefore have that f (R ∪ S ∪ H) ≥ (1 − 1/e − /3) (f (R ∪ OH,R ∪ H) − fR(H)). We will instantiate the Lemma with R = Rl and H = Hl as discussed above: for any i ∈ [1/δ] we will define Ri = ∪j(cid:54)=iHj and use the index l to denote the smoothing set in {Hi}1/δ i=1 which has the least marginal contribution to the rest, i.e. Hl = argmini∈[1/δ] fRi(Hi). We first show that the iteration of SLICK-GREEDY on l finds a solution arbitrarily close to 1 − 1/e for sufficiently large k. Lemma (2.5). Let Sl be the set returned by SMOOTH-GREEDY that is initialized with Rl and Hl its smoothing set. Then, for any fixed  > 0 when k ≥ 36(cid:96)/2 with probability of at least 1 − 1/n3 we have: f (Sl ∪ Hl) ≥ (1 − 1/e − 2/3)OPT Proof. To ease notation, let R = Rl, H = Hl, and O = Ol where Ol is the solution which maximizes f (H ∪ R ∪ T ) over all subsets T of size at most k − H ∪ R. Let β = H ∪ R/k. Notice that by submodularity we have that: f (H ∪ R ∪ O) ≥ (14) Notice also that by the minimality of H = Hl and submodularity we have that fR(H) ≤ δf (H∪R). Recall also that δ = /6 and notice that whenever k ≥ (cid:96)/δ2 = 36(cid:96)/2 we have that β < δ and hence β + δ < /3. Therefore, by application of Lemma B.7 we get that with probability 1 − 1/n3: k OPT = (1 − β)OPT (cid:18) 1 − H ∪ R (cid:19) OPTH,R (f (H ∪ R ∪ O) − fR(H)) by Lemma B.7 by definition (f (H ∪ R ∪ O) − δ · f (H ∪ R)) fR(H) ≤ δf (H ∪ R) f (S ∪ R ∪ H) ≥ = ≥ ≥ ≥ ≥ ≥ (cid:18) (cid:18) (cid:18) (cid:18) (cid:18) (cid:18) (cid:18) (cid:19) (cid:19) (cid:19) (cid:19) 1 − 1 e 1 − 1 e 1 − 1 e 1 − 1 e 1 − 1 e 1 − 1 e 1 − 1 e −  3 −  3 −  3 −  3 −  3 −  3 − 2 3 (cid:19) (cid:19) − δ − δ (cid:19) ((1 − δ)f (H ∪ R ∪ O)) (f (H ∪ R ∪ O)) (1 − β) OPT OPT. 55 monotonicity of f by (14) β + δ < /3 The smooth comparison procedure Lemma (2.6). Assume k ≥ 96(cid:96)/2. Let Ti be the set that won the SMOOTH-COMPARE tournament. Then, with probability at least 1 − 1/n2: f (Ti) ≥(cid:16) (cid:17) (cid:26)(cid:18) 1 −  3 min 1 − 1 e − 2 3 OPT, max j∈[1/δ] f (Tj) (cid:19) (cid:27) The proof of the lemma uses the following two claims. Claim B.8. Let Ti = Si ∪ Hi and Tj = Sj ∪ Hj be two sets that are compared by SMOOTH-COMPARE, and suppose that (i)f (Ti) ≥ (1 + 2β)f (Tj) where β = Hij/k(cid:48)(cid:48) and k(cid:48)(cid:48) = k − (cid:96)/δ, and (ii) f (Tj) < (1 − 1/e − 2/3)OPT for any  ≥ 3(1 − k(cid:48)(cid:48)/k)/2. Then, for any set H(cid:48) ij ⊆ Hij w.p. ≥ 1 − 1/n3: Proof. Recall that Hij ∩(cid:16) (cid:17) f (Ti ∪ H(cid:48) ij) ≥ f (Tj ∪ H(cid:48) ij). Ti ∪ Tj = ∅. We will argue that assuming f (Tj) < (1 − 1/e)OPT, the fact that every element in H(cid:48) ij was a candidate for selection by SMOOTH-GREEDY and wasn't selected, implies that w.h.p. either (i) f (Tj) is arbitrarily close to 1 − 1/e (in which case we wouldn't mind that if it wins the comparison) or (ii) the marginal contribution of H(cid:48) ij to Tj is bounded from above by 2βf (Tj) which suffices since then we get: ij) = f (Tj) + fTj (H(cid:48) ij) ≤ (1 + 2β)f (Tj) < f (Ti) ≤ f (Ti ∪ H(cid:48) ij) f (Tj ∪ H(cid:48) To prove this, consider the instantiation of SMOOTH-GREEDY initialized with Rj with smoothing set Hj, and let S be the set selected after its k(cid:48)(cid:48) = k − Rj − Hj iterations. Recall that Sj = Rj ∪ S and that Tj = Sj ∪ Hj. To ease notation let R = Rj and H = Hj. We will first prove the statement in the case that the iteration is γ-relevant for γ = 1/4. For every iteration r ∈ [k(cid:48)(cid:48)] let S(r) be the set of elements selected in the previous iterations and a(r) be the element added to the solution at that stage by SMOOTH-GREEDY. From Claim B.5 we know that large then w.p. ≥ 1 − 1/n4: since a(r) ∈ argmaxb (cid:101)F (R ∪ S(r) ∪ b) and the size of the smoothing neighborhood t is sufficiently gS(r)(a(r)) ≥ (1 − γ) max b /∈H gH∪S(r)(b) 56 We therefore have that: g(S) = gS(r)(ar) (1 − γ) max b /∈H gS(r)∪H (b) r=1 k(cid:48)(cid:48)(cid:88) ≥ k(cid:48)(cid:48)(cid:88) ≥ k(cid:48)(cid:48)(cid:88) r=1 gS∪H (b) gS∪H (b) gS∪H (h) r=1 (1 − γ) max b /∈H = k(cid:48)(cid:48)(1 − γ) max b /∈H ≥ k(cid:48)(cid:48)(1 − γ) max h∈H(cid:48) ≥ k(cid:48)(cid:48)(1 − γ) gS∪H (H(cid:48) H(cid:48) ij ij) ≥ (1 − γ)k(cid:48)(cid:48) gS∪H (H(cid:48) ij) ij (cid:96) Since g(T ) = fR(T ) and γ = 1/4 this implies: k(cid:48)(cid:48) 2(cid:96) Since Tj = Rj ∪ S ∪ Hj = R ∪ S ∪ H we get: f (R ∪ S) − f (R) > (cid:0)f (R ∪ H ∪ H(cid:48) ij) − f (R ∪ S)(cid:1) fTj (H(cid:48) ij) < 2(cid:96) k(cid:48)(cid:48) f (Tj) = 2βf (Tj). If the iteration is not γ-relevant, assume first that e · OPT[G]H ≥ OPT[G]. In this case, let OH = argmaxT :T≤k(cid:48)(cid:48) gH (T ). Notice that the fact that iteration is not relevant in this case says that there is an iteration r for which maxb /∈H gH∪S(r)(b) < γOPT[G]H /k and from submodularity of g since S(r) ⊆ S we get maxb /∈H gH∪S(b) < γOPT[G]H /k. Thus: which implies: gH∪S(OH ) ≤ k(cid:48)(cid:48) · gH∪S(b(cid:63)) ≤ k(cid:48)(cid:48) · γOPT[G]H k < γOPT[G]H g(H ∪ S) > g(OH ∪ H ∪ S) − γOPT[G]H ≥ gH (OH ) − γOPT[G]H = (1 − γ)OPT[G]H 57 Using this bound we get: gH∪S(H(cid:48) ij) ≤ H(cid:48) ≤ H(cid:48) ≤ H(cid:48) ij gH∪S(h) gH∪S(b) ij max h∈H(cid:48) ij max b /∈H ij γ OPT[G]H k g(H ∪ S) γ(cid:96) < k(1 − γ) Again, as before for δ = 1/4 we get that in this case: fTj (H(cid:48) ij) < 2(cid:96) k(cid:48)(cid:48) f (Tj) = 2βf (Tj) Lastly, it remains to show that if if the iteration is not γ-relevant because e · OPT[G]H < OPT[G], we get a contradiction to our assumption that f (Tj) < (1 − 1/e − 2/3)OPT. To see this, let O ∈ argmaxT :T≤k(cid:48)(cid:48) g(T ), and notice that: hence: g(H ∪ OH ) − g(H) < g(O) e f (R ∪ H) − f (R) = g(H) > g(H ∪ OH ) − g(O) e ≥ g(O) (cid:19) (cid:19) (cid:18) (cid:18) ≥ 1 − 1 e 1 − 1 e (f (R ∪ O)) − f (R) We therefore get that f (Tj) ≥ f (R ∪ H) > (1 − 1/e)f (O). Notice that since O = k(cid:48)(cid:48) and k(cid:48)(cid:48)/k ≥ (1 − 2/3), submodularity implies f (Tj) ≥ (1 − 1/e − 2/3)OPT, a contradiction. Claim B.9. For k f (Tj) ≤ (1 − 1/e − 2/3)OPT. Then, Ti wins in the smooth comparison procedure w.p. ≥ 1 − 2/n3. (1 + δ/3)f (Tj) that f (Ti) and that suppose 96(cid:96)/2 ≥ ≥ Proof. Let β = Hij/k(cid:48)(cid:48) where k(cid:48)(cid:48) = k − (Hij + Ri). Since we assume that k ≥ 96(cid:96) and δ = /6 this implies that 2β < 2/45. We therefore have: 1 + δ 3 f (Ti) > f (Tj) = 2 18 ij ⊆ Hij we have that with probability at least 1 − 1/n3: From Claim B.8 this implies that for any H(cid:48) ij) ≤ (1 + 2β)f (Tj ∪ H(cid:48) f (Tj ∪ H(cid:48) ij) f (Tj) > (1 + 2β)2 f (Tj) f (Tj) > 2 45 1 + 1 + (cid:18) (cid:19) (cid:18) (cid:19) (cid:18) (cid:19)2 58 We will condition on this event as well as the event that the maximal value obtained throughout the iterations of the algorithm is νmax and minimal value is νmin, and that νmax/νmin ≤ nτ for some constant τ > 0. ij) ≥ (cid:101)f (Tj ∪ H(cid:48) ij) ij) ≥ ξjf (Tj ∪ H(cid:48) ij) (cid:18) (cid:12)(cid:12)(cid:12)f (Ti) ≥ (cid:12)(cid:12)(cid:12)f (Ti) ≥ (cid:19) (cid:21) δ 3 1 + (cid:18) f (Tj) (cid:19) 1 + f (Tj) δ 3 (cid:21) (cid:20)(cid:101)f (Ti ∪ H(cid:48) (cid:20) (cid:20) ξif (Ti ∪ H(cid:48) (1 + 2β) · ξi ξj Pr = Pr > Pr (cid:21) ≥ 1 ≥ 1 2 + 1 2 log1+2β( νmax νmin ) The last inequality follows from a discretization argument: Consider the m ∈ O(log n) intervals, where the i'th interval is [νmin(1 + 2β)i, νmin(1 + 2β)i+1], and i ranges from 0 to log1+2β( νmax ). Due νmin to symmetry of ξi and ξj, the likelihood of ξi falling in the same or higher interval than ξj is: (cid:80)m i=1 i m2 = 1 2 + 1 2m = 1 2 + 1 2 log1+2β( νmax νmin ) = 1 2 + 1 2τ log1+2β n Applying a Chernoff bound, for any constants , δ > 0, s.t. δ/8 > 1 + 2β, and νmax/νmin ≤ nτ for some constant τ > 0, we get that Ti is chosen with probability at least 1 − exp(−Ω(n/ log(n))), conditioned on νmax/νmin < nτ which by Lemma A.2 occurs with probability 1 − exp(−Ω(nα)) for some constant α > 0. For sufficiently large n, Ti therefore wins w.p. at least 1 − 2/n3. Proof of Lemma 2.6. Since ∀i, j ∈ [1/δ] SMOOTH-COMPARE({Ti, Tj}, Hij) returns Ti as long as f (Ti) ≥ (1 − δ/3)f (Tj) and f (Tj) < (1 − 1/e − 2/3)OPT, and SMOOTH-COMPARE is called 1/δ times we get: (cid:19) (cid:17) (cid:18) (cid:16) 1 − δ 3 1 −  3 1/δ f (Ti) ≥ ≥ (cid:26)(cid:18) (cid:26)(cid:18) (cid:19) (cid:19) × × min min 1 − 1 e 1 − 1 e − 2 3 − 2 3 OPT, max j∈[1/δ] f (Tj) OPT, max j∈[1/δ] f (Tj) . (cid:27) (cid:27) 59 C Optimization for Small k Smoothing Guarantees Lemma C.1 (3.1). For any  > 0 and any set S ⊂ N, let A(cid:63) ∈ arg maxA:A=1/ fS(A). Then: (1 − ) fS(A(cid:63)) ≤ FS(A(cid:63)) ≤ fS(A(cid:63)). Proof. By the maximality of A(cid:63) we have that f (A(cid:63)) ≥ f (A(cid:63) ij is generated by replacing ai ∈ A(cid:63) with aj /∈ A(cid:63) ∪ S. Therefore, the average of all Aijs is upper bounded by fS(A(cid:63)). For the lower bound, let c = 1/ and consider some arbitrary ordering on a1, . . . , ac ∈ A(cid:63). Define A-i = A \ {ai}. From the diminishing returns property we get that for any i ∈ [c]: ij) for any i, j since A(cid:63) f (S ∪ A(cid:63) -i ∪ ai) f (S ∪ {a1 . . . , ai}) − − f (S ∪ A(cid:63) -i) f (S ∪ {a1, . . . , ai−1}) (f (S ∪ {a1 . . . , ai}) − f (S ∪ {a1, . . . , ai−1})) = fS(A(cid:63)) (15) = ≤ Thus: fS∪A(cid:63) -i (ai) c(cid:88) i=1 fS∪A(cid:63) -i (ai) ≤ c(cid:88) i=1 By summing over all A(cid:63) -i we get the desired bound: FS(A(cid:63)) = 1 c(n − c − S) n−c−S(cid:88) c(cid:88) j=1 i=1 fS(A(cid:63) ij) fS(A(cid:63) -i) (cid:0)fS(A(cid:63) -i ∪ ai) − fS∪A(cid:63) -i monotonicity, since A(cid:63) -i ⊂ A(cid:63) ij (ai)(cid:1) fS∪A(cid:63) -i (ai) by (15) i=1 c(cid:88) c(cid:88) c(cid:88) i=1 i=1 ≥ 1 c = = 1 c 1 c c(cid:88) i=1 fS(A(cid:63)) − 1 c fS(A(cid:63)) (cid:19) (cid:18) ≥ fS(A(cid:63)) − 1 c fS(A(cid:63)) = = (1 − ) fS(A(cid:63)). 1 − 1 c The smoothing lemma. The rest of this subsection is devoted to proving the following impor- tant lemma. Intuitively, this lemma implies that at every iteration of SM-GREEDY we identify the bundle which nearly maximizes the mean marginal contribution. Lemma (3.2). Let A ∈ argmaxB:B=c (cid:101)F (S ∪ B) where c ≥ 16  , and assume that the iteration is  4- significant. Then, with probability at least 1 − e−Ω(n1/10) we have that: FS(B). FS(A) ≥ (1 − ) max B:B=c 60 Smoothing neighborhoods. The proof uses the smoothing arguments developed in Section A. Recall that for a given set of elements A ⊆ N a smoothing function is a method which assigns A a family of sets H(A) called the smoothing neighborhood. For a given function f : 2N → R, A, S ⊆ N, and smoothing neighborhood H(A) we define: (1) (2) (3) FS(A) F(S ∪ A) (cid:101)F(S ∪ A) := EX∈H(A) := EX∈H(A) := EX∈H(A) [ fS(X) [ f (S ∪ X) [ (cid:101)f (S ∪ X) ]; ]; ]. Note that F(A) (cid:54)= F (A). In particular, as discussed above, we do not apply smoothing on the noisy version of F directly, but rather on the noisy version of the function F which is applied on A-i := A \ {ai}, for all i ∈ [c]:(cid:101)F(S ∪ A-i) := (cid:88) j /∈S∪A (cid:101)f (S ∪ A-i ∪ {aj}) 1 n − c − S Notice that the smoothing arguments then apply to F since: (cid:101)F (S ∪ A) = c(cid:88) i=1 1 c (cid:101)F(S ∪ A-i) In our case, for every A-i, its smoothing neighborhood is: H(A-i) = {A-i ∪ {aj} : j /∈ S ∪ A} Throughout the rest of this section we will use t to denote the number of sets in a smoothing neighborhood of H(A-i). Note that for every i ∈ [c] the size of a smoothing neighborhood is: t = H(A-i) = N ∪ (S \ A) = n − c − S ∈ O(n). Smoothing in the sampled mean method. we need to bound the variation of the neighborhoods H(A(cid:63) which essentially bounds the variation of the smoothing neighborhoods H(A(cid:63) Claim C.2. Let A(cid:63) ∈ argmaxB:B=c fS(B), c ≥ 4/. Then: In order to apply Lemma A.4 in a meaningful way -i). To do so, we use the next claim -i), of almost all A(cid:63) -i. (cid:110) c(cid:88) i=1 1 c -i)) · t−1/4(cid:111) max 0, 1 − 2vS(H(A(cid:63) FS(A(cid:63) -i) ≥ (1 − ) fS(A(cid:63)). -i}c Proof. To bound the average variation of the sets {A(cid:63) s.t. fS(A(cid:63) which fS(A(cid:63) -i) < fS(A(cid:63))/2. To see this, assume for purpose of contradiction there are A(cid:63) -j we get a contradiction: i=1 we argue that at most one set A(cid:63) -i ∪ A(cid:63) -j) < fS(A(cid:63))/2, then since A(cid:63) = A(cid:63) -i) ≤ fS(A(cid:63) -i will be -j for -i and A(cid:63) fS(A(cid:63)) = fS(A(cid:63) -i ∪ A(cid:63)−j) ≤ fS(A(cid:63) -i) + fS(A(cid:63)−j) < 2 · fS(A(cid:63)) = fS(A(cid:63)). 2 61 We therefore have at least c−1 sets s.t. each A(cid:63) -i ⊂ A(cid:63) For any such bounded set A(cid:63) -i, since A(cid:63) -i respects fS(A(cid:63) ij for any j /∈ S ∪ A(cid:63), monotonicity implies: -i) ≥ fS(A(cid:63))/2. Call these sets bounded. ij) ≥ fS(A(cid:63)) -i note that for every j, every set Aij ∈ H(A(cid:63) min ij∈H(A(cid:63) A(cid:63) -i) fS(A(cid:63) 2 For a given set A(cid:63) the maximality of A(cid:63). Thus for any bounded set A(cid:63) -i: i ) respects fS(A(cid:63) ij) ≤ fS(A(cid:63)) due to vS(H(A(cid:63) -i)) = maxA(cid:63) minA(cid:63) ij∈H(A(cid:63) ij∈H(A(cid:63) i ) fS(A(cid:63) ij) i ) fS(A(cid:63) ij) ≤ fS(A(cid:63)) fS(A(cid:63))/2 = 2 Let l be the index of the set A(cid:63) -i). Our discussion above implies that this is the only set whose variation may not be bounded from above by 2. Assume n sufficiently large s.t. t ≥ 212/4. We therefore get: -i with the lowest value fS(A(cid:63) c(cid:88) (cid:16) i=1 1 c max{0, 1 − 2vS(H(A(cid:63) -i))t− 1 4}(cid:17) FS(A(cid:63) -i) ≥ 1 c max{0, 1 − 2vS(H(A(cid:63) -i))t− 1 FS(A(cid:63) -i) 4}(cid:17) i(cid:54)=l (cid:88) (cid:88) (cid:88) i(cid:54)=l (cid:16) (cid:16) (cid:16) 1 − 4t− 1 4 1 − 4t− 1 4 fS(A(cid:63) -i) FS(A(cid:63) -i) (cid:17) (cid:17) (cid:32) c(cid:88) (cid:33) (cid:17) 1 (cid:17) 1 (cid:0)(c − 1)fS(A(cid:63)) − fS(A(cid:63)−l)(cid:1) (cid:17) 1 (cid:17)(cid:18) c − 2 (cid:19) ((c − 1)fS(A(cid:63)) − fS(A(cid:63))) -i) − fS(A(cid:63)−l) fS(A(cid:63)) fS(A(cid:63) (cid:19) i=1 c c c c fS(A(cid:63)) ≥ 1 c ≥ 1 c 4 i(cid:54)=l 1 − 4t− 1 ≥(cid:16) ≥(cid:16) ≥(cid:16) ≥(cid:16) (cid:18) c − 2 1 − 4t− 1 1 − 4t− 1 1 − 4t− 1 4 4 4 ≥ − 4t− 1 ≥ (1 − ) fS(A(cid:63)) c 4 (16) (17) (18) (19) (20) (21) (22) (23) (24) The inequality (17) is justified by the bound we established on bounded sets; (18) is due to mono- tonicity of fS, since FS(A(cid:63) ij, which is a superset of A(cid:63) -i; (20) is due to an argument in the proof of Lemma 3.1; (21) is due to the opti- mality of A(cid:63); (24) is due to the assumption on the parameters in the statement of the claim. -i) is an average of the marginal contribution over all possible A(cid:63) Proof of Lemma 3.2. Let A(cid:63) = arg maxA:A=c fS(A) and let B : B = c be such that FS(B) < (1 − )FS(A(cid:63)). We will apply the smoothing arguments and show that with high probability (cid:101)F (S ∪ A(cid:63)) > (cid:101)F (S ∪ B). 62 By taking a union bound over all possible O(nc) sets B we will then conclude that the set whose smooth noisy contribution is largest must have smooth contribution at least factor of (1 − ) from that of A(cid:63), with high probability. We will denote 1 =  and 2 = /4. Notice that the conditions of Claim C.2 are met with 2 and that the iteration is 2-significant, which from submodularity implies fS(A(cid:63)) ≥ 2 · f (S)/k. For a set B-i ⊂ B, using Lemma A.5, for t = n− c−S, when ω denotes the highest realized value of a noise multiplier, we know that for λ ∈ [0, 1) with probability 1 − exp(cid:0)−Ω(λ2t1/4/ω)(cid:1): (cid:101)F (S ∪ B) = (cid:88) (cid:88) i 1 c (cid:101)F(S ∪ B-i) (cid:18) (1 + λ)µ · (cid:19) (cid:33) i < 1 c ≤ (1 + λ)µ · ≤ (1 + λ)µ · (cid:32) (cid:32) ≤ (1 + λ)µ ·(cid:16) ≤ (1 + λ)µ ·(cid:16) ≤ (1 + λ)µ ·(cid:16) = (1 + λ)µ ·(cid:16) c(cid:88) i=1 1 c (cid:33) f (S) + FS(B-i) + 3t−1/4 max Bij∈{H(B-i)} fS(Bij) f (S) + 3t−1/4 Bij∈{∪i∈[c]H(B-i)} fS(Bij) + max FS(B-i) c(cid:88) i=1 1 c FS(B-i) (cid:17) f (S) + 3t−1/4fS(A(cid:63)) + f (S) + 3t−1/4fS(A(cid:63)) + F (S ∪ B) f (S) + 3t−1/4fS(A(cid:63)) + (1 − 1)F (S ∪ A(cid:63)) f (S) + 3t−1/4fS(A(cid:63)) + (1 − 1)fS(A(cid:63)) f (S) + fS(A(cid:63)) 3t−1/4 + (1 − 1) (cid:17)(cid:17) (cid:16) (cid:17) (cid:17) sufficiently large s.t. t ≥ 220/4, from lemmas A.4 and C.2 we know that for λ ∈ [0, 1) w.p. We now need to argue that (cid:101)F (S ∪ A(cid:63)) is sufficiently large to beat (cid:101)F (S ∪ B). Assuming n is 1 − e−Ω(λ2t1/4/ω):(cid:101)F (S ∪ A(cid:63)) = c(cid:88) (cid:101)F(S ∪ A(cid:63)) (cid:32) 1 c i=1 c(cid:88) (cid:16) > (1 − λ)µ · > (1 − λ)µ · (f (S) + (1 − 2)fS(A(cid:63))) f (S) + 1 c i=1 1 − 2v(H(A(cid:63) (cid:33) i )) · t−1/4(cid:17) · FS(A(cid:63)) 63 We therefore get that: (cid:101)F (S ∪ A(cid:63)) − (cid:101)F (S ∪ B) ≥ µ ≥ µ ≥ µ (1 − λ) · (f (S) + (1 − 2)fS(A(cid:63))) − (1 + λ) ·(cid:16) (cid:16) (cid:16) (cid:16) (cid:18) (cid:16) (1 − λ)(1 − 2)fS(A(cid:63)) − 2λf (S) − (1 + λ) (1 − λ)(1 − 2)fS(A(cid:63)) − 2λk 2 fS(A(cid:63)) − (1 + λ) (cid:16) f (S) + fS(A(cid:63)) 3t−1/4 + (1 − 1) 3t−1/4 + (1 − 1) fS(A(cid:63)) (cid:17)(cid:17)(cid:17) (cid:17) 3t−1/4 + (1 − 1) fS(A(cid:63)) (cid:19) (cid:16) (cid:17) (cid:17)(cid:19) (cid:17) (cid:18) (cid:18) (cid:18) (cid:18) ≥ µ · fS(A(cid:63)) ≥ µ · fS(A(cid:63)) ≥ µ · fS(A(cid:63)) > µ · fS(A(cid:63)) 3t−1/4 + (1 − 1) − (1 + λ) (1 − λ)(1 − 2) − 2λk 2 (1 − λ)(1 − 2) − 2λk 2 − 2 − λ2 − 1 − λ + 1 1 − λ − 2 − 2λk 2 − (1 + λ) (4 + (1 − 1)) (cid:19) (cid:19) (cid:18) 2k (cid:19)(cid:19) 2 1 − 32 − λ For any λ ≤ 2/2k the difference above is strictly positive. Conditioning on ω being bounded from above by t1/5 which happens with probability 1 − e−Ω(t1/5/ log t), since k ∈ O(log log n) we that the result holds with probability at least 1 − e−Ω(t1/10). Approximation Guarantee in Expectation Lemma (3.3). Let δ > 0 and assume k > 16/δ2, c = 16/δ. Suppose that in every δ/4-significant iteration of SM-GREEDY when S are the elements selected in previous iterations, A ∈ argmaxB:B=c (cid:101)F (S ∪ B), the bundle added A respects fS( A) ≥ (1− δ)FS(A). Let ¯S be the solution after (cid:98)k/c(cid:99) iterations. Then, w.p. ≥ 1 − 1/n2: f ( ¯S) = (1 − 1/e − 5δ)OPT. Proof. We will analyze the solution only on iterations that are δ/4 relevant since this is when we can apply the smoothing arguments. Since k > 16/δ2 and since each iteration is δ/4-significant, by Lemma 3.2 we know that in each iteration A ∈ argmaxB:B=c (cid:101)F (S ∪ B) respects with overwhelm- ing probability: FS(A) ≥ (1 − δ) max B:B=c FS(B) We will condition on the success of this event in every one of the (cid:98)k/c(cid:99) iterations. By a union bound the result will hold w.p. at least 1 − 1/n2. We assume that n is sufficiently large s.t. t ≥ 220/δ4. To account for the fact that we are only analyzing δ/4-significant iterations, we can compare against (1 − δ/4) of the optimal value: let k be the last δ/4-significant iteration and O ⊆ O be the subset of size k of the optimal solution whose value is largest. By submodularity: f ( O) ≥ (1 − δ/4)OPT 64 (25) Second, we argue that optimizing over sets of size c rather than singletons is inconsequential when k > c/. To be convinced, notice that when the algorithm selects c elements in every iteration the total number of elements selected will be k(cid:48) > k − c. Let O(cid:48) ∈ arg maxT :T≤k(cid:48) f (T ). As in previous arguments, from submodularity we have that: (1 − c/k)f ( O) ≤ f (O(cid:48)). Since k > c/ we have that: f (O(cid:48)) > (1 − δ)f ( O) > (1 − 2δ)OPT (26) We will henceforth analyze the algorithm against O(cid:48). In a similar manner to the analysis of the greedy algorithm which selects singletons at every stage i ∈ [k], we can analyze the greedy algo- rithm which selects sets of size c at every stage i ∈ [k(cid:48)/c]. To ease notation assume (cid:98)k(cid:48)/c(cid:99) = k(cid:48)/c. For a given stage of the algorithm, assume the set S has been previously selected and that a set A is being added into the solution. Let B(cid:63) = arg maxB⊆O(cid:48):B=c fS(B) and A(cid:63) = arg maxB:B=c fS(B). assumption in the statement Lemma 3.2 applied with  = δ Lemma 3.1 and c ≥ 1/δ maximality of A(cid:63) subadditivity. FS(B) fS( A) ≥ (1 − δ) max B:B=c > (1 − 2δ)FS(A(cid:63)) > (1 − 3δ)fS(A(cid:63)) > (1 − 3δ)fS(B(cid:63)) > (1 − 3δ) = (1 − 3δ) ≥ (1 − 3δ) c c k(cid:48) ·(cid:0)f (O(cid:48) ∪ S) − f (S)(cid:1) k(cid:48) · fS(O(cid:48)) k(cid:48) ·(cid:0)f (O(cid:48)) − f (S)(cid:1) c A standard inductive argument stating that at every iteration i ∈ (cid:98)k/c(cid:99) we have that the value of the current solution is at least(cid:0)1 − (1 − 1/(cid:98)k/c(cid:99))i(cid:1) OPT implies that f ( ¯S) ≥ (1 − 1/e − 3δ) f (O(cid:48)). Since we lose 2δ from (26) this concludes our proof. From Expectation to High Probability Definition C.3. For a given set S, let A(cid:63) ∈ argmaxB:B=c fS(B), A ∈ argmaxB:B=c (cid:101)F (S ∪ B), and A = {Aij}i∈A,j /∈A. For a fixed  > 0: • Aij ∈ A is -good if fS(Aij) ≥ (1 − 2)fS(A(cid:63)); let good(A) denote all -good Aij ∈ A; • Aij ∈ A is -bad if fS(Aij) ≤ (1 − 3)fS(A(cid:63)); let bad(A) denote all -bad Aij ∈ A. Claim C.4. For a set S ⊆ N let A ∈ argmaxB:B=c (cid:101)F (S ∪ B) and assume the iteration is /8-significant and that c ≥ /2. Then with probability at least 1 − 1/n10: • good(A) ≥ c(n−c−S) • bad(A) ≤ c(n−c−S) 2 . 2 ; 65 Proof. Since the sets Aij are distinct both good(A) and bad(A) contain no repetitions and we can argue about their size. To lower bound the size of good(A), let A(cid:63) ∈ argmaxA:A=c fS(A). When the iteration is /8-significant, from Lemma 3.2 we know that with exponentially high probability: When c ≥ 2/, from Lemma, we know that: FS(A) ≥ (1 − /2)FS(A(cid:63)) FS(A(cid:63)) ≥ (1 − /2)fS(A(cid:63)) Denoting m = c(n − c − S), we get with exponentially high probability: m(cid:88) c(cid:88) FS(A) = 1 m j=1 i=1 fS(Aij) ≥ (1 − )fS(A(cid:63)) (27) m(cid:88) c(cid:88) In addition, due to the maximality of A(cid:63) we have that fS(Aij) ≤ fS(A(cid:63)) for every i, j. Therefore: fS(Aij) ≤ good(A) · fS(A(cid:63)) + (m − good(A)) · (1 − 2)fS(A(cid:63)) (28) j=1 i=1 Putting (27) and (28) together we get that for sufficiently large n, with probability at least 1−1/n10: m(1 − )fS(A(cid:63)) ≤ ( good(A) + (m − good(A))(1 − 2)) fS(A(cid:63)) Rearranging and using m = c(n − c − S) we get that good(A) ≥ c(n − c − S)/2. Since there are a total of c(n − c − S) it follows that bad(A) ≤ c(n − c − S) as required. Definition C.5. Let ρ(x) denote the probability density function of the noise distribution. For a set S : S ∈ O(log n), c > 0, γ > 0, we define θg and θb as: • (cid:82) ∞ • (cid:82) ∞ θb θg ρ(x)dx = c(n−c−S) log n; 2 ρ(x)dx = 2 log n c(n−c−S). The following claim immediately follows from the definition, yet it is still useful to specify ex- plicitly. The claim considers c(n − c − S)/2 samples since this is an upper and lower bound on good(A) and bad(A). Therefore the claim gives us the likelihood that the largest noise multi- plier of bad(A) does not exceed θb and that at least one set from good(A) exceeds θg. Claim C.6. For a fixed set S and A ∈ argmaxB:B=c (cid:101)F (S ∪ B), let m = c(n− c−S) and consider m/2 • Pr(cid:2)max{ξ1, . . . ξm/2} ≤ θb • Pr(cid:2)max{ξ1 . . . ξm/2} ≥ θg independent samples from the noise distribution. Then: (cid:16) (cid:3) > (cid:3) > 1 − 2/n. 1 − 2 (cid:17) log n ; 66 Proof. For a single sample ξ from D, we have that: Pr[ξ ≤ θb] = 1 − 2 m log n If we take m/2 independent samples ξ1, . . . ξm/2, the probability they are all bounded by θb is: Pr(cid:2)max{ξ1, . . . ξ bad(A) } ≤ θb (cid:3) ≥ (cid:18) (cid:19) m 2 (cid:18) (cid:19) 1 − 2 m log n > 1 − 2 log n In the case of θg, the probability that a single sample ξ taken from D is at most θg is equal to: Pr [ξ ≤ θg] = 1 − 2 log n m If we take independent samples ξ1, . . . ξm/2, the probability they are all bounded by θg is: Pr(cid:2)max{ξ1, . . . ξc(n−c−S)} ≤ θg (cid:18) (cid:3) = Pr(cid:2)max{ξ1 . . . ξm/2} ≥ θg 2 1 − 2 log n (cid:19) m (cid:3) > 1 − 2/n. m < 2 2log n = 2 n And accordingly the probability that at least one of these samples is greater than θg is: Showing θg is arbitrarily close to θb. Lemma C.8 below relates θg and θb assuming that D has a generalized exponential tail. This lemma makes the result applicable for Exponential and Gaussian distributions, and it fully leverages the fact that k ∈ O(log log n). The lemma is quite technical, and we therefore first prove the much simpler case where the distribution is bounded. Lemma C.7. Assume D has a generalized exponential tail and that D is bounded, then for all γ ∈ Ω(1/ log log n) we have that θg ≥ (1 − γ) θb. Proof. Let χ be an upper bound on D. If there is an atom at χ with some probability γ > 0, then we are done, as θg = θb = χ. Otherwise, since D has a generalized exponential tail we know that ρ(χ) = γ for some γ > 0, and that ρ is continuous at χ. But then there is some δ > 0 such that for any χ − δ ≤ x ≤ χ we have that ρ(x) ≥ γ/2. Choosing n to be large enough that (1 − )γ > γ − δ, we have that (cid:90) γ ρ(x) ≥ γ/2 Choosing n large enough such that (1−)γ Gives that θg ≥ (1 − )χ. As θb ≤ χ we are done. 2 log n c(n − c − S) < γ/2 67 Lemma C.8. If D has a generalized exponential tail then (1 − γ) θb ≤ θg, ∀ γ ∈ Ω(1/ log log n). Proof. The proof follows three stages: that(cid:82) ∞ θg 1. We use properties of D to argue upper and lower bounds for ρ(x); 2. We show an upper bound M on θb; 3. We show that integrating a lower bound of ρ(X) from (1 − γ)M to ∞, yields a probability γ c(n−c−S). Now suppose for contradiction that θg < (1 − γ) θb, we would get mass at least log n ρ(x) is strictly greater than log n γ c(n−c−S), which contradicts the definition of θg. e−g(x), where g(x) =(cid:80) x ≥(cid:16) log n We now elaborate each on stage. Recall that by definition of D for x ≥ x0, we have that ρ(x) = i aiαi and that we do not assume that all the αi's are integers, but only that α0 ≥ α1 ≥ . . ., and that α0 ≥ 1. We do not assume anything on the other αi values. For the first stage we will show that for every g(x), there exists n0 such that for any n > n0 and (cid:17)1/α0 we have that for β = γ /100 < 1/100: 2a0 (1 + β)a0xα0−1e−(1+β)a0xα0 ≤ ρ(x) ≤ (1 − β)a0xα0−1e−(1−β)a0xα0 We explain both directions of the inequality. To see a0xα0−1(1 + β)e−(1+β)a0xα0 ≤ ρ(x) we first show: This holds since for sufficiently large n, we have that: e−(1+β/2)a0xα0 ≤ ρ(x) (cid:18) 2(cid:80) i=1 ai βa0 (cid:19)α0−α1 x ≥ (log n)1/α0 2a0 ≥ So the term β 2 xα0 dominates the rest of the terms. We now show that: e−(1+β/2)a0xα0 ≥ a0xα0−1(1 + β)e−(1+β)a0xα0 This is equivalent to: eβa0/2xα0 ≥ a0xα0−1(1 + β) Which hold for x = log log3 n and large enough n. The other side of the inequality is proved in a similar way. We want to show that: ρ(x) ≤ (1 − β)a0xα0−1e−(1−β)a0xα0 Clearly for x > log log3 n we have that (1 − β)a0xα0−1 > 1. Hence we just need to show that: ρ(x) ≤ e−(1−β)a0xα0 But this holds for sufficiently large n s.t.: x ≥ (log n)1/α0 2a0 ≥ (cid:19)α0−α1 (cid:18)(cid:80) i=1 ai βa0 68 We now proceed to the second stage, and compute an upper bound on θb. Note that if (cid:90) ∞ (cid:90) ∞ ρ(x) = g(x) θb M and for every x ≥ M we have ρ(x) ≤ g(x) then it must be that M ≥ θb. Applying this to our setting, we bound ρ(x) ≤ (1 − β)a0xα0−1e−(1−β)a0xα0 to get: 1 c(n − c − S) log n (1 − β)a0xα0−1e−(1−β)a0xα0 (cid:90) ∞ M = = −e−(1−β)a0xα0∞ = e−(1−β)a0M α0 M Taking the logarithm of both sides, we get: −(1 − β)a0M α0 = log 1 c(n − c − S) log n = − log(c(n − c − S) log n) Multiplying by −1, dividing by (1 − β)a0 and taking the 1/α0 root we get: (cid:16) log n M = (cid:19)α0 (cid:18) log(c(n − c − S) log n) (cid:17)1/α0 and hence our bounds on ρ(x) hold for this regime. (1−γ)M ρ(x) from below. If we show that:(cid:82) ∞ (1 − β)a0 Note that (1 − γ)M > We move to the third stage, and bound(cid:82) ∞ 2a0 (1−γ)M ρ(x) is γ c(n−c−S), this implies that θg ≥ (1 − γ)M, as θg is defined as the value such that log n greater than when we integrate ρ(x) from θg to ∞ we get exactly log n γ c(n−c−S). We show: (cid:16) log(c(n−c−S) log n) (cid:17) (1−β) However a0M α0 = both expressions we get: . Since β < 0.1 we have that 1+β 1−β < 1 + 3β. Substituting (cid:90) ∞ (1−γ)M ρ(x) ≥ (1 + β)a0α0xα0−1e−(1+β)a0xα0 (1−γ)M = −e−(1+β)a0xα0∞ = e−(1+β)a0((1−γ)M )α0 = e−(1+β)a0M α0 (1−γ)α0 ≥ e−(1+β)a0M α0 (1−γ) e−(1+β)a0M α0 (1−γ) ≥ e−(1+3β)(1−γ) log(c(n−c−S) log n) (cid:19)(1−γ)(1+3β) (cid:19)(1−γ /2) (cid:18) (cid:18) = ≥ 1 c(n − c − S) log n 1 c(n − c − S) log n 69 Where we used that β = γ /100 and hence (1 − γ)(1 + 3β) < 1 − γ /2. We now need to compare this to γ c(n−c−S). To do this, note that: log n √ (cid:18) 1 c(n − c − S) log n (cid:19)(1−γ /2) ≥ c(n − c − S)1−γ /2 log n 1 √ 2 log n ≥ ≥ c(n − c − S) log n log n γ c(n − c − S) √ 2 log(n − c − S) > Where n is large enough that γ θg ≥ (1 − γ)M ≥ (1 − γ) θb as required. Lemma (3.4). For any  > 0, suppose we run SM-GREEDY where in each iteration we add a bun- dle of elements of size c = 16/. For any /8-significant iteration where the set previously selected is probability at least 1 − 3/ log n we have that: S : S ∈ O(log log n), let A ∈ argmax(cid:101)F (S ∪ A) and A = argmax(i,j)∈A×N\S∪A (cid:101)f (S ∪ Aij). Then, with log n. This completes the proof, since fS( A) ≥ (1 − 3)FS(A). Proof. We will use the above claims to argue that with probability at least 1 − 4/ log n the noisy mean value of any set in bad(A) is smaller than the largest noisy mean value of a set in good(A). Since a bad set is defined as a set B for which fS(B) ≤ (1 − 3)fS(A(cid:63)) this implies that the set returned by the algorithm has value at least (1 − 3)fS(A(cid:63)). Since for any set A : A = c we have that fS(A(cid:63)) is an upper bound on FS(A) will complete the proof. We will condition on the event that good(A) ≥ c(n − c − S)/2 which happens with probability at least 1 − 1/n10 from Claim C.4. Under this assumption, from Claim C.6 we know that with probability at least 1− 2/n at least one of the noise multipliers of sets in good(A) has value at least θg, and from Lemma C.8 we know that θg ≥ (1 − γ) θb for any γ ∈ Θ(1/ log log n). Thus: max Aij∈good(A) f (S ∪ Aij) = ≥ ≥ max Aij∈good(A) ξAij × θg × (1 − γ) θb × [ [ f (S) + fS(Aij) f (S) + (1 − 2)fS(A(cid:63)) f (S) + (1 − 2)fS(A(cid:63)) ] ] Let B ∈ argmaxC∈bad(A) (cid:101)f (S ∪ C). From Claim C.6 we know that w.p. at least 1 − 2/ log n all noise (cid:101)f (S ∪ B) = max ξAij f (S ∪ Aij) ≤ θb ·[f (S) + (1 − 3)fS(A(cid:63))] multipliers of sets in bad(A) are at most θb. Thus: f (S ∪ Aij) = max ] [ Aij∈bad(A) Aij∈bad(A) Let d be some constant such that S ≤ d log log n. Note that the iteration is -significant, and therefore due to the maximality of A(cid:63) and since f (S) ≤ OPT and the optimal solution has at most d · log log n elements we have that: fS(A(cid:63)) ≥  d log log n f (S). 70 Since Lemma C.8 applies to any γ ∈ Θ(1/ log log n), we know that for any constant d there is a large enough value of n such that γ < 2/3d log log n. Putting it all together and conditioning on all events we have with probability at least 1 − 3/ log n: (1 − γ) θb ·[f (S) + (1 − 2)fS(A(cid:63))] θb ·[f (S) + (1 − 3)fS(A(cid:63))] (cid:17) −(cid:16) ] (cid:17) (cid:17) (cid:3) (cid:17) (cid:3) (cid:17) (cid:3) (cid:17) (cid:101)f (S ∪ A) − (cid:101)f (S ∪ B) ≥ (cid:16) (cid:16) (cid:16) (cid:16) (cid:16) (cid:16) ≥ θb ≥ θb = θb fS(A(cid:63)) > θb fS(A(cid:63)) > θb fS(A(cid:63))  fS(A(cid:63)) − γ fS(A(cid:63)) − γ − γ − − 2 3   2 (cid:17) 3d log log n × [ × (cid:2) × (cid:2) × (cid:2) (1 − 2)fS(A(cid:63)) + f (S) (1 − 2)fS(A(cid:63)) + (1 − 2) (1 − 2) + +    d log log n fS(A(cid:63)) d log log n d log log n > 0 Since the difference is strictly positive this implies that with probability at least 1 − 3/ log n a bad set will not be selected by the algorithm which concludes our proof. Approximation Guarantee of SM-Greedy 2N → R and  > 0, when Theorem C.9. For any monotone submodular function f k ∈ Ω(1/) ∩ O(log log n), there is a (1 − 1/e − ) approximation for maxS:S≤k f (S), with probability 1 − 4/ log n given access to a noisy oracle whose distribution has a generalized exponential tail. : f ( A) ≥ (1−δ)FS(A), where A ∈ argmaxB:B=c (cid:101)F (B). We can then apply Lemma 3.3 which implies Proof. First, for the case in which k ∈ Ω(1/2), we can apply SM-GREEDY as described in the main body of the paper. Let δ = /5 and set c = 16/δ. At any given δ/8-significant iteration of SM-GREEDY from Lemma 3.4 we know that with probability at least 1 − 3/ log n we have that that with probability at least 1 − 4 In the case k ∈ Ω(1/) ∩ O(1/2) note that taking bundles of size c ∈ O(1/) in each iteration may result in a 1/2 approximation. In this case, we therefore enumerate over all possible sets of size w.p. 1 − 3 log n: c = k and output A = argmax(cid:101)f (Aij) where A = argmaxB:B=k (cid:101)F (B). By Lemma 3.4 we know that log n we have a 1 − 1/e − 5δ = (1 − 1/e − ) approximation. f ( A) ≥ (1 − 48/c)F (A) = (1 − 48/k)F (A) ≥ (1 − /2)F (A) (29) By the smoothing lemma (Lemma 3.2) we know that for any fixed  and sufficiently large n with overwhelming probability F (A) ≥ (1 − /2)F (A(cid:63)) for A(cid:63) ∈ argmaxB:B=k f (B). By the sampled mean method (Lemma 3.1) we know that F (A(cid:63)) ≥ (1 − 1/k)f (A(cid:63)), thus: F (A) ≥ (1 − 1/k − /2)f (A(cid:63)) (30) Putting (29) and (30) together and taking a union bound we get our result. 71 D Optimization for Very Small k Smoothing Guarantees Lemma (4.1). Let A ∈ argmaxB:B=k (cid:101)F (B). Then, for any fixed  > 0 w.p. 1 − e−Ω(2(n−k)): F (A) ≥ (1 − ) max B:B=k F (B) Proof. The proof follows the same reasoning as those from previous sections. Let A(cid:63) = argmaxB:B=k F (B). We will show that w.h.p. no set B for which F (B) < (1 − )F (A(cid:63)) beats A. The size of the smoothing set is t = n − k, and ω is an upper bound on the noise multiplier. Note that the optimality of A(cid:63) and submodularity imply that f (A(cid:63)∪x) ≤ 2f (A(cid:63)), for all x ∈ N\A(cid:63). Hence from monotonicity the variation is bounded by 2: maxx∈N\A f (A(cid:63) ∪ x) minx∈N\A f (A(cid:63) ∪ x) ≤ 2f (A(cid:63)) f (A(cid:63)) v(A(cid:63)) = = 2 We can therefore apply Lemma A.5 and get that with probability at least 1 − eΩ(λ2t1/4/ω): To upper bound (cid:101)F (B) for a set B s.t. F (B) < (1 − )F (A(cid:63)), note that the value of largest set in the smoothing neighborhood is maxx∈N\B f (B ∪ x) ≤ 2f (A(cid:63)). Hence, from Lemma A.4 we get that with probability at least 1 − eΩ(λ2t1/4/ω): 1 − 4t−1/4F (A(cid:63)) (cid:101)F (A(cid:63)) ≥ (1 − λ)µ (cid:16) (cid:17) (cid:17) (cid:16) F (B) ≤ (1 + λ)µ F (B) + 6t−1/4F (A(cid:63)) Therefore when n is sufficiently large s.t. t−1/4 ≤ /100 and λ < 1 we get that: F (A(cid:63)) − F (B) ≥ (1 − λ)µ(1 − 4t−1/4)F (A(cid:63)) − (1 + λ)µ (cid:18) (cid:18) ≥ µ (1 − λ)(1 − 4 100 (1 − λ)(1 − 4 100 ≥ µ > µ · F (A(cid:63)) ( − 2λ − /5) F (B) + 6t−1/4F (A(cid:63)) )F (A(cid:63)) − (1 + λ)(1 − )F (A(cid:63)) − (1 + λ) 6 100 6 100 )F (A(cid:63)) − (1 + λ)(1 − )F (A(cid:63)) − (1 + λ) (cid:19) (cid:19) F (A(cid:63)) F (A(cid:63)) (cid:16) (cid:17) Using λ < /10 the above inequality is strictly positive. Conditioning on the event of ω being sufficiently small completes the proof. An Approximation Algorithm for Very Small k Approximation guarantee in expectation. We first present the algorithm whose approximation guarantee is arbitrarily close to k/(k + 1), in expectation. 72 1: A ← arg maxB :B=k (cid:101)F (B) Algorithm 5 EXP-SMALL-GREEDY Input: budget k 2: x ← select random element from N \ A 3: A ← random set of size k from A ∪ x 4: return A Theorem D.1. For any submodular function f : 2N → R, the algorithm EXP-SMALL-GREEDY obtains returns a (k/(k + 1) − ) approximation for maxS:S≤k f (S), in expectation, for any fixed  > 0. Proof. From Lemma 3.1 we know that f ( A) ≥ (k/(k + 1))F (A). Let A(cid:63) = argmaxB:B=k f (B). From monotonicity we know that f (A(cid:63)) ≤ F (A(cid:63)). Applying Lemma 4.1 we get that for the set F (A) ≥ (1 − )F (A(cid:63)). Hence: f ( A) ≥ F (A) ≥ (1 − ) F (A(cid:63)) ≥ (1 − ) f (A(cid:63)) > (cid:18) k (cid:19) k + 1 (cid:18) k (cid:19) k + 1 (cid:18) k (cid:19) k + 1 (cid:18)(cid:18) k (cid:19) k + 1 (cid:19) −  OPT. High probability. To obtain a result w.h.p. we modify the algorithm above. The algorithm enu- merates all possible subsets of size k − 1, and then select the set A ∈ argmaxB:B=k−1 (cid:101)F (B). The algorithm then selects A ∈ argmaxX∈H(A) (cid:101)f (X). A formal description is added below. 1: A ← arg maxB :B=k−1 (cid:101)F (B) 2: A ← argmaxx∈N\A (cid:101)f (A ∪ x) Algorithm 6 WHP-SMALL-GREEDY Input: budget k 3: return A The analysis of the algorithm is similar to the high probability proof from Section 3. Theorem (4.2). For any submodular function f : 2N → R and any fixed  > 0 and constant k, there is a (1 − 1/k − )-approximation algorithm for maxS:S≤k f (S) which only uses a generalized exponential tail noisy oracle, and succeeds with probability at least 1 − 6/ log n. Proof. Let A ∈ argmaxB:B=k−1 (cid:101)F (B), and let A(cid:63) ∈ argmaxB:B=k−1 f (B). Since A(cid:63) is the optimal remains to show is that A ∈ argmaxx∈N\A (cid:101)f (A ∪ x) is a (1 − ) approximation to F (A). To do so solution over k− 1 elements, from submodularity we know that f (A(cid:63)) ≥ (1− 1/k)OPT. What now recall the definitions of good and bad sets from the previous section. Let δ = /3. Suppose that a set X is in δ-good(A) if f (X) ≥ (1 − 2δ)f (A(cid:63)) and in δ-bad(A) if f (X) ≤ (1 − 3δ)f (A(cid:63)). We will show that the set selected has value at least as high as that of a bad set, i.e. (1 − 3δ)f (A(cid:63)) which will complete the proof. We first show that with probability at least 1 − 6/ log n the noise multiplier of some good set is at least θg and of a bad set is at most θb. To do so we will first argue about the size of δ-good(A) 73 and δ-bad(A). From Lemma 4.1 and the maximality of A we know that with exponentially high probability F (A) ≥ (1 − δ)F (A(cid:63)). Therefore for m = n − k: (cid:88) x /∈A (cid:88) x /∈A(cid:63) F (A) = 1 m f (A ∪ x) ≥ (1 − δ) 1 m f (A(cid:63) ∪ x) ≥ (1 − δ)f (A(cid:63)) Due to the maximality of A(cid:63) and submodularity we know that f (A ∪ x) ≤ 2f (A(cid:63)) for all x /∈ A: f (A ∪ x) ≤ δ-good(A)2f (A(cid:63)) + (m − δ-good(A))(1 − 2δ)f (A(cid:63)) (cid:88) x /∈A Putting the these bounds on F (A) together and rearranging we get that: δ-good(A) ≥ δ · m 1 + 2 ≥ δm 3 Therefore, for sufficiently large n the likelihood of at least one set achieving value at least θg is: (cid:19) δm (cid:18) (cid:18) Pr[max{ξ1, . . . , ξδ·m/3} ≥ θg] ≥ 1 − 1 − 2 log n m 3 ≥ 1 − 2 nδ/3 ≥ 1 − 1 log n To bound δ-bad(A) we will simply note that it is trivial that δ-bad(A) < m. Thus, the likelihood that all noise multipliers of bad sets are bounded from above by θb is: (cid:19)m (cid:18) (cid:19) Pr [max{ξ1, . . . ξm} ≤ θb] ≥ 1 − 2 m log n > 1 − 4 log n Thus, by a union bound and conditioning on the event in Lemma 4.1 we get that θb is an upper bound on the value of the noise multiplier of bad sets and θg is with lower bound on the value of the noise multiplier of a good stem all with probability at least 1 − 6/ log n. From Lemma C.8 we know that for any γ ∈ Θ(1/ log log n) we have that θg ≥ (1 − γ) θb. Thus: max f (X) = max X∈δ-good(A) Let B ∈ argmaxC∈δ-bad (cid:101)f (S∪C). From Claim C.6 we know that with probability at least 1−2/ log n X∈δ-good(A) ξX f (X) ≥ θg ·(1 − 2δ)f (A(cid:63)) ≥ (1 − γ)Mb · (1 − 2δ)f (A(cid:63)) all noise multipliers of sets in bad(A) are at most θb. Thus: (cid:101)f (S ∪ B) = max (cid:101)f ( A) − (cid:101)f (B) ≥ Mbf (A(cid:63)) · ((1 − γ)(1 − 2δ) − (1 − 3δ)) > θb f (A(cid:63)) (δ − γ) ξX f (X) ≤ Mb · (1 − 3δ)f (X) f (X) = max X∈bad(A) Putting it all together we have with probability at least 1 − 6/ log n: X∈δ-bad Since Lemma C.8 applies to any γ ∈ Θ(1/ log log n), and δ is fixed it applies to γ < δ and the difference is positive. Since δ = /6 this completes our proof. 74 Information Theoretic Lower Bounds for Constant k Surprisingly, even for k = 1 no algorithm can obtain an approximation better than 1/2, which proves a separation between large and small k.5 The following is a tight bound for k = 1. Claim D.2. There exists a submodular function and noise distribution for which w.h.p. no randomized √ algorithm with a noisy oracle can obtain an approximation better than 1/2 + O(1/ n) for maxa∈N f (a). Proof. We will construct two functions that are identical except that one function attributes a value of 2 for a special element x(cid:63) and 1 for all other elements, whereas the other is assigns a value of 1 for each element. In addition, these functions will be bounded from above by 2 so that the only queries that gives any information are those of singletons. More formally, consider the functions f1(S) = min{S, 2} and f2(S) = min{g(S), 2} where g : 2N → R is defined for some x(cid:63) ∈ N as: (cid:40) g(S) = if S = x(cid:63) 2, S, otherwise √ The noise distribution will return 2 with probability 1/ n and 1 otherwise. √ We claim that no algorithm can distinguish between the two functions with success probability greater than 1/2 + O(1/ n). For all sets with two or more elements, both functions return 2, and so no information is gained when querying such sets. Hence, the only information the algorithm √ has to work with is the number of 1, 2, and 4 values observed on singletons. If it sees the value 4 n. on such a set, it concludes that the underlying function is f2. This happens with probability 1/ Conditioned on the event that the value 4 is not realized, the only input that the algorithm has is the number of 1s and 2s it sees. The optimal policy is to choose a threshold, such if a number of 2s observed is or above this threshold, the algorithm returns f2 and otherwise it reruns f1. In this case, the optimal threshold is √ n + 1. √ √ n twos is 1/2 − 1/ √ The probability that f2 has at most least n + 1 twos, and hence the advantage over a random guess is O(1/ √ An algorithm which approximates the maximal set on f2 with ratio better than 1/2 + ω(1/ √ be used to distinguish the two functions with advantage ω(1/ approximation one can get is 1/2 + O(1/ n) can n). Having ruled this out, the best n) as required. √ n, and so is the probability that f1 has at √ n) again. We generalize the construction to general k. The lower for general k behaves like 2k/(2k − 1), where our upper bound is (k − 1)/k. Claim D.3. There exists a submodular function and noise distribution for which w.h.p. no randomized √ algorithm with a noisy oracle can obtain an approximation better than (2k − 1)/2k + O(1/ n) for the optimal set of size k. 5We note that if the algorithm is not allowed to query the oracle on sets of size greater than k, Claim D.2 can be extended to show aO(n) inapproximability, so choosing a random element is almost the best possible course of action. 75 Proof. Consider the function: 2S, 2k − 1, 2k, if S < k if S = k if S > k f1(S) = and the function f2, which is dependent on the identity of some random set of size k, denoted S(cid:63) :  2S, 2k − 1, 2k, 2k, if S < k if S = k, S (cid:54)= S(cid:63) if S = S(cid:63) if S > k f2(S; S(cid:63)) = Note that both functions are submodular. The noise distribution will return 2k/(2k − 1) with probability n−1/2 and 1 otherwise. Again we claim that no algorithm can distinguish between the functions with probability greater than 1/2. Indeed, since f1, f2 are identical on sets of size different than k, and their value only depends on the set size, querying these sets doesn't help the algorithm (the oracle calls on these sets can be simulated). As for sets of size k, the algorithm will see a mix of 2k− 1, 2k, and at most one value of 4k2/(k− 1). If the algorithm sees the value 4k2/(k− 1) then it was given access to f2. However, the n. Conditioning on not seeing this value, algorithm will see this value only with probability 1/ (n k)√ the best policy the algorithm can adopt is to guess f2 if the number of 2k values is at least 1 + n , and guess f1 otherwise. The probability of success with this test is 1/2 + O(1/ n) (regardless of whether the underlying function is f1 or f − 2). Any algorithm which would approximate the best set of size k to an expected ratio better than (2k − 1)/2k + ω(1/ √ n) could be used to distinguish between the function with an advantage greater than 1/ n, and this puts a bound of (2k − 1)/2k + O(1/ n) on the expected approximation ratio. √ √ √ √ 76 E Noise Distributions As discussed in the Introduction, our goal was to allow noise distribution in the model to po- tentially be Gaussian, Exponential, uniform and generally bounded. It was important for us that algorithm to be oblivious to the specific noise distribution, and rely on its properties only in the analysis. For achieve this we introduced the class of generalized exponential tail distributions. We recall the definition from the Introduction. Definition. A noise distribution D has a generalized exponential tail if there exists some x0 such that i aixαi. We do not assume that all the αi's are integers, but only that α0 ≥ α1 ≥ . . ., and that α0 ≥ 1. If D has bounded support we only require that either it has an atom at its supremum, or that ρ is continuous and non zero at the supremum. for x > x0 the probability density function ρ(x) = e−g(x), where g(x) =(cid:80) Note that the definition includes Gaussian and Exponential distributions. For i > 0 it is possible that αi < 1 which implies that a generalized exponential tail also includes cases where the prob- ability density function denoted ρ respects ρ(x) = ρ(x0)e−g(cid:48)(x−x0) (we can simply add ρ(x0) to g using αi = 0 for some i, and move from g(cid:48)(x − x0) to an equivalent g(x) via a coordinate change). The most important property of the noise distribution is that all of its moments are constant, inde- pendent of n. In fact, D describes how the noise affects a single evaluation, and does not depend on the number of elements. This means (for example) that if we could get h(n) independent samples from D, we would be arbitrarily close to the mean, as long as h(n) is monotone in n. Impossibility for distributions that depend on n. We note that if the adversary would have been allowed to choose the noise distribution as a function of n, then no approximation would be possible, even if the noise distribution had mean 1. For example, a noise distribution which returns 0 with probability 1 − 1/22n and 22n with probability 1/22n has an expected value of 1, is not always 0, but does not enable any approximation. Impossibility for two distributions. One can consider having multiple noise distributions which act on different sets. A noise distribution can be assigned to a set either in adversarial manner, or at random. If sets are assigned to noise distributions in an adversarial manner, it is possible to construct the bad example of the correlated case from Section 5 with just two noise distributions. If sets are assigned to a noise distribution in an i.i.d manner, this reduces to the i.i.d case when there is a single distribution. The relation between n and the distribution As we have explained above, if the distribution depends on n, then approximation is not possible. In particular, this means that if the universe is too small, optimization is not possible. For example, suppose that D returns 0 with probability 1 − 2−100, and otherwise returns 2100. Then D is bounded away from zero, has expectancy 1, but approximation is not possible if n = 50. Hence we need to assume some minimal value n0 that depends on the distribution, and assert an approximation ratio of 1 − 1/e −  only for n > n0. We note that n0 is constant, and hence if n ≤ n0 we can run the "optimal" algorithm of evaluating the noisy oracle over all subsets of n, but the approximation ratio might still be arbitrarily bad. 77 We note that the problem is not "just" an atom at zero. Suppose that f is additive, and bounded between 1 and 100. if D is uniform over the set 2100i for 1 ≤ i ≤ 2100 and n = 50 then approxima- tion is not possible; if f (A) turns out to be larger than f (B) this says very little about f (A), f (B) - it's more likely happen due to the noise. 78 F Additional Examples In this section we show some examples of how greedy and its variants fail under error and noise. Greedy fails with error. In the maximum-coverage problem we are given a family of sets that cover a universe of items, and the goal is to select a fixed number of sets whose union is maxi- mal. This classic problem is an example of maximizing a monotone submodular function under a cardinality constraint. For a concrete example showing how greedy fails with error, consider the instance illustrated in Figure 4. In this instance there is one family of sets A depicted on the left where all sets cover the same two items, and another family of disjoint sets B that each cover a single unique item. Consider an oracle which evaluates sets as follows. For any combination of sets the oracle evaluates the cardinality of the union of the subsets exactly, except for a few special cases: For S = A ∪ b ∀A ⊆ A, b ∈ B the oracle returns (cid:101)f (S) = 2, and for S ⊆ A the oracle returns (cid:101)f (S) = 2 + δ for some arbitrarily small δ > 0. With access to this oracle, the greedy algorithm will only select sets in A which may be as bad as linear in the size of the input. In this example we tricked the greedy algorithm with a 1/3-erroneous oracle, but same consequences apply to an -erroneous oracle for any  > 0 by planting (1 − )/ items in A. Greedy fails with random noise. In practice, the greedy algorithm is often used although we know the data may be noisy. Hence, a different direction for research could be to analyze the effect of noise on the existing greedy algorithm. Unfortunately, it turns out that the greedy algorithm fails even on very simple examples. Theorem F.1. Given a noise distribution that is either uniformly distributed in [1 − , 1 + ] for any  > 0, a Gaussian, or an Exponential, the greedy algorithm cannot obtain a constant factor approximation ratio even in the case of maximizing additive functions under a cardinality constraint. √ Proof sketch. Consider an additive function, which has two types of elements: k = n good ele- ments, each worth n1/4, and n − k bad elements, each worth 1. Suppose that the noise is uniform in [1 − , 1 + ]. Then after taking k2/3 good elements greedy is much more likely to take bad el- ements, which leads to an approximation ratio of O(1/n1/6). Similar examples hold for Gaussian and Exponential noise. Greedy fails when taking maximal sampled mean bundle. algorithm which iteratively takes bundles of O(1/) elements that maximize (cid:101)F (S ∪ B), where (cid:101)F (S ∪ A) =(cid:80) i∈A,j /∈S∪A (cid:101)f (S ∪ Aij). To see this can be arbitrarily bad, even when (cid:101)F ≈ F , consider In Section 3 we discuss a greedy an instance with n − 2 elements N(cid:48) s.t. for any S ⊆ N(cid:48) the function evaluates to f (S) = M for some arbitrarily large value M > 0, and an additional subset of elements A = {a1, a2} s.t. f (A) = f (a1) = f (a2) = , for some arbitrarily small  > 0. Now assume that for any S ⊆ N(cid:48) and i ∈ [2] we have f (S∪ ai) = M + . The sampled mean of A is maximal, its value is arbitrarily small. 79 Figure 4: An instance of max-cover for which the greedy algorithm fails with access to an oracle with error. 80 . . .
1902.02921
1
1902
2019-02-08T02:59:15
Are your Items in Order?
[ "cs.DS" ]
Items in many datasets can be arranged to a natural order. Such orders are useful since they can provide new knowledge about the data and may ease further data exploration and visualization. Our goal in this paper is to define a statistically well-founded and an objective score measuring the quality of an order. Such a measure can be used for determining whether the current order has any valuable information or can it be discarded. Intuitively, we say that the order is good if dependent attributes are close to each other. To define the order score we fit an order-sensitive model to the dataset. Our model resembles a Markov chain model, that is, the attributes depend only on the immediate neighbors. The score of the order is the BIC score of the best model. For computing the measure we introduce a fast dynamic program. The score is then compared against random orders: if it is better than the scores of the random orders, we say that the order is good. We also show the asymptotic connection between the score function and the number of free parameters of the model. In addition, we introduce a simple greedy approach for finding an order with a good score. We evaluate the score for synthetic and real datasets using different spectral orders and the orders obtained with the greedy method.
cs.DS
cs
Are your Items in Order? Nikolaj Tatti Department of Mathematics and Computer Science Universiteit Antwerpen [email protected] 9 1 0 2 b e F 8 ] S D . s c [ 1 v 1 2 9 2 0 . 2 0 9 1 : v i X r a Abstract Items in many datasets can be arranged to a natural order. Such orders are useful since they can provide new knowledge about the data and may ease further data exploration and visualization. Our goal in this paper is to define a statistically well-founded and an objective score measuring the quality of an order. Such a measure can be used for determining whether the current order has any valuable information or can it be discarded. Intuitively, we say that the order is good if depen- dent attributes are close to each other. To define the or- der score we fit an order-sensitive model to the dataset. Our model resembles a Markov chain model, that is, the attributes depend only on the immediate neighbors. The score of the order is the BIC score of the best model. For computing the measure we introduce a fast dynamic program. The score is then compared against random orders: if it is better than the scores of the random or- ders, we say that the order is good. We also show the asymptotic connection between the score function and the number of free parameters of the model. In addi- tion, we introduce a simple greedy approach for finding an order with a good score. We evaluate the score for synthetic and real datasets using different spectral or- ders and the orders obtained with the greedy method. 1 Introduction Seriation, discovering a linear order for the attributes, is a popular topic in data mining. The motivation for ordering the attributes comes from the fact that many datasets have an inherent order, for example, the loca- tion of genes in gene amplification data. In fields such as paleontology [1] or archaeology [2] discovering the order (age) of the sites is a fundamental question. There are many benefits once the order has been discovered. The data can visualized as a binary matrix for further anal- ysis. Also, the complexity of certain data mining algo- rithms, for example discovering tiles [3], can be reduced when we restrict ourselves to the discovered order. In this paper, we study measuring the quality of a given attribute order. Such a measure will help us to determine whether the order at hand is genuinely significant. We propose an intuitive and novel method for measuring the quality. In our approach an order is good if the attributes that are dependent of each other are close in the given order. Example 1. Assume that we have a dataset with 5 items, a1, . . . , a5, in which the value of attribute ai is generated from the value of the previous attribute ai−1 by copying it and flipping it with a (small) probability. We may now conclude that here the original order is good. Whereas, for example, an order a1, a4, a3, a5, a2 is bad since the attributes a1 and a2 are far away from each other. Our measure is a generalization of the idea given in the example. Given a dataset and an order we build a model that depends on the order. Our construction will be such that model is simple and has good likelihood if the dependent attributes are close. As a measure for goodness of the model we will use Bayesian Information Criteria (BIC) which favors simple models that fit data well. It turns out that we can find the model with the best BIC score through a fast dynamic program. Also, our model can be seen as a Markov Random Field (MRF) model in which the the items depend only on their immediate neighbors (see, for example, [4] for introduction to MRF). We compare the score of the discovered model against the scores of random orders, for example, we consider the probability that a random order will have a better score than the score of the given model. The probability is close to 0, if the order under investigation has an exceptionally good score. We study the asymptotic behavior of the score and show that asymptotically it is an increasing function of the number of free model parameters. Such a behavior is natural since we favor simple models yet surprising since the BIC penalty, the term through which the degree of freedom affects the score, vanishes as the number of data points grows. The rest of the paper is organized as follows. The preliminaries are given in Section 2 and the model itself is defined in Section 3. We explain the dynamic program for finding the best in Section 4. In Section 5 we consider spectral and greedy methods for inducing the order. In Section 6 we compare the score with random orders. We discuss the asymptotic behavior in Section 7. Section 9 is devoted to the related work and in Section 8 we describe our empirical results. Finally, we conclude the paper with a discussion in Section 10. 2 Preliminaries and Notation In this section we introduce the preliminaries and nota- tion that we will use in subsequent sections. A transaction t ∈ {0, 1}K is a binary vector of length K. A binary dataset is a collection of N transactions having the length K. We can easily visualize the dataset as a binary matrix of size N × K. We use the notation of D = N to express the number of transactions in D. An attribute ai, i = 1, . . . , K, is a random Bernoulli variable representing the ith element in a random transaction. We set A = {a1, . . . , aK} to be the collection of all attributes. Assume that we are given a distribution p defined over a space of binary vectors {0, 1}K. Let X = {x1, . . . , xL} ⊆ A be the collection of attributes. Let v = {0, 1}L be a binary vector of length L. We use the notation p(X = v) to mean the probability p (x1 = v1, . . . , xL = vL). Given a binary dataset D we define qD, an empirical distribution to be qD(A = v) = {t ∈ D; t = v} D . We assume that there is a specific linear order induced on the attributes. Such an order can be identified with a permutation function o mapping from (1, . . . , K) to (1, . . . , K). To ease the notation we often assume that o is the identity permutation, that is o(i) = i. Let X be a collection of attributes, we say that X is an item segment if X contains only consecutive attributes. For example, ao(1)ao(2)ao(3) is an item segment, however, ao(1)ao(2)ao(4) is not since ao(3) is missing. The entropy of an item segment X w.r.t. to the distribution p, denoted by H(X; p), is H(X; p) = −(cid:88) p(X = v) log p(X = v) , v where the usual convention 0× log 0 = 0 is used. All the logarithms in this paper is of base 2. We will shorten H(A; p) into H(p). We also write H(X; D) to mean H(X; qD). 3 Order-sensitive Model In this section we define our model that is based on the order of the attributes. Informally, our approach is based on generalizing simple markov chain model demonstrated in Example 1. We generalize this by allowing the item ai to depend on several previous items. However, we require that if ai depends on aj, then it also must depend on all items between aj and ai. Thus, our model will be simple if the dependent items are close to each other. segments C = {C1, . . . , CL}, that is, (cid:83) In order to make the preceeding discussion more item formal, assume that we are given a cover of i Ci = A. We assume that there is no Ci, Cj ∈ C such that Ci ⊂ Cj, that is, C is an antichain. We also assume that C is ordered based on the first attribute of each segment Ci. We define seg(o) to be the family of all such collections. Given the collection C we define a model M (C) to be a collection of distributions that can be expressed as (3.1) p(A) = = p(C1) p(Ci+1 − Ci Si) , (cid:81)L (cid:81)L−1 i=1 p(Ci) i=1 p(Si) L−1(cid:89) i=1 where Si = Ci+1 ∩ Ci. That is, the attributes in Ci − Ci−1 depend only on their immediate neighbors, Ci ∩ Ci−1. Example 2. Assume that C = {{a1} , . . . ,{aK}}, that is, each segment is simply a singleton. Then the attributes according to any distribution p ∈ M (C) are independent, p(A) =(cid:81)K i p(ai). The distribution p used to generate data in Exam- ple 1 can be written as p(a1)p(a2 a1)··· p(a5 a4) = (cid:81)4 (cid:81)4 i=1 p(aiai+1) . i=2 p(ai) Hence, p ∈ M ({a1a2, a2a3, a3a4, a4a5}). The other extreme is that C contains only one segment containing all items, C = {A}. In this case the distribution maximizing the likelihood is the empirical distribution, qD(A). More generally, if C is an ordered partition of A, then the distribution p ∈ M (C) has independent components Ci, p(A) =(cid:81) p(Ci). Hence we can view the general model that is, Ci ∩ Ci−1 = ∅, as a generalization of a partition of A by allowing the segments to overlap. Given a dataset D we define p∗ to be the the unique distribution from M (C) such that p∗(Ci = t) = qD(Ci = t) for any Ci ∈ C and any binary vector t of length Ci. We wish to show that p∗ maximizes the log-likelihood of D. To see this, let p ∈ M (C). Let us write Si = Ci ∩ Ci+1. Then we have log p∗(D) − log p(D) = D L(cid:88) (cid:88) i=1 t p∗(A = t) log p∗(Ci = tCi) p(Ci = tCi) . s(C) = DH(C; D) + log D 2 In order to compute the BIC score we can combine Eqs. 3.2 -- 3.3 in the following way. We define a score s(C) for an item segment C to be (cid:16) (cid:17) 2C − 1 . Similarly, given a collection C = {C1, . . . , CL} of item segments we define (3.4) s(C) = L(cid:88) s(Ci) − L−1(cid:88) s(Si) , i=1 i=1 that is, s(C) is the sum of the negative likelihood of the optimal distribution in M (C) and the BIC penalty term. Given an order o we define s(o) to be the score of the best possible model, s(o) = min (s(C) C ∈ seg(o)) . It is easy to see that minimizing the score produces simple models having high likelihood of the data. Note that if the dependent attributes are close to each other, the segments will be short. Hence the BIC punishment will be small. However, if the dependent attributes are far away, then the segments must be long and the BIC penalty is far greater. Hence, our score favors orders in which dependent attributes are close to each other. Example 3. Assume that we have a dataset D given by  1 1 0 1 0 1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 0 1 1 1  . The last equation is the (scaled) Kullback-Leibler divergence between p∗ and p It is always non-negative and is 0 if and only if p = p∗. Hence p∗ maximizes the likelihood. Let us compute the the log-likelihood of D given a distribution p∗ ∈ M (C), that is, the distribution maxi- mizing the likelihood. Let Si = Ci ∩ Ci+1. A straight- forward calculation reveals that the log-likelihood can be rewritten as a sum of entropies, (3.2) log p∗(D) = log p∗(A = t) (cid:88) = −D L(cid:88) t∈D H(Ci; D) + D L−1(cid:88) H(Si; D) . i=1 i=1 Our goal is to find a collection C for which the model provides high likelihood. The problem is that the model with the highest likelihood would be always for the collection C = {A}, for which the optimal distribution is simply the empirical distribution. To keep it from this behaviour we will use Bayesian Information Criteria (BIC) to punish more complex models over the simple ones [5]. Hence, our goal is to minimize the BIC cost function, − log p∗(D) + log D 2 deg(C) , (3.5) D = where deg(C) is the number of free parameters in the model M (C). To compute the number of free parameters, let us consider the right side of Eq. 3.1. The first component p(C1) can be parameterized with a real vector of length 2C1 − 1. Similarly, the ith component can be parameterized with a vector of length 2Ci−Si−1−1. Since the ith component depends on the values of Si−1 we need parameters for each combination of values of Si−1. There are 2Si−1 such values. The total number of free parameters is then equal to (3.3) deg(C) = 2C1 − 1 + 2Ci−Si−1 − 1 2Si−1(cid:16) L(cid:88) 2Ci − 1 − L−1(cid:88) i=2 2Si − 1. L(cid:88) = i=1 i=1 (cid:17) Assume also that our model is C = {ab, bcd, de}. We have S1 = C1 ∩ C2 = b and S2 = C2 ∩ C3 = d. The entropies for the segments are H(C1) = 1.52, H(C2) = 2.32, H(C3) = 1.52, H(S1) = 0.72, and H(S2) = 0.97. Hence the final score is s(C) =5 × (1.52 + 2.32 + 1.52 − 0.72 − 0.97) (3 + 7 + 3 − 1 − 1) = 31.13. log 5 + 2 We will finish this section by discussing the con- nection between the order and Bayesian networks. Our model can be seen as a Bayesian network, where item ai is a parent of aj, if and only if i < j and ai and (cid:122) a3 (cid:125) C2 (cid:125)(cid:124) (cid:124) a4 (cid:123) (cid:123)(cid:122) a5 C3 C4 (cid:122) (cid:125)(cid:124) (cid:123) (cid:125) a6 a7 a1 (cid:124) a2 (cid:123)(cid:122) C1 Figure 1: A toy example of an order-sensitive model. The model can be viewed as a special type of Bayes Network. aj belongs to the same segment (see Figure 1 for an example). If we interpret our model as a Bayesian net- par (ai)) = work, then it is easy to see that p∗(ai qD(ai par (ai)). In other words, the distribution p∗ is the maximum-likelihood estimate of the correspond- ing Bayesian network. In fact, the factorization of the BIC score in Eq. 3.4 is equivalent to the factorization obtained by performing a junction tree decomposition (see [4]) to the network. However, interpreting the model as a Bayesian network is somewhat misleading, since our model does not change if we reverse the order of the items. 4 Finding the Optimal Model In this section we demonstrate how we can find the collection of item segments having the minimal score s(C). We do this by constructing a dynamic program. Furthermore, we demonstrate how we can prune a large amount of long segments, and thus reducing the required execution time. In addition, we discuss how to efficiently compute the entropy using a particular tree structure. 4.1 Forming the Dynamic Program Our goal is to find a collection C for which the score s(C) is the smallest possible. We achieve this by using dynamic program and solving subproblems. In order to do this we set f (i, j) to be the best collection of segments covering the attributes {ai, . . . , aK} such that the first segment has the attribute aj The optimal collection would be then f (1, 1). To compute the values of f we use the following order: f (K, K), f (K − 1, K), f (K − 1, K − 1), . . . . . . , f (1, K), . . . , f (1, 1). To compute f (i, j) we first note that either f (i, j) has X = ai ··· aj as its first segment or f (i, j) = f (i, j + 1). Let H be the optimal collection having X as the first segment. The second segment of H must cover j + 1 and must start at k = i + 1, . . . , j + 1. Hence, we have H = arg min i<k≤j+1 s(X ∪ f (k, j + 1)) . Once we have discovered H we can set f (i, j) = arg min (s(H) , s(f (i, j + 1))) . The details of the algorithm are given in Algorithm 1. Algorithm 1: Dynamic program solving the optimal collection of segments. 1 for i = K, . . . , 1 do 2 f (i, K) ← ai ··· aK; 3 for i = K − 1, . . . , 1 do for j = K − 1, . . . , i do 4 5 6 7 8 9 10 X ← ai ··· aj; H ← X ∪ f (i + 1, j + 1); for k = i + 2, . . . , j + 1 do H ← X ∪ f (k, j + 1); if s(H) < s(X ∪ f (k, j + 1)) then f (i, j) ← arg min (s(H) , s(f (i, j + 1))); 11 return f (1, 1); Algorithm 1 is O(cid:0)K 3(cid:1). K min (K, log D)2(cid:17) (cid:16) 4.2 Pruning Long Segments The running time for In this section we introduce a pruning condition and reduce the running time to O . This improvement is crucial since log D is typically much smaller than K. We begin by asserting the necessary criteria for a segment occurring in the optimal collection. Lemma 4.1. Let X, Y be segments of length N having N − 1 mutual items. If s(X ∪ Y ) ≥ s(X) + s(Y ) − s(X ∩ Y ) , (4.6) then there is a collection without X ∪ Y having an optimal score. Proof. Let C be a collection with the optimal score. Assume that X ∪ Y ∈ C. Assume that X and Y are not included in some Si, that is, the only set in C that contains X or Y is X ∪ Y . We can build an alternative collection by replacing X ∪ Y with separate X and Y . The impact on the score is that we replace the term s(X ∪ Y ) with the terms s(X) + s(Y ) − s(X ∩ Y ). The assumption now implies that this alternative model will have a better or an equal score. Assume now that X is one of the Si but Y is not. Then if we replace X ∪ Y with Y we replace the terms s(X ∪ Y ) − s(X) with the terms s(Y ) − s(X ∩ Y ). The assumption now implies that the new has a better or an equal score. The case is similar for Y . If X and Y are both included in some Si, then by simply removing X∪Y we replace the terms s(X ∪ Y )− s(X)−s(Y ) with −s(X ∩ Y ). This completes the proof. We can use the lemma to prune a large number of segments from dynamic program. if the segment is long enough, then the lemma is automatically guaranteed. In fact, Proposition 4.1. Let X, Y be segments of length N having N − 1 mutual items. If N ≥ log D − log log D + 2, then s(X ∪ Y ) ≥ s(X) + s(Y ) − s(X ∩ Y ). The idea behind the proof is that the BIC penalty for long segments is too large when compared to the gain from obtained from the likelihood. Proof. Let us write V = X ∩ Y and W = X ∪ Y and Z = X−Y . By using the definition of the score function we can rewrite the inequality in Eq. 4.6 as (4.7) 2N−2 log D ≥ D (H(X) + H(Y ) − H(V ) − H(W )) . To guarantee this inequality we will bound the right side from above. Let A and B be two sets of items. Basic properties of the entropy state that H(A) + H(B) ≥ H(A ∪ B) ≥ H(A). This immediately implies that H(Y ) − H(W ) ≤ 0 and that H(X) − H(V ) = H(V ∪ Z) − H(V ) ≤ H(V ) + H(Z) − H(V ) = H(Z) ≤ 1. The last inequality is true since, by definition, Z = X−Y contains only one item and the entropy of a single Bernoulli variable is 1, at maximum. This implies that the right side of Eq. 4.7 is bounded by D. Hence we have the sufficient condition 2N−2 log D ≥ D. By taking the logarithm we obtain the assessment of the proposition. The proposition tells us that we can safely ignore length log D − log log D + 3 ∈ any segments of O (log D), or longer. Thus, by modifying Line 2 in Algorithm 1 we can ignore computing f (i, j) if j − i is large enough. This speeds up the execution time of Algorithm 1 to O which can be very effective for datasets with many attributes but small number of transactions. K min (K, log D)2(cid:17) (cid:16) 4.3 Computing Entropy Efficiently In our exper- iments the bottleneck is the entropy calculation. Con- sequently, it is to optimize the computation to be as fast as possible. In this section we will show that in our case, computing entropy for a single segment can be in essentially O(D) time. Assume that we want to compute entropy H(C; D) for a given item segment C. To compute this we first partition the transaction into groups {T1, . . . , TL}, such that transactions t and u belong to the same group Ti if and only if tC = uC. Then it follows directly from the definition that H(C; D) = − L(cid:88) Ti D log Ti D . i=1 Constructing the partition for a single item segment from a scratch can be done in O(CD) time by a radix sort. We can, however, speed up the total execution time by computing the entropies of several segments simultaneously. More precisely, if we are given indices s and e such that s < e, then Algorithm 2 will output entropies for segments as ··· aj, where s ≤ j ≤ e. Algorithm 2: Algorithm for computing en- tropies H(as), H(asas+1), . . . , H(as ··· ae). 1 T1 ← D; 2 for j = s, . . . , e do 3 foreach Ti in the partition do U ← ∅; foreach t ∈ Ti, tj = 1 do Remove t from Ti and add to U ; if Ti = ∅ then Remove Ti from the partition; if U (cid:54)= ∅ then Add U to the partition; H(as ··· aj) ← −(cid:80)L Ti D log Ti D ; i=1 4 5 6 7 8 9 The execution time of Algorithm 2 is O((e − s + 1)D) but it will compute entropies for e−s+1 segments simultaneously. We use this algorithm to cache all the needed entropies before we invoke the dynamic program in Algorithm 1. We need only K calls of Algorithm 2, one call for each s = 1, . . . , K. Inducing the Order 5 So far we have assumed that we are given an order and we have focused on measuring the quality of that order. In this section, we will consider different techniques for inducing the order from the data. 5.1 Fiedler Vector Approach Assume for the mo- ment that we are interested in a model that have seg- ments only of size 2. We are interested in finding the order that produces the best model. We define C, the mutual information matrix of size K × K to be Cij = H(ai) + H(aj) − H(aiaj) . Discovering the best order reduces to Traveling Salesman Problem which is a computationally infeasible problem [6]. We will use a popular technique in which the order is constructed from a Fiedler vector [7]. To be more precise, let the Laplacian of C be L = diag(C) − C, where diag(C) is a diagonal matrix containing the sums of the rows of C. The Fiedler vector f (C) is the eigenvector of L of the second smallest eigenvalue. The order induced by this vector is simply the order of indices of the sorted entries of the vector. If we were to permute the attributes, then entries in the Fiedler vector are shuffled with the exactly same permutation. Thus, the fiedler order is not affected by the original order of the attributes. We will justify our choice by showing that the Fiedler vector does return the best order in some cases. To be more specific, assume for a moment that the attribute ai depends only on its immediate neighbor ai−1. In other words, we assume that the data is generated from a model constructed from the segments {ai−1ai i = 2, . . . , K}. If that is the case, then the mutual information matrix C has a special property: the entries of C are decreasing as we move from the diagonal towards the corners. That is, max(cid:0)Ci(j+1), C(i−1)j (cid:1) < Cij, for i < j, (5.8) and similarly for the lower triangular part of C. Such a matrix is called R-matrix [8]. The following theorem states that for R-matrices, the Fiedler vector finds the correct order. Theorem 5.1. (Theorem 3.3 in [8]) Let C be such that the property in Eq. 5.8 holds. Then the Fiedler vector f (C) will have fi > fj whenever i < j. Motivated by this result we consider in this paper 4 different approaches for computing the order. 1. mi = f (C) uses the order obtained from the Fiedler vector of the mutual information matrix. 2. m2 = f (C(cid:48)), where C(cid:48) ij = Cij except when Cij ≤ log D/2D in which case C(cid:48) ij = 0. The motivation behind this approach is as follows. The mutual information Cij can be viewed as a difference of the log-likelihoods. The first model is the independence model M1 and has the log-likelihood −H(ai) − H(aj). The second model M2 is the full contingency table model and has the log-likelihood −H(aiaj). Here the idea is that instead of always comparing M2 against M1, we first select the one model that is more probable. If we select M2, then the difference is the mutual information. If, on the other hand, we select M1, then the difference will be 0. If we use BIC score as a criteria for selecting the model, then M1 will have a better score if and only if Cij ≤ log D/2D. In other words, if Cij is too small compared to the BIC penalty, then we treat ai and aj as independent, and set the mutual information to be 0. 3. co = f (DT D), that is, the Fiedler vector of the co- occurrence matrix. Such orders have been used for minimizing the Lazarus effects, that is, 0s occurring between 1s [8]. 4. cs = f (V DT DV ), where V is a diagonal matrix, , that is, cs is the order such that, Vii = (DT D) obtained from the cosine similarity matrix. −1/2 ii For calculating the Fiedler order we use the algo- rithm given in [8]. We should point out that the Fiedler order is unique if there is only one Fiedler vector (up to normalization). However, it is often the case that there are several vectors and hence several orders. In that case the Atkins' algorithm returns a set of all possible orders represented by a PQ-tree. This set of orders may be large (it can contain all possible orders) so in practice we will sample orders from this set in our experiments. Luckily, sampling orders from a set represented by a PQ-tree is trivial. 5.2 Greedy Local Search In addition to the afore- mentioned spectral methods we will consider a simple greedy descent approach. Assume that we are given an order o. For each i = 2, . . . , K, we consider orders which are obtained from o by swapping o(i) and o(i−1). Among such orders we select the one that has the lowest score, say b. If the score s(b) is lower than the original s(o), then we replace o with b and repeat the step, other- wise we stop the search and output o. The pseudo-code is given in Algorithm 3. 6 Comparing to Random Orders The score of a model alone is not sufficient alone and it needs to be compared against some baseline. In this section we will consider two different approaches for the post-normalization. Let o be the order of the attributes. Let I be the collection of item segments corresponding to the Algorithm 3: GreedyOrder, A simple hill- climbining algorithm for improving the order o. 1 while changes do 2 b ← o; foreach i = 2, . . . , K do u ← o; Swap u(i − 1) and u(i); if s(u) < s(b) then b ← u; 3 4 5 6 7 (cid:104) s(o)2(cid:105)−µ2 measure based on estimation with normal distributions. In order to do that, let µ1 = E [s(o)] and µ2 = E [s(u)] be the means of the scores and let σ2 1 = 2 be the variances. E Let Xi be a random normal variable distributed as N (µi, σi), for i = 1, 2. We define s(u)2(cid:105)−µ2 1 and σ2 2 = E (cid:104) r(O) = − log P (X1 > X2) = − log Φ (cid:32) (cid:33) , (cid:112)σ2 µ1 − µ2 1 + σ2 2 8 o ← b; 9 return o; independence model, I = {{a1} , . . . ,{aK}}. Our first attempt is to compare the scores s(o) and s(I), that is, how good the score is against the independence model. This approach, however, has a drawback. Consider a dataset with two clusters such that the probability of having 1 is high in the first cluster and low in the second cluster. Assume also that the inside a cluster the attributes are independent and have the same probability of having 1. Such a dataset has a curious property. The best score for any order is lower than the score for the independence model. However, since data is symmetric, the best scores for all orders should be equal. The discussion above suggests a more refined ap- proach, that is, we should compare the score of the given order against the scores of random orders. Instead of defining a measure just for a single order we define a measure for a set of orders. The reason for this is that Atkins' algorithm (see Section 5.1) may not return a single order but a set of orders represented as a PQ-tree. Let us assume that we are given a set of orders O. Let o be a random order from O selected uniformly. Also let u be a random order from the set of all possible orders U . We define the measure to be the the probability that s(o) is higher than s(u), that is, l(O) = P (s(o) > s(u)) + P (s(o) = s(u)) /2. If the set O consists of orders with exceptionally low scores then the l(o) will be close to 0. If the orders have the same score as random orders, then l(O) will be close to 1/2. If we are given a single order o, we write l(o) for l({o}). In practice, we estimate the measure by sampling orders o and u. A problem with the measure l(o) is that in the case when it is close to 0, the number of samples should be really large in order to get an estimate different from 0. Hence, we define a second, smoother, where Φ is the cumulative density function for the standard normal distribution N (0, 1). In practice we estimate the means and the variances by sampling the orders from the sets O and U . We should make clear that r(O) should not be treated as an estimate for − log l(O). The distribution of the scores for random scores is not normal even if the number of data points increases to infinity. Nevertheless, the measure r(O) has desired properties. It is large if the scores of orders in O are significantly better. If the scores are as good as random, then r(O) is close to − log 1/2 = 1. The value l(o) gives us means to test whether the order o is significantly better than the random order. However, if the order is induced from the dataset, for example, using the spectral methods, we may overfit the data. To illustrate the problem consider the cluster data discussed above. In this data no order should be significant. However, since dataset is finite there are small variations in the scores. Now consider the algorithm that finds the order with the best score. The measure l(o) of such order will always be 0. We remedy this problem with cross validation, that is, we split the data into two random datasets. We will learn the order from the first dataset and compute the measure from the second. 7 Asymptotic Analysis Assume that we know the distribution p from which data is generated. What is then the appropriate definition for a score of a linear order? In this section we will define such a score, which we denote deg(opt(o, p)), and show that s(o) is directly connected to this score as the number of transactions goes to infinity. Let p be a distribution from which data is generated. Assume that we are given an order o and let opt(o, p) = arg minC {deg(C) ;C ∈ seg(o) , p ∈ M (C)} , that is, opt(o, p) ∈ seg(o) is the set of item segments with the smallest number of freedom such that p ∈ M (opt(o, p)). Such a set exists, since p ∈ M ({A}). Example 4. We continue Example 1 given in Sec- tion 1. The optimal set of segments for the order a1 ··· a5 is O1 = {a1a2, a2a3, a3a4, a4a5}. On the other hand, the optimal set of segments for the order a1a4a3a5a2 is O2 = {A} since there is no other way to include a1 and a2 into the same segment. The degrees are deg(O1) = 9 and deg(O2) = 31. The preceding example demonstrates that if the de- gree of opt(o, p) is low, then the order is good. This sug- gests that the orders in which the dependent attributes are close will have a low degree of freedom, hence there should be a connection between deg(opt(o, p)) and s(o). We will now state the main result of this section that states essentially that asymptotically s(o) is an increas- ing function of deg(opt(o, p)). The proof of the theorem is given in Appendix. Theorem 7.1. Let p be a distribution from which D is generated such that p(A = t) > 0 to any t. Let o1 and o2 be two orders such that deg(opt(o1, p)) < deg(opt(o2, p)). Then the probability of s(o1) < s(o2) converges to 1 as D approaches infinity. Note that r(o) and l(o) are both increasing func- tions of s(o). Hence, the theorem states that eventually both measures are increasing functions of deg(opt(o, p)). Such a behavior is reasonable yet surprising since the BIC penalty vanishes from s(o) as the amount of data increases. The reason for such behavior is that the dif- ference between the BIC penalty terms will outweight the difference between the likelihoods. 8 Experiments In this section we will describe our empirical results1. We begin by showing with synthetic datasets that our measures do give the expected results. Measures l(o) and r(o) are high for datasets in which there are no particular order structure. On the other hand, measures are small for datasets in which there is a clear order structure. We continue by studying the asymptotic behavior of the score as described in Section 7. We also tested the spectral methods with real-world datasets and show that all these datasets do have an order structure. Finally, we study how well the greedy method improves the scores of the spectral orders. Since Atkins' algorithm for discovering spectral orders returns PQ-tree which may correspond to several spectral orders, we sampled 1000 random orders from PQ-tree. However, if the number of orders represented by PQ-tree was less than 1000 we computed all the orders. 1Implementation is available at http://adrem.ua.ac.be/ implementations 8.1 Synthetic datasets For testing purposes we considered 4 different generated datasets. Each dataset had 20 attributes and 2000 of rows. Each dataset was split into two subsets, each having 1000 rows. The first part of the data was used for finding the spectral orders and the second part for actually computing the score. The measures l(o) and r(o) were computed by compar- ing them with 1000 random orders. Our first dataset, Ind, contains independent at- tributes. The second data, Clust, contains two clusters, each of 500 rows. The attributes within the cluster are independent. The probability of 1 was set to 3/4 in the first cluster and 1/4 in the second cluster. Our third dataset, Path, was generated such that attribute ai was generated from ai−1 by adding 1/4 amount of noise, that is, P (ai = 0; ai−1 = 1) = P (ai = 1; ai−1 = 0) = 1/4. The first attribute a1 was generated by a fair coin flip. Our last dataset is similar, Npath, to Path except that 3/4 were used as the amount of noise. Note that the at- tributes in Path are positively correlated whereas the consecutive attributes in Npath are negatively corre- lated. Our expectation is that Ind and Clust have no extraordinary order whereas in Path and Npath the gen- erating order is the most natural one. From the results given in Table 1 we see that we get the expected results. The datasets Ind and Clust both have high measure values since these datasets have no extraordinary order. In dataset Path all the orders have l(o) = 0 suggesting that there is a strong order structure. The orders given by the spectral algorithms for Path are all close to the original order. For Npath we see that the methods CO and CS fail to find a significant order. The reason for this is that Npath contains negative correlations. On the other hand, both MI and M2 find a significant order and produce significantly small measure values. 8.2 Asymptotic Behavior Our next focus is to study the asymptotic behavior of the score s(o). Theo- rem 7.1 implies that asymptotically l(o) is an increasing function of deg(opt(o, p)), the number of free parame- ters of the model containing the generative distribution p. To illustrate behavior we generated 4 datasets us- ing the same method we used to generate dataset Path. The datasets contained 10 attributes and varying num- ber of transactions. We computed 1000 random orders for which we computed l(o) Since we know the genera- tive distribution we were able to compute deg(opt(o, p)) directly. From the results given in Figure 2 we see that the measure l(o) converges into an increasing function of deg(opt(o, p)) as the number of transactions increases. Note that for the first two datasets there are many or- l(o) r(o) CO CS MI M2 CO CS MI M2 0.6 0.9 0 0.98 0.6 0.9 0 0.9 0.6 0.7 0 0 0.5 0.7 0 0 0.6 0.1 36.1 0.03 0.6 0.2 41.8 0.2 0.6 0.6 41.8 44.4 1.0 0.6 41.8 44.4 Data Ind Clust Path Npath Table 1: Measures l(o) and r(o) of the spectral orders obtained from the synthetic datasets. The orders are explained in Section 5.1. (a) D = 103, ρ = 0.29 (b) D = 104, ρ = 0.77 (c) D = 105, ρ = 0.97 (d) D = 106, ρ = 0.98 Figure 2: Measure l(o) as a function of deg(opt(o)), the number of free parameters. Theorem 7.1 implies that asymptotically l(o) is a monotonic function of deg(opt(o)). Each plot contain 1000 random orders of a dataset generated similarly as Path dataset. The number of transactions is indicated in each sublabel. The variable ρ is the correlation between l(o) and deg(opt(o)). ders which have the maximal number of free parame- ters, 1023, yet their measure values are small. Such behavior is hinted by Proposition 4.1: In such orders the model opt(o, p) is equal to one segment, contain- ing all items. Proposition 4.1 states that the necessary condition to produce this model as the model with the lowest BIC score we must have an exponential number of transactions. Note that in the larger datasets we have enough transactions to convince us that the model with the worst BIC penalty term is actually the best. 8.3 Spectral Methods with Real Datasets We continue our experiments with real-world datasets. The dataset Paleo2 contains information of species fossils found in specific paleontological sites in Europe [9]. The dataset Courses contains the enrollment records of stu- dents taking courses at the Department of Computer Science of the University of Helsinki. We took datasets Anneal and Mushroom from the LUCS/KDD reposi- tory [10]. A click-stream dataset WebView-1 3 was con- tributed by Blue Martini Software as the KDD Cup 2000 data [11]. The final dataset, Dna, is DNA copy number amplification data collection of human neoplasms [12]. Each dataset was split into two, the first part was used for calculating the order and the second part to calcu- late the actual score. To compute the measures we also computed the scores for 1000 random orders. The ba- sic characteristics and the running times are given in Table 2. Name Anneal Courses Dna Mushroom Paleo WebView-1 K 73 98 391 90 139 497 Time D % of 1s 3ms 20% 898 8ms 5% 3506 24ms 4587 1% 44ms 25% 8124 5% 501 3ms 1% 331ms 59602 Table 2: Statistics and running times of datasets used in experiments. The 4th column is the time needed to compute a score for one order. 2NOW public release 030717 available from [9]. 3http://www.ecn.purdue.edu/KDDCUP/data/BMS-WebView-1. dat.gz Measure l(o) was 0 for all orders and datasets, except for Anneal, where l(CO) = l(CS) = 0.03. This suggests that the almost all found orders were 2004006008001000deg(opt(o))0.2.4.6.81l(o)02004006008001000deg(opt(o))0.2.4.6.81l(o)02004006008001000deg(opt(o))0.2.4.6.81l(o)2004006008001000deg(opt(o))0.2.4.6.81l(o) significantly good. To illustrate this further we plotted the scores of the random and the spectral orders in a box plot in Figure 3. Data Anneal Courses Dna Mushroom Paleo WebView-1 CO CS MI M2 5.93 55.47 ∞ 39.13 129.39 289.08 6.04 72.80 ∞ 18.69 109.39 229.18 82.96 54.31 ∞ 46.74 13.18 561.93 47.89 58.72 ∞ 54.18 131.01 764.20 Table 3: Measure r(o) of the spectral orders obtained from the real datasets. The orders are explained in Section 5.1. method discussed in Section 5.2. We applied the al- gorithm for the first part of each dataset. As starting points we used the orders obtained by the spectral meth- ods. Our hope is that the greedy method improves the scores of spectral order because it is able to use statis- tics of higher-order and because spectral orders are only guaranteed to work with L-matrices (see Section 5.1). For comparison we sampled up to 50 orders from the PQ-tree produced by Atkins' algorithm. Each order was used as a starting point for the greedy algorithm. We also tested the greedy method with 50 random starting orders. The obtained orders were then evaluated by computing the scores from the second part of the dataset. The running times varied from 1 second to 1 hour, depending on the size of the dataset. Name Anneal Courses Dna Mushroom Paleo WebView-1 CO CS MI M2 RND 5.05 2.50 7.36 7.28 0.80 0.92 3.39 2.02 9.26 9.18 0.98 1.62 2.98 1.56 12.57 9.91 0.61 1.20 3.25 2.82 8.80 13.33 0.98 1.59 3.41 1.68 2.31 7.66 0.58 0.63 Table 4: Gains of the scores when using the greedy method compared to the scores of the starting points. The percentages are computed as 100% − 100% × s(o1) /s(o2), where o1 is the final order and o2 is the starting order. Figure 3: A box plot of the scores of random and spectral orders. The scores were normalized by dividing with s(I), the score of the independent model. Examining Table 3 reveals that the best scores are achieved with Dna dataset, suggesting that there is a strong order structure in the dataset. Measures r(o) becomes infinite due to the finite precision of the floating point number. Also, the scores of the spectral orders for the Mushroom dataset are small but so are the scores of the random orders. This implies that there are lot of dependencies in the dataset but the order structure is not that strong. Interestingly enough, either MI or M2 produces the lowest score for 5 datasets. One possible explanation is that MI and M2 are able to use the negative correlations and their score is directly related to the log-likelihood of the model. On the other hand, the order CS is the best for the Courses dataset and the order MI fails with Paleo dataset. 8.4 Improving the Scores with Greedy Search We conclude our experiments by studying the greedy By comparing the measure r(o) given in Table 5 to the values given in Tables 3 we see that the greedy method does not perform well alone: when random orders are used as starting points, the discovered orders are worse than the spectral orders. However, greedy method is useful when spectral orders are used as starting points. From Table 4 we see that the greedy method improves the scores of the spectral orders up to 13 percents. The gain of the score depends on the dataset but less on the spectral method used. The scores for Courses, Paleo and WebView-1 datasets improve up to 3 percents where as the biggest gains are with Dna, and Mushroom datasets where the scores improve by 7 -- 13 percents. 9 Related Work A popular choice for measuring the goodness of an order is the Lazarus count, the number of 0s between 1s in a row. If the Lazarus count is 0, then the data is said to have the consecutive ones property. In some cases this has a natural interpretation, for example, in a paleontological data a taxon becomes extant and AnnCrsDNAMshPalWeb0.40.50.60.70.80.91.0s(o)/s(I)COCSMIM2 Data Anneal Courses Dna Mushroom Paleo WebView-1 l(o) RND 0.12 0.10 0.03 0.01 0.13 0 r(o) CO CS MI M2 RND 20.1 100.3 ∞ 75.2 181.5 453.7 14.6 110.9 ∞ 56.1 169.7 570.5 104.2 79.8 ∞ 100.9 26.9 871.4 66.9 109.8 ∞ 136.1 196.3 940.0 2.9 3.4 4.9 7.5 2.8 11.6 Table 5: Measures l(o) and r(o) of the orders obtained using the greedy method with the spectral and random orders as the starting points. Measure values l(o) for all spectral orders were 0 and are omitted from the table. then extinct. If the matrix has a consecutive ones property, then the Fiedler vector of the co-occurrence matrix returns the correct order [8]. It is an open question why the spectral method works also with the noisy data. An alternative approach has been suggested in [13], where the authors construct a probabilistic model encapsulating the consecutive ones property. Ranking or sorting items can be seen as deducing a linear order for the items. Applications for ranking are, for example, finding relevant web pages [14, 15] or ranking database query results [16]. One of the key differences in these approaches and ours is that in our case the reversed order is as good as the original. We are interested in finding the order in which the dependent attributes are close. This goal is different than finding the most relevant items. In some cases, linear orders is too strict a struc- ture, in such case partial orders (transitive, asymmetric, and reflexive relation) may be more natural. For exam- ple, consider the course enrollment data, in which the same basic course is prerequisite for several advanced independent courses. Finding partial orders have been studied for example in [17]. General partial orders seem to be very complex objects. A simple but yet interesting subclass of partial orders are bucket orders [16, 18]. A problem of searching fragments of order, that is finding a collection of linear orders defined for a subset of items has been studied in [19]. 10 Conclusions We studied the concept of measuring the goodness of an order. We say that the order is good if the heavily dependent attributes are close to each other. In order to define the score we introduce an order-sensitive model and then use the BIC score to rank the model. To find the optimal model we created a dynamic program and show that it can be evaluated in O time. Hence, our method works well even for the datasets with vast number of items. K min(K, log D)2(cid:17) (cid:16) We provided asymptotic results showing that the score is connected the number of free parameters in the model. We also demonstrate this result empirically with synthetic data. We compared the score of the order against the scores of random orders. We say that the order is good if the score is exceptionally lower than the score of the random order. We used two different measures, l(o) the proportion of random scores having the smaller score than o, and r(o), the ratio of the score s(o) and the average score of a random order. One of our future goals is to develop a more refined measure for comparing the score against the scores of random orders. We evaluate the measures with several spectral and greedy methods. In our experiments we found out that Fiedler orders of the mutual information matrices (see Section 5.1) produced better results for our datasets than the orders based on co-occurrences or cosine dis- tance. In our experiments, the greedy optimization im- proved the scores of spectral orders up to 13 percents. One of our future goals is to extend the current method for more general partial orders (see Section 9). Such an extension is not trivial since in general case finding the best model is a computationally difficult task. References [1] M. Fortelius, A. Gionis, J. Jernvall, and H. Mannila, "Spectral ordering and biochronology of european fossil mammals," Paleobiology, vol. 32, no. 2, pp. 206 -- 214, March 2006. [2] D. G. Kendall, "Abundance matrices and seriation in archaeology," Probability Theory and Related Fields, vol. 17, no. 2, pp. 104 -- 112, June 1971. [3] A. Gionis, H. Mannila, and J. K. Seppanen, "Geomet- ric and combinatorial tiles in 0-1 data," in 8th Euro- pean Conference on Principles and Practice of Knowl- edge Discovery in Databases (PKDD 2004), 2004, pp. 173 -- 184. [4] R. G. Cowell, A. P. Dawid, S. L. Lauritzen, and D. J. Spiegelhalter, Probabilistic Networks and Expert Sys- tems, ser. Statistics for Engineering and Information Science, M. Jordan, S. L. L. nad Jeral F. Lawless, and V. Nair, Eds. Springer-Verlag, 1999. [5] G. Schwarz, "Estimating the dimension of a model," Annals of Statistics, vol. 6, no. 2, pp. 461 -- 464, 1978. [6] C. H. Papadimitriou, Computational Complexity. Addison-Wesley, 1994. [7] M. Fiedler, "A property of eigenvectors of nonnega- tive symmetric matrices and its application to graph theory," Czechoslovak Mathematical Journal, vol. 25, no. 4, pp. 619 -- 633, 1975. [8] J. E. Atkins, E. G. Boman, and B. Hendrickson, "A spectral algorithm for seriation and the consecutive ones problem," SIAM J. Comput., vol. 28, no. 1, pp. 297 -- 310, 1999. [9] M. Fortelius, "Neogene of the old world database of fossil mammals (NOW)," University of Helsinki, http: //www.helsinki.fi/science/now/, 2005. [10] F. Coenen, "The LUCS-KDD discretised/normalised ARM and CARM data library," 2003. [11] R. Kohavi, C. Brodley, B. Frasca, L. Mason, and Z. Zheng, "KDD-Cup 2000 organizers' report: Peeling the onion," SIGKDD Explorations, vol. 2, no. 2, pp. 86 -- 98, 2000. [12] S. Myllykangas, J. Himberg, T. Bhling, B. Nagy, J. Hollm´en, and S. Knuutila, "Dna copy number am- plification profiling of human neoplasms," Oncogene, vol. 25, no. 55, pp. 7324 -- 7332, Nov. 2006. [13] K. Puolamaki, M. Fortelius, and H. Mannila, "Seriation in paleontological data using markov chain monte carlo methods," PLoS Comput Biol, vol. [Online]. Available: http://dx.doi.org/10.1371%2Fjournal.pcbi.0020006 2, Feb 2006. no. 2, [14] S. Brin and L. Page, "The anatomy of a large-scale hypertextual web search engine," Computer Networks and ISDN Systems, vol. 30, no. 1 -- 7, pp. 107 -- 117, 1998. [15] J. Kleinberg, "Authoritative sources in a hyperlinked environment," Journal of the ACM, vol. 46, no. 5, pp. 604 -- 632, 1999. [16] R. Fagin, R. Kumar, M. Mahdian, D. Sivakumar, and E. Vee, "Comparing and aggregating rankings with ties," in Proceedings of the ACM-SIAM Symposium on Discrete Algorithms (PODS), 2004, pp. 47 -- 58. [17] A. Ukkonen, M. Fortelius, and H. Mannila, "Finding partial orders from unordered 0-1 data," in KDD '05: Proceedings of the eleventh ACM SIGKDD interna- tional conference on Knowledge discovery in data min- ing. New York, NY, USA: ACM, 2005, pp. 285 -- 293. [18] A. Gionis, H. Mannila, K. Puolamaki, and A. Ukkonen, "Algorithms for discovering bucket orders from data," in KDD '06: Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining. New York, NY, USA: ACM, 2006, pp. 561 -- 566. [19] A. Gionis, T. Kujala, and H. Mannila, "Fragments of order," in KDD '03: Proceedings of the ninth ACM SIGKDD international conference on Knowledge discovery and data mining. New York, NY, USA: ACM, 2003, pp. 129 -- 136. [20] I. Csisz´ar, "I-divergence geometry of probability dis- tributions and minimization problems," The Annals of Probability, vol. 3, no. 1, pp. 146 -- 158, Feb. 1975. [21] A. Wald, "Tests of statistical hypotheses concerning several parameters when the number of observations is large," Trans. of the American Mathematical Society, vol. 54, no. 3, pp. 426 -- 482, Nov. 1943. [22] A. W. van der Vaart, Asymptotic Statistics, ser. Cam- bridge Series in Statistical and Probabilistic Mathe- matics. Cambridge University Press, 1998. A Proof of Theorem 7.1 Throughout the whole section we will assume that the underlying distribution p has no zero probabilities, p > 0. Given a distribution q and a set of segments C we will adopt the notation h(A = t) = q(A = t;C) to mean the unique distribution h ∈ M (C) such that q(C) = h(C) for any C ∈ C. We begin by considering indicator functions. Given an itemset X = {ai1 , . . . , aiL} we define an indicator function SX : {0, 1}K → {0, 1} to be SX (t) = ti1 ··· tiL. Thus SX (t) = 1 if and only if all ti corresponding to the elements of X have value of 1. We also define S∅(t) = 1. Lemma A.1. Given a family of itemsets X , the set of indicator functions S = {SX ; X ∈ X} are independent, X∈X rX SX (t) = 0 is possible only for rX = 0. If X contains all itemsets, then S forms a basis. that is,(cid:80) (cid:110) Tv; v ∈ {0, 1}K(cid:111) Proof. It is sufficient to prove the lemma for the case when X = {X; X ∈ A} contains all possible itemsets. For a v ∈ {0, 1}K, Consider a function Tv : {0, 1}K → {0, 1} for which Tv(t) = 1 if and only if t = v. Obviously, the set of functions T = is linearly independent. Hence to prove the lemma we need to show that we can build a linear mapping from T onto S that has an inverse. (cid:80) exclusion principle TX (t) = (cid:80) To prove this we first note that SX (t) = Y ⊇X TY (t). This can be inverted using the inclusion- Y ⊇X (−1)Y −XSY (t). This completes the proof. A direct calculation implies that the distributions in M (C) have a particular exponential form. Lemma A.2. Let X = {X; X ⊆ C ∈ C} be the down- ward closure of C. A distribution p is in M (C) if only constants {rX}. X∈X rX SX (t)(cid:1) for some specific if p(A = t) = exp(cid:0)(cid:80) Proof. Assume that p ∈ M (C). Then p has a form of p(A) = (cid:81) p(Ci) /(cid:81) p(Ci ∩ Ci−1). Fix i. Lemma A.1 (cid:80) (cid:16)(cid:80) now implies that we can write log p(Ci = tCi) = aX SX (t) or in other words p(Ci = tCi) = exp . We can perform this factor- X⊆Ci ization for each p(Ci) and for each p(Ci ∩ Ci−1). By combining these factorizations we arrive at the desired result. aX SX (t) X⊆Ci (cid:17) We will prove the other direction by induction. Let p be the distribution having the exponential form and let {rX} be the needed constants. Shorten V = C1, W = A − (C1 − C2), and H = C1 ∩ C2. Using the argument in the first paragraph we can write p(H = tH ) = exp for some constants {uX}. Note that if X ∈ X is such that X (cid:42) H, then either X ⊆ V or X ⊆ W . We have X⊆H uX SX (t) (cid:16)(cid:80) (cid:17) log p(A − H = tA−H H = tH ) = = X∈X (cid:88) rX SX (t) − (cid:88) (cid:88) − (cid:88) rX SX (t) + X∈X ,X⊆V X∈X ,X⊆H (rX + uX )SX (t). X∈X ,X⊆H uX SX (t) (cid:88) rX SX (t) X∈X ,X⊆W The third term depends only on tH , hence it is a part of the normalization constant of the conditioned distribution. The first term depends only on the values of tV while the second term depends only on the values of tW . This leads to p(A) = p(A − H H)p(H) = p(V − H H)p(W − H H)p(H) = p(V )p(W ) p(H) = p(C1)p(W ) p(C1 ∩ C2) . The distribution p(W ) = p(W H)p(H) has an exponential form, hence if we assume inductively that p(W ) ∈ M (C − C1), then the above equality proves that p(A) ∈ M (C). Our next step is to study opt(o, p). Let V,W ∈ seg(o). We say that W refines V if for each V ∈ V there is W ∈ W such that V ⊆ W . In this case we write V (cid:64) W. We will now show that opt(o, p) is the minimal set with the respect of the relation (cid:64). Theorem A.1. Let O = opt(o, p). p ∈ M (C), then O (cid:64) C. Moreover, O is unique. If C is such that Proof. Assume the maximal otherwise and segments of the define V to set of be segments {C ∩ O; C ∈ C, O ∈ O}. Clearly deg(V) < deg(O). We need to show that p ∈ M (V). Let X and Y be the downward closure of O and C, respectively. Let {rX}, {sY } be the sets of constants in Lemma A.2 when applied to X and Y, respectively. We have rX SX (t) = log p(A = t) = sY SY (t). (cid:88) X∈X (cid:88) Y ∈Y Since the functions SX are linearly independent we must have that rZ = sZ for any Z ∈ X∩Y and rX = 0, sY = 0 otherwise. The downward closure of V is exactly X ∩Y. But now Lemma A.2 implies that p ∈ M (V) which is a contradiction by the minimality of O. We will need the following technical lemma that states that the difference between the likelihood terms is bounded. Lemma A.3. Assume two orders o1 and o2. Let Oi = opt(oi, p) and let Ci ∈ seg(oi) such that Oi (cid:64) Ci. Let D be a dataset with N = D transactions and let hi = qD (A;Ci) ∈ M (Ci). Let ZN = N H(h1) − N H(h2) and let Z be the limit distribution as N → ∞. Then P (ZN < t) → P (Z < t) uniformly in t as N → ∞. Moreover, P (Z = ∞) = 0. Proof. Let Xi be the downward closure of Oi and let when applied to Oi and p. Note that we have (cid:9) be the set of constraints given by Lemma A.2 (cid:88) (cid:8)ri (cid:88) O r1 OSO(t) = log p(A = t) = r2 OSO(t). O∈X1 O∈X2 O = r2 O whenever O ∈ X1 ∩ X2 and ri Since the functions SO are linearly independent we must have r1 O = 0 otherwise. Let Y = X1 ∩ X2. We know that (see Theorem 3.1 in [20]) there is a set of constants {rY } such that the dis- tribution g defined as g(A = t) = exp(cid:0)(cid:80) Y ∈Y rY SY (t)(cid:1) has the property g(SY = 1) = qD(SY = 1). Now a classic result (see [21] for example) implies that N H(hi) − N H(g) converges into a chi-square distribu- tion. A known result (see Theorem 2.3 in [22]) im- plies that the distribution of Z is a difference of two chi-square distributions implying that P (Z = ∞) = 0. Since Z is continuous, a known result (see Lemma 2.11 in vaart98statistics) now implies that the convergence is uniform. Elementary analysis now implies the following key corollary. Corollary A.1. Let ZN as in Lemma A.3 and let tN be a sequence such that tN → ∞. Then P (ZN ≥ tN ) → 0. = −(cid:88) t s(C) N lim N p(A = t) log h(A = t) Let D be a dataset with N transactions. We will denote by CN ∈ seg(o) to be the model with the lowest score. Note that CN is a random variable since it depends on D. We will show that CN converges into opt(o, p). Theorem A.2. Let O P(cid:0)O = CN(cid:1) → 1 as N approaches infinity. opt(o, p). Then = Proof. Let C ∈ seg(o) such that O (cid:54)(cid:64) C. Let h = p(A;C) ∈ M (C). Theorem A.1 now implies that h (cid:54)= p. Note that s(O) N Hence P(cid:0)C = CN(cid:1) → 0 since CN is the collection of > H(p) = lim N . segments with the optimal score. Assume now that O (cid:64) C, O (cid:54)= C. Let h = qD(A;O) and g = qD(A;C). Set d = 1/2(deg(C) − deg(O)). Note that s(O) − s(C) = N H(h) − N H(g) − d log N. Since d log N → ∞ as N → ∞, Corollary A.1 implies that P (s(O) ≥ s(C)) = P (N H(h) − N H(g) ≥ d log N ) → 0. Thus we must have P(cid:0)O = CN(cid:1) → 1. We are now ready to prove the main theorem. Proof. [of Theorem 7.1] The theorem follows if we can prove that s(o1) is lower than s(o2) with probability 1 as N approaches infinity. Let Oi = opt(oi, p). We write P (s(o1) ≥ s(o2)) ≤ P (s(O1) ≥ s(O2)) + P(cid:0)CN ≤ P (s(O1) ≥ s(O2)) + P(cid:0)CN (cid:1) 2 (cid:54)= O2 Theorem A.2 implies that the second and the third terms converge to 0. To annihilate the first term we use again Corollary A.1. Let gi = qD(A;Oi). Set d = 1/2(deg(O2) − deg(O1)). Note that 1 (cid:54)= O1 ∨ CN 1 (cid:54)= O1 (cid:1) + P(cid:0)CN 2 (cid:54)= O2 (cid:1) . s(O1) − s(O2) = N H(g1) − N H(g2) − d log N. Since d log N → ∞ as N → ∞, Corollary A.1 implies that P (s(O1) ≥ s(O2)) = P (N H(g1) − N H(g2) ≥ d log N ) → 0. This completes the proof.
1805.01407
2
1805
2019-08-01T11:01:41
Scrambled Linear Pseudorandom Number Generators
[ "cs.DS", "cs.CR", "cs.MS" ]
Linear pseudorandom number generators are very popular due to their high speed, to the ease with which generators with a sizable state space can be created, and to their provable theoretical properties. However, they suffer from linear artifacts which show as failures in linearity-related statistical tests such as the binary-rank and the linear-complexity test. In this paper, we give three new contributions. First, we introduce two new linear transformations that have been handcrafted to have good statistical properties and at the same time to be programmable very efficiently on superscalar processors, or even directly in hardware. Then, we describe a new test for Hamming-weight dependencies that is able to discover subtle, previously unknown biases in existing generators (in particular, in linear ones). Finally, we describe a number of scramblers, that is, nonlinear functions applied to the state array that reduce or delete the linear artifacts, and propose combinations of linear transformations and scramblers that give extremely fast pseudorandom generators of high quality. A novelty in our approach is that we use ideas from the theory of filtered linear-feedback shift register to prove some properties of our scramblers, rather than relying purely on heuristics. In the end, we provide simple, extremely fast generators that use a few hundred bits of memory, have provable properties and pass very strong statistical tests.
cs.DS
cs
Scrambled Linear Pseudorandom Number Generators∗ DAVID BLACKMAN, Independent researcher, Australia SEBASTIANO VIGNA, Università degli Studi di Milano, Italy Linear pseudorandom number generators are very popular due to their high speed, to the ease with which generators with a sizable state space can be created, and to their provable theoretical properties. However, they suffer from linear artifacts which show as failures in linearity-related statistical tests such as the binary-rank and the linear-complexity test. In this paper, we give three new contributions. First, we introduce two new linear transformations that have been handcrafted to have good statistical properties and at the same time to be programmable very efficiently on superscalar processors, or even directly in hardware. Then, we describe a new test for Hamming-weight dependencies that is able to discover subtle, previously unknown biases in existing generators (in particular, in linear ones). Finally, we describe a number of scramblers, that is, nonlinear functions applied to the state array that reduce or delete the linear artifacts, and propose combinations of linear transformations and scramblers that give extremely fast pseudorandom generators of high quality. A novelty in our approach is that we use ideas from the theory of filtered linear-feedback shift register to prove some properties of our scramblers, rather than relying purely on heuristics. In the end, we provide simple, extremely fast generators that use a few hundred bits of memory, have provable properties and pass very strong statistical tests. CCS Concepts: • Mathematics of computing → Random number generation; Additional Key Words and Phrases: Pseudorandom number generators 1 INTRODUCTION In the last twenty years, in particular since the introduction of the Mersennne Twister [34], linear1 pseudorandom generators have been very popular: indeed, they are often the stock generator provided by several programming languages. Linear generators have several advantages: they are fast, it is easy to create full-period generators with large state spaces, and thanks to their connection with linear-feedback shift registers (LFSRs) [18] many of their properties, such as full period, are mathematically provable. Moreover, if suitably designed, they are rather easy to implement using simple xor and shift operations. In particular, Marsaglia [31] introduced the family of xorshift generators, which have a very simple structure. The linear structure of such generators, however, is detectable by some randomness tests: in particular, the binary-rank test [32] and the linear-complexity test [5, 9] are failed by all linear generators.2 These tests were indeed devised to "catch" linear generators, and they are not consid- ered problematic by the community working on such generators, as the advantage of being able to prove precise mathematical properties is perceived as outweighing the failure of such tests. Nonetheless, one might find it desirable to mitigate or eliminate such linear artifacts by scrambling a linear generator, that is, applying a nonlinear function to its state array to produce the actual output. In this direction, two simple approaches are multiplication by a constant or adding two components of the state array. However, while empirical tests usually do not show linear artifacts ∗This paper contains version 1.0 of the generators described therein. 1More precisely, F2-linear or, equivalently, Z/2Z-linear generators; since we will not discuss other types of linear generators in this paper, we will omit to specify the field. 2In principle: in practice, the specific instance of the test used must be powerful enough to detect linearity. Authors' addresses: David Blackman, Independent researcher, Australia; Sebastiano Vigna, [email protected], Università degli Studi di Milano, Italy. 2 David Blackman and Sebastiano Vigna anymore, it is easy to prove that the two lower bits are unchanged or just slightly modified by such operations. Thus, those bits in isolation (or combined with a sufficiently small number of good bits) fail linearity tests. In this paper, we try to find a middle ground by proposing very fast scrambled generators with provable properties. By combining in different ways an underlying linear engine and a scrambler we can provide different tradeoffs in terms of speed, space usage and statistical quality. For example, xoshiro256** is a 64-bit generator with 256 bits of state that emits a value in 0.84 ns; it passes all statistical tests we are aware of, and it is 4-dimensionally equidistributed, which is the best possible. Similarly, xoshiro256++ emits a value in 0.86 ns; it is 3-dimensional equidistributed but it has higher linear complexity. They are our all-purpose generators. However, if the user is interested in the generation of floating-point numbers only, we provide a xoshiro256+ generator that generates a value in 0.78 ns (the value must then be converted to float); it is just 3-dimensionally equidistributed, and its lowest bits have low linear complexity, but since one needs just the upper 53 bits, the resulting floating-point values have no linear bias. If space is an issue, a xoroshiro128**, xoroshiro128++ or xoroshiro128+ generator provides similar timings and properties in less space. We also describe higher-dimensional generators, albeit mainly for theoretical reasons, and 32-bit generators with similar properties that are useful for embedded devices and GPUs. Our approach can even provide fast, reasonable 16-bit generators. We also introduce and analyze in detail a new test based on the dependency of Hamming weights, that is, the number of ones in each output word. The test examines the stream produced by a generator in search for bias, and can be run for an arbitrarily long stretch: we usually stop testing after 1 PB (1015) bytes, or when we detect a p-value below 10−20. While all generators above pass the BigCrush test suite from TestU01 [27], we can show that xoroshiro128+ is slightly weaker than the alternatives, as it fails our new test after about 5 TB of data. Our new test is strong enough to find bias in the Tiny Mersenne Twister [41] after almost 600 TB of data: it is indeed the first test in the literature to find bias in a generator of the Mersenne Twister [34] family that is not related to binary rank or linear complexity. It can also find easily bias in low-dimensional Mersenne Twisters, and in generators of the xorshift family scrambled with a sum, as in the case of xorshift+ [50]. Finally, we develop some theory related to our linear engines and scramblers using results from the theory of noncommutative determinants and from the theory of filtered LFSRs. The C code for the generators described in this paper is available from the authors and it is public domain.3 The test code is distributed under the GNU General Public License version 2 or later. 2 ORGANIZATION OF THE PAPER In this paper we consider words of size w, w-bit operations and generators with kw bits of state, k ≥ 2. We aim mainly at 64-bit generators (i.e., w = 64), but we also provide 32-bit combinations. Some theoretical data are computed also for the 16-bit case. The paper is organized in such a way to make immediately available code and basic information for our new generators as quickly as possible: all theoretical considerations and analysis are postponed to the second part of the paper, albeit sometimes this approach forces us to point at subsequent material. Our generators consist of a linear engine4 and a scrambler. The linear engine is a linear trans- formation on Z/2Z, represented by a matrix, and it is used to advance the internal state of the generator. The scrambler is an arbitrary function on the internal state which computes the actual 3http://prng.di.unimi.it/ 4We use consistently "engine" throughout the paper instead of "generator" when discussing combinations with scramblers to avoid confusion between the overall generator and underlying linear generator, but the two terms are otherwise equivalent. 3 output of the generator. We will usually apply the scrambler to the current state, to make it easy for the CPU to parallelize internally the operations of the linear engine and of the scrambler. Such a combination is quite natural: for example, it was advocated by Marsaglia for xorshift generators [31], by Panneton and L'Ecuyer in their survey [25], and it has been used in the design of XSAdd [43] and of the Tiny Mersenne Twister [44]. An alternative approach is that of combining a linear generator and a nonlinear generator [24]. In Section 3 we introduce our linear engines. We describe the matrices representing the trans- formation, and the associated code. In Section 4 we describe the scramblers we will be using, and their elementary properties. Finally, in Section 5 we describe generators given by a number of combinations between scramblers and linear engines, their speed and their results in statistical tests. Section 5.3 contains a guide to the choice of an appropriate generator. Next we start to discuss the theoretical material. Section 6 describes in detail the new test we have used in addition to BigCrush, and some interesting implementation issues. In Section 7 and 8 we discuss mathematical properties of our linear engines: in particular, we introduce the idea of word polynomials, polynomials on w × w matrices associated with a linear engine. The word polynomial makes it easy to compute the characteristic polynomial, which is the basic tool to establish full period, and can be used as a heuristic to evaluate the resistance of the generator to our new test. We then provide equidistribution results. In the last part of the paper, starting with Section 10, we apply ideas and techniques from the theory of filtered LFSRs to the problem of analyzing the behavior of our scramblers. We provide some exact results, and discuss a few heuristics based on extensive symbolic computation. Our discussion gives a somewhat more rigorous foundation to the choices made in Section 5, and opens several interesting problems. 3 LINEAR ENGINES In this section we introduce our two linear engines xoshiro (xor/shift/rotate) and xoroshiro (xor/rotate/shift/rotate). They are built using not only shifts and xors, as it is customary in several traditional linear generators [31, 34, 40, 49, 50], but also rotations. All modern C/C++ compilers can compile a simulated rotation into a single CPU instruction, and Java provides intrinsified rotation static methods to the same purpose. As a result, rotations are no more expensive than a shift, and they provide better state diffusion, as no bit of the operand is discarded.5 We denote with S the w × w matrix on Z/2Z that effects a left shift of one position on a binary row vector (i.e., S is all zeroes except for ones on the principal subdiagonal) and with R the w × w matrix on Z/2Z that effects a left rotation of one position (i.e., R is all zeroes except for ones on the principal subdiagonal and a one in the upper right corner). We will use ρr(−) to denote left rotation by r of a w-bit vector in formulae; in code we will write rotl(-,r). 3.1 xoroshiro The xoroshiro linear transformation is closer to traditional linear generators in the sense that it updates cyclically two words of a larger state array. The update rule is designed so that it is formed by two almost independent computation paths, leading to good parallelizability inside superscalar CPUs. 5Note that at least one shift is necessary, as rotations and xors map the set of words x satisying xRs = x for a fixed s into itself, so there are no full-period generators using only rotations. 4 David Blackman and Sebastiano Vigna static inline uint64_t rotl(const uint64_t x, int k) { return (x << k) (x >> (64 - k)); } Fig. 1. A sample C implementation of a left-rotation operator. const uint64_t s0 = s[0]; uint64_t s1 = s[1]; const uint64_t result_plus = s0 + s1; const uint64_t result_plus = rotl(s0 + s1, R) + s0; const uint64_t result_star = s0 * S; const uint64_t result_starstar = rotl(s0 * S, R) * T; s1 ^= s0; s[0] = rotl(s0, A) ^ s1 ^ (s1 << B); s[1] = rotl(s1, C); Fig. 2. The C code for a xoroshiro128+/xoroshiro128++/xoroshiro128*/xoroshiro128** generator. The array s contains two 64-bit unsigned integers, not all zeros. The base xoroshiro linear transformation is obtained combining a rotation, a shift and again a rotation (hence the name), and it is defined by the following 2w × 2w matrix: (cid:18)Ra + Sb + I Rc (cid:19) Sb + I . Rc X2w = The general kw × kw form is given instead by · · · · · · · · · · · · · · · · · · 0 I 0 · · · 0 0 0 0 I · · · 0 0 Xkw = (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) 0 0 0 · · · I 0 Ra + Sb + I 0 0 · · · 0 Sb + I (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) Rc 0 0 · · · 0 Rc (1) Note that the general form applies the basic form to the first and last words of state, and uses the result to replace the last and next-to-last words. The remaining words are shifted by one position. The structure of the transformation may appear repetitive, but it has been so designed because this implies a very simple and efficient computation path. Indeed, in Figure 2 we show the C code implementing the xoroshiro transformation for w = 64 with 128 bits of state. The constants prefixed with "result" are outputs computed using different scramblers, which will be discussed in Section 4. The general case is better implemented using a form of cyclic update, as shown in Figure 3. The reader should note that after the first xor, which represents the only data dependency between the two words of the state array, the computation of the two new words can continue in parallel, as depicted graphically in Figure 4. 5 const int q = p; const uint64_t s0 = s[p = (p + 1) & 15]; uint64_t s15 = s[q]; const uint64_t result_plus = s0 + s15; const uint64_t result_plusplus = rotl(s0 + s15, R) + s15; const uint64_t result_star = s0 * S; const uint64_t result_starstar = rotl(s0 * S, R) * T; s15 ^= s0; s[q] = rotl(s0, A) ^ s15 ^ (s15 << B); s[p] = rotl(s15, C); Fig. 3. The C code for a xoroshiro1024+/xoroshiro1024++/xoroshiro1024*/xoroshiro1024** generator. The state array s contains sixteen 64-bit unsigned integers, not all zeros, and the integer variable p holds a number in the interval [0 . . 16). Fig. 4. The data dependencies of the xoroshiro128 linear engine. Data flows from top to bottom: lines converging to a box are xor'd together, and labels represent w × w linear transformations applied to the data flowing through the line. Note that the linear transformation Sb + I is a xorshift. 3.2 xoshiro The xoshiro linear transformation uses only a shift and a rotation. It radically departs from traditional linear generators in that it updates all of the state at each iteration. As such, it is sensible only for moderate state sizes. We will discuss the 4w × 4w transformation (cid:169)(cid:173)(cid:173)(cid:173)(cid:171) I I 0 I I I I 0 0 I Sa Rb 0 I 0 Rb (cid:170)(cid:174)(cid:174)(cid:174)(cid:172) S4w = s0s1s0s1RaRcSb+I 6 David Blackman and Sebastiano Vigna const uint64_t result_plus = s[0] + s[3]; const uint64_t result_plusplus = rotl(s[0] + s[3], R) + s[0]; const uint64_t result_starstar = rotl(s[1] * S, R) * T; const uint64_t t = s[1] << A; s[2] ^= s[0]; s[3] ^= s[1]; s[1] ^= s[2]; s[0] ^= s[3]; s[2] ^= t; s[3] = rotl(s[3], B); Fig. 5. The C code for a xoshiro256+/xoshiro256++/xoshiro256** generator. The state array s contains four 64-bit unsigned integers, not all zeros. Fig. 6. The data dependencies of the xoshiro256 linear engine. and the 8w × 8w transformation S8w = (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) . (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) I 0 0 0 0 0 I 0 I I I 0 0 0 0 0 I 0 I 0 0 0 0 0 0 0 0 I I 0 0 0 0 I 0 0 I I 0 0 0 I 0 0 0 I 0 0 0 Sa 0 I 0 0 I I 0 0 0 Rb 0 0 0 Rb The layout of the two matrices above might seem arbitrary, but it is just derived from the imple- mentation. In Figure 5 and 7 is it easy to see the algorithmic structure of a xoshiro transformation: the second word of the state array is shifted and stored; then, in order all words of the state array are xor'd with a different word; finally, the shifted part is xor'd into the next-to-last word of the state array, and the last word is rotated. The shape of the matrix depends on the order chosen for the all-words xor sequence. Due to the all-word state mix, xoshiro has better statistical properties than xoroshiro, but at the same time it becomes slower in higher dimensions. Figure 6 and 8 show that also for xoshiro data dependencies are very short. s0s1s2s3s0s1s2s3SaRb const uint64_t result_plus = s[0] + s[2]; const uint64_t result_plusplus = rotl(s[0] + s[2], R) + s[2]; const uint64_t result_starstar = rotl(s[1] * S, R) * T; 7 const uint64_t t = s[1] << A; s[2] ^= s[0]; s[5] ^= s[1]; s[1] ^= s[2]; s[7] ^= s[3]; s[3] ^= s[4]; s[4] ^= s[5]; s[0] ^= s[6]; s[6] ^= s[7]; s[6] ^= t; s[7] = rotl(s[7], B); Fig. 7. The C code for a xoshiro512+/xoshiro512++/xoshiro512** generator. The state array s contains eight 64-bit unsigned integers, not all zeros. Fig. 8. The data dependencies of the xoshiro512 linear engine. 4 SCRAMBLERS Scramblers are nonlinear mappings from the state of the linear engine to a w-bit value, which will be the output of the generator. The purpose of a scrambler is to improve the quality of the raw output of the linear engine: since in general linear transformations have several useful provable properties, this is a practical approach to obtain a fast, high-quality generator. 4.1 Sum The + scrambler simply adds two words of the state array in Z/2w Z. The choice of words is relevant to the quality of the resulting generator, and we performed a number of tests to choose the best pair depending on the underlying engine. The idea appeared in Saito and Matsumoto's XSadd generator [43], and was subsequently used by the xorshift+ family [50]. In Figure 2-7 the result_plus output is computed using the + scrambler. Note that the lowest bit output by the + scrambler is just a xor of bits following the same linear recurrence, and thus follows in turn the same linear recurrence. For this reason, we consider + a weak scrambler. As we consider higher bits, there is still a linear recurrence describing their behavior, but it becomes quickly of such a high linear complexity to become undetectable. We will discuss in more detail this issue in Section 10. s0s1s2s3s4s5s6s7s0s1s2s3s4s5s6s7RbSa 8 David Blackman and Sebastiano Vigna 4.2 Multiplication The * scrambler multiplies by a constant a chosen word of the state array, and since we are updating more than a word at a time, the choice of the word is relevant. Its only parameter is the multiplier. The multiplier must be odd; moreover, if the second-lowest bit set is in position b, the lowest b bits of the output are unmodified, and the following bit is a xor of bit 0 and bit b, so the same consideration of the + scrambler apply to the lowest b + 1 bits. For this reason, we consider also * a weak scrambler. We will use multipliers close to φ2w, where φ is the golden ratio, as φ is an excellent multiplier for multiplicative hashing [19]. To minimize the number of unmodified bits, however, we will adjust the lower bits in such a way that bit 1 is set. In Figure 2 and 3 the result_star output is computed using the * scrambler. 4.3 Sum, rotation, and again sum The ++ scrambler uses two words of the state array: the two words are summed in Z/2w Z, the sum is rotated to the left by r positions, and finally we add in Z/2w Z the first word to the rotated sum. Note that the choice and the order are relevant -- the ++ scrambler on the first and last word of state is different from the ++ scrambler on the last and first word of state. Beside the choice of words, we have to specify the amount r of left rotation. Since the rotation moves the highest bits obtained after the first sum to the lowest bits, it is easy to set up the parameters so that there are no linear bits (of low linear complexity) in the output. For this reason, we consider ++ a strong scrambler. In Figure 2-7 the result_plusplus output is computed using the ++ scrambler. 4.4 Multiplication, rotation, and again multiplication The ** scrambler is given by a multiply-rotate-multiply sequence applied to a chosen word of the state array (again, since we are updating more than a word at a time, the choice of the word is relevant). It thus requires three parameters: the first multiplier, the amount of left rotation, and the second multiplier. As in the case of the ++ scrambler, it is easy to choose r so that there are no linear bits (of low linear complexity) in the output, so ** is a strong scrambler. We will mostly use multipliers of the form 2s + 1, which are usually computed very quickly, and which have the advantage of being alternatively implementable with a left shift by s and a sum (the compiler should make the right choice, but one can also benchmark both implementations). In Figure 2-7 the result_starstar output is computed using the ** scrambler. 5 COMBINING LINEAR ENGINES AND SCRAMBLERS In this section we discuss a number of interesting combinations of linear engines and scramblers, both for the 64-bit and the 32-bit case, and report results of empirical tests. We remark that all our generators, being based on linear engines, have jump functions that make it possible to move ahead quickly by any number of next-state steps. Please refer to [12] for a simple explanation, and for a fast algorithm.6 Part of our experiments use the BigCrush test suite from the well-known framework TestU01 [27]. We follow the protocol described in [49], which we briefly recall. We sample generators by executing BigCrush starting from a number of different seeds.7 We consider a test failed if its p-value is outside 6We note that computation of jump functions can be enormously sped up by exploiting the built-in carry-less multiplication instructions available on modern processors; such instructions, in practice, implement multiplication of polynomials on Z/2Z. 7TestU01 is a 32-bit test suite. As in [49], we implemented the generation of a uniform real value in [0 . . 1) by dividing the output of the generator by 264, but we implemented the generation of uniform 32-bit integer values by returning first the lower and then the upper 32 bits of each 64-bit generated value, so the entire output of the generator is examined. 9 of the interval [0.001 . . 0.999]. We call systematic a failure that happens for all seeds, and report systematic failures (a more detailed discussion of this choice can be found in [49]). Note that we run our tests both on a generator and on its reverse, that is, on the generator obtained by reversing the order of the 64 bits returned. Moreover, we run a new test aimed at detecting Hamming-weight dependencies, that is, depen- dencies in the number of zeros and ones in each output word. The test will be described in full in Section 6. We run the test until we examine a petabyte (1015 bytes) of data, or if we obtain a p-value smaller than 10−20, in which case we report the amount of data at which we stop. The amount gives an idea of how much the generator is resilient to the test, and makes it possible to discuss the seriousness of the failure. Note that, as discussed in Section 6, the test is very strong: it is able to find bias in the Tiny Mersenne Twister, for which no bias was previously known, except for linear artifacts (i.e., binary rank and linear complexity). We warn immediately the reader that we do not consider all the generators we discuss useful from a practical viewpoint, but discussing several combinations and their test failures brings to the light the limitation of each component in a much clearer way. If the main interest is a practical choice, we suggest to skip to Section 5.3. 5.1 The 64-bit case We consider engines xoroshiro128, xoshiro256, xoshiro512 and xoroshiro1024; parameters are provided in Table 2. The reason for the switch between the two engines at different sizes is that xoshiro is not definable for a state of 2w bits, and it is too slow for a state of 16w bits. However, xoshiro yields generators which have a better behavior with respect to the tests reported in the first eight lines of Table 1. All linear engines have obvious linear artifacts, but the xoroshiro engines require an order of magnitude less data to fail our Hamming-weight dependency test. Note that this is not only a matter of size, but also of structure: compare xoshiro512 and xoroshiro1024. Analogously, the + scrambler deletes all bias detectable with our test from the xoshiro generators, but it just improves the resilience of xoroshiro+ by almost three orders of magnitudes. We then present data on the xoroshiro generators combined with the * scrambler: as the reader can notice, the * scrambler does a much better job at deleting Hamming-weight dependencies, but a worse job at deleting linear dependencies, as xoroshiro128* still fails MatrixRank when reversed. In Section 10 we will present some theory explaining in detail why this happens. Once we switch to the ++ and ** strong scramblers, we are not able to detect any bias. The parameters for all scramblers are provided in Table 3. The actual state words used by the scramblers are described in the code in Figure 2, 3, 5 and 7. Note that the choice of word for the 64-bit engine xoroshiro128 applies also to the analogous 32-bit engine xoroshiro64, and that the choice for xoshiro256 applies also to xoshiro128. Our speed tests have been performed on an Intel® Core™ i7-8700B CPU @3.20GHz using gcc 8.3.0. We used suitable options to keep the compiler from unrolling loops, or extracting loop invariants, or vectorizing the computation under the hood. 5.2 The 32-bit case We consider engines xoroshiro64 and xoshiro128. Most of the considerations of the previous section are valid, but in this case for xoroshiro we suggest * as a weak scrambler: the + scrambler, albeit faster, in this case is actually too weak. As in the previous case, the lowest bits of the generators 10 David Blackman and Sebastiano Vigna Table 1. Results of tests for 64-bit generators. The columns "S" and "R" report systematic failures in BigCrush (MR=MatrixRank, i.e., binary rank; LC=LinearComp, i.e., linear complexity). The column "HWD" reports the number of bytes generating a p-value smaller than 10−20 in the test described in Section 6; no value means that the test was passed after 1015 bytes. The time to emit a 64-bit integer and the number of clock cycles per byte (reported by PAPI [47]) were computed on an Intel® Core™ i7-8700B CPU @3.20GHz. Generator xoroshiro128 xoshiro256 xoshiro512 xoroshiro1024 xoroshiro128+ xoshiro256+ xoshiro512+ xoroshiro1024+ xoroshiro128* xoroshiro1024* xoroshiro128++ xoshiro256++ xoshiro512++ xoroshiro1024++ xoroshiro128** xoshiro256** xoshiro512** xoroshiro1024** S R Failures HWD MR, LC MR, LC 1 × 1010 MR, LC MR, LC 6 × 1013 MR, LC MR, LC MR, LC MR, LC 5 × 1012 5 × 1012 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- MR -- -- -- -- -- -- -- -- -- -- -- 4 × 1013 -- -- -- -- -- -- -- -- -- -- ns/64 b cycles/B 0.81 0.72 0.83 1.05 0.72 0.78 0.88 1.05 0.87 1.11 0.95 0.86 0.99 1.17 0.93 0.84 0.99 1.17 0.32 0.29 0.39 0.42 0.29 0.31 0.35 0.42 0.37 0.44 0.38 0.34 0.39 0.47 0.42 0.33 0.39 0.47 using a weak scrambler are linear: however, since the output is just 32 bits, BigCrush detects this linearity (see failures in the reverse test).8 Again, once we switch to the ** and ++ scrambler, we are not able to detect any bias (as for the + scrambler, we do not suggest to use the++ scrambler with xoroshiro64). The parameters for all scramblers are provided in Table 6. 8We remark that testing subsets of bits of the output in the 64-bit case can lead to analogous results: as long as the subset contains the lowest bits in the most significant positions, BigCrush will be able to detect their linearity. This happens, for example, if one rotates right by one or more positions (or reverses the output) and then tests just the upper bits, or if one tests the lowest 32 bits, reversed. Subsets not containing the lowest bits of the generators will exhibit no systematic Table 2. Parameters suggested for the 64-bit linear engines used in Table 1. See Section 7 for an explanation of the "Weight" column. 11 Engine xoroshiro128 xoroshiro128++ xoshiro256 xoshiro512 xoroshiro1024 A 24 49 17 11 25 C Weight B 53 37 16 28 63 21 115 45 -- 251 21 -- 27 36 439 Table 3. Parameters suggested for the 64-bit scramblers used in Table 1. Scrambler * ** xoroshiro128++ xoshiro256++ xoshiro512++ xoroshiro1024++ R S 5 T 0x9e3779b97f4a7c13 -- -- 7 9 17 -- 23 -- 17 -- 23 -- -- -- -- -- Table 4. Results of tests for 32-bit generators. The column labels are the same as Table 1. Generator xoroshiro64 xoshiro128 xoroshiro64* xoshiro128+ xoshiro128++ xoroshiro64** xoshiro128** Failures S R HWD 5 × 108 MR, LC MR, LC MR, LC MR, LC 3.5 × 1013 -- -- -- -- -- -- -- -- -- -- MR, LC MR, LC -- -- -- Table 5. Parameters suggested for the 32-bit linear engines used in Table 4. Engine xoroshiro64 xoshiro128 A 26 9 C Weight B 31 9 13 11 -- 55 12 David Blackman and Sebastiano Vigna Table 6. Parameters suggested for the 32-bit scramblers used in Table 4. Generator xoroshiro64* xoshiro128++ xoshiro128** xoroshiro64** 0x9E3779BB S R T 0x9E3779BB -- -- 5 5 7 -- 9 7 -- 5 5.3 Choosing a generator Our 64−bit proposals for an all-purpose, rock-solid generator are xoshiro256++ and xoshiro256**. Both sport excellent speed, a state space that is large enough for any parallel application,9 and pass all tests we are aware of. In theory, xoshiro256++ uses simpler operations; however, it also accesses two words of state. Moreover, even if the ** scrambler in xoshiro256** is specified using multiplications, it can be implemented using only a few shifts, xors and sums. Another difference is that xoshiro256** is 4-dimensionally equidistributed (see Section 8), whereas xoshiro256++ is just 3-dimensionally equidistributed, albeit this difference will not have any effect in practice. On the other hand, as we will see in Section 10, the bits of xoshiro256++ has higher linear complexity. If, however, one has to generate only 64-bit floating-point numbers (by extracting the upper 53 bits), or if the mild linear artifacts in its lowest 2 bits are not considered problematic, xoshiro256+ is a faster generator with analogous statistical properties.10 There are however some cases in which 256 bits of state are considered too much, for instance when throwing a very large number of lightweight threads, or in embedded hardware. In this case a similar discussion applies to xoroshiro128++, xoroshiro128**, and xoroshiro128+, with the caveat that the latter has mild problems with the Hamming-weight dependency test that will be discussed in Section 6: however, bias can be detected only after 5 TB of data, which makes it unlikely to affect applications in any way. Finally, there might be cases that we cannot foresee in which more bits of state are nec- essary: xoshiro512++, xoshiro512**, and xoshiro512+ should be the first choice, switching to xoroshiro1024++, xoroshiro1024**, or xoroshiro1024* if even more bits are necessary. In particular, if rotations are available xoroshiro1024* is an obvious better replacement for xorshift1024* [49]. As previously discussed, however, it is very difficult to motivate from a theoretical viewpoint a generator with more than 256 bits of state.11 Turning to 32-bit generators, xoshiro128++, xoshiro128**, and xoshiro128+ have a role cor- responding to xoshiro256++, xoshiro256** and xoshiro256+ in the 64-bit case: xoshiro128++ and xoshiro128** are our first choice, while xoshiro128+ is excellent for 32-bit floating-point generation. For xoroshiro64 we suggest however a * scrambler, as the + scrambler turns out to be too weak for this simple engine. failures of MatrixRank or LinearComp. In principle, the linearity artifacts of the lowest bits might be detected also simply by modifying the parameters of the TestU01 tests. We will discuss in detail the linear complexity of the lowest bits in Section 10. 9With 256 bit of state, 264 sequences starting at 264 random points in the state space have an overlap probability of ≈ 2−64, which is entirely negligible. 10On our hardware, generating a floating-point number with 53 significant bits takes 1.15 ns. This datum can be compared, for example, with the dSFMT [42], which using extended SSE2 instructions provides a double with 52 significant bits only in 0.90 ns. 11We remark that, as discussed in Section 7, it is possible to create xoroshiro generators with even more bits of state. The state of a generator should be in principle initalized with truly random bits. If only a 64-bit seed is available, we suggest to use a SplitMix [46] generator, initialized with the given seed, to fill the state array of our generators, as research has shown that initialization must be performed with a generator radically different in nature from the one initialized to avoid correlation on similar seeds [36].12 Since SplitMix is an equidistributed generator, the resulting initialized state will never be the all-zero state. Notice, however, that using a 64-bit seed only a minuscule fraction of the possible initial states will be obtainable. 13 6 TESTING HAMMING-WEIGHT DEPENDENCIES In this section we describe in detail the new statistical test we used beyond BigCrush for our experimental evaluation of Section 5 (Table 1 and 4). Similarly to the binary-rank and linear- complexity tests of BigCrush, our test does not depend on the numerical values of the numbers output by the generator: indeed, sorting the bits of each examined block (e.g., first all zeroes and then all ones) would not modify the results of the test (albeit the values would now be very small). Hamming-weight dependency tests try to discover some statistical bias in the Hamming weight (i.e., the number of ones in the binary representation of x, denoted by νx [21]) of the w-bit words emitted by a generator. Since the number of ones in a random w-bit word has a binomial distribution with w trials and probability of success 1/2, in the most trivial instance one examines m consecutive outputs x0, x1, . . . , xm−1 and checks that the average of their Hamming weights has the correct distribution (which will be quickly approximated very well by a normal distribution as m grows [14]). Tests may also try to detect dependencies: for example, one can consider (overlapping) pairs of consecutive outputs, and check that the associated pairs of Hamming weights have the expected distribution [26]. Dependency in Hamming weights is a known problem for linear generators: for example, the Mersenne Twister [34], when initialized in a state containing a single bit set to one, needs several million iterations before the Hamming weight of the output has the correct distribution. This happens because linear transformations (in particular, those with sparse matrices) map bit vectors of low weight into bit vectors of low weight. Matsumoto and Nishimura [35] have introduced a theoretical figure of merit that is able to predict after how many samples a linear generator will fail a specific Hamming-weight test. During the design and testing of our generators we used extensively a test for detecting multidi- mensional Hamming-weight dependencies that was initially developed by the first author as part of the gjrand framework for testing PRNGs. In its current incarnation, the test is very powerful: for example, it finds in a matter of seconds bias in xorshift128+ or xorshift1024+ [50], in a matter of hours in xoroshiro128+, and in a matter of days in low-dimensional Mersenne Twisters and in the Tiny Mersenne Twister [44], for which no bias was previously known beyond linearity tests. Similarly to linearity tests, a failure in our test is an indication of lesser randomness, but in general the impact on applications will be negligible if we can detect bias only after, say, a gigabyte of data. 6.1 Details The test considers sequences of w-bit values (w even and not too small, say ≥ 16) extracted from the output of the generator. Usually w will be the entire output of the generator, but it is possible to run the test on a subset of bits, break the generator output in smaller pieces fed sequentially to the test, or glue (a subset of) the generator output into larger pieces. We fix a parameter k and consider overlapping k-tuples of consecutive w-bit values (ideally, the number of bits of generator state should be less than kw). We also consider an integer parameter 12It is immediate to define a 32-bit version of SplitMix to initialize 32-bit generators. 14 David Blackman and Sebastiano Vigna void transform(double v[], int sig) { double * const p1 = v + sig, * const p2 = p1 + sig; for (int i = 0; i < sig; i++) { const double a = v[i], b = p1[i], c = p2[i]; v[i] = p1[i] = (a - c) / sqrt(2.0); p2[i] = (2*b - a - c) / sqrt(6.0); (a + b + c) / sqrt(3.0); } if (sig /= 3) { transform(v, sig); transform(p1, sig); transform(p2, sig); } } Fig. 9. The code for the (in-place) transform described in Section 6.1. It should be invoked with sig equal to 3k−1. ℓ ≤ w/2, and we map each w-bit value x into 0, if νx < w/2 − ℓ; 1, if w/2 − ℓ ≤ νx ≤ w/2 + ℓ; 2, if νx > w/2 + ℓ. In other words, we count the number of ones in x and categorize x, as it is typical, in three classes: left tail (before the 2ℓ + 1 most frequent values), central (the 2ℓ + 1 central, most frequent values), right tail (after the 2ℓ + 1 most frequent values). The standard choice for ℓ is the largest integer such that the overall probability of the most frequent values does not exceed 1/2. We thus get from the k-tuple a signature of k trits. Now, given a sequence of m values, for each signature s we compute the average number of ones in the word appearing after a k-tuple with signature s in the sequence. This bookkeeping can be easily performed using 3k integers while streaming the generator output. For a large m, this procedure yields 3k values vi with approximately normal distribution [14], which we normalize to a standard normal distribution.1314 In principle, since the vi's should be normally distributed one might compute the associated p-values and return a global p-value. But we can make the test much more powerful by applying a Walsh -- Hadamard-like transform. The transform is given by the k-th Kronecker power of the base matrix (cid:169)(cid:173)(cid:173)(cid:171) 1√3 1√2 1√3 0 1√3 − 1√2 (cid:170)(cid:174)(cid:174)(cid:172) . 1√6 − 2√6 1√6 Assuming that the resulting matrix is indexed using sequences of trits as numerals in base 3, the transform can be implemented recursively in the same vein as the fast Walsh-Hadamard transform. 15 for the transformed values. i i i Figure 9 shows C code to compute the transform in place: it should be called with sig equal to 3k−1. We shall write v′ Since the matrix is unitary, the v′ 's must appear still to be drawn from a standard normal distribution. Their meaning, however, has changed. Let us write the index ¯ı of a transformed value v′ as a sequence of trits t0, t1, . . . , tk−1. If the trits are all zero, we are just computing the normalized ¯ı sum of all values, which is of little interest. On the contrary, if a single trit, say in position ¯ȷ, is equal to 1, v′ is given by the sum of all vi's in ¯ı which the ¯ȷ-th trit of i is 0 minus the sum of all vi's in which the ¯ȷ-th trit of i is 2: if the Hamming weight of the output depends on the Hamming weight of the output ¯ȷ values before, the value of v′ ¯ı will be biased. If instead a single trit in position ¯ȷ is equal to 2 we will detect a kind of bias in which the Hamming weight of the current value depends on whether the Hamming weight of the output ¯ȷ values before was extremal or average. More complex trit patterns detect more complex dependencies (see Table 7): the most interesting patterns, however, are those with few nonzero trits (except for the index 0, whose associated value v′ 0 we discard). Thus, we divide indices in C categories using the number of nonzero trits contained in their ternary representation: the first category contains indices with a single nonzero trit, the second category contains indices with two nonzero trits, and so on, until the last category, which contains all indices containing at least C nonzero trits (of course, C ≤ k; usually, C = ⌊k/2⌋ + 1). in a category; for each category we take then the minimum p-value obtained, say, ¯p, and compensate for the fact that we are considering a minimum by computing 1 − (1 − ¯p)c, where c is the cardinality of the category. Finally, we take the minimum compensated p-value over all categories, and compensate once again for the fact we are considering the minimum over C values. This arrangement puts indices with a higher chance of giving low p-values in small categories, making the test more sensitive. 6.2 Results We ran tests with w = 32 or w = 64 and k ranging from 8 to 19, depending on the state size. We performed the test incrementally, that is, for increasingly larger values of m, and stopped after a petabyte (1015 bytes) of data or if we detected a p-value smaller than 10−20. We remark that statistical testing usually involves examining data that is orders of magnitude smaller. Table 7 reports some results of our test on failing generators. All generators considered other than xorshift pass BigCrush, except for linearity tests (MatrixRank and LinearComp). We report the faulty signature, that is, the pattern of dependencies that caused the low p-value: it provides interesting insights on the structure of the generator. In Section 7 we will find a possible explanation for the increasing resistance to the test, starting from xorshift and going towards xoshiro. A p-value is computed for each v′ We remark that our test is able to find bias in some small generators of the Mersenne Twister family. First of all, we consider the 64-bit Tiny Mersenne Twister [44], which has 127 bits of state and a significantly more complex structure than the other generators in Table 7: indeed, it is four to five times slower. Moreover, contrarily to other members of the Mersenne Twister family, the Tiny Mersenne Twister is scrambled, as the output is computed by adding the two components of its state space in Z/264Z and applying some further bijective transformation. To find the bias, 13Breaking the generator output in smaller pieces provides obviously a finer analysis of the distribution of each piece, but a test with parameters k and w "covers" kw bits of output: if we analyze instead values made of w/2 bits, to cover kw bits of output we need to increase the length of tuples to 2k, with a quadratic increase of memory usage. 14There is also a transitional variant of the test: we see the sequence of w-bit values as a stream of bits, xor the stream with itself shifted forward by one bit, and run the test on the resulting w-bit values. In practice, we look for Hamming-weight dependencies between bit transitions. 16 David Blackman and Sebastiano Vigna Table 7. Detailed results of the test described in Section 6 for w = 64. We report the number of bytes generating a p-value smaller than 10−20; generators from Table 1 and 4 passing the test after 1015 bytes of data are not listed. We report also the trit signature which caused the low p-value. The results should be compared with those of Table 1. Generator xorshift128 xorshift128+ xorshift1024 xorshift1024+ xoroshiro128 xoroshiro128+ xoroshiro1024 xoroshiro1024+ xoshiro256 Tiny Mersenne Twister (127 bits) Mersenne Twister (521 bits) p = 10−20 @ 8 × 108 6 × 109 6 × 108 9 × 109 1 × 1010 8 × 1012 5 × 1012 4 × 1013 6 × 1013 6 × 1014 4 × 1010 -- Mersenne Twister (607 bits) 4 × 108 -- 4 × 1010 Faulty signature 00000021 00000012 (trans.) 2000000000000001 2000000000000001 00000012 00000012 1200000000000001 1200000000000001 000120102001 (w = 32) 10001021 (trans., w = 32) 1000000100000000 2000000100000000 1000000001000000000 2000000001000000000 we had to resort to a slightly more detailed analysis, using w = 32 and breaking up the 64-bit output of the generator in two 32-bit words. For this specific generator the best results were given by the transitional variant of the test, but the standard version is only slightly less sensitive. The interesting fact is that there are no other known tests which this generator fails (except for the usual binary rank for large matrices). We also analyzed the classical Mersenne Twister [34] at 521 and 607 bits. We used Matsumoto and Nishimura's library for dynamic creation of Mersenne Twisters [33], and generated eight different instances of each generator: this is why we report in Table 7 a range of values and multiple signatures. The results are quite interesting. Firstly, all these generators fail our test quite soon, and also for these generators no failure in tests except for linearity tests was known.15 Secondly, the 607-bit version performs much worse than the 521-bit version. But, more importantly, we found huge variability in the test results depending on the parameter generated by the library: in some cases the 607-bit Mersenne Twister perform worse than a xorshift128 generator. In other words, our results suggest that the dynamic generation process described in [13] yields generators with wildly different statistical quality, and should be avoided. All in all, we believe that our results show that dependencies on Hamming weights should be considered a systematic problem for linear generators, together with more classical linear artifacts 15Some tests based on specific set of lags had already caused other failures, such as in [13], but these tests (and the lags) were chosen using deep knowledge of the generator. (i.e., failures in binary-rank and linear-complexity tests). In particular, our test shows that such dependencies are more difficult to mask by scrambling than low linear complexity. 17 6.3 Implementation To be able to perform our test in the petabyte range, we carefully engineered its implementation: in particular, the main loop enumerating the output of the generator and computing the values vi must be as fast as possible. Counting the number of ones in a word can be performed using single-clock specialized instructions in modern CPUs. Moreover, one can keep track very easily of the current trit signature by using the update rule s ← ⌊s/3⌋ + t · 3k−1, where t is the next trit. We can replace the division with the fixed-point computation(cid:4)(cid:0)(cid:6)232/3(cid:7)s(cid:1)/232(cid:5) (this strategy works up to k = 19; for larger k, one needs to perform an actual division), so by precomputing(cid:6)232/3(cid:7) and 3k−1 the costly operations in the update of s can be reduced to two independent multiplications. The main implementation challenge, however, is that of reducing the counter update area so that it fits into the cache. In a naive implementation, we would need to use two "large" 64-bit values. Instead, we will use a single "small" 32-bit value to store both the number of appearances of signature s, and the sum of Hamming weights of the following words, with a fourfold space saving. In particular, we will use 13 bits for the counter and 19 bits for the summation. We fix a batch size, and update the small values blindly through the batch. At the end of the batch, we update the large counters using the current values of the small counters, and zero the latter ones. At the same time, we check that the sum of the small counters is equal to the batch size: if not, a counter overflowed. Otherwise, we continue with the next batch, possibly computing the transform and generating a p-value. How large should a batch be? Of course we prefer larger batches, as access to large counters will be minimized, but too large a batch will overflow small counters. This question is actually interesting, as it is related to the mean passage time distribution of the Markov chain having all possible signatures as states, and probability of moving from signature s to signature ⌊s/3⌋ + t · 3k−1 given by the probability of observing the trit t. Let this probability be p for the central values (trit 1), and (1 − p)/2 for the extremal values (trits 0 and 2). We are interested in the following question: given a k, p and a batch size B, what is the probability that a counter will overflow? This question can be reduced to the question: given k, p and a batch size B, what is the probability that the Markov chain after B steps passes through the all-one signature more than 213 times?16 We want to keep this probability very low (say, 10−100) so to not interfere with the computation of the p-values from the test; moreover, in this way if we detect a counter overflow we can simply report that we witnessed an event that cannot happen with probability greater than 10−100, given that the source is random, that is, a p-value. As a first approximation, we could use general results about Markov chains [15, Theorem 7.4.2] which state that in the limit the number of passages is normally distributed with mean and variance related to those of the recurrence time distribution, which can in turn be computed symbolically using the Drazin inverse [16, 37]. Since, however, no explicit bound is known for the convergence speed of the limit above, we decided to compute exactly the mean passage time distribution for the all-ones signature. To do this, we model the problem as a further Markov chain with states xc,s, where 0 ≤ c ≤ b, b is a given overflow bound, and 0 ≤ s < k. The idea is that we will define transitions so that after t steps the probability of being in state xc,s will be the probability that after examining t w-bit values our curren trit signature has a maximal 16It is obvious that the the all-ones signature has the highest probability in the steady-state distribution, and that by bounding its probability of overflow we obtain a valid bound also for all other signatures. 18 David Blackman and Sebastiano Vigna suffix of s trits equal to one, and that we have counted exactly c passages through the all-ones signature (b or more, when c = b), with the proviso that the value s = k −1 represents both maximal suffixes of length k − 1 and of length k (we can lump them together as receiving a one increases the passage count in both cases). We use an initial probability distribution in which all states with c (cid:44) 0 have probability zero, and all states with c = 0 have probability equal to the state-steady probability of s, which implies that we are implicitly starting the original chain in the steady state. However, as argued also in [15], the initial distribution is essentially irrelevant in this context. We now define the transitions so that the probability distribution of the new chain evolves in parallel with the distribution of passage times of the original chain (with the probability for more than b passages lumped together): • all states have a transition with probability 1 − p to xc,0; • all states xc,s with s < k − 1 have a transition with probability p to xc,s +1; • all states xc,k−1 with c < m have a transition with probability p to xc +1,k−1; • there is a loop with probability p on xb,k−1. It is easy to show that after t steps the sum of the probabilities associated with the states x−,b is exactly the probability of overflow of the counter associated with the all-one signature. We thus iterate the Markov chain until, say at step T , we obtain a probability of, say, 3−k ¯p: we can then guarantee that, given that the source is random, running our test with blocks of size T we can observe overflow only with probability at most ¯p. This approach becomes unfeasible when we need to iterate the Markov chain more than, say 107 times. However, at that point we can use a very close approximation: we apply a simple dynamic- programming scheme on the results for 106 steps to extend the results to larger number of steps, using a strategy analogous to exponentiation by iterated squaring. The approximation is due to the fact that doing so we are implicitly assuming that the Markov chain is reset to its steady-state distribution after each 106 steps, but experiments at smaller sizes show that the error caused by this approximation is, as expected, negligible. We can also report that in our case the normal approximation is not very precise even after a billion steps. In the end, we computed T for 1 ≤ k ≤ 19 and included the result into the our code (for example, when w = 64 one has T ≈ 15 × 103 for k = 1, T ≈ 23 × 106 for k = 8 and T ≈ 109 for k = 16). Combining all ideas described in this section, our test for Hamming-weight dependencies with parameters w = 64 and k = 8 can analyze a terabyte of output of a 64-bit generator in little more than 3 minutes on an Intel® Core™ i7-8700B CPU @3.20GHz. The k = 16 test is an order of magnitude slower due to the larger memory accessed. 7 POLYNOMIALS AND FULL-PERIOD GENERATORS One of the fundamental tools in the investigation of linear transformations is the characteristic polynomial. If M is the matrix representing the transformation associated with a linear engine the characteristic polynomial is P(x) = det(M − xI). The associated linear engine has full period (i.e., maximum-length period) if and only if P(x) is primitive over Z/2Z [29], that is, if P(x) is irreducible and if x has maximum period in the ring of polynomials over Z/2Z modulo P(x). By enumerating all possible parameter choices and checking primitivity of the associated polynomials we can discover all full-period generators. In particular, every bit of a linear engine is a LFSR with characteristic polynomial P(x). Different bits emit different outputs because they return sequences from different starting points in the orbit of the LFSR. 19 The weight of P(x) is the number of terms in P(x), that is, the number of nonzero coefficients. It is considered a good property for linear engine of this kind17 that the weight is close to half the degree, that is, that the polynomial is neither too sparse nor too dense [7]. 7.1 Word polynomials A matrix M of size kw × kw can be viewed as a k × k matrix on the ring of w × w matrices. At that point, some generalization of the determinant to noncommutative rings can be used to obtain a characteristic polynomial Pw(x) for M (which will be a polynomial with w × w matrices as coefficients): if the determinant of Pw(x) on Z/2Z is equal to the characteristic polynomial of M, then Pw(x) is a word polynomial of size w for M. The main purpose of word polynomials is to make easier the computation of the characteristic polynomial of M (and thus of the determinant of M), in particular for large matrices. But we will see that under some further commutativity constraints word polynomials are just a different representation of M, as in the commutative case, and we will present some empirical evidence that in all cases they provide useful information about the dependence of an output from the previous outputs. In all our examples w is the intended output size of the generator, but it some cases it might be necessary to use a smaller block size, say, w/2, to satisfy commutativity conditions: one might speak, in that case, of the semi-word polynomial. For blocks of size one the word polynomial is simply the characteristic polynomial; the commutation constraints are trivially satisfied. 7.2 The commutative case If all w×w blocks of M commute, a very well-known result from Bourbaki [2] shows that computing the determinant of M in the commutative ring of w × w matrices R generated by the w × w blocks of M one has (2) where "det" denotes the determinant in the base ring (in our case, Z/2Z) whereas "Det" denotes the determinant in R. This equivalence provides a very handy way to compute easily the determinants of large matrices with a block structure containing several zero blocks and commuting non-zero blocks: one simply operates on the blocks of the matrix as if they were scalars. However, if M is the matrix associated with a linear engine, Det(M) can be used also to charac- terize how the current state of the generator depends on its previous states. Indeed, since we are working in a commutative ring the Cayley -- Hamilton theorem holds, and thus M satisfies its own characteristic polynomial: if we let P(x) = Det(M − xI), then P(M) = 0. In more detail, if det(Det(M)) = det(M), P(x) = xk + Ak−1xk−1 + · · · + A1x + A0 then Ak−1 + · · · + MA1 + A0 = 0. Thus, given a sequence of states of the generator s0, s1 = s0M, s2 = s0M sr = sr−1Ak−1 + · · · + sr−k +1A1 + sr−kA0. Mk + Mk−1 2, . . . , sr = s0Mr we have18 This recurrence makes it possible to compute the next state of the generator knowing its previous w states. 17Technically, the criterion applies to the LFSR represented by the characteristic polynomial. The behavior of a linear engine, however, depends also on the relationships among its w bits, so the degree criterion must always be weighed against other evidence. 18Note that in this formula the coefficients Ai are w × w matrices of the ring R generated by the blocks of M. 20 David Blackman and Sebastiano Vigna This consideration may seem trivial, as we already know how to compute the next state given the previous state -- a multiplication by M is sufficient -- but the recurrence is true of every w-bit block of the state array. Said otherwise, no matter which word of the state array we use as output, we can predict the next output using the equation above knowing the last w outputs of the generator. Another way of looking at the same statement is that we expressed the linear engine described by M using Niederreiter's multiple-recursive matrix method [39]. It is thus tempting to conjecture that a too simple combination of previous outputs might be easy to discover, and that the structure of P(x) might help us in identifying generators whose outputs do not satisfy too simple equations. 7.3 The noncommutative case There are three issues in generalizing the arguments we made about the commutative case: first, we need a notion of noncommutative determinant; second, it would be useful to know whether (2) generalizes to our case; and third, we need to know whether a generalization of the Cayley -- Hamilton theorem applies to our noncommutative determinant. The first two problems can be solved by recent results of Sothanaphan [45]. One starts by defining a (standard) notion of determinant for noncommutative rings by fixing the order of the products in Leibniz's formula. In particular, we denote with Detr the row-determinant of an n × n matrix M on a noncommutative base ring: sgn(π)M0,π(0)M1,π(1) · · · Mn−1,π(n−1) (3) Detr(M) =  π ∈Sn Note that the definition is based on Leibniz's formula, but the order of the products has been fixed. Then, Theorem 1.2 of [45] shows that det(Detr(M)) = det(M), (4) provided that blocks in different columns, but not in the first row, commute. In other words, one can compute the characteristic polynomial of M by first computing the "row" characteristic polynomial of M by blocks and then computing the determinant of the resulting matrix. By the definition we gave, in this case Detr(M − xI) is a word polynomial for M. The row-determinant is (trivially) antisymmetric with respect to the permutation of columns.19 Moreover, a basic property of row-determinants depends on a commutativity condition on the matrix entries (blocks): if M has weakly column-symmetric commutators, that is, if Mij Mkl − Mkl Mij = Mil Mk j − Mk j Mil whenever i (cid:44) k and j (cid:44) l, then the row-determinant is antisymmetric with respect to the permutation of rows [4]. Dually, we can define the column-determinant sgn(π)Mπ(0),0Mπ(1),1 · · · Mπ(n−1),n−1. (5) Detc(M) =  π ∈Sn All recalled properties can be easily dualized to the case of the column-determinant: in particular, (6) provided that blocks in different rows, but not in the first column, commute; if M has weakly row-symmetric commutators, that is, if det(Detc(M)) = det(M), Mij Mkl − Mkl Mij = Mk j Mil − Mil Mk j whenever i (cid:44) k and j (cid:44) l, 19In our case, that is, on the base field Z/2Z there is no difference between "symmetric" and "antisymmetric" as sign change is the identity. For sake of generality, however, we will recall the properties we need in the general case. then the column-determinant is antisymmetric with respect to the permutation of columns [4]. Finally, if M is weakly commutative [4], that is, Mij and Mkl commute whenever i (cid:44) k and j (cid:44) l (i.e., noncommuting blocks lie either on the same row or on the same column) the two determinants are the same, as all products in (3) and (5) can be rearranged arbitrarily.20 21 7.3.1 Warmup: xorshift. The generators of the xorshift family [31] with more than 2w bits 0 of state are defined by the linear transformation · · · · · · · · · · · · · · · · · · 0 0 0 I · · · 0 0 0 I 0 · · · 0 I 0 0 · · · 0 Mkw = 0 0 0 0 · · · I (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) (I + Sa)(cid:16) I +(cid:0)ST(cid:1)b(cid:17) I +(cid:0)ST(cid:1)c(cid:17) (cid:16) 0 0 0 · · · (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) , where ST is the right-shift matrix. The matrix Mkw is weakly commutative and satisfies trivially the conditions for (4), so we can compute the row-determinant (which is equal to the column- determinant) by performing Laplace expansion along the first line, noting that all resulting minors are made of commuting blocks: Detc(Mkw − xI) = Detr(Mkw − xI) = xk−1(cid:16) I +(cid:0)ST(cid:1)c + xI (cid:17) + (I + Sa)(cid:16) = xk I + xk−1(cid:16) I +(cid:0)ST(cid:1)b(cid:17) I +(cid:0)ST(cid:1)c(cid:17) + (I + Sa)(cid:16) I +(cid:0)ST(cid:1)b(cid:17) . We thus obtain our first word polynomial. Now, an interesting fact is that the transpose of Mkw is a Manin matrix [30], a special subclass of matrices on noncommutative rings related to quantum groups which enjoy the extension of a number of classical theorems from the theory of matrices on commutative rings. More precisely, a Manin matrix M is a matrix in which elements on the same column commute, and in which Mij Mkl − Mkl Mij = Mk j Mil − Mil Mk j for all i, j, k and l. The transpose of a Manin matrix enjoys a version of the Cayley -- Hamilton theorem that uses the row-determinant and left substitution [6, Theorem 14]: M k kw + M k−1 kw I +(cid:0)ST(cid:1)c(cid:17) (cid:16) I +(cid:0)ST(cid:1)c(cid:17) + (I + Sa)(cid:16) + sr−k(I + Sa)(cid:16) I +(cid:0)ST(cid:1)b(cid:17) I +(cid:0)ST(cid:1)b(cid:17) (cid:16) = 0. Thus, we can reason as in the commutative case: given a sequence of states s0, s1 = s0Mkw, s2 = s0M 2 kw , . . . , sr = s0M r kw we have . sr = sr−1 (7) In this particular case, the previous formula is entirely obvious: it corresponds exactly to the cyclic update rule of a high-dimensional xorshift generator [49]. When the update matrix is more complex, however, as in our case, it will turn out to be a very useful tool to understand the dependencies among subsequent outputs. Even when we do not have the theoretical support of an extension of the Cayley -- Hamilton theorem, we can still check empirically if at least some of the bits are predictable using a word polynomial: indeed, the fact that the determinant of the word 20We remark that if the only aim is to compute easily the characteristic polynomial, one can rearrange columns and rows at will until (4) or (6) is true, because these operations cannot change the value of the determinant on Z/2Z. 22 David Blackman and Sebastiano Vigna polynomial is the determinant of the original linear transformation suggests that there must be relevant information. We remark that if a certain word of state is equidistributed in the maximum dimension (see Section 8) it is always possible to predict the next output given k consecutive outputs: by equidis- tribution, there is a matrix that given a sequence of k outputs returns the state that emits exactly those outputs: at that point, by advancing the engine k times we obtain a description of each bit of the current state (and thus of the current output) in terms of the bits the previous k outputs. However, such a description is not amenable in general to a block-based description, which, as we will see in Section 7.4, is one of the most interesting features of word polynomials. 7.3.2 xoroshiro. This case is more difficult as there is no way to modify the matrix to satisfy the conditions for (4), which would be our first try, given the previous example. However, it is easy to check that Xkw has weakly row-symmetric commutators, so we can move its next-to-last column to the first one, and then the resulting matrix clearly falls into the conditions for (6). We thus obtain a word polynomial based on the column-determinant: Detc(cid:0)Xkw − xI(cid:1) = Detc (cid:169)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:173)(cid:171) Ra + Sb + I 0 0 · · · xI xI I 0 · · · 0 0 0 xI I · · · 0 0 · · · · · · · · · · · · · · · · · · 0 0 0 · · · I 0 Sb + I =(cid:0)Ra + Sb + I(cid:1)(cid:0)Rc + xI(cid:1) + x(cid:0)Rc + xI(cid:1)xk−2 +(cid:0)Sb + I(cid:1)Rc Rc + x(cid:0)Ra + Sb + I(cid:1) + Ra+c . = xk I + xk−1 Rc + xI Rc 0 0 · · · 0 (cid:170)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:174)(cid:172) Given the results we used about the extensions of the Cayley -- Hamilton theorem for Manin matrices, it is unlikely that the polynomial above can satisfy an equation analogous to (7): and indeed it does not. However, empirically 4/5 of the bits of each word of state can be predicted using the polynomial above when k = 2 (xoroshiro128), and the ratio becomes about 1/2 for k = 16 (xoroshiro1024).21 xoshiro. In this case we have to perform an ad hoc maneuver to move S4w and S8w into a form amenable to the computation of a word polynomial by row-determinant: we have to exchange the first two rows. It is very easy to see that this operation cannot modify the row- determinant because every element of the first row commutes with every element of the second row: thus, in the products of (3) the first two elements can always be swapped. 7.3.3 At that point, by (a quite tedious) Laplace expansion along the first row we get Detr(cid:0)S4w − xI(cid:1) = x Detr(cid:0)Sw8 − xI(cid:1) and 8 = x I + x 4 I + x 3(cid:0)Rb + I(cid:1) + x 6(cid:0)Rb + I(cid:1) + x 3(cid:0)SaRb + Rb + Sa(cid:1) + x 2(cid:0)Sa + Rb(cid:1) + x(cid:0)Sa + I(cid:1)(cid:0)Rb + I(cid:1) +(cid:0)Sa + I(cid:1)Rb 4(cid:0)Sa + I(cid:1)(cid:0)Rb + I(cid:1) 5(cid:0)Sa + Rb + I(cid:1) + x 2(cid:0)Sa + I(cid:1)(cid:0)Rb + I(cid:1) + x(cid:0)SaRb + Rb + I(cid:1) + Rb . 7(cid:0)Rb + I(cid:1) + x + x 21The empirical observation about predicted bits are based on the parameters of Table 2 and 5: different parameters will generate different results. 23 We should have a better chance to be able to predict an output using a row-determinant, and this is indeed the case: for S4w (xoshiro256), the second word of state can be predicted exactly22; for the other words, about two thirds of the bits can be predicted. In the case of S8w (xoshiro512), all words except the last one can be predicted exactly; for the last one, again about two thirds of the bits can be predicted. 7.4 Word polynomials and Hamming-Weight Dependencies Beside the usefulness of the word polynomial for computing the characteristic polynomial, we want to highlight what appears to be an empirical connection with the test described in Section 6. In Figure 10 we show for a few generators the correlation between the number of nonzero coefficients of the word polynomial (excluding the leading term) and the amount of data required by our test to generate a p-value below 10−20. It is rather evident that the more complex dependencies on previous outputs exhibited by complex word polynomials have a correlation with the amount of data that it is necessary to analyze before finding a bias. We used this fact as a heuristic in the design of our linear engines. In fact, the connection has a clear explanation: every bit of output predictable by the word polynomial implies the existence of a dependence of the bit from a subset of the previous output bits. Dependencies of this kind are very well known in the study of linear generators [13, 35], where their number of terms has been suggested as a figure of merit connected to the Hamming- weight distribution test [35]. Harase [13] describes sophisticated linear techniques that can find dependencies beyond k (which is the obvious limit using a word polynomial). In our case, it is interesting to note that once the coefficients have been fully expanded, every rotation (including the identity) contributes a term in all dependencies, but shifts (even multiplied by a rotation) add a term or not depending on their parameters and on the output bit. In this sense, rotations are measurably more efficient in creating dependencies with more terms. For example, some bits of xorshift can depend on as few as three previous bits, but a bit of xoroshiro is guaranteed to depend on at least four, and sometimes five; the number grows with the xoshiro linear engines (we could indeed obtain a more precise version of Figure 10 counting exactly such terms, instead of the coefficients, which are a rough approximation). The faulty signatures for xorshift and xoroshiro in Table 7 reflect exactly the terms of the word polynomial with nonzero coefficients, that is, the terms of the induced dependency. We leave for future work a more detailed, formal study of the dependencies induced by word polynomials. 7.5 Full-period generators Using the word polynomials just described we computed exhaustively all parameters providing full-period generators using the Fermat algebra system [28], stopping the search at 4096 bits of state.23 Table 8 and 10 report the number of full-period generators, whereas Table 9 and 11 report the maximum weight of a primitive polynomial. As one can expect, with respect to xoshiro we find that xoroshiro has many more full-period generators at many more different state sizes, due to the additional parameter. We remark that we did not discuss 16-bit generators, but there is a xoshiro and several xoroshiro choices available. For example, the Parallax Propeller 2 microcontroller contains a version of the 16-bit engine xoroshiro32 in every processor core. 24 David Blackman and Sebastiano Vigna Fig. 10. Correlation between nonzero coefficients of a word polynomial (excluding the leading term) and amount of data required to generate a p-value of less than 10−20 using the test of Section 6 on some linear engines. Note that xoshiro512 does not actually fail the test, but we stopped testing after a petabyte of data. Table 8. Number of xoroshiro primitive polynomials depending on word size and state size. 64 26 250 State size in bits 128 21 149 1000 256 7 59 491 512 3 41 261 1024 1 16 129 2048 0 5 42 4096 0 6 25 16 w 32 64 Table 9. Maximum weight of a xoroshiro primitive polynomial depending on word size and state size. 64 37 39 128 45 67 75 16 w 32 64 State size in bits 1024 41 187 475 512 35 201 263 256 73 115 139 2048 4096 195 651 143 653 8 EQUIDISTRIBUTION Equidistribution is a uniformity property of pseudorandom number generators: a generator with kw bits of state and w output bits is d-dimensionally equidistributed if when we consider the sequences of the first d output values over all possible states of the generator, each sequence appears exactly the same number of times [23]. In practice, in linear generators over the whole 22Incidentally, if we reverse multiplication order in the coefficients, the first word can be predicted exactly instead. 23The reason why the number 4096 is relevant here is that we know the factorization of Fermat's numbers 22k + 1 only up to k = 11. When more Fermat numbers will be factorized, it will be possible to look for full-period generators with larger state. 1x108 1x109 1x1010 1x1011 1x1012 1x1013 1x1014 1x1015 1x1016 1 2 3 4 5 6 7xorshift128xorshift1024xoroshiro128xoroshiro1024xoshiro256xoshiro512Data to fail HWDDistinct nonzero coefficients of a word polynomial Table 10. Number of xoshiro primitive polynomials depending on word size and state size. 25 State size in bits 64 1 128 0 1 256 512 0 4 4 16 w 32 64 Table 11. Maximum weight of a xoshiro primitive polynomial depending on word size and state size. State size in bits 64 33 128 256 512 55 131 251 16 w 32 64 output every d-tuple of consecutive output values must appear 2w(k−d) times, except for the zero d-tuple, which appears 2w(k−d) − 1 times, as the zero state is not used. In particular, 1-dimensionally equidistributed generators with w bits of state emit each w-bit value exactly one time, except for the value zero, which is never emitted. We will start by discussing the equidistribution of our linear engines (without scramblers). Typically, linear generators (e.g., xorshift) update cyclically a position of their state array. In this case, the simple fact that the generator has full period guarantees that the generator is equidistributed in the maximum dimension, that is, k. However, since our linear engines update more than one position at a time, full period is not sufficient, and moreover different words of the state may display different equidistribution properties. Testing for maximum equidistribution of a word of the state array is easy using standard techniques, given the update matrix M of the linear engine: if we consider the j-th word, the square matrix obtained juxtaposing the j-th block columns of M 0 = I, M 1 = M , M 2, . . . , M k−1 must be invertible (the inverted matrix returns, given an output sequence of k words, the state that will emit the sequence). It is straightforward to check that every word of xoroshiro (for every state size) and of xoshiro512 is equidistributed in the maximum dimension. The words of xoshiro256 are equidistributed in the maximum dimension with the exception of the third word, for which equidistribution depends on the parameters; we will not use it. The * and ** scramblers cannot alter the equidistribution of a linear engine,24 as they just remap sequences bijectively. Thus, all our generators using such scramblers are k-dimensionally equidistributed (i.e., in the maximum dimension). We are left with proving equidistribution results for our generators based on the + scrambler and on the ++ scrambler. For d-dimensionally equidistributed linear engines which update cyclically a single position, adding two consecutive outputs can be easily proven to provide a (d − 1)- dimensionally equidistributed generator. However, as we already noticed our linear engines update 24More precisely, they cannot alter the equidistribution of the full output: if we start to consider the equidistribution of a subset of output bits (e.g., the highest bit) this is not longer true. 26 David Blackman and Sebastiano Vigna p q , ui =(cid:0)xM i(cid:1) we add variables ti , ui and equations ti =(cid:0)xM i(cid:1) more than one position at time: we thus proceed to develop a general technique, which can be seen as an extension of the standard technique to prove equidistribution of a purely linear generator. Throughout this section subtraction between words of state will happen in Z/2w Z, whereas + will continue to denote sum in (Z/2Z)w. There is no need for a subtraction symbol in (Z/2Z)w, and by arranging our few equations with operations in Z/2w Z so that sums in are never necessary we avoid to introduce additional notation. The reader must only be aware of that fact that in general (x + y) − y (cid:44) x. For a linear engine with k words of state, we consider a vector of variables x = ⟨x0, x1, . . . , xk−1⟩ representing the state of the engine. Then, for each 0 ≤ i < d, where d is the target equidistribution, , where p and q are the two state words to be used by the + or ++ scrambler. Given a target sequence of output values ⟨v0, v1, . . . , vd−1⟩, we would like to show that there are 2w(k−d) possible values of x which will give the target sequence as output. This condition can be expressed by equations on the ti's and the ui's involving the arithmetic of Z/2w Z. In the case of the + scrambler, we have equations vi − ti = ui; in particular, p and q can be exchanged without affecting the equations. In the case of the ++ scrambler, instead, if ti denotes the first word of state used by the scrambler (see Section 4.3) we have ui = (vi − ti)R−r − ti, but there is no way to derive ti from ui; the dual statement is true if ti denotes the second word of state used by the scrambler. Now, to avoid mixing operations in Z/2w Z and (Z/2Z)w we first solve using standard linear algebra the xi's with respect to the ti's and the ui's. At that point, we will be handling a new set of constraints in (Z/2Z)w containing only ti's and ui's: using a limited amount of ad hoc reasoning, we will have to show how by choosing k − d parameters freely we can satisfy at the same time both the new set of constraints and the equations on Z/2w Z induced on the ti's and the ui's by the choice of scrambler. If we will be able to do so, we will have proved that a generic target sequence ⟨v0, v1, . . . , vd−1⟩ appears exactly 2w(k−d) times. 8.1 xoroshiro the first and last word of state is (k − 1)-dimensionally equidistributed. Proposition 8.1. A xoroshiro+ generator with w bits of output and kw bits of state scrambling Proof. For the case k = 2 the full period of the underlying xoroshiro generator proves the statement. Otherwise, denoting with the ti's the first word and with the ui's the last word our technique applied to Xkw provides equations (8) (9) (10) Thus, the only constraint on the ti's and ui's is the last equation. It is immediate that once we assign a value to u0 we can derive a value for t0 = v0 − u0, then a value for u1 and so on. □ ti = xi u0 = xk−1 ui +1 = (ti + ui)Rc 0 ≤ i ≤ k − 3 0 ≤ i ≤ k − 2 Note that in general it is not possible to claim k-dimensional equidistribution. Consider the full-period 5-bit generator with 10 bits of state and parameters a = 1, b = 3 and c = 1. As a xoroshiro generator it is 2-dimensionally equidistributed, but it is easy to verify that the sequence of outputs of the associated xoroshiro+ generator is not 2-dimensionally equidistributed (it is, of course, 1-dimensionally equidistributed by Proposition 8.1). The proof of Proposition 8.1 can be easily extended to the case of a xoroshiro++ generator. Proposition 8.2. A xoroshiro++ generator with w bits of output and kw bits of state scrambling the last and first word of state is (k − 1)-dimensionally equidistributed. If k = 2, also scrambling the first and last word of state yields a 1-dimensionally equidistributed generator. 27 Proof. We use the same notation as in Proposition 8.1. For the case k = 2 the full period of the underlying xoroshiro generator proves the statement, as there is no constraint, so the only equation between t0 and u0 is either u0 = (v0 − t0)R−r − t0, if we are scrambling the first and the last words of state, or t0 = (v0 − u0)R−r − u0, if we are scrambling the last and the first one. Otherwise, we proceed as in the proof of Proposition 8.1. Since we are scrambling the last and first word, we have ti = (vi − ui)R−r − ui, and the proof can be completed in the same way. □ The countexample we just used for xoroshiro+ can be used in the xoroshiro++ case, too, to show that in general it is not possible to claim k-dimensional equidistribution. Moreover, the full-period xoroshiro++ 4-bit generator with 16 bits of state and parameters a = 3, b = 1 and c = 2 is not even 3-dimensionally equidistributed if we scramble the first and last word (instead of the last and the first), showing that the stronger statement for k = 2 does not extend to larger values of k. 8.2 xoshiro Proposition 8.3. A xoshiro+ generator with w bits of output and 4w bits of state scrambling the first and last word of state is 3-dimensionally equidistributed. Proof. In this case, denoting with the ti's the first word and with the ui's the last word, our technique applied to S4w provides the constraints t0 = t2 + u2R −b −b + t1R −b t1 = t2 + u2R But if we choose t2 arbitrarily, we can immediately compute u2 = v2 − t2 and then t1 and t0. □ Once again, it is impossible to claim 4-dimensional equidistribution. The only possible 2-bit xoshiro generator with 8 bits of state has full period but it is easy to verify that the associated xoshiro+ generator is not 4-dimensionally equidistributed. Now, we prove an analogous equidistribution result for xoshiro512+. Proposition 8.4. A xoshiro+ generator with w bits of output and 8w bits of state and scrambling the first and third words of state is 7-dimensionally equidistributed. Proof. Denoting with the ti's the first word and with the ui's the third word and applying again our general technique, we obtain the constraints t0 = u0 + u1 t1 = u1 + u2 t2 = u2 + u3 t3 = u3 + u4 t4 = u4 + u5 t5 = u5 + u6 Choosing a value for u0 (and thus t0 = v0 − u0) gives by the first equation u1 = t0 + u0 and thus t1 = v1 − u1, by the second equation u2 = t1 + u1 and t2 = v2 − u2, and so on. □ 28 David Blackman and Sebastiano Vigna Note that it is impossible to claim 8-dimensional equidistribution: the xoshiro+ generator associated with the only full period 5-bit xoshiro generator with 40 bits of state (a = 2, b = 3) is not 8-dimensionally equidistributed. Proposition 8.5. A xoshiro++ generator with w bits of output and 4w bits of state and scrambling the first and last words of state is 3-dimensionally equidistributed. Proof. The proof uses the same notation of Proposition 8.3, and proceeds in the same way: the equations we obtain are the same, and due to che choice of scrambler we have ui = (vi − ti)R−r − ti, so can obtain the ui's from the ti's. □ Note that it is impossible to claim 4-dimensional equidistribution, as shown, once again, by the only possible 2-bit xoshiro generator with 8 bits of state: the only possible associated xoshiro++ generator is not 4-dimensionally equidistributed. Proposition 8.6. A xoshiro++ generator with w bits of output and 8w bits of state scrambling the third and first words of state is 7-dimensionally equidistributed. Proof. The proof uses the same notation of Proposition 8.4, and proceeds in the same way: the equations we obtain are the same, and due to che choice of scrambler we have ti = (vi −ui)R−r −ui, so we can obtain the ti's from the ui's. □ 8.3 Full period for bits An immediate consequence of the propositions of this section is that every individual bit of our generators has full period: Proposition 8.7. Every bit of a generator in Table 1 and 4 with n bits of state has period 2n − 1. Proof. By the results in this section all such generators are at least 1-dimensionally equidis- □ tributed, and we just have to apply Proposition 7.1 from [49]. 9 ESCAPING ZEROLAND We show in Figure 11 the speed at which the generators hitherto examined "escape from ze- roland" [40]: linear engines need some time to get from an initial state with a small number of bit set to one to a state in which the ones are approximately half,25 and while scrambling reduces this phenomenon, it is nonetheless detectable. The figure shows a measure of escape time given by the ratio of ones in a window of 4 consecutive 64-bit values sliding over the first 1000 generated values, averaged over all possible seeds with exactly one bit set (see [40] for a detailed description). Table 12 condenses Figure 11 into the mean and standard deviation of the displayed values. Comparing these values with those reported in [50], one can observe that xoroshiro escapes a little faster than xorshift. 10 A THEORETICAL ANALYSIS OF SCRAMBLERS We conclude the paper by discussing our scramblers from a theoretical point of view. We cast our discussion in the same theoretical framework as that of filtered linear-feedback shift registers. A filtered LFSR is given by an underlying LFSR, and by a Boolean function that is applied to the state of the register. The final output is the output of the Boolean function. Since shift registers update one bit at a time, we can see the Boolean function as sliding on the sequence of bits generated by 25Famously, the Mersenne Twister requires millions of iterations. 29 Fig. 11. Convergence to "half of the bits are ones in average" plot. Table 12. Mean and standard deviation for the data shown in Figure 11. Generator xoroshiro128+ xoroshiro128* xoroshiro128++ xoroshiro128** xoshiro256+ xoshiro256++ xoshiro256** xoshiro512+ xoshiro512++ xoshiro512** xoroshiro1024+ xoroshiro1024* xoroshiro1024++ xoroshiro1024** Mean Standard deviation 0.017392 0.003958 0.012830 0.021876 0.033354 0.025578 0.024809 0.051387 0.041219 0.035350 0.108212 0.070485 0.093901 0.096509 0.498701 0.499723 0.498942 0.498389 0.495908 0.498198 0.497779 0.491710 0.494275 0.495308 0.464861 0.483116 0.472517 0.471698 the LFSR, emitting a scrambled output. The purpose of filtering a LFSR is that of making it more difficult to guess its next bit: the analogy with linear engines and scramblers is evident, as every 0 0.1 0.2 0.3 0.4 0.5 0.6 1 10 100 1000Average number of onesSamplesxoroshiro128+xoroshiro128*xoroshiro128++xoroshiro128**xoshiro256+xoshiro256**xoshiro256++xoshiro512+xoshiro512++xoshiro512**xoroshiro1024+xoroshiro1024*xoroshiro1024++xoroshiro1024** 30 David Blackman and Sebastiano Vigna scrambler can be seen as set of w boolean functions applied to the state of the linear engine. There are however a few differences: • we use only primitive polynomials; • we use several Boolean functions, and we are concerned with the behavior of their combined outputs; • we do not apply a Boolean function to a sliding window of the same LFSR: rather, we have kw copies of the same LFSR whose state is different, and we apply our set of Boolean functions to their single-bit output concatenated; • we are not free to design our favorite Boolean functions: we are restricted to the ones • we are not concerned with predictability in the cryptographic sense, but just in the elimination of linear artifacts, that is, failures in tests for binary rank, linear complexity and Hamming- weight dependencies. computable with few arithmetic and logical operations; 2 + 1. 3 + x 5 + x 6 + x Nonetheless, we will see that many basic techniques coming from the cryptographic analysis of filtered LFSRs can be put to good use in our case. To make our discussion more concrete, we will bring along a very simple example: a full-period xorshift generator with w = 3 and 6 bits of state [49]. Its parameters are a = 1, b = 2, c = 1 and its characteristic polynomial is p(x) = x 10.1 Representation by generating functions We know already that all bits of a linear engine are LFSRs with the same characteristic polynomial, but we can be more precise: we can fix a nonzero initial state and compute easily for each bit the generating function associated with the bit output (see [18] for a detailed algorithm). Such functions have at the denominator the reciprocal polynomial xnp(1/xn) (n here is the degree of p), whereas the numerator (a polynomial of degree less then n) represents the initial state. In our example, representing the first word using x0 (lowest bit), x1, x2 and the second word using y0, y1 and y2, we have Fx0(z) = Fx1(z) = Fx2(z) = 5 + z 2 + z + 1 z 6 + z z 6 + z z 6 + z z 4 + z 5 + z z 4 + z 5 + z z 4 + z 3 + z + 1 2 3 + z + 1 4 3 + z + 1 5 + z Fy0(z) = z 6 + z z Fy1(z) = Fy2(z) = 6 + z z 6 + z z 4 + z 4 + z 4 + z z 4 + z 4 + z z 4 + z 3 + z 2 + z 3 + z + 1 3 + z + 1 3 3 + z + 1 If we write the formal series associated with each function, the i-th coefficient will give exactly the i-th output of the corresponding bit of the generator. In particular, the first output for x0 is one, whereas for all other bits it is zero. The interest in the representation by generating function lies in the fact that now we can perform some operations on the bits. For example, if we want to study the associated xorshift+ generator, the lowest bit will be just x0 + y0, and we can actually easily compute the associated function, as adding coefficients is the same as adding functions: Fx0+y0(z) = Fx0(z) + Fy0(z) = z 5 + z 2 + z + 1 3 + z + 1 + z 5 + z 6 + z z 4 + z 4 + z 4 + z 2 + z 3 + z 3 + z + 1 = z 6 + z 4 + z 4 + z 3 + 1 3 + z + 1 . z 6 + z z 31 However, we are now stuck, because to compute the functions associated with the xorshift+ generator we need more than just xors. Indeed, it is very well known that if we consider sequences x0, x1, . . . , xw−1 and y0, y1, . . . , yw−1 representing the bits, from least significant to most significant, of two w-bit words, and we want to represent their arithmetic sum over Z/2w Z, we can define the result bits si and the carry bits ci using the recurrence si = xi + yi + ci−1 ci = (xi + yi)ci−1 + xiyi (11) (12) where c−1 = 0. This recurrence is fundamental because carries are the only source of nonlinearity in our scramblers (even multiplication by a constant can be turned into a series of shifts and sums). The expression for ci is simply the standard definition of carry expressed using the base of xor/and (sum/product) that is typical of the arithmetic in Z/2Z. It is clear that to continue to the higher bits we need to be able to multiply two sequences, but multiplying generating functions unfortunately corresponds to a convolution of coefficients. 10.2 Representation in the splitting field We now start to use the fact that the characteristic polynomial p(x) of our generator is primitive. Let E be the splitting field of a polynomial p(x) of degree n over Z/2Z [29]. In particular, E can be represented by polynomials in α computed modulo p(α), and in that case by primitivity the zeroes of p(x) are exactly the powers that is, the powers having exponents in the cyclotomic coset C =(cid:8) 1, 2, 4, 8, . . . , 2n−1(cid:9). Note that 2n = α. Every rational function f (z) representing a bit of the generator can then be expressed as α a sum of partial fractions , . . . , α 2n−1 , α α, α , α , 2 4 8 (13) where βi ∈ E, βc (cid:44) 0. As a consequence [18], the j-th bit bj of the sequence associated with f (z) has an explicit description: 1 − zαc , βc . (14) f (z) = bj = c∈C βc c∈C (cid:0)αc(cid:1) j βcαc .  д(z) = c∈S c∈S βc 1 − zαc This property makes it possible to compute easily in closed form the sum of two sequences and the (output-by-output) product of two sequences. We just need to compute the sum or the product of the representation (14). In the case of the sum of two sequences it is just a term-by-term sum, whereas in the case of a product we obtain a convolution.26 In both cases, we might experience cancellation -- some of the β's might become zero. But, whichever operation we apply, we will obtain in the end for a suitable set S ⊆ [2n] a representation of the form (15) with βc (cid:44) 0. The cardinality of S is now exactly the degree of the polynomial at the denominator of the rational function associated with the new sequence, that is, its linear complexity [18]. 26We used the Sage algebra system [48] to perform our computations 32 Fs0(z) = Fs1(z) = Fs2(z) = David Blackman and Sebastiano Vigna z4 + z3 + 1 z6 + z4 + z3 + z + 1 z13 + z9 + z8 + z z15 + z14 + z11 + z7 + z4 + z3 + 1 z41 + z39 + z34 + z32 + z30 + z28 + z27 + z26 + z24 + z23 + z17 + z16 + z15 + z14 + z13 + z11 + z9 + z8 + z7 + z6 + z5 + z3 + 1 z37 + z35 + z32 + z30 + z27 + z25 + z24 + z20 + z19 + z17 + z14 + z11 + z8 + z2 Fig. 12. The generating functions of the three bits of the xorshift+ generator. In our example, the coefficients of the representation (14) of x0 are β1 = α β2 = α β4 = α β8 = α β16 = α β32 = α 4 + α 5 + α 5 + α 4 + α 5 + α 5 + α 3 3 + α 4 + α 3 + α 4 + α 2 + a 2 + α 2 + 1 2 + α 3 + α and similar descriptions are available for the other bits, so we are finally in the position of computing exactly the values of the recurrence (11): we simply have to use the representation in the splitting field to obtain a representation of si, and then revert to functional form using (13). The result is shown in Figure 12: as it is easy to see, we can still express the bits of xorshift+ as LFSRs, but their linear complexity rises quickly (remember that every generator with n bits of state is a linear generator of degree 2n with characteristic polynomial x 2n + 1, so "linear" should always mean "linear of low degree"). In fact, the generating function is irrelevant for our purposes: the only relevant fact is that the representation in the splitting field of the first bit has 6 coefficients, that of the second bit 15 and that of the third bit 41, because, as we have already observed, these numbers are equal to the linear complexity of the bits. Unfortunately, this approach can be applied only to state arrays of less than a dozen bits: as the linear complexity increases due to the influence of carries, the number of terms in the representation (15) grows quickly, up to being unmanageable. Thus, this approach is limited to the analysis of small examples or to the construction of counterexamples. 10.3 Representing scramblers by polynomials A less exact but more practical approach to the analysis of the scrambled output of a generator is that of studying the scrambler in isolation. To do so, we are going to follow the practice of the theory of filtered LFSRs: we will represent the scramblers as a sum of Zhegalkin polynomials, that is, squarefree polynomials over Z/2Z. Due to the peculiarity of the field, no coefficients or exponents are necessary. If we are able to describe the function as a sum of distinct polynomials, we will say that the function is in algebraic normal form (ANF). For example, the 3-bit scrambler of our example iff there is an S ⊆ [n] with 0 < S ≤ k and 2ti = αc α  c = i∈[k] s∈S 2s . generator can be described by expanding recurrence (11) into the following three functions in ANF: S0(x0, x1, x2, y0, y1, y2) = x0 + y0 S1(x0, x1, x2, y0, y1, y2) = x1 + y1 + x0y0 S2(x0, x1, x2, y0, y1, y2) = x2 + y2 + x1y1 + x0y0x1 + x0y0y1 33 There is indeed a connection between the polynomial degree of a Boolean function, that is, the maximum degree of a polynomial in its ANF, the linear complexity of the bits of a linear engine and the linear complexity of the bit returned by the Boolean function applied to the engine state. Lemma 10.1. Let E be the splitting field of a primitive polynomial p(x) of degree n, represented by polynomials in α computed modulo p(α). Then, there is a tuple ⟨t0, t1, . . . tk−1⟩ ∈ [n]k such that Note that we used that standard notation [n] = {0, 1, 2, . . . , n − 1}. Proof. First we show that the all c's are of the form above. When all the ti's are distinct, we have trivially S = {ti 0 ≤ i < k }. If ti = tj 2ti α α 2tj = α 2·2ti = α 2ti +1 , remembering that computations of exponents of α are to be made modulo 2n − 1. Thus, the problem is now reduced to a smaller tuple, and we can argue by induction that the result will be true for some S ⊆ [k − 1] ⊆ [k]. Now we show that for every S as in the statement there exists a corresponding tuple. If S = k, this is obvious. Otherwise, let S = j and s0, s1, . . . , sj−1 be an enumeration of the elements of S. Then, the k-tuple s0, s1, . . . , sj−2, sj−1 − 1, sj−1 − 2, . . . , sj−1 − k + j + 1, sj−1 − k + j, sj−1 − k + j, where the operations above are modulo 2n − 1, gives rise exactly to the set S, as 2sj−1−1 2sj−1−2 · · · α α α 2sj−1−k +j +1 α 2sj−1−k +j α 2sj−1−k +j 2sj . = α □ An immediate consequence of the previous lemma is that there is a bound on the increase of linear complexity that a Boolean function, and thus a scrambler, can induce: Proposition 10.2. If f is a Boolean function of n variables with polynomial degree d in ANF and xi, 0 ≤ i < n, are the bits of a linear engine with n bits of state, then the rational function representing f(cid:0)x0, x1, . . . , xn−1) has linear complexity at most U(n, d) = . (16) d (cid:19) (cid:18)n j=1 j David Blackman and Sebastiano Vigna resentation of f(cid:0)x0, x1 . . . , xn−1(cid:1) are bounded by U(n, d) by Lemma 10.1. Indeed, U(n, d) is very The result is obvious, as the number of possible nonzero coefficients of the splitting-field rep- well known in the theory of filtered LFSR: it is the standard bound on the linear complexity of a filtered LFSR. Our case is slightly different, as we are applying Boolean functions to bits coming from different instances of the same LFSR, but the mathematics goes along essentially in the same way. There is also another inherent limitation: a uniform scrambler on m bits cannot have polynomial 34 degree m: Proposition 10.3. Consider a vector of n Boolean functions on m variables such that the preimage of each vector of n bits contains exactly 2m−n vectors of m bits. Then, no function in the vector can have the (only) monomial of degree m in its ANF. Proof. Since the vector of functions maps the same number of input values to each output value, if we look at each bit and consider its value over all possible vectors of m bits, it must happen that it is zero 2m−1 times, one 2m−1 times. But all monomials of degree less than m evaluate to an even number of zeroes and ones. The only monomial of degree m evaluates to one exactly once. Hence, it cannot appear in any of the polynomial functions. □ Getting back to our example, the bounds for linear complexity of the bits of our xorshift+ 2(cid:1) +(cid:0)6 1(cid:1) +(cid:0)6 2(cid:1) = 21 and(cid:0)6 1(cid:1) +(cid:0)6 1(cid:1) = 6,(cid:0)6 3(cid:1) = 41. Thus, from Figure 12 we generator are respectively(cid:0)6 see that the less significant and the most significant bit attain the upper bound (16), whereas the intermediate bit does not. However, Lemma 10.1 implies that in principle every subset of S might be associated with a nonzero coefficient. If this does not happen, as in the case of the intermediate bit, it must be the case that all the contribution for that subset of S canceled out. The actual amount of cancellation happening for a specific combination of linear engine and scrambler can in principle be computed exactly using the splitting-field representation, but as we have discussed this approach does not lend itself to computations beyond very small generators. However, we gather some empirical evidence by computing the polynomial degree of the Boolean function associated with a bit using (11) and then by measuring directly the linear complexity using the Berlekamp -- Massey algorithm [18]: with a careful implementation, this technique can be applied much beyond where the splitting-field representation can get. The algorithm needs an upper bound on the linear complexity to return a reliable result, but we have (16), so this is not a problem. We ran extensive tests on a number of generators, the largest being 12-bit generators with 24 bits of state. The results are quite uniform: unless the state array of the linear engine is tiny, cancellation is an extremely rare event. Table 13 reports the measured linear complexity of a 12-bit xorshift generator with 24 bits of state after applying a + scrambler. As a comparison, we also show the large loss with respect to the upper bound (16) in the case of a generator based on an irreducible, but not primitive polynomial. Similar figures are reported in Table 14 for the ++ scrambler and in Table 15 for the ** scrambler. These empirical results suggest that it is a good idea to independently study scramblers as Boolean functions, and in particular estimating or computing their polynomial degree. Then, given a class of generator, one should gather some empirical evidence that cancellation is rare, and at that point use the upper bound (16) as an estimate of linear complexity. We remark however that a simply high polynomial degree is not sufficient to guarantee to pass all tests related to linearity. The problem is that such tests depends on the joint output of the Boolean functions we are considering. Moreover, there is a great difference between having high polynomial degree and passing a linear-complexity or binary-rank test. Polynomial a = 1, b = 7, c = 5 (primitive) a = 2, b = 1, c = 11 (nonprimitive) degree Loss Loss 35 0 0 8 136 2080 19336 122342 541886 1651167 3559524 6049875 8753797 Linear degree 24 300 2324 12950 55454 190050 536150 1271625 2579121 4540385 7036529 9740685 1 2 3 4 5 6 7 8 9 10 11 12 Linear degree 24 300 2316 12814 53374 170714 413812 729739 927962 980861 986654 986888 0 0 0 0 0 0 4 0 8 0 0 0 Table 13. Polynomial degree versus linear complexity for two 12-bit xorshift generators with 24 bits of state using the + scrambler. The first polynomial is primitive, whereas the second polynomial is just irreducible. The second column shows the loss in linear complexity with respect to the upper bound (16). In the first case the loss is due to cancellation only, in the second case also to the lack of primitivity. xw−1 +  i∈[w−1] For example, consider the following pathological Boolean function that could be part of a scrambler: xi . (17) Clearly, this function has very high polynomial degree, and thus a likely high linear complexity. The problem is that if, say, w = 64 from a practical viewpoint it is indistinguishable from xw−1, as the "correction" that raises its linear complexity almost never happens. If the state array is small, this bit will fail all linearity tests. A single high-degree monomial is not sufficient in isolation, in spite of Lemma 10.1. As a last counterexample, and cautionary tale, we consider the scrambler given by change of sign, that is, multiplication by the all-ones word. It is trivial to write this scrambler using negated variables, but when we expand it in ANF we get ¯xk = 1 + xw−1 +  (cid:0)1 + xk) = 1 + xw−1 +  xk . (18)  ¯xw−1 +  k ∈[w−1] k ∈[w−1] S ⊆[w−1] k ∈S In other words, the ANF contains all monomials formed with all other bits, but the Boolean function is still as pathological as (17), as there is no technical difference between xi and ¯xi. 10.4 The + scrambler We conclude this part of the paper with a detailed discussion of each scrambler, starting from +, introduced in Section 4.1. Recurrence (11) can be easily unfolded to a closed form for the scrambled 36 David Blackman and Sebastiano Vigna ρ8(x + y) + x Lin. deg. 55454 190050 536154 2579121 7036529 12236811 15505589 16587164 16764264 16764258 16764258 16764252 Pol. deg. 5 6 7 9 11 13 15 17 19 19 19 19 Loss Pol. deg. 4 5 6 8 10 12 14 16 18 20 20 20 0 0 0 8 0 18 0 0 0 6 6 12 ρ9(x + y) + x Lin. deg. 12950 55454 190046 1271625 4540385 9740685 14198085 16241044 16721760 16774890 16774890 16774890 Loss Pol. deg. 3 4 5 7 9 11 13 15 17 19 21 21 0 0 4 0 0 0 0 16 0 0 0 0 ρ10(x + y) + x Lin. deg. 2324 12950 55454 536154 2579129 7036529 12236829 15505587 16587164 16764264 16776908 16776906 Loss 0 0 0 0 0 0 0 2 0 0 6 8 Table 14. Polynomial degree versus linear complexity for a 12-bit xorshift generator with 24 bits of state and parameters a = 1, b = 7 and c = 5 using a few ++ scramblers. The second column shows the loss in linear complexity with respect to the upper bound (16) due to cancellation. 5ρ5(3x) 9ρ7(5x) 17ρ9(9x) Pol. deg. Lin. deg. Loss Pol. deg. Lin. deg. Loss Pol. deg. Lin. deg. Loss 0 0 0 0 0 0 0 4 8 0 3 0 536154 1271625 2579129 4540385 7036529 7036529 7036525 7036529 7036529 7036526 7036529 7036529 12950 55454 190050 536154 1271622 2579126 4540385 7036526 7036529 7036529 7036529 7036529 24 300 2324 12950 55454 190050 536154 2579125 4540377 7036529 7036526 7036529 7 8 9 10 11 11 11 11 11 11 11 11 1 2 3 4 5 6 7 9 10 11 11 11 0 0 0 0 3 3 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 3 0 0 4 5 6 7 8 9 10 11 11 11 11 11 Table 15. Polynomial degree versus linear complexity for a 12-bit xorshift generator with 24 bits of state and parameters a = 1, b = 7 and c = 5 using a few ** scramblers. The second column shows the loss in linear complexity with respect to the upper bound (16) due to cancellation. 37 xoroshiro128+ 128 8256 349632 11017632 275584032 xoshiro256+ 256 32896 2796416 177589056 8987138112 xoshiro512+ 512 131328 22370048 2852247168 290367762560 xoroshiro1024+ 1024 524800 178957824 45723987200 9336909979904 xoroshiro64+ 64 2080 43744 679120 8303632 xoshiro128+ 128 8256 349632 11017632 275584032 Table 16. Estimated linear complexity of the five lowest bit of generators (first line is bit 0) using the + scrambler. bit sb: sb = xb + yb + b i =1 xi−1yi−1   S ⊆[b−i] j∈S xi +j  j∈[b−i]\S yi +j = xb + yb + b i =1 xi−1yi−1  j∈[b−i] (cid:0)xi +j + yi +j (cid:1) (19) If the xi's and the yi's are distinct, the expressions above are in ANF: there are exactly 2b + 1 monomials with maximum degree b + 1. Thus, if the underlying linear engine has n bits of state the linear-degree bound for bit b will be U(n, b + 1). An important observation is that no monomial appears in two instances of the formula for different values of b. This implies that any linear combination of bits output by the + scrambler have the same linear complexity of the bit of highest degree, and at least as many monomials: we say in this case that there is no polynomial degree loss. Thus, with the exception of the very lowest bits, we expect that no linearity will be detectable: in Table 16 we report the linear complexity of the lowest bits of some generators; the degree has been estimated using (16). The lowest values have also been verified using the Berlekamp -- Massey algorithm: as expected, we could not detect any linear-degree loss. While an accurate linear-complexity test might catch the fourth lowest bit of xoroshiro128+, the degree raises quickly to the point the linearity is undetectable. Note that if the underlying linear engine is d-dimensionally equidistributed, the scrambler The situation for Hamming-weight dependencies is not so good, however, as empirically (Table 1) we have already observed that xoroshiro engines still fail our test (albeit using three orders of magnitude more data). We believe that this is due to the excessively regular structure of the monomials: the simplest successful scrambler against the test is indeed multiplication by a constant, which provides a very irregular monomial structure. If there is some overlap it is necessary to rewrite (19) replacing suitably xi and yi and try to obtain an algebraic normal form. generator will be in general at most (d − 1)-dimensionally equidistributed (see Section 8). 10.5 The * scrambler We now discuss the * scrambler, introduced in Section 4.2, in the case of a multiplicative constant of the form 2s + 1. This case is particularly interesting because it is very fast on recent hardware; in particular, (2s +1)·x = x +(x ≪ s), where the sum is in Z/2w Z, which provides a multiplication-free implementation. Moreover, as we will see, the analysis of the 2s + 1 case sheds light on the general case, too. 38 David Blackman and Sebastiano Vigna Let z = (2s + 1)x. Specializing (19), we have that zb = xb when b < s; otherwise, b = c + s ≥ s and c i =1    zb = zc +s = xc +s + xc + xi−1+s xi−1 xi +j+s xi +j S ⊆[c−i] j∈S j∈[c−i]\S = xc +s + xc + xi−1+s xi−1 c i =1  k ∈[c−i] (cid:0)xi +k +s + xi +k (cid:1). (20) However, contrarily to (19) the expressions above do not denote an ANF, as the same variable may appear many times in the same monomial. We note that the monomial xsx0xs +1 · · · xs +c−1, which is of degree c + 1, appears only and always in the function associated with yb, b > s. Thus, bits with b ≤ s have degree one, whereas bits b with b > s have degree b − s + 1. In particular, as in the case of +, there is no polynomial degree loss when combining different bits. In case of a generic (odd) constant m, one has to modify recurrence (11) so as to start including shifted bits at the right stage, which creates a very complex monomial structure. Note, however, that bits after the second-lowest bit set in m cannot modify the polynomial degree. Thus, the decrease of Hamming-weight dependencies we observe in Table 1 even for xoroshiro* is not due to higher polynomial degree with respect to + (indeed, the opposite is true), but to a richer structure of the monomials. The degree reported for the + scrambler in Table 16 can indeed be adapted to the present case: one has just to copy the first line as many times as the index of the second-lowest bit set in m. To get some intuition about the monomial structure, it is instructive to get back to the simpler case m = 2s + 1. From (20) it is evident that monomials associated with different values of i cannot be equal, as the minimum variable appearing in a monomial is xi−1. Once we fix i with 1 ≤ i ≤ c, the number of monomials is equal to the number of sets of the form S + s ∪ [c − i] \ S ∪ {s − 1} (21) that can be expressed by an odd number of values of S (if you can express the set in an even number of ways, they cancel out). But such sets are in bijection with the values (v ≪ s) ∨ ¬s ∨ (1 ≪ s − 1) as v varies among the words of c − i bits. In a picture, we are looking at the logical or by columns of the following diagram, where the bj's are the bits of v, for convenience numbered from the most significant: S ⊆ [c − i] A first obvious observation is that if s > c − i the two rows are nonoverlapping, and they are not influenced by the one in position s − 1. In this case, we obtain all possible 2c−i monomials. More generally, such sets are all distinct iff s ≥ (c − i + 1)/2, as in that case the value must differ either in the first s or in the last s − 1 bits: consequently, the number of monomials in this case is again 2c−i. Minimizing i and maximizing c we obtain s ≥ (w − s − 1)/2, whence s ≥ (w − 1)/3. In this case, the monomials of zb are exactly 2b−s + 1 when b ≥ s. As s moves down from (w −1)/3, we observe empirically more and more reduction in the number of monomials with respect to the maximum possible 2b−s. When we reach s = 1, however, a radical change happens: the number of monomials grows as 2b/2. b0b1...bs−2bs−1bsbs+1...bc−i−1¬b0¬b1...¬bc−i−s−11¬bc−i−s+1...¬bc−i−1 39 Theorem 10.4. The number of monomials of the Boolean function representing bit b of 3x is27 (2 + [b odd]) · 2⌊b/2⌋ − 1. We remark a surprising combinatorial connection: this is the number of binary palindromes smaller than 2b, that is, A052955 in the "On-Line Encyclopedia of Integer Sequences" [17]. Proof. When s = 1, the different subsets in (21) obtained when S varies are in bijection with the values v ∨ ¬(v ≫ 1) as v varies among the words of c − i bits. Again, we are looking at the logical or by columns of the following diagram, where the bj's are the bits of v numbered from the most significant: will cancel each other. Note that if there is a bj whose value is irrelevant, flipping will generate two monomials which Let us consider now a successive assignment of values to the bj's, starting from b0. We remark that as long as we assign ones, no assigned bit is irrelevant. As soon as we assign a zero, however, say to bj, we have that the value of bj+1 will no longer be relevant. To make bj+1 relevant, we need to set bj+2 = 0. The argument continues until the end of the word, so we can actually choose the value of (c − i − j − 1)/2 bits, and only if c − i − j − 1 is even (otherwise, bc−i−1 has no influence). We now note that if we flip a bit bk that we were forced to set to zero, there are two possibilities: either we chose bk−1 = 1, in which case we obtain a different word, or we chose bk−1 = 0, in which case bk is irrelevant, but by flipping also bk +1 we obtain once again the same word, so the two copies cancel each other. Said otherwise, words with an odd number of occurrences are generated either when all bits of v are set to one, or when there is a string of ones followed by a suffix of odd length in which every other bit (starting from the first one) is zero. All in all, we have 2 1 + (cid:7) 2 (cid:5) (cid:4) c−i−1 2k = 2(cid:6) c−i−1 2(cid:6) b−i−2 (cid:7) b−1 k =0 2 = (2 + [b odd]) · 2⌊b/2⌋ − 1. possible monomials, where 2k + 1 is the length of the suffix. Adding up over all i's, and adding the two degree-one monomials we have that the number of monomials of yb for b = c + 1 > 0 is b−1 2(cid:6) b−i−2 2 (cid:7) 2 + = 1 + 1 + i =1 i =1 The correctness for the case b = 0 can be checked directly. □ We remark that in empirical tests the 3x scrambler performs very badly, which seems to confirm the intuition that the cancellation of monomials is excessive in that case. 27Note that we are using Knuth's extension of Iverson's notation [20]: a Boolean expression between square brackets has value 1 or 0 depending on whether it is true or false, respectively. b0b1b2b3...bc−i−1¬b0¬b1¬b2...¬bc−i−2 40 David Blackman and Sebastiano Vigna xoroshiro128++ xoshiro256++ xoshiro512++ xoroshiro1024++ xoshiro128++ 1 × 1027 5 × 1027 2 × 1028 6 × 1028 1 × 1036 2 × 1036 3 × 1036 4 × 1036 9 × 1074 2 × 1076 4 × 1077 1 × 1079 3 × 1048 2 × 1049 1 × 1050 4 × 1050 1 × 1068 1 × 1069 9 × 1069 8 × 1070 Table 17. Approximate lower bound on the estimated linear complexity of the four lowest bit (first line is bit 0) of generators using the ++ scrambler with parameters from Table 3 and 6. 10.6 The ++ scrambler We will now examine the strong scrambler ++ introduced in Section 4.3. We choose two words x, y from the state of the linear engine and then z = ρr(x + y) + x, where + denotes sum in Z/2w Z. Computing an ANF for the final Boolean functions appears to be a hard combinatorial problem: nonetheless, with this setup we know that the lowest bit will have polynomial degree w − r + 1, and we expect that the following bits will have increasing degree, possibly up to saturation. Symbolic computations in low dimension show however that the growth is quite irregular (see Table 14). The linear complexity of the lowest bits is large, as shown in Table 17, where we display a theoretical estimate based on (16), assuming that on lower bits degree increase at least by one at each bit (experimentally, it usually grows more quickly -- see again Table 17). This scrambler is potentially very fast, as it requires just three operations and no multiplication, and it can reach a high polynomial degree, as it uses 2w bits.28 Moreover, its simpler structure makes it attractive in hardware implementations: for example, it has been used by Parallax to embed in their Propeller 2 microcontroller multiple 16-bit xoroshiro32++ generators. However, the very regular structure of the + scrambler makes experimentally ++ less effective on Hamming-weight dependencies. Thus, any choice of state words and parameters should be carefully analyzed using the test of Section 6. As a basic heuristic, we suggest to choose a rotation parameter r ∈ [w/4 . . 3w/4] such that r and w − r are both prime (or at least odd), and they are not equal to any of the shift/rotate parameters appearing in the generator (the second condition being more relevant than the first one). Smaller values of r will of course provide a higher polynomial degree, but too small values yield too short carry chains. For w = 64 candidates are 17, 23, 41, and 47; for w = 32 one has 13 and 19; for w = 16 one has 5 and 11. In any case, a specific combination of linear engine and scrambler should be analyzed using the test described in Section 6. As in the case of the + scrambler, if the underlying linear engine is d-dimensionally equidistributed, the scrambler generator will be in general at most (d − 1)-dimensionally equidistributed (see Section 8). 10.7 The ** scrambler We conclude our discussion with the strong scrambler ** introduced in Section 4.4. We start by discussing the case with multiplicative constants of the form 2s + 1 and 2t + 1, which is particularly fast (the + symbol will denote sum in Z/2w Z for the rest of this section). Let z = ρr(x ·(2s +1))·(2t +1). Clearly, the min{r , t } lowest bits of z are the min{r , t } highest bits of x · (2s + 1). To choose s, r and t we can leverage our previous knowledge of the scrambler *. We 28Symbolic computation suggests that this scrambler can reach only polynomial degree 2w − 3; while we have the bound 2w − 1 by Proposition 10.3, proving the bound 2w − 3 is an open problem. 3 × 1037 4 × 1037 6 × 1037 7 × 1037 2 × 1057 7 × 1057 3 × 1058 9 × 1058 xoroshiro128** xoshiro256** xoshiro512** xoroshiro1024** xoroshiro64** xoshiro128** 8 × 1025 3 × 1026 1 × 1027 5 × 1027 Table 18. Approximate estimated linear complexity of the four lowest bit (first line is bit 0) of generators using the ** scrambler with parameters from Table 3 and 6. 4 × 1075 3 × 1076 2 × 1077 2 × 1078 1 × 1093 2 × 1094 3 × 1095 6 × 1096 41 2 × 1018 3 × 1018 5 × 1018 6 × 1018 start by imposing that s < t, as choosing s = t generates several duplicates that reduce significantly the number of monomials in the ANF of the final Boolean functions, whereas t < s provably yields a lower minimum degree for the same r (empirical computations show also a smaller number of monomials). We also have to impose t < r, for otherwise some bits or xor of pair of bits will have very low linear complexity (polynomial degree one). So we have to choose our parameters with the constraint s < t < r. Since the degree of the lowest bit is max(1, w − r − s + 1), choosing r = t + 1 maximizes the minimum degree across the bits. Moreover, we would like to keep s and t as small as possible, to increase the minimum linear complexity and also to make the scrambler faster. Also in this case computing an ANF for the final Boolean functions appears to be a hard combina- torial problem: nonetheless, with this setup we know that the lowest bit will have (when r + s ≤ w) polynomial degree w − r − s + 1, and we expect that the following bits will have increasing degree up to saturation (which happens at degree w − 1 by Proposition 10.3). Symbolic computations in low dimension show some polynomial degree loss caused by the second multiplication unless r = 2t + 1; moreover, for that value of r the polynomial degree loss when combining bits is almost absent. Taking into consideration the bad behavior of the multiplier 3 highlighted by Theorem 10.4, we conclude that the best choice is s = 2, t = 3 and consequently r = 7. These are the parame- ters reported in Table 3. The linear complexity of the lowest bits is extremely large, as shown in Table 18.29 At 32 bits, however, tests show that this scrambler is not sufficiently powerful for xoroshiro64, and Table 6 reports indeed different parameters: the first multiplier is the constant used for the * scrambler, and the second multiplier 2t + 1 has been chosen so that bit t is not set in the first constant. Again, r = 2t + 1, following the same heuristic of the previous case.30 11 CONCLUSIONS The combination of xoroshiro/xoshiro and suitable scramblers provides a wide range of high- quality and fast solutions for pseudorandom number generation. Parallax has embedded in their re- cently designed Propeller 2 microcontroller xoroshiro128** and xoroshiro32++; xoroshiro116+ is the stock generator of Erlang, and the next version of the popular embedded language Lua will sport xoshiro256** as stock generator. Recently, the speed of xoshiro128** has found application in cryptography [1, 11]. 29Note that as we move towards higher bits the ++ scrambler will surpass the linear complexity of the ** scrambler; the fact that the lower bits appear of lower complexity is due only to the fact that we use much larger rotations in the ++ case. 30We remark that in this case in theory we would not strictly need to fix the first constant so that it has the second-lowest bit set, but we prefer to use the same constant of the * case for uniformity. The same consideration is true of the r = 2t + 1 heuristics. 42 David Blackman and Sebastiano Vigna We believe that a more complete study of scramblers can shed some further light on the behavior of such generators: the main open problem is that of devising a model explaining the elimination of Hamming-weight dependencies. While targeting a high polynomial degree (and several low-degree monomials) seem to be sufficient to obtain resilience to binary-rank and linear-complexity test, we have little intuition of what causes an improvement in the results in the test described in Section 6. The main difficulty is that analyzing the Boolean functions representing each scrambled bit in isolation is not sufficient, as Hamming-weight dependencies are generated by their collective behavior. There are variants of the scramblers we discussed that do not use rotations: for example, in the ++ and ** scrambler the rotation can be replaced by xoring x with x ≫ r, as also this operation will increase the linear complexity of the lower bits. For contexts in which rotations are not available or too expensive, one might explore the possibility of using xorshift generators scrambled with such variants. On a more theoretical side, it would be interesting to find a closed form for the number of monomials of the scrambler * with constant (2s + 1) when s > 1, thus extending Theorem 10.4, or an ANF for the Boolean functions of the ++ and ** scramblers. For more complex matrices, word polynomials might be based on more general approaches, such as quasideterminants [10]. In some desperate case, one might degenerate to the Dieudonné determinant [8], which basically forces commutativity of all blocks by remapping them in the Abelianization of the subring R they generate. In the case of a word polynomial predicting (almost) exactly the generator it might be interesting to tune the parameters of the generator using the figure of merit introduced in [38]. There is of course a vast literature on filtered LFSR that might be used to prove aspects we approached only with symbolic small-state computations in Section 10. For example, in [22] the authors prove a lower bound on the linear degree of a Boolean function made of single very specific monomial, something for which we just argued on the basis of measurement made using the Berlekamp -- Massey algorithm. In [3] the authors try to provide closed forms or even ANFs when the argument of a Boolean function is multiplied or summed with a constant, which might be a starting point for a closed form for the ** scrambler. Finally, several concepts developed in the context of filtered LFSR, such as algebraic immunity and Bent functions might prove to be useful in choosing scrambler parameters, or defining new ones. In general, it is an interesting open problem to correlate explicitly the monomial structure of a Boolean function in ANF with the resilience to linearity tests. Intuitively, recalling (18), one sees that besides large-degree monomials one needs small-degree monomials to make the tests "perceive" the increase in linear complexity at the right time. ACKNOWLEDGMENTS The authors would like to thank Jeffrey Hunter for useful pointers to the literature about mean passage times in Markov chains, Parallax developers Chip Gracey, Evan Hillas and Tony Brewer for their interest, enthusiasm and proofreading, Pierre L'Ecuyer for a number of suggestions that significantly improved the quality of the presentation, Raimo Niskanen of the Erlang/OTP team and Nat Sothanaphan for several useful discussions, Guy Steele for stimulating correspondence and for suggesting to include data-dependency diagrams, Robert H. Lewis for the unbelievable speed of Fermat [28], and the Sage authors for a wonderful tool [48]. REFERENCES [1] Joppe W. Bos, Simon Friedberger, Marco Martinoli, Elisabeth Oswald, and Martijn Stam. 2018. Fly, you fool! Faster Frodo for the ARM Cortex-M4. Cryptology ePrint Archive, Report 2018/1116. (2018). https://eprint.iacr.org/2018/1116. 43 [2] Nicolas Bourbaki. 1989. Algebra: Elements of Mathematics. Springer-Verlag. [3] An Braeken and Igor A. Semaev. 2005. The ANF of the Composition of Addition and Multiplication mod 2n with a Boolean Function. In Fast Software Encryption: 12th International Workshop, FSE 2005, Paris, France, February 21-23, 2005, Revised Selected Papers (Lecture Notes in Computer Science), Henri Gilbert and Helena Handschuh (Eds.), Vol. 3557. Springer, 112 -- 125. [4] Sergio Caracciolo, Alan D. Sokal, and Andrea Sportiello. 2009. Noncommutative determinants, Cauchy -- Binet for- mulae, and Capelli-type identities I. Generalizations of the Capelli and Turnbull identities. The Electronic Journal of Combinatorics 16, 1 (2009), 103. [5] G. D. Carter. 1989. Aspects of local linear complexity. Ph.D. Dissertation. University of London. [6] A. Chervov, G. Falqui, and V. Rubtsov. 2009. Algebraic properties of Manin matrices 1. Advances in Applied Mathematics [7] Aaldert Compagner. 1991. The hierarchy of correlations in random binary sequences. Journal of Statistical Physics 63, 43, 3 (2009), 239 -- 315. 5-6 (1991), 883 -- 896. [8] Jean Dieudonné. 1943. Les déterminants sur un corps non commutatif. Bull. Soc. Math. France 71, 171-180 (1943), 95. [9] E. D. Erdmann. 1992. Empirical tests of binary keystreams. (1992). [10] Israel M Gel'fand and Vladimir S Retakh. 1991. Determinants of matrices over noncommutative rings. Functional Analysis and Its Applications 25, 2 (1991), 91 -- 102. [11] FranÃğois GÃľrard and MÃľlissa Rossi. 2019. An Efficient and Provable Masked Implementation of qTESLA. Cryptology ePrint Archive, Report 2019/606. (2019). https://eprint.iacr.org/2019/606. [12] Hiroshi Haramoto, Makoto Matsumoto, Takuji Nishimura, François Panneton, and Pierre L'Ecuyer. 2008. Efficient Jump Ahead for F2-Linear Random Number Generators. INFORMS Journal on Computing 20, 3 (2008), 385 -- 390. [13] Shin Harase. 2014. On the F2-linear relations of Mersenne Twister pseudorandom number generators. Mathematics and Computers in Simulation 100 (2014), 103 -- 113. [14] Christian Hipp and Lutz Mattner. 2008. On the Normal Approximation to Symmetric Binomial Distributions. Theory [15] Jeffrey J. Hunter. 1983. Mathematical Techniques of Applied Probability, Volume 2, Discrete-Time Models: Techniques and [16] Jeffrey J. Hunter. 2008. Variances of first passage times in a Markov chain with applications to mixing times. Linear Probab. Appl. 52, 3 (2008), 516 -- 523. Applications. Academic Press, New York. Algebra Appl. 429, 5 (2008), 1135 -- 1162. [17] OEIS Foundation Inc. 2017. The On-Line Encyclopedia of Integer Sequences. (2017). http://oeis.org/ [18] Andreas Klein. 2013. Stream Ciphers. Springer London, London. [19] Donald E. Knuth. 1973. The Art of Computer Programming. Addison -- Wesley. [20] Donald E. Knuth. 1992. Two notes on notation. American Mathematical Monthly 99, 5 (May 1992), 403 -- 422. [21] Donald E. Knuth. 2011. The Art of Computer Programming: Volume 4, Combinatorial algorithms. Part 1. Vol. 4A. Addison-Wesley. xv + 883 pages. [22] Nicholas Kolokotronis, Konstantinos Limniotis, and Nicholas Kalouptsidis. 2007. Improved Bounds on the Linear Complexity of Keystreams Obtained by Filter Generators. In Inscrypt (Lecture Notes in Computer Science), Dingyi Pei, Moti Yung, Dongdai Lin, and Chuankun Wu (Eds.), Vol. 4990. Springer, 246 -- 255. [23] Pierre L'Ecuyer. 1996. Maximally Equidistributed Combined Tausworthe Generators. Math. Comp. 64, 213 (1996), [24] Pierre L'Ecuyer and Jacinthe Granger-Piché. 2003. Combined generators with components from different families. Mathematics and Computers in Simulation 62, 3 (2003), 395 -- 404. 3rd IMACS Seminar on Monte Carlo Methods. [26] Pierre L'Ecuyer and Richard Simard. 1999. Beware of linear congruential generators with multipliers of the form [25] Pierre L'Ecuyer and François Panneton. 2009. F2-Linear Random Number Generators. In Advancing the Frontiers of Simulation, Christos Alexopoulos, David Goldsman, and James R. Wilson (Eds.). International Series in Operations Research & Management Science, Vol. 133. Springer US, 169 -- 193. a = ±2q ± 2r . ACM Trans. Math. Softw. 25, 3 (1999), 367 -- 374. ACM Trans. Math. Softw. 33, 4, Article 22 (2007). [27] Pierre L'Ecuyer and Richard Simard. 2007. TestU01: A C library for empirical testing of random number generators. [28] Robert H. Lewis. 2018. Fermat: A Computer Algebra System for Polynomial and Matrix Computation. (2018). 203 -- 213. http://home.bway.net/lewis/ Press, Cambridge. [29] Rudolf Lidl and Harald Niederreiter. 1994. Introduction to finite fields and their applications. Cambridge University [30] Yuri Ivanovitch Manin. 1988. Quantum groups and non-commutative geometry. Centre de Recherches mathématiques, Université de Montréal, Montréal QC, Canada. [31] George Marsaglia. 2003. Xorshift RNGs. Journal of Statistical Software 8, 14 (2003), 1 -- 6. [32] George Marsaglia and Liang-Huei Tsay. 1985. Matrices and the structure of random number sequences. Linear Algebra 44 David Blackman and Sebastiano Vigna Appl. 67 (1985), 147 -- 156. [33] Makoto Matsumoto and Takuji Nishimura. 1998a. Dynamic creation of pseudorandom number generators. Monte Carlo and Quasi-Monte Carlo Methods 2000 (1998), 56 -- 69. [34] Makoto Matsumoto and Takuji Nishimura. 1998b. Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator. ACM Trans. Model. Comput. Simul. 8, 1 (1998), 3 -- 30. [35] Makoto Matsumoto and Takuji Nishimura. 2002. A Nonempirical Test on the Weight of Pseudorandom Number Generators. Springer Berlin Heidelberg, Berlin, Heidelberg, 381 -- 395. [36] Makoto Matsumoto, Isaku Wada, Ai Kuramoto, and Hyo Ashihara. 2007. Common Defects in Initialization of Pseudorandom Number Generators. ACM Trans. Model. Comput. Simul. 17, 4 (2007). [37] Carl D. Jr. Meyer. 1975. The Role of the Group Generalized Inverse in the Theory of Finite Markov Chains. SIAM Rev. [38] Harald Niederreiter. 1992. Random number generation and quasi-Monte Carlo methods. CBMS-NSF regional conference [39] Harald Niederreiter. 1995. The multiple-recursive matrix method for pseudorandom number generation. Finite Fields 17, 3 (1975), 443 -- 464. series in Appl. Math., Vol. 63. SIAM. and their Applications 1, 1 (1995), 3 -- 30. ac.jp/~m-mat/MT/XSADD/ sci.hiroshima-u.ac.jp/~m-mat/MT/TINYMT/ Supplement C (2017), 202 -- 218. [40] François Panneton, Pierre L'Ecuyer, and Makoto Matsumoto. 2006. Improved long-period generators based on linear recurrences modulo 2. ACM Trans. Math. Softw. 32, 1 (2006), 1 -- 16. [41] Mutsuo Saito and Makoto Matsumoto. 2008. SIMD-oriented fast Mersenne Twister: a 128-bit pseudorandom number generator. In Monte Carlo and Quasi-Monte Carlo Methods 2006. Springer, 607 -- 622. [42] Mutsuo Saito and Makoto Matsumoto. 2009. A PRNG Specialized in Double Precision Floating Point Numbers Using an Affine Transition. In Monte Carlo and Quasi-Monte Carlo Methods 2008, Pierre L'Ecuyer and Art B. Owen (Eds.). Springer Berlin Heidelberg, 589 -- 602. DOI:http://dx.doi.org/10.1007/978-3-642-04107-5_38 [43] Mutsuo Saito and Makoto Matsumoto. 2014. XSadd (Version 1.1). (25 March 2014). http://www.math.sci.hiroshima-u. [44] Mutsuo Saito and Makoto Matsumoto. 2015. Tiny Mersenne Twister (Version 1.1). (24 March 2015). http://www.math. [45] Nat Sothanaphan. 2017. Determinants of block matrices with noncommuting blocks. Linear Algebra Appl. 512, [46] Guy L. Steele, Jr., Doug Lea, and Christine H. Flood. 2014. Fast Splittable Pseudorandom Number Generators. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA '14). ACM, New York, NY, USA, 453 -- 472. [47] Dan Terpstra, Heike Jagode, Haihang You, and Jack Dongarra. 2010. Collecting Performance Data with PAPI-C. In Tools for High Performance Computing 2009, Matthias S. Müller, Michael M. Resch, Alexander Schulz, and Wolfgang E. Nagel (Eds.). Springer Berlin Heidelberg, 157 -- 173. [48] The Sage Developers. 2018. SageMath, the Sage Mathematics Software System (Version 8.0). http://www.sagemath.org [49] Sebastiano Vigna. 2016a. An experimental exploration of Marsaglia's xorshift generators, scrambled. ACM Trans. Math. Software 42, 4 (2016). Article No. 30. [50] Sebastiano Vigna. 2016b. Further scramblings of Marsaglia's xorshift generators. J. Comput. Appl. Math. 315 (2016), 175 -- 181.
1803.04865
1
1803
2018-03-13T15:02:57
Mathematical models and search algorithms for the capacitated $p$-center problem
[ "cs.DS" ]
The capacitated p-center problem requires to select p facilities from a set of candidates to service a number of customers, subject to facility capacity constraints, with the aim of minimizing the maximum distance between a customer and its associated facility. The problem is well known in the field of facility location, because of the many applications that it can model. In this paper, we solve it by means of search algorithms that iteratively seek the optimal distance by solving tailored subproblems. We present different mathematical formulations for the subproblems and improve them by means of several valid inequalities, including an effective one based on a 0-1 disjunction and the solution of subset sum problems. We also develop an alternative search strategy that finds a balance between the traditional sequential search and binary search. This strategy limits the number of feasible subproblems to be solved and, at the same time, avoids large overestimates of the solution value, which are detrimental for the search. We evaluate the proposed techniques by means of extensive computational experiments on benchmark instances from the literature and new larger test sets. All instances from the literature with up to 402 vertices and integer distances are solved to proven optimality, including 13 open cases, and feasible solutions are found in 10 minutes for instances with up to 3038 vertices.
cs.DS
cs
Mathematical models and search algorithms for the capacitated p-center problem Raphael Kramer, Manuel Iori Dipartimento di Scienze e Metodi dell'Ingegneria Universit`a degli Studi di Modena e Reggio Emilia, Italy {raphael.kramer, manuel.iori}@unimore.it Thibaut Vidal Departamento de Inform´atica Pontif´ıcia Universidade Cat´olica do Rio de Janeiro, Brazil [email protected] Technical Report – March 2018 Abstract The capacitated p-center problem requires to select p facilities from a set of candidates to service a number of customers, subject to facility capacity constraints, with the aim of minimizing the maximum distance between a customer and its associated facility. The problem is well known in the field of facility location, because of the many applications that it can model. In this paper, we solve it by means of search algorithms that iteratively seek the optimal distance by solving tailored subproblems. We present different mathematical formulations for the subproblems and improve them by means of several valid inequalities, including an effective one based on a 0-1 disjunction and the solution of subset sum problems. We also develop an alternative search strategy that finds a balance between the traditional sequential search and binary search. This strategy limits the number of feasible subproblems to be solved and, at the same time, avoids large overestimates of the solution value, which are detrimental for the search. We evaluate the proposed techniques by means of extensive computational experiments on benchmark instances from the literature and new larger test sets. All instances from the literature with up to 402 vertices and integer distances are solved to proven optimality, including 13 open cases, and feasible solutions are found in 10 minutes for instances with up to 3038 vertices. 1 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. 1 Introduction Facility location problems play an important role in the operations research and combi- natorial optimization literature. Since the early years of these disciplines, considerable research effort has been dedicated to their solution, due to their importance in supply chain management, healthcare, telecommunications, humanitarian relief, and machine learning applications, among many others (see, e.g., Drezner and Hamacher 2002 and Laporte et al. 2015). The p-center problem (PCP) is a particular facility location problem that requires to select p facilities, from a set of candidates, to serve a set of customers in such a way that the maximum distance between a customer and its closest facility is minimized (see, e.g., Hakimi 1964 and Minieka 1970). Two problem variants are usually distinguished: the absolute PCP, where the facilities can be located on the vertices or on the edges of a graph, and the vertex PCP, considered here, in which the facilities can be located only on the vertices (see, e.g., Kariv and Hakimi 1979). The main applications of the PCP arise in the location of emergency facilities, such as fire stations, police stations, and ambulance waiting locations, in a context where the worst-case service level, e.g., service time or distance, must be bounded or minimized (see, e.g., Daskin 1995 and Marianov and ReVelle 1995). The PCP is known to be NP-hard (Kariv and Hakimi, 1979; Masuyama et al., 1981), and thus several heuristics have been proposed for its solution, making use of paradigms such as tabu search (Mladenovi´c et al., 2003), bee colony optimization (Davidovi´c et al., 2011), variable neighborhood search (Irawan et al., 2015), and other techniques (Hochbaum and Shmoys 1985, Plesn´ık 1987, Mihelic and Robic 2003, and Davoodi et al. 2011). From the perspective of exact PCP methods, the most successful type of approach, to the best of our knowledge, consists in solving a series of covering subproblems with the help of preprocessing and reduction techniques (Daskin 2000, Ilhan et al. 2002, Elloumi et al. 2004, Chen and Chen 2009, and Calik and Tansel 2013). In this paper, we focus on the capacitated version of the vertex PCP, in which each customer is characterized by a demand and each candidate facility by a capacity. Each demand must be serviced integrally by one of the p chosen facilities, without exceeding their capacities. This feature renders the problem more challenging: a customer may no longer be assigned to its closest facility, and thus the complete characterization of a solution requires both facility opening and customer-facility allocation decisions. To solve the problem, we propose a decomposition algorithm that searches for the op- timal distance by iteratively solving a capacitated set covering formulation. The decom- position is enhanced by devising tailored search algorithms as well as valid inequalities and symmetry breaking rules for the set covering subproblems. We also introduce an al- 2 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. ternative arc-flow formulation, which is shown to provide good linear-relaxation bounds. Computational experiments conducted on a large set of benchmark instances show that our techniques help to find and prove optimal solutions. In particular, we provide the optimal solutions for all the benchmark instances with up to 402 vertices considered in the literature, including 13 open cases. Finally, to better evaluate the performance of the proposed algorithms, we introduce and solve new instances containing between 50 and 3000 vertices. The remainder of this paper is organized as follows. Section 2 formally describes the problem and reviews the related literature. Section 3 presents the mathematical formu- lations and the decomposition-based approach. Section 4 introduces improvement meth- ods, whereas Section 5 presents classical and alternative decomposition-based search algorithms. Section 6 reports our computational experiments and Section 7 concludes. 2 Problem Description and Literature Review The capacitated p-center problem (CPCP) is defined as follows. Let G = (F, C, E) be a bipartite graph, where F = {1, . . . , m} and C = {1, . . . , n} are the sets of candidate locations and customer nodes, respectively, and E = {(i, j) : i ∈ F, j ∈ C} is the set of edges. Each edge (i, j) ∈ E represents a possible assignment of a customer j to a facility i and has a non-negative distance dij. Each facility i ∈ F has a capacity Qi, which can be used to supply the demands qj of customers j ∈ C. Unless stated otherwise, we assume in the following that the input parameters are integer. The CPCP aims at opening at most p facilities and assigning each customer to exactly one facility, seeking to minimize the maximum distance between a customer and its facility, and ensuring that the total demand of the customers assigned to each facility does not exceed its capacity. The CPCP is closely related to the capacitated p-median problem (CPMP), the latter differing only in the objective function, which minimizes the sum of all the customer- facility assignments. The literature on the CPMP is abundant, especially for heuristic methods (see, e.g., Reese, 2006). In terms of exact algorithms, we highlight the column generation approach of Lorena and Senne (2004) and the branch-and-price algorithm of Ceselli and Righini (2005). In the former article, the authors formulate the restricted master problem as a set covering model, solve m binary knapsack subproblems to gener- ate the columns, and use a Lagrangian/surrogate relaxation to speed up the convergence. In the latter article, the authors use a similar column generation approach to obtain the linear relaxation for the nodes of a branch-and-bound algorithm. Branching is performed first on location variables, and then on assignment variables. Their best algorithm has good performance on small instances and on instances with a large n/p ratio. The benchmark sets introduced in these articles are now commonly used to evaluate solution 3 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. procedures for the CPCP. In addition to these works, Boccia et al. (2008) proposed a cutting plane algorithm based on Fenchel cuts (see Boyd 1993, 1994), which improved the gaps provided by the previously cited works and led to new proven optimal solutions. For what concerns exact approaches for the uncapacitated version of the p-median prob- lem, we point out the column-and-row generation method by Garc´ıa et al. (2011), and the branch decomposition algorithm by Fast and Hicks (2017). In contrast with the CPMP, the literature on the CPCP is limited. Concerning exact methods, Jaeger and Goldberg (1994) presented a polynomial algorithm for the special case in which assignments among customers and facilities are organized on a tree network and capacities are identical. Ozsoy and Pınar (2006) proposed binary search algorithms that iteratively solve either a capacitated concentrator location problem or a variant of the bin packing problem. Their computational experiments demonstrate that these search algorithms provide better results than the solution of a compact formulation of the problem. The idea of decomposing the original problem into smaller subproblems was also adopted by Albareda-Sambola et al. (2010). They considered two subproblems: a capacitated concentrator location problem, and a capacitated maximal covering problem. Moreover, instead of directly solving the subproblem formulations via available mixed integer linear programming (MILP) solvers, they performed a Lagrangian relaxation of the assignment constraints to improve the lower bounds, and they applied heuristic procedures in the inner iterations of a subgradient optimization to generate feasible solutions. The resulting algorithm had good convergence and improved the results of Ozsoy and Pınar (2006) in most cases. Concerning heuristic approaches, Scaparra et al. (2004) proposed a very large neigh- borhood search, relying on flow-based algorithms to efficiently detect improving neigh- bors, while Quevedo-Orozco and R´ıos-Mercado (2015) addressed the problem with an iterated greedy local search with variable neighborhood descent. We also mention the work of Espejo et al. (2015), who proposed a CPCP variant in which the maximum distance to the second-closest center is minimized. The problem is relevant in situations where the facilities can become unavailable because of unforeseen events such as natu- ral disaster or a labor strike. Mathematical formulations, heuristics, and preprocessing procedures were proposed and experimentally evaluated. 3 Mathematical Formulations and Decomposition Approach In this section, we provide two formulations for the CPCP and then describe the re- lationship between the CPCP and the capacitated set covering problem, which is the foundation of our search algorithms. We need some additional notation. Let D = [dij] define the cost matrix and r ∈ D denote a coverage radius. In our search algorithms, r 4 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. represents the maximum distance allowed for a customer-facility assignment. Moreover, the circular area having radius r and center in facility i is called the coverage area of i. Let C r i = {j ∈ C : dij ≤ r and qj ≤ Qi} be the set of customers lying in the coverage area of facility i induced by r, and F r j = {i ∈ F : dij ≤ r and qj ≤ Qi} be the set of facilities that can cover customer j within distance r. 3.1 Descriptive formulation Let yi be a binary variable taking value 1 if facility i ∈ F is open and 0 otherwise, and xij a binary variable stating whether or not customer j ∈ C is assigned to facility i ∈ F . Let z be a non-negative variable that keeps track of the maximum distance over all customer-facility assignments. The CPCP can be modeled with the following descriptive formulation: yi ≤ p s.t.Xi∈F Xi∈F z ≥Xi∈F Xj∈C qjxij ≤ Qiyi dijxij (CPCP-D) min z xij = 1 xij ∈ {0, 1} yi ∈ {0, 1} j ∈ C, j ∈ C, i ∈ F, i ∈ F, j ∈ C, i ∈ F. (1) (2) (3) (4) (5) (6) (7) Objective function (1) minimizes the maximum distance. Constraints (2) ensure that each customer is assigned to one facility. The total number of open facilities is limited to p by constraint (3). Constraints (4) force z to be greater than or equal to the distance from any customer to its assigned facility. Constraints (5) ensure that the sum of demands assigned to an open facility does not exceed its capacity, and constraints (6) and (7) provide the binary conditions. 3.2 Extended arc-flow formulation Arc-flow formulations model a problem by using a capacitated network of pseudo-poly- nomial size. Successful formulations of this type have been presented for a number of combinatorial optimization problems (see, e.g., the works on bin packing and cutting stock by Val´erio de Carvalho 2002 and Delorme et al. 2016), but, to the best of our knowledge, this is the first time they have been applied to the CPCP. To construct a 5 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. CPCP arc-flow formulation, first of all we associate with each i ∈ F an acyclic directed multigraph Gi = (Vi, Ai), with Vi = {0, 1, . . . , Qi} and Ai = {(e, f, j) : e, f ∈ Vi and j ∈ C ∪ {0}}. The vertices represent partial fillings of the facility capacity, whereas the arcs have a double meaning: customer arcs represent the assignment of a customer to a facility, whereas loss arcs represent the unused residual capacity of the facility. Formally, for any i ∈ F we partition Ai = ∪j∈C∪{0}Aij, where Ai0 = {(d, Qi, 0) : d ∈ Vi \ Qi} is the set of loss arcs, and Aij = {(d, d + qj, j) : d, d + qj ∈ Vi} are the sets of customer arcs for all j ∈ C. A valid assignment of customers to a facility corresponds to a path P ⊆ Gi containing one or more customer arcs and at most one loss arc. If arc (d, e, j) ∈ P, then either customer j ∈ C (with demand qj = e − d) is served by i, or a residual capacity of e − d (= Qi − d) units is unused. The aim of the arc-flow formulation is to open facilities and assign a path to each open facility by minimizing the maximum assignment distance and ensuring that all customers are served. Let A = ∪i∈F Ai be the set of all arcs, a be the index of a generic arc in A, δ+ ij (e) be the subset of arcs a ∈ Aij exiting from node e, and δ− ij (e) be the subset of arcs a ∈ Aij entering node e. Let faij be a binary variable that takes value 1 if arc a ∈ Aij is selected and 0 otherwise. The CPCP can be modeled as (CPCP-AF) min z s.t. (2)–(4), (6), (7), and Xj∈C Xa∈δ− ij (e) faij −Xj∈C Xa∈δ+ ij (e) −yi if e = 0 yi if e = Qi 0 otherwise faij =  Xe∈Vi Xa∈δ+ ij (e) i ∈ F, e ∈ Vi, faij = xij i ∈ F, j ∈ C, (8) (9) faij ∈ {0, 1} i ∈ F, j ∈ C, a ∈ Aij. (10) Constraints (8) impose the flow conservation at the nodes Vi for all the facilities. Constraints (9) ensure that the number of arcs associated with customer j in facility i is equal to xij (thus being either 1 or 0). Note that CPCP-AF is an extended formulation of CPCP-D, and practical CPCP-AF solutions may be obtained by replacing xij with ij (e) faij in constraints (2) and (4) and removing constraints (6) and (9). Pe∈ViPa∈δ+ This formulation provides good lower bounds. However, due to its pseudo-polynomial number of variables (O(QiC) for each i), it becomes impracticable for large instances. Hence, we introduce reduction techniques. First, one can use an upper bound r, i.e., a valid CPCP coverage radius, and remove the assignment variables associated with distances greater than r. Secondly, it is important to know which customers are served 6 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. by a facility, but not their sequence. Thus, one can sort the customers according to an arbitrary criterion and so reduce the number of arcs. Similarly to Val´erio de Carvalho (2002), for each facility i, we sort the customers in C r i by non-increasing qj value. Then, we build the arcs by considering this order (arcs associated with the first customer can only start at 0, arcs associated with the second customer can start either at 0 or right after the arcs of the first customer, and so on). This was done by a standard dynamic programming algorithm. 3.3 Decomposition Approach The objective function of the CPCP minimizes the maximum distance among the se- lected customer-facility assignments. The optimal solution value is therefore contained in the distance matrix D, and one can test with a search algorithm whether a solution value r is optimal. More precisely, testing whether the CPCP admits a solution with optimal value z ≤ r is equivalent to solving a feasibility test where all the capacity constraints are satisfied and only customer-facility assignments of distance dij ≤ r are used. On the basis of preliminary experimental analyses, we decided to transform this feasibility test into the problem of minimizing the number of selected facilities that cover all the customers while satisfying the capacity constraints. Formally, this corresponds to the following capacitated set covering problem (CSCP-r): yi (CSCP-r) minXi∈F xij ≥ 1 s.t.Xi∈F r Xj∈Cr qjxij ≤ Qiyi j i xij ∈ {0, 1} yi ∈ {0, 1} j ∈ C, i ∈ F, i ∈ F, j ∈ C r i , i ∈ F. (11) (12) (13) (14) (15) Objective function (11) minimizes the number of selected facilities. Constraints (12) ensure that each customer j ∈ C is assigned to at least one facility, whereas con- straints (13) impose capacity restrictions on all the facilities. Note that in constraints (12), we opted to replace the "=" (originally used in constraints (2)) with a "≥". This can be done without loss of optimality and allows us to develop improvement methods (given in Section 4 below). Clearly, a solution in which a customer is entirely assigned to more than one facility can be mapped to a solution with the same cost, in which such the customer is assigned to a single facility. Note that an extended arc-flow formulation for CSCP-r, denoted CSCP-AF-r, can also be obtained by replacing constraints (13) 7 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. with (8)–(10) and removing the assignment variables associated with distances dij > r. Based on this decomposition, the success of the approach now depends on two factors: 1) an efficient solution of each CSCP-r, and 2) an efficient search for the optimal value r ∈ D, with the smallest total computational effort. Note that the smallest computational effort is not necessarily proportional to the number of calls to the CSCP-r subproblems, since some subproblems are simpler to solve (e.g., when r is small) than others. In fact, there can be large differences in the computational effort required to either find a feasible solution or prove that no feasible solution exists for a given radius. To address these two challenges, the next two sections present techniques that improve the solution of the subproblems (Section 4) and search strategies to find the optimal coverage radius (Section 5). 4 Improvement Methods for the CSCP-r To ease the description, let ∆i(r) =Pj∈Cr qj be the sum of the demands of the customers located inside the coverage area defined by facility i and coverage radius r, and let Ki(r) = min{∆i(r), Qi} be an upper bound on the maximum demand that can be satisfied by facility i within radius r. i First, we report the classical inequalities used to improve the linear relaxation of the CSCP-r: xij ≤ yi i ∈ F, j ∈ C r i . (16) In addition, we use several techniques to improve the CSCP-r relaxation value and re- duce the number of nodes explored by the MILP branch-and-bound. To illustrate these techniques, we consider a small instance with five vertices, each representing both a cus- tomer and a candidate location for a facility (i.e., C = F ), with demands q = [3, 5, 4, 1, 1], capacities Q = [10, 15, 5, 15, 10], and positioned as illustrated in Figure 1 at the end of this section. The dij values are assumed to be proportional to the Euclidean distances in the figure. Facility domination inequalities. Let i1 and i2 be two facilities with C r i1 and Qi1 ≥ Ki2(r). Under these conditions, i1 can be preferred to i2 because it can serve a larger or equivalent set of customers. Consequently, an optimal solution that includes i2 but not i1 can always be transformed into an equivalent solution that includes i1 but not i2. We say that i1 dominates i2. We thus obtain the following result: i2 ⊆ C r Proposition 1. The following inequalities are valid for the CSCP-r: yi2 ≤ yi1 i1, i2 ∈ F : C r i2 ⊆ C r i1 and Qi1 ≥ Ki2(r). (17) 8 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Note that inequalities (17) do not forbid solutions in which both i1 and i2 are selected. In the example in Figure 1, facility 1 dominates facility 2, because it can serve the same customers of 2 and, in addition, customer 3. Forcing service inequalities. If ∆i(r) ≤ Qi for a given facility i and coverage radius r, then the capacity constraint associated with i becomes redundant. This means that whenever i is open, all the customers j ∈ C r Proposition 2. The following inequalities are valid for the CSCP-r: i can be served by it. Hence, we have: xij ≥ yi i ∈ F : ∆i(r) ≤ Qi, j ∈ C r i . (18) Note that the presence of two or more constraints (18) involving the same customer j is allowed in our model because of the "≥" in constraint (12). For the example in Figure 1, if facility 2 is open, then customers 1, 2, 4, and 5 are assigned to it. Surplus demand inequalities. Let ∆i(r) > Qi and S ⊂ C r whose total demand does not exceed the capacity of i. We obtain: i be a subset of customers Proposition 3. The following inequalities are valid for the CSCP-r: xik ≥ yi −(cid:18)Xj∈Cr i \S xij(cid:19) i ∈ F, S ⊂ C r i :Xj∈S qj ≤ Qi, k ∈ S. (19) Inequalities (19) generalize (18) because they force all customers k ∈ S to be served by i when i is open, and all customers j ∈ C r i \ S are served by a facility other than i. In the example of Figure 1, this inequality occurs for i = 1 and S = {1, 3, 5}, imposing customers 1, 3, and 5 to be assigned to facility 1 if x12 = x14 = 0 and y1 = 1. Symmetry breaking inequalities. Consider the case in which two customers j1 and j2, with identical demands, are located in the common coverage area of two facilities i1 and i2, and suppose j1 < j2 and i1 < i2. Then, one can forbid the assignment of j1 to i2 and of j2 to i1, since this would be equivalent to assigning j1 to i1 and j2 to i2. Consequently: Proposition 4. The following inequalities are valid for the CSCP-r i1, i2 ∈ F, j1, j2 ∈ C r i1 ∩ C r xi1,j2 + xi2,j1 ≤ 1 Inequalities (20) do not forbid the assignments of both customers to the same facility (or to neither i1 nor i2). In the example in Figure 1, the assignment of 4 to 2 and 5 to 1 is forbidden, but the equivalent assignment of 4 to 1 and 5 to 2 is still possible. Note that i2 : i1 < i2, j1 < j2, qj1 = qj2. (20) 9 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. these inequalities may be incompatible with (18) and (19), which might force an assign- ment instead of forbidding it. To avoid this issue, we simply remove from constraints (18) and (19) all inequalities containing a variable that also appears in an inequality of type (20). Capacity inequalities. Let S ⊆ C be a subset of customers and FS = Sj∈S Fj be the subset of facilities covering at least one customer in S. If all facilities in FS had the same capacity, say, Q, then a lower bound on the minimum number of facilities required to serve S could be imposed by adding Xk∈FS yk ≥(cid:24)Xj∈S qj/Q(cid:25) S ⊆ C. Following the work on the heterogeneous vehicle routing problem by Yaman (2006), these constraints can be extended to handle heterogeneous capacities using the next result: Proposition 5. The following inequalities are valid for the CSCP-r: Xk∈FS⌈Qk/γ⌉yk ≥(cid:24)Xj∈S qj/γ(cid:25) S ⊆ C, γ ∈ N. (21) In our implementation, we consider a facility i, select all subsets S containing 2 or 3 customers and lying entirely in the coverage area of i, then compute FS and impose γ = Qi in (21). The process is repeated for all i ∈ F . In Figure 1, the example for inequality (21) is obtained by setting S = {1, 2, 3}, FS = {1, 2, 3, 4, 5}, and γ = Q1. Subset sum inequalities. From Boschetti et al. (2002), the capacity of a facility i can potentially be decreased, while preserving optimality, by computing the maximal capacity usage through the solution of the following subset sum problem (SSP): Q′ i = max(cid:26)Xj∈Cr i ≤ Qi, the capacity constraints (5) can be improved to qjxij :Xj∈Cr i(cid:27). qjxij ≤ Qi, xij ∈ {0, 1} for j ∈ C r i i Since Q′ Xj∈Cr i qjxij ≤ Q′ iyi i ∈ F. (22) The same idea can be applied to increase the customers' demands. The demand of a customer k, when assigned to a facility i, can be increased by evaluating the maximal usage of the facility capacity through the solution of the SSP β1 ik = max(Pj∈Cr i \{k} qjxij :Pj∈Cr i \{k} qjxij ≤ Qi − qk, xij ∈ {0, 1} for j ∈ C r i \ {k}). 10 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. ik is lower than Qi−qk, then the unused capacity in i amounts to at least Qi−qk−β1 If β1 units, so qk can be increased to qk + Qi − qk − β1 Proposition 6. The following inequalities are valid for the CSCP-r: ik = Qi − β1 ik, leading to ik qjxij + (Qi − β1 ik)xik ≤ Qiyi i ∈ F, k ∈ C r i . (23) i \{k} Xj∈Cr These cuts have been used intensively in the cutting and packing literature. However, it is easy to find cases in which they do not provide any improvement with respect to the original capacity constraints (5). This is highlighted by the example in Figure 1, in which both (22) for facility 1, and (23) for facility 1 and customer 2 are equivalent to (5). This fact holds for all possible cuts in the example. The following inequalities provide, instead, a stronger improvement over (5). Disjunctive subset sum inequalities. As discussed earlier in this section, β1 sents the maximum possible use of capacity Qi when k is served by i. Now let β0 the maximum ik use when k is not served by i, namely: ik repre- ik be β0 ik = max(Xj∈Cr i \{k} qjxij :Xj∈Cr i \{k} qjxij ≤ Qi, xij ∈ {0, 1} for j ∈ C r i \ {k}). An extension of the subset sum inequalities (23) can be performed by embedding these β0 ik values in the trivial disjunctive cuts by Balas (1973) (in our case being xij ≤ 0∨xij ≥ 1 for i ∈ F, j ∈ C r Proposition 7. The following inequalities are valid for the CSCP-r: i ), as follows: qjxij ≤ β0 ikyi − (β0 ik − β1 ik)xik i ∈ F, k ∈ C r i . (24) i \{k} Xj∈Cr Proof. We wish to prove that inequalities (24) correspond to the disjunction qjxij ≤ β0 ikyi i \{k} Xj∈Cr ∨ Xj∈Cr qjxij ≤ β1 ikyi i ∈ F, j ∈ C r i . i \{k} We consider the two cases in which xik takes value 0 (left) or 1 (right). When xik = 0, constraints (24) directly reduce to qjxij ≤ β0 ikyi, i \{k} Xj∈Cr which is valid because all xij take value 0 when yi = 0 and because of the maximality of β0 ik. If xik = 1 instead, then yi must take value 1 too, and thus constraints (24) can 11 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. be rewritten as ik − β1 which is valid because of the maximality of β1 ik. qjxij ≤ β0 Xj∈Cr ikyi − (β0 i \{k} ik) ≤ β0 ikyi − (β0 ik − β1 ik)yi = β1 ikyi, The idea behind inequalities (24) is reminiscent of up-lifting and down-lifting in cut- ting plane theory. For instance, in a binary integer problem, a given inequality can be strengthened by considering the linear relaxation solution at a certain node of a branch- and-bound tree and taking into account the previously performed branches to 0 or 1 (see, e.g., Kaparis and Letchford 2008, and Vasilyev et al. 2016). In Figure 1, the inequality (24) applied to facility 1 and customer 2 leads to a stronger capacity constraint. Inequalities (24) are indeed more effective than the well-known inequalities (23) but also more specialized: the constraints (23) can be readily extended to integer x variables, whereas the constraints (24) hold only for binary x variables due to the nature of the disjunction. 2 1 3 4 5 Examples of Inequalities: (17) y2 ≤ y1 x21 ≥ y2 x11 ≥ y1 − (x12 + x14) x34 + x25 ≤ 1 y1 + 2y2 + 1y3 + 2y4 + y5 ≥ 2 3x11 + 5x12 + 4x13 + 1x14 + 1x15 ≤ 10y1 3x11 + 5x12 + 4x13 + 1x14 + 1x15 ≤ 10y1 3x11 + 4x12 + 4x13 + 1x14 + 1x15 ≤ 9y1 (18) (19) (20) (21) (22) (23) (24) Figure 1: Examples of valid inequalities for a small instance. Q =[10, 15, 5, 15, 10]; and q =[3, 5, 4, 1, 1]. Input data: F = C = {1, 2, 3, 4, 5}; 5 Searching for the Optimal Radius As presented in Section 3.3, an optimal CPCP solution can be found by iteratively solving a series of CSCP-r subproblems, each associated with a different distance. Let (z1, . . . , zD) be the distinct values from the distance matrix, in increasing order. Then, zk, for k ∈ {1, . . . , D}, is the optimal distance value if and only if there exists a fea- sible solution for the CSCP-r subproblem with r = zk, and either k = 1 or there is no feasible solution for r = zk−1. Apart from the trivial case where z1 is optimal, at least two subproblems, one feasible and one infeasible, have to be solved to prove op- timality, but more subproblems are usually solved because the optimal value is unknown. 12 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. 2 Binary and sequential search. The most straightforward approach to find the op- timal distance is to adopt a binary search over the vector (zilow, . . . , ziup), where zilow is an up- is a strict lower bound on the distance (known to be infeasible) and ziup per bound (known to be feasible). Iteratively, the subproblem obtained for zimid with imid = ⌊ ilow+iup ⌋ is solved. If the subproblem is feasible, then the next iteration is per- formed over (zilow, . . . , zimid), otherwise the search is performed over (zimid, . . . , ziup). The process terminates when iup = ilow + 1. This search strategy is guaranteed to take O(log D) = O(log(nm)) iterations. This is the best possible method in terms of number of search iterations. However, the two drawbacks of this approach are that it tends to overshoot the value of the optimal solution in the early steps of the search, and that it solves on average 50% of feasible and infeasible subproblems. In our context, the size of the mathematical formulation solved at each iteration grows quickly with z, because more variables and constraints have to be considered. Moreover, in our experiments it appeared to be more computationally expensive to solve a feasible problem (i.e., find a feasible CPCP solution) than an infeasible one (i.e., to prove infeasibility). In light of the previous observations, the second most natural strategy involves a sequential search, solving the subproblems in increasing order of z ∈ (zilow, . . . , ziup) and stopping as soon as a feasible solution is found. This strategy circumvents the two afore- mentioned issues, because it avoids large problems with z values that are greater than the optimum. It also requires the solution of only one feasible subproblem. However, its drawback is the high number of iterations, which rises to O(nm) and renders this approach slower for problems with many distinct distance values and a weak lower bound. Layered search. We thus propose an alternative search methodology, called L-Layered Search and described in Algorithm 1, which combines the benefits of both previous approaches. This method can be viewed as a recursive sequential search, starting with larger increments (when L > 1), and finishing with smaller ones (a classical sequential search when L = 1). At each step, the algorithm solves a sequence of subproblems with increasing distance bounds (lines 5–8), and then performs a recursive call with parameter L−1 on a smaller interval (lines 9–13). The algorithm is initially called with the function Layered Search(L, ilow, iup), and it terminates as soon as iup = ilow + 1 (line 1). The increment size of δ = ⌈(iup−ilow−1)(L−1)/L⌉ is chosen at each recursion (line 2) to attain good overall complexity and guarantee a small number of calls to feasible subproblems. Proposition 8. The number of feasible subproblems solved by Layered Search(L, ilow, iup) is in O(L). Proof. At each recursive call, at most one feasible subproblem is solved in the loop of lines 5–8, and L is decremented by one unit. Moreover, when L = 1 the behavior of the algorithm corresponds to a sequential search (because δ = 1 at step 2), and 13 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Algorithm 1: Layered Search(L, ilow, iup) 1 if iup = ilow + 1 then return ziup end if 2 δ ← ⌈(iup − ilow − 1)(L−1)/L⌉ 3 i ← ilow 4 isF easible ← False 5 while isF easible = False and i + δ < iup do i ← i + δ isF easible ← SolveCSCP-r(zi) 6 7 10 12 8 end 11 else 13 end 9 if isF easible = True then Layered Search(L − 1, i − δ, i) Layered Search(L − 1, i, iup) this necessarily leads to the termination criterion for L = 0, if that was not already attained. Proposition 9. The number of subproblems solved by Layered Search(L, ilow, iup) is in O(L(iup − ilow − 1)1/L). Proof. Let N = iup − ilow − 1 be the number of subproblems with unknown sta- tus within the range {ilow, . . . , iup}, and let T (L, N) be the complexity of Layered Search(L, ilow, iup) in terms of number of subproblem resolutions. The algorithm solves ⌈N (L−1)/L⌉ ≤ N 1/L subproblems, and then performs a recursive call on a smaller up to range, in which the number of subproblems with unknown feasibility status is reduced to ⌈N (L−1)/L⌉ − 1. Therefore, the following holds: N T (L, N) ≤ N N 1/L + T (L − 1,⌈N (L−1)/L⌉ − 1)  and T (L, N) ≤ LN 1/L follows by direct induction. if L = 1 if L > 1, The complexity of the three search strategies, in terms of total number of subproblem calls and number of calls to feasible subproblems, is summarized in Table 1. One can observe that the L-layered search constitutes an interesting alternative between sequen- tial and binary search, behaving as a sequential search when L = 1, and coming closer to a binary search (low number of subproblems overall, but no control on the number of feasible subproblems) as L grows larger. Typical values for L are in the range {2, . . . , 5}. 14 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Table 1: Complexity of search strategies (N = number of distinct values in the range to be searched) Sequential # overall subproblems O(N ) # feasible subproblems 1 3-Layers L-Layers 2-Layers Binary O(√N ) O(N 1/3) O(LN 1/L) O(log N ) O(log N ) 2 3 L Other speedup techniques. A complete solution of the CSCP-r subproblem is often unnecessary. To reduce the computational effort, we use three simple techniques: (i) we estimate the maximum demand that can be covered by each facility by looking at the customers in its coverage area, and then, if the sum of the p largest such values is lower than the total demand, we avoid solving the CSCP-r (since the subproblem is clearly infeasible); (ii) we terminate the solution of each CSCP-r whenever a valid lower bound greater than p is achieved (infeasible subproblem); (iii) we terminate the solution of the CSCP-r whenever a feasible solution opening at most p facilities is found (feasible subproblem). In addition, we obtain initial upper bounds on the optimal radius via the heuristic of Quevedo-Orozco and R´ıos-Mercado (2015), which is the current state-of-the-art meta- heuristic for the CPCP. However, as reported by the authors, this algorithm does not perform well on instances with a small n/p ratio. Thus, we also perform a simple iterated local search (ILS), possibly obtaining a better initial upper bound. Our simple ILS builds an initial solution by opening one facility at a time and as- signing customers as follows. Let ¯C be the set of unassigned customers. The facility i that realizes the minimum of maxj∈ ¯C dij/Qi is opened, and the closest customers in ¯C are assigned to i, iteratively, until the capacity constraints prevent further assignments. This process is repeated until a maximum of p facilities have been opened. If some customers remain unassigned, then they are assigned to their closest facility, possibly giving an infeasible initial solution. Subsequently, the method attempts to improve this solution with local search and perturbation steps. Let ¯Qi be the excess of capacity in facility i (either zero for a feasible solution, or strictly positive for an infeasible solution), and ¯dij = dij + M ¯Qi be the cost function associated with the assignment of customer j to facility i, where M is a large value. The ILS attempts to change the customer and facility associated with the largest ¯dij. Three types of moves are considered: Cust-Swap, Relocate, and Fac- Swap, invoked in this order. Cust-Swap exchanges two customers assigned to different facilities, Relocate attempts to move a customer from one facility to another, and Fac-Swap exchanges an open facility with a closed one. Finally, a strong perturbation operator is invoked once no improving move can be found. This perturbation randomly exchanges the open facilities with the closed ones (one exchange for each open facility). 15 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. The algorithm terminates after 300 executions of the local search and perturbation mechanism. This simplistic metaheuristic was able to produce a feasible solution for all the in- stances presented in Section 6.1, and it led to a better upper bound in 73 instances. The detailed results are provided on our webpage: http://www.or.unimore.it/site/ home/online-resources.html. 6 Computational Experiments We conducted extensive computational experiments to evaluate the performance of the proposed techniques. The algorithms were coded in C++ and executed on a single thread of an Intel Core i5-2410M 2.3GHz with 4GB of RAM, running under Linux Mint 17.2 64-bit. GUROBI 6.51 was adopted to solve the MILP models, using its default parameters. A time limit of 600 seconds was allowed for each run. 6.1 Benchmark instances We considered five sets of instances: four are from previous literature, and the fifth is a set of large instances that we created to better evaluate our methods. Following the literature, in all the test sets each vertex is both a customer and a candidate location for a facility (i.e., C = F ). • Set 1 (S1) – This set contains 160 instances proposed for the CPMP by Ceselli and Righini (2005) and derived from 40 different graphs containing either 50, 100, 150, or 200 vertices. This set includes and extends 20 instances from the OR-Library used in Scaparra et al. (2004). The demands and the coordinates of the vertices were randomly generated, and the distances were obtained by computing Euclidean values rounded down to the nearest integer. From each graph, four instances were produced by setting p equal to ⌊n/10⌋, ⌊n/4⌋, ⌊n/3⌋, or ⌊n/2.5⌋. The facility capacities are homogeneous and set to ⌈12n/p⌉. • Set 2 (S2) – This set contains eight instances by Scaparra et al. (2004), derived from two different graphs containing either 100 or 150 vertices and with non-Euclidean integer distances. From each graph, four instances with homogeneous capacities and four with heterogeneous capacities were created by selecting p ∈ {5, 15}. • Set 3 (S3) – Proposed by Lorena and Senne (2004) for the CPMP, this set contains six instances with n varying from 100 to 402 and p from 10 to 40, with homogeneous capacities equal to lPj qj/(τ p)m and τ ∈ {0.8, 0.9}. The distances are Euclidean. Albareda-Sambola et al. (2010) considered floating-point values, while Quevedo- Orozco and R´ıos-Mercado (2015) rounded down to the nearest integer. 16 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. • Set 4 (S4) – This set contains five instances by Lorena and Senne (2004), obtained by modifying the Pcb3038 instance of the TSPLIB, varying p in {600, 700, 800, 900, 1000}. The facility capacities are homogeneous and set to lPj qj/(τ p)m, with τ ∈ {0.8, 0.9}. • New set (KIV) – We generated 280 new instances that are similar to S1, but have ei- ther n ∈ {300, 500, 1000, 2000, 3000} and integer distances, or n ∈ {50, 100, 150, 200, 300, 500, 1000, 2000, 3000} and floating-point distances. As in S1, the demand val- ues were randomly generated within the interval [1, 20]. To obtain a customer density similar to that of Scaparra et al. (2004), we randomly generated the vertex coordinates in [1,√100n]. We created 20 instances for each value of n, dividing them into four groups of five instances each, with p equal to (cid:4) n 4(cid:5), or (cid:4) n 3(cid:5). These instances are available at http://www.or.unimore.it/site/home/ online-resources.html. 10(cid:5), (cid:4) n 7(cid:5), (cid:4) n 6.2 Evaluation of the solution techniques for the CSCP subproblem Our first experiment focused on the formulations and valid inequalities used to solve the CSCP subproblem. Recall that the subproblem seeks to minimize the number of facilities needed to cover the demands subject to a radius limit r, and that finding any lower bound greater than p, or a feasible solution using up to p facilities, immediately terminates the subproblem execution. For this experiment, we used S1 and considered r = BLB − 1, where BLB is the best known lower bound from the literature, collected from Quevedo-Orozco and R´ıos-Mercado (2015). Based on our computational experi- ments, we know that this BLB matches the optimal radius in 150 of the 160 instances. This choice of r is particularly relevant because the solution of the associated subproblem usually constitutes the last and hardest infeasible iteration. A formulation that produces good linear programming (LP) relaxation values in reasonable times is clearly preferable. Choice of the CSCP formulation. Table 2 presents the results of our first experiment, which compares the descriptive and arc-flow formulations (CSCP-r and CSCP-AF-r, respectively), with and without additional inequalities. Each row refers to a group of ten instances with the same n and p values. The left part of the table presents the results of the LP relaxations of the "plain" formulations, obtained by disregarding the inequalities of Section 4, namely, (11)–(15) for CSCP-r and (8)–(12), (14), (15) for CSCP-AF-r. The right part shows the results achieved by adding the inequalities (16)–(21) and (24) to the plain formulations, thus obtaining the "full" formulations. Column "LB" gives the average LP relaxation lower bound, "> p" reports the number of instances for which LB > p, "T(s)" gives the average CPU seconds required to solve 17 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. the LP models, and "gap(%)" is the percentage gap between the two LP relaxations (computed as 100 × (LBB − LBA)/LBA, where LBA and LBB are the LP bounds of CSCP-AF-r and CSCP-r, respectively). Table 2: Comparison of the linear relaxations of plain and full CSCP-AF-r and CSCP-r formulations. instance n 50 p # 5 10 100 10 10 150 15 10 200 20 10 50 12 10 100 25 10 150 37 10 200 50 10 50 16 10 100 33 10 150 50 10 200 66 10 50 20 10 100 40 10 150 60 10 200 80 10 avg/sum plain formulations (LP) full formulations (LP) CSCP-AF-r CSCP-r LB > p T(s) LB > p T(s) gap(%) CSCP-AF-r CSCP-r LB > p T(s) LB > p T(s) gap(%) 4.69 9.22 13.72 18.40 11.75 24.18 36.21 49.34 15.78 32.65 49.75 67.16 19.86 39.83 59.77 81.58 33.37 2 0 2.65 5.51 0 13.44 0 28.58 2 2 2 2 2 3 3 7 4 2 3 8 42 0.17 0.34 0.52 0.90 0.08 0.19 0.31 0.54 0.07 0.15 0.27 0.44 3.39 4.46 8.82 12.92 17.58 10.70 22.05 31.64 43.95 14.07 28.61 43.07 57.01 17.83 35.29 51.68 70.32 29.38 0 0.07 0 0.14 0 0.21 0 0.33 0 0.02 0 0.04 -4.90 -4.29 -5.83 -4.49 -9.00 -8.78 0 0.07 -12.61 0 0.11 -10.92 0 0.01 -10.82 0 0.03 -12.36 0 0.06 -13.42 0 0.10 -15.11 0 0.01 -10.24 0 0.03 -11.40 0 0.06 -13.53 0 0.09 -13.81 5.28 10.10 15.67 20.41 12.04 25.13 38.13 51.25 16.12 33.30 51.08 68.99 20.12 40.19 60.71 82.92 0 0.09 -10.10 34.46 109 8 3.77 5 12.61 7 25.94 7 59.14 6 6 10 9 6 4 9 9 6 4 5 8 0.51 1.15 1.91 3.36 0.30 0.66 0.97 1.55 0.36 0.63 0.96 1.86 7.23 5.28 10.10 15.67 20.41 12.00 25.05 37.95 51.02 16.03 32.88 50.50 68.16 19.58 39.07 58.72 80.30 33.92 8 0.44 5 1.50 7 3.18 7 7.75 6 0.16 5 0.29 10 0.43 8 0.82 5 0.15 4 0.24 6 0.36 8 0.61 1 0.27 2 0.33 3 0.56 7 0.93 92 1.13 0.00 0.00 0.00 -0.01 -0.32 -0.30 -0.46 -0.45 -0.54 -1.25 -1.13 -1.20 -2.69 -2.77 -3.28 -3.16 -1.10 From Table 2, we first observe that the plain CSCP-AF-r provides significantly better LP bounds than the plain CSCP-r. For 42 instances, infeasibility is proven by simply solving the plain CSCP-AF-r LP. The drawback of CSCP-AF-r is its higher CPU time consumption, especially on instances with large n/p ratio. The full CSCP-AF-r also provides better lower bounds than the full CSCP-r. However, the CSCP-r benefits more from the additional inequalities: the gap between the two bounds reduces from −10.10% to −1.10% when the additional inequalities are included. The full CSCP-r LP bound is sufficient to prove CPCP infeasibility for 92 instances, compared to 109 instances for the full CSCP-AF-r. However, solving the full CSCP-AF-r LP requires six times the CPU effort required by the full CSCP-r LP. Given the similar performance of the two full formulations, but their significant difference in terms of time, we decided to invoke the CSCP-r at each iteration of our search algorithms. Impact of the valid inequalities. Our second experiment, reported in Table 3, ana- lyzes in detail the impact of the inequalities from Section 4. In the left part of the table, column "LB" provides the average LP relaxation value of the plain CSCP-r. Each succes- sive column under the label "gap(%)" reports the gap between LB and the LP relaxation 18 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. value of the plain CSCP-r after the inclusion of the indicated inequality. Similarly, each column in the right part of the table shows the gap(%) from the average LP relaxation value of the full CSCP-r when removing the indicated inequality. From Table 3, we ob- serve that the addition of inequalities (19) to the plain CSCP-r does not improve the LP bound, but their removal from the full formulation decreases the LP bound, even if only slightly. All the other inequalities have a visible impact on the LB when added to the plain formulation or removed from the full formulation. The well-known inequalities (16) are essential for the quality of the LB, as are the new disjunctive subset sum inequalities (24). Inequalities (19), (21), and (24) have a larger impact on instances with small n/p values, while inequalities (16) contribute more on instances with large n/p values. Table 3: Impact of valid inequalities on linear relaxation of CSCP-r formulation. plain CSCP-r (LP) gap(%) full CSCP-r (LP) gap(%) LB +(16) +(19)a +(19)b +(21)a +(21)b +(24) 2.47 4.46 18.50 0.00 0.00 0.00 0.00 LB −(16) −(19)c −(19)d −(21)c −(21)d −(24) -0.03 5.28 -7.20 0.00 0.00 0.00 0.00 instance n p # 50 5 10 100 10 10 8.82 14.46 150 15 10 12.92 21.25 200 20 10 17.58 16.00 50 12 10 10.70 10.01 100 25 10 22.05 10.13 150 37 10 31.64 15.65 200 50 10 43.95 11.93 50 16 10 14.07 10.22 100 33 10 28.61 10.81 150 50 10 43.07 10.81 200 66 10 57.01 12.11 50 20 10 17.83 4.23 100 40 10 35.29 4.48 150 60 10 51.68 7.00 200 80 10 70.32 7.07 average - 11.54 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.49 0.35 0.61 0.97 1.35 1.81 2.21 2.66 1.70 2.06 2.41 3.02 1.23 0.00 0.00 0.00 0.90 1.84 2.24 1.85 1.42 2.43 3.19 3.74 2.00 2.65 3.21 3.31 1.80 3.99 5.98 3.61 5.47 5.49 8.13 6.41 6.15 6.85 7.06 8.33 6.21 6.24 6.61 7.12 6.01 10.10 -4.91 -0.01 15.67 -7.09 -0.01 20.41 -5.81 0.00 12.00 -1.09 -0.04 25.05 -1.12 -0.01 37.95 -2.04 -0.02 51.02 -1.57 -0.02 16.03 -0.21 -0.03 32.88 -0.64 -0.04 50.50 -0.59 -0.06 68.16 -0.57 -0.06 19.58 -0.06 -0.04 39.07 -0.15 -0.06 58.72 -0.13 -0.13 80.30 -0.21 -0.10 - -2.09 -0.04 -0.01 -0.01 0.00 -0.05 -0.03 -0.03 -0.04 -0.03 -0.08 -0.07 -0.10 -0.18 -0.14 -0.17 -0.18 -0.07 0.00 0.00 0.00 -0.48 -1.90 -2.20 -1.92 -1.31 -1.34 -2.14 -2.34 -0.86 -1.01 -1.26 -1.27 -1.13 0.00 0.00 0.00 -0.02 -0.04 -0.06 -0.48 -0.91 -1.90 -0.56 -2.20 -0.64 -1.92 -0.88 -1.43 -1.27 -1.40 -1.43 -2.22 -2.06 -2.43 -1.83 -0.94 -3.08 -1.27 -3.06 -1.49 -2.84 -1.56 -3.07 -1.20 -1.36 a S ∈ {1, 2}. b S ∈ {1, 2, 3}. c S ∈ {2, 3}. d S ∈ {1, 2, 3}. Impact of the symmetry-breaking inequalities. The impact of inequalities (17), (18), and (20) is not shown in Table 3, because they do not enhance the linear relaxation but rather help to reduce the search space. We thus evaluated their impact by computing the number of nodes explored in the subproblems. For this experiment, we selected the instances from S1 that were not proved to be infeasible after the solution of the LP relaxation of the full CSCP-r (68 instances in total) and solved them with our models, terminating upon proven infeasibility or when a time limit of 600 seconds was reached. Table 4 reports the average number of nodes explored by GUROBI when solving the 19 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. plain and full CSCP-r formulations (columns 4 and 8, respectively); the formulations obtained by adding inequalities (17), (18), or (20) one at a time to the plain CSCP-r (columns 5–7); and the formulations obtained by removing these inequalities one at a time from the full CSCP-r (columns 9–11). We observe a significant decrease in the number of nodes explored when using the full CPCP-r instead of the plain version. The contribution of the three inequalities is not always relevant when they are added one at a time to the plain formulation. One instance in particular (with n=100 and p=25) could not be proven infeasible within the time limit, either by the plain CSCP-r or by adding (18). However, the number of nodes explored increased significantly with the use of inequalities (18). Their removal from the full formulation is detrimental, since it significantly increases the number of nodes explored. Table 4: Number of nodes explored to prove infeasibility with CSCP-r formulations instance explored nodes plain 22.00 4,024.20 +(17) 10.00 607.60 +(18) 64.50 +(20) 52.00 full 1.00 explored nodes −(17) 1.00 −(18) 1.00 −(20) 1.00 191.60 1,737.80 3,402.40 310.00 244.20 305.20 17,512.33 4,820.33 10,270.00 9,460.33 1,482.00 9,927.00 1,648.67 1,299.00 3,891.00 1,071.00 4,100.67 2,656.00 285.33 200.33 996.50 112.00 759.25 126.00 1.00 1.75 89.33 1.00 1.00 1.00 46,141.80 12,563.00 111,176.80 33,091.60 6,017.00 28,510.40 19,308.80 11,141.80 - 1.00 1,706.00 625.00 - 1.00 205.20 637.33 - 1.00 - 1.00 2,237.20 3,183.40 695.50 494.50 - 1.00 1.00 1.00 2,110.25 1,002.50 2,832.00 3,606.50 144.50 420.50 521.00 263.50 266.00 1.00 2,515.78 2,767.89 2,000.67 1,375.11 155.44 1,637.63 691.71 380.67 397.75 342.43 384.00 340.25 410.14 365.67 1,834.88 670.71 363.00 10.88 87.00 1.00 - 1.00 3.20 18.83 162.00 1.00 71.67 107.25 90.00 1.00 - 1.00 1.00 1.00 - 1.00 1.00 1.00 138.00 376.00 1.00 1.00 474.56 138.56 19.00 85.00 1.00 65.50 85.57 1.00 n 50 100 150 200 50 100 150 200 50 100 150 200 50 100 150 200 p # 5 10 15 20 12 25 37 50 16 33 50 66 20 40 60 80 2 5 3 3 4 5 0 2 5 6 4 2 9 8 7 3 average 5,511.76 1,696.20 9,150.33 4,038.90 566.61 2,622.71 1,471.70 887.07 6.3 Performance of the search algorithms for the CPCP Based on the results of Section 6.2, we decided to integrate the full CSCP-r, composed of (11)–(21) and (24), into the search algorithms presented in Section 5. We now evaluate the performance of the resulting search approaches for the CPCP. We set the initial search interval for the radius r to [0, UBbest], where UBbest is the best upper bound found by the heuristic of Quevedo-Orozco and R´ıos-Mercado (2015) and by the ILS that we described at the end of Section 5. Table 5 compares the results obtained by the proposed algorithms with those of recent state-of-the-art heuristic and exact approaches, on the classical instances from the literature, namely: 20 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. SPS – the multi-exchange neighborhood search algorithm of Scaparra et al. (2004); OP – the binary search of Ozsoy and Pınar (2006) that solves plain CSCP models at each iteration; ADF – the Lagrangian relaxation method of Albareda-Sambola et al. (2010); QR – the iterated greedy local search metaheuristic of Quevedo-Orozco and R´ıos- Mercado (2015), including supplementary results available from a personal communication. For our search algorithms, we tested sequential search (SS), L-layered search with L=2, 3, or 4 (L2, L3, L4), and binary search (BS). Each row in the table reports the results for a subset of instances. For each algorithm and subset, we report the number of proven optimal solutions "#opt", the average gap "gap(%)", and the average computing time in seconds "T(s)". For the exact algorithms (all but SPS and QR), gap(%) is evaluated as 100 · (UB − LB)/UB, where UB and LB are the upper and lower bounds produced by the given algorithm, and #opt is the number of times for which LB=UB. For the heuristics (SPS and QR), gap(%) and #opt are computed by considering the best known LB values. The results for SPS, OP, ADF, and QR were taken from Quevedo-Orozco and R´ıos-Mercado (2015), who ran the algorithms on a 2.0GHz AMD Opteron processor with 32GB of RAM. As they did not solve the S3 instances with float distances, the ADF results for these instances were collected from Albareda-Sambola et al. (2010), who used a 2.39GHz Intel Pentium 4 processor with 512MB of RAM. From Table 5, we can observe that the results of SS, L2, L3, L4, and BS on the set S1 are better than those of the previous literature for the majority of the instances. The ten instances with n = 200 and p = 20 are solved to optimality only by OP, SS, and L3, while those with n = 200 and p = 50 are solved only by SS. Instances from S2 and S3-int are solved by all the exact methods. Of the six instances from S3-float, five are solved to proven optimality by L2, L3, L4 and BS, whereas SS can solve only two. The five instances from S4, which involve more than 3000 vertices, are not solved to proven optimality by any of the algorithms. This is also the only set for which the average gap of our L-layered search algorithms is large, although it is still smaller than that of SPS, ADF, and QR (that for OP is not computed because the memory exceeded the limit imposed by the authors, and no upper bound could be found). The average CPU time of SS, L2, L3, L4, and BS is smaller than that of OP and ADF, due to more generous time limits for the latter approaches. Despite this difference, SS, L2, L3, L4, and BS are all able to produce better results. Between them, our five algorithms were able prove optimality for 179 of the 185 benchmark instances, including 13 open cases. 21 Table 5: Evaluation of existing (SPS, OP, ADF, QR) and new (SS, L2, L3, L4, BS) exact CPCP algorithms on classical benchmark sets. instance #opt gap(%) T(s) set n p # SPS OP ADF QR SS L2 L3 L4 BS SPS OP ADF QR SS L2 L3 L4 BS SPS OP ADF QR 1.2 2.4 2.8 1.9 2.9 5.5 1.4 9.7 21.3 82.8 86.5 1103.1 0.2 0.4 0.6 0.7 SS 0.8 0.9 0.7 2.6 L2 1.2 1.4 0.8 4.8 L3 0.9 1.5 1.4 4.8 L4 0.7 1.1 1.3 3.9 BS 0.4 1.7 0.9 2.9 9.5 62.4 59.4 0.6 4.0 6.8 6.4 4.8 4.2 9.7 423.4 975.6 1.4 29.1 22.1 26.0 35.0 35.1 15.6 377.6 1380.4 30.8 191.0 2021.3 2.1 2.4 4.7 3.4 8.4 3.8 9.9 6.6 8.3 8.7 6.8 5.8 26.6 154.4 165.1 1.0 11.2 16.7 30.0 30.7 14.4 46.9 386.0 532.5 34.6 560.9 1834.6 51.5 914.8 1908.3 2.6 5.5 7.2 6.5 16.1 34.1 37.6 12.4 1.9 4.7 6.0 10.8 4.0 4.8 10.1 12.3 22.8 11.6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.50 1.88 63.6 237.5 625.9 1.6 31.6 75.6 66.8 72.5 68.4 4.62 4.00 1.00 2.50 46.8 1145.3 2469.8 6.5 107.3 110.5 158.9 186.0 163.1 0 0 0 0 0 0 0 0 0 4.74 0 0 0 0 0 0 55.3 846.2 2163.5 9.8 9.3 45.9 26.4 34.1 27.9 94.4 560.3 1800.6 11.9 36.9 33.6 69.6 69.0 64.1 27.3 152.7 219.4 0.8 51.9 64.0 99.3 57.6 72.0 285.4 319.3 256.6 2.4 143.4 65.6 84.5 61.5 57.1 M a t h e m a t i c a l m o d e l s a n d s e a r c h a l g o r i t h m s f o r t h e C P C P K r a m e r , R . ; I o r i , M . ; i V d a l , T . S1 50 5 10 12 10 16 10 20 10 100 10 10 25 10 33 10 40 10 2 2 150 15 10 37 10 50 10 60 10 200 20 10 50 10 66 10 80 10 S2 S3-int S3-float S4 8 6 6 5 7 2 3 2 0 1 0 1 0 0 0 0 0 0 0 0 0 0 – 0 10 10 10 10 10 9 9 10 10 9 9 9 10 6 9 7 8 6 – 0 10 10 8 10 8 7 6 10 9 7 6 9 4 4 5 8 6 4 0 3 2 0 8 3 2 0 4 0 0 0 3 0 0 0 1 0 – 0 10 10 10 10 10 10 10 1.88 10 10 10 10 10 5.39 10 10 10 10 10 2.87 10 10 10 10 10 3.59 10 10 10 10 10 8.01 0 0 0 0 0 0 0 0 0 6.64 8.97 2.14 21.28 0 1.30 10 10 10 10 10 12.97 1.33 3.21 9.08 10 10 10 10 10 10.34 1.67 2.32 9.46 10 10 10 10 10 9.89 10 10 10 10 10 13.74 0 0 3.93 35.82 0 3.54 10 10 10 10 10 18.14 1.67 0.83 12.31 10 10 10 10 10 16.1 1.67 3.50 22.84 10 10 10 10 10 16.2 3.57 4.21 38.47 10 10 9 9 10 8 9 9 9 9 18.8 0 0.67 5.26 21.08 4.22 11.20 22.24 10 10 10 10 10 23.13 2.22 8.76 31.23 10 23.91 7.17 9.05 36.53 10 10 10 8 6 2 0 8 6 5 0 8 6 5 0 9 8 6 5 0 8 6 5 0 6.21 23.96 – 0 0 – 0 0 3.25 3.57 0 0 0 0 0 0 0 0 0 0 0 0 1.25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 avg/sum 185 16 161 141 36 176 177 177 176 177 16.41 1.31 5.57 17.10 4.29 1.72 0.97 1.01 0.95 141.3 343.1 2020.6 21.5 80.3 66.7 71.8 69.8 65.1 0.55 – 23.38 0.18 0.04 0.02 0.00 – – 1201.5 – 555.5 242.6 190.2 150.1 150.0 75.61 – 60.94 53.14 62.38 28.28 15.35 11.95 14.6 1877.6 – 21600.0 350.4 600.0 600.0 600.0 600.0 600.0 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Overall, it seems that SS performs especially well for small instances with integer distances, while BS behaves better on large instances with floating-point distances. The L-layered search algorithms have a performance that is quite close to the best results on both types of instances. This analysis, however, is restricted because of the limited variety of the existing instances, with few test cases involving large and/or floating-point distances. To fill this experimental gap, we conducted additional experiments on the new KIV test set, reported in Tables 6 and 7, with either integer or floating point distances. These two tables have the same format as Table 5. Table 6: Performance of search algorithms on KIV instances – integer distances. instance #opt gap(%) T(s) n 300 500 1000 2000 3000 p # SS L2 L3 L4 BS 30 42 75 100 50 71 125 166 100 142 250 333 200 285 500 666 300 428 750 1000 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 3 5 5 3 3 3 4 1 0 2 1 0 0 3 4 0 0 2 4 5 3 5 5 3 3 3 3 1 0 2 1 0 0 3 4 0 0 1 4 5 3 5 5 3 3 3 2 0 0 2 1 0 0 3 4 0 0 0 2 4 3 5 5 3 3 3 4 0 0 2 1 0 0 3 4 0 0 2 4 5 3 5 5 3 3 3 4 0 0 2 1 0 0 1 1 0 0 0 4 SS 0.00 8.83 0.00 0.00 4.63 L2 0.00 6.00 0.00 0.00 8.20 L3 0.00 2.22 0.00 0.00 5.17 L4 0.00 3.33 0.00 0.00 BS 4.17 4.44 0.00 0.00 SS L2 L3 L4 BS 149.85 115.83 160.70 131.49 244.88 266.02 265.96 272.29 278.29 248.85 64.81 35.48 44.22 25.93 114.55 7.81 7.31 8.40 10.54 8.99 6.45 10.80 384.85 324.63 297.72 294.51 268.99 8.00 14.00 10.00 2.35 2.35 291.11 260.54 294.79 271.94 287.95 17.62 6.42 4.29 5.33 22.09 274.87 257.56 270.51 277.59 264.58 10.00 16.50 18.75 2.86 19.17 315.53 360.84 378.13 299.34 343.37 19.06 5.00 19.33 17.91 14.61 520.71 598.12 600.00 600.00 600.00 29.12 42.41 41.82 11.11 11.50 600.00 600.00 600.00 600.00 600.00 29.17 17.51 9.11 8.19 57.56 408.05 423.35 449.11 433.46 410.31 44.05 16.00 20.29 31.29 7.69 490.49 491.41 500.35 538.24 497.69 31.24 38.88 35.06 54.16 45.04 600.00 600.00 600.00 600.00 600.00 38.69 40.36 65.04 54.22 34.60 600.00 600.00 600.00 600.00 600.00 22.54 11.72 8.00 4.00 7.79 38.46 1.54 51.59 3.08 8.00 421.82 443.65 505.54 596.94 419.01 243.88 243.29 308.17 539.54 236.96 33.77 41.13 47.45 54.42 45.58 600.00 600.00 600.00 600.00 600.00 42.78 54.88 65.40 54.11 45.09 600.00 600.00 600.00 600.00 600.00 35.04 12.00 12.82 70.83 10.97 566.33 583.55 600.00 600.00 567.66 12.14 5.33 13.50 5.00 8.57 340.07 350.55 575.66 305.95 383.53 avg/sum 100 48 46 41 46 40 19.92 16.83 18.98 23.58 17.77 387.31 388.10 413.28 410.19 394.87 As can be observed in Table 6, SS solves the largest number of instances with integer distances. However, the best average gap is attained by L2. This is because SS cannot improve the upper bound if it is unable to prove optimality. Moreover, BS may spend a significant time solving one or more feasible iterations with an overestimated value of r, obtaining a worse overall #opt value. The layered searches constitute an alternative between SS and BS: progressing faster than a sequential search toward the optimal solution, and avoiding CSCP-r subproblems with large r. In terms of CPU time, the global average of each method is similar, because these values are strongly influenced by the time spent on the largest instances, where the time limit is usually reached. Still, significant effects can be observed on some subgroups of instances. For small and medium instances especially, the layered and binary searches usually prove optimality 23 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Table 7: Performance of search algorithms on KIV instances – floating-point distances. instance #opt gap(%) p # SS L2 L3 L4 BS SS L2 L3 L4 BS n 50 100 150 200 300 500 1000 2000 3000 5 7 12 16 10 14 25 33 15 21 37 50 20 28 50 66 30 42 75 100 50 71 125 166 100 142 250 333 200 285 500 666 300 428 750 1000 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 4 4 5 5 4 4 2 0 1 4 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 5 4 5 5 4 4 4 5 5 4 4 2 1 1 4 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 5 4 5 5 4 4 4 4 5 5 4 2 0 1 4 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 5 4 5 5 5 5 4 5 5 5 4 3 1 1 4 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 3 5 5 5 4 5 5 5 4 4 4 5 4 4 2 0 1 4 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 27.12 0.00 0.00 0.00 0.00 0.00 SS 5.32 6.10 1.28 0.60 L2 1.28 2.07 0.60 0.33 T(s) L3 1.05 2.34 0.90 0.34 L4 1.39 1.42 0.55 0.37 BS 0.99 1.30 1.07 0.29 0.00 0.00 0.00 0.00 0.00 30.17 17.19 13.49 15.93 14.83 0.00 0.00 0.00 0.00 0.00 15.60 10.25 8.58 15.35 10.46 6.24 1.06 0.61 0.14 0.57 158.07 220.95 166.26 166.96 167.92 0.00 0.00 0.00 0.00 0.00 42.58 48.79 70.50 31.30 36.28 0.00 0.00 0.00 0.00 0.00 32.23 13.05 21.64 20.45 12.58 0.00 1.17 0.10 0.00 0.00 166.67 172.82 185.70 77.61 126.11 5.58 0.05 0.15 0.00 0.05 237.82 247.20 260.61 225.36 211.39 5.24 0.30 2.88 0.62 0.87 156.58 153.83 159.03 145.42 146.85 0.00 0.00 0.29 0.00 0.20 169.19 87.50 166.74 169.80 184.77 0.00 0.00 0.00 0.00 0.00 71.36 49.19 41.97 29.46 49.32 5.96 0.75 0.00 0.00 0.10 245.93 282.82 116.00 210.95 226.99 4.40 5.43 0.52 1.34 0.88 173.39 180.51 168.94 161.10 233.10 11.80 4.42 2.88 0.89 6.92 487.59 507.61 475.35 416.42 476.94 23.23 12.98 10.62 13.67 22.82 600.00 598.77 600.00 565.02 600.00 23.69 9.26 17.61 22.68 5.46 516.02 525.55 575.60 503.92 581.75 5.56 0.23 1.14 0.80 0.17 192.91 155.79 166.97 159.29 172.72 22.88 14.82 5.14 10.05 7.38 543.02 580.47 532.92 600.00 572.86 29.64 8.72 13.79 14.45 59.70 600.00 600.00 600.00 600.00 600.00 27.70 25.62 7.18 9.96 24.39 511.39 506.27 506.38 496.78 499.03 40.21 5.54 9.43 11.40 7.00 600.00 600.00 600.00 600.00 600.00 35.97 36.54 21.06 47.28 80.13 600.00 600.00 600.00 600.00 600.00 40.32 42.06 35.28 24.33 63.46 600.00 600.00 600.00 600.00 600.00 42.90 6.92 11.25 20.89 15.99 600.00 600.00 600.00 600.00 600.00 46.24 23.99 38.65 22.89 12.21 600.00 600.00 600.00 600.00 600.00 45.23 41.22 49.48 55.55 96.77 600.00 600.00 600.00 600.00 600.00 49.21 48.07 30.01 35.97 70.28 600.00 600.00 600.00 600.00 600.00 47.16 15.84 34.96 12.70 16.99 600.00 600.00 600.00 600.00 600.00 50.10 16.19 18.53 17.62 12.34 600.00 600.00 600.00 600.00 600.00 49.90 41.54 49.74 55.26 96.77 600.00 600.00 600.00 600.00 600.00 54.59 48.37 48.06 54.74 96.48 600.00 600.00 600.00 600.00 600.00 57.42 35.11 35.93 22.29 16.21 600.00 600.00 600.00 600.00 600.00 58.55 8.96 9.89 9.77 9.23 600.00 600.00 600.00 600.00 600.00 avg/sum 180 84 84 83 87 81 21.94 12.64 12.64 12.92 20.85 354.55 354.52 351.12 344.86 353.50 24 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. more quickly, because of their reduced number of subproblem iterations. The results of Table 7, in the presence of floating-point distances, complete the anal- ysis with a different perspective. In this case, the layered searches lead to better results in terms of proven optimal solutions (L4), average gaps (L2 and L3), and time (L4). This is because the number of iterations required by the sequential search is very large in comparison to the other algorithms, and the speedup related to the solution of small subproblems is not sufficient to counterbalance the number of iterations. BS is not a good option either, since it fails to find the optimal solution on a few small instances (e.g., (n, p) = (50, 12)) or leads to large gaps (e.g., (n, p) = (1000, 100) or (2000, 200)) because of large overestimates of r. The layered searches have much more stable performance, with smaller gaps in the wide majority of cases. 7 Conclusions In this paper, we have presented and evaluated different formulations and search algo- rithms for the capacitated p-center problem. We have proposed valid inequalities and symmetry-breaking constraints, as well as an alternative layered search strategy for the distance bound which behaves in between the traditional sequential search and binary search. Our combination of these techniques solved to proven optimality, for the first time, all the instances from the literature with n ≤ 402 and integer distances, including 13 open cases. The inequalities, especially the disjunctive-based subset sum inequality, helped to improve the lower bound and to reduce the number of nodes explored. The layered search effectively limits the number of feasible subproblems and avoids large over- estimates of the distance. It appears to be especially useful for instances with a large number of distinct distance values, a typical situation in the presence of floating-point distances, where both sequential search and binary search become inefficient. To stimulate future research, we have also introduced a new set of larger instances, ranging from 300 to 3000 nodes, with integer or floating-point distances. This set of in- stances is currently at the frontier of the solution capabilities of exact methods. Future research could focus on exact decomposition methods for the solution of the arc-flow formulation, which has been shown to lead to higher-quality bounds despite its high time consumption, or on the development of additional cutting planes and heuristic call- back procedures. Since many applications arising from the machine-learning literature involve problems with thousands or even millions of data points, we also recommend the investigation of aggregation and dominance techniques, to achieve smaller gaps for very large instances. 25 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Acknowledgments This research was partially supported by Conselho Nacional de Desenvolvimento Cient´ıfico e Tecnol´ogico (CNPq/Brazil) under Grant GDE 201222/2014-0, by Coor- dena¸cao de Aperfei¸coamento de Pessoal de N´ıvel Superior (CAPES/Brazil) under Grant PVE n. A007/2013, and MIUR/Italy under grant PRIN 2015. References Albareda-Sambola, M., D´ıaz, J. and Fern´andez, E. (2010), Lagrangean duals and ex- act solution to the capacitated p-center problem. European Journal of Operational Research, v. 201, n. 1, p. 71–81. Balas, E. (1973), Disjunctive programming. Annals of Discrete Mathematics, v. 5, p. 3–51. Boccia, M., Sforza, A., Sterle, C. and Vasilyev, I. (2008), A cut and branch approach for the capacitated p-median problem based on Fenchel cutting planes. Journal of Mathematical Modelling and Algorithms, v. 7, n. 1, p. 43–58. Boschetti, M., Hadjconstantinou, E. and Mingozzi, A. (2002), New upper bounds for the two-dimensional orthogonal non-guillotine cutting stock problem. IMA Journal of Management Mathematics, v. 13, n. 2, p. 95–119. Boyd, E. (1993), Generating Fenchel cutting planes for knapsack polyhedra. SIAM Journal on Optimization, v. 3, n. 4, p. 734–750. Boyd, E. (1994), Fenchel cutting planes for integer programs. Operations Research, v. 42, n. 1, p. 53–64. Calik, H. and Tansel, B. (2013), Double bound method for solving the p-center location problem. Computers & Operations Research, v. 40, n. 12, p. 2991–2999. Ceselli, A. and Righini, G. (2005), A branch-and-price algorithm for the capacitated p-median problem. Networks, v. 45, n. 3, p. 125–142. Chen, D. and Chen, R. (2009), New relaxation-based algorithms for the optimal solution of the continuous and discrete p-center problems. Computers & Operations Research, v. 36, n. 5, p. 1646–1655. Daskin, M. Network and Discrete Location: Models, Algorithms, and Applications. Wiley, New York, 1995. 26 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Daskin, M. (2000), A new approach to solving the vertex p-center problem to optimality: Algorithm and computational results. Communications of the Operations Research Society of Japan, v. 45, n. 9, p. 428–436. Davidovi´c, T., Ramljak, D., Selmi´c, M. and Teodorovi´c, D. (2011), Bee colony optimiza- tion for the p-center problem. Computers & Operations Research, v. 38, n. 10, p. 1367–1376. Davoodi, M., Mohades, A. and Rezaei, J. (2011), Solving the constrained p-center prob- lem using heuristic algorithms. Applied Soft Computing, v. 11, n. 4, p. 3321–3328. Delorme, M., Iori, M. and Martello, S. (2016), Bin packing and cutting stock problems: Mathematical models and exact algorithms. European Journal of Operational Research, v. 255, n. 1, p. 1–20. Drezner, Z. and Hamacher, H. (Eds.). Facility Location: Applications and Theory. Springer, 2002. Elloumi, S., Labb´e, M. and Pochet, Y. (2004), A new formulation and resolution method for the p-center problem. INFORMS Journal on Computing, v. 16, n. 1, p. 84–94. Espejo, I., Mar´ın, A. and Rodr´ıguez-Ch´ıa, A. (2015), Capacitated p-center problem with failure foresight. European Journal of Operational Research, v. 247, n. 1, p. 229–244. Fast, C. and Hicks, I. (2017), A branch decomposition algorithm for the p-median prob- lem. INFORMS Journal on Computing, v. 29, n. 3, p. 474–488. Garc´ıa, S., Labb´e, M. and Mar´ın, A. (2011), Solving large p-median problems with a radius formulation. INFORMS Journal on Computing, v. 23, n. 4, p. 546–556. Hakimi, S. (1964), Optimum locations of switching centers and the absolute centers and medians of a graph. Operations Research, v. 12, n. 3, p. 450–459. Hochbaum, D. and Shmoys, D. (1985), A best possible heuristic for the k-center problem. Mathematics of Operations Research, v. 10, n. 2, p. 180–184. Ilhan, T., Ozsoy, F. and Pınar, M. An efficient exact algorithm for the vertex p-center problem and computational experiments for different set covering subproblems. Tech- nical report, Optimization-Online. Available at http://www.optimization-online. org/DB_HTML/2002/12/588.html, 2002. Irawan, C., Salhi, S. and Drezner, Z. (2015), Hybrid meta-heuristics with VNS and exact methods: Application to large unconditional and conditional vertex p-centre problems. Journal of Heuristics, v. 22, n. 4, p. 507–537. 27 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Jaeger, M. and Goldberg, J. (1994), Technical note–a polynomial algorithm for the equal capacity p-center problem on trees. Transportation Science, v. 28, n. 2, p. 167–175. Kaparis, K. and Letchford, A. (2008), Local and global lifted cover inequalities for the 0-1 multidimensional knapsack problem. European Journal of Operational Research, v. 186, n. 1, p. 91–103. Kariv, O. and Hakimi, S. (1979), An algorithmic approach to network location problems. I: The p-centers. SIAM Journal on Applied Mathematics, v. 37, n. 3, p. 513–538. Laporte, G., Nickel, S. and Saldanha da Gama, F. (Eds.). Location Science. Springer, 2015. Lorena, L. and Senne, E. (2004), A column generation approach to capacitated p-median problems. Computers & Operations Research, v. 31, n. 6, p. 863–876. Marianov, V. and ReVelle, C. Facility Location: A Survey of Applications and Methods. Springer-Verlag, New York, 1995. Masuyama, S., Ibaraki, T. and Hasegawa, T. (1981), The computational complexity of the m-center problems on the plane. Transactions of the IECE of Japan, v. E64, p. 57–64. Mihelic, J. and Robic, B. Approximation algorithms for the k-center problem: An experimental evaluation. Leopold-Wildburger, U., Rendl, F. and Wascher, G. (Eds.), Operations Research Proceedings 2002. Springer, Berlin, Heidelberg, 2003. Minieka, E. (1970), The m-center problem. SIAM Review, v. 12, n. 1, p. 138–139. Mladenovi´c, N., Labb´e, M. and Hansen, P. (2003), Solving the p-center problem with tabu search and variable neighborhood search. Networks, v. 42, n. 1, p. 48–64. Ozsoy, F. and Pınar, M. (2006), An exact algorithm for the capacitated vertex p-center problem. Computers & Operations Research, v. 33, n. 5, p. 1420–1436. Plesn´ık, J. (1987), A heuristic for the p-center problems in graphs. Discrete Applied Mathematics, v. 17, n. 3, p. 263–268. Quevedo-Orozco, D. and R´ıos-Mercado, R. (2015), Improving the quality of heuristic solutions for the capacitated vertex p-center problem through iterated greedy local search with variable neighborhood descent. Computers & Operations Research, v. 62, p. 133–144. Reese, J. (2006), Solution methods for the p-median problem: An annotated bibliography. Networks, v. 48, n. 3, p. 125–142. 28 Mathematical models and search algorithms for the CPCP Kramer, R.; Iori, M.; Vidal, T. Scaparra, M., Pallottino, S. and Scutell`a, M. (2004), Large-scale local search heuristics for the capacitated vertex p-center problem. Networks, v. 43, n. 4, p. 241–255. Val´erio de Carvalho, J. (2002), LP models for bin packing and cutting stock problems. European Journal of Operational Research, v. 141, n. 2, p. 253–273. Vasilyev, I., Boccia, M. and Hanafi, S. (2016), An implementation of exact knapsack separation. Journal of Global Optimization, v. 66, n. 1, p. 127–150. Yaman, H. (2006), Formulations and valid inequalities for the heterogeneous vehicle routing problem. Mathematical Programming, v. 106, n. 2, p. 365–390. 29
1907.06001
1
1907
2019-07-13T02:45:24
The Two-Sided Game of Googol and Sample-Based Prophet Inequalities
[ "cs.DS", "cs.GT" ]
The secretary problem or the game of Googol are classic models for online selection problems that have received significant attention in the last five decades. We consider a variant of the problem and explore its connections to data-driven online selection. Specifically, we are given $n$ cards with arbitrary non-negative numbers written on both sides. The cards are randomly placed on $n$ consecutive positions on a table, and for each card, the visible side is also selected at random. The player sees the visible side of all cards and wants to select the card with the maximum hidden value. To this end, the player flips the first card, sees its hidden value and decides whether to pick it or drop it and continue with the next card. We study algorithms for two natural objectives. In the first one, as in the secretary problem, the player wants to maximize the probability of selecting the maximum hidden value. We show that this can be done with probability at least $0.45292$. In the second one, similar to the prophet inequality, the player maximizes the expectation of the selected hidden value. We show a guarantee of at least $0.63518$ with respect to the expected maximum hidden value. Our algorithms result from combining three basic strategies. One is to stop whenever we see a value larger than the initial $n$ visible numbers. The second one is to stop the first time the last flipped card's value is the largest of the currently $n$ visible numbers in the table. And the third one is similar to the latter but it additionally requires that the last flipped value is larger than the value on the other side of its card. We apply our results to the prophet secretary problem with unknown distributions, but with access to a single sample from each distribution. Our guarantee improves upon $1-1/e$ for this problem, which is the currently best known guarantee and only works for the i.i.d. case.
cs.DS
cs
The Two-Sided Game of Googol and Sample-Based Prophet Inequalities José Correa, Andrés Cristi, Boris Epstein , and José A. Soto Universidad de Chile Abstract The secretary problem or the game of Googol are classic models for online selection problems that have received significant attention in the last five decades. In this paper we consider a variant of the problem and explore its connections to data-driven online selection. Specifically, we are given n cards with arbitrary non-negative numbers written on both sides. The cards are randomly placed on n consecutive positions on a table, and for each card, the visible side is also selected at random. The player sees the visible side of all cards and wants to select the card with the maximum hidden value. To this end, the player flips the first card, sees its hidden value and decides whether to pick it or drop it and continue with the next card. We study algorithms for two natural objectives. In the first one, similar to the secretary problem, the player wants to maximize the probability of selecting the maximum hidden value. We show that this can be done with probability at least 0.45292. In the second objective, similar to the prophet inequality, the player wants to maximize the expectation of the selected hidden value. Here we show a guarantee of at least 0.63518 with respect to the expected maximum hidden value. Our algorithms result from combining three basic strategies. One is to stop whenever we see a value larger than the initial n visible numbers. The second one is to stop the first time the last flipped card's value is the largest of the currently n visible numbers in the table. And the third one is similar to the latter but to stop it additionally requires that the last flipped value is larger than the value on the other side of its card. We apply our results to the prophet secretary problem with unknown distributions, but with access to a single sample from each distribution. In particular, our guarantee improves upon 1 − 1/e for this problem, which is the currently best known guarantee and only works for the i.i.d. prophet inequality with samples. 1 Introduction In the classic game of Googol we are given n cards with n different arbitrary positive numbers written on them. The cards are shuffled and spread on a table with the numbers facing down. The cards are flipped one at a time, in a random uniform order, and we have to decide when to stop. The goal is to maximize the probability that the last flipped card has the overall greatest number. In this paper we study a variant of this problem that we call The two-sided game of Googol. Similar to the classic version, we are given n cards that we have to flip in random uniform order. However, here the cards have numbers on both sides, so we have 2n different arbitrary non-negative 1 numbers instead of n, written on each side of each card. The cards are shuffled and spread on a table so that, independently for each card, either side faces up with probability 1/2. We can see all the numbers that landed facing up (while the other side is hidden), and flip one card at a time, revealing the number that was facing down. Again we have to decide when to stop. We study the secretary and the prophet variants. In the secretary variant, the goal is to maximize the probability of stopping at the maximum number over the numbers that landed facing down. In the prophet variant, the goal is to maximize the ratio between the expectation of the last number revealed before stopping, and the expected maximum of the numbers that landed facing down. This problem naturally fits within the theory of optimal stopping theory which is concerned with choosing the right time to take a particular action, so as to maximize the expected reward. Two landmark examples within this theory are the secretary problem (or game of Googol) described above, and the prophet inequality. In the latter a gambler faces a finite sequence of non-negative independent random variables X1, . . . , Xn with known distributions Fi from which iteratively a prize is drawn. After seeing a prize, the gambler can either accept the prize and the game ends, or reject the prize and the next prize is presented to her. The classical result of Krengel and Sucheston, and Garling [22, 23], states that the gambler can obtain at least half of the expected reward that a prophet can make who knows the realizations of the prizes beforehand. That is, sup{E[Xt] : t stopping rule} ≥ 1 2E{sup1≤i≤n Xi}. Moreover, Krengel and Sucheston also showed that this bound is best possible. Remarkably, Samuel-Cahn [26] showed that the bound of 1/2 can be obtained by a simple threshold rule, which stops as soon as a prize is above a fixed threshold. We refer the reader to the survey by Hill and Kertz [19] for further classic results. In recent years, motivated by the connections between optimal stopping and posted price mech- anisms [17, 4, 8], there has been a regained interest in studying algorithms for variants of the classic prophet inequalities. The recent survey of Lucier [25] is a good starting point to understand the economic perspective of prophet inequalities, while the recent letter of Correa et al. [7] provides a recent overview of results for single choice prophet inequalities. Due to this regained interest, new variants of the prophet inequality setting have been studied, including problems when the gambler has to select multiple items, when the selected set has to satisfy combinatorial constraints, when the market is large, when prior information is inaccurate, among many others (see e.g. [1, 21, 11, 13, 12]). Particularly relevant to our work in the prophet secretary problem. In this version, the random variables are shown to the gambler in uniform random order, as in the secretary problem. The [14] who found a bound of 1 − 1/e. Later, Eshani problem was first studied by Esfandiari et al. [13] showed that the bound of 1 − 1/e can even be achieved using a single threshold. The et al. factor 1 − 1/e was first beaten by Azar et al [3] by a tiny margin, while the current best bound is 0.67 [9]. In terms of upper bounds it was unclear until very recently whether there was a separation between prophet secretary and the i.i.d prophet inequality, where the random variables are identically distributed. For this problem, Hill ad Kertz [18] provided the family of worst possible instances from which [20] proved the largest possible bound one could expect is 0.7451 and Correa et al. [6] proved that this value is actually tight. Very recently, Correa et al. show that no algorithm 3 − 1 ≈ 0.71 for the prophet secretary problem can achieve an approximation factor better than (see the full version of [9]). Interestingly, the tight is still unknown. On the other hand, some recent work has started to investigate data-driven versions of the prophet inequality since the full distributional knowledge seems quite strong for many applications. In this context, Azar et al. [2] consider a version in which the gambler only has access to one sample from each distribution. They prove a prophet inequality with an approximation guarantee of 1/4 for √ 2 this problem and left open whether achieving 1/2 is possible. This question was recently answered on the positive by Wang [27] who uses an elegant approach to prove that just taking the maximum of the samples as threshold leads to the optimal guarantee. If the instance is further specialized to an i.i.d. instance, the best known bound is 1 − 1/e while it is known that one cannot achieve a guarantee better than ln(2) ≈ 0.69 [5]. Our problem is closely related to the single-sample version of the secretary problem and the prophet secretary problem, which combine the data-driven approach of Azar et al [2] and the random arrival order of Esfandiari et al. [14]. In these problems we are given n distributions, which are unknown to us, and only have access to a single sample from each. Then n values are drawn, one from each distribution, and presented to us in random order. When we get to see a value, we have to decide whether to keep it and stop, or to drop it and continue. Again in the single-sample secretary problem the goal is to maximize the probability of stopping with the largest value while in the single-sample prophet secretary problem the goal is to maximize the expectation of the value at which we stopped divided by the expectation of the maximum of the values. It is immediate to observe that an algorithm for the two-sided game of Googol that has a guarantee of α, for either the secretary or prophet variants of the problem, readily implies the same approximation guarantee for the single-sample secretary problem and single-sample prophet secretary problem respectively [27]. Indeed, if we consider an instance of the two-sided game of Googol where the values on card i are independent draws from a distribution Fi we exactly obtain the single-sample secretary and the single-sample prophet secretary problems. 1.1 Our results Most of our results come from analyzing three basic algorithms. The first is the Open moving window algorithm, in which we stop the first time the card just flipped is larger than all the currently visible values. The second is the Closed moving window algorithm, in which we additionally require that in the last flipped card the value just revealed is larger than the value that was visible before. Finally we consider the Full window algorithm in which we simply take the largest value initially visible as threshold (and therefore stop the first time we see a value larger than all values we have seen). We first study the secretary variant of the two-sided game of Googol in which the goal is to maximize the probability of choosing the maximum hidden value. For this problem we prove that the closed window algorithm gets the maximum value with probability 0.4529. Of course, this value is more than 1/e which is the best possible for the classic secretary problem [10, 24, 15], but it is less than 0.5801 which is the best possible guarantee for the full information secretary problem, i.e., when the full distribution is known [16]. Next, we concentrate in the prophet variant of the two-sided game of Googol in which the goal is to maximize the ratio between the expectation of the chosen value, and that of the maximum hidden value. In this case we start by observing that all three algorithms described above can only give a guarantee of 1/2. Indeed, consider an instance with two cards. Card 1 has values 0 and 1 on each side while card 2 has the numbers ε and ε2. Clearly the expectation of the maximum hidden value is 1/2 + O(ε) (the value 1 is hidden with probability 1/2) while the open moving window algorithm gets in expectation 1/4 + O(ε) (to get the value of 1 the algorithm needs that it is hidden and that card 1 is the first card). For the other two algorithms, consider the instance in which card 1 has the values 1 and 1 − ε while card 2 has the values ε and 0. Clearly the expectation of the maximum hidden value is 1 − O(ε), but since now neither of the algorithms can stop when 1 − ε is 3 Instance Independent (Prophet Secretary) I.I.D. Samples Known distributions Samples Known distribution Prophet (E(ALG) ≥ αE(OP T)) 2 [27] ≤ 0.635 [*] ≤ α ≤ ln(2) [5] 1 3 − 1 [9] 0.669 [9] ≤ α ≤ √ e [5] ≤ 0.635 [*] ≤ α ≤ ln(2) [5] 0.745[6]≤ α ≤ 0.745 [18, 20] 1 − 1 Secretary (P(ALG = OP T) ≥ α) e [10] ≤ 0.452 [*] ≤ α 1 ≤ 0.580 [16] α = 0.580 [16] Table 1: Summary of known results for prophet secretary and secretary problems in the single- sample and full information settings. Results marked [*] are proven in this paper. revealed, both algorithms obtain 1/2 + O(ε). However, by randomizing the choice of the algorithm we significantly improve the approximation ratio. Our main result in the paper is to show that a simple randomization of the three proposed algorithms achieves a guarantee of 0.635 > 1− 1/e. Interestingly, our bound surpasses that of Azar et al [3] which until very recently was the best known bound for (the full information) prophet secretary. Furthermore, our bound also beats the bound of 1 − 1/e obtained by Correa et al. [5] for the i.i.d. single-sample prophet inequality. So our bound not only improves upon these known bounds, but also works in a more general setting. The key behind the analysis is a very fine description of the performance of each of the three basic algorithms. Indeed for each algorithm we exactly compute the probability that they obtain any of the 2n possible values.1 With this performance distribution at hand it remains to set the right probabilities of choosing each so as to maximize the expectation of the obtained value. To wrap-up the paper we consider a large data-set situation which naturally applies to a slightly restricted version of the single sample prophet secretary problem. The assumption states that, with high probability, the if we rank all 2n values from largest to smallest, the position of maximum minimum value a card lies far down the list (i.e., when ranking the 2n values the first few values correspond to a maximum in its card). This assumption holds for instance in the single-sample i.i.d. prophet inequality, under the large market assumption used by Abolhassan et al. [1], or whenever the underlying distributions of the prophet secretary instance overlap enough. For this variant we design an optimal moving window algorithm and prove that it achieves an approximation ratio of 0.642. In table 1 we summarize our results and the previous best bounds for the problems considered in this paper. 1.2 Preliminaries and notation Formal problem statement. We are given 2n different and arbitrary positive numbers, orga- nized into n pairs that we denote as {(ai, bi)}n i=1, representing the numbers written in both sides of each card. These pairs of numbers are shuffled into sets U and D: for each i = 1, ..., n an indepen- 1In this respect, our result for the secretary variant can be seen as a warm up for the prophet variant of the problem. 4 dent unbiased coin is tossed, if the coin lands head, then ai = Ui ∈ U and bi = Di ∈ D, otherwise bi = Ui ∈ U and ai = Di ∈ D. The set U = {U1, ..., Un} represents the numbers that landed facing up, and the numbers in D = {D1, ..., Dn} are those facing down. The numbers in U are revealed, and a random uniform permutation σ ∈ Σn is drawn. Then the elements in D are revealed in n steps: at each step i ∈ [n], the value Dσ(i) and the index σ(i) are revealed. After this, we must decide whether to stop or to continue to step i + 1. We study algorithms (stopping rules) for the two variants. Let τ be the step at which we stop. In the secretary variant the objective is to maximize P(Dσ(τ) = max D), and in the prophet variant the objective is to maximize E(Dσ(τ))/E(max D). Note that the latter is equivalent to just maximizing E(Dσ(τ)) since the algorithm does not control E(max D). Ranking and couples Our analyses rely of the ranking of the 2n numbers of the instance, so let us denote by Y1 > Y2 > ··· > Y2n the 2n numbers in U ∪D ordered from the largest to the smallest. We say that indices i and j are a couple, and denote it by i ∼ j if Yi and Yj are written in the two sides of the same card, i.e., if (Yi, Yj) = (a', b') or (Yj, Yi) = (a', b') for some ' ∈ [n]. Let k be the smallest index so that k is the couple of some k0 < k. In particular, Y1, Y2, . . . , Yk−1 are all written on different cards. Note that k and k0 only depend on numbers in the cards2, i.e., on the numbers {(ai, bi)}n i=1, and not on the coin tosses or on the permutation σ. We will restrict all our analysis to the numbers Y1, ..., Yk, which is easily justified by the observation that max D always lies in the set {Y1, ..., Yk}. Random arrival times. For most of our analyses it will be useful to consider the following rein- terpretation of the randomness of both the coins tosses (hidden sides) and the random permutation (flipping order). Consider that each of the 2n numbers arrives in a random uniform time in the interval (−1, 1] as follows. For every index ' smaller than its couple '0 (i.e. ' ∼ '0, Y' > Y'0) an independent random arrival time θ' uniform in (−1, 1] is sampled and '0 receives opposite arrival time θ'0 = C(θ'), where ( C(x) = x − 1, x + 1, otherwise. if x > 0, The reinterpretation can the be done as follows. For each j ∈ [2n], if θj > 0, the number Yj is facing down, i.e., Yj ∈ D, and if θj ≤ 0 then Yj is facing up, i.e., Yj ∈ U. Therefore, we get to see all values whose corresponding arrival time is negative and the order in which we scan the hidden values Yj ∈ D is increasing in θj. Throughout the paper we use the term value to refer to the numbers written in the cards Y1, Y2, . . . , Y2n, while we use the term element to refer to a side of a particular card, that is an element in {U1, . . . , Un, D1, . . . , Dn}. Of course these sets are the same so the point is that the i-th value corresponds to Yi, whereas the i-th element corresponds to the i-th number in the list Uσ(1), . . . , Uσ(n), Dσ(1), . . . , Dσ(n). 2This notation was introduced by Wang [27] 5 2 Basic Algorithms and statement of our results Once the random coins for all cards and the random uniform permutation are all selected, we are left with the following situation. A list E = (e1, . . . , e2n) = (Uσ(1), . . . , Uσ(n), Dσ(1), . . . , Dσ(n)) of 2n different positive elements are presented one-by-one to an algorithm. The algorithm must observe and skip the first n elements of the list, since they correspond to the values that landed facing up on the cards. The next n elements correspond to values that landed facing down (in such a way that the s-th and the s + n-th elements form a couple). The algorithm must decide immediately after observing the s-th element whether to select it and stop, or to continue with the next element. We now present generic moving window algorithms for selecting one of the last n elements of a given list E = (e1, . . . , e2n). These family of algorithms form the basis of the algorithms employed in this paper, which are described next. Generic moving window algorithm. For every s ∈ {n+1, . . . , 2n}, the algorithm first specifies, possibly in a random or implicit way, a window of elements Ws = {er : r ∈ {'s, . . . , s − 1}} (1) scheduled to arrive immediately before s (the window may be empty). Then the algorithm proceeds as follows. It observes the first n elements without selecting them. For every s ≥ n+1, the algorithm observes the s-th element, es, and selects it if es is larger than every element in its window3, i.e. if es > max Ws. Otherwise, the algorithm rejects it and continues. We now present three basic moving window algorithms for deciding when to stop. Each of them s=n+1 that will define the elements inside the can be described by a sequence of left extremes ('s)2n window Ws. Open moving window algorithm (ALGo ). This algorithm corresponds to the following strat- egy: flip the next unflipped card and accept its value x if and only if x is the largest of the n values that are currently visible (i.e., the i-th element is accepted if and only if it is larger than the n − i currently unflipped cards, and is also larger than the i − 1 previously flipped cards). In terms of the generic moving window, the left extreme of Ws is 's = s − n + 1 for n + 1 ≤ s ≤ 2n. Closed moving window algorithm (ALGc ). This algorithm works similarly to the previous one, with a slight difference. In this strategy, the element on the back of the last flipped card, the one that was facing up, is also required to be smaller than the element to be selected. In terms of the generic moving window, the left extreme of Ws is 's = s − n for n + 1 ≤ s ≤ 2n. Full window algorithm (ALGf ). This algorithm corresponds to the algorithm presented by Wang [27]. It stops when the revealed element is larger than all element seen so far. Note that this is equivalent to stop with the first element that is larger than all elements that landed facing up. In terms of the generic moving window, the left extreme of Ws is 's = 1 for n + 1 ≤ s ≤ 2n. 3If Ws = ∅ then we say that es is trivially selected. 6 Combinig these three algorithms, we can obtain algorithm ALG∗ with probability (1 − r)/2 and ALGf with probability r. Our main results are: Theorem 1. For any instance of the two-sided game of Googol, r, which picks ALGo and ALGc (cid:18) (cid:19) P(ALGc = max D) ≥ ln 2 1 − ln 2 2 ≈ 0.45292. Theorem 2. There exists a value r∗ ∈ [0, 1] such that for any instance of the two-sided game of Googol, E(ALG∗ r∗) ≥ αE(max D) with α = 4−5 ln 2 5−6 ln 2 ≈ 0.635184. The moving windows can also be seen from the perspective of the random arrival times. For ALGo, the window for an element that arrives at time θ > 0 can be defined as all elements arriving in (θ−1, θ). For ALGc, this changes to [θ−1, θ), while for ALGf it becomes [−1, θ). Therefore, we can define threshold functions4 for ALGo , ALGc , and ALGf as To(θ) = max{Yj : θj ∈ (θ − 1, θ)}, Tc(θ) = max{Yj : θj ∈ [θ − 1, θ)} and Tf(θ) = max{Yj : θj ∈ [−1, θ)}, respectively. This motivates the definition of a fourth algorithm, ALG(t), for which the window for an element that arrives at time θ is defined as all elements that arrive in [max{−1, θ − 1 − t}, θ). Our third result shows that for large k, this type of algorithms perform better. Theorem 3. For t∗ ≈ 0.1128904, and any instance of the two-sided game of Googol, as k goes to infinity, E[ALG(t∗)]/E[max D] is at least R∞(t∗) ≈ 0.6426317. To wrap up this section, we stablish two basic lemmas that will be useful later on. The first is used to estimate the probability of selecting any element arriving before a given element es. It is clear to see that all our algorithms satisfy the conditions. Lemma 4 (Moving window lemma). Suppose the windows' left extremes ('s)s∈{n+1,...2n} specified by a moving window algorithm satisfy 'n+1 ≤ 'n+2 ≤ ··· ≤ '2n ≤ n + 1 (2) Let s be an index with n+1 ≤ s and let eM = max{er : n+1 ≤ r ≤ s} be the maximum value arriving between positions n + 1 and s. The algorithm selects some element in the set {er : n + 1 ≤ r ≤ s} if and only if eM is larger than every element in its window, i.e. eM > max WM. In particular, if the window Ws of s is nonempty and eJ = max Ws then the algorithm does not stop strictly before es if and only if J ≤ n or (J ≥ n + 1 and eJ < max WJ). Proof. Suppose the algorithm selects some er with n + 1 ≤ r ≤ s. Note that er cannot arrive after eM because in that case eM > er would be in the window Wr of er contradicting that er was selected. Then er must be eM or an element arriving before eM. In any case, by condition (2), 'r ≤ 'M. Since er is selected, er ≥ max{et : 'r ≤ t ≤ r − 1} ≥ max{et : 'M ≤ t ≤ n}. But then, as eM is the largest element arriving between n + 1 and s, we also conclude that eM > max{et : 'M ≤ t ≤ M − 1} = max WM. For the converse suppose that eM > max WM then the algorithm will pick eM unless it has already selected another element er arriving before eM. In any case, the algorithm stops by selecting some element er, with n + 1 ≤ r ≤ s. 4These thresholds specify the minimum value under which the algorithm stops for each possible arrival time. 7 Let us show the second statement of the lemma. Suppose that the window of s is nonempty and let J be the index of the maximum element in its window. Let also, M0 be the largest element arriving between steps n+1 and s−1. Since eM0 is also in the window of s, we conclude that either J ≥ n + 1 and M0 = J, or J ≥ n and eJ > eM0. Suppose J ≥ n + 1. By the first part of the lemma, not stopping strictly before es is equivalent to eM0 < max WM0, and since M0 = J, eJ < max WJ. If on the other hand J ≤ n then eJ > eM0 and by assumption (2), 'M0 ≤ 's ≤ J ≤ n+1 ≤ M0 ≤ s−1. We conclude that eJ is also in the window of M0 and therefore max WM0 ≥ eJ > eM0, which is equivalent to not stopping strictly before es. As a final ingredient for our results we need the following lemma about independent uniform random variables in (−1, 1]. Lemma 5. Let X0, X1, . . . , Xm be i.i.d. random variables distributed uniformly in (−1, 1]. Define the event E : X0 > 0 and, for all i ∈ {1, . . . , m}, Xi ∈ [X0 − 1, X0). Conditioned on event E, {1 − X0, X1 + 1 − X0, X2 + 1 − X0, . . . , Xm + 1 − X0} is a family of m + 1 i.i.d. random variables distributed uniformly in [0, 1). Proof. Conditioned on E and on the realization a ∈ (0, 1] of the variable X0, the family {Xi + 1 − a}i∈{1,...,m} is mutually independent. Since this is true for every realization a of X0, we can uncondition on a and deduce that the family {1− X0, X1 +1− X0, X2 +1− X0, . . . , Xm +1− X0} is mutually independent only conditioned on E. Furthermore, since under E, X0 distributes uniformly in (0, 1] we conclude that 1 − X0 is uniform in [0, 1). Finally, under E, for i > 0, Xi distributes uniformly in [X0 − 1, X0), and therefore, Xi + 1 − X0 distributes uniformly in [0, 1). 3 Maximizing the probability of picking the maximum In this section we present a lower bound for the secretary variant of the two-sided game of Googol. Recall that the objective is to maximize the probability of stopping at the maximum value that landed facing down. If we were maximizing the probability of stopping the overall maximum value (the classical secretary problem), the best strategy [24, 10] would be to skip a constant number of elements (roughly 1/e) and then select the first element larger than all previous ones. Since we cannot select any number from the first half, we would be tempted to try the full window algorithm ALGf that selects the first element in the second half that is larger than all previous ones. Unfortunately, this algorithm does not select any element if the top one, Y1, appears in the first half. It turns out that the best algorithm among the three basic algorithms presented is the closed moving window algorithm ALGc that we analyze below. Theorem 1. For any instance of the two-sided game of Googol, (cid:18) (cid:19) P(ALGc = max D) ≥ ln 2 1 − ln 2 2 ≈ 0.45292. To prove Theorem 1 the interpretation using random arrival times over (−1, 1] will be of use. The idea of the proof is to compute, for a fixed value k, the probability of winning, that is, selecting the largest number in D. To compute this, we partition the event of winning by identifying which value Yi is picked and which element Yj is the largest inside its window. We find out that the worst case is when k −→ ∞ and conclude the bound. 8 Define the events E1: Yj is the largest element inside Yi's window, E2: Yi = max D, E3: the algorithm selects Yi. Define Qij as the event of E1, E2 and E3 happening simultaneously. The following lemma will be of use to compute the probability of winning. Lemma 6. For 1 ≤ i ≤ k − 1, (cid:17) (cid:16)1 − 1 j  1 1 2j i 1 2k−1 0 1 i P(Qij) = i + 1 ≤ j ≤ k − 1, j = k, otherwise. Proof. If j < i and E1 holds, Yi will not be selected, therefore P(Qijj < i) = 0. Also, note that a window of length 1 will contain either Yk or Yk0, where k0 is the couple of k, so if j > k, E1 can not hold and P(Qijj > k) = 0. So assume that i + 1 ≤ j ≤ k. Observe now that E1 is equivalent to the event that C(θ1), . . . , C(θi−1), C(θi+1), . . . , C(θj−1), θj are inside the interval [θi−1, θi). As this interval has length 1 and all variables are independent and uniformly chosen from [−1, 1), P(E1 θi > 0, j < k) = 1/2j−1. The case j = k is slightly different, because θk = C(θk0). If i = k0 then θk = θi − 1 ∈ [θi − 1, θi), and if i 6= k0 then θk = C(θl) for some l ∈ {1, . . . , j − 1}\{i}. In both cases, we need to impose only j − 2 variables in [θi − 1, θi), resulting in P(E1 θi > 0, j = k) = 1/2k−2. Define the auxiliary events F1 : max{0, C(θ1), . . . , C(θi−1)} = 0 and F2 : max{0, C(θ1), . . . , C(θi−1), C(θi+1), . . . , C(θj−1), θj)} 6= θj. Note that given E1, event E2 is equivalent to θ1, . . . , θi−1 ≤ 0 < θi, which in turn is equivalent to θi > 0 and F1. From here E1 and E2 happening simultaneously is equivalent to E1, F1 and θi > 0. Also, by Lemma 4, E3 is equivalent to either θj ≤ 0, or θj > 0 and Yj is smaller than some element arriving in [θj − 1, θj). If j = k we distinguish 2 cases. Indeed, suppose that E1, E2 hold. E1, E2). have that θk ≤ 0. θk0 ∈ [θj − 1, θj]. In both cases, E3 holds. We claim first that for j = k, Qik is equivalent to E1, F1 and θi > 0 (which is equivalent to If i ∼ k, then we If i 6∼ k and θk > 0 then the couple k0 of k, will satisfy that Yk0 > Yk and Now we claim that for 1 ≤ j ≤ k − 1, Qij is equivalent to all events E1, F1, F2 and θi > 0 happening simultaneously. For that, suppose that E1, and E2 hold. Under that conditioning, E3 holds in two cases, either θj ≤ 0, or θj > 0 and for some ' ∈ {1, . . . , j − 1} \ {i}, θj − 1 ≤ θ' < θj, the latter being the same as C(θ') ∈ [−1, θj − 1) ∪ [θj, 1]. But recall that by E1, every ' ∈ {1, . . . , j − 1} \ {i} satisfies C(θ') ∈ [θi − 1, θi). Therefore, E3 holds if and only if θj ≤ 0 or for some ' ∈ {1, . . . , j − 1} \ {i}, C(') ∈ [θj, θi). This is equivalent to event F2, concluding the claim. We are ready to compute the probability of Qij. Note that θj being or not the maximum of the set {0, C(θ1), . . . , C(θi−1), C(θi+1), . . . , C(θj−1), θj} does not depend on the inner ordering of the set {0, C(θ1), . . . , C(θi−1)} = 0. This implies that F1 and F2 are independent events. Since F1 is equivalent to max{1 − θi, C(θ1) + 1 − θi, . . . , C(θi−1) + 1 − θi} = 1 − θi, from Lemma 5, P(F1E1, θi > 0) = 1/i, and since F2 is equivalent to max{1 − θi, C(θ1) + 1 − θi, . . . , C(θi−1) + 1 − θi, C(θi+1)+1− θi, . . . , C(θj−1)+1− θi, θj +1− θi} 6= θj +1− θi, P(F2E1, θi > 0) = 1−1/j. Putting i , and for 1 ≤ j ≤ k − 1 all together and using independence, P(Qik) = P(E1, θi > 0, F1) = 1 1 2 P(Qij) = P(E1, θi > 0, F1, F2) = 1 2 . This concludes the proof of the lemma. (cid:16)1 − 1 j 1 2k−2 1 2j−1 1 i (cid:17) 9 With Lemma 6, we can compute the probability of winning as:  k−1X j=i+1 k−1X i=1 (cid:18) 1 − 1 (cid:19) j 1 2j 1 i  = Hk−1 2k−1 + + 1 2k−1 1 i k−2X k−1X i=1 j=i+1 1 2j j − 1 j 1 i , P(Qij) = kX j=i+1 P(W in) = k−1X where Hs =Ps i=1 1 i is the s-th harmonic number. Note that the probability of winning only depends on k and denote it F(k). The following lemma helps to find the worst case scenario for our algorithm. i=1 Lemma 7. F(k) is non-increasing in k. Proof. To prove the lemma we note that for k ≥ 2: k−1X 1 2k − Hk−1 (cid:18) 2k−1 + 2k 1 − 1 2k + Hk−1 2k (cid:18) 1 1 − 1 i k 2k−1 = 1 − Hk−1 − Hk−1 Proof of Theorem 1. To prove the main theorem of the section we use the previous results to give a lower bound for the probability of winning. The worst case happens k −→ ∞: F(k + 1) − F(k) = Hk = Hk ≤ 0. (cid:19) (cid:19) k2k i=1 k ∞X 1 2j 1 i ! j=i+1 xj−1dx Z x Z x 1 − x 1 1 0 i=1 ∞X k→∞ Fk = 1 Z 1/2 2j − Z 1/2 xi−1dx − Z 1/2 (cid:19) dx − 0 0 0 1 − x ≈ 0.45292. 0 Fk = lim j=i+1 = i=1 1 i P(Win) ≥ min k≥2 ∞X ∞X Z 1/2 ∞X Z 1/2 (cid:18) i=1 = = 1 0 0 = ln 2 1 − x 1 − ln 2 2 j (cid:19) (cid:18) 1 − 1 1 ∞X 2i − ∞X i=1 yi−1dydx 1 i = i=1 1 1 − y dydx ! Z 1/2 0 xi 1 − x dx 4 Maximizing the expected value In this section we present a lower bound for the prophet variant of the two-sided game of Googol, in which the objective is to maximize E(Dσ(τ))/E(max D). We analyze a combination of the three basic algorithms presented in Section 2. More precisely, for a fixed r ∈ [0, 1], we define ALG∗ r as follows. With probability (1 − r)/2 run ALGo, with probability (1 − r)/2 run ALGc, and with probability r run ALGf. This combination allows us to obtain the main result of the section. Theorem 2. There exists a value r∗ ∈ [0, 1] such that for any instance of the two-sided game of Googol, E(ALG∗ r∗) ≥ αE(max D) with α = 4−5 ln 2 5−6 ln 2 ≈ 0.635184. This ratio is better than the best known guarantee of 1 − 1/e ≈ 0.632 for the i.i.d. prophet secretary problem with samples [5], which is a particular case of our problem. 10 Recall that none of the 3 basic algorithms can guarantee a ratio better than 1 2 by itself, even in very simple cases. Indeed, as shown in the introduction, for the instance {(1, 0), (ε, ε2)} we have that E(max D) = 1/2 + O(ε) and E(ALGo) = 1/4 + O(ε). Furthermore, if we consider the instance {(1, 1 − ε), (ε, 0)} then E(max D) = 1 − O(ε) but E(ALGc) = E(ALGf) = 1/2 + O(ε). The intuition of our result is that the situations where each of the three algorithms perform poorly are very different. As we are able to compute exactly the distribution of the outcome of each algorithm, we can balance their distributions, so that in all cases ALG∗ r performs well. We can state this in terms of the ordered values Y1, ..., Yk. On the one hand, since ALGf is very restrictive, it has good chances of stopping at Y1 when it is in D. On the other hand, ALGc has higher probability of stopping at Yi than ALGf , for 1 < i < k. But none of the two algorithms can stop at Yk, whereas ALGo stops at Yk with positive probability. This comes at the cost of sacrificing a bit of the better elements, but as showed in the examples, it is very important for the case when k is small. Roughly speaking, the proof of Theorem 2 goes as follows. For each of the basic algorithms we compute in lemmas 9 to 11 the probability that they stop with the value Yj for each j < k, and express it as a series truncated in k and an extra term that depends on k. Then in Lemma 12 we prove that in the combined formula, for certain values of r, the extra term can be replaced with the tail of the series, so the formula does not depend on k. Finally, for a specific value of r, we show in lemmas 13 and 14 an approximate stochastic dominance and conclude, i.e., we make use of the following general observation. Observation 8. If minj≤k P(ALG≥Yj) P(max D≥Yj) ≥ α, then E(ALG) ≥ αE(max D).5 4.1 Distribution of the Maximum As noted before, P(max D = Yi) = 0 if i > k. For the remaining values, Wang [27] did a simple analysis for the distribution of max D. For Yi to be the maximum of D we need: (1) Yi ∈ D and (2) Yj ∈ U for 1 ≤ j < i. If 1 ≤ i < k all these events are independent with probability 1 2)i. If i = k, the fact that Yk is facing downwards implies that its couple is facing upwards, so we need one less coin toss for the events to happen simultaneously. Putting all together: 2, so we have P(max D = Yi) = ( 1  1 2i 1 2k−1 0 P(max D = Yi) = i < k i = k i > k Therefore we have that, P(max D ≥ Yi) = 1 − 1 2i if 1 ≤ i < k and P(max D ≥ Yk) = 1. 4.2 Analysis of the basic algorithms In this section we precisely derive the distribution of the obtained value of each of the basic al- gorithms. In the next section we combine these distributions to find an improved randomized algorithm. In what follows, we will denote by k0 the couple of k. Note that the identities of k and k0 depend only on the instance, and not on the realizations of the random coins or the random permutation. 5Recall that max D can only take values in {Y1, ..., Yk}, so the implication follows immediately. 11 Lemma 9. For every 1 ≤ i ≤ k − 1, and (cid:18) k−1X j=i+1 1 2j 1 − 1 j (cid:19) P(ALGc = Yi) = 1 2k−1 + k−1X P(ALGc ≥ Yk) = 1 2jj . j=1 Proof. Intuitively, for each j > i, we condition on that Yj is the maximum value in the window of Yi and show that ALGc stops in Yi with probability (1 − 1/j). More precisely, fix an index i ≤ k − 1. For j ≤ i, j 6= i, denote by Fj the event that θi ≥ 0 (or equivalently Yi ∈ D) and that j is the smallest index such that θj ∈ [θi − 1, θi). If j < k then P(Fj) = 1/2j because the variables {θ'}'≤j are all independent and uniformly distributed in (−1, 1], and for any given θi ≥ 0, the interval [θi − 1, θi) has length 1. For Fk we have that θk ∈ [θi − 1, θi) if and only if θk0 = C(θk) 6∈ [θi − 1, θi). Since the variables {θ'}'≤k,'6=k0 are all independent, P(Fk) = 1/2k−1. Note that if for some j < i, θj ∈ [θi − 1, θi), then ALGc 6= Yi, because its threshold Tc(θi) will be at least Yj > Yi. Also note that either θk or θk0 is in [θi − 1, θi), so the events (Fj)k j=i+1 (that are pairwise disjoint) completely cover the event {ALGc = Yi}. Thus we have the identity P(ALGc = Yi) = 1 2k−1 P(ALGc = YiFk) + 1 2j · P(ALGc = YiFj). (3) k−1X j=i+1 Now, for j > i, conditional on Fj, ALGc = Yi if and only if ALGc does not stop before observing Yi. Using lemmas 4 and 5 we will show that P(ALGc = YiFk) = 1 and that P(ALGc = YiFj) = (1−1/j) if i < j < k, and conclude the first formula of the lemma. Conditional on Fk, the maximum value in the window of Yi is Yk, but Yk is not larger than all elements in its window, because Yk0 is in it (it is on the other side of its card). So Lemma 4 implies that P(ALGc = YiFk) = 1. For the case i < j < k, we have that conditional on Fj, Yj is the maximum value in the window of Yi, so Lemma 4 implies that ALGc stops in (0, θi) if and only if θj ≥ 0 and Yj is larger than all elements in its window, i.e., θ' 6∈ [θj − 1, θj), for all ' < j. This is equivalent to max{0, C(θ1), ..., C(θi−1), C(θi+1), ..., C(θj−1), θj} = θj. Now, Lemma 5 implies that conditional on Fj, the random variables {0 − (θi − 1), C(θ1) − (θi − 1), ..., C(θi−1) − (θi − 1), C(θi+1) − (θi − 1), ..., C(θj−1) − (θi − 1), θj − (θi − 1)} are independent and uniformly distributed in (0, 1). Hence, conditional on Fj, ALGc stops in (0, θi) with probability 1/j, so P(ALGc = YiFj) = (1−1/j). This proves the first formula. For computing P(ALGc ≥ Yk), which is the probability that ALGc stops, define as Ej the event that j is the smallest index such that θj > 0 (or equivalently, that Yj = max D). It is clear that for j < k, P(Ej) = 1/2j, that P(Ek) = 1/2k−1, and that P(Ej) = 0 if j > k. For j < k , conditional on Ej, Lemma 4 implies that ALGc stops if and only if max{C(θ1), C(θ2), ..., C(θj−1), θj} = θj. But this happens with probability 1/j. Conditional on Ek, ALGc never stops. This concludes the proof of the lemma. 12 Lemma 10. For every 1 ≤ i ≤ k − 1, P(ALGo = Yi) = 1 2k−1 (cid:18) and P(ALGo ≥ Yk) = 1 − 1{i6=k0} k − 1 k−1X 1 2k−1(k − 1) + j=1 (cid:18) (cid:19) + k−1X j=i+1 1 2j 1 − 1 j (cid:19) 1 2jj . Proof. Recall that ALGo cannot select a value Yj with j > k. Suppose now that we run ALGo and ALGc in the same instance and realization. Since ALGc is more restrictive than ALGo , if ALGo stops, it stops earlier than ALGc . Nevertheless, note that Yk is the only value that can be accepted by ALGo but not by ALGc . Hence, for 1 ≤ i ≤ k − 1, if ALGo = Yi then ALGc = Yi, and if ALGc = Yi then either ALGo = Yi or ALGo = Yk. Thus, we can write the following identity for the case 1 ≤ i ≤ k − 1. P(ALGo = Yi) = P(ALGc = Yi) − P(ALGc = Yi and ALGo = Yk) . (4) Thus, we just need to compute the negative term in Equation (4). In order to have ALGo = Yk we need that θk > 0 and that θj 6∈ (θk − 1, θk], for all 1 ≤ j ≤ k − 1, with j 6= k0. Note that this is also a sufficient condition, because values that are smaller than Yk cannot be accepted by ALGo . Thus, P(ALGo = Yk) = 1/2k−1. If i = k0, then θi = θk0 = θk − 1, which is negative if θk is positive, so P(ALGc = Yk0 and ALGo = Yk) = 0. Assume now that i 6= k0. Conditional on ALGo = Yk, we have that ALGc = Yi if Yi arrives after Yk and all other values in {Y1, ..., Yk} arrive either before the window of Yk or after Yi, i.e., if θk < θi and θj ∈ (−1, θk − 1) ∪ (θi, 1], for all j ≤ k − 1, with j 6∈ {i, k0}. This is equivalent to say that C(θi) = min{0, C(θ1), ..., C(θk0−1), C(θk0+1), ..., C(θk−1)}. Note that Lemma 5 implies that conditional on ALGo = Yk, the variables {0 − (θk − 1), C(θ1) − (θk − 1), ..., C(θk0−1) − (θk − 1), C(θk0+1) − (θk − 1), ..., C(θk−1) − (θk − 1)} are independent and uniformly distributed in [0, 1]. Then, P(ALGc = YiALGo = Yk) = 1/(k − 1). Lemma 9 in Equation (4). For the second one, we have that P(ALGo ≥ Yk) = Pk We conclude the first formula by replacing the just computed probability and the formula of i=1 P(ALGo = 2k−1(k−1) + P(ALGc ≥ 2k−1(k−1) +Pk−1 1 i=1 P(ALGc = Yi) = 1 2k − (k − 2) Yi) = P(ALGo = Yk) − (k − 2) Yk) = P(ALGc ≥ Yk) + 1 Lemma 11. For every 1 ≤ i ≤ k − 1, 2k−1(k−1). 1 and P(ALGf = Yi) = 1 2k−1 1 k − 1 + P(ALGf ≥ Yk) = 1 2 . k−1X j=i+1 1 2j(j − 1) Proof. Let Fj be the event that Yj is the maximum value (j is the minimum index) such that θj < 0. Roughly speaking, we condition on each Fj and show that ALGf = Yi if Yi is the value with earliest arrival time from {Y1, ..., Yj−1}. 13 j=i+1 P(ALGf = YiFj)P(Fj). P(ALGf = Yi) =Pk Note that the events Fj are pairwise disjoint, and since either θk or θk0 is negative, P(Fj) = 0 if j > k. Thus, the events Fj for 1 ≤ j ≤ k form a partition of the probability space. Note also that conditional on Fj, by definition ALGf cannot accept any value smaller than Yj. Therefore For j ≤ k − 1 the arrival times θ1, ..., θj are all independent and uniform in (−1, 1], so P(Fj) = 1/2j. Conditional on Fj we have that θ1, ..., θj−1 are independent and uniform in [0, 1]. Moreover, conditional on Fj, ALGf simply accepts the element in {Y1, ..., Yj−1} with earliest arrival time, as they are exactly the ones larger than max U = Yj. Hence, P(ALGf = YiFj) = 1/(j − 1). The case of Fk is slightly different. Fk is equivalent to the event that θ1, ..., θk−1 > 0, because θk0 > 0 implies that θk < 0, so P(Fk) = 1/2k−1. Again ALGf simply accepts the first element larger than Yk, so it accepts Yi with probability 1/(k − 1). This concludes the proof of the first formula. For computing P(ALGf ≥ Yk), note that this is simply the probability that θ1 > 0, which is 1/2. This is because Y1 is the overall largest value, so if it arrives before 0, nothing can be accepted, and if it arrives after 0, then Y1 itself (and possibly other values with earlier arrival times) can be accepted. 4.3 The combined algorithm We now use the distributions obtained in the last section in order to obtain an improved randomized algorithm. To this end we combine lemmas 9 to 11 to conclude that for 1 ≤ i ≤ k − 1, P(ALG∗ 2k−1 + r − 1{i6=k0} · (1 − r)/2 r = Yi) = 1 − r 2k−1(k − 1) k−1X 2k−1 + r − (1 − r)/2 ≥ 1 − r 2k−1(k − 1) + + 1 2j j=i+1 (cid:18) 1 2j k−1X (cid:18) (1 − r) − (1 − r) j=i+1 (1 − r) − (1 − r) + r j − 1 j (cid:19) (cid:19) + r j − 1 j . (5) j (cid:19) + r X j≥k X j≥k 1 − r − 1 − r (cid:18) 1 − r − 1 − r j − 1 Proof. Rearranging terms, we obtain the following. The inequality comes from the fact that −1{i6=k0} ≥ −1. Now we use the following lemma to complete the summation in Equation (5) using the extra term. Lemma 12. For every 3−4 ln(2) 5−6 ln(2) ≤ r ≤ 2/3, and any k ≥ 2, (cid:18) ≤ 1 − r 2k−1 + r − (1 − r)/2 1 2k−1(k − 1) . 2j + X r/2 2k−1(k − 1) −X 2jj 1 − 3r/2 X 2k−1(k − 1) − (1 − 3r/2) 2k−1(k − 1) ≥P Therefore, it is enough to prove that −(1− 3r/2)P (1−3r/2) is positive. Note that for k ≥ 2, we haveP 2k−1 −X = 1 − r = 1 − r 2k−1 + = 1 − r 2k−1 + (k−1) 2j(j+k−1) ≤ r− 1/2. Since r ≤ 2/3, the term (k−1)/(j+k−1) 2j(j+1) = 2 ln(2)−1. j≥1 1 − r 2jj r/2 2j(j + k − 1) . + r j − 1 1 j≥1 2jj j≥k (k − 1) j≥k−1 r/2 j≥1 (cid:19) j j≥k 1 2j (6) j≥1 2j 14 Thus, it would be enough to prove that −(1−3r/2)(2 ln 2−1) ≤ r−1/2. Rearranging the terms in the last expression and multiplying by −1, we obtain the equivalent condition 3−4 ln 2 ≤ r(5−6 ln 2). In what follows, we apply Lemma 12 to derive a bound on the distribution of the accepted element that does not depend on k. Then, we select a specific value for r that balances these bounds, and allows us to approximate the distribution of max D. We define now the function (1 − r) − (1 − r) + r j − 1 j = 1 − ln 2 + r(3 ln 2 − 2) 2 . (7) (cid:18) a(r) :=X j≥2 1 2j (cid:19) This function appears in the next lemma we prove as the approximation factor of the distribution of max D. Lemma 13. For r∗ = 3−4 ln 2 5−6 ln 2 we have that for all 1 ≤ i ≤ k − 1, 2i 2a(r∗) . r∗ = Yi) ≥ 1 P(ALG∗ Proof. Using Lemma 12 in Equation (5) we can write the following for r∗ ≤ r ≤ 2/3. r = Yi) ≥ X j≥i+1 P(ALG∗ (cid:18) 1 2j (1 − r) − (1 − r) + r j − 1 . j Note that this immediately gives the desired bound for i = 1 and any r in the interval [r∗, 2/3]. We will prove directly that it also holds for i = 2 and will proceed by induction for i ≥ 3. For i = 2, Equation (9) combined with the definition of a(r) gives that (8) (9) P(ALG∗ r = Y2) ≥ a(r) − 1 4 (1 − r) − (1 − r) + r 2 (cid:18) = a(r) − 1 + r 8 . (cid:19) (cid:19) j (cid:19) Therefore, it is enough to prove that a(r∗)− 1+r∗ 8 ≥ a(r∗)/2, which is equivalent to 4a(r∗) ≥ 1 + r∗. If we replace a(r∗) with the explicit formula in the right hand of Equation (7) and rearrange terms, we obtain the inequality 3− 4 ln(2) ≥ r∗(5− 6 ln(2)). Note that this is satisfied with equality by r∗. (cid:19) For i ≥ 3 we simply prove that if r ≤ 1/3, then ≥ 1 2 (cid:18) (1 − r) − (1 − r) (1 − r) − (1 − r) X X + r j − 1 + r j − 1 (10) (cid:18) (cid:19) 1 2j 1 2j j . j≥i In fact, note that we can change the index in the right-hand side of Equation (10) to get the same range as in the sum of the left-hand side. So when we write the inequality for each term of the two summations, we obtain j≥i+1 (cid:18) 1 2j (1 − r) − 1 − r j (cid:18) (cid:19) (1 − r) − 1 − r ≥ 1 (cid:18) 1 + r j − 1 2j j − 1 − 1 j − 2 − 1 1 ≥ r j − 2 2(j − 1) ≥ r . j j (cid:19) j − 1 + r j − 2 ⇔ ⇔ which holds whenever j ≥ 4 and r ≤ 1/3. Since r∗ = 3−4 ln 2 holds for r∗, and therefore, Equation (8) holds for all 1 ≤ i ≤ k − 1. 5−6 ln 2 ≈ 0.270, we conclude that Equation (10) 15 Lemma 14. For any k ≥ 2, we have that P(ALG∗ Proof. Using lemmas 9 to 11 we get the following inequality. P(ALG∗  + r∗ 2 . 1 2k(k − 1) + r∗ ≥ Yk) ≥ 2a(r∗). k−1X r∗ ≥ Yk) = (1 − r∗)  2k(k−1) +Pk−1 G(k + 1) − G(k) = 1 1 2k(k − 1) 2kk = 2(k − 1) + (k − 1) − 2k + 1 2k+1k 1 2jj j=1 j=1 − 1 Define now the function G(k) = bound for Equation (11). We have that 1 2j j . We minimize G to obtain a general lower (11) Hence, G(2) ≥ G(3), and G(k) ≤ G(k + 1) for k ≥ 3, so G is minimized when k = 3. Thus, P(ALG∗ 2k+1k(k + 1) k − 3 = 2k+1k(k + 1) . (cid:19) + r∗ 2 2 + 1 8 (cid:18) 1 16 + 1 r∗ ≥ Yk) ≥ (1 − r∗) = 11 − 3r∗ = 55 − 66 ln 2 − 9 + 12 ln 2 16(5 − 6 ln 2) + 26 ln 2 − 18 = 16(4 − 5 ln 2) 16(5 − 6 ln 2) ≥ 2a(r∗). 16(5 − 6 ln 2) 16 The last inequality comes from the fact that 26 ln 2−18 a(r∗) = 1 − ln 2 + r(3 ln 2 − 2) 2 16(5−6 ln 2) ≈ 0.00162 ≥ 0 and that = (2 − 2 ln 2)(5 − 6 ln 2) + (3 − 4 ln 2)(3 ln 2 − 2) = 4 − 5 ln 2 2(5 − 6 ln 2) . 2(5 − 6 ln 2) With the last two lemmas we are ready to prove the main theorem of this section. Proof of Theorem 2. Summing the lower bound in Lemma 13 it follows that for all 1 ≤ i ≤ k − 1, P(ALG∗ r∗ ≥ Yi) ≥ 2a(r∗) · (cid:19) (cid:18) 1 − 1 2i From Lemma 14 we get that also P(ALG∗ max D ∈ {Y1, ..., Yk} with probability 1, we conclude that E(ALG∗ = 2a(r∗)P(max D ≥ Yi) . r∗ ≥ Yk) ≥ 2a(r∗) · P(max D ≥ Yk). Therefore, as r∗) ≥ 2a(r∗) · E(max D). 16 5 Large Data Sets (large k) In this section we consider the case in which k is large and show that for that case one can obtain better guarantees for the prophet two-sided game of Googol. This case appears very often, for instance, in the i.i.d. prophet secretary problem with unknown (continuous) distributions, all per- mutations of [2n] are equally likely to be the ordering of the 2n values in the cards. The probability that k is at least k0 equals the probability that the top t elements of the list are written in different √ (cid:19) (cid:18) cards. Note that for any ' = o( 1 − 1 ≥ 1 − '2 2n − ' (cid:18) 1 − ' 2n − (' − 1) ≥ 1 − o(1). P(k ≥ ') = 1 − 2 2n − 1 2n − 2 2n − ' ··· 1 − ' − 1 n), (cid:18) · (cid:19)' (cid:19) (cid:18) (cid:19) ≥ The algorithm that we use uses a moving window of length strictly larger than 1, as outlined in Section 2. Moving window algorithm of length 1 + t (ALG(t)). We first draw n uniform variables in [0, 1] and we sort them from smallest to largest6 as 0 < τ1 < τ2 < ··· < τn < 1. We interpret τj as the arriving time of the s-th hidden value that we reveal, and therefore, τs − 1 = C(τj) is the arriving time of the corresponding s-th face up value. The algorithm will accept the s-th face up value x = Dσ(s) if and only if x is larger than any value arrived in the previous 1 + t time units, i.e. if and only if x is larger than all elements arriving in [max(τs − 1 − t,−1), τs] Observe that ALG(0) and ALG(1) are exactly the algorithms ALGc and ALGf defined in previous sections. Below we analyze the performance of ALG(t). Lemma 15. For every 1 ≤ i ≤ k − 1, P(ALG(t) = Yi) = b(k, t) + k−1X a(j, t) , j=i+1 j − 1 2j a(j, t) = 1 − (1 − t)j−1(1 + t) 1 − (1 − t)k−1 b(k, t) = 1 2k−1 k−1X (1 − t)j k − 1 2 + i=2 . 2jj P(ALG(t) ≥ Yk) = 1 where and (12) , + (1 − t)j−1(1 + t) − (1 − t)j + (1 − t)k−1 ! j , Proof. Fix an index i ≤ k − 1. Recall that θi ∈ [−1, 1) denotes the arriving time of Yi. Let J be the random variable denoting the index of the largest element arriving in the window of Yi, or equivalently, the smallest index such that θj ∈ [θi − 1 − t, θi). Since [max(θi − 1 − t,−1), θi) has length at least 1, it always contains θk or C(θk) = θk0 (or both), we conclude that J ≤ k. Note that the algorithm selects Yi if and only if the next three events occur: (I) θi > 0, (II) J > i, as otherwise, YJ > Yi would be inside the window of Yi, and (III) No element is selected 6We assume that the drawn values are all distinct as this happens with probability 1 17 before Yi's arrival. By Lemma 4, the third event occurs if and only if the maximum element7 X arriving in [0, θi) is smaller than some element in its own window. Note that this happens in two cases: either θJ < 0 (and therefore YJ is in the window of X), or θJ ≥ 0 and YJ is smaller than some element arriving in its own window. In what follows fix some j with i + 1 ≤ j ≤ k − 1. We will compute the probability of both selecting Yi and J = j. Case 1: 0 ≤ θi ≤ t. In order to impose that J = j we need that all j − 2 arrival times (θl : l ∈ [j − 1] \ {i}) are outside the interval [−1, θi] and θj is inside. Furthermore, in this case every element arriving in [0, θj) is strictly smaller than Yj. Therefore in order to impose that no element is selected before Yi's arrival we need that θj < 0. It follows that P(ALG(t) = Yi, J = j, θi ∈ [0, t]) = 1 2 = 1 2 Z t Z t 0 0 1 2 P(θj < 0) Y (cid:19)j−2 (cid:18)1 − x l∈[j−1]\{i} 2 P(θl > 1 − x)dx 2j · 1 − (1 − t)j−1 j − 1 . dx = 1 Case 2: t < θi ≤ 1 and θj < 0. We now need that all j − 2 arrival times θl, l ∈ [j − 1] \ {i} fall outside [θi − t − 1, θi] and θj is inside. Since we are imposing θj < 0, we actually require that θj ∈ [θi − t − 1, 0]. Since θJ < 0 this is enough to guarantee that Yi will be selected. Therefore, Z 1 Z 1 P(θj ∈ [x − t − 1, 0]) Y P(ALG(t) = Yi, J = j, θi ∈ (t, 1] ∧ θj < 0) = 1 2 = 1 2 (cid:18)1 − t (cid:19)j−2 1 + t − x 2 2 t t l∈[j−1]\{l} dx = (1 − t)j−1(1 + t) . 2j+1 P(θl 6∈ [x − t − 1, x])dx Case 3: t < θi ≤ 1 and 0 ≤ θj < t. As before we need that all j−2 arrival times θl, l ∈ [j−1]\{i} fall outside [θi−t−1, θi] and θj ∈ [0, t). Since θj ≥ 0 we also need that at least one of Yl, l ∈ [j−1]\{j} arrives in Yj's window [−1, θj) and since they must be outside Yi's window this reduces to the event that not all j − 2 arrival times fall in the interval (θi, 1]. Therefore, Z 1 Z 1 t P(ALG(t) = Yi, J = j, θi ∈ (t, 1] ∧ 0 ≤ θj < t) = 1 2 = 1 2 (cid:18)1 − t (cid:19)j−2 − (cid:18)1 − x (cid:19)j−2! t 2 2 2 t dx = t(1 − t)j−1 2j − t(1 − t)j−1 2j(j − 1) P(θj ∈ [0, t))P(∀l ∈ [j − 1] \ {i}, θl 6∈ [x − t − 1, x] and not all in (x, 1])dx Case 4: t < θi ≤ 1 and t ≤ θj < θi. Once again we need that all j − 2 arrival times θl, l ∈ [j − 1] \ {i} fall outside [θi − t − 1, θi] and θj ∈ [t, θi). Since θj ≥ 0 we also need that at least one of Yl, l ∈ [j − 1]\{j} arrives in Yj's window [θj − 1− t, θj) and since they must be outside Yi's window 7If no element arrives in [0, θi) then event (III) also occurs 18 t t t 2 (cid:19)j−2 − (cid:18)1 − x + y − t this reduces to the event that not all j − 2 arrival times fall in the set [−1, θj − t − 1) ∪ (θi, 1]. Therefore, Z 1 P(ALG(t) = Yi ∧ J = j ∧ θi ∈ (t, 1] ∧ t ≤ θj < x) = 1 (cid:18)1 − t (cid:19)j−2! P(θj ∈ [t, x))P(∀l ∈ [j − 1] \ {i}, θl 6∈ [x − t − 1, x] and not all in [−1, θj − t − 1) ∪ (x, 1])dx Z x Z 1 2 = 1 Z 1 2 (1 − t)j−2(x − t) − (1 − t)j−1 − (1 − x)j−1 = 1 2j Putting all cases together we get that for all 1 ≤ i ≤ k − 1 and i + 1 ≤ j ≤ k − 1, + (1 − t)j−1(1 + t) − (1 − t)j P(ALG(t) = Yi ∧ J = j) = 1 2j · Now let us consider the case J = k. In this case we only need to impose that all k − 2 arrival times θl, l ∈ [k−1]\{i} fall outside the window of Yi. No matter who the couple of k is, the previous condition implies that k is inside the window of Yi. Therefore, 1 − (1 − t)j−1(1 + t) 2j+1 − (1 − t)j dx = (1 − t)j j − 1 j − 1 (13) ! dydx 2jj 2 j . . t Z t P(ALG(t) = Yi ∧ J = k) = 1 2 = 1 2k−1 0 (cid:18)1 − x (cid:19)k−2 1 − (1 − t)k−1 2 dx + (cid:18)1 − t 2 (cid:19)k−1 ! k − 1 + (1 − t)k−1 . (14) By combining (13) and (14) together we finish the proof of the first equality of this lemma, (12). We now compute the probability that ALG(t) selects one of the top k values Y1, . . . , Yk. Observe first that the algorithm never selects a value Yj with j > k. This is because the window of Yj always contains θk or C(θk) = θk0, and both Yk and Yk0 are larger than Yj. By this observation, P(ALG(t) ≥ Yk) equals the probability that the algorithm stops by selecting something. Let M be the random variable denoting the index of the largest value arriving after 0, i.e. θM ≥ 0 and θi < 0, for all i < M. By Lemma 4, ALG(t) stops by selecting a value if and only if YM is larger than every value arriving in its window [max(θM − 1 − t, 1), θM)). Observe that if M = k, this is impossible because the couple of k is always in that interval. Therefore, P(ALG(t) ≥ Yk) = = kX kX j=1 j=1 P(ALG(t) ≥ Yk, M = j) Z 1 k−1X (cid:18) x − t P(∀i ∈ [j − 1], θi ∈ [−1, x − 1 − t)dx. Z 1 (cid:19)j−1 k−1X 1 2 (1 − t)j 0 dx = 1 2 + . 2jj j=2 = 1 2 + 1 2 j=2 t 2 Algorithm ALG(t) has a very poor performance for k = 2. For example, in the instance {(1, 1 − ε), (ε, 0)}, we have Y1 = 1, Y2 = 1 − ε and k = 2. By Lemma 15, P(ALG(t) ≥ Y2) = 1/2. Therefore E(ALG(t)) ≤ 1/2, while E(max D) ≥ 1 − ε. 19 Figure 1: Auxiliary functions to analyze ALG(t), as k tends to ∞. We will now study the behaviour of ALG(t) when k is large. For that, define b(k, t) + a(j, t) 2j Rk(i, t) = 1 . P(ALG(t) ≥ Yi) P(max D ≥ Yi) = Rk(t) = P(ALG(t) stops) = 1 k−1X iX (1 − t)j l=1 j=l+1 . 2jj 1 − (1/2)i k−1X 2 + j=2 Consider also their limits as k → ∞, which since kb(k, t) → 0 can be computed as R∞(i, t) = R∞(t) = 1 iX ∞X l=1 (1 − t)j j=l+1 = t 2jj 1 1 − (1/2)i ∞X 2 + j=2 a(j, t) 2j 2 + ln . (cid:18) 2 1 + t (cid:19) . Recall that the competitiveness of ALG(t) is at least mini≥1 R∞(i, t), and we are looking for the value t that maximizes this minimum. In Figure 1 we plot a few of these R∞(i, t), for small values of i, together with function R∞(t). From the plot we observe that the t∗ maximizing the minima of all the curves satisfies R∞(1, t∗) = R∞(t∗). By simplifying the sums, we obtain that t∗ ≈ 0.1128904 is the only root of: R∞(1, t) − R∞(t) = 2 − (5t)/2 − (3 + t) ln 2 + (4 + t) ln(1 + t). To formally prove that R∞(t∗) ≈ 0.6426317 is the sought guarantee we need the following lemma. Lemma 16. Let a(j, t) be defined as in Lemma 15. For all j ≥ 3, we have a(j, t∗) ≥ a(j + 1, t∗) Proof. Below, we tabulate a few values of a(j, t∗) with t∗ ≈ 0.1128904, and we observe that a(j, t∗) ≥ a(j + 1, t∗) for all j ∈ {3, . . . , 9}: 20 R[1,t]R[2,t]R[3,t]R[4,t]R[t]0.20.40.60.81.00.550.600.650.70 (cid:18) 1 j − 1 − 1 j (cid:19) j 3 4 5 6 7 8 9 10 0.705194 a(j, t∗) Let us prove that the inequality also holds for j ≥ 10. By rearranging terms, a(j, t) ≥ a(j + 1, t) 0.696462 0.607906 0.556898 0.460684 0.417513 0.65704 0.50734 is equivalent to j 1 (1 − t)j−1 − (1 − t)2 − (1 − t∗)2 j + 1 + 1 + t j − 1 . j + 1 + 1 + t∗ ≥ −t(1 + t) − t(1 − t) j − 1 − t∗(cid:19) (cid:18) 1 j But note that the right hand side, evaluated at t∗ ≥ 1/9 is: (cid:18) 1 −t∗(1 + t∗) − t∗(1 − t∗) j − 1 − 1 j − 1 ≤ (1 + t∗) 9 which is nonpositive for all j ≥ 10. Then, it is smaller than the left hand side which is positive. Theorem 3. For t∗ ≈ 0.1128904, and any instance of the two-sided game of Googol, as k goes to infinity, E[ALG(t∗)]/E[max D] is at least R∞(t∗) ≈ 0.6426317. limk→∞ P(ALG(t∗) = Yi) =P∞ Proof. We will prove that for all i ≥ 1, R∞(i, t∗) ≥ R∞(t∗). Denote for all i ≥ 1, Pi = j=i+1 a(j, t∗)/2j. By choice of t∗, R∞(1, t∗) = R∞(t∗) ≈ 0.6426317. 1−1/4 ≈ 0.6547 ≥ R∞(t∗) and R∞(3, t∗) = Furthermore we we can numerically evaluate R∞(2, t∗) = P1+P2 1−1/8 ≈ 0.654331 ≥ R∞(t∗). P1+P2+P3 To finish the proof, we will show that for all i ≥ 4, R∞(i, t∗) ≥ R∞(i + 1, t∗), and therefore, for all i ≥ 4, R∞(i, t∗) ≥ limj→∞ R∞(j, t∗) = R∞(t∗). For this, we will also need the inequality P1 ≈ 0.3213158 ≥ 0.304065 ≈ 8P4. By Lemma 16, for all i ≥ 2, ≤ (1 + t∗) (cid:19) , Therefore, ∞X j=i+1 Pi = iX '=1 a(j, t∗) 2j ≥ iX '=2 ∞X j=i+1 (cid:18) 1 + We conclude that, R(i + 1, t∗) = Pi+1 +Pi '=1 P' 1 − 1/2i+1 ≤ a(j + 1, t∗) 2j = 2Pi+1. iX (cid:19) iX '=2 '=2 1 2i+1 − 2 2i+1 − 1 2i+1 Pl = iX Pl '=2 2i+1 − 2 2i+1 P' ≥ 8P4 + P' ≥ 2iPi+1 + Pi+1 2i+1−' = Pi+1(2i+1 − 2). = R∞(i, t∗). To conclude this section we observe that the guarantee obtained in the k = ∞ case is still useful for moderately high values of k. Indeed, note that for all j ≥ 1, and all t ∈ (0, 1), a(j, t) ≤ 2,b(k, t) ≤ 2 Therefore, for all 1 ≤ i ≤ k − 1 and all k ≥ 3. (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)P(ALG(t) = Yi) − ∞X j=i+1 (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) = (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)b(k, t) − ∞X j=k a(j, t) 2j a(j, t) 2j 2k−1 . (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ 2 2k−1 + 2 ∞X j=k 2j = 4 1 2k−1 = 1 2k−3 . 21 Therefore, Rk(i, t) − R∞(i, t) = 1 1 − 1/2k We also have that (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) iX '=1 (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ 2i 2k−3 ≤ 16k 2k . a(j, t) 2j ∞X j='+1 P(ALG(t) = Y') − (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ 1 (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ∞X (1 − t)j 2jj j=k Rk(t) − R∞(t) = 2k−1 ≤ 16k 2k . From here, min(Rk(t∗), min 1≤i≤k−1 Rk(i, t∗)) ≥ min(R∞(t∗), min 1≤i≤k−1 Rk(i, t∗)) − 16k 2k = R∞(t∗) − 16k 2k . Thus the guarantee of ALG(t) for not so large values of k is already very close to R∞(t∗) ≈ 0.6426317. For example, the guarantee of ALG(t) for k ≥ 20 is at least R∞(t∗) − 0.00031. Acknowledgments This work was partially supported by CONICYT under grants CONICYT-PFCHA/Doctorado Nacional/2018-21180347, CONICYT-PFCHA/Magister Nacional/2018-22181138, Conicyt-Fonde- cyt 1181180, conicyt-fondecyt 1190043 and PIA AFB-170001, and by an Amazon Research Award. References [1] Abolhassani, M., Ehsani, S., Esfandiari, H., Hajiaghayi, M., Kleinberg, R., Lucier, B. Beating 1-1/e for ordered prophets. STOC 2017. [2] Azar, P., Kleinberg, R., Weinberg., S.M. Prophet Inequalities With Limited Information. SODA 2014. [3] Azar, Y., Chiplunkar, A., Kaplan, H. Prophet secretary: Surpassing the 1-1/e barrier. EC 2018. [4] Chawla, S., Hartline, J., Malec, D., Sivan, B. Multi-parameter mechanism design and sequential posted pricing. STOC 2010. [5] Correa, J., Duetting, P., Fischer, F., Schewior, K., Prophet inequalities for i.i.d. random vari- ables from an unknown distribution. EC 2019. [6] Correa, J., Foncea, P., Hoeksma, R., Oosterwijk, T., Vredeveld, T. Posted price mechanisms for a random stream of customers. EC 2017. [7] Correa, J., Foncea, P., Hoeksma, R., Oosterwijk, T., Vredeveld, T. Recent Developments in Prophet Inequalities. ACM SIGecom Exchanges 17(1), 61 -- 70, 2018. 22 [8] Correa, J., Foncea, P., Pizarro, D., Verdugo, V. From pricing to prophets, and back!. Operations Research Letters, 47(1), 25 -- 29, 2019. [9] Correa, J., Saona, R., Ziliotto, B. Prophet secretary through blind strategies. SODA 2019. [10] Dynkin, E.B. The optimum choice of the instant for stopping a Markov process. Soviet Math. Dokl. 4, 627 -- 629, 1963. [11] Düetting, P., Feldman, M., Kesselheim, T., Lucier, B. Prophet inequalities made easy: Stochas- tic optimization by pricing non-stochastic inputs. FOCS 2017. [12] Düetting, P., Kesselheim, T. Posted Pricing and Prophet Inequalities with Inaccurate Priors. EC 2019. [13] Ehsani, S., Hajiaghayi, M., Kesselheim, T., Singla, S. Prophet secretary for combinatorial auctions and matroids. SODA 2018. [14] Esfandiari, H., Hajiaghayi, M., Liaghat, V., Monemizadeh, M. Prophet secretary. ESA 2015. [15] Ferguson, T.S. Who solved the secretary problem? Statistical Science 4(3), 282 -- 296, 1989 [16] Gilbert, J., Mosteller, F. Recognizing the maximum of a sequence. J. Am. Statist. Assoc. 61, 35 -- 73, 1966 [17] Hajiaghayi, M., Kleinberg, R., Sandholm, T. Automated online mechanism design and prophet inequalities. AAAI 2007. [18] Hill, T., Kertz, R. Comparisons of stop rule and supremum expectations of i.i.d. random variables. The Annals of Probability 10(2), 336 -- 345, 1982. [19] Hill, T., Kertz, R. A survey of prophet inequalities in optimal stopping theory. Contemporary Mathematics 125, 191 -- 207, 1992. [20] Kertz, R. Stop rule and supremum expectations of i.i.d. random variables: A complete com- parison by conjugate duality. Journal of Multivariate Analysis 19, 88 -- 112, 1986. [21] Kleinberg, R., Weinberg, S. M. Matroid prophet inequalities. STOC 2012. [22] Krengel, U., Sucheston, L. Semiamarts and finite values. Bull. Amer. Math. Soc. 83, 745 -- 747, 1977. [23] Krengel, U., Sucheston, L. On semiamarts, amarts, and processes with finite value. Adv. in Probability 4, 197 -- 266, 1978. [24] Lindley D.V. Dynamic programming and decision theory. Appl. Statist. 10, 39 -- 51, 1961. The optimum choice of the instant for stopping a Markov process. Soviet Math. Dokl. 4 627-629. [25] Lucier, B. An economic view of prophet inequalities. ACM SIGecom Exchanges 16(1), 24 -- 47, 2017. [26] Samuel-Cahn, E. Comparisons of threshold stop rule and maximum for independent nonnega- tive random variables. The Annals of Probability 12(4), 1213 -- 1216, 1984. 23 [27] Wang, J. The prophet inequality can be solved optimally with a single set of samples. ArXiv preprint, 2018. 24
1910.10412
2
1910
2019-11-11T13:42:45
A story of diameter, radius and Helly property
[ "cs.DS" ]
A graph is Helly if every family of pairwise intersecting balls has a nonempty common intersection. Motivated by previous work on dually chordal graphs and graphs of bounded distance VC-dimension we prove several new results on the complexity of computing the diameter and the radius on Helly graphs and related graph classes. * First, we present algorithms which given an $n$-vertex $m$-edge Helly graph $G$ as input, compute w.h.p. its radius and its diameter in time $\tilde{\cal O}(m\sqrt{n})$. Our algorithms are based on the Helly property and on several implications of the unimodality of the eccentricity function in Helly graphs: every vertex of locally minimum eccentricity is a central vertex. * Then, we focus on $C_4$-free Helly graphs, which include, amongst other subclasses, bridged Helly graphs and so, chordal Helly graphs and hereditary Helly graphs. For the $C_4$-free Helly graphs, we present linear-time algorithms for computing the eccentricity of all vertices. Doing so, we generalize previous results on strongly chordal graphs to a much larger subclass. * Finally, we derive from our findings on chordal Helly graphs a more general one-to-many reduction from diameter computation on chordal graphs to either diameter computation on split graphs or the {\sc Disjoint Set} problem. Therefore, split graphs are in some sense the {\em only} hard instances for diameter computation on chordal graphs. As a byproduct of our reduction the eccentricity of all vertices in a chordal graph can be approximated in ${\cal O}(m\log{n})$ time with an additive one-sided error of at most one, and on any subclass of chordal graphs with constant VC-dimension the diameter can be computed in truly subquadratic time. These above results are a new step toward better understanding the role of abstract geometric properties in the fast computation of metric graph invariants.
cs.DS
cs
A story of diameter, radius and Helly property Guillaume Ducoffe1,2 and Feodor F. Dragan3 1National Institute for Research and Development in Informatics, Romania 3Computer Science Department, Kent State University, Kent, Ohio, USA 2University of Bucharest, Romania Abstract A graph is Helly if every family of pairwise intersecting balls has a nonempty common intersection. Motivated by previous work on dually chordal graphs and graphs of bounded distance VC-dimension (with the former being a subclass of Helly graphs and the latter being a particular case of graphs of bounded fractional Helly number, respectively) we prove several new results on the complexity of computing the diameter and the radius on Helly graphs and related graph classes. • First, we present algorithms which given an n-vertex m-edge Helly graph G as input, its radius and its diameter in time O(m√n). Our algorithms are based compute w.h.p. on the Helly property and on several implications of the unimodality of the eccentricity function in Helly graphs: every vertex of locally minimum eccentricity is a central vertex. • Then, we focus on C4-free Helly graphs, which include, amongst other subclasses, bridged Helly graphs and so, chordal Helly graphs and hereditary Helly graphs. For the C4- free Helly graphs, we present linear-time algorithms for computing the eccentricity of all vertices. Doing so, we generalize previous results on strongly chordal graphs to a much larger subclass. • Finally, we derive from our findings on chordal Helly graphs a more general one-to-many reduction from diameter computation on chordal graphs to either diameter computation on split graphs or the Disjoint Set problem. Therefore, split graphs are in some sense the only hard instances for diameter computation on chordal graphs. As a byproduct of our reduction the eccentricity of all vertices in a chordal graph can be approximated in O(m log n) time with an additive one-sided error of at most one. This answers an open question of [Dragan, IPL 2019]. We also get from our reduction that on any subclass of chordal graphs with constant VC-dimension the diameter can be computed in truly subquadratic time. These above results are a new step toward better understanding the role of abstract geometric properties in the fast computation of metric graph invariants. 9 1 0 2 v o N 1 1 ] S D . s c [ 2 v 2 1 4 0 1 . 0 1 9 1 : v i X r a 1 Introduction For any undefined graph terminology, see [6, 22]. We study the fundamental problems of computing, for a given undirected unweighted graph, its diameter and its radius. There is a textbook algorithm for solving both problems in O(nm) time on n-vertex m-edge graphs. However, it is a direct reduction to All-Pairs Shortest-Paths (APSP), that is a seemingly more complex problem with a 1 much larger (quadratic-size) output than for the diameter and radius problems. On one hand, there is a long line of work presenting more efficient -- often linear-time -- algorithms for computing the diameter and/or the radius on some special graph classes [1, 11, 12, 13, 14, 16, 18, 20, 21, 24, 26, 29, 30, 31, 32, 33, 34, 42]. On the other hand, under the Strong Exponential-Time Hypothesis (SETH) and the Hitting Set Conjecture (HS), respectively, we cannot solve either of these two problems in truly subquadratic-time [1, 43]1. We aim at characterizing the graph classes for which these above (SETH- or HS-) "hardness" results do not hold. Ideally we would like to derive a dichotomy theorem, not unlike those proved in [1] but covering many more subquadratic-time solvable special cases from the literature. Our work is part of a recent series of papers, with co-authors, where we try to reach this objective based on tools and concepts from Computational Geometry [29, 30, 31]. -- See also [1, 13] for some pioneering works in this line of research. -- Specifically, a class H of hypergraphs has fractional Helly number at most k if for any positive α there is some positive β such that, in any subfamily of hyperedges in a hypergraph of H, if there is at least a fraction α of all the k-tuples of hyperedges with a non-empty common intersection, then there exists an element that is contained in a fraction at least β of all hyperedges in this subfamily. Then, the fractional Helly number of a graph class G is the fractional Helly number of the family of the ball hypergraphs of all graphs in G. For instance Matousek proved that every hypergraph of VC-dimension d has its fractional Helly number that is upper bounded by a function of d [41]. It implies that the graphs of bounded distance VC-dimension, studied in [8, 10, 17, 31], have a bounded fractional Helly number. Note that the latter graphs comprise planar graphs [17], bounded clique-width graphs [10] and interval graphs [31] amongst other subclasses of interest. Motivated by the results from [31] on diameter and radius computation in these graphs, we ask whether we can compute the diameter and the radius in truly subquadratic time within graph classes of constant fractional Helly number. As a first step toward resolving this question, our current research focuses on the simpler class of Helly graphs. Recall that a graph is Helly if any family of pairwise intersecting balls has a non-empty common intersection. So, in particular, Helly graphs have fractional Helly number two. Furthermore, we stress that the Helly graphs are one of the most studied classes in Metric Graph Theory (e.g., see the survey [2] and the papers cited therein). Indeed, this is partly because of the very nice property that every graph is an isometric subgraph of some Helly graph, thereby making of the latter the discrete equivalent of hyperconvex metric spaces [28, 38]. Conjecture 1. There is a positive ε such that, for every n-vertex m-edge Helly graph, we can compute its diameter and its radius in time O(mn1−ε). To the best of our knowledge, until this work the only known result toward proving Conjecture 1 was a positive answer to this conjecture for the class of dually chordal graphs [11]. In fact, the diameter and the radius of a dually chordal graph can be computed in linear time, that is optimal. We note that obtaining such a strong complexity result for the general Helly graphs looks more challenging. Hence, we also studied whether stronger versions of Conjecture 1 could hold true on more restricted subclasses, such as chordal Helly graphs or more generally C4-free Helly graphs. -- This latter choice was also partly motivated by a nice characterization of hereditary Helly graphs: indeed, they are exactly the 3-sun-free chordal graphs [26]. -- We stress that it is already SETH-hard to compute the diameter on chordal graphs in truly subquadratic time [7]. On the positive side, there exist linear-time algorithms for computing the radius on general chordal graphs [14], and the 1 By truly subquadratic we mean a running-time in O(namb), for some positive a, b such that a + b < 2. 2 interval graphs, directed path graphs and diameter on various subclasses of chordal graphs, e.g. strongly chordal graphs [11, 18, 25]. Most of these special cases, including the three aforementioned examples, are strict subclasses of chordal Helly graphs. As a result, our work pushes forward the tractability border for diameter computation on chordal graphs and beyond. Our Contributions Our first main result in the paper is a positive resolution of Conjecture 1 in the general case. Specifically, we present truly subquadratic-time algorithms for computing both the radius and the diameter of Helly graphs (Theorem 1 and Theorem 4). Although for a Helly graph we can compute its diameter from its radius [26] -- a property which is not known to hold for general graphs -- we present separate algorithms for diameter and radius computations. Indeed, our approach for computing the radius can be applied to a broader class than the Helly graphs, both as an exact and approximation algorithm. Our algorithms run in time O(m√n) w.h.p., and they use as their main ingredients several consequences of the unimodality of the eccentricity function in Helly graphs [26]: every local minimum of the eccentricity function in a Helly graph is a global minimum. Next we focus on the class of C4-free Helly graphs, which have been studied on their own and have more interesting convexity properties than general Helly graphs [26, 23]. In particular, the center C(G) of a C4-free Helly graph G is convex and it has diameter at most 3 and radius at most 2 [26, 23]. In contrast, the center C(G) of a general Helly graph G is isometric but it can have arbitrarily large diameter; in fact, any Helly graph H is the center of some other Helly graph G [26]. We stress that C4-free Helly graphs encompass the bridged Helly graphs and all Helly graphs of hyperbolicity 1/2, amongst other examples. By restricting ourselves to this subclass we can use the well-known multi-sweep heuristic of Corneil et al. [18], in order to compute vertices of provably large eccentricity, as a brick-basis for exact linear-time algorithms for computing both a central vertex and the diameter. Our general approach for these graphs is also partly inspired by the algorithms of Chepoi and Dragan [14] and Dragan and Nicolai [24], in order to compute a central vertex in chordal graphs and a diametral pair in distance-hereditary graphs, respectively. We stress that in contrast to this positive result on C4-free Helly graphs, and as notified to us by Chepoi (private communication), a similar method cannot apply to general Helly graphs. Indeed, the values obtained for Helly graphs with the multi-sweep heuristic can be arbitrarily far from the diameter, which comes from the property that any graph can be isometrically embedded into a Helly graph [28, 38]. Furthermore, our results for C4-free Helly graphs go beyond the mere calculation of the diameter and the radius. Indeed, we are able to compute the eccentricity of all vertices, which for Helly graphs can be reduced to computing the graph center. For that, we first need to solve the related problem of computing a diametral pair (i.e., a pair of vertices of which the distance in the graph equals the diameter), which surprisingly requires a more intricate approach than for just computing the diameter. -- We note that the algorithm of Theorem 4 also computes a diametral pair, but in super- linear time. -- This intermediate result has interesting consequences on its own. For instance, if we apply our algorithms on an arbitrary chordal graph, then we can use a (supposedly) diametral pair in order to decide, in linear time, if either we computed the diameter correctly or the input graph is not Helly. See Remark 2 for more details. Note that in comparison, the best-known recognition algorithms for chordal Helly graphs run in O(m2) time [40]. Our two main ingredients in order to solve these above problems are (i) a "pseudo-gatedness" property of the subsets of weak diameter at most two in C4-free Helly graphs, and (ii) a reduction from finding a diametral pair under 3 some technical assumptions to the same problem on a related split Helly graph. We find the latter result all the more interesting that split graphs are amongst the hardest instances for diameter computation [7]. Finally, our above investigations on C4-free Helly graphs lead us to the following natural research question: what are the other graph classes where the diameter can be efficiently computed from a subfamily of split graphs? In particular, can we reduce diameter computation on general chordal graphs to the same problem on split graphs? This would imply that the subclass of split graphs is, in some sense, the sole hard case for diameter computation on chordal graphs. Furthermore, this could help in finding new subclasses of chordal graphs for which we can compute the diameter faster than in O(nm). We answer positively to this open question, but in a more restricted setting (Theorem 8). Specifically, our reduction is indeed from diameter computation on chordal graphs to the same problem on split graphs, but the computational results which we obtain are better if then we reduce to the well-known Disjoint Set problem -- a.k.a. the monochromatic Orthogonal Vector problem. We stress that there is a trivial linear-time reduction from diameter computation on split graphs to Disjoint Set, but the converse reduction from this problem to computing the diameter of a related split graph runs in time quadratic in the number of elements in the ground set of the input family. This is evidence that Disjoint Set might be a harder problem than diameter computation on split graphs -- at least in some density regimes. As a byproduct of our reduction, we prove that the diameter can be computed in truly sub- quadratic time on any subclass of chordal graphs with constant VC-dimension (Theorem 10). This nicely complements the results from [31], which mostly apply to sparse graph classes of constant distance VC-dimension or assuming a bounded (sublinear) diameter. Another application of our reduction is the approximate computation in quasi linear time of the eccentricity of all vertices in a chordal graph with an additive one-sided error of at most 1. The latter result answers an open question from [27]. G[v]. G[v], NG[S] := N 1 Notations. Throughout the remainder of the paper, we denote by distG(u, v) the distance between vertices u and v. The metric interval IG(u, v) between u and v is defined as {w ∈ V distG(u, w) + distG(w, v) = distG(u, v)}. For any k ≤ distG(u, v), we can also define the slice L(u, k, v) := {w ∈ IG(u, v) distG(u, w) = k}. The ball of radius r and center v is de- fined as {u ∈ V distG(u, v) ≤ r}, and denoted N r G[v] and (cid:83) NG(v) := NG[v] \ {v} denote the closed and open neighbourhoods of a vertex v, respectively. More generally, for any vertex-subset S we define distG(u, S) := minv∈S distG(u, v), N r G[S] := v∈S N r G[S] and NG(S) := NG[S] \ S. The metric projection of a vertex u on S, denoted P rG(u, S), is defined as {v ∈ S distG(u, v) = distG(u, S)}. The eccentricity of a vertex u is defined as maxv∈V distG(u, v) and denoted by eG(u). We also define the set FG(u) := {v ∈ V distG(u, v) = eG(u)} of all the farthest vertices from vertex u. -- Note that we will omit the subscript if the graph G is clear from the context. -- The radius and the diameter of a graph G are denoted rad(G) and diam(G), respectively. Finally, C(G) := {v ∈ V e(v) = rad(G)} is the center of G, a.k.a. the set of all the central vertices of G. In particular, NG[v] := N 1 2 Fast Computations within Helly graphs In this section, we answer positively to Conjecture 1. Section 2.1 is devoted to a subquadratic-time randomized algorithm for radius computation, that can be turned to an exact or approximation 4 algorithm for larger classes than the Helly graphs (namely, in every class where the diameter equals twice the radius, up to some additive constant). Then, we combine this approach with several other technical arguments in order to compute the diameter of Helly graphs in truly subquadratic time (Section 2.2). 2.1 Radius computation We start this section with a simple randomized test, which is inspired from previous works on adaptive greedy set cover algorithms [46]. Lemma 1. Let G = (V, E) be a graph, let r be a positive integer and let ε ∈ (0; 1). There is an algorithm that w.h.p. computes a set D(cid:104)G; r; ε(cid:105) in O(m/ε) time with the following two properties: • if e(v) ≤ r then v ∈ D(cid:104)G; r; ε(cid:105); • conversely, if v ∈ D(cid:104)G; r; ε(cid:105) then N r[v] ≥ (1 − ε) · n. εn , and so ε Proof. Let p = c · log n we can compute the set of all the vertices of eccentricity at most r in time O(m/ε) by running a BFS from every vertex. From now on we assume that p < 1. By U (p) we mean a subset in which every vertex was added independently at random with probability p. Observe that we If p ≥ 1 then n ≤ c log n for some arbitrary large constant c. ε > c · log n. By Chernoff bounds we get U (p) = O(ε−1) with probability have E[U (p)] = c log n ≥ 1 − n−c. Then, for every v ∈ V , we compute N r[v] ∩ U (p), which takes total time O(m/ε). We divide our analysis in two cases. First let us assume that e(v) ≤ r. Then, with probability 1 we have U (p) ⊆ N r[v]. Second, let us assume that N r[v] < (1 − ε) · n. We get P rob[U (p) ⊆ p·c log n ≤ n−c. Overall, let D(cid:104)G; r; ε(cid:105) contain all the vertices v such that N r[v]] < (1− p)εn = (1− p) U (p) ⊆ N r[v]. By a union bound over ≤ n vertices, the set D(cid:104)G; r; ε(cid:105) satisfies our two above-stated properties with probability ≥ 1 − n−(c−1). 1 We derive from this simple test above an approximation algorithm for computing the radius and the diameter, namely: Lemma 2. Let G = (V, E) be a graph and r be a positive integer. There is an algorithm that w.h.p. runs in O(m√n) time and such that: • If the algorithm accepts then diam(G) ≤ 2r; • If the algorithm rejects then rad(G) > r. Note that since diam(G) ≤ 2rad(G), this algorithm rejects any graph G with diam(G) > 2r. However, it might also reject some graphs G such that diam(G) ≤ 2r but rad(G) > r. Proof. For some ε to be defined later, we construct a set D(cid:104)G; r; ε(cid:105) as in Lemma 1. W.h.p. takes time O(m/ε). There are two cases. If D(cid:104)G; r; ε(cid:105) = ∅ then we know that rad(G) > r and we stop. Otherwise, we pick any vertex c ∈ D(cid:104)G; r; ε(cid:105) and we compute N r[c]. Here it is important to observe that all the vertices of N r[c] are pairwise at a distance ≤ 2r. Furthermore, w.h.p. we have V \ N r[c] ≤ ε · n. We end up computing a BFS from every vertex of V \ N r[c], accepting in the end if and only if all these vertices have eccentricity ≤ 2r. By setting ε = n−1/2, the total running time is w.h.p. in O(m√n). it 5 An important consequence of Lemma 2 is that the hard instances for diameter and radius approximations are those for which the difference 2rad(G) − diam(G) is large, namely: Corollary 1. If 2rad(G) − diam(G) ≤ k then, w.h.p., we can compute an additive +(cid:98)k/2(cid:99)- approximation of rad(G) and an additive +k-approximation of diam(G) in total O(m√n) time. Proof. We compute by dichotomic search the smallest r such that the algorithm of Lemma 2 accepts. Note that w.h.p. r ≥ (cid:100)diam(G)/2(cid:101), and so r ≥ = rad(G) − (cid:98)k/2(cid:99). Furthermore, we have w.h.p. r ≤ rad(G), and so 2r ≤ diam(G) + k. We output r and 2r as approximations of rad(G) and diam(G), respectively. 2 (cid:108) 2rad(G)−k (cid:109) Application to Helly graphs. For Helly graphs, the diameter and the radius are closely related. This is a consequence of the unimodality property of the eccentricity function of Helly graphs [26], a property that will be further discussed in the next section. In particular, the following relations hold between the two: Lemma 3 ([26]). If G is a Helly graph then 2rad(G) ≥ diam(G) ≥ 2rad(G) − 1. In particular, rad(G) = (cid:100)diam(G)/2(cid:101). By combining Lemma 3 with Corollary 1, we obtain the main result of this section, namely: Theorem 1. If G is a Helly graph then, w.h.p., we can compute rad(G) and an additive +1- approximation of diam(G) in time O(m√n). 2.2 Diameter computation Equipped with Theorem 1, we already know how to compute, for a Helly graph, an additive +1- approximation of its diameter. However, this is not enough yet in order to prove Conjecture 1. For instance, consider the case of chordal graphs: we can compute their radius [14] and an additive +1-approximation of their diameter [18, 25] in linear time, however it is SETH-hard to compute their diameter exactly in truly subquadratic time [7]. Our main result in this section is that the exact diameter of Helly graphs can be computed in truly subquadratic time (Theorem 4), that is in sharp contrast with the chordal graphs. An intermediate problem We start with a parameterized algorithm for computing all eccentricities up to some threshold value in a Helly graph G. Our results for the following more general problem are also used in Section 3.3. Problem 1 (Small Eccentricities). Input: a graph G = (V, E); a vertex-subset A; a positive integer k. Output: the set Bk := {b ∈ V A ⊆ N k[b]}. We note that already for k = 2, Problem 1 is unlikely to be solvable in truly subquadratic time. Indeed, this special case is somewhat related to the Hitting Set problem [1]. We explain next how to solve this problem in parameterized linear time when G is a Helly graph. 6 Theorem 2. If G is Helly then, for every subset A and every positive integer k, we can solve Small Eccentricities in O(km) time. Proof. We reduce the problem to the construction of a partition P k that, for every 1 ≤ j ≤ pk, we have ∩{N k[a] a ∈ Ak j} = V k V k 1 , V k and in such a case Bk = V k the associated sets V k for every aj ∈ A, the corresponding set V 0 to construct P k A = (Ak ) of A such (cid:54)= ∅, and furthermore the sets are pairwise disjoint. Indeed, observe that we have Bk (cid:54)= ∅ if and only if pk = 1, A, and A = A and we are done (notice that is exactly the singleton {aj}). Otherwise, we show how j , in O(km) time. If k = 0, then we set P 0 and the V k−1 1 . It now remains to prove that we can construct the partition P k 's, in linear time. 2 , . . . , V k pk 2, . . . , Ak pk 1, Ak j j j A sets W k we may have W k For that, let us define for every j the new subset W k j := N [V k−1 j takes total linear time as by the hypothesis, the sets V k−1 j ∩ W k A and its associated sets from P k−1 j =(cid:84) j(cid:48) (cid:54)= ∅ for some j (cid:54)= j(cid:48). = (cid:84) {N k[a] a ∈ Ak−1 }. (cid:84) {N k−1[a] a ∈ Ak−1 {N k[a] a ∈ Ak−1 (cid:48) Claim 1. W k Proof. Since we have V k−1 construction. Conversely, let v ∈ Ak−1 pairwise intersect, by the Helly property, N [v] ∩ V k−1 j j j j j j j (cid:84) j ⊆ {N k[a] a ∈ Ak−1 }, we get W k } by } be arbitrary. Since N [v] and N k−1[a],∀a ∈ (cid:5) j(cid:48)'s. For (cid:54)= ∅, proving that v ∈ W k j . j j ]. Notice that constructing the are pairwise disjoint. However, A j(cid:48) ∩ j(cid:48), we u ∈ W k A and the V k j v ∈ W k (cid:84) {W k (cid:84) {W k j } = ∅. j } ⊂ {j(cid:48) s as the union of pairwise disjoint subfamilies of the W k j } is maximized. For any j(cid:48) such that v /∈ W k (cid:54)= ∅ we pick a vertex v ∈ V such that #{j v ∈ W k {Ak−1 We are left with computing the V k j that, we need the following additional result: Claim 2. Let v ∈ V be such that #{j v ∈ W k have W k Proof. Suppose for the sake of contradiction that there exists a vertex u ∈ W k j(cid:48) ∩ Then, we get {j v ∈ W k vertex v. We now proceed as follows in order to compute P k Av :=(cid:83) of sets (at the end of this sub-procedure below, we shall get Fk = (V k P k−1 {N k[a] a ∈ Av} =(cid:84) (cid:84) j v ∈ W k j }. j(cid:48)}. However, the latter contradicts the maximality of (cid:5) j 's. Let Fk be an empty family )). While j } is maximized. We add the new sets A and Fk, respectively. Indeed, such that v ∈ W k j . j } for j 's can be constructed in total linear time, this pre-processing also takes A lists, where ∀i the ith list contains all the vertices that j . Then, starting from i = P k−1 A , if the ith list is empty then i := i − 1. j }. In this latter j ). Since all the subsets Ak−1 j Ak−1 , A , after this step v is no more contained in and so it will never be used again during the sub-procedure. linear time. We create an array of P k−1 case the total running time of the step is in O((cid:80) are in exactly i subsets W k Otherwise, we can pick any vertex v of this list as it maximizes #{j v ∈ W k Overall, the running time is in O((cid:80) ∈ P k−1 j Ak−1 By the above claim, the sets in Fk are pairwise disjoint. every vertex v. Since the W k Finally, in order to construct Fk, during a pre-processing step we compute #{j v ∈ W k jv∈W k j , are subsequently removed from P k−1 j }, in the families P k j v ∈ W k j }. Then, we remove from P k−1 j } and(cid:84) such that v ∈ W k a group W k {W k j v ∈ W k j , for any Ak−1 j ) = O(n + m). 1 , V k 2 , . . . , V k pk every Ak−1 v ∈ W k + W k +W k {W k A A j j j j j j 7 Corollary 2. For any Helly graph G and positive integer k, we can compute the set of all the vertices of eccentricity at most k in O(km) time. Proof. It suffices to apply Theorem 2 with A = V . Using the unimodality of the eccentricity function We stress that using our previous Corollary 2, if the diameter of a Helly graph is sublinear in the number of nodes, then we can compute the eccentricity of all vertices in truly subquadratic time. However, there exist very simple Helly graphs, such as paths, for which the diameter is linear in the number of nodes. For such "giant-diameter" Helly graphs, we next adapt a well-known sampling technique for distance oracles [5]. Recall that a function is called unimodal if every its local minimum is global. It was proved in [26] that the eccentricity function in Helly graphs is unimodal, and that the latter implies the following interesting property: Lemma 4 ([26]). If G is Helly then, for every vertex v, e(v) = dist(v, C(G)) + rad(G). Theorem 3. Let G be a Helly graph such that rad(G) > 3k = ω(log n). Then w.h.p. in O(mn/k) time, we can compute a diametral pair for G. Proof. Let p = c log n/k for some sufficiently large constant c. We construct a subset U (p) where every vertex is included independently with probability p. By Chernoff bounds we have U (p) = O(n/k) w.h.p., and we assume from now on that it is indeed the case. In particular, we can perform a BFS from every vertex in U (p) in O(mn/k) time. Then, we define for every vertex v ∈ V : ¯e(v) := min u∈U (p)dist(u,v)≤k dist(u, v) + e(u) (by convention, we set ¯e(v) = 0 if every vertex of U (p) is at distance > k from v). Note that all the values ¯e(v) can be computed in O(nU (p)) = O(n2/k) time. We now divide our analysis in two cases: • Case e(v) < rad(G) + k. Then, for any u ∈ U (p) such that dist(u, v) ≤ k, we get e(u) ≤ e(v) + k < rad(G) + 2k. Hence, ¯e(v) < rad(G) + 3k ≤ 2 · rad(G) − 1. By Lemma 3, we get that ¯e(v) < diam(G) with probability 1. • Case e(v) ≥ rad(G) + k. Note that in particular, we always fall in this case if v is an end of a diametral path. Let us consider the set Sv of the k first vertices on a fixed shortest path between v and a closest vertex of C(G). By Lemma 4, e(v) = dist(v, C(G)) + rad(G). In particular, for every u ∈ Sv we have e(v) = dist(u, v) + e(u). If v is an end of a diametral path, and furthermore U (p) ∩ Sv (cid:54)= ∅, then this implies ¯e(v) = e(v) = diam(G). Therefore, we are left proving that w.h.p., U (p)∩ Sv (cid:54)= ∅. That is indeed the case since P rob[U (p)∩ Sv = ∅] = (1 − p)Sv = (1 − p)k = (1 − p) p ≤ n−c. c log n Finally, it follows from our above analysis that, w.h.p., a vertex v which maximizes ¯e(v) is an end of a diametral path. Once such an end is computed, we can compute a corresponding diametral pair in linear time, e.g., using BFS. Combining Theorem 2 and Theorem 3, we finally obtain our main result, namely: 8 Theorem 4. A diametral pair in a Helly graph can be computed w.h.p. in O(m√n) time. Proof. Let k = 6(cid:100)√n(cid:101). By Corollary 2 we can compute the set Bk of all the vertices of eccentricity at most k in O(mk) = O(m√n) time. There are now two cases. First assume that Bk = V . We can compute by dichotomic search the smallest d ≤ k such that Bd = V , which is exactly the diameter, in O(m√n) time. Then, a vertex is an end of a diametral path if and only if it is in V \ Bd−1, and by Corollary 2 we can enumerate all such vertices in O(md) = O(m√n) time. Otherwise, Bk (cid:54)= V , and so, diam(G) > k. Note that it implies rad(G) > k/2 ≥ 3√n. By Theorem 3, we can compute a diametral pair of G w.h.p. in time O(mn/√n) = O(m√n). 3 Journey to the Center of C4-free Helly graphs We now improve our results for the class of C4-free Helly graphs. Our results in this section are divided into three parts. In Section 3.1 we first explain how to compute a central vertex, and so the radius, in a C4-free Helly graph. We use this result and other properties in Section 3.2, in order to compute the diameter and a corresponding diametral pair. Finally, all the results in Section 3.1 and Section 3.2 are combined and enhanced in Section 3.3 so as to compute the eccentricity of all vertices. 3.1 Computing a central vertex We start with general properties of Helly graphs and C4-free Helly graphs which we will then use in our analysis. The first such property is a consequence of the unimodality of the eccentricity function in Helly graphs (see [26]). Lemma 5 ([26]). Let G be a Helly graph. Then, for any vertex v of G and any farthest vertex u ∈ F (v) we have L(u, rad(G), v) ∩ C(G) (cid:54)= ∅. Pseudo-modular graphs are exactly the graphs where each family of three pairwise intersecting balls has a common intersection [3]. Clearly, Helly graphs is a subclass of pseudo-modular graphs. Lemma 6 ([3]). For every three vertices x, y, z of a pseudo-modular graph G there exist three shortest paths P (x, y), P (x, z), P (y, z) connecting them such that either (1) there is a common vertex v in P (z, y) ∩ P (x, z) ∩ P (x, y) or (2) there is a triangle (cid:52)(x(cid:48), y(cid:48), z(cid:48)) in G with edge z(cid:48)y(cid:48) on P (z, y), edge x(cid:48)z(cid:48) on P (x, z) and edge x(cid:48)y(cid:48) on P (x, y) (see Fig. 1). Furthermore, (1) is true if and only if d(x, y) = p + q, d(x, z) = p + k and d(y, z) = q + k, for some k, p, q ∈ N, and (2) is true if and only if d(x, y) = p + q + 1, d(x, z) = p + k + 1 and d(y, z) = q + k + 1, for some k, p, q ∈ N. (a) (b) Figure 1: Vertices x, y, z and three shortest paths connecting them in pseudo-modular graphs. The next properties are specific to C4-free Helly graphs. A set S ⊆ V of a graph G = (V, E) is called convex if for every x, y ∈ S, I(x, y) ⊆ S holds. 9 xyzvxyzx′y′z′ Lemma 7 ([23]). Every ball of a C4-free Helly graph is convex. Lemma 8. For every vertices v and u of a C4-free Helly graph G and any integer k ≤ dist(u, v), the set L(u, k, v) is a clique. Proof. Consider any two vertices x, y ∈ L(u, k, v) and assume that they are not adjacent. Let (cid:96) = dist(x, y) ≥ 2. Consider balls N 1[x], N (cid:96)−1[y] and N k−1[u] in G. These balls pairwise intersect. By the Helly property, there must exist a vertex z on a shortest path from x to y which is at distance at most k − 1 from u. As by Lemma 7 the ball N dist(v,x)[v] is convex, z must belong to N dist(v,x)[v]. Thus, dist(u, v) ≤ dist(u, z) + dist(z, v) ≤ k − 1 + dist(v, x) = dist(u, v) − 1, and a contradiction arises. We now introduce an important brick-basis of our approach. The multi-sweep heuristic of Corneil et al. consists in performing a BFS [19], or a variant of it [18], from an arbitrary vertex v, then from a farthest vertex u ∈ F (v) (usually the last one visited), and finally to output e(u) as an estimate of diam(G). On general graphs, there may be an arbitrary gap between diam(G) and the output of this heuristic [18]. However, on many graph classes it gives us a constant additive approximation of the diameter [15, 18, 19, 26]. We now prove that in particular, it is the case for C4-free Helly graphs. Lemma 9. Let G be a C4-free Helly graph with diameter d and radius r. Let s be an arbitrary vertex, v be a vertex most distant from s, and (x, y) be a diametral pair of G. Then, e(v) ≥ d − 2. Furthermore, if e(v) = d − 2, then e(v) = 2r − 3 = dist(v, x) = dist(v, y) and d = 2r − 1. So, in particular, if e(v) is even, then e(v) ≥ d − 1. Proof. By Lemma 3, d is either 2r or 2r − 1. Let (cid:96) = e(s) = dist(s, v). For vertices s, v, x, y of G, we have dist(x, y) = d, dist(s, x) ≤ dist(s, v) = (cid:96), dist(s, y) ≤ dist(s, v) = (cid:96). Furthermore, the three of dist(v, x), dist(v, y) and dist(s, v) = (cid:96) are at most e(v). First we show that, if max{dist(v, y), dist(v, x)} ≤ 2k for some integer k, then d ≤ 2k + 1. By the triangular inequality, we have 2k ≤ 2e(s) = 2(cid:96). Consider balls N (cid:96)−k[s], N k[v], N k[y] in G. As dist(v, y) ≤ 2k and dist(s, y) ≤ (cid:96), those balls pairwise intersect. By the Helly property, there is a vertex a in G belonging to all three balls. Necessarily, dist(a, s) = (cid:96) − k, dist(a, v) = k and dist(a, y) ≤ k. Similarly, we can get a vertex b in G such that dist(b, s) = (cid:96) − k, dist(b, v) = k and dist(b, x) ≤ k. As both a and b are in L(v, k, s), by Lemma 8, dist(a, b) ≤ 1. Thus, d = dist(x, y) ≤ dist(x, b) + dist(b, a) + dist(a, y) ≤ 2k + 1. Now, if e(v) = 2k for some integer k, then max{dist(v, y), dist(v, x)} ≤ e(v) = 2k and, therefore, d ≤ 2k + 1 = e(v) + 1. If e(v) = 2k + 1 for some integer k, then either max{dist(v, y), dist(v, x)} < e(v) = 2k + 1 and hence d ≤ 2k + 1 = e(v) or max{dist(v, y), dist(v, x)} = e(v) = 2k + 1. As in the latter case max{dist(v, y), dist(v, x)} < 2k + 2, we also get d ≤ 2k + 3 = e(v) + 2. In what follows, we consider this case, when e(v) = 2k + 1 = max{dist(v, y), dist(v, x)}, in more details. If d is even (i.e., d = 2r), then d ≤ 2k + 2 and therefore d ≤ e(v) + 1. Assume now that d is odd (i.e., d = 2r − 1) and that d = e(v) + 2 = 2k + 3 = 2r − 1. That is, r = k + 2. We will show that, under these conditions, dist(v, y) = dist(v, x) = 2k + 1 must hold. For that assume w.l.o.g. that dist(v, y) = max{dist(v, y), dist(v, x)} = 2k + 1. Since v ∈ F (s), we have that dist(s, y) ≤ (cid:96) = dist(s, v). Furthermore, by the triangular inequality, we have 2k + 1 ≤ 2e(s) = 2(cid:96), and so (cid:96) ≥ k + 1. We shall use the following intermediate results: 10 • If dist(s, y) = (cid:96) then, by Lemma 6, there is a triangle (cid:52)(v(cid:48), s(cid:48), y(cid:48)) in G such that dist(s, s(cid:48)) = (cid:96) − k − 1, dist(v(cid:48), v) = dist(y, y(cid:48)) = k. Necessarily, v(cid:48) • If dist(s, y) ≤ (cid:96) − 1, consider balls N (cid:96)−k−1[s], N k+1[v], N k[y] in G. As these balls pairwise intersect, by the Helly property, there is a vertex a in G with dist(a, s) = (cid:96)−k−1, dist(a, v) = k + 1 and dist(a, y) = k. That is, a ∈ L(v, k + 1, s). ∈ L(v, k, s) and s(cid:48) ∈ L(v, k + 1, s). • If dist(v, x) ≤ 2k then, as before, we can get a vertex b in G with dist(b, s) = (cid:96)−k, dist(b, v) = k and dist(b, x) ≤ k. Necessarily, b ∈ L(v, k, s). Summarizing, we get the following combinations. If dist(v, y) = 2k + 1, dist(v, x) ≤ 2k and dist(s, y) = (cid:96), then d = dist(x, y) ≤ dist(x, b) + dist(b, v(cid:48)) + dist(v(cid:48), y(cid:48)) + dist(y(cid:48), y) ≤ k + 1 + 1 + k = 2k+2 (notice that, by Lemma 8, dist(b, v(cid:48)) ≤ 1), contradicting with d = 2k+3. If dist(v, y) = 2k+1, dist(v, x) ≤ 2k and dist(s, y) ≤ (cid:96) − 1, then d = dist(x, y) ≤ dist(x, b) + dist(b, a) + dist(a, y) ≤ k + 2 + k = 2k + 2 (notice that, by Lemma 8, dist(b, a) ≤ 2 as a ∈ L(v, k + 1, s) and b ∈ L(v, k, s)), contradicting with d = 2k + 3. Hence, dist(v, x) = 2k + 1 = dist(v, y) must hold. We left open whether the lower-bound of Lemma 9 can be refined to e(v) ≥ d − 1. Note that this would be best possible. Indeed although in some cases of interest, e.g. interval graphs, the output of the multi-sweep heuristic always equals the diameter [25], this nice property does not hold for strongly chordal graphs and so neither for C4-free Helly graphs [18]. Therefore, in Section 3.2 we shall need additional tests in order to decide whether the output of this heuristic equals the diameter (and to compute a diametral pair when it is not the case). Before finally proving the main result of this subsection, we need the following gated property of Helly graphs. The (weak) diameter of a set S is equal to diam(S) := maxx,y∈S dist(x, y). (cid:84) Lemma 10. Let G be a Helly graph and S be a subset of weak diameter at most two. Then, for any v /∈ S there exists a vertex gS(v) ∈ N dist(v,S)−1[v] ∩ {N (x) x ∈ P r(v, S)}. As it is standard [14] we call such a vertex a gate of v, and we denote it by gS(v) -- we will omit the subscript if the set S is clear from the context. Proof. Since S has weak diameter at most two the balls N dist(v,S)−1[v] and N [x],∀x ∈ P r(v, S) pairwise intersect. Therefore, the result follows from the Helly property. Remark 1. For any fixed S as above, we can compute a gate for every vertex v /∈ S in linear time. For that we first run a breadth-first search from S. Then, we recursively assign a gate to every vertex of V \ S, as follows. If v ∈ N (S), then v is its own gate and we set p(v) = N (v) ∩ S. Otherwise, we choose for every vertex v a father u, one step closer to S, that maximizes p(u). Indeed, by induction, p(u) = P r(u, S). Then, we choose for v the same gate as for its father u, and we set p(v) = p(u). We observe that, more generally, if S is an arbitrary vertex-subset (possibly, of weak diameter larger than two), then for every vertex v with a gate in N (S) this above procedure correctly computes such a gate. Indeed, to every vertex v it associates a vertex v∗ ∈ N (S) ∩ I(v, S) which maximizes N (v∗) ∩ S. This observation is crucial in our proof of Theorem 7. We are now ready to improve the result of Theorem 1 for C4-free Helly graphs, as follows: 11 Theorem 5. If G is a C4-free Helly graph then we can compute a central vertex and so rad(G) in linear time. Proof. Let v be an arbitrary vertex, let u ∈ F (v) and let w ∈ F (u). By Lemma 9, e(u) = dist(u, w) ≥ diam(G) − 2. Therefore, by Lemma 3, rad(G) ∈ {(cid:100)e(u)/2(cid:101) ,(cid:100)(e(u) + 1)/2(cid:101) , 1 + (cid:100)e(u)/2(cid:101)} (two of these numbers being equal, it gives us two possibilities). In order to decide in which case we are, we use Lemma 5. Indeed, if rad(G) = r then L(w, r, u) ∩ C(G) (cid:54)= ∅. Further- more, by Lemma 8, this set C = L(w, r, u) is a clique. We compute, for every x /∈ C, its distance dist(x, C) and a corresponding gate g(x) -- which exists by Lemma 10. As observed in Remark 1, it takes linear time. Then, rad(G) = r implies maxx∈V dist(x, C) = r. If so then note that a vertex of C has eccentricity r if and only if it is adjacent to the gate of every vertex at a distance exactly r from C. Overall, in order to compute rad(G) we pick the smallest r such that a vertex of eccentricity r can be extracted from L(w, r, u). 3.2 Computing a diametral pair We base on the results from Section 3.1 so as to prove the following theorem: Theorem 6. If G is a C4-free Helly graph then we can compute a diametral pair and so diam(G) in linear time. Digression: an application to chordal Helly graphs Our results in the paper are proved valid assuming the input graph to be Helly. However, the best- known recognition algorithms for this class of graphs run in quadratic time [40]. In what follows, we first explain an interesting application of Theorem 6 to general chordal graphs. We recall that it can be decided in linear time whether a given graph is chordal [44]. The Lexicographic Breadth-First-Search (LexBFS) [44], of which a description can be found in Fig. 2, is a standard algorithmic procedure that runs in linear time [37]. Figure 2: Algorithm LexBFS [44]. We use the following results on LexBFS in our analysis: Lemma 11 ([25]). Let v be the vertex visited last by an arbitrary LexBFS. If the graph is chordal, then the eccentricity of v is within 1 of the diameter. Lemma 12 ([18]). If the vertex u of a chordal graph G last visited by a LexBFS has odd eccentricity, then e(u) = diam(G). 12 Altogether combined with Theorem 6 we obtain that: Remark 2. Consider an arbitrary chordal graph G. If we assume G to be Helly then, by Theorem 6, there exists a linear-time algorithm for computing a diametral pair of G. Note that, we can apply this algorithm to G without the knowledge that it is Helly, and either the algorithm will detect that G is not Helly (e.g., because some property of Helly graphs does not hold for G) or it will output some pair of vertices (x, y). Furthermore, if G is chordal Helly, then (x, y) is a diametral pair. Let d = dist(x, y).We can check for a chordal graph G whether diam(G) = d, or G is not Helly, as follows: • Let u be the vertex visited last by a LexBFS. We may assume, by Lemma 11, that e(u) ∈ {d − 1, d} (otherwise, d (cid:54)= diam(G), and so G is not Helly) and, by Lemma 12, that e(u) is even. Then, we compute rad(G), which takes linear time [14]. By Lemma 11, diam(G) ∈ {e(u), e(u) + 1}, and so either G is not Helly or, by Lemma 3, rad(G) ∈ {e(u)/2, e(u)/2 + 1}. • If e(u) = d, d is even and rad(G) = d/2, then this certifies that diam(G) = e(u). Else, either G is not Helly or we have e(u) = d − 1, d is odd and rad(G) = e(u)/2 + 1. Since dist(x, y) = d = e(u) + 1, we get diam(G) = d by Lemma 11. Proof of Theorem 6 The remainder of this subsection is now devoted to the proof of Theorem 6. For that, we first compute r = rad(G), which by Theorem 5 can be done in linear time. We also apply the multi- sweep heuristic, i.e., we pick an arbitrary vertex v and we perform a BFS from a vertex u ∈ F (v). There are two main cases depending on the parity of e(u). Case e(u) is even. By Lemma 9, e(u) ≥ diam(G) − 1. Since by Lemma 3 we have diam(G) ≥ 2r−1, it follows that e(u) ∈ {2r−2, 2r}. Note that, in particular, if e(u) = 2r then diam(G) = e(u) and u belongs to a diametral path. Otherwise, diam(G) = e(u) + 1 = 2r − 1. We now explain how to compute a diametral pair in this latter subcase. Let w ∈ F (u). We may assume e(w) = 2r− 2 (otherwise, e(w) > dist(u, w) = e(u) = 2r− 2 and so, w is an end of a diametral pair). In this situation, dist(u, w) = 2r − 2 and u, w are mutually far apart. The next result is a cornerstone of our algorithm: Lemma 13. Let u, w be mutually far apart vertices in a C4-free Helly graph G such that dist(u, w) = diam(G) − 1 = 2r − 2 is even, and let C = L(u, r − 1, w). Then, (x, y) is a diametral pair of G if and only if dist(x, C) = dist(y, C) = r − 1 and P r(x, C) ∩ P r(y, C) = ∅. Proof. Since e(u) = e(w) = 2r − 2, for any x ∈ V , the balls of radius r − 1 and with centers u, w, x, respectively, pairwise intersect. The Helly property implies the existence of a vertex c ∈ V such that max{dist(u, c), dist(w, c), dist(x, c)} ≤ r − 1. Since we also have dist(u, w) = 2r − 2, we conclude that c ∈ L(u, r − 1, w) = C and dist(x, C) ≤ dist(x, c) ≤ r − 1. Now on one direction, let (x, y) be a diametral pair. By Lemma 8, C is a clique, implying dist(x, y) ≤ dist(x, C) + 1 + dist(y, C) ≤ 2r − 1 = diam(G). Therefore, dist(x, C) = dist(y, C) = r − 1. For similar reasons, we must have P r(x, C) ∩ P r(y, C) = ∅ (otherwise, dist(x, y) ≤ dist(x, C) + dist(y, C) ≤ 2r − 2 < diam(G), a contradiction). Conversely, let (x, y) be such that dist(x, C) = dist(y, C) = r − 1 and P r(x, C) ∩ P r(y, C) = ∅. Suppose by contradiction dist(x, y) < diam(G). In particular, the balls of radius r − 1 and respective centers u, v, x, y pairwise intersect. By the Helly property, there 13 exists a c ∈ C such that min{dist(x, c), dist(y, c)} ≤ r − 1 = dist(x, C) = dist(y, C). But then, c ∈ P r(x, C) ∩ P r(y, C) = ∅, a contradiction. Hence, we proved that (x, y) is a diametral pair. ∃x ∈ V such that gC(x) = x∗ Our strategy now consists in computing a pair (x, y) that satisfies the condition of this above Lemma 13. We do so by using the "gated property" of Lemma 10. Indeed, let C = L(u, r − 1, w) be as above defined, and let S = {x∗ ∧ dist(x, C) = r − 1}. Since by Lemma 8 C is a clique, this set S is well-defined and, according to Remark 1, it can be computed in linear time. In order to compute a diametral pair of G, by Lemma 13 it is sufficient to compute a pair x∗, y∗ that promising since it is a particular case of the Disjoint Set problem (sometimes called the monochromatic Orthogonal Vector), that cannot be solved in truly subquadratic time under SETH [48]. Before presenting our solution to this special Disjoint Set problem (i.e., Lemma 16) we introduce an -- optional -- pre-processing so as to simplify a little bit the structure of our problem. For that we need the following lemma: ∈ S such that N (x∗) ∩ N (y∗) ∩ C = ∅. At first glance this approach does not look ∈ P r(t, C) \ P r(s, C). Then, (s, t, t∗, s∗, s) induces a C4. Lemma 14. In a C4-free Helly graph G, for any clique C and adjacent vertices s, t ∈ N (C), the metric projections P r(s, C) and P r(t, C) are comparable, i.e., either P r(s, C) ⊆ P r(t, C) or P r(t, C) ⊆ P r(s, C). Proof. Let s, t ∈ N (C) be adjacent and suppose for the sake of contradiction that there exist ∈ P r(s, C) \ P r(t, C) and t∗ s∗ Let us compute dC(s) := N (s)∩ C for every s ∈ S. It takes linear time. We initialize Sred := S and then we consider the vertices in S sequentially. At the time we consider a vertex s ∈ S, we check whether there exists a t ∈ N (s) ∩ Sred such that dC(t) ≤ dC(s). If it is the case then we remove s from Sred. Indeed, by Lemma 14 it implies N (t) ∩ C = P r(t, C) ⊆ P r(s, C) = N (s) ∩ C. In particular, N (s) ∩ N (z) ∩ C = ∅ =⇒ N (t) ∩ N (z) ∩ C = ∅, and so we can safely discard vertex s. Overall, the resulting subset Sred is a stable set by construction. A graph is split if its vertex-set can be bipartitioned in a clique and a stable set. Note that by construction, the induced subgraph H = G[C ∪ Sred] is a split graph. Computing the diameter of split graphs is already SETH-hard [7]. Fortunately, our split graph H has some additional properties, namely we prove next that it is Helly. Lemma 15. Let u, w be two vertices in a C4-free Helly graph G such that dist(u, w) = 2r − 2, let C = L(u, r − 1, v) and let S ⊆ N (C) be a stable set. Then, H = G[C ∪ S] is a split Helly graph. Proof. By Lemma 8, the subset C is a clique, hence H is a split graph. Furthermore, let us consider a family of pairwise intersecting balls in H. We may assume that no such a ball is equal to NH [c],∀c ∈ C, or N 2 H [s],∀s ∈ S, for all of these fully contain C. In particular, there exists a subset ⊆ S such that the subsets N (z) ∩ C, z ∈ S(cid:48) pairwise intersect. Then, we have that the balls of S(cid:48) radius r − 1 and with centers in u, w and the balls of radius 1 and with centers in the vertices of S(cid:48) ≤ r − 1 from both u and w, and at a distance ≤ 1 from all of S(cid:48). Since dist(u, w) = 2r − 2, we get c ∈ L(u, r − 1, w) = C and so, c ∈ pairwise intersect in G. By the Helly property (applied to G), there exists a vertex c at a distance (cid:84) {N (z) ∩ C z ∈ S(cid:48) }. Consequently, H is Helly. We are now left with computing a diametral pair for split Helly graphs. Actually since every split graph has constant diameter (at most three), then by Corollary 2 the eccentricity of all vertices in a split Helly graph can be computed in total linear time. In what follows, we propose a different 14 approach for computing the diameter of a split Helly graph than the one we presented in Corollary 2. Interestingly, this approach also works for other Helly-type properties, e.g. for split clique-Helly graphs and split open-neighbourhood-Helly graphs [39]. Lemma 16. A diametral pair in a split Helly graph can be computed in linear time. G[(cid:84) 1 2 Proof. Let G = (C ∪ S, E) be a split Helly graph with clique C and stable set S (note that if C and S are not given then they can be computed in linear time [36]). Assume G to be connected and diam(G) > 1 (otherwise, we are done). By the Helly property, diam(G) = 2 if and only if G contains a universal vertex. Furthermore, if it is the case then any pair x, y of non-adjacent vertices is diametral. Hence, from now on we assume that diam(G) = 3. Let G0 := G and let (x1, x2, . . . , xS) be an arbitrary total order of S. For every 1 ≤ i ≤ S, we define Gi := {NG(xj) 1 ≤ j ≤ i} ∪ S]. Our algorithm proceeds the vertices xi ∈ S sequentially, for i = 1 . . .S, and does the following: If xi has eccentricity 3 in Gi−1, then we compute a diametral pair in this subgraph which contains xi and we stop. We claim that our algorithm above is correct. For that we prove by finite induction that for any i ≥ 0, if the algorithm did not stop in less than i steps then: (i) Gi is connected; and (ii) (xp, xq) is a diametral pair of Gi if and only if it is a diametral pair of G. Since G0 = G, this is true for i = 0. From now on we assume i > 0. If the algorithm did not stop at step i then (since in addition Gi−1 is connected by the induction hypothesis), xi has eccentricity two in Gi−1. In particular, every vertex has a common neighbour with xi, implying that there can be no isolated vertex in Gi. We so obtain that Gi is connected. Furthermore, if (xp, xq) is a diametral pair of G then, necessarily, it is also a diametral pair of the connected subgraph Gi (i.e., because xp and xq have no common neighbour in this subgraph, and so they are at distance 3 to each other). Conversely, let (xp, xq) be a diametral pair of Gi. Suppose, by contradiction, that (xp, xq) is not a diametral pair of G, or equivalently NG(xp)∩ NG(xq) (cid:54)= ∅. Since the neighbour sets NG(xj), j ∈ {1, 2, . . . , i}∪{p, q} pairwise intersect, by the Helly property, there exists a vertex w ∈ {NG(xj) j ∈ {1, 2, . . . , i} ∪ {p, q}}. But then, (xp, xq) is not a diametral pair of Gi (as diam(Gi) ≥ diam(G) = 3), a contradiction. As a result, our above algorithm for computing a diametral pair of G is correct. We still have to explain how to execute this algorithm in linear time. For that, we main- tain a partition of the clique, initialized to P0 := (C). At step i we refine the former partition Pi−1 = (Ci−1 \ NG(xi), Ci−1 2 ∩ NG(xi), Ci−1 ki−1 \ NG(xi)). This partition refinement can be done in time O(NG(xi)) (up to some initial pre-processing in O(C) time) [37]. Furthermore, an easy induction proves for any i ≥ 0 that the first group of Pi is exactly Ci {NG(xj) 1 ≤ j ≤ i} i.e., the clique of Gi. We finally explain how we use this partition in order to decide, at step i, whether xi has eccentricity equal to 3 in Gi−1. At the beginning of the algorithm we compute the degree of ev- ery vertex in S. Then, at step i we consider all the vertices in Ci {NG(xj) 1 ≤ j < i}\ NG(xi) sequentially (second group of the partition Pi). For every w ∈ Ci 2 we enumerate all its neighbours in S and we decrease their respective degrees by one. In particular, if during step i the degree of some vertex xp ∈ S falls to 0, then xp has no common neighbour with xi in Gi−1. Equivalently, (xi, xp) is a diametral pair of Gi−1 and the eccentricity of xi, xp in this subgraph is 3. We observe that the sets Ci 2 on which we iterate are pairwise disjoint. As a result, the total complexity of the algorithm is linear. ) into a new partition Pi = (Ci−1 ki−1 ∩ NG(xi), Ci−1 1 =(cid:84) 2 =(cid:84) 2 , Ci−1 , . . . , Ci−1 ki−1 \ NG(xi), . . . , Ci−1 1 ∩ NG(xi), Ci−1 1 (cid:84) This above Lemma 16 achieves proving Theorem 6 in the case when e(u) is even. 15 Case e(u) is odd. By Lemma 9, e(u) ≥ diam(G)−2. Therefore, by Lemma 3, e(u) ∈ {2r−3, 2r− 1}. In the first subcase, we deduce from Lemma 3 that diam(G) = 2r − 1. Furthermore, we can compute a diametral pair as follows. Let w ∈ F (u), and assume e(w) = e(u) = dist(u, w) = 2r − 3 (otherwise, either e(w) = 2r − 2 is even and we are back to the former case, or e(w) = 2r − 1 and then we are done since w is an end of a diametral path). Lemma 17. Let u, w be mutually far apart vertices in a C4-free Helly graph G such that dist(u, w) = diam(G) − 2 = 2r − 3 is odd, and let A = L(w, r − 2, u). Then, (x, y) is a diametral pair of G if and only if dist(x, A) = dist(y, A) = r − 1, P r(x, A) ∩ P r(y, A) = ∅, and in addition dist(y, u) = dist(y, w) = dist(x, u) = dist(x, w) = 2r − 3. Proof. We first prove that for every vertex x we have dist(x, A) ≤ r − 1. Indeed, since w, u are mutually far apart, we have dist(x, u) ≤ dist(w, u) = 2r − 3 and dist(x, w) ≤ dist(w, u) = 2r − 3. Hence, balls N r−1[u], N r−2[w] and N r−1[x] pairwise intersect. By the Helly property, there is a vertex z ∈ A with dist(x, z) ≤ r − 1. For any pair (x, y) we have dist(x, y) ≤ dist(x, A) + dist(P r(x, A), P r(y, A)) + dist(y, A) ≤ 2r− 2+dist(P r(x, A), P r(y, A)). By Lemma 8, A is a clique, which implies dist(P r(x, A), P r(y, A)) ≤ 1. As a result, if (x, y) is diametral, we get dist(x, A) = dist(y, A) = r−1 and P r(x, A)∩P r(y, A) = ∅. We also get dist(y, u) = dist(y, w) = dist(x, u) = dist(x, w) = 2r − 3 by Lemma 9. Conversely let (x, y) be any pair that satisfies all these above properties, and suppose for the sake of contradiction that we have dist(x, y) ≤ 2r − 2. Consider balls N r−1[x], N r−1[y], N r−1[u] and N r−2[w]. By distance requirements, these balls pairwise intersect. The Helly property implies that a vertex z ∈ A exists such that dist(x, z) = r − 1 and dist(y, z) = r − 1. However, the latter contradicts with P r(x, A) ∩ P r(y, A) = ∅. We observe that Lemma 17 is quite the same as Lemma 13 and that the same techniques can be used in order to compute a diametral pair in this subcase. The most difficult subcase is when e(u) = 2r − 1. By Lemma 3, either diam(G) = 2r − 1 or diam(G) = 2r. We explain below how, assuming diam(G) = 2r, we can compute in linear time all central vertices. Then, if diam(G) = 2r, by Lemma 5, a pair (x, y) is diametral if and only if both x and y are at a distance exactly r from all central vertices. In particular, we can pick any such a pair (x, y) and check whether we have dist(x, y) = 2r (otherwise, diam(G) = 2r − 1 and u is an end of a diametral path). Assume w.l.o.g. r ≥ 2 (otherwise, computing a diametral pair is trivial). Lemma 18. If G is a C4-free Helly graph of radius r ≥ 2 and diameter 2r then C(G) is a clique. Proof. Every central vertex is at a distance exactly r from both ends x, y of any diametral path. In particular, C(G) ⊆ L(x, r, y), which is a clique by Lemma 8. Therefore, if diam(G) = 2r, by Lemma 18, for any central vertex c, we have C(G) ⊆ N [c] = S. Note that, by Theorem 5, we can compute such a central vertex c in linear time. Furthermore, diam(S) ≤ 2. For every x /∈ S, we compute dist(x, S) and a corresponding gate g(x), which exists by Lemma 10. Note that, according to Remark 1, it takes linear time. By construction, maxx dist(x, S) ≤ dist(x, c) ≤ r. Furthermore, every vertex at a distance ≤ r− 2 from S is at a distance ≤ r from every vertex of S. As a result, we only need to consider the vertices at a distance ≥ r − 1 from S. In fact, and as already observed in the proof of Theorem 5, for a vertex of S to be central it needs to be adjacent to the gates of all the vertices at a distance 16 exactly r from S. All the vertices which satisfy this necessary condition can be computed in linear time. Hence, we can restrict ourselves to the vertices that are at distance exactly r − 1 from S. Lemma 19. Let G be a C4-free Helly graph and let S be such that diam(S) ≤ 2 and maxx dist(x, S) = r. If dist(x, S) = r−1, then there exists a vertex pgS(x) ∈ N r−1[x] such that S∩N r[x] ⊆ N [pgS(x)]. Moreover, pgS(x) is in the closed neighbourhood of some gate of x. We call such a vertex a pseudo-gate of x. Proof. The existence of such a pseudo-gate follows from the fact that the balls N r−1[x] and N [s], s ∈ S ∩ N r[x] pairwise intersect, and from the Helly property. Now, let pg(x) and g(x) be arbitrary pseudo-gate and gate of x, respectively, and assume pg(x) (cid:54)= g(x) and pg(x)g(x) /∈ E (else, we are done). In particular, pg(x) /∈ P r(x, S). Note that, since we have P r(x, S) ⊆ N (g(x)) ∩ N (pg(x)), dist(g(x), pg(x)) = 2. Then, the balls N r−2[x], N [g(x)] and N [pg(x)] pairwise intersect. By the Helly property, there exists a vertex x∗ in their common intersection. We claim that x∗ is a gate of x, that will prove the lemma. Indeed, for every s ∈ P r(x, S) we get a cycle (s, pg(x), x∗, g(x), s). Since G is C4-free, this implies sx∗ ∈ E. Remark 3. For every x ∈ N (S), we can choose as its pseudo-gate any vertex of N [x] that maxi- mizes the intersection of S with its closed neighbourhood (possibly, x itself ). Then, when we compute a gate for every vertex, we break ties by choosing one such a gate whose pseudo-gate maximizes its intersection with S. In doing so, we can compute a pseudo-gate for every vertex at distance r − 1 from S, in total linear time. Altogether combined if diam(G) = 2r then the central vertices of S are exactly those that are adjacent to the gates of all the vertices at distance exactly r from S and either equal or adjacent to the pseudo-gates of all the vertices at distance exactly r − 1 from S. 3.3 Computing all eccentricities We are now ready to present the main result of this section, namely: Theorem 7. If G is a C4-free Helly graph then we can compute the eccentricity of all vertices in linear time. The remainder of this subsection is devoted to the proof of Theorem 7, or equivalently, by Lemma 4, how to compute C(G) in linear time for a C4-free Helly graph G. Our main tool for that is our parameterized linear-time algorithm for Small Eccentricities, for k = 2 (Theorem 2). In particular, by Corollary 2, we may assume that rad(G) = r ≥ 3. Let (x, y) be a diametral pair. By Theorem 6, it can be computed in linear time. There are two cases, depending on the parity of dist(x, y) = d = diam(G). If d = 2r is even then, by Lemma 18, C(G) ⊆ L(x, r, y) is a clique. We can reuse the same idea as for Theorem 5 in order to extract all the central vertices from L(x, r, y) in linear time (see also Section 3.2, Subcase e(u) = 2r − 1, for a more complicated method which does not need the pre-computation of a diametral pair). From now on we assume d = 2r− 1 is odd. Obviously, C(G) ⊆ N r[x]∩ N r[y]. Since dist(x, y) = 2r − 1 we get N r[x] ∩ N r[y] = L(x, r − 1, y) ∪ L(y, r − 1, x) ∪ Z, where Z := {z ∈ V dist(z, x) = dist(z, y) = r}. Furthermore, for a C4-free Helly graph, by Lemma 8 the slices L(x, r − 1, y) and 17 L(y, r − 1, x) are cliques; again we can reuse the same idea as for Theorem 5 in order to extract all the central vertices in these two disjoint sets in linear time. Note that, by Lemma 5, there must be at least one such central vertex in both cliques. From now on we focus on Z. Claim 3. Every vertex z ∈ Z has two adjacent neighbours in L(x, r − 1, y) and L(y, r − 1, x), respectively. Proof. Let p = q = r−1 and k = 0. We have dist(x, y) = p+q+1, dist(x, z) = p+k+1, dist(y, z) = q + k + 1. Since G is pseudo-modular, by Lemma 6, z is adjacent to the two ends of an edge in the middle of some shortest xy-path. (cid:5) This above claim has many important consequences. The first one is that, since both L(x, r− 1, y) and L(y, r − 1, x) are cliques, Z has weak diameter at most 3 ≤ r. Furthermore, still by Claim 3, every vertex of Z is at a distance ≤ 2 < r from all the vertices of L(x, r − 1, y) ∪ L(y, r − 1, x). As a result, in order to decide whether a vertex of Z is central, we only need to consider its distances to the vertices outside of N r[x] ∩ N r[y]. Note that in particular, every vertex at a distance ≤ r − 2 from L(x, r− 1, y)∪ L(y, r− 1, x) is at a distance ≤ r from every vertex of Z. Therefore, we further restrict our study to the vertices w such that dist(w, L(x, r − 1, y) ∪ L(y, r − 1, x)) ≥ r − 1. Recall that, by Lemma 5, we have L(x, r− 1, y)∩ C(G) (cid:54)= ∅ and similarly L(y, r− 1, x)∩ C(G) (cid:54)= ∅. Hence, dist(w, L(x, r − 1, y) ∪ L(y, r − 1, x)) ∈ {r − 1, r}. Subcase dist(w, L(x, r − 1, y) ∪ L(y, r − 1, x)) = r − 1. Let C := L(x, r − 1, y) and consider the set W of all vertices w such that dist(w, L(x, r − 1, y) ∪ L(y, r − 1, x)) = dist(w, C) = r − 1 (the subcase when dist(w, L(y, r − 1, x)) = r − 1 is symmetric to this one). Let A contain a gate gC(w) for every w ∈ W , which exists by Lemma 10. Recall that the set A can be computed in linear time (see Remark 1). Claim 4. For every z ∈ Z, we have maxw∈W dist(z, w) ≤ r if and only if A ⊆ N 2[z]. Proof. First assume that ∀a ∈ A, N [a]∩N [z] (cid:54)= ∅. Let w ∈ W be arbitrary and let a := gC(w) ∈ A. Then, dist(z, w) ≤ dist(z, a) + dist(a, w) ≤ 2 + (r − 2) = r. Conversely, let us assume that we have maxw∈W dist(z, w) ≤ r, and let w ∈ W be arbitrary. The balls N r−1[x], N r−1[w], N r[y], N [z] pairwise intersect. Therefore, by the Helly property, N [z]∩ P r(w, C) (cid:54)= ∅. For any gate gC(w) ∈ A, it implies N [z] ∩ N [gC(w)] ⊇ N [z] ∩ P r(w, C) (cid:54)= ∅. (cid:5) Overall with this above claim we are reduced to Small Eccenttricities, with k = 2, which by Theorem 2 can be solved in linear time. Subcase dist(w, L(x, r − 1, y) ∪ L(y, r − 1, x)) = r. Let W contain all vertices w such that dist(w, L(x, r − 1, y) ∪ L(y, r − 1, x)) = r. We will need the following properties of this subset W . Claim 5. For every w ∈ W we have dist(x, w) = dist(y, w) = 2r − 1 and dist(w, Z) = r − 1. Moreover, P r(w, Z) = L(w, r − 1, x) ∩ L(w, r − 1, y) is a clique. Proof. We first prove that dist(x, w) = dist(y, w) = 2r − 1. contradiction that dist(x, w) ≤ 2r − 2. Since the balls N r−1[x], N r−1[w], N r[y] pairwise intersect, by the Helly property, we get dist(w, L(x, r − 1, y)) ≤ r − 1, a contradiction. Hence, the balls N r−1[w], N r[x], N r[y] pairwise intersect, which implies, by the Helly property, dist(w, Z) = r − 1. Indeed, suppose for the sake of 18 (cid:84) In this situation, we have P r(w, Z) = L(w, r − 1, x) ∩ L(w, r − 1, y). By Lemma 8, P r(w, Z) is a clique. (cid:5) The combination of this above claim with Lemma 10 implies the existence of a gate gZ(w) ∈ N r−2[w] ∩ {N (v) v ∈ P r(w, Z)} for every vertex w ∈ W . Note that we can compute the gate of all such vertices w in linear time, by using our classical BFS method in order to compute all the gates (see Remark 1). -- Incidentally, this algorithm will also associate a vertex gZ(v) to every v /∈ W , but the latter may not be a gate of v. -- So, let A contain a gate gZ(w) for every vertex w ∈ W . We prove as before: Claim 6. For every z ∈ Z, we have maxw∈W dist(z, w) ≤ r if and only if A ⊆ N 2[z]. Proof. We can prove this above condition to be sufficient for having maxw∈W dist(z, w) ≤ r in the exact same way as we did for Claim 4. Conversely, let us assume that we have maxw∈W dist(z, w) ≤ r, and let w ∈ W be arbitrary. The balls N [z], N r−1[w], N r[x], N r[y] pairwise intersect, and so, by the Helly property, N [z] ∩ P r(w, Z) = N [z] ∩ (L(w, r − 1, x) ∩ L(w, r − 1, y)) (cid:54)= ∅. It implies that N [z] ∩ N [gZ(w)] ⊇ N [z] ∩ P r(w, Z) (cid:54)= ∅. (cid:5) We are done by reducing a final time to Small Eccentricities, with k = 2, which by Theorem 2 can be solved in linear time. 4 More reductions to split graphs We conclude by considering diameter computation within another class than Helly graphs, namely chordal graphs. This is motivated by our results in Section 3.2 where we reduced the problem of computing a diametral pair on chordal Helly graphs to the same problem on split Helly graphs. We prove next that there exists a (randomized) reduction from diameter computation on general chordal graphs to the same problem on split graphs. by its sparse representation. For a split graph H with stable set U we define (cid:96)(H) :=(cid:80) The sparse representation of a split graph is the list of the closed neighbourhoods of vertices in its stable set [30]. The Disjoint Set problem consists in computing the diameter of a split graph given u∈U degH (u), a.k.a. the size of its sparse representation. Theorem 8. For any chordal graph G, we can compute in linear time the sparse representations of a family (Hi) of split graphs such that: • If for every i we can compute diam(Hi) in time O(E(Hi)a · V (Hi)), then we can compute diam(G) in time O(m1+a); • If for every i we can compute diam(Hi) in time O((cid:96)(Hi) · V (Hi)b), then we can compute diam(G) in time O(mnb). An interesting byproduct of our reduction, proved in Section 4.4, is that we can approximate in quasi linear time the eccentricity of all vertices in a chordal graph with a one-sided additive error of at most one. This answers an open question from [27]. Finally, in Section 4.5 we give another application of Theorem 8 to chordal graphs of constant VC-dimension. 19 4.1 Preliminaries We shall use the following metric properties of chordal graphs. We stress that these are quite similar to some metric properties of C4-free Helly graphs that we proved in Section 3. Lemma 20 ([14]). For any clique C in a chordal graph G, we can compute in linear time the {I(x, w) w ∈ P r(x, C)} adjacent to all vertices from distance dist(x, C) and a gate g(x) ∈ P r(x, C), for all vertices x. (cid:84) Lemma 21 ([14]). In a chordal graph G, for any clique C and adjacent vertices s, t /∈ C the metric projections P r(s, C) and P r(t, C) are comparable, i.e., either P r(s, C) ⊆ P r(t, C) or P r(t, C) ⊆ P r(s, C). 4.2 The reduction Our reduction is one-to-many. We recall that a clique-tree of a graph G is a tree T of which the nodes are the maximal cliques of G, and such that for every vertex v the set of all the maximal cliques that contain v induces a connected subtree. It is known [4] that G is chordal if and only if it has a clique-tree and, furthermore, a clique-tree can be computed in linear time. C. Then, let w(T ) := (cid:80) We may see a clique-tree T as a node-weighted tree where, for any maximal clique C, w(C) = C w(C). For a chordal graph, w(T ) = O(n + m) [4]. We will use a standard result on weighted centroids in trees, namely: Lemma 22 ([35]). Every node-weighted tree T has at least one weighted centroid, that is, a node v whose removal leaves components of maximum weight ≤ w(T )/2. Moreover, a weighted centroid can be computed in linear time. T \ {S}, and for every 1 ≤ i ≤ (cid:96) let Vi := ((cid:83) V (Ti)) \ S. It is known [4] that the sets V1, V2, . . . , V(cid:96) Let T be a fixed clique-tree of G. If T is reduced to a single node, or to exactly two nodes, respectively (equivalently, either G is a complete graph or it is the union of two crossing complete subgraphs), then we output diam(G) = 1, or diam(G) = 2, respectively (base case of our reduction). Otherwise, let S ∈ V (T ) be a weighted centroid of T . By Lemma 22, the clique S can be computed in time O(n) if we are given T in advance. Furthermore, let T1, T2, . . . , T(cid:96) be the components of are exactly the connected components of G \ S. Since ∀i, NG(Vi) ⊆ S is a clique, the closed neighbourhoods NG[Vi], 1 ≤ i ≤ (cid:96) induce distance-preserving subgraphs of G, which we denote by G1, G2, . . . , G(cid:96). We apply our reduction recursively on each of these subgraphs Gi. Then, let dS := maxvi∈Vi,vj∈Vji(cid:54)=j dist(vi, vj). We have: diam(G) = max{dS, max{diam(Gi) 1 ≤ i ≤ (cid:96)}}. We are left with computing dS. For that, we define ∀i, di := maxvi∈Vi dist(vi, S). We order the sets Vi by non-increasing value of di. Since S is a clique, we get d1 + d2 ≤ dS ≤ d1 + d2 + 1. In order to decide in which case we are, we proceed as follows: • We discard all sets Vi such that di < d2. Doing so we are left with sets V1, V2, . . . , Vk, k ≤ (cid:96). • Then, for every 1 ≤ i ≤ k and v ∈ Vi, if dist(v, S) = di then we compute a gate for vertex v, which exists by Lemma 20. Furthermore, if two such gate vertices are adjacent then they must be in the same connected component of G\ S, and by Lemma 21 their respective metric 20 projections on S are comparable. It implies that we can remove any of these two vertices with largest metric projection on S (see Section 3.2 for a similar idea on C4-free Helly graphs). Thus, from now on, we assume all selected gate vertices to be pairwise non-adjacent. • Finally, let a, b /∈ V be fresh new vertices which we make adjacent to each other and to all vertices of S. There are two subcases: make vertex b adjacent to all gates of the vertices in(cid:83)k -- Case d1 (cid:54)= d2. We make vertex a adjacent to all gates of the vertices in V1, while we i=2 Vi. -- Case d1 = d2. For every 1 ≤ i ≤ k, with probability 1/2 we make vertex a adjacent to all gates of the vertices in Vi (otherwise, we do so with vertex b). Doing as above we get a split graph H whose clique and stable set are S ∪ {a, b} and the selected gate vertices, respectively. Claim 7. If diam(H) = 3 then dS = d1 + d2 + 1. Conversely, if dS = d1 + d2 + 1 then diam(H) = 3 with probability ≥ 1/2. Proof. On one direction, let x∗ and y∗ be two gate vertices such that distH (x∗, y∗) = 3. By construction of H, we have that x∗, y∗ are the respective gates of two vertices x, y such that min{distG(x, S), distG(y, S} ≥ d2. Furthermore, since {a, b} ∩ (NH (x∗) ∩ NH (y∗)) = ∅, we get that x, y are in different components of G \ S, and {distG(x, S), distG(y, S} = {d1, d2}. Hence, dS ≥ dist(x, y) ≥ d1 + d2 + 1. On the other direction, let us assume the existence of a pair (x, y) such that: x and y are in different connected components of G \ S, and dist(x, y) = d1 + d2 + 1. Without loss of generality, let dist(x, S) = d1 and dist(y, S) = d2. Let also x∗, y∗ be the two gates computed for x and y, respectively (we may assume, without loss of generality, that x∗, y∗ are indeed in the stable set of H). We must have NH (x∗) ∩ NH (y∗) ⊆ {a, b}. In particular, if d1 (cid:54)= d2 then NH (x∗) ∩ NH (y∗) = ∅, else P rob[NH (x∗) ∩ NH (y∗) = ∅] ≥ 1/2. (cid:5) Overall, we may repeat the construction of this above split graph H up to O(log n) times in order to compute dS with high probability. 4.3 Analysis Since at every step of our reduction we pick a weighted centroid in the clique-tree of every subgraph Gi considered, there are O(log w(T )) = O(log n) recursion levels. Therefore, up to polylogarithmic factors, the total running-time of the reduction is of the same order of magnitude as the worst-case running time of a single step. Furthermore, it is not hard to prove that the first step, when we only consider the full input graph G, runs in linear time (i.e., omitting the computation of the diameter for the related split graph H). However, during the next steps of our reduction we may need to consider pairwise overlapping subgraphs Gi, thereby making the analysis more delicate. The key insight here is that the clique-trees of all these subgraphs form a family of pairwise disjoint subtrees of T . We next explain how to perform the first step, and so all subsequent ones, in time O(w(T )). Since w(T ) = O(n + m) [4], doing so we can compute all the desired split graphs H throughout our reduction in total quasi linear time O(n + m). Lemma 23. Let S be any clique of a chordal graph G. If a clique-tree T is given, then in time O(w(T )) we can compute ∀v /∈ S, dist(v, S) and a corresponding gate g(v). 21 Proof. Let C := V (T ) ∪ {S} be the set of all maximal cliques of G, to which we also add the clique S if it is not maximal. We define a set of fresh new vertices indexed by C, namely let XC := {xC C ∈ C}. Then, let J := (V ∪ XC,{vxC v ∈ C}) be the vertex-clique incidence graph of G. Note that we can construct J by scanning once the clique S and all the maximal cliques of G. We prove as a subclaim that for every vertex v we have distJ (v, xS) = 2·distG(v, S)+1. Indeed, since by construction NJ (xS) = S, we get distJ (v, xS) = 1 + minu∈S distJ (v, u) = 1 + distJ (v, S). Furthermore, in every vS-path of J, that is in every path between v and a closest vertex of S, half of the internal vertices must be in XC. Since in addition two vertices that are adjacent to a same maximal clique in J are adjacent in G, it allows us to transform such a path in J to a vS-path in G that is twice shorter. Conversely, any vS-path of G can be transformed into a vS-path of J that is twice longer, simply by adding between every two consecutive vertices a maximal clique which contains both of them. -- Note that combining the two constructions, the latter exactly characterizes the shortest vS-paths in J. -- As a result, we proved as claimed that distJ (v, S) = 2 · distG(v, S). It implies that after a BFS in J rooted at xS we get distG(v, S),∀v /∈ S. Then, we recursively define p(α),∀α ∈ V (J)\ NJ [xS] as follows (recall that NJ [xS] = {xS}∪ S): if α = xC for some C ∈ C\{S}, and C ∩ S (cid:54)= ∅ (equivalently, distJ (xS, α) = 2), then p(α) = C ∩ S; otherwise, p(α) = max{p(β) β ∈ NJ (α) ∩ IJ (xS, α)}. Note that, we can compute all those values p(α) during a BFS with no significant computational overhead. Furthermore, we claim that ∀v ∈ V, p(v) = P rG(v, S). Indeed, by induction, p(v) = max{C ∩ S xC ∈ XC ∩ IJ (v, S)}. We recall our earlier characterization of the shortest vS-paths in J as those obtained from the shortest vS-paths in G by adding a maximal clique between every two consecutive vertices. As a result, p(v) is the number of vertices in S that are at distance exactly distG(v, S) from v, that is exactly P rG(v, S). J [xS] = S∪{xC C ∩ S (cid:54)= ∅}): if α ∈ V and α ∈ NG(S) (equivalently, distJ (xS, α) = 3), then g(α) = α; otherwise, g(α) ∈ {g(β) β ∈ NJ (α) ∩ IJ (xS, α) ∧ p(α) = p(β)}. Again, we can compute all those values g(α) during a BFS with no significant computational overhead. Furthermore, it also follows from our characterization of shortest vS-paths in J that we have, ∀v /∈ S, g(v) is a gate of v. Lemma 24. For a clique-tree T of a given chordal graph G, let H be the split graph constructed as in Section 4.2. The sparse representation of the split graph H can be computed in O(w(T )) time. Furthermore, if U ⊆ V (H) is the stable set of H, then U = O(V (T )) and (cid:96)(H) = O(w(T )). Proof. After Lemma 23, we need to select a subset of pairwise non-adjacent gates in order to construct U . For that, we consider all the maximal cliques C sequentially. If C contains at least two gates, then we suppress all the gates in C but one with minimum metric projection on S. Overall, this post-processing also takes time O(w(T )). Doing so there is at most one gate selected C C = w(T ). We end up adding a, b and the edges incident to these two vertices and the stable set U , that takes total time O(U) = O(V (T )). per maximal clique, i.e., U ≤ V (T ). Furthermore, we have (cid:96)(H) =(cid:80) u∈U degH (u) ≤ Finally, we recursively define g(α),∀α ∈ V (J)\N 2 J [xS] as follows (recall that N 2 (cid:80) Finally, in order to complete the proof of Theorem 8, let (Hi) be the family of split graphs considered for a given recursive step of the reduction. • Let us assume that for every i, we can compute diam(Hi) in O(E(Hi)a · V (Hi)) time. By construction, maxi E(Hi) = O(m + n). Furthermore, by Lemma 24, the gate vertices in the 22 stable sets of Hi sum up to O(V (T )) = O(n). Since, in addition, the maximal cliques of the split graphs Hi are pairwise different maximal cliques of G (each augmented by two new i V (Hi) = O(w(T )) = O(m). As a result, computing diam(Hi) for all i vertices), we get(cid:80) time. By Lemma 24,(cid:80) takes total time O(m1+a). • In the same way let us assume that for every i, we can compute diam(Hi) in O((cid:96)(Hi)·V (Hi)b) i (cid:96)(Hi) = O(w(T )) = O(n + m). Furthermore, maxi V (Hi) ≤ n. As a result, computing diam(Hi) for all i takes total time O(mnb). 4.4 Application: Approximating all eccentricities It was proved in [27] that for all chordal graphs, an additive +2-approximation of all eccentricities can be computed in total linear time. Using our previous reduction from Section 4.2, we improve this result to an additive +1-approximation, but at the price of a logarithmic overhead in the running time. Theorem 9. For every n-vertex m-edge chordal graph, we can compute an additive +1-approximation of all eccentricities in total O(m log n) time. The remainder of Section 4.4 is devoted to the proof of this above theorem. For that, we need to carefully revisit the reduction from Section 4.2. In what follows, let G be chordal and let T be a fixed clique-tree of G. We can assume that G has at least two vertices. • If T is reduced to a single node, or equivalently, G is a complete graph, every vertex has eccentricity equal to 1. In the same way if T is reduced to exactly two nodes, then G is the union of two crossing complete subgraphs C1 and C2. Furthermore, every vertex of C1 ∩ C2 has eccentricity equal to 1, whereas every vertex of the symmetric difference C1∆C2 has eccentricity equal to 2. • Otherwise, let S ∈ V (T ) be a weighted centroid of T . By Lemma 22, the clique S can be computed in time O(V (T )) = O(w(T )) if we are given T in advance. ((cid:83) V (Ti)) \ S. We recall [4] that the sets V1, V2, . . . , V(cid:96) are exactly the connected -- Let T1, T2, . . . , T(cid:96) be the components of T \ {S}, and for every 1 ≤ i ≤ (cid:96) let Vi := components of G \ S, and that the closed neighbourhoods NG[Vi], 1 ≤ i ≤ (cid:96) induce distance-preserving subgraphs of G. As in Section 4.2, we denote these subgraphs by G1, G2, . . . , G(cid:96). We apply our reduction recursively on each of these subgraphs Gi. Doing so, for every i and every vertex vi ∈ Vi we get an additive +1-approximation of eGi(vi). -- Then, for every vertex v /∈ S, we compute distG(v, S) and a gate gS(v). By Lemma 23 this can be done in total O(w(T )) time if T is given in advance. Furthermore, notice that since S is a clique, for every s ∈ S we have that maxv∈V distG(v, S) is an additive +1-approximation of eG(s). -- Finally, we observe that for every i and every vertex vi ∈ Vi we have: eG(vi) = max{eGi(v), max u /∈Vi distG(vi, u)}. As in Section 4.2 we define ∀i, di := maxvi∈Vi dist(vi, S). If we compute the two largest values amongst the di's, then we can compute ∀i, ei := maxj(cid:54)=i dj. We are done as for every vi ∈ Vi, distG(vi, S) + ei is an additive +1-approximation of maxu /∈Vi distG(vi, u). 23 As already observed in Section 4.3, there are O(log w(T )) = O(log n) recursion levels. Since at any level, the clique-trees of all the subgraphs considered form a family of pairwise disjoint subtrees of T , each step can be done in O(w(T )) time. Therefore, the total running time is in O(w(T ) log n) = O(m log n) [4]. 4.5 Application to chordal graphs of constant VC-dimension The VC-dimension of a graph G is the largest cardinality of a subset S such that {N [v] ∩ S v ∈ V } = 2S (we say that S is shattered by G). For instance, interval graphs have VC-dimension at most two [9]. We now apply the reduction of Theorem 8 so as to prove the following result: Theorem 10. For every d > 0, there exists a constant ηd ∈ (0; 1) such that in O(mn1−ηd) time, we can compute the diameter of any chordal graph of VC-dimension at most d. Proof. If a split graph H has VC-dimension at most d(cid:48), then we can compute its diameter in truly subquadratic time O((cid:96)(H) · V (H)1−εd(cid:48) ), for some εd(cid:48) ∈ (0; 1) [31, Theorem 1]. As a result it is sufficient to prove that all the split graphs Hi, which are output by the reduction of Theorem 8, have a VC-dimension upper bounded by a function of d. We observe that every such Hi is obtained from an induced subgraph H(cid:48) i of G by adding two new vertices a and b (see Section 4.2). Since G has VC-dimension at most d, so does H(cid:48) i. Then, let S be a largest subset shattered by Hi. We can extract from S a maximal shattered subset S(cid:48) i) (i.e., not containing a and b). In particular, S(cid:48) ≥ S − 2. Furthermore, since S(cid:48) is shattered by Hi, {N [v] ∩ S(cid:48) holds. It implies that {N [v] ∩ S(cid:48) − 2. By the Sauer-Shelah-Perles d), which implies S(cid:48) Lemma [45, 47], we also have {N [v] ∩ S(cid:48) = O(d log d). Consequently, every Hi has VC-dimension in O(d log d). i) = V (Hi) \ {a, b}} ≥ 2S(cid:48) i)} = O(S(cid:48) v ∈ V (Hi)} = 2S(cid:48) v ∈ V (H(cid:48) ⊆ V (H(cid:48) v ∈ V (H(cid:48) We left open whether there exist other subclasses of chordal graphs for which we can use our techniques in order to compute the diameter in truly subquadratic time. References [1] A. Abboud, V. Vassilevska Williams, and J. Wang. Approximation and fixed parameter sub- In SODA, pages 377 -- 391. quadratic algorithms for radius and diameter in sparse graphs. SIAM, 2016. [2] H. Bandelt and V. Chepoi. Metric graph theory and geometry: a survey. Contemporary Mathematics, 453:49 -- 86, 2008. [3] H. Bandelt and H. Mulder. Pseudo-modular graphs. Discrete mathematics, 62(3):245 -- 260, 1986. [4] J. Blair and B. Peyton. An introduction to chordal graphs and clique trees. In Graph theory and sparse matrix computation, pages 1 -- 29. 1993. [5] B. Bollob´as, D. Coppersmith, and M. Elkin. Sparse distance preservers and additive spanners. SIAM Journal on Discrete Mathematics, 19(4):1029 -- 1055, 2005. [6] J. A. Bondy and U. S. R. Murty. Graph theory. 2008. 24 [7] M. Borassi, P. Crescenzi, and M. Habib. Into the square: On the complexity of some quadratic- time solvable problems. ENTCS, 322:51 -- 67, 2016. [8] G. Borradaile and E. Chambers. Covering nearly surface-embedded graphs with a fixed number of balls. Discrete & Computational Geometry, 51(4):979 -- 996, 2014. [9] N. Bousquet, A. Lagoutte, Z. Li, A. Parreau, and S. Thomass´e. Identifying codes in hereditary classes of graphs and VC-dimension. SIAM Journal on Discrete Mathematics, 29(4):2047 -- 2064, 2015. [10] N. Bousquet and S. Thomass´e. VC-dimension and Erdos -- P´osa property. Discrete Mathematics, 338(12):2302 -- 2317, 2015. [11] A. Brandstadt, V. Chepoi, and F. Dragan. The algorithmic use of hypertree structure and maximum neighbourhood orderings. DAM, 82(1-3):43 -- 77, 1998. [12] K. Bringmann, T. Husfeldt, and M. Magnusson. Multivariate analysis of orthogonal range searching and graph distances parameterized by treewidth. In IPEC, 2018. [13] S. Cabello. Subquadratic algorithms for the diameter and the sum of pairwise distances in planar graphs. ACM TALG, 15(2):21, 2018. [14] V. Chepoi and F. Dragan. A linear-time algorithm for finding a central vertex of a chordal graph. In ESA, pages 159 -- 170. Springer, 1994. [15] V. Chepoi, F. Dragan, B. Estellon, M. Habib, and Y. Vax`es. Diameters, centers, and ap- proximating trees of δ-hyperbolic geodesic spaces and graphs. In SocG, pages 59 -- 68. ACM, 2008. [16] V. Chepoi, F. Dragan, and Y. Vax`es. Center and diameter problems in plane triangulations and quadrangulations. In SODA'02, pages 346 -- 355, 2002. [17] V. Chepoi, B. Estellon, and Y. Vax`es. Covering planar graphs with a fixed number of balls. Discrete & Computational Geometry, 37(2):237 -- 244, 2007. [18] D. Corneil, F. Dragan, M. Habib, and C. Paul. Diameter determination on restricted graph families. DAM, 113(2-3):143 -- 166, 2001. [19] D. Corneil, F. Dragan, and E. Kohler. On the power of BFS to determine a graph's diameter. Networks: An International Journal, 42(4):209 -- 222, 2003. [20] D. Coudert, G. Ducoffe, and A. Popa. Fully polynomial FPT algorithms for some classes of bounded clique-width graphs. ACM TALG, 15(3), 2019. [21] P. Damaschke. Computing giant graph diameters. In IWOCA, pages 373 -- 384. Springer, 2016. [22] R. Diestel. Graph Theory, 4th Edition, volume 173 of Graduate texts in mathematics. Springer, 2012. [23] F. Dragan. Domination in quadrangle-free Helly graphs. Cybernetics and Systems Analysis, 29(6):822 -- 829, 1993. 25 [24] F. Dragan and F. Nicolai. LexBFS-orderings of distance-hereditary graphs with application to the diametral pair problem. DAM, 98(3):191 -- 207, 2000. [25] F. Dragan, F. Nicolai, and A. Brandstadt. LexBFS-orderings and powers of graphs. In WG, pages 166 -- 180. Springer Berlin Heidelberg, 1997. [26] F. F. Dragan. Centers of graphs and the Helly property. PhD thesis, Moldova State University, 1989. [27] F. F. Dragan. An eccentricity 2-approximating spanning tree of a chordal graph is computable in linear time. Information Processing Letters, 2019. [28] A. Dress. Trees, tight extensions of metric spaces, and the cohomological dimension of cer- tain groups: a note on combinatorial properties of metric spaces. Advances in Mathematics, 53(3):321 -- 402, 1984. [29] G. Ducoffe. A New Application of Orthogonal Range Searching for Computing Giant Graph Diameters. In SOSA, 2019. [30] G. Ducoffe, M. Habib, and L. Viennot. Fast diameter computation within split graphs. To appear in COCOA'19. [31] G. Ducoffe, M. Habib, and L. Viennot. Diameter computation on H-minor free graphs and graphs of bounded (distance) VC-dimension. Technical Report 1907.04385, arXiv, 2019. To appear in SODA'20. [32] D. Eppstein. Diameter and treewidth in minor-closed graph families. Algorithmica, 27(3- 4):275 -- 291, 2000. [33] A. Farley and A. Proskurowski. Computation of the center and diameter of outerplanar graphs. DAM, 2(3):185 -- 191, 1980. [34] P. Gawrychowski, H. Kaplan, S. Mozes, M. Sharir, and O. Weimann. Voronoi diagrams on planar graphs, and computing the diameter in deterministic O(n5/3) time. In SODA, pages 495 -- 514. SIAM, 2018. [35] A. Goldman. Optimal center location in simple networks. Transportation science, 5(2):212 -- 221, 1971. [36] M. Golumbic. Algorithmic graph theory and perfect graphs, volume 57. Elsevier, 2004. [37] M. Habib, R. McConnell, C. Paul, and L. Viennot. Lex-BFS and partition refinement, with applications to transitive orientation, interval graph recognition and consecutive ones testing. TCS, 234(1-2):59 -- 84, 2000. [38] J. Isbell. Six theorems about injective metric spaces. Commentarii Mathematici Helvetici, 39(1):65 -- 76, 1964. [39] V. Le, A. Oversberg, and O. Schaudt. A unified approach to recognize squares of split graphs. Theoretical Computer Science, 648:26 -- 33, 2016. 26 [40] M. Lin and J. Szwarcfiter. Faster recognition of clique-Helly and hereditary clique-Helly graphs. IPL, 103(1):40 -- 43, 2007. [41] J. Matousek. Bounded VC-dimension implies a fractional Helly theorem. Discrete & Compu- tational Geometry, 31(2):251 -- 255, 2004. [42] S. Olariu. A simple linear-time algorithm for computing the center of an interval graph. International J. of Computer Mathematics, 34(3-4):121 -- 128, 1990. [43] L. Roditty and V. Vassilevska Williams. Fast approximation algorithms for the diameter and radius of sparse graphs. In STOC, pages 515 -- 524. ACM, 2013. [44] D. Rose, R. Tarjan, and G. Lueker. Algorithmic aspects of vertex elimination on graphs. SIAM J. on computing, 5(2):266 -- 283, 1976. [45] N. Sauer. On the density of families of sets. Journal of Combinatorial Theory, Series A, 13(1):145 -- 147, 1972. [46] S. Sen and V. Muralidhara. The covert set-cover problem with application to Network Discov- ery. In International Workshop on Algorithms and Computation (WALCOM), pages 228 -- 239. Springer, 2010. [47] S. Shelah. A combinatorial problem; stability and order for models and theories in infinitary languages. Pacific Journal of Mathematics, 41(1):247 -- 261, 1972. [48] R. Williams. A new algorithm for optimal 2-constraint satisfaction and its implications. TCS, 348(2-3):357 -- 365, 2005. 27
1808.04360
2
1808
2018-11-30T19:28:16
Stochastic on-time arrival problem in transit networks
[ "cs.DS", "eess.SY", "math.OC", "stat.AP" ]
This article considers the stochastic on-time arrival problem in transit networks where both the travel time and the waiting time for transit services are stochastic. A specific challenge of this problem is the combinatorial solution space due to the unknown ordering of transit line arrivals. We propose a network structure appropriate to the online decision-making of a passenger, including boarding, waiting and transferring. In this framework, we design a dynamic programming algorithm that is pseudo-polynomial in the number of transit stations and travel time budget, and exponential in the number of transit lines at a station, which is a small number in practice. To reduce the search space, we propose a definition of transit line dominance, and techniques to identify dominance, which decrease the computation time by up to 90% in numerical experiments. Extensive numerical experiments are conducted on both a synthetic network and the Chicago transit network.
cs.DS
cs
Stochastic on-time arrival problem in transit networks Yang Liua,∗, Sebastien Blandinb, Samitha Samaranayakea aSchool of Civil and Environmental Engineering, Cornell University, Ithaca, NY 14853 bIBM Research, Singapore 8 1 0 2 v o N 0 3 ] S D . s c [ 2 v 0 6 3 4 0 . 8 0 8 1 : v i X r a Abstract This article considers the stochastic on-time arrival problem in transit networks where both the travel time and the waiting time for transit services are stochastic. A specific challenge of this problem is the combinatorial solution space due to the unknown ordering of transit line arrivals. We propose a network structure appropriate to the online decision-making of a passenger, including boarding, waiting and transferring. In this framework, we design a dynamic programming algorithm that is pseudo-polynomial in the number of transit stations and travel time budget, and exponential in the number of transit lines at a station, which is a small number in practice. To reduce the search space, we propose a definition of transit line dominance, and techniques to identify dominance, which decrease the computation time by up to 90% in numerical experiments. Extensive numerical experiments are conducted on both a synthetic network and the Chicago transit network. Keywords: Stochastic routing, Dynamic programming, Optimal policy, Dominance condition 1. Introduction People navigate over 1 billion kilometers a day using mobile routing services (Townsend 2017), and many of these services provide travelers with information on transit networks. In most of such applications, given an origin-destination (OD) pair and a desired departure or arrival time, the route associated with the minimum expected trip time is provided to the user. However, the uncertainty associated with these recommendations, either due to variability in travel time or the transit service headway, is rarely accounted for. In contrast, a number of surveys and numerical studies have highlighted that the degree of risk aversion This manuscript version is made available under Accepted manuscript for Transportation Research Part B, https://doi.org/10.1016/j.trb.2018.11.013 c(cid:13)2018. ∗Corresponding author Email addresses: [email protected] (Yang Liu), [email protected] (Sebastien Blandin), the CC-BY-NC-ND 4.0 license http://creativecommons.org/licenses/by-nc-nd/4.0/ [email protected] (Samitha Samaranayake) of transit passengers highly affects their route choices (Szeto et al. 2011), even more so than in the road networks. In this work, we attempt to bridge this gap by formulating and solving the Stochastic On-time Arrival (SOTA) problem for transit networks, which provides a transit routing policy that maximizes the probability of reaching the destination within a given travel time budget in stochastic transit networks. A vast majority of previous studies on routing problems in stochastic transportation net- works aim to identify the route or adaptive policy with the least expected travel time (LET) (Loui 1983, Hall 1986, Polychronopoulos and Tsitsiklis 1996, Miller-Hooks and Mahmassani 2000, Waller and Ziliaskopoulos 2002, Fan et al. 2005a, Gao and Chabini 2006, Huang and Gao 2012, Yang and Zhou 2014, Chen et al. 2014). While the expected travel time is a natural optimality metric, there exists a variety of situations where it is not sufficient, and tail statistics must be considered; for instance, travelers who want to catch a flight are more concerned with arriving on time with a high probability rather than with minimizing their expected travel time (Yang and Zhou 2017). To account for these contexts, other formula- tions that consider a reliable optimal path have been proposed, starting with Frank (1969). In this formulation, the goal is to find the path that maximizes the probability of realizing a travel time smaller than some desired time budget. This definition is subsequently extended to the online context in Fan et al. (2005b), and is commonly referred to as the Stochastic On-Time Arrival (SOTA) problem. In the SOTA problem, the weight of each network link is a random variable with a known probability density function that represents the travel time of the link. The solution to the SOTA problem is a routing policy that maximizes the probability of arriving at the destination within a specified time budget. Here the routing policy is an adaptive solution that determines the routing decision at each node based on the realization of the travel time experienced en-route up to that point. Given the complexity of the SOTA problem, significant efforts have been made to design efficient solution algorithms. Fan and Nie (2006) formulate it as a dynamic programming problem and use a standard successive approximation (SA) procedure. This approach, how- ever, has no finite bound on the maximum number of iterations needed for convergence in networks with loops. In Samaranayake et al. (2012a,b), the authors propose a label-setting algorithm to resolve this issue, exploiting the fact that there is always a non-zero minimum realizable travel time on each link in road networks. To further reduce the computation time, Sabran et al. (2014) modify two deterministic shortest path preprocessing techniques: reach (Gutman 2004) and arc-flags (Bauer and Delling 2009, Hilger et al. 2009), and apply them to the SOTA problem. Other studies (Nikolova et al. 2006, Nie and Wu 2009, Parmen- tier and Meunier 2014, Niknami and Samaranayake 2016) explore computationally efficient solution strategies for providing reliability guarantees in stochastic shortest path problems, where a fixed route (as opposed to a policy) is desired. In transit networks, the problem of determining a set of reliable travel decisions is signif- icantly more complex than in road networks. In this context, the traveler is not in control of the transit line(s) that they may travel on to reach the destination, and may have to make a number of complex decisions regarding which transit line(s) to take. This complexity arises from the following characteristics of transit systems. 2 • Uncertainty of arrival times/headways: While the uncertainty in road networks is limited to the travel time, in transit networks one also needs to consider the un- certainty of arrival times and headways. Whether to take a transit line that arrives at a station or wait for a potentially faster service that is yet to arrive depends on the probabilistic trade-off between the extra waiting time and potential travel time savings. Therefore, computing the solution also requires modeling and solving for the headway distributions. • Combinatorial choice set: In road networks, it never pays off to idle at a node and delay the departure from the node in hopes of improving the probability of arriving at the destination on time. However, in transit networks, it may be advantageous to not take the first transit line that arrives at the station (that can get you to your destination) and wait for a better option (e.g. wait for an express train or a more direct bus line). Therefore, a passenger needs to choose between multiple transit lines sharing segments of routes, and the decision regarding which transit line to board at a station depends on the unknown future arrival order of the candidate transit lines, which is an exponentially large set in the number of candidate (feasible) lines at each station, and leads to a combinatorial choice set. Previous research on transit routing problems typically simplifies the problem by assum- ing that passengers board the first arriving transit service from an attractive line set that is precomputed to minimize the expected total travel time (Spiess and Florian 1989, Cominetti and Correa 2001, Nonner and Laumanns 2014, Li et al. 2015). Under this assumption, the passenger is committed to a transit line set. However, the traveler does not need to make a boarding decision until a transit vehicle is about to depart (Hickman and Bernstein (1997)), and it can be meaningful to adapt decisions based on information learned (uncertainties that are realized) during the trip. Fortunately, the role of online information has been noted re- cently in multiple studies. Gentile et al. (2005) propose a frequency-based assignment model under the assumption that the arrival time of the next transit vehicle is available once the passenger arrives at a transit station and demonstrate the potential benefits of utilizing such information. Instead of assuming full information, Chen and Nie (2015) propose a routing strategy in a transit network with partial online information at the stations. The partial on- line information represents that the arrival time of the incoming transit vehicles is available only for a subset of the candidate transit lines. Oliker and Bekhor (2018) develop a transit assignment model which considers two types of available information (partial information and full information), and demonstrate the impact of online information on assignment re- sults. In our work, we consider the routing problem in transit networks as a fully online problem. The online information setting mentioned above can be easily adopted into our framework by changing the travel time and headway distributions accordingly. The aim of this article is to formulate the SOTA problem for transit networks and develop efficient algorithms to solve it in this setting. The specific contributions of the work include: • The formulation of the SOTA problem for transit networks, including a general net- work structure for stochastic transit networks and a decision-making model. Both 3 the waiting time for each transit line and the travel time on each link are assumed to be random variables with known probability density functions. The solution is an adaptive policy that fully considers the transit specific characteristics of the problem mentioned above. • The design of a dynamic programming (DP) algorithm, which is pseudo-polynomial in the number of transit stations and time budget, and exponential in the number of transit lines at each station, which is practically a small number. To reduce the search space, we develop a definition of transit line dominance and present methods to identify this transit line dominance, which significantly decreases the computation time in our numerical experiments. • Extensive experiments in a synthetic network and in the Chicago transit network, which show the potential for solving this problem in a real-time route planning appli- cation setting. We also propose a general procedure to generate travel time, headway, waiting time distributions from General Transit Feed Specification (GTFS) data. The rest of this article is organized as follows. In Section 2, we formulate the mathe- matical problem, in particular, we describe the network model and the underlying decision- making framework. In Section 3, we introduce a dynamic programming based approach to solve the problem, as well as the complexity analysis of the algorithm. In Section 4, we provide a series of algorithmic techniques to reduce the search space. Section 5 consists of numerical results on the computational performance and practical efficiency of the model and algorithms introduced in this work, both in a synthetic network and in the Chicago tran- sit network. Finally, in Section 6, we provide closing remarks and discuss possible directions for future research. 2. Problem formulation. 2.1. Problem description In this section, we extend the SOTA problem definition to the context of transit net- works. In this setting, as mentioned previously, two types of random variables need to be considered: the travel time between two transit stations and the waiting time for each transit line arrival at each transit station. The objective of the SOTA problem for transit networks is to find the routing (boarding, alighting and transferring) policy that maximizes the probability of arriving at the destination within a time budget. For conciseness, in the remainder of the article, we use utility to represent the probability of arriving at the des- tination within the remaining time budget, but note that the framework can be extended to other functions, and to robust settings (Flajolet et al. 2017). The routing policy here includes the boarding, alighting and transferring decisions at each transit station in different situations (time already spent waiting at a station, arrival order of transit services, etc). The following modeling assumptions are made. 4 Assumption 1. Passengers' arrivals are independent of the transit schedule. This assumption models a situation where the transit service is frequency-based (not schedule-based) and passengers do not adjust their specific departure times based on the transit schedule. This is a standard assumption made in the literature (Gentile et al. 2005, Li et al. 2015). In modern services, transit vehicles' positions may be published in real-time (even for frequency-based services), and thus passenger arrivals may be correlated with the bus schedule. The formulation can be adapted to account for this by changing the travel time distribution and waiting time distribution accordingly. Assumption 2. Only the first arrival from each transit line (after the passenger enters the station) is considered as a candidate in the choice set. This assumption is made for both modeling and algorithmic reasons: • Guiding the passenger to ignore the first arrival from a particular line, but board the second arrival from that same transit line makes the routing direction confusing; • Without this assumption, it is possible for the passenger to have to make an infinite number of decisions in the theoretical worst case (albeit with vanishing probability). The passenger may not be able to board certain transit services (especially during rush hour or after a major event), if the transit service is full and has no remaining capacity. However, since we do not have data about the occupancy of each transit vehicle, the capacity of each transit service is not considered in our study. Note that this is not a disadvantage of our framework because given the data for the occupancy of transit vehicles, we should be able to define the waiting time to be the waiting time for the first arrival transit service that the passenger can board, and our framework can then be adapted to use these distributions without any changes. Assumption 3. No two transit services can arrive at the transit station at the same time. Without loss of generality, two events never occur at exactly the same time in the contin- uous setting. In the subsequent discretized form of the problem, this assumption translates to no two transit services arriving at a transit station during the same discretized time interval1. 2.2. Transit network representation We consider a directed graph G(V, E), in which V is the set of nodes and E is the set of links. We model the transit stations with three types of nodes: • Station nodes: A station node denoted by SX y station y for the set of candidate transit lines X. represents a passenger waiting at 1While the optimality of the solution relies on this assumption, if two lines arrive in the same time interval in practice, the algorithm can closely approximate the solution by considering the two cases of one arriving before the other. 5 • Arrival nodes: An arrival node denoted by Ai,X represents transit line i arriving first at station y among all the candidate lines in X ∪ {i}, and transit lines j ∈ X having not arrived yet, since the passenger arrives at the station. y • Line nodes: A line node denoted by Li y represents the passenger boarding transit line i at station y. Figure 1: Network representation of a transit station served by two transit lines. All the links and nodes within the dashed line rectangle are used to model the decision-making at a single physical station. The set of station nodes, arrival nodes and line nodes are VS, VA and VL respectively. Without loss of generality, the OD is selected from the station nodes to model a passenger starting their trip from a station node in the waiting state. Give a passenger in a waiting state at a station node with m candidate transit lines, it is possible for any of the m lines to arrive first. In each of these situations, the passenger either boards the transit line that arrives or continues waiting for other candidate lines. Passengers make decisions that max- imize their utility. We categorize links as follows: • Arrival links: Links from station nodes to arrival nodes. • Riding links: Links from line nodes to arrival nodes. • Boarding links: Links from arrival nodes to line nodes. • Alighting links: Links from arrival nodes to station nodes. Figure 1 illustrates the network representation of the decision-making process at a transit station with two transit lines. A passenger starting the trip physically at station 1 starts the trip at station node S1,2 in the model. If transit line 1 arrives first, the passenger moves to 1 6 1. Otherwise, the passenger moves to line node L1 the corresponding arrival node A1,2 1 . The passenger has to decide to either board this transit line or continue to wait for line 2. If the passenger continues waiting, the passenger moves to station node S2 1. All the links and nodes within the dashed line rectangle are used to model the decision-making at a single physical station. This network model allows for transfers. For instance, a passenger having boarded line 1 at station S0 (the station preceding station S1) is able to get to station node S2 1 and wait for the next arrival of line 2. The link costs in the network are defined as follows. A riding link (i, j) is associated with a travel time distribution pi,j(·). A boarding link has no cost, since it refers to an instantaneous event. An arrival link is associated with a waiting time distribution wj y(θ, r), characterizing the probability density for the waiting time being θ for transit line j at station y, given that the passenger has already waited at the station for r units of time. Note that θ is the waiting time on top of r, and models transit line j arriving at station y after a total waiting time of (r + θ) since the passenger arrives at the station. Therefore, wj y(θ, 0) is the original waiting time distribution when the passenger arrives at the station. Research has shown that empirical headway data fit better with Loglogistic, Gamma and Erlang distributions than the exponential distribution (Li et al. 2015). Therefore, we do not assume that the waiting time distribution is memoryless (as some other studies do), and use the following rule to normalize the waiting time distribution given r: wj y(θ, r) = 1 −(cid:82) r wj y(r + θ, 0) 0 wj y(α, 0)dα 0 ≤ θ ≤ T − r, 0 < r ≤ T (1) with T being the total time budget when the passenger begins the trip. In Section 2.3, we discretize the time-space to solve the problem numerically. In the discretized space, we force the waiting time to be at least one unit of the discretized time interval. Therefore, the waiting time equation reads as follows. wj y(θ, r) = 1 −(cid:80)r wj y(r + θ, 0) 0 wj can save computation time in practice by precomputing and storing 1 −(cid:82) r Although the waiting time distribution is a 2-D array, as explained in Section 3.2, we y(α, 0)dα for y(α, 0)dα 0 wj 1 ≤ θ ≤ T − r, 0 < r ≤ T (2) each r after we discretize the time-space. 2.3. The SOTA problem for transit networks In this section, we describe how to compute the utility functions of the passenger at the different types of nodes in the model. The utility at a node i is a function of the remaining time budget t when the passenger arrives at the node, denoted by ui(t). The utility function at the destination node D is: uD(t) = 1 0 ≤ t ≤ T since the passenger has completed the trip when at node D. 7 2.3.1. Line nodes Recall from Figure 1 that a line node only contains an outgoing edge to an arrival node. Assume that the line node we are considering is i and the following arrival node is j. The travel time on link (i, j) is a random variable θ, and the remaining time budget at node j is t− θ. Therefore, the utility at line node i is a function of the remaining time budget t when the passenger arrives at the node, denoted by ui(t). Definition 1. The utility function at a line node i can be computed as follows. (cid:90) t 0 ui(t) = E (uj(t − θ)) = θ pi,j(θ) · uj(t − θ)dθ,∀i ∈ VL, (i, j) ∈ E, 0 ≤ t ≤ T where j ∈ VA is the subsequent arrival node of line node i. This utility function is analogous to the standard utility function of the SOTA problem for road networks. 2.3.2. Arrival nodes All the routing decisions occur at arrival nodes, since the passenger is faced with the decision of either boarding the transit line that arrives first (selecting the subsequent line node) or continuing to wait for the other candidate transit lines (selecting the corresponding station node). Let Ai,X (t, r) be the utility when the passenger has a remaining time budget t and has already waited at the station for r units of time. We call the tuple (t, r) the passenger state. Since the passengers aim to maximize the utility, the utility at an arrival node is the maximum of the utilities at the subsequent line node and station nodes. y be the arrival node of interest, and uAi,X y Definition 2. The utility function at an arrival node Ai,X y with passenger state (t, r) is: uAi,X y (t, r) = j∈VL(Ai,X y 2.3.3. Station nodes max ,j)∈E; SX y ∈VS(Ai,X y {uj(t), uSX y (t, r)} y )∈E ,SX Station nodes are followed only by arrival nodes, and the utility at a station node is the expectation of the utility at the following arrival nodes. An arrival node is defined by the first arriving transit line and the corresponding passenger state. Let (i, θ) be a random event which represents that transit line i is the first arriving transit line, and the waiting time for it is θ. Assume that SX is the station node of interest, and that we want to compute (t, r). For each 0 ≤ θ ≤ t, the probability of the transit line i arriving the first after y uSX waiting θ units of time is wi y(α, r) dα). In this case, the passenger has (t − θ, θ + r). waited θ + r units of time in total, and the utility at this arrival node is uAi,X\i y(θ, r) · (cid:81) (1 −(cid:82) θ 0 wj j∈X\i y y 8 Definition 3. The utility function at a station node is: (t, r) = E uSX y (uAi,X\i y (cid:90) t (t − θ, θ + r)) y(θ, r) · (cid:89) wi (1 − 0 j∈X\i (i,θ) (cid:88) i∈X = (cid:90) θ 0 y(α, r)dα) · uAi,X\i wj y (t − θ, θ + r)dθ  This utility is the weighted average of the utility at the corresponding arrival nodes. The integrals in the above equations do not have closed form expressions and cannot be solved analytically. Therefore, they need to be integrated numerically by discretizing the time horizon into small intervals. In the discretized model, we assume that no two transit lines can arrive at the same transit station at the same discretized time interval. As a consequence, the solution not guaranteed to be optimal, since there is a small (non-zero) probability that two lines might arrive at the same time interval regardless of how small the discretization is. However, we can set the length of time intervals to be a small number in practice2. Given a fixed time discretization, the discrete form of the utility function at station node reads as follows. Definition 4. The discrete form of the utility function at station nodes is:  t(cid:88) θ=1 (cid:88) i∈X (cid:89) (1 − θ(cid:88) j∈X\i α=0 wi y(θ, r) y(α, r)) · uAi,X\i wj y (t − θ, θ + r)  uSX y (t, r) = . The utility function for other types of nodes can be discretized similarly. Example 1. Here we show a simple example that shows the sophisticated decision-making process that the model allows. Assume that the passenger is waiting at a station with three candidate transit lines. Table 1 is the waiting time distribution for each transit line, and the utility of taking the transit line corresponding to the waiting time. Figure 2 shows the optimal decision based on the arrival order. We can observe that: (1) The transit line that first arrives is not always the optimal choice. When transit line 3 arrives at time 2, it is the first transit service that arrives. However, it is optimal for the passenger to not board, and continue to wait; (2) Even when it is optimal to not board a transit line at an arrival event, the event may impact the future optimal decisions, as illustrated by the differing policies following the arrival or non-arrival of transit line 3 at time 2. 2In the experiments, we set the time interval length to be 15 seconds. Using this time interval length, the average probability of multiple buses arriving at the same time interval for each station is about 0.6% in the Chicago transit network we use in numerical experiments. For a particular OD, this probability is usually lower since the candidate bus line set is a subset. 9 Table 1: The waiting time and utility distribution for example 1. Transit line ID Waiting time Probability Utility 1 2 3 1 3 10 5 15 2 6 0.05 0.05 0.90 0.90 0.10 0.50 0.50 0.90 0.80 0.00 0.85 0.00 0.70 0.60 Figure 2: The optimal boarding decision corresponding to the transit line arriving order for example 1. The number in each decision node (board and wait) represents the decision's utility. Note that arrival events for which boarding is never optimal are ignored in the figure (e.g. the arrival of transit line 1 at time 3 following the non-arrival of transit line 3 at time 2). 3. Solving the SOTA problem for transit networks In this section, we describe how to solve the discrete time version of the SOTA problem for transit networks. We first show how the problem can still (even in the transit setting) be solved using a dynamic programming approach, then present a complexity analysis of the algorithm, and finally in Section 4 describe a number of search space pruning methods designed to make the problem tractable in practice. 3.1. Dynamic programming approach In Samaranayake et al. (2012b), a label-setting algorithm for the SOTA problem is developed by exploiting the fact that each link in a road network has a positive minimum 10 realizable travel time. This fact guarantees that there will be no loops in the network with zero travel time, and thus allows for a dynamic programming approach for solving the problem. However, in the transit network representation proposed in the previous section, there are links with zero minimum realizable travel time. Claim 1. In the transit network representation introduced in Section 2, there is no loop with a zero realizable travel time. Proof. Only the links starting from the arrival nodes can have zero minimum realizable time. To form a loop, the passenger has to first get to an arrival node from some other type of node, which is not an arrival node. The links originating from all other types of nodes have (cid:4) a positive minimum realizable travel time, so a zero travel time loop is not possible. Therefore, we can still use a dynamic programming approach to solve the SOTA problem for transit networks. Each sub-problem in the dynamic program can be defined by (i, t, r) where i is the node that we consider, t and r have the same definition as in Section 2. Let OPT(i, t, r) denote the utility at node i when the passenger has a time budget of t and has waited at the station for r units of time. Note that the OPT(i, t, r) satisfies the Bellman's Principle of Optimality, i.e., the remaining decisions only depend on the current state and are not related to the past states and decisions. According to the definitions in Section 2, we claim that OPT(i, t, r) satisfies the following recurrence relation:  1 0 t(cid:88) 0 (cid:88) i∈X  t(cid:88) θ=1 pi,j(θ) · OPT(j, t − θ, 0) j∈VL(Ai,X y max ,j)∈E; SX y ∈VS(Ai,X y (cid:89) y )∈E ,SX (1 − θ(cid:88) j∈X\i α=0 if i is the destination if t < 0 if i is a line node and (i, j) ∈ E if i is arrival node Ai,X y if i is station node SX y  OPT(i, t, r) = {OPT(j, t, 0), OPT(SX y , t, r)} wi y(θ, r) y(α, r)) · OPT(Ai,X\i wj y , t − θ, θ + r) (3) The initial problem we wish to solve is given by (O, T, 0), i.e., the passenger is at the origin node O with time budget T and has waited for zero units of time. The algorithm first initializes the utility function corresponding to the destination node to 1 and computes all the normalized waiting time distributions that are needed in the subsequent computation. Then, the utility at each node is updated in a dynamic programming fashion according to the recurrence relation given in Equation 3. 3.2. Complexity analysis The runtime of the algorithm is pseudo-polynomial in the number of stations in the transit network and time budget, and exponential in the number of transit lines at any station. We first provide the number of nodes of all three types. Then, we analyze the time complexity for computing the utility on each type of node. 11 Claim 2. For a station with m transit lines, there are i) m line nodes, ii) nodes, and iii) i · C i m arrival nodes. m(cid:80) i=1 m(cid:80) i=1 C i m station Proof. i) For every transit line, there is a corresponding line node. Therefore, there are m line nodes in total. ii) For each combination of transit lines representing the non-empty set of lines yet to arrive, there is a station node. Therefore, there are C i m station nodes in total. iii) For each station node, any transit line can be the line arriving the first and yield (cid:4) an associated arrival node. Therefore, there are i · C i m arrival nodes. m(cid:80) i=1 m(cid:80) i=1 We now analyze the time complexity of the algorithm for a transit network with a station set Y and each station has no more than m transit lines. Let My be the set of transit lines at station y. The algorithm first computes all the normalized waiting time distributions that are needed in the subsequent computation, which takes O(Y ·m·T 3) time based on Equation 1. y(α, 0),∀θ ≤ T, y ∈ Y, j ∈ My, which decreases the time complexity to O(Y · m · T 2). In our implementation, we use O(Y · m· T ) memory to store 1−(cid:80)θ α=0 wj Claim 3. For a station set Y in which each station has no more than m transit lines, the time complexity of computing the utility functions for a time budget of T is: • O(Y · m · 2m−1 · T 2) for all arrival nodes, • O(Y · (m2 − m) · 2m−2 · T 3) for all station nodes. m(cid:80) i · C i Proof. Based on Definition 2, we need to update the utility functions at each arrival node for each possible remaining time budget t and each waiting time r. In addition, based on O(Y · m(cid:80) (cid:80)t θ=1 wi i=1 Claim 2, there are m arrival nodes for a station with m transit lines, so it takes m · T 2) = O(Y · m · 2m−1 · T 2) time to compute the utility at all the arrival i=1 i · C i y α=0 wj y . To compute USX y(θ, r)(cid:81) Assume that the station node of interest is SX j∈X\i(1−(cid:80)θ nodes. (t, r), for each transit line i ∈ X, we need to compute the probability of line i arriving among all lines in X, which is y(α, r)) according to Definition 4. Therefore, for each i ∈ X and passenger state (t, r), we need O((X − 1) · T 2) to compute the above probabilities. Based on Definition 4, we need to update the utility functions at each station node for m(cid:80) each possible remaining time budget t and each waiting time r. Consequently, we need O(X·(X−1)·T 4) to update the utility functions for each station node in total. According m station nodes for a station with m transit lines. Therefore, it to Claim 2, there are m· i· (i− 1))· T 4) = O(Y · (m2− m)· 2m−2· T 4) time to compute the utility at all the station nodes, without re-using any information. We find that the probability of takes O(Y · m(cid:80) (C i C i i=1 i=1 12 station y, which appears in Definition 4 reads: 1 −(cid:80)θ implementation, we use O(Y · m · T ) memory to store 1 −(cid:80)θ y(α, r) = 1−(cid:80)r+θ transit line j arriving after α time given that the passenger has already waited r time at 1−(cid:80)r . In our y(α, 0),∀θ ≤ T, y ∈ Y, j ∈ My. Then, the time complexity for computing utility for all station nodes becomes O(Y · m2 · 2m · T 3). (cid:4) In summary, the time complexity of the algorithm is O(Y · m2 · 2m · T 3). Considering that there is a constant maximum number of transit lines at a station, the time complexity is O(Y · T 3), which leads to a pseudo-polynomial time algorithm in Y and T . α=0 wj α=0 wj α=0 wj y(α,0) y(α,0) α=0 wj 4. Search space reduction Although the DP approach is a pseudo-polynomial time algorithm in Y and T , the computation time can still be high in large-scale networks when T is large. Therefore, we propose some search space reduction techniques to further decrease the computation time in practice. 4.1. Eliminate the infeasible paths The simplest pruning technique we employ is to eliminate infeasible paths, i.e., paths that have zero probability of being used based on the minimum realizable travel time on each link. This pruning can be performed by simply running a shortest path search on a modified graph where the link weight is the minimum realizable travel time, to find the shortest path distance from each station to the destination. Assume that the minimum realizable travel time from station y to the destination is αy. The utility for any node at station y given a time budget smaller than αy will be zero. This method is similar to the pruning method in Samaranayake et al. (2012b) for road networks. Since the complexity of the shortest path algorithm is dominated by the com- plexity of the SOTA problem, the cost of the pruning method is negligible compared to the total computation time. 4.2. Search space reduction using transit line dominance To compute the utility at an arrival node, we need to compare the utility of boarding the transit service (line node) and continuing to wait (station node). In this section, we propose a definition of transit line dominance, and a set of computationally efficient conditions to check for such dominance. This allows us to save the computation for the utility of the corresponding station node in the case of a dominating line node. 4.2.1. Dominance definition and properties Definition 5. Assume that the passenger is at node Ai,X line i dominates X if uLi and i ≺ X to represent that i does not dominate X. y (t) ≥ uSX\i y y with passenger state (t, r). Transit (t, r). We use i (cid:23) X to represent that i dominates X, 13 According to the definition, if i (cid:23) X, the passenger should board the transit line i; If i ≺ X, the passenger should continue to wait for the transit lines in X. We now propose a useful claim that will be used in the proof of the dominance properties that we propose later. Claim 4. Assume that the passenger is at station y with passenger state (t, r). uSX uSX(cid:48) (t, r),∀X(cid:48) ⊃ X. y y (t, r) ≤ Proof. The passengers in our system are utility maximizers. Therefore, more transit line (cid:4) choices will make the utility of the station node increase or remain the same. Property 1. Assume that the passenger is at station y with passenger state (t, r). If i (cid:23) X, then i (cid:23) X(cid:48),∀X(cid:48) ⊂ X. Correspondingly, if i ≺ X, then i ≺ X(cid:48),∀X(cid:48) ⊃ X. Proof. We prove the first part of the claim. The second part can be proved using similar y (t) ≥ reasoning. Assume that the passenger is at station y. According to Definition 5, uLi (t, r) based on Claim 4. uSX (cid:4) Therefore, uLi (t, r) if i (cid:23) X. In addition, for any X(cid:48) ⊂ X, uSX(cid:48) (t, r), and thus i (cid:23) X =⇒ i (cid:23) X(cid:48),∀X(cid:48) ⊂ X. (t, r) ≤ uSX y (t) ≥ uSX(cid:48) y y y y y y (t) ≥ uLj If (t), then: (1) i (cid:23) X for any X such that j (cid:23) X; (2) j ≺ X(cid:48) for any X(cid:48) Property 2. Assume that the passenger is at station y with passenger state (t, r). uLi such that i ≺ X(cid:48). Proof. For (1), if j (cid:23) X, then uLj dominance. Since uLi y (t) ≤ uSX represents j ≺ X(cid:48). (t, r) according to the definition of transit line (t, r), which proves that i (cid:23) X. (t, r), which (cid:4) For (2), as i ≺ X(cid:48), uLi y (t) ≥ uSX y (t) ≥ uLj y (t) ≥ uLj (t), we derive uLi (t) ≤ uSX (t) ≥ uSX (t, r). Since uLi y (t), uLj y y y y y y y According to the two properties above, we can infer transit line dominance based on the transit line dominance that we already know. Therefore, at an arrival node Ai,X y with passenger state (t, r), if we can infer i (cid:23) X from the known dominance, we can reduce the computation for uSX (t, r). y 4.2.2. Dominance conditions In this section, we present a series of conditions that can be assessed efficiently, and are practically useful to reduce the number of utility computations at station nodes. The conditions are considered at arrival nodes in order. The first dominance condition is a subproblem pruning technique. If the condition is satisfied, we do not need to compute the utility at the corresponding station node at this specific passenger state. Proposition 1. (Subproblem pruning) Assume that the passenger is at node Ai,X senger state (t, r). If uLi (t − 1)}, then i (cid:23) X. y (t) ≥ max j∈X {uLj y y with pas- 14 y Proof. The utility function is a nondecreasing function with respect to the time budget, i.e., (t − 1) ≥ uLj (t, r) is a weighted average of uLj (t(cid:48)) for t(cid:48) ≤ t and j ∈ X where the sum of the weight is not larger than 1. Therefore, if uLj (cid:4) the condition is satisfied, uLi (t(cid:48)),∀t(cid:48) ≤ t − 1,∀j ∈ X. In addition, uSX (t, r) =⇒ i (cid:23) X. y (t) ≥ uSX y y y y Proposition 1 needs O(m) time to be checked. The intuition is as follows: Assume that we know all the transit lines in X will arrive right after i arrives. If boarding the transit line i under this assumption has a larger utility than waiting for the rest, then boarding the transit line i also has a larger utility than waiting for the rest without the assumption (i.e. the transit lines in X might arrive later). If Proposition 1 cannot prove that i (cid:23) X, then we need to compute uSX (t, r) explicitly. We show next that, in some cases, we can safely remove some transit lines in X and only consider a subset of the candidate transit lines. Before we propose this candidate set pruning technique, we first provide the following definition of improving lines that will be used later on. y Definition 6. Assume that the passenger is at station y with passenger state (t, r). Transit line k improves line j at station y if uS (t, r) > uS (t, r). {k,j} y {j} y A sufficient and necessary condition for transit line k improving line j at station y is given as follows. (t − γ − θ)). y with passenger state (t, r). Line k Claim 5. Assume that the passenger is at node Ai,X improves line j if there exists some state (t − γ, r + γ) such that uLk γ) · uLj Proof. If there exists a passenger state (t−γ, r+γ) satisfying the condition above in Claim 5, the passenger should board k when it arrives at state (t − γ, r + γ) instead of continuing to wait for j. Therefore, the utility at the station node with {k, j} is larger than the utility at (cid:4) station node with only line j. (t − γ) > y(θ, r + (wj θ=1 y y t−γ(cid:80) Now, we propose the candidate set pruning technique as follows. (t, r), we can instead compute uSX(cid:48) y with (t − 1)}. When we compute (t, r) where X(cid:48) ⊆ X and X(cid:48) = Z ∪ {j ∈ X Proposition 2. (Candidate set pruning) Assume that the passenger is at node Ai,X passenger state (t, r). Let Z = {j ∈ X uLi uSX j improves at least one line in Z}. Proof. Let K = X\X(cid:48). Since no line in K improves the lines in Z, it is never better to (t, r). Since Z ⊂ X(cid:48), take a line in K than waiting for the lines in Z, i.e., uSZ∪K it is also never better to take the line in K than waiting for the lines in X(cid:48), which implies (cid:4) uSX(cid:48) y(t) < uLj (t, r) = uSX (t, r) = uSZ (t, r). y y y y y y y 15 We can consider the candidate set pruning technique as an extension of Proposition 1 since Z is obtained when we check the condition in Proposition 1. If Z = 0, the condition in Proposition 1 is satisfied, i (cid:23) X. Otherwise, we prune the transit lines in {j ∈ X\Z j cannot improve any line in Z} before computing for the utility at the station node. According to Definition 4, we iterate through the time intervals {z 1 ≤ z ≤ t} when (t, r). Here z is the waiting time for the first transit line arrival. In some we compute uSX cases, we can infer i (cid:23) X when we finish the computation for an iteration z < t and thus reduce the computation for the rest of the iterations. y Proposition 3. (Time interval pruning) Assume that the passenger is at Ai,X y with passenger state (t, r). Let umax be the maximum utility among all subsequent arrival nodes of SX y at (t − z, z + r)}. Let pj,X(θ) be passenger state (t − z, r + z), i.e., umax(z) = max j∈X the probability that transit service j is the first transit service arrives at the station among all transit lines in X, and it arrives at the station at passenger state (t − θ, r + θ), i.e., pj,X(θ) = wj y (α, r)). Let usum(z) be the expected utility for the cases {uAj,X\j wk y where there is one transit service in X arriving at the station from passenger state (t, r) to (t − θ, θ + r)). If there exists z ≤ t such y (pj,X(θ) · uAj,X\j pj,X(θ)) · umax(z), then i (cid:23) X. z(cid:80) θ=1 α=1 j∈X k∈X\j that uLi z(cid:80) z(cid:80) y(θ, r) (cid:81) (1 − θ(cid:80) (t − z, r + z), i.e., usum(z) = (cid:80) y (t) ≥ usum(z) + (1 − (cid:80) Proof. If we can show that usum(z) + (1 − (cid:80) (t, r) = usum(z) + (cid:80) pj,X(θ) ≥ (cid:80) z(cid:80) 1 − (cid:80) t(cid:80) t(cid:80) (pj,X(θ) · uAj,X\j uSX j∈X j∈X j∈X θ=z+1 θ=1 (t, r) ≤ usum(z) + (1 − (cid:80) j∈X θ=z+1 z(cid:80) correct since uSX y j∈X θ=1 y j∈X θ=1 is non decreasing, we know that umax(z) = max proposition is proved. According to Definition 4, uSX pj,X(θ)) · umax(z) ≥ uSX y (t, r), then the θ=1 y (t, r) = usum(t). We can infer that (t − θ, θ + r)). Since the utility function y {uAj,X\j y j∈X,z≤θ≤t (t − θ, θ + r)}. In addition, pj,X(θ). Therefore, we can conclude that the proposition is pj,X(θ) · umax(z). (cid:4) Whenever we finish computing for a specific time interval z = i, we can check the condition in Proposition 3. If the condition is not satisfied, we let z = i + 1 and continue the procedure. However, if the condition is satisfied, we know that i (cid:23) X and thus can reduce the computation for i + 1 ≤ z ≤ t. To sum up all the techniques discussed in this section and Section 4.2.1, we modify the procedure of computing the utility at arrival nodes as follows. Two dictionaries dom and nondom are used to record the transit line dominance and non-dominance. update dom and update nondom are two functions to update dom and nondom according to dominance properties in Section 4.2.1. Specifically, for any arrival node Ai,X , the pruning is done via the following set of steps. y 16 Step 1: Check if X is in dom[i, t, r]: if yes, return uLi Step 2: Check if X is in nondom[i, t, r]: if yes, compute uSX (t, r) and return it; Otherwise, go to Step 3. Step 3: Check if i (cid:23) X or i ≺ X using the pruning techniques. If i (cid:23) X, run update dom and return uLi y (t); Otherwise, run function update nondom and return uSX y (t); Otherwise, go to Step 2. (t, r). y y We call the algorithm DP with dominance. Note that all the methods discussed retain the optimality of the solution. 4.3. Heuristic rules In this section, we propose three heuristic rules, which can be employed in the procedure of checking dominance, to further decrease the computation time. We will show in the numerical experiments that the heuristics can significantly reduce the computation time without much loss of the results accuracy. Heuristic 1. Assume that the passenger is at node Ai,X Z = {j ∈ X uLi y (t−θ) is an indicator function. If p ≥ , we say that the passenger should board the transit line i. y with passenger state (t, r). Let y(θ, r) where IuLi y(t) < uLj y (t)≥u y (t)≥u ·wj IuLi y (t−θ) j∈Z θ=1 L L y j j (t−1)}, and p = (cid:81) t(cid:80) This is an extension of Proposition 1.  is a constant coefficient. p is the probability of the case that boarding transit line i has a larger utility than boarding any other single transit line in X. If p is large, then only with a small probability, the realization of the waiting time for a transit line in X can make its utility larger than boarding transit line i. Heuristic 2. Assume that the passenger is at node Ai,X If (t − θ),∀j ∈ X, we say that the passenger should board the transit y with passenger state (t, r). y(θ, r) · uLj wj y y (t) ≥ t(cid:80) θ=1 uLi line i. In other words, the passenger should board transit line i if boarding it has a larger utility (t, r),∀j ∈ than waiting for any single line in X. It is an approximation since uSX X according to Claim 4. Therefore, it is possible that uSX (t, r) > uLi (t, r) ≥ uS y (t). {j} y y y Heuristic 3. Assume that the passenger is at Ai,X (t− z, z + r)}, and usum(z) = (cid:80) y max ( j∈X j∈X θ=1 θ, θ + r)). If there exists z ≤ t such that β · uLi {uAj,X\j y with passenger state (t, r). Let umax(z) = (t− wj y(θ, r) (cid:81) (1− θ(cid:80) z(cid:80) y (t) (cid:62) usum(z) + (1−(cid:80) k∈X\j α=1 y (α, r))· uAj,X\j z(cid:80) wk y(θ, r) (cid:81) wj y k∈X\j ( θ=1 j∈X (1− y (α, r)))) · umax(z), then we say that the passenger should board transit line i. wk θ(cid:80) α=1 This is an extension of Proposition 3. The difference is that we add a constant relaxation coefficient β (β > 1) in the condition. This represents that when we compute the utility of a station node, if β times the utility of the line node is larger than the largest possible utility 17 of the station node, we say that the passenger should board the transit line that arrives. β in Heuristic 3 and  in Heuristic 1 are used to control the tradeoff between the results accuracy and computation performance. In the numerical experiments, we let β = 1.25 and  = 0.75. In the following section, we present numerical results and compare the three versions of the solution algorithm introduced in this work: (1) DP; (2) DP with dominance; (3) DP with dominance and heuristics. 5. Numerical experiments In this section, we present numerical experiments focused on illustrating the runtime performance of the various versions of the solution, as well as the practical value of using a SOTA policy in transit networks. All the algorithms are coded in Python 3.6, and all tests are conducted on an AMD Ryzen processor computer (3.4 gigahertz, 16 gigabytes RAM). We first validate the algorithms and conduct a sensitivity analysis in a controlled setting using a synthetic transit network, and then test them on the Chicago transit network. 5.1. Estimating travel time and headway distributions To obtain the required network and transit line information, we develop a procedure for taking the input data (GTFS data) and generate all the processed data we need in the experiments, including travel time distributions, headway distribution, and waiting time distributions. The first step is to generate the travel time distributions for each transit line. Studies have shown that travel time distributions on road networks can be well approxi- mated by a lognormal distribution (see Emam and Ai-Deek (2006), Hunter et al. (2009), Zou et al. (2014)). Therefore, in our experiments, we model the travel time distributions using appropriately parameterized lognormal distributions. A lognormal distributed random variable X is parameterized by two parameters µ and σ that are, respectively, the mean and standard deviation of the variable's natural logarithm. For every two adjacent stations S1 and S2 in a transit line, we calibrate µ and σ for the travel time between the two stations based on the following steps: (1) Compute the minimum realizable travel time tm by dividing the distance between S1 and S2 by the corresponding speed limit. (2) Let the mode of the lognormal distributed variable, i.e., the point of the maximum of the probability density function, be the difference between the scheduled departure time at S2 and S1. The mode of a lognormal distribued variable is eµ−σ2. Therefore, if the schedule departure time at S1 and S2 are 8:45 and 9:00 and tm = 5 min, then we have eµ−σ2 = 10. (3) In the absence of more information from GTFS, σ of the lognormal distribution is sampled uniformly from 0.25 ≤ σ ≤ 0.5 so that the variance is neither too large or too small. (4) Compute µ according to the mode and σ. Shift the distribution rightwards by tm. As σ is randomly sampled from a given range, a sensitivity analysis is conducted in Section 5.2.3. If one can get access to the transit vehicle's real-time location, σ can be obtained from the real realized travel time data. After computing the travel time distribution between every two adjacent stations, we can obtain the travel time distribution between the 18 origin and all other stations on each transit line by computing the appropriate summation of the random variables due to the independence assumption. The headway at the origin station of each transit line is set to the mean of the difference between the scheduled departure time for every two consecutive trips in our experiment time span. For instance, if the scheduled departure times for a transit line i at the origin station are 8:45, 8:55, 9:10, then we let the headway be 10+15 2 = 12.5. The headway for other stations is computed as follows. Let X1 and X2 be the arrival time of the first transit vehicle and the second transit vehicle of the transit line of interest at a station S. O is the origin, and h is the deterministic headway at O. The cumulative distribution function of the headway is computed as follows: (cid:90) ∞ P (X2 − X1 ≤ t) = P (X2 ≤ X1 + t) = P (X2 ≤ x + t) · P (X1 = x)dx 0 where P (x2 ≤ x + t) and P (X1 = x) are the cumulative distribution function of X2 and the probability density function of X1. Let tO,S be the travel time between O and S. The distribution of X1 is the same as the distribution for tO,S, and the distribution of X2 is to shift the distribution for tO,S rightwards by h. Finally, we estimate the waiting time distribution from the headway distributions fol- lowing Larson and Odoni (1981). Let Ei,y[hi,y] be the expected headway of transit line i at station y, and Hi,y(·) be the cumulative distribution function of headway of transit line i at station y. Then the waiting time reads: wi y(t, 0) = 1 Ei,y[hi,y] · (1 − Hi,y(t)) 5.2. Synthetic network experiments The synthetic network we use is a 3-line 3-station transit network, as shown in Figure 3. The three transit lines pass through each of the three stations. The line attributes are presented in Table 2. The headway and travel time are in minutes. Line i Headway at station A Travel time from A to B Travel time from B to C 1 2 3 10 15 12 4 4 7 5 3 4 Table 2: Line attributes of the 3-line synthetic transit network. All times are provided in minutes. Figure 3: A 3-line synthetic transit network. 5.2.1. Performance analysis We first illustrate the performance of the algorithms, specifically the relationship between the computation time and the time budget. Let station A be the origin, and station C be the destination, and the time discretization of the algorithm to be 15 seconds. The three 19 Figure 4: Computation time of three algorithms on the synthetic network. Left: All three algorithms. Right: Only algorithms with the dominance based pruning to showcase the relative improvement. Figure 5: Comparison of the utility between the SOTA policy and LET path. algorithms introduced in Section 3 are tested on time budgets ranging from 10 min to 45 min with a step size of 2.5 min. Computation time of DP As shown in Figure 4, the algorithms with search space reduction techniques perform sig- nificantly better than the basic DP approach. The DP with the dominance test can provide an average computation time reduction of 77.8% compared to the basic DP approach. The heuristics further decrease the computation time by 68.9% on average relative to the DP with dominance. The time reduction percentage ( Computation time of DP - Computation of DP with dominance ) is typically higher when the time budget is large. When the time budget is 45 min, the time reduction can be 97.3% for the DP with dominance and heuristics. The average relative error for the heuristic method is only 2.8% in this experiment. Therefore, the heuristic (at least in this case) provides a satisfactory trade-off between accuracy and computation time. We also quantify the benefits of utilizing a SOTA policy instead of using the least ex- pected travel time (LET) path. This is done by using the expected value of both the travel time and waiting time distributions to compute the LET path between station A and station C. The utility of the LET solution is then computed based on the probability of success when using the LET path for different time budgets. Figure 5 illustrates the utility differ- ence between the LET path and the SOTA policy we obtain from our algorithm. When the time budget is very small, the utility difference is zero because the passenger cannot reach the destination on time regardless of the policy the passenger uses. Similarly, when 20 the time budget is very large, the utility difference is also 0 because the passenger reaches the destination on time with high probability even with a sub-optimal route. The SOTA policy will always be no worse than the LET solution by definition. The maximum utility difference observed in this experiment is 23 percent (when the time budget is 22.5 min in this case). 5.2.2. Sensitivity to the modes of the travel time distributions. In this section, we analyze the effect of the modes3 of travel time distributions on compu- tation time. The modes of the travel time distributions on each link are sampled uniformly from a range instead of being predefined. Two sets of experiments are conducted. In the first set of experiments, we let the width of the range be 1. More specifically, we first gen- erate a random number i ∈ {1, 2, 3, 4, 5, 6, 7, 8, 9} uniformly, and then set the range to be [i, i + 1). Assume that X1 and X2 are two random variables sampled uniformly from this 3 since X1 − X2 follows a triangle distribution with the pa- range. Then, E(X1 − X2) = 1 rameters a = 0, c = 0 and b = 1. In the second set of experiments, the range is set to [1, 10), and E(X1 − X2) = 3 since X1 − X2 follows a triangle distribution where a = 0, c = 0 and b = 9. We call the first set of experiments low diff, and the second set of experiments high diff. Each set of experiments are conducted for 100 times. Figure 6: Computation time reduction of speed-up techniques on two cases. high diff represent the case where the travel time distributions' modes are highly different, while low diff represents the case where the travel time distributions' modes are relatively close. The computation time reduction with respect to the time budget is shown in Figure 6. The search space reduction techniques work well in both sets of experiments. The average computation time reductions for the DP with dominance are 88.9% and 67.1% for the low diff and high diff cases respectively relative to standard DP, and the time reductions are 95.7% and 89.8% for the DP with dominance and heuristics. The search space reduction techniques work better in the low diff cases because the transit services that arrive the first will intuitively dominate the other transit lines more often with similar travel time 3Note that mode here is the statistical definition. 21 distributions, since waiting is not likely to increase the utility. Another interesting result is that the heuristics will provide a higher time reduction for the high diff cases compared to the DP with dominance algorithm. A potential reason is that a line will have a higher probability of being better than any other single candidate line at the same station in this case, which indicates dominance according to the Heuristic 2. 5.2.3. Sensitivity to the σ parameter We now analyze the sensitivity of the algorithm performance to the parameter σ in the lognormal travel time distributions. Assume that the CDF of a lognormal distribution is F (x), and γ is the mode of the distribution. In Section 5.2.1, we use σ = 0.25, which makes F (1.5 · γ) ≈ 0.9 when γ is in the range shown in Table 2. To show the effects of σ on the distribution, we compare the distribution with σ = 0.25 and σ = 0.5 in Figure 7. When σ = 0.5, F (1.5 · γ) ≈ 0.6. Figure 7: The PDF of lognormal distributions with different σ. To analyze the sensitivity of σ on the algorithm's performance, two sets of experiments are conducted. In the first set of experiments, the algorithms are tested under σ = 0.5. In the second set of experiments, σ is uniformly sampled from [0.25, 0.5] for each link of each transit line. Again, each set of experiments are conducted for 100 times. Table 3: Algorithms' performance under different σ settings. Parameter setting Computation time reduction for DP with dominance Computation time reduction for DP with dominance and heuristics σ = 0.25 σ = 0.5 σ randomly chosen from [0.25, 0.5] 77.8% 80.3% 79.8% 92.6% 94.1% 93.9% As shown in Table 3, the search space reduction techniques perform similarly under different σ values. The computation time is reduced slightly more when the variance of the travel time distribution is larger. In the following experiments for the Chicago transit network, we use σ randomly sampled from [0.25, 0.5]. 22 5.3. Chicago network experiments We now use the Central/South region (including downtown) of the Chicago transit net- work as a case study. The network is created according to the GTFS data published by the Chicago Transit Authority (CTA) through Google's GTFS project. The GTFS data con- tains schedules and associated geographic information. In the experiments, only active bus lines in the morning (6 am to 10 am) are considered. The transit network, which contains 49 transit lines and 1565 stations, is shown in Figure 8. Figure 8: Chicago transit network (Central/South region). 5.3.1. Runtime performance in the Chicago network The average travel time to commute in the United States is 26.1 min according to the U.S. Census Bureau (census.gov 2017). Therefore, we select 100 ODs randomly from the station set under the constraints: (1) The expected trip duration is from 15 min to 45 min; (2) At least one of the origin and the destination is in the downtown area, to simulate the case of commuting. The experiments are conducted for the time budgets which also span from 10 min to 45 min. For each time budget, we use the same three algorithms described previously to compute the utility. The computation time for each algorithm is shown in Figure 9. The DP with dominance reduces the computation time by 89.3% on average. The com- putation time reductions are significant, but not as high as in the synthetic network shown in Figure 3 especially when T is large. In the synthetic network, there are only three sta- tions which limit the search space. However, in real-size networks, the search space will be much larger since there are more stations and transit lines to be considered. The heuristic rules further decrease the computation time by 34.0% on average relative to the DP with dominance. The average relative error for the heuristic rules is about 1.6%. Recall from Section 4, if i (cid:23) X at an arrival node Ai,X we save the computation for uSX y given passenger state (t, r), (t, r). In the experiments, we also record the number of y 23 Figure 9: Computation time of three algorithms on the Chicago transit network. Left: All three algorithms. Right: Only algorithms with the dominance based pruning to showcase the relative improvement. Figure 10: The computation reduction for computing the utility on station nodes. The vertical axis shows the percentage of function calls reduction to compute the utility at stations. function calls to compute the utility at station nodes. Figure 10 shows the percentage of the function calls reduction by DP with dominance and DP with dominance and heuristics. Both algorithms provide more than 90% function calls reduction for all the cases. However, the reduction decreases as the time budget increases. When the time budget is higher, the set of feasible arrival nodes that followed by a station node SX y at passenger state (t, r) is larger. Here an arrival node Ai,X is feasible at passenger state (t, r) if it is not pruned by the y techniques in Section 4. Let Z X y be the set of feasible arrival nodes followed by station node y } needs to dominate SX y . To save the computation for uSX X, which is of less probability when Z is higher. (t, r), every line in {i Ai,X y y ∈ Z X The average computation time of the DP with dominance and heuristics is only about 9.2 seconds on a personal computer, which indicates the potential of running the algorithm in real-time applications. 5.3.2. Compare the utility of the SOTA policy and LET path Recall from Section 5.2.1, the utility difference between the SOTA policy and LET path can be as large as 0.23 in the synthetic network. In this section, we test the utility difference in the Chicago transit network. Intuitively, if there is one and only one transit line that 24 Figure 11: The histogram of the utility difference between the SOTA policy and LET path on the Chicago transit network. Figure 12: The utility improvement of the SOTA policy over the LET path under different circumstances. Left: With respect to the number of transit lines passing by the origin. Right: With respect to the ratio of the travel time of the LET path and the time budget. can directly take the passenger to the destination without transferring, the SOTA policy and LET path will likely be the same due to the time cost of transferring. Therefore, we compare the utility difference of all the ODs from the station set under the constraints: (1) The expected trip duration is from 15 min to 45 min; (2) At least one of the origin and the destination is in the downtown area; (3) There is no transit line or there are more than one transit line that can directly take the passenger to the destination. The number of ODs satisfying the above conditions is 9290. Again, the experiments are conducted for the time budgets from 10 min to 45 min. For each OD, we record the maximum utility difference between the SOTA policy and LET path among all the time budgets we test. Figure 11 shows the histogram of the maximum utility difference. The utility difference for 19.6% of the ODs is larger than 0.05, and the utility difference for 7.6% of the ODs is larger than 0.1. The utility difference is close to 0 for most of the ODs, which are the cases that either there is only one route choice between the origin and the destination or there is one obvious better line than the other choices. It should be noted that the results highly depend on the network and the travel time distribution we use. To give insights of what trips will likely benefit from the SOTA policy, we show the 25 utility increases of the SOTA policy over the LET path on different circumstances with respect to: i) The number of transit lines passing by the origin; ii) The ratio of the least expected time (LET) path travel time to the time budget. As shown in Figure 12 (Left), a SOTA policy outperforms the LET path more when the number of transit lines at the origin increases, which demonstrates that a SOTA policy is more advantageous when there are more states and options to consider. In addition, even though there might be more transit lines to transfer on the way, it may not be beneficial to conduct a transfer in most of the cases due to the transfer time. Therefore, when there is only one transit line passing by the origin, the average utility difference is about 0.025, which is close to 0. The ratio of the LET path travel time to the time budget represents how sufficient the time budget is relative to the trip length. Figure 12 (Right) shows the utility increase versus the ratio. If the ratio is relatively large (larger than 2), passengers cannot increase the utility by using the adaptive routing policy since it is difficult to get to the destination in a very limited time budget; On the other hand, if the ratio is very small (smaller than 0.5), the utility increase is also close to 0 since passengers will likely reach the destination within the given time budget whatever transit line they board. The SOTA policy performs the best when the ratio is around 1. In summary, the SOTA policy in transit networks shines the most when there are more states to consider and when the time budget is neither too high or too low relative to the trip length. 6. Conclusion. In this article, we extend the SOTA formulation to the case of transit networks. A network representation comprised of three types of nodes is proposed to model the common line problem in the SOTA framework. Instead of assuming that the passenger will board the first arriving transit service in an attractive line set that is precomputed, we give a routing policy which outperforms a-priori solutions for all practical purposes. From the perspective of computation, we show that computing the utility in transit networks is significantly more difficult than in road networks, and design an dynamic programming based algorithm to solve the problem, which is pseudo-polynomial in the number of stations and time budget, and exponential in the number of transit lines at a station, which is practically a small number. To reduce search space, we propose a definition of transit line dominance, and a series of techniques to check if a transit line dominates. Experiments are conducted on both a synthetic network and the Chicago transit network. The results show that the search space reduction techniques can reduce the computation time by up to around 90%, and the heuristic rules can further decrease the computation time by about 34%. Two sensitivity analyses on the travel time distribution show that the search space reduction techniques can significantly decrease the computation time in all the cases we test. Finally, the algorithms are applied in the Chicago transit network, and similar conclusions are obtained. In future research, we will focus on designing proper preprocessing techniques to further reduce the computation time in practice. In reality, the spatial and temporal correlation of link travel time usually exists in transit networks. In addition, the travel time and waiting 26 time can be time-varying at the different time of a day (e.g., at peak hours or off-peak hours). Therefore, one possible future research direction is to explore the ways to generate more realistic travel time and waiting time distributions and design algorithms to deal with them. References Bauer, R., Delling, D., 2009. Sharc: Fast and robust unidirectional routing. Journal of Experimental Algorithmics (JEA) 14, 4. census.gov, 2017. Average one-way commuting time by metropolitan areas. https://www.census. gov/library/visualizations/interactive/travel-time.html. Chen, B. Y., Lam, W. H., Sumalee, A., Li, Q., Tam, M. L., 2014. Reliable shortest path problems in stochastic time-dependent networks. Journal of Intelligent Transportation Systems 18 (2), 177 -- 189. Chen, P. W., Nie, Y. M., 2015. Optimal transit routing with partial online information. Trans- portation Research Part B: Methodological 72, 40 -- 58. Cominetti, R., Correa, J., 2001. Common-lines and passenger assignment in congested transit networks. Transportation Science 35 (3), 250 -- 267. Emam, E., Ai-Deek, H., 2006. Using real-life dual-loop detector data to develop new methodology for estimating freeway travel time reliability. Transportation Research Record: Journal of the Transportation Research Board (1959), 140 -- 150. Fan, Y., Kalaba, R., Moore, J., 2005a. Shortest paths in stochastic networks with correlated link costs. Computers & Mathematics with Applications 49 (9), 1549 -- 1564. Fan, Y., Kalaba, R., Moore II, J., 2005b. Arriving on time. Journal of Optimization Theory and Applications 127 (3), 497 -- 513. Fan, Y., Nie, Y., 2006. Optimal routing for maximizing the travel time reliability. Networks and Spatial Economics 6 (3-4), 333 -- 344. Flajolet, A., Blandin, S., Jaillet, P., 2017. Robust adaptive routing under uncertainty. Operations Research 66 (1), 210 -- 229. Frank, H., 1969. Shortest paths in probabilistic graphs. Operations Research 17 (4), 583 -- 599. Gao, S., Chabini, I., 2006. Optimal routing policy problems in stochastic time-dependent networks. Transportation Research Part B: Methodological 40 (2), 93 -- 122. Gentile, G., Nguyen, S., Pallottino, S., 2005. Route choice on transit networks with online infor- mation at stops. Transportation science 39 (3), 289 -- 297. Gutman, R. J., 2004. Reach-based routing: A new approach to shortest path algorithms optimized for road networks. ALENEX/ANALC 4, 100 -- 111. Hall, R. W., 1986. The fastest path through a network with random time-dependent travel times. Transportation science 20 (3), 182 -- 188. Hickman, M. D., Bernstein, D. H., 1997. Transit service and path choice models in stochastic and time-dependent networks. Transportation Science 31 (2), 129 -- 146. Hilger, M., Kohler, E., Mohring, R. H., Schilling, H., 2009. Fast point-to-point shortest path computations with arc-flags. The Shortest Path Problem: Ninth DIMACS Implementation Challenge 74, 41 -- 72. 27 Huang, H., Gao, S., 2012. Optimal paths in dynamic networks with dependent random link travel times. Transportation Research Part B: Methodological 46 (5), 579 -- 598. Hunter, T., Herring, R., Abbeel, P., Bayen, A., 2009. Path and travel time inference from gps probe vehicle data. NIPS Analyzing Networks and Learning with Graphs 12 (1). Larson, R. C., Odoni, A. R., 1981. Urban operations research. No. Monograph. Li, Q., Chen, P. W., Nie, Y. M., 2015. Finding optimal hyperpaths in large transit networks with realistic headway distributions. European Journal of Operational Research 240 (1), 98 -- 108. Loui, R. P., 1983. Optimal paths in graphs with stochastic or multidimensional weights. Commu- nications of the ACM 26 (9), 670 -- 676. Miller-Hooks, E. D., Mahmassani, H. S., 2000. Least expected time paths in stochastic, time- varying transportation networks. Transportation Science 34 (2), 198 -- 215. Nie, Y. M., Wu, X., 2009. Shortest path problem considering on-time arrival probability. Trans- portation Research Part B: Methodological 43 (6), 597 -- 613. Niknami, M., Samaranayake, S., 2016. Tractable pathfinding for the stochastic on-time arrival problem. In: International Symposium on Experimental Algorithms. Springer, pp. 231 -- 245. Nikolova, E., Kelner, J. A., Brand, M., Mitzenmacher, M., 2006. Stochastic shortest paths via quasi-convex maximization. In: European Symposium on Algorithms. Springer, pp. 552 -- 563. Nonner, T., Laumanns, M., 2014. Shortest path with alternatives for uniform arrival times: Al- gorithms and experiments. In: OASIcs-OpenAccess Series in Informatics. Vol. 42. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik. Oliker, N., Bekhor, S., 2018. A frequency based transit assignment model that considers online information. Transportation Research Part C: Emerging Technologies 88, 17 -- 30. Parmentier, A., Meunier, F., 2014. Stochastic shortest paths and risk measures. arXiv preprint arXiv:1408.0272. Polychronopoulos, G. H., Tsitsiklis, J. N., 1996. Stochastic shortest path problems with recourse. Networks 27 (2), 133 -- 143. Sabran, G., Samaranayake, S., Bayen, A., 2014. Precomputation techniques for the stochastic on-time arrival problem. In: Proceedings of the Meeting on Algorithm Engineering & Exper- miments. Society for Industrial and Applied Mathematics, pp. 138 -- 146. Samaranayake, S., Blandin, S., Bayen, A., 2012a. Speedup techniques for the stochastic on-time arrival problem. In: OASIcs-OpenAccess Series in Informatics. Vol. 25. Schloss Dagstuhl- Leibniz-Zentrum fuer Informatik. Samaranayake, S., Blandin, S., Bayen, A., 2012b. A tractable class of algorithms for reliable routing in stochastic networks. Transportation Research Part C: Emerging Technologies 20 (1), 199 -- 217. Spiess, H., Florian, M., 1989. Optimal strategies: a new assignment model for transit networks. Transportation Research Part B: Methodological 23 (2), 83 -- 102. Szeto, W. Y., Solayappan, M., Jiang, Y., 2011. Reliability-based transit assignment for congested stochastic transit networks. Computer-Aided Civil and Infrastructure Engineering 26 (4), 311 -- 326. Townsend, google google-io-biggest-announcements-keynote-highlights-2017. that https://www.recode.net/2017/5/17/15654076/ Google today. T., 2017. announced Everything important i/o 2017: 28 Waller, S. T., Ziliaskopoulos, A. K., 2002. On the online shortest path problem with limited arc cost dependencies. Networks 40 (4), 216 -- 227. Yang, L., Zhou, X., 2014. Constraint reformulation and a lagrangian relaxation-based solution algorithm for a least expected time path problem. Transportation Research Part B: Method- ological 59, 22 -- 44. Yang, L., Zhou, X., 2017. Optimizing on-time arrival probability and percentile travel time for elementary path finding in time-dependent transportation networks: Linear mixed integer programming reformulations. Transportation Research Part B: Methodological 96, 68 -- 91. Zou, Y., Zhu, X., Zhang, Y., Zeng, X., 2014. A space -- time diurnal method for short-term freeway travel time prediction. Transportation Research Part C: Emerging Technologies 43, 33 -- 49. 29
1802.03905
1
1802
2018-02-12T06:31:58
How to Match when All Vertices Arrive Online
[ "cs.DS" ]
We introduce a fully online model of maximum cardinality matching in which all vertices arrive online. On the arrival of a vertex, its incident edges to previously-arrived vertices are revealed. Each vertex has a deadline that is after all its neighbors' arrivals. If a vertex remains unmatched until its deadline, the algorithm must then irrevocably either match it to an unmatched neighbor, or leave it unmatched. The model generalizes the existing one-sided online model and is motivated by applications including ride-sharing platforms, real-estate agency, etc. We show that the Ranking algorithm by Karp et al. (STOC 1990) is $0.5211$-competitive in our fully online model for general graphs. Our analysis brings a novel charging mechanic into the randomized primal dual technique by Devanur et al. (SODA 2013), allowing a vertex other than the two endpoints of a matched edge to share the gain. To our knowledge, this is the first analysis of Ranking that beats $0.5$ on general graphs in an online matching problem, a first step towards solving the open problem by Karp et al. (STOC 1990) about the optimality of Ranking on general graphs. If the graph is bipartite, we show that the competitive ratio of Ranking is between $0.5541$ and $0.5671$. Finally, we prove that the fully online model is strictly harder than the previous model as no online algorithm can be $0.6317 < 1-\frac{1}{e}$-competitive in our model even for bipartite graphs.
cs.DS
cs
How to Match when All Vertices Arrive Online Zhiyi Huang∗ Ning Kang∗ Zhihao Gavin Tang∗ Xue Zhu∗ Xiaowei Wu† Yuhao Zhang∗ Abstract We introduce a fully online model of maximum cardinality matching in which all vertices arrive online. On the arrival of a vertex, its incident edges to previously-arrived vertices are revealed. Each vertex has a deadline that is after all its neighbors' arrivals. If a vertex remains unmatched until its deadline, the algorithm must then irrevocably either match it to an un- matched neighbor, or leave it unmatched. The model generalizes the existing one-sided online model and is motivated by applications including ride-sharing platforms, real-estate agency, etc. We show that the Ranking algorithm by Karp et al. (STOC 1990) is 0.5211-competitive in our fully online model for general graphs. Our analysis brings a novel charging mechanic into the randomized primal dual technique by Devanur et al. (SODA 2013), allowing a vertex other than the two endpoints of a matched edge to share the gain. To our knowledge, this is the first analysis of Ranking that beats 0.5 on general graphs in an online matching problem, a first step towards solving the open problem by Karp et al. (STOC 1990) about the optimality of Ranking on general graphs. If the graph is bipartite, we show that the competitive ratio of Ranking is between 0.5541 and 0.5671. Finally, we prove that the fully online model is strictly harder than the previous model as no online algorithm can be 0.6317 < 1− 1 e -competitive in our model even for bipartite graphs. 8 1 0 2 b e F 2 1 ] S D . s c [ 1 v 5 0 9 3 0 . 2 0 8 1 : v i X r a ∗Department of Computer Science, University of Hong Kong. {zhiyi,nkang,zhtang,yhzhang2,xzhu2}@cs.hku.hk †Department of Computing, Hong Kong Polytechnic University. [email protected]. The work was done when the author was a postdoc at the University of Hong Kong. 1 1 Introduction Online Bipartite Matching is a central problem in the area of online algorithms with a wide range of applications. Consider a bipartite graph where the left-hand-side is known in advance, while vertices on the right-hand-side arrive online in an arbitrary order. On the arrival of a vertex, its incident edges are revealed and the algorithm must irrevocably either match it to one of its unmatched neighbors or leave it unmatched. Karp et al. [KVV90] introduced the Ranking algorithm, which picks at the beginning a random permutation over offline vertices, and matches each online vertex to the first unmatched neighbor according to the permutation. Further, they proved that Ranking is (1 − 1 e )-competitive and the best possible among online algorithms. The analysis of Ranking has been subsequently simplified in a series of papers [GM08, BM08, DJK13]. Further, it has been generalized to several extended settings, including the vertex-weighted case [AGKM11], the random arrival model [KMT11, MY11], and the Adwords problem [MSVV07, BJN07, DJ12]. However, all the above successful applications of Ranking crucially rely on the assumption that one side of the bipartite graph is known upfront. This assumption prevents us from applying the known positive results to some applications. Here is an example: Example (Real Estate Agency). During a typical day of a real estate agent in Hong Kong, both tenants and landlords drop by in an online fashion. Tenants specify what kinds of apartments they are looking for as well as the deadlines before which they need to move in1. Similarly, landlords list certain rules for tenant screening together with their deadlines. Tenants and landlords can be modeled as the vertices in a bipartite graph. There is an edge between a tenant-landlord pair if (1) they mutually satisfy each other's conditions, and (2) their time windows (between their respective arrivals and deadlines) overlap. Real estate agents charge for each successful deal and, thus, seek to maximize the size of the bipartite matching. This is clearly a bipartite matching problem with an online nature. However, it does not fit into the existing model in two fundamental ways. First, vertices from both sides of the bipartite graphs arrive online. Second, matching decision of each vertex is made at its deadline rather than its arrival. There are many other applications with similar flavors such as job market intermediary and organ transplantation. A Fully Online Model. Motivated by these applications, we formulate the following alternative online model of bipartite matching. We call it Fully Online Bipartite Matching since vertices from both sides arrive online. Let there be an underlying bipartite graph that is completely unknown to the algorithm at the beginning. Each time step falls into one of the following two kinds: • Arrival of v: A vertex v arrives; edges between v and previously-arrived vertices are revealed. • Deadline of v: This is the last time a vertex v can be matched (if it is not matched yet). The model further guarantees that all edges incident to a vertex are revealed before its deadline. Indeed, a tenant-landlord pair must have overlapping time windows in order to have an edge between them in the above example. We further assume without loss of generality that algorithms are lazy in the sense that they only make decisions on the deadlines of the vertices. On the deadline of a vertex v, it might be the case that v has already been matched to another vertex u on u's deadline. Otherwise, the algorithm must irrevocably either match v to one of its unmatched neighbors, or leave it unmatched. 1Tenants may also specify their earliest move-in dates. This is omitted in our model because, from the algorithmic point of view, it is equivalent to having each tenant arrive on the earliest move-in date. The same applies to landlords. 1 The previous one-sided online model is a special case in which all offline vertices arrive at the beginning and have deadlines at the end, and each online vertex has its deadline right after arrival. Further, there are many applications for which the underlying graph is not necessarily bipartite. Consider the following example: Example (Ride-sharing Platform). DiDi is a major ride-sharing platform in China, han- dling tens of millions of rides on a daily basis. Requests are submitted to the platform in an online fashion. Each request is active in the system for a few minutes. The platform may match a pair of requests and serve them with the same taxi (or self-employed driver), provided that the pick-up locations and destinations are compatible, and their active time windows overlap. Requests can be modeled as vertices in a general graph and the compatibilities of pairs of requests can be modeled as edges. Our model generalizes straightforwardly to general graphs by removing the bipartite assumption on the underlying graph. We refer to the generalization as Fully Online Matching. It is easy to check that the naıve greedy algorithm that simply matches a vertex to an arbitrary unmatched neighbor remains to be 0.5-competitive. Can we do better? 1.1 Our Results and Techniques We consider a natural generalization of the Ranking algorithm that picks a random permutation over all vertices at the beginning, and matches each vertex (if unmatched at its deadline) to the first unmatched neighbor according to the permutation. This algorithm can be implemented in our fully online model following the interpretation of Ranking by Devanur et al. [DJK13]: On the arrival of v ∈ V , the rank of vertex v, denoted by yv, is chosen uniformly at random from [0, 1); each vertex (if unmatched at its deadline) is matched to its unmatched neighbor with the highest, i.e., smallest, rank. We show that the Ranking algorithm is strictly better than 0.5-competitive: Theorem 1.1 Ranking is 0.5211-competitive for Fully Online Matching. Theorem 1.2 Ranking is 0.5541-competitive for Fully Online Bipartite Matching. To our knowledge, our result for the Fully Online Matching problem is the first generalization of Ranking that achieves a competitive ratio strictly better than 0.5 in an online matching model that allows general graphs, making the first step towards providing a positive answer to the open question of whether Ranking is optimal for general graphs by [KVV90]. Our Techniques (Bipartite Case). We build on the randomized primal dual technique intro- duced by Devanur et al. [DJK13]. It can be viewed as a charging argument for sharing the gain of each matched edge between its two endpoints. Whenever an edge (u, v) is added to the matching, where v is an offline vertex and u is an online vertex, imagine a total gain of 1 being shared between u and v based on the rank of the offline vertex v. The higher the rank of v, the smaller share it gets. For Online Bipartite Matching, Devanur et al. [DJK13] introduced a gain sharing method such that, for any edge (u, v) and for any fixed ranks of offline vertices other than v, the expected gains of u and v (from all of their incident edges) combined is at least 1 − 1 e over the randomness of v's rank. This implies the 1 − 1 e competitive ratio. Next, consider an edge (u, v) in our model. Suppose u is the one with an earlier deadline. Since algorithms are lazy, the edge can only be added into the matching as a result of u's decision at its deadline. In this sense, u plays a similar role as the online vertex and v as the offline vertex in the 2 analysis of Devanur et al. [DJK13]. Hence, a natural attempt is to consider the expected gains of u and v combined in the charging argument over the randomness of v's rank alone. To explain why the above approach fails, we first introduce the notions of active and passive vertices. We say a vertex u matches actively (or is active) if it is added to the matching by the algorithm at u's deadline; other matched vertices are passive. All previous analyses [KVV90, AGKM11, DJK13, CCWZ14, ACC+16] crucially rely on a structural property that whenever vertex v is unmatched, its neighbor u must be matched to some other vertex with rank higher than v. In our model, however, this holds only if v's neighbor u is active. One may try to resolve this issue with a global amortized argument. If we go over all the edges in the graph, it cannot be the case that the endpoint with an earlier deadline of every edge always matches passively. After all, the numbers of active and passive vertices are equal. Interestingly, we instantiate this intuition with a local amortized argument by taking expectation over the randomness of u's rank as well. Recall that u is the vertex with earlier deadline and, thus, plays a similar role as the online vertex in the argument of Devanur et al. [DJK13]. Taking expectation over u's rank can be viewed as amortizing the case when u's rank is low (active) and the case when u's rank is high (passive). Our Techniques (General Case). Moving from bipartite graphs to general graphs takes away another crucial structural property that the previous arguments rely on. In a bipartite graph, if a vertex u is matched by the Ranking algorithm for a realization of ranks while one of its neighbors v is not, then u remains matched no matter how the rank of v changes. In a general graph, however, it is possible that u becomes unmatched when v gets a higher rank. We introduce a novel charging mechanic on top of the gain sharing rule used in the bipartite case. After a matching has been chosen by Ranking, for each active vertex w, consider an alternative run of Ranking with the same ranks but with w removed from the graph. The difference between the two matchings will be an alternating path and, thus, at most one vertex v would change from unmatched to matched in the absence of w. We shall refer to such a vertex v as the victim of w. Note that each active vertex has at most one victim, but an unmatched vertex could be the victim of many vertices. If the victim of w turns out to be its neighbor2, our new charging mechanic will have w send to v a portion of w's share from its incident edge in the matching, which we shall refer to as the compensation from w to v. Further, we show that whenever the aforementioned structural property fails, namely, some vertex u becomes unmatched when its unmatched neighbor v gets a higher rank, we can always identify a unique neighbor w of v that sends a compensation to v to remedy the loss in the charging argument. Putting together the gain sharing mechanic from the bipartite case and the new mechanic of compensations, we can prove that for any edge (u, v), the expected net gains of u and v combined is strictly greater than 0.5 over the randomness of the ranks of both u and v. To our knowledge, this is the first charging mechanic that allows a vertex other than the two endpoints of a matched edge to get a share. We believe this novel charging mechanic will find further applications in other matching problems that consider general graphs. Hardness Results. We complement our competitive analysis with two hardness results. The first hardness applies to arbitrary online algorithms, showing a separation between the best competitive ratio in our fully online model and the optimal ratio of 1 − 1 online model. The second hardness focuses on the Ranking algorithm, certifying that our analysis for the bipartite case is close to the best possible. e ≈ 0.6321 in the existing one-sided 2This would induce an odd cycle and, thus, can only happen in non-bipartite graphs. 3 Theorem 1.3 No randomized algorithm can achieve a competitive ratio better than 0.6317 for Fully Online Bipartite Matching. Theorem 1.4 Ranking is at most 0.5671-competitive for Fully Online Bipartite Matching. 1.2 Other Related Works An alternative generalization of Ranking to general graphs has been considered for the problem of oblivious matching [CCWZ14, ACC+16]: Pick a permutation of vertices uniformly at random; then, go over the vertices one by one according to the permutation; for each unmatched vertex, match it to the first unmatched neighbor according to the same permutation. Chan et al. [CCWZ14] showed that it is a 0.523-approximation algorithm, improving the previous ( 1 400000 )-approximation by a greedy algorithm [ADFS95]. Abolhassani et al. [ACC+16] improved the ratio to 0.526 and analyzed the weighted case. We stress that the alternative generalization is an offline algorithm because it needs to consider the vertices in random order, while our generalization is online. Nevertheless, our result for general graphs can be viewed as a 0.5211-approximation in the oblivious matching problem. We believe the new algorithm and analysis in this paper, in particular, the new charging mechanic of compensations, will find further applications in oblivious matching and other matching problems that consider general graphs. 2 + 1 √ 1 3+2 2 1 1 Another online matching model in the literature considers online edge arrivals, upon which the algorithm must immediately decide whether to add the edge to the matching. McGregor [McG05] ≈ 0.1715-competitive algorithm in the edge-weighted preemptive setting. gave a deterministic This ratio is later shown to be tight for deterministic algorithms [Var11]. Epstein et al. [ELSW13] 1+ln 2 ≈ 0.59. designed a Chiplunkar et al. [CTV15] considered a restricted setting where the input graph is an unweighted growing tree and gave a 15 28 -competitive algorithm. Finally, Buchbinder et al. [BST17] introduced an optimal 5 5.356 ≈ 0.1867-competitive randomized algorithm and proved a hardness of 9 -competitive algorithm for unweighted forests. Wang and Wong [WW15] considered a more restrictive model of online bipartite matching with both sides of vertices arriving online: A vertex can only actively match other vertices at its arrival; if it fails to match at its arrival, it may still get matched passively by other vertices later. They showed a 0.526-competitive algorithm for a fractional version of the problem. We argue that the model in this paper better captures our aforementioned motivating applications. 2 Preliminaries We consider the standard competitive analysis against an oblivious adversary. The competitive ratio of an algorithm is the ratio between the expected size of the matching by the algorithm over its own random bits to the size of the maximum matching of the underlying graph in hindsight. The adversary must in advance choose an instance, i.e., the underlying graph as well as arrivals and deadlines of vertices, without observing the random bits used by the algorithm. Otherwise, no algorithm can get any competitive ratio better than 0.5. 2.1 Ranking Algorithm and Some Basic Properties See Algorithm 1 for a formal definition of Ranking in our model. Let M ((cid:126)y) denote the matching produced when Ranking is run with (cid:126)y as the ranks. 4 Algorithm 1 The Ranking Algorithm (1) a vertex v arrives: pick yv ∈ [0, 1) uniformly at random. (2) a vertex v's deadline reaches: if v is unmatched, let N (v) be the set of unmatched neighbors of v. if N (v) = ∅, then v remains unmatched; else match v to arg minu∈N (v) yu. Recall the following definition of active/passive vertices. In the one-sided online model, only online vertices can be active and only offline vertices can be passive. In our fully online model, however, vertices can in general be of either types depending on the random ranks of the vertices. Definition 2.1 (Active, Passive) For any edge (u, v) added to the matching by Ranking at u's deadline, we say that u is active and v is passive. The proofs of the following lemmas are deferred to Appendix A. The first lemma is a variant of the monotonicity property in previous works, incorporating the notions of active and passive vertices in our fully online model. Lemma 2.1 (Monotonicity) For any rank vector (cid:126)y and any vertex u, we have 1. if u is active/unmatched, then M ((cid:126)y) remains the same when yu increases; 2. if u is passive, then u remains passive when yu decreases. Let (cid:126)y-u ∈ [0, 1)V \{u} be the ranks of all vertices but u, i.e., (cid:126)y-u is obtained by removing the u-th entry in (cid:126)y. Let M ((cid:126)y-u) denote the matching produced by Ranking on G − {u}, i.e., the subgraph with vertex u removed, with (cid:126)y-u as the ranks. For ease of notation, for any y ∈ [0, 1], we use y- to denote a value that is arbitrarily close to, but smaller than y. For example, our arguments consider functions discontinuous at 1 and use f (1-) to denote the limit of f (x) as x goes to 1 from below. We also consider the matching w.r.t. ranks (yu = θ-, (cid:126)y-u) to avoid confusions in marginal cases where ranks (yu = θ, (cid:126)y-u) need tie-breaking. By Lemma 2.1, we can uniquely define the following marginal rank for every vertex. Definition 2.2 (Marginal Rank) For any u and any ranks (cid:126)y-u of other vertices, the marginal rank θ of u with respect to (cid:126)y-u is the largest value such that u is passive in M (yu = θ-, (cid:126)y-u). Note that a vertex may still match another vertex (actively) when its rank is below the marginal rank in our fully online model. Nevertheless, it is consistent with the previous definition in the one-sided online model that concerns offline vertices, which cannot match actively. Lemma 2.2 (Unmatched Neighbor) Suppose v has marginal rank θ < 1 with respect to (cid:126)y-v. Then, for any neighbor u of v that has an earlier deadline than v, and for any rank vector (yv = y, (cid:126)y-v) with y ∈ [θ, 1), u either is passive, or actively matches a vertex with rank at most θ. It is well known that removing a matched vertex from the graph results in an alternating path in the matching produced by Ranking. The next lemma provides a more fine-grained characterization. Lemma 2.3 (Alternating Path) If u is matched in (cid:126)y, then the symmetric difference between the matchings M ((cid:126)y) and M ((cid:126)y-u) is an alternating path (u0, u1, . . . , ul) with u0 = u such that 5 1. for all even i < l, we have (ui, ui+1) ∈ M ((cid:126)y); for all odd i < l, we have (ui, ui+1) ∈ M ((cid:126)y-u); 2. from M ((cid:126)y) to M ((cid:126)y-u), vertices {u1, u3, . . .} get worse, vertices {u2, u4, . . .} get better. Here, passive is better than active, which is in turns better than unmatched. Conditioned on being passive, matching to a vertex with earlier deadline is better. Conditioned on being active, matching to a vertex with higher rank is better. 2.2 Randomized Dual Fitting Consider the following linear program relaxation of the matching problem and its dual. max : (cid:80) s.t. (cid:80) (u,v)∈E xuv v:(u,v)∈E xuv ≤ 1 xuv ≥ 0 ∀u ∈ V ∀(u, v) ∈ E min : (cid:80) u∈V αu s.t. αu + αv ≥ 1 αu ≥ 0 ∀(u, v) ∈ E ∀u ∈ V It is known that the above linear program relaxation is integral for bipartite graphs, but it has a large integrality gap for general graphs (e.g., a complete graph of 3 vertices). Interestingly, this relaxation is sufficient for proving our positive results, even for general graphs. Our approach builds on the randomized primal dual technique by Devanur et al. [DJK13]. We believe it is more appropriate to call our analysis (for general graphs) randomized dual fitting, however, because it relies on an extra phase of adjustments to the dual variables at the end that requires full knowledge of the instance. Randomized Dual Fitting. We set the primal variables according to the matching by Ranking, which ensures primal feasibility, and set the dual variables such that the dual objective equals the primal objective. The dual assignment can be viewed as splitting the gain of 1 of every matched edge among the vertices; the dual variable αv for every vertex v is equal to the total share it gets from all matched edges. Given primal feasibility and equal objectives, the usual primal dual and dual fitting techniques would further seek to show approximate dual feasibility, namely, αu +αv ≥ F for every edge (u, v) where F is the target competitive ratio. This is where the usual techniques fail and the smart insight by Devanur et al. [DJK13] comes to help. Due to the intrinsic randomness of Ranking, the above primal and dual assignments are themselves random variables. Devanur et al. [DJK13] observe that it suffices to have approximate dual feasibility in expectation. For completeness, we formulate this insight as the following lemma and include a proof in Appendix A. Lemma 2.4 Ranking is F -competitive if we can set (non-negative) dual variables such that 1. (cid:80) (u,v)∈E xuv =(cid:80) 2. E(cid:126)y[αu + αv] ≥ F for all (u, v) ∈ E. u∈V αu; and 3 Bipartite Graphs: A Warm-up Dual Assignment. We adopt the dual assignment by Devanur et al. [DJK13] and share the gain of each matched edge between its two endpoints as follows: • Gain Sharing: Whenever an edge (u, v) is added to the matching with u active and v passive, let αu = 1 − g(yv) and αv = g(yv). Here, g : [0, 1] → [0, 1] is non-decreasing with g(1) = 1. 6 Randomized Primal Dual Analysis. The previous analysis of Ranking for Online Bipartite Matching relies on a structural property that for any edge (u, v) and any ranks (cid:126)y-v, u matches a vertex with rank no larger than v's marginal rank regardless of v's rank (e.g. Lemma 2.3 of [DJK13]). However, in our fully online setting, the same property holds only when u is active. By introducing the notions of passive and active vertices, we show the following weaker version of the property. It complements the basic property when yu is larger than the marginal rank (Lemma 2.2). Lemma 3.1 Suppose v has marginal rank θ < 1 with respect to (cid:126)y-v. Then, for any neighbor u of v that has an earlier deadline than v, and for any rank vector (yv = y, (cid:126)y-v) with y ∈ [0, θ), u either is passive, or matches actively to a vertex with rank at most θ. Proof: We consider the matchings in 3 sets of ranks (cid:126)y = (yv = y, (cid:126)y-v), (cid:126)y-v and (cid:126)yθ = (yv = θ, (cid:126)y-v). First, we show that u matches the same neighbor in M ((cid:126)yθ) and M ((cid:126)y-v). Since v is unmatched or active in M ((cid:126)yθ), removing v cannot affect vertices with earlier deadlines. In particular, u would match the same neighbor. Consider the alternating path from M ((cid:126)y) to M ((cid:126)y-v). If u is not in the alternating path, then u matches the same neighbor in all M ((cid:126)y), M ((cid:126)y-v) and M ((cid:126)yθ). Otherwise, u appears in the alternating path with an odd distance from v since the graph is bipartite. Hence, by Lemma 2.3, u is better in M ((cid:126)y) than in M ((cid:126)y-v) and, thus, is better than in M ((cid:126)yθ). In both cases, u is passive or actively matches a vertex with rank ≤ θ in M ((cid:126)y), since this holds for u in M ((cid:126)yθ) (by Lemma 2.2). Recall that for any edge (u, v) we will consider the expected gain of αu and αv combined over the randomness of the ranks of both u and v. First, let us fix the rank of u, the vertex with an earlier deadline, and consider the expected gain over the randomness of v's rank alone. Lemma 3.2 For any neighbor u of v that has an earlier deadline than v, and for any (cid:126)y-v, we have Eyv [αu + αv] ≥ f (yu) def = minθ∈[0,1] and gets g(yv) when yv < θ, i.e. Eyv [αv · 1 (yv < θ)] = (cid:82) θ Proof: Let θ be the marginal rank of v with respect to ranks (cid:126)y-v. By definition, v is passive 0 g(yv)dyv. By Lemma 2.2 and 3.1, Eyv [αu] ≥ min{1 − g(θ), g(yu)}. Adding them together and taking the minimum over all possible θ's concludes the statement. (cid:110)(cid:82) θ 0 g(yv)dyv + min{1 − g(θ), g(yu)}(cid:111) . It is worthwhile to make a comparison with a similar claim in the previous analysis by Devanur et al. [DJK13] for Online Bipartite Matching: Eyv [αu + αv] ≥ minθ∈[0,1] (cid:110)(cid:82) θ 0 g(yv)dyv + 1 − g(θ) (cid:111) , where u is an online vertex and v is an offline vertex. As we have discussed in the introduction, for every edge in our model, the endpoint with an earlier deadline plays a similar role as the online vertex in the previous one-sided online model since the edge can only be added to the matching as a result of this endpoint's matching decision. In this sense, the bounds are indeed very similar, except for the last term, where the previous bound simply has 1 − g(θ) while our bound has the smaller of 1 − g(θ) and g(yu). We interpret Lemma 3.2 as follows. It recovers the previous bound when the rank of u is large (1 − g(θ) ≤ g(yu)), which roughly corresponds to the case when u is active (or unmatched) and the previous structural property holds. When the rank of u is small (1 − g(θ) > g(yu)), which roughly corresponds to the case when u is passive, it still provides some weaker lower bound on the expected gains of the two endpoints. The weaker bound, however, is at most 0.5 in the worst 7 case: the RHS becomes min{1 − g(0), g(0)} ≤ 0.5 for θ = yu = 0. Hence, it is crucial that we take expectation over the randomness of u's rank as well, effectively amortizing the cases when u is active and when it is passive. This idea carries over to general graphs. Proof of Theorem 1.2: Let g(x) = ex−1, where x ∈ [0, 1]. For all (u, v) ∈ E, by Lemma 3.2, E(cid:126)y [αu + αv] = E(cid:126)y-v [Eyv [αu + αv]] ≥ E(cid:126)y-v [f (yu)] =(cid:82) 1 0 f (yu)dyu. Observe that and(cid:82) θ (cid:82) θ 0 g(z)dz + 1 − g(θ) = eθ−1 − 1 0 g(z)dz + g(x) ≥ g(x) for all θ ∈ [0, 1]. We have f (x) ≥ min{g(x), 1 − 1 (cid:82) 1 0 f (x)dx ≥(cid:82) θ e + (1 − ln(e − 1))(1 − 1 0 ex−1dx + (1 − θ)(1 − 1 e + 1 − eθ−1 = 1 − 1 e ) = e−2 θ = ln(e − 1) s.t. g(θ) = 1 − 1 e ) e e}, which implies (let e ) ≈ 0.55418. By Lemma 2.4, we conclude that Ranking is at least 0.5541-competitive. We are aware of a different function g(y) = min{1, ey−1 + 0.0128} that gives a (very slightly) better competitive ratio 0.5547. For convenience of presentation we only fix a simple form here. 4 General Graphs: An Overview Dual Assignment. Moving from bipartite graphs to general graphs, even the weaker version of the structural property, i.e., Lemma 3.1, ceases to hold. Consider an edge (u, v) with u's deadline being earlier. It is possible that decreasing yv leads to a change of u's status from matched to unmatched in a non-bipartite graph. As a result, the simple gain sharing rule in the previous analysis on the bipartite case no longer gives any bound strictly better than 0.5. To handle general graphs, we design a novel charging mechanic on top of the gain sharing rule between the endpoints of matched edges. First, we introduce the following notion of victim. Definition 4.1 (Victim) For any ranks (cid:126)y and any active vertex w, v is w's victim if • v is an unmatched neighbor of w; • v is matched in M ((cid:126)y-w). Observe that removing w results in an alternating path (Lemma 2.3) and, thus, at most one vertex changes from unmatched to matched. Hence, each active vertex has at most one victim. Consider the following two-step approach for computing a dual assignment: • Gain Sharing: Whenever an edge (u, v) is added to the matching with u active and v passive, let αu = 1 − g(yv) and αv = g(yv). Here, g : [0, 1] → [0, 1] is non-decreasing with g(1) = 1. • Compensation: For every active vertex u that has a victim z, suppose u is matched to v. Decrease αu and increase αz by the same amount h(yv), where h : [0, 1] → [0, 1] is non- decreasing in [0, 1), h(y)/y is non-increasing, h(1) = 0 and 1 − g(y) − h(y) ≥ 0 for all y. Note that the second step, in particular, identifying the victims of active vertices, can only be done after the entire instance has been revealed. Each matched vertex will gain only from its incident matched edge. If it is further active and has a victim, it needs to send a compensation to the victim. Further, the active vertex can always afford the compensation from its gain since 1 − g(y) − h(y) ≥ 0 for all y ∈ [0, 1). The monotonicity of h(y)/y is for technical reasons in the analysis. Finally, note that an unmatched vertex may receive compensations from any number of active vertices. 8 (a) when yv = θ- (b) when yv ∈ [θ, τ ) (c) the symmetric difference Figure 4.1: We use solid line to represent an edge in the matching, where the direction (if any) is from active vertex to passive vertex. (a) when v is higher than its marginal rank, u matches a vertex with rank yz = τ > θ; (b) v is unmatched and compensated by w when it is lower than its marginal rank; u either is passive, or matches actively some vertex with rank higher than τ since v is unmatched; (c) the symmetric difference between the two matchings: an alternating path triggered when yv increases to be larger than its marginal rank. Randomized Dual Fitting Analysis. The main technical lemma is to establish a lower bound for Eyv [αu + αv], as we have done in Lemma 3.2 for bipartite graphs. Due to space constraint, we present the analysis for a special case with following assumptions (θ is the marginal rank of v): • v is unmatched in M (yv = y, (cid:126)y-v) for all y ≥ θ; • u actively matches the same vertex z with rank yz = τ > θ in M (yv = y, (cid:126)y-v) for all y < θ. In other words, any rank of v higher than its marginal rank leads to the same (worse) situation for u, i.e. matching a vertex with rank τ ∈ (θ, 1). See Figure 4.1 for an illustrative example. In general, we need to also consider the case that v is active when its rank is lower than the marginal θ, and the possibility that u's matching status may change multiple times as the rank of v gets higher. See Appendix B.1 for the analysis without the simplifying assumptions. Subject to the above simplifying assumptions, we show the following: Lemma 4.1 For any neighbor u of v that has an earlier deadline than v, and for any (cid:126)y-v, we have Eyv [αv + αu] ≥(cid:82) θ 0 g(yv)dyv + (τ − θ) · h(θ) + θ · (1 − g(τ ) − h(τ )) + (1 − θ) · min(cid:8)g(yu), 1 − g(θ) − h(θ)(cid:9) . Suppose w matches actively to v in M (yv = θ-, (cid:126)y-v) (refer to Figure 4.1(a)), that is, it is the first vertex after v in the alternating path when v's rank moves below its marginal rank (refer to Figure 4.1(c)). We show in the following lemma that v receives a compensation from w whenever its rank yv is between θ and τ (refer to Figure 4.1(b)). Lemma 4.2 For any y ∈ [θ, τ ), v is the victim of w in M (yv = y, (cid:126)y-v). Proof: Let (cid:126)y1 = (yv = y, (cid:126)y-v), where y ∈ [θ, τ ). By our assumption, v is unmatched and, thus, is an unmatched neighbor of w in M ((cid:126)y1). To prove that v is the victim of w, we need to show that (1) w is active in M ((cid:126)y1) and (2) v becomes matched when we remove w from the graph. Consider (cid:126)y2 = (yv = θ-, (cid:126)y-v). By our assumptions, v is passively matched to w and u actively matches z with yz = τ in M ((cid:126)y2). For this to happen, w must have an earlier deadline than v and none of matching decisions before w's deadline pick w or v. Then, lowering v's rank would not affect these decisions before w's deadline and, thus, w must also be active in M ((cid:126)y1). 9 vuwzvuwzCompensatevuwz𝑦𝑧=𝜏>𝜃...when 𝑦𝑣>𝜃when 𝑦𝑣=𝜃‐ Finally, consider what happens when w is removed from the graph. It triggers a portion of the alternating path (i.e., Figure 4.1(c)), the symmetric difference between M ((cid:126)y1) and M ((cid:126)y2). The portion starts from w (exclusive) and ends the first time when v becomes relevant, i.e., a vertex in the alternating path decides to pick v instead of the next vertex in the path. Further, we know for sure that v will be relevant at some point because otherwise u is in the path and the next vertex z has rank τ > y. Therefore, v must be matched when w is removed from the graph. The next two lemmas give lower bounds on the expected gain of αv and αu, respectively, over the randomness of v's rank alone. Lemma 4.3 Eyv [αv] ≥(cid:82) θ 0 g(yv)dyv + (τ − θ) · h(θ). Proof: By definition, when yv < θ, v is passive and hence αv = g(yv). Since w matches v actively in M (yv = θ-, (cid:126)y-v) but not in M (yv = θ, (cid:126)y-v), we know that w must match a vertex with rank θ in M (yv ≥ θ, (cid:126)y-v). For yv ∈ [θ, τ ), Lemma 4.2 implies that v is the victim of w and, thus, v receives a compensation h(θ) from w. To sum up, we have Eyv [αv] ≥ Eyv [αv · 1 (yv < θ)] + Eyv [αv · 1 (yv ∈ [θ, τ ))] ≥(cid:82) θ 0 g(yv)dyv + (τ − θ)h(θ), as claimed. Lemma 4.4 Eyv [αu] ≥ θ · (1 − g(τ ) − h(τ )) + (1 − θ) · min{g(yu), 1 − g(θ) − h(θ)}. Proof: By assumption, u actively matches vertex z with rank yz = τ when yv < θ. Thus, u gains 1 − g(τ ) during the gain sharing phase and gives away h(τ ) to its victim (if any). Integrating yv from 0 to θ gives the first term on the RHS. For yv ≥ θ, u either is passive, or actively matches a vertex with rank at most θ. In the first case, we have αu = g(yu). In the second case, we have αu ≥ 1 − g(θ) − h(θ), by the monotonicity of g, h. Integrating yv from θ to 1 gives the second term on the RHS. Summing up the inequalities in Lemma 4.3 and 4.4 proves Lemma 4.1. Comparing the bounds of Lemma 4.3 and Lemma 4.4, the parameter τ presents a trade-off between the expected gains αu and αv of the two vertices. The larger τ is, the less u gets when v is above its marginal rank, e.g., 1 − g(τ ) − h(τ ), and the more v gets as compensations when it is below its marginal rank, e.g., (τ − θ) · h(τ ); and vice versa. Charging Functions. functions g, h (with desired properties) and constant F > 0.5 such that If Lemma 4.1 holds unconditionally, it remains to show that there exists (cid:90) 1 0 min 0≤θ<τ <1 (cid:26)(cid:90) θ + (1 − θ) · min(cid:8)g(yu), 1 − g(θ) − h(θ)(cid:9)(cid:27) g(yv)dyv + (τ − θ)h(θ) + θ · (1 − g(τ ) − h(τ )) dyu ≥ F , 0 and to apply Lemma 2.4 to conclude that Ranking is F -competitive. The unconditional version of Lemma 4.1 turns out to give a more complicated bound due to the considerations of other cases. Nevertheless, we can use a linear program to optimize the ratio over fine-grained discretized versions of g and h. To give a rigorous proof, which is deferred to Appendix B.2, we approximate the solutions of the linear program with piecewise-linear g and h (with two segments). We conclude with our choice of g and h that Ranking is 0.5211-competitive. 10 References [ACC+16] Melika Abolhassani, T.-H. Hubert Chan, Fei Chen, Hossein Esfandiari, Mohammad- Taghi Hajiaghayi, Hamid Mahini, and Xiaowei Wu. Beating ratio 0.5 for weighted oblivious matching problems. In ESA, volume 57 of LIPIcs, pages 3:1–3:18. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2016. [ADFS95] Jonathan Aronson, Martin Dyer, Alan Frieze, and Stephen Suen. Randomized greedy matching. ii. Random Struct. Algorithms, 6(1):55–73, January 1995. [AGKM11] Gagan Aggarwal, Gagan Goel, Chinmay Karande, and Aranyak Mehta. Online vertex- In SODA, pages weighted bipartite matching and single-bid budgeted allocations. 1253–1264, 2011. [BJN07] [BM08] [BST17] Niv Buchbinder, Kamal Jain, and Joseph Naor. Online primal-dual algorithms for maximizing ad-auctions revenue. In ESA, volume 4698 of Lecture Notes in Computer Science, pages 253–264. Springer, 2007. Benjamin Birnbaum and Claire Mathieu. On-line bipartite matching made simple. ACM SIGACT News, 39(1):80–87, 2008. Niv Buchbinder, Danny Segev, and Yevgeny Tkach. Online algorithms for maximum cardinality matching with edge arrivals. In ESA, volume 87 of LIPIcs, pages 22:1–22:14. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2017. [CCWZ14] T.-H. Hubert Chan, Fei Chen, Xiaowei Wu, and Zhichao Zhao. Ranking on arbitrary graphs: Rematch via continuous lp with monotone and boundary condition constraints. In SODA, pages 1112–1122, 2014. [CTV15] Ashish Chiplunkar, Sumedh Tirodkar, and Sundar Vishwanathan. On randomized algorithms for matching in the online preemptive model. In ESA, volume 9294 of Lecture Notes in Computer Science, pages 325–336. Springer, 2015. [DJ12] Nikhil R. Devanur and Kamal Jain. Online matching with concave returns. In STOC, pages 137–144. ACM, 2012. [DJK13] Nikhil R. Devanur, Kamal Jain, and Robert D. Kleinberg. Randomized primal-dual analysis of RANKING for online bipartite matching. In SODA, pages 101–107. SIAM, 2013. [ELSW13] Leah Epstein, Asaf Levin, Danny Segev, and Oren Weimann. Improved bounds for online preemptive matching. In STACS, volume 20 of LIPIcs, pages 389–399. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2013. [GM08] Gagan Goel and Aranyak Mehta. Online budgeted matching in random input models with applications to adwords. In SODA, pages 982–991, 2008. [KMT11] Chinmay Karande, Aranyak Mehta, and Pushkar Tripathi. Online bipartite matching with unknown distributions. In STOC, pages 587–596, 2011. [KVV90] Richard M. Karp, Umesh V. Vazirani, and Vijay V. Vazirani. An optimal algorithm for on-line bipartite matching. In STOC, pages 352–358, 1990. 11 [McG05] Andrew McGregor. Finding graph matchings in data streams. In APPROX-RANDOM, volume 3624 of Lecture Notes in Computer Science, pages 170–181. Springer, 2005. [MSVV07] Aranyak Mehta, Amin Saberi, Umesh V. Vazirani, and Vijay V. Vazirani. Adwords and generalized online matching. J. ACM, 54(5):22, 2007. [MY11] [Var11] [WW15] Mohammad Mahdian and Qiqi Yan. Online bipartite matching with random arrivals: an approach based on strongly factor-revealing LPs. In STOC, pages 597–606, 2011. Ashwinkumar Badanidiyuru Varadaraja. Buyback problem - approximate matroid intersection with cancellation costs. In ICALP (1), volume 6755 of Lecture Notes in Computer Science, pages 379–390. Springer, 2011. Yajun Wang and Sam Chiu-wai Wong. Two-sided online bipartite matching and ver- tex cover: Beating the greedy algorithm. In Automata, Languages, and Programming - 42nd International Colloquium, ICALP 2015, Kyoto, Japan, July 6-10, 2015, Proceed- ings, Part I, pages 1070–1081, 2015. 12 A Missing Proofs in Section 2 Proof of Lemma 2.1: For the first statement, since u is active or unmatched, we know that for each neighbor v of u with an earlier deadline than u, v does not match u in M ((cid:126)y) at their deadlines. Hence when yu increases, they would make the same decision. In other words, when u's deadline reaches, the partial matching produced is the same as before. As a consequence, the eventual matching produced would be identical, as u will actively match the same vertex as in M ((cid:126)y). The second statement is implied by the first statement. Suppose otherwise, e.g., u is active or unmatched when yu is decreased from y to some y(cid:48) < y. Then we know that by increasing yu from y(cid:48) to y, u becomes passive, which violates the first statement. Proof of Lemma 2.2: Consider the matching M (yv = θ, (cid:126)y-v). By definition, v is either active or unmatched. Hence, at u's deadline, which is earlier than v's deadline, v is unmatched. Conse- quently, u either is passive or matches actively to some vertex w with yw ≤ yv = θ. By Lemma 2.1, there is no change in the matching when we increases yu, which concludes the proof. Proof of Lemma 2.3: We prove the lemma by mathematical induction on n, the total number of vertices. For the base case when n = 2, the symmetric difference is a single edge (u, u1) and the second statement holds since u1 is matched in M ((cid:126)y) and unmatched in M ((cid:126)y-u). (cid:126)y(cid:48) ∈ [0, 1]V \{u,u1} be the resulting vector), then we have M ((cid:126)y) = M ((cid:126)y(cid:48)) ∪ {(u, u1)}. Suppose the lemma holds for 1, 2, . . . , n − 1 and we consider the case when V = n. Let u1 be matched to u in M ((cid:126)y). Observe that if we remove both u and u1 from G (let If u1 is unmatched in M ((cid:126)y-u), then we have M ((cid:126)y-u) = M ((cid:126)y(cid:48)) and the lemma holds by induction hypothesis. Now suppose u1 is matched in M ((cid:126)y-u). By definition (cid:126)y(cid:48) is obtained by removing u1 (which is matched in (cid:126)y-u) from (cid:126)y-u. By induction hypothesis, the symmetric difference between M ((cid:126)y-u) and M ((cid:126)y(cid:48)) is an alternating path (u1, . . . , ul) such that (a) for all odd i < l, we have (ui, ui+1) ∈ M ((cid:126)y-u); for all even i < l, we have (ui, ui+1) ∈ M ((cid:126)y(cid:48)); (b) from M ((cid:126)y-u) to M ((cid:126)y(cid:48)), vertices {u2, u4, . . .} get worse, vertices {u3, u5, . . .} get better. Hence the symmetric difference between M ((cid:126)y) and M ((cid:126)y-u) is the alternating path (u, u1, . . . , ul) (recall that M ((cid:126)y) = M ((cid:126)y(cid:48)) ∪ {(u, u1)}). It is easy to see that statement (a) holds, and statement (b) holds for vertices {u2, . . . , ul}. Now consider vertex u1, which is matched to u in M ((cid:126)y), and matched to u2 in M ((cid:126)y-u). If u1 is passively matched (by u) in M ((cid:126)y), then we know that u has an earlier deadline than u1. Hence in M ((cid:126)y-u), either u1 is active, or passively matched by some u2 with a deadline later than u. In other words, u1 gets worse from M ((cid:126)y) to M ((cid:126)y-u). If u1 matches u actively in M ((cid:126)y), then we know that u1 has an earlier deadline than u. Hence when u1 is considered in (cid:126)y-u, the set of unmatched vertices (except for u) is identical as in M ((cid:126)y). Consequently, u1 actively matches some vertex u2 with yu2 > yu (otherwise u1 will not match u in M ((cid:126)y)). In other words, u1 gets worse from M ((cid:126)y) to M ((cid:126)y-u). Proof of Lemma 2.4: Let αu := E(cid:126)y [αu] /F for all u ∈ V . By the first assumption, (cid:35) (cid:34)(cid:88) u∈V αu = 1 F E(cid:126)y  (cid:88) (u,v)∈E  . xuv (cid:88) (cid:88) u∈V αu = u∈V F E(cid:126)y [αu] = 1 F E(cid:126)y Moreover, α is a feasible dual solution: by the second assumption, αu+ αv = E(cid:126)y [αu + αv] /F ≥ 1 13 for all (u, v) ∈ E. By duality, we conclude that  (cid:88) (u,v)∈E 1 F E(cid:126)y  = (cid:88) u∈V αu ≥ OPT, xuv where OPT is the optimal primal solution, which is at least the size of a maximum matching. B Missing Proofs in Section 4 B.1 General Version of Lemma 4.1 In this section we prove the following lemma, which is a general version of Lemma 4.1 (without the simplifying assumptions on u, v we made in Section 4). Lemma B.1 For any neighbor u of v that has an earlier deadline than v, and for any (cid:126)y-v, we have Eyv [αu + αv] ≥ f (yu) (cid:90) θ def = min (cid:8)(cid:90) θ (cid:26) +(1 − θ) min{g(yu), 1 − g(θ) − h(θ)} + θ min{g(yu), 1 − g(τ ) − h(τ )}(cid:9), (cid:27) g(yv)dyv + min{(1 − θ)(1 − g(1-) − h(1-)), (τ − θ)h(θ)} min τ∈[θ,1) 0 θ g(yv)dyv + (1 − θ) min{1 − g(1-) − h(1-), h(θ)} + (1 − θ) min{g(yu), 1 − g(θ)} . 0 Fix any neighbor u of v with an earlier deadline than v, and any (cid:126)y-v. Let θ be the marginal rank of v, i.e. v is passive only when yv < θ. By Lemma 2.2, we know that when yv ≥ θ, u either is passive or actively matches some vertex with rank at most θ. We define in the following two lists of thresholds {θi}m+1 i=0 and {τi}m+1 i=0 that captures the match- ing statuses of u when yv is smaller than the marginal rank θ. Imagine that we decrease yv continuously starting from yv = θ. Let θ0 = θ and τ0 = θ. We define yv = θ- i+1 to be the first moment after θi when u actively matches some vertex zi+1 with yzi+1 > τi. For convenience of description, we say that u actively matches a vertex with rank 1 if u is unmatched (by definition, the gain of αu is 0 in both descriptions since 1 − g(1) = 0). Define τi+1 := yzi+1. Let θm be the last non-zero threshold. For convenience, we define θm+1 = 0 and τm+1 = 1. By definition we have the following fact. Fact B.1 There exists a sequence of non-increasing thresholds {θi}m+1 decreasing thresholds {τi}m+1 i=0 and a sequence of non- such that i=0 1. for all 0 ≤ i ≤ m and y ∈ [θi+1, θi), u is passive or actively matches some vertex with rank at most τi in M (yv = y, (cid:126)y-v); 2. for all 1 ≤ i ≤ m, u actively matches a vertex zi with rank τi in M (yv = θ- For all i ∈ [m], let wi be be vertex that actively matches v in M (yv = θ- Observe that all wi's must be different, e.g. the deadline of wi+1 must be earlier than wi, in i+1, (cid:126)y-v). Moreover, we know that in M (yv = θ, (cid:126)y-v), each wi order for wi+1 to match v in M (yv = θ- matches a vertex with rank θi, since wi chooses v in M (yv = θ- i, (cid:126)y-v) but not in M (yv = θi, (cid:126)y-v). Lemma B.2 For all y ∈ [θ, τi), if v is unmatched in M (yv = y, (cid:126)y-v), then v is the victim of wi. i, (cid:126)y-v). i, (cid:126)y-v). 14 Proof: Let (cid:126)y1 = (yv = y, (cid:126)y-v), where y ∈ [θ, τi). Trivially, v is an unmatched neighbor of wi in M ((cid:126)y1). To prove that v is the victim of wi, it suffices to show that wi is active in M ((cid:126)y1) and v becomes matched when we remove wi from the graph. Let (cid:126)y2 = (yv = θ- i, (cid:126)y-v). By definition, v is passively matched by wi and u actively matches zi with yzi = τi in M ((cid:126)y2). It is easy to see that wi is also active in M ((cid:126)y1), as otherwise, wi should still be passive in M ((cid:126)y2) given that v does not affect any decisions before wi's deadline. Let (cid:126)y3 be the ranks by removing the wi-th entry from (cid:126)y1. Assume for contrary that v is unmatched in M ((cid:126)y3). Then we have M ((cid:126)y3) = M ((cid:126)y2) \ {(wi, v)}. This implies that u actively matches zi in M ((cid:126)y3) while v (with rank yv < yzi = τi) is unmatched, which is a contradiction. Equipped with Lemma B.2, we first give a lower bound on the expected gain of αv. For notational convenience, we define a new function φ : [0, 1] → [0, 1] such that φ(y) := 1− g(y)− h(y). Recall by definition of g and h, φ is a non-increasing function with φ(1) = 0. i=0(τi − θ)h(θi)}. Lemma B.3 Eyv [αv] ≥(cid:82) θ Proof: By definition, v is passive when yv < θ. Hence we have Eyv [αv · 1 (yv < θ)] =(cid:82) θ 0 g(yv)dyv + min{(1 − θ)φ(1-),(cid:80)m 0 g(yv)dyv, which corresponds to the first term on the RHS. For all yv ≥ θ, v is either active or unmatched. In the first case, let p be matched passively by v in M (yv, (cid:126)y-v). We know that v gains 1 − g(yp) during the gain sharing phase and gives away h(yp) to its victim (if any), which implies αv ≥ 1 − g(yz) − h(yz) = φ(yz) ≥ φ(1-). Hence we have Eyv [αv · 1 (yv ≥ θ)] ≥ (1 − θ)φ(1-). In the second case, by Lemma B.2, v is the victim of wi when yv ∈ [θ, τi). Hence v gains (cid:80)m h(θi) from wi in the compensation phase (recall that wi matches a vertex with rank θi when yv ∈ [θ, τi)). Putting all compensation (from w1, . . . , wm) together, we get Eyv [αv · 1 (yv ≥ θ)] ≥ i=0(τi − θ)h(θi), which corresponds to the second the term on the RHS. Lemma B.4 Eyv [αu · 1 (yv < θ)] ≥(cid:80)m i=0(θi − θi+1) min{g(yu), φ(τi)}. Proof: We partition the interval [0, θ) into m + 1 segments: [θi+1, θi), for 0 ≤ i ≤ m. Fix any i, and consider yv ∈ [θi+1, θi). If u is passive in M (yv, (cid:126)y-v), then we have αu ≥ g(yu). Otherwise, we know that u actively matches a vertex z with yz ≤ τi (by Fact B.1). Hence u gains 1− g(yz) during the gain sharing phase and gives away h(yz) to its victim (if any), i.e., we have αu ≥ φ(yz) ≥ φ(τi). Summing up the gain from the m + 1 segments concludes the proof. Observe that for lower bounding Eyv [αu + αv], we shall consider the total gain of αu + αv. We may omit the compensation from u to v, since it does not change the summation. For analysis convenience, we assume v is never a victim of u. Lemma B.5 Eyv [αu · 1 (yv ≥ θ)] ≥ (1 − θ) min{g(yu), φ(θ)}. Moreover, if τm = 1, then we have Eyv [αu · 1 (yv ≥ θ)] ≥ (1 − θ) min{g(yu), 1 − g(θ)}. Proof: Therefore, αu ≥ min{g(yu), φ(θ)}. Integrating yv from θ to 1 gives the first statement. For all yv ≥ θ, u is either passive or actively matches a vertex with rank at most θ. m. Fix any (cid:126)y = (yv, (cid:126)y-v), where yv ≥ θ. We show that u does not have any unmatched neighbor other than v in M ((cid:126)y), which implies that u does not have a victim and hence αu ≥ min{g(yu), 1 − g(θ)}. When τm = 1, we know that u is unmatched when yv = θ- Suppose otherwise, let z (cid:54)= v be the unmatched neighbor of u in M ((cid:126)y). Let (cid:126)y1 = (yv = θ- m, (cid:126)y-v). We know that u is matched in M ((cid:126)y) and unmatched in M ((cid:126)y1). Consider the partial matchings produced right after u's deadline when Ranking is run with (cid:126)y and 15 (cid:126)y1, respectively. We denote the matchings by Mu((cid:126)y) and Mu((cid:126)y1), respectively. It is easy to see that the symmetric difference between Mu((cid:126)y) and Mu((cid:126)y1) is an alternating path, with u being one endpoint. Observe that v is matched in Mu((cid:126)y1) (as u is unmatched), and is unmatched in Mu((cid:126)y) (as it is not passive in M ((cid:126)y)). Hence v is the other end point of the alternating path. Consequently, we know that z is unmatched in Mu((cid:126)y1) (as it is unmatched in Mu((cid:126)y)), which is a contradiction as its neighbor u is also unmatched in Mu((cid:126)y1). The next technical lemma shows that the worst case is achieved when there exists only one threshold θm = θ, i.e. u matches some vertex with rank τ > θ in M (yv = θ-, (cid:126)y-v), and matches a vertex with rank at most τ for all yv < θ. Lemma B.6 Given that h(y)/y is a non-increasing function, we have (cid:26) (cid:26) m(cid:88) (cid:27) m(cid:88) i=0 i=0 min (1 − θ)φ(1-), (τi − θ)h(θi) + (θi − θi+1) min{g(yu), φ(τi)} ≥ min Proof: Consider the first term of LHS. If (1 − θ)φ(1-) <(cid:80)m min{(1 − θ)φ(1-), (τi − θ)h(θ)} + θ min{g(yu), φ(τi)} i i=0(τi − θ)h(θi), we have m(cid:88) LHS ≥(1 − θ)φ(1-) + (θi − θi+1) min{g(yu), φ(τm)} =(1 − θ)φ(1-) + θ min{g(yu), φ(τm)} ≥ RHS. i=0 If (1 − θ)φ(1-) ≥(cid:80)m LHS = (θi − θi+1) min{g(yu), φ(τi)} (cid:27) . (cid:19) (cid:19) (cid:27) i=0 i=0 (τi − θ)h(θi) + i=0(τi − θ)h(θi), we have m(cid:88) m(cid:88) (cid:18) τi − θ m(cid:88) (cid:18) τi − θ ≥ m(cid:88) (cid:26) τj − θ ≥ m(cid:88) (θi − θi+1) min (θi − θi+1) (θi − θi+1) θi − θi+1 i=0 i=0 = θ j θ (cid:26) i=0 = min j h(θi) + min{g(yu), φ(τi)} h(θ) + min{g(yu), φ(τi)} h(θ) + min{g(yu), φ(τj)} (cid:27) (τj − θ)h(θ) + θ min{g(yu), φ(τi)} ≥ RHS, where the first inequality follows from τi−θ θi−θi+1 h(θi) ≥ (τi − θ) h(θi) θi ≥ (τi − θ) h(θ) θ . Proof of Lemma B.1: By Lemma B.3 and B.4, we have (cid:90) θ Eyv [αv] + Eyv [αu · 1 (yv < θ)] (cid:90) θ g(yv)dyv + min (cid:40) (cid:26) 0 (1 − θ)φ(1-), g(yv)dyv + min i 0 ≥ ≥ m(cid:88) (τi − θ)h(θi) (cid:41) m(cid:88) i=0 i=0 min{(1 − θ)φ(1-), (τi − θ)h(θ)} + θ min{g(yu), φ(τi)} , + (θi − θi+1) min{g(yu), φ(τi)} (cid:27) 16 where the last inequality comes from Lemma B.6. Combining with Lemma B.5 (which gives different lower bounds for Eyv [αu · 1 (yv ≥ θ)] de- pending on whether τm = 1), we prove Lemma B.1 for two cases, depending on whether τm = 1. If τm < 1, we have (recall that φ(θ) = 1 − g(θ) − h(θ) ≤ 1 − g(θ)) (cid:90) θ Eyv [αu + αv] = Eyv [αv] + Eyv [αu · 1 (yv < θ)] + Eyv [αu · 1 (yv ≥ θ)] (cid:8) min{(1 − θ)φ(1-), (τ − θ)h(θ)} + θ min{g(yu), φ(τ )}(cid:9) ≥ g(yv)dyv + min τ∈[θ,1) 0 + (1 − θ) min{g(yu), φ(θ)}, which corresponds to the first term of the outer most min in the expression of Lemma B.1. (cid:8) min{(1 − θ)φ(1-), (τ − θ)h(θ)} + θ min{g(yu), φ(τ )}(cid:9) If τm = 1, we have Eyv [αu + αv] ≥ (cid:90) θ 0 (cid:40) g(yv)dyv + min τ∈[θ,1] + (1 − θ) min{g(yu), 1 − g(θ)} (cid:26)(cid:90) θ 0 ≥ min min τ∈[θ,1) g(yv)dyv + min{(1 − θ)φ(1-), (τ − θ)h(θ)} + θ min{g(yu), φ(τ )} (cid:27) + (1 − θ) min{g(yu), φ(θ)} , g(yv)dyv + (1 − θ) min{φ(1-), h(θ)} + (1 − θ) min{g(yu), 1 − g(θ)} (cid:41) . (cid:90) θ 0 Taking the minimum over all possible θ's concludes the proof. B.2 Lower Bound of the Competitive Ratio Recall that (cid:90) θ 0 0 f (yu) def= min θ min τ∈[θ,1) (cid:8)(cid:90) θ g(yv)dyv + (1 − θ) min{1 − g(1-) − h(1-), h(θ)} + (1 − θ) min{g(yu), 1 − g(θ)} g(yv)dyv + min{(1 − θ)(1 − g(1-) − h(1-)), (τ − θ)h(θ)} (cid:26) +(1 − θ) min{g(yu), 1 − g(θ) − h(θ)} + θ min{g(yu), 1 − g(τ ) − h(τ )}(cid:9), (cid:27) k1 x ∈ [0, t] gt + b, x ∈ (t, 1) x ∈ [0, t] ht, x ∈ (t, 1) hx, h(x − t) + k1 k2 0 gx + b, g(x − t) + k1 k2 1 k1 , h(x) = x = 1 x = 1 , . g(x) = We construct the functions g, h explicitly as follows (refer to Figure B.1). where t = 0.3, k1 non-decreasing in [0, 1) and h(x)/x is non-increasing. g = 0.1, b = 0.46, k1 g = 0.21, k2 h = 0.26, k2 h = 0.17. It is easy to see that both g, h are 17 Figure B.1: g(x) and h(x) We first simplify the expression of f (yu). Recall that we define φ(y) = 1 − g(y) − h(y), which is a decreasing function with φ(1) = 0. By definition of g, h stated above, we have φ(1-) = 0.21. Observe that (1 − θ)φ(1-) > (1 − θ) · 0.197 = (1 − θ)h(1-) ≥ (τ − θ)h(θ) for all τ, θ. Hence, (cid:26) (cid:27) where ψ1(yu, θ, τ ) def= ψ2(yu, θ) def= (cid:90) θ (cid:90) θ 0 0 f (yu) = min min θ≤τ <1 ψ1(yu, θ, τ ), min θ≤1 ψ2(yu, θ) , g(yv)dyv + (τ − θ)h(θ) + (1 − θ) min{g(yu), φ(θ)} + θ min{g(yu), φ(τ )} , g(yv)dyv + (1 − θ)h(θ) + (1 − θ) min{g(yu), 1 − g(θ)} . The following lemma implies that Ranking is 0.5211-competitive. Lemma B.7 (cid:82) 1 0 f (yu)dyu > 0.5211. (cid:26) (cid:27) Proof: As we will show in Lemma B.8 and Lemma B.9 below, we have f (yu) = min min θ≤τ <1 ψ1(yu, θ, τ ), min θ≤1 ψ2(yu, θ) ≥ min{g(yu), 0.5349}. Let y∗ u be such that g(y∗ u) = 0.5349, we have (cid:90) 1 (cid:90) y∗ u f (yu)dyu = 0 0 f (yu)dyu + f (yu)dyu = (cid:90) 1 y∗ u (cid:90) y∗ u 0 g(yu)dyu + (1 − y∗ u) · 0.5349 > 0.5211. We first consider the easier one, ψ2. Lemma B.8 For any θ ≤ 1, we have ψ2(yu, θ) > min{g(yu), 0.5349}. 18 Proof: First, if θ = 1, we have ψ2(yu, θ) =(cid:82) 1 If g(yu) < 1 − g(θ), we have ψ2(yu, θ) =(cid:82) θ 0 g(yv)dyv ≈ 0.5381 > 0.5349. Now consider θ < 1. 0 g(yv)dyv + (1 − θ)h(θ) + (1 − θ)g(yu). Thus (cid:40) = g(θ) + (1 − θ)h(cid:48)(θ) − h(θ) − g(yu), ∂ψ2 ∂θ ∂2ψ2 ∂θ2 = g(cid:48)(θ) − 2 · h(cid:48)(θ) = g − 2k2 k1 g − 2k2 k2 h = −0.31 θ < t h = −0.24 θ > t . Hence the minimum of ψ2(yu, θ) is achieved at arg minθ<1{ψ2(yu, θ)} ∈ {0, t, 1-}. Note that ψ2(yu, 0) = h(0) + g(yu) ≥ g(yu), (cid:90) t (cid:90) 1 0 ψ2(yu, t) = g(yv)dyv + (1 − t)h(t) + (1 − t)g(yu) > t · 0.673 + (1 − t) · g(yu) > g(yu), ψ2(yu, 1-) = g(yv)dyv ≈ 0.5381 > 0.5349. 0 We have minθ<1{ψ2(yu, θ)} ≥ min{g(yu), 0.5349}, as claimed. If g(yu) ≥ 1 − g(θ), we have ψ2(yu, θ) =(cid:82) θ = g(θ) + (1 − θ)h(cid:48)(θ) − h(θ) − (1 − g(θ)) − (1 − θ)g(cid:48)(θ), 0 g(yv)dyv + (1 − θ)h(θ) + (1 − θ)(1 − g(θ)). Thus (cid:40) ∂ψ2 ∂θ ∂2ψ2 ∂θ2 = 3 · g(cid:48)(θ) − 2 · h(cid:48)(θ) = 0.11 θ < t −0.04 θ > t . We calculate the zero point of ∂ψ2 ∂θ in [0, t), i.e., let ∂ψ2 ∂θ = 0, we have solution θ∗ = g − k1 1 + k1 g − 2k1 3k1 h − 2b h ≈ 0.273. (a) ψ2(yu, θ) (b) ∂ψ2 ∂θ Figure B.2: ψ2(yu, θ) and ∂ψ2 ∂θ Thus, for any fixed yu, ψ2(yu, θ) is decreasing in [0, θ∗] and increasing in (θ∗, t). So the minimum ∂θ2 < 0 in (t, 1), the minimum of ψ2(yu, θ) in of ψ2(yu, θ) in [0, t] is achieved at θ∗. Also, since ∂2ψ2 19 (cid:90) θ∗ (cid:90) 1 0 ψ2(yu, θ∗) = ψ2(yu, 1-) = [t, 1) is achieved at either t or 1-. To sum up, the overall minimum is achieved at either θ∗ or 1-: g(yv)dyv + (1 − θ∗)h(θ∗) + (1 − θ∗)(1 − g(θ∗)) ≈ 0.5359 > 0.5349 g(yv)dyv ≈ 0.5381 > 0.5349, Thus we have minθ<1 ψ2(yu, θ) = min{ψ2(yu, θ∗), ψ2(yu, 1-)} > 0.5349, as required. 0 Next we consider ψ1. If g(yu) ≤ φ(τ ), then we have ψ1(yu, θ, τ ) =(cid:82) θ Lemma B.9 For all θ ≤ τ < 1, we have ψ1(yu, θ, τ ) > min{g(yu), 0.5349}. Proof: θg(yu) ≥ g(yu), as required. Now consider g(yu) > φ(τ ). Observe that 0 g(yv)dyv + (τ − θ)h(θ) + (1 − θ)g(yu) + = h(θ) − θ(g(cid:48)(τ ) + h(cid:48)(τ )) ≤ 0, ∂ψ1 ∂τ where the last inequality holds since h(θ) ≤ k1 all τ we have ψ1(yu, θ, τ ) ≥ ψ1(yu, θ, 1-), i.e., the minimum is achieved when τ = 1-. h)θ ≤ (g(cid:48)(τ ) + h(cid:48)(τ ))θ for all τ . Thus, for Depending on whether g(yu) ≥ φ(θ), we consider two cases. If g(yu) < φ(θ), we have hθ ≤ (k2 g + k2 ψ1(yu, θ, τ ) = g(yv)dyv + (τ − θ) · h(θ) + (1 − θ) · g(yu) + θ · φ(τ ). (cid:90) θ 0 For any fixed θ, the minimum is achieved when τ = 1-, which is ψ1(yu, θ, 1-) = ≥ g(yv)dyv + (1- − θ)h(θ) + (1 − θ)g(yu) + θ · φ(1-) g(yv)dyv + (1 − θ)h(θ) + (1 − θ)g(yu) ≥ ψ2(yu, θ) ≥ min{g(yu), 0.5349}, where the last inequality follows from Lemma B.8. If g(yu) ≥ φ(θ), we have (cid:90) θ (cid:90) θ 0 0 the minimum of which is achieved when τ = 1-. Define ψ(θ) to be the minimum: ψ1(yu, θ, τ ) = ψ(θ) def= ψ1(yu, θ, 1-) = By the following, we have ∂ψ 0 g(yv)dyv + (τ − θ) · h(θ) + (1 − θ) · φ(θ) + θ · φ(τ ), (cid:90) θ (cid:90) θ (cid:90) θ ∂θ > 0 for all θ ∈ (t, 1), i.e., ψ(θ) is increasing when θ ∈ (t, 1). g(yv)dyv + (1 − θ) · (1 − g(θ)) + θ · (1 − g(1-) − h(1-)). g(yv)dyv + (1- − θ) · h(θ) + (1 − θ) · φ(θ) + θ · φ(1-) = 0 0 ∂ψ ∂θ ∂2ψ ∂ψ ∂θ ∂ψ ∂θ (cid:12)(cid:12)(cid:12)(cid:12)θ=0 (cid:12)(cid:12)(cid:12)(cid:12)θ=t = g(θ) + (1 − θ)(−g(cid:48)(θ)) − (1 − g(θ)) + 1 − g(1-) − h(1-). ∂θ2 = 3g(cid:48)(θ) > 0, = 2g(0) − k1 ∀θ ∈ [0, t) ∪ (t, 1) g − g(1-) − h(1-) ≈ −0.08 < 0 = 2g(t) − (1 − t)k2 g − g(1-) − h(1-) = 0.186 > 0. 20 (a) ψ(θ) (b) ∂ψ ∂θ Figure B.3: ψ(θ) and ∂ψ ∂θ Hence the minimum of ψ(θ) is achieved when θ ∈ (0, t]. Let ∂ψ ∂θ = 0, we have = g(θ) − (1 − θ)g(cid:48)(θ) − (1 − g(θ)) + 1 − g(1-) − h(1-) = 0 ∂ψ ∂θ gθ + 2b − g(1-) − h(1-) − k1 ⇐⇒ 3k1 g + g(1-) + h(1-) − 2b k1 ⇐⇒ θ∗ = g = 0. ≈ 0.127. 3k1 g Thus for all θ ≤ τ < 1, we have ψ1(yu, θ, τ ) ≥ ψ(θ) ≥ ψ(θ∗) ≈ 0.5349, as claimed. C Hardness Results and n := (cid:80)h i=0 ki = kh+1−1 k−1 Proof of Theorem 1.3: Consider the following hard instance. Let k, h be integer parameters, In the following, we construct a bipartite graph on vertices U ∪ V , where U = {u1, . . . , un} and V = {v1, . . . , vn−kh, b1, . . . , bkh}. It is easy to check by our construction that the graph is bipartite, but U, V does not correspond to the two sides of the bipartite graph. be the number of vertices on each side of a bipartite graph. Hard Instance. Refer to Figure C.1 (an illustrating example with k = 3 and h = 2). At the beginning, vertex u1 arrives, together with all its k + 1 neighbors (children). Let the deadline of u1 be reached immediately. Then we choose uniformly at random k vertices from the k + 1 neighbors of u1 to be u2, . . . , uk+1. Let the remaining vertex be v1. We repeat the procedure for vertices u2, . . . , uk+1, i.e., each vertex ui has k + 1 children, among which k vertices are chosen to be u(i−1)k+2 . . . , uik+1 while the remaining one becomes vi, and let the deadline of ui be reached immediately. We continue building the tree for h levels. Note that in level i, there are ki vertices (excluding the v vertices). Hence the tree with h levels has n vertices. At last, we pick a random permutation A = (a1, a2, . . . , akh) of the kh vertices {un−kh+1, . . . , un} at level h. Let vertices B = {b1, . . . , bkh} arrive (b1 arrives first and bkh last), such that bi is connected to vertices ai, . . . , an, and the deadline of bi is reached immediately when it arrives. Let the deadlines of vertices in A ∪ (V \ B) be reached at the end. 21 Figure C.1: Hard instance for any online algorithm: an illustrating example with k = 3 and h = 2. Competitive Ratio. First observe that graph G has a perfect matching, by matching ui to vi (for all i ∈ [n− kh]) and ai to bi (for all i ∈ [kh]). Now we consider any online algorithm. Note that when the deadline of ui is reached, it is not worse to match ui if it has an unmatched neighbor: if we do not match ui, then the symmetric difference is an alternating path, thus the number of vertices matched does not increase. Hence we assume w.l.o.g. that all vertices in U \ A will be matched eventually. Let pi be the probability that a vertex ux from level i is matched when the deadline of its parent uy in the tree is reached. Note that pi is also the probability that vy is matched, as vy is chosen uniformly at random among the k + 1 children of uy. Observe that we have pi = 1−pi−1 k+1 , where p0 = 1. It is easy to check (by induction) that for all i ≤ h, we have (cid:32) (cid:19)i(cid:33) (cid:18) −1 k + 1 pi = 1 k + 2 1 − (cid:18) −1 (cid:19)h Hence before vertex b1 arrives, each vertex from A is matched with probability ph. By the standard water-filling algorithm, it is easy to see that the expected number of matched vertices from B (at the end of the algorithm) is t such that 1 kh + 1 kh − 1 + . . . + 1 kh − t + 1 = 1 − ph = k + 1 k + 2 + 1 k + 2 k + 1 . When h tends to infinity, we have t ≈ (1 − e − k+1 k+2 ) · kh. Hence the competitive ratio is 2t + U \ A + 1 2n k+2A + 1 k+2V \ B = 2(1 − e − k+1 k+2 ) · kh · (k − 1) + kh − 1 2(kh+1 − 1) + 1 2(k + 2) , which tends to k−1 63 − 6 k (1 − e 9 ≈ 0.631745. 7 · e− 8 62 − k+1 k+2 ) + 1 2k + 1 2(k+2) when h tends to infinity. For k = 7, the ratio is Proof of Theorem 1.4: Consider the following hard instance. Let k, h be integer parameters, and n := k · h be the number of vertices on each side of a bipartite graph G. In the following, we construct a bipartite graph on vertices U ∪ V , where U = {u1, . . . , un} and V = {v1, . . . , vn}. As before, it is easy to check by our construction that the graph is bipartite, but U, V does not correspond to the two sides of the bipartite graph. 22 𝒖𝟏𝒖𝟑𝒖𝟐𝒖𝟒𝒗𝟏𝒖𝟔𝒖𝟓𝒖𝟕𝒖𝟗𝒖𝟖𝒖𝟏𝟎𝒖𝟏𝟐𝒖𝟏𝟏𝒖𝟏𝟑𝒗𝟐𝒗𝟑𝒗𝟒Level1Level2Level 0AB Hard Instance. Refer to Figure C.2. For all i ∈ [n], let ui be the only neighbor of vi. We group every k consecutive vertices in U as a group, i.e., let U = ∪i∈[h]Ui, where the i-th group Ui = {u(i−1)k+1, u(i−1)k+2, . . . , uik}. Let there be an edge between ui and uj if they are from two consecutive groups, respectively. In other words, we form a complete bipartite graph between any two consecutive groups Ui and Ui+1. Figure C.2: Hard instance for Ranking: an illustrating example with k = 3 and h = 4: vertices in U and V are represented by the solid black circles and white circles, respectively. Let the deadline of vertex u1 be reached first, then u2's deadline, u3's deadline, etc. Competitive Ratio of Ranking. It is easy to see that graph G has a perfect matching, by matching ui to vi for each i ∈ [n]. Recall that in the Ranking algorithm, each vertex u is assigned a random rank yu ∈ [0, 1). At the deadline of an unmatched vertex, it is matched to its unmatched neighbor v (if any) with the smallest yv. Observe that in our instance, all vertices from U will be matched eventually, while each vi ∈ V will be matched only if at the deadline of ui, ui is unmatched and yvi is smaller than the ranks of all unmatched vertices from the next group U(cid:100) i For all i ∈ [h], let Xi ∈ {0, 1,··· , k} be the number of unmatched vertices in Ui right before the deadline of the first vertex u(i−1)k+1 in Ui is reached. It is easy to see that Xi+1 is a random variable that depends only on Xi. Hence the sequence X1, X2, . . . , Xh forms a Markov chain (with k + 1 states) with initial state X1 = k. Observe that all vertices in U are matched, and the number of vertices matched in Vi equals Xi + Xi+1 − k. Hence the competitive ratio of Ranking ≈ i∈[h] Xi . kh We say phase i begin when the deadline of the first vertex of Ui is reached, and end after the deadline of the last vertex of Ui. Fix any phase i, where i < h. Recall that initially Xi vertices of Ui are unmatched. Let Z(t) be the number of unmatched vertices in Ui+1, when the deadlines of exactly t unmatched vertices in Ui have passed. We have Z(0) = k and Xi+1 = Z(Xi). Let y1 ≤ y2 ≤ ··· ≤ yk be the ranks of vertices in Ui+1. It is easy to see that E [Z(t + 1)] = Z(t) − 1 + yZ(t). Taking expectation over all yi's, we have E [Z(t + 1)] = E [Z(t)] − 1 + E[Z(t)] k . It is easy to see when k → ∞, z( t k when k tends to infinity. k . This is saying, given Xi, E [Xi+1] = k · e− Xi k+1 . Let z( t k ) → e− t k(cid:101)+1. (cid:80) k ) def= Z(t) Finally, note that all vertices in Ui+1 are symmetric. Hence, each of them is unmatched at the k . Moreover, for any two vertices ua, ub ∈ Ui+1, the end of phase i with probability E[Xi+1] probability that ua is unmatched at the end of phase i is negatively correlated with the probability of ub: conditioned on ub being unmatched at the end of phase i, the probability of ua being unmatched is smaller. Thus we have measure concentration bound on Xi+1, by standard argument = e− Xi k 23 𝑢2𝑣3𝑢3𝑣1𝑢1𝑣5𝑢5𝑣6𝑢6𝑣4𝑢4𝑣8𝑢8𝑣9𝑢9𝑣7𝑢7𝑣11𝑢11𝑣12𝑢12𝑣10𝑢10𝑈1∪𝑉1𝑈2∪𝑉2𝑈3∪𝑉3𝑈4∪𝑉4𝑣2 using moment generation function. In other words, the stationary distribution (when k and h tends to infinity) converges to a single point mass with, which implies X k ≈ 0.56714, the Omega constant, which is also the competitive ratio of Ranking. = e− X k , X k 24
1708.03812
2
1708
2019-03-21T01:01:38
Optimal Offline Dynamic $2,3$-Edge/Vertex Connectivity
[ "cs.DS" ]
We give offline algorithms for processing a sequence of $2$ and $3$ edge and vertex connectivity queries in a fully-dynamic undirected graph. While the current best fully-dynamic online data structures for $3$-edge and $3$-vertex connectivity require $O(n^{2/3})$ and $O(n)$ time per update, respectively, our per-operation cost is only $O(\log n)$, optimal due to the dynamic connectivity lower bound of Patrascu and Demaine. Our approach utilizes a divide and conquer scheme that transforms a graph into smaller equivalents that preserve connectivity information. This construction of equivalents is closely-related to the development of vertex sparsifiers, and shares important connections to several upcoming results in dynamic graph data structures, outside of just the offline model.
cs.DS
cs
Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity Richard Peng1, Bryce Sandlund2, and Daniel D. Sleator3 1 School of Computer Science, Georgia Institute of Technology, Atlanta, GA, USA [email protected] 2 Cheriton School of Computer Science, University of Waterloo, Waterloo, ON, CA 3 Dept. of Computer Science, Carnegie Mellon University, Pittsburgh, PA, USA [email protected] [email protected] Abstract. We give offline algorithms for processing a sequence of 2 and 3 edge and vertex connectivity queries in a fully-dynamic undirected graph. While the current best fully-dynamic online data structures for 3-edge and 3-vertex connectivity require O(n2/3) and O(n) time per up- date, respectively, our per-operation cost is only O(log n), optimal due to the dynamic connectivity lower bound of Patrascu and Demaine. Our approach utilizes a divide and conquer scheme that transforms a graph into smaller equivalents that preserve connectivity information. This con- struction of equivalents is closely-related to the development of vertex sparsifiers, and shares important connections to several upcoming results in dynamic graph data structures, outside of just the offline model. 1 Introduction Dynamic graph data structures seek to answer queries on a graph as it undergoes edge insertions and deletions. Perhaps the simplest and most fundamental query to consider is connectivity. A connectivity query asks for the existence of a path connecting two vertices u and v in the current graph. As the insertion or deletion of a single edge may have large consequences to connectivity across the entire graph, constructing an efficient dynamic data structure to answer connectivity queries has been a challenge to the data structure community. A number of solutions have been developed, achieving a wide variety of runtime tradeoffs in a number of different models [12,13,14,25,20,21,24,26,29,35,39] The models typically addressed are online: each query must be answered before the next query or update is given. A less demanding variant is the offline setting, where the entire sequence of updates and queries is provided as input to the algorithm. While an online data structure is more general, there are many scenarios in which the entire sequence of operations is known in advance. This is often the case when a data structure is used in a subroutine of an algorithm [30,7], one specific example being the use of dynamic trees in the near-linear time minimum cut algorithm of Karger [27]. 2 Peng et al. In exchange for the loss of flexibility, one can hope to obtain faster and sim- pler algorithms in the offline setting. This has been shown to be the case in the dynamic minimum spanning tree problem. While an online fully-dynamic mini- mum spanning tree data structure requires about O(log4 n) time per update [22], the offline algorithm of Eppstein requires only O(log n) time per update [12]. In this paper, we show similar, but stronger, performance gains for higher ver- sions of connectivity. In particular, we consider the problems of 2, 3-edge/vertex connectivity on a fully-dynamic undirected graph. An extension of connectivity, c-edge connectivity asks for the existence of c edge-disjoint paths between two vertices u and v in the current graph. Vertex connectivity requires vertex-disjoint paths instead of edge-disjoint paths. Current online fully-dynamic 2-edge/vertex connectivity data structures require update time at least O(log2 n) [21] and O(log3 n)4 [35], respectively, and current online fully-dynamic 3-edge/vertex con- nectivity data structures require update time at least O(n2/3) and O(n), respec- tively [13]. In contrast, our offline algorithms for 2, 3-edge/vertex connectivity require only O(log n) time per operation. As the lower bound on dynamic con- nectivity [33], as well as most lower bounds in general [3,2,1,8], also apply in the offline model, our algorithms are optimal up to a constant factor. This paper further shows that any lower bound attempting to show hardness stronger than Ω(log n) time per operation for online fully-dynamic 2, 3-edge/vertex connectiv- ity must make use of the online model. As a straightforward application of our results, one can consider the use of our algorithms when data regarding a dynamic network is collected, but not analyzed, until a later point in time. For example, to diagnose an issue of network latency across key routing hubs, or determine viability of a dynamically-changing network of roads, our algorithms can answer a batch of queries in time O(t log n), where t is the total number of updates and queries. Since online fully-dynamic algorithms for higher versions of connectivity are significantly slower, namely, O(n2/3) and O(n) time update for 3-edge and 3-vertex connectivity, respectively, our offline data structure makes these computations practical for large data sets when they would otherwise be prohibitively expensive. Related to our work are papers by Lacki and Sankowski [29] and Karcmarz and Lacki [26], which also apply to the above applications but for lower versions of connectivity. Their work considers a fixed sequence of graph updates, given in advance, and is then able to answer connectivity queries regarding intervals of this sequence, online. This is more general than the model we consider because the queries need not be supplied in advance and data regarding an interval of time is richer than information from a specific point in time. For connectivity and 2-edge connectivity, Karcmarz and Lacki achieve O(log n) time per opera- tion [26]. Both 2-vertex connectivity and 3-edge/vertex connectivity queries are not supported. 4 This complexity is claimed in Thorup's STOC 2000 [35] result. As noted by Huang et al. [24], the paper provides few details, deferring to a journal version that has since not appeared. The best complexity for online fully-dynamic biconnectivity prior to this claim was O(log5 n) by Holm and Thorup [20]. Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 3 The techniques developed in this paper may be of independent interest. Our work has close connections with recent developments in vertex spar- sification, particularly vertex sparsification-based dynamic graph data struc- tures [4,11,17,18,10,14,19,28,5,16,15]. In particular, the equivalent graphs at the core of our algorithms are akin to vertex sparsifiers, with the main difference that 2- and 3-connectivity require preserving far less information than the more general definitions of vertex sparsifiers [17,28]. A promising step in this direction is very recent work of Goranci et al. [19], which suggests the notion of a local sparsifier. This is a generalization of the sparsifier that we consider here, and leads to efficient incremental algorithms in the online setting. Indeed, offline algorithms haven proven useful for the development of online counterparts in the past. Once such example is recent development in the main- tenance of dynamic effective resistance. Recent work in fully-dynamic data struc- tures for maintaining effective resistances online [10] relied heavily upon ideas from earlier data structures for maintaining effective resistances in offline [11,31] or offline-online hybrid [11,30] settings. The results of this paper were previously published online in the open access journal arXiv [34] and have recently been extended to offline 4- and 5-edge connectivity [32]. This new work achieves about O(√n) time complexity per operation. The rest of this paper will be dedicated to proving the following theorem: Theorem 1. Given a sequence of t updates/queries on a graph of the form: -- Insert edge (u, v), -- Delete edge (u, v), -- Query if a pair of vertices u and v are 2-edge connected/3-edge connected/bi- connected/tri-connected in the current graph, there exists an algorithm that answers all queries in O(t log n) time. For simplicity, we will assume the graph is empty at the start and end of the sequence, but the results discussed are easily modified to start with an initial graph G, at the cost of an additive O(m) term in the running time, where m is the number of edges of G. Further, we assume a fixed vertex set of size n. Any update sequence with arbitrary vertex endpoints can be modified to one on a fixed set of vertices, where the size of the fixed set is equal to the largest number of non-isolated vertices in any graph achieved in the given update sequence. The paper is organized as follows. We describe our offline framework for re- ducing graphs to smaller equivalents in Section 2. We show how simple techniques can be used to create such equivalents for 2-edge connectivity and bi-connectivity in Section 3. In Section 4 we extend these constructions to 3-edge connectivity. Our most technical section is 3-vertex connectivity, where constructing equiva- lent graphs requires careful manipulation of SPQR trees. Unfortunately, due to page limits, this is located in Appendix A. 4 Peng et al. 2 Offline Framework The main idea of our offline framework is to perform divide and conquer on the input sequence, similar to what is done in Eppstein's offline minimum spanning tree algorithm [12]. Consider the full sequence of updates and queries x1, . . . , xt, where each xi is either an edge insertion, edge deletion, or query. Call each xi an event. Assume each inserted edge has unique identity. Then for each inserted edge e, we may associate an interval [I(e), D(e)], indicating that edge e was inserted at time I(e) and removed at time D(e). Plotting time along the x-axis and edges on the y-axis as in Figure 1 gives a convenient way to view the sequence of events. 1 2 3 4 5 6 7 8 9 10 11 e4 e3 e2 e1 I(e1) I(e2) Q I(e3) D(e2) Q I(e4) D(e3) Q D(e4) D(e1) Fig. 1. A timeline diagram of four edge insertions(I)/deletions(D) and three queries(Q), with time on the x-axis and edges on the y-axis. Fix some subinterval [l, r] of the sequence of events. Let us classify all edges present at any point of time in the sequence xl, . . . , xr as one of two types. 1. Edges present throughout the duration (ie ≤ l ≤ r ≤ de), we call permanent 2. Edges affected by an event in this range (one or both of I(e), D(e) is in edges. (l, r)), we call non-permanent edges. While there may be a large number of permanent edges, the number of non- permanent edges is limited by the number of time steps, r − l + 1. Therefore, the graph can be viewed as a large static graph on which a smaller number of events take place. Our goal will be to reduce this graph of permanent edges to one whose size is a small function of the number of events in the subinterval. If we may do so without affecting the answers to the queries, we can recursively apply the technique to achieve an efficient divide and conquer algorithm for the original dynamic c-connectivity sequence. We will work in the dual-view, considering cuts instead of edge-disjoint or vertex-disjoint paths. Two vertices u and v are c-edge connected if there does Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 5 not exist a cut of size c − 1 edges separating them; further, u and v are c-vertex connected if there does not exist a cut of c − 1 vertices that separates them. We need the following definition. Definition 1. Given a graph G = (VG, EG) with vertex subset W ⊆ VG and a graph H = (VH , EH ) with W ⊆ VH , we say that H and G are c-edge equivalent if, for any partition (A, B) of W , the size of a minimum cut separating A and B is the same in G and H whenever either of these sizes is less than c. Similarly, we say H and G are c-vertex equivalent if, for any partition (A, B, C) of W with C < c, the size of a minimum vertex cut D separating A and B such that C ⊆ D and D ∩ A = ∅, D ∩ B = ∅, is the same in G and H whenever either of these sizes is less than c. This gives the following. Lemma 1. Suppose G = (VG, EG) and H = (VH , EH ) are c-edge/c-vertex equivalent on vertex set W . Let EW denote any set of edges between vertices of W . Then H ′ = (VH , EH ∪ EW ) and G′ = (VG, EG ∪ EW ) are c-edge/c-vertex equivalent. Proof. We first show c-edge equivalence. Let (A, B) be any partition of W and consider the minimum cuts separating A and B in G′ and H ′. Since the edges in EW are between vertices of W , they must cross the separation (A, B) in the same way. Therefore, if the minimum cut separating A and B had size less than c in either G or H, the minimum cuts separating A and B will have equivalent size in G′ and H ′. Further, if the minimum cuts separating A and B had size larger or equal to c in both G and H, the minimum cuts separating A and B will also have size larger or equal to c in G′ and H ′, since we only add edges to G′ and H ′. Thus G′ and H ′ are c-edge equivalent. We now consider c-vertex equivalence. Consider a partition (A, B, C) of W . As with edge connectivity, if no vertex subset D exists satisfying the conditions of Definition 1, the introduction of additional edges between any vertices of W will not change the existence of such a set D in G′ or H ′. Furthermore, if an edge of EW connects a vertex of A to a vertex of B, no vertex cut separates A and B in G′ and H ′. Now suppose none of these cases is true, and there exists a vertex set D satisfying the conditions of Definition 1 such that the removal of D disconnects A and B in G and H and further that no edge of EW connects a vertex of A to a vertex of B. Then the removal of vertex set D still disconnects A and B in G′ and H ′. Thus c-vertex equivalence of G′ and H ′ follows from c-vertex equivalence of G and H. Now consider the graph G of permanent edges for the subinterval xl, . . . , xr of events. Let W be the set of vertices involved in any event in the subinterval. We will refer to these vertices as active vertices, and all other vertices of G not in W as inactive vertices. Lemma 1 says that if we reduce G to a c-edge/ c-vertex equivalent graph H on set W , the result of all queries in xl, . . . , xr on H will be the same as on G. This is because all cuts in H and G that affect the queries 6 Peng et al. (therefore of size less than c) are of equivalent size, even after the addition of non-permanent edges in H and G. This idea can lead to a divide and conquer algorithm if we can produce such equivalent graphs H of small size efficiently. Specifically: Lemma 2. Given a graph G with m edges and vertex set W of size k, if there is an O(m) time algorithm that produces a graph H of size O(k) that is c-edge/c- vertex equivalent to G on W , then there is an algorithm that can answer all c- edge/c-vertex connectivity queries in a sequence of events x1, . . . , xt in O(t log n) time. Proof. We perform divide and conquer on the sequence of events. We take the sequence of events x1, . . . , xt and divide it in half. Over each half, we will take the graph of permanent edges, which we denote G, and reduce it to a c-edge/ c- vertex equivalent graph H. We repeat the scheme recursively. As the subintervals get smaller, non-permanent edges become permanent and are absorbed by the production of equivalent graphs. Eventually, we reduce to subintervals with a constant number of events, which can be answered by any algorithm of our choice on a graph of constant size. Consider the sizes of the graphs in each step of recursion. At the top level, the graph of permanent edges in each half has size O(t), the number of events in the full sequence. Thus in the second level, the graph we start with is of size linear in the number of events in that interval, plus the number of edges that became permanent in that interval, which in turn are bounded by the number of non-permanent edges in the interval at the preceding level. This continues recursively, and the result is that all graphs operated on are of size linear in the number of events processed at that level. The runtime recurrence is T (t) = T (t/2) + O(t), which clearly solves to O(t log t). If t is polynomially-bounded by n, this is O(t log n). If not, we may first break the sequence of events x1, . . . xt into blocks of size, say, n2. Since the size of the graph cannot be more than O(n2) in any block, the runtime argument carries through. This proves the lemma. The remainder of the paper will show the construction of 2-edge, 2-vertex, 3-edge, and 3-vertex equivalent graphs. 3 Equivalent Graphs for 2-Edge Connectivity and Bi-connectivity We now show offline algorithms for dynamic 2-edge connectivity and bi- connectivity by constructing 2-edge and 2-vertex equivalents needed by Lemma 2. These two properties ask for the existence of a single edge/vertex whose re- moval separates query vertices u and v. Since these cuts can affect at most one connected component, it suffices to handle each component separately. The underlying structure for 2-edge connectivity and bi-connectivity is tree- like. This is perhaps more evident for 2-edge connectivity, where vertices on the same cycle belong to the same 2-edge connected component. We will first Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 7 describe the reductions that we will make to this tree in Section 3.1, and adapt them to bi-connectivity in Section 3.2. At times we will make use of the term "equivalent cut". By this we mean that a cut C ′ is equivalent to C if it has the same size and separates the vertices of W in the same way. 3.1 2-Edge Connectivity Using depth-first search [23], we can identify all cut-edges in the graph and the 2- edge connected components that they partition the graph into. The case of edge cuts is slightly simpler conceptually, since we can combine vertices without in- troducing new cuts. Specifically, we show that each 2-edge connected component can be shrunk to single vertex. Lemma 3. Let S be a 2-edge connected component in G. Then contracting all vertices in S to a single vertex s in H 5, and endpoints of edges correspondingly, creates a 2-edge equivalent graph. Proof. The only cuts that we need to consider are ones that remove cut edges in G or H. Since we only contracted vertices in a component, there is a one-to-one mapping of these edges from G to H. Since S is 2-edge connected, all vertices in it will be on the same side of one of these cuts. Furthermore, removing the same edge in H leads to a cut with s instead. Therefore, all active vertices in S are mapped to s, and are therefore on the same side of the cut. This allows us to reduce G to a tree H, but the size of this tree can be much larger than k. Therefore we need to prune the tree by removing inactive leaves and length 2 paths whose middle vertex is inactive. Lemma 4. If G is a tree, the following two operations lead to 2-edge equivalent graphs H. -- Removing an inactive leaf. -- Removing an inactive vertex with degree 2 and adding an edge between its two neighbors. Proof. In the first case, the only cut in G that no longer exist in H is the one that removes the cut edge connecting the leaf with its unique neighbor. However, this places all active vertices in one component and thus does not separate W and need not be represented in H. In the second case, if a cut removes either of the edges incident to the degree 2 vertex, removing the new edge creates an equivalent cut since the middle vertex is inactive. Also, for a cut that removes the new edge in H, removing either of the two original edges in G leads to an equivalent cut. 5 Here we abuse our requirement W ⊆ VH, where VH are the vertices of H, slightly. A map of W onto VH that preserves the cuts needed by c-edge/c-vertex equivalence is all that is required, but c-edge/c-vertex equivalence is easier to read without introducing the map notation. 8 Peng et al. This allows us to bound the size of the tree by the number of active vertices, and therefore finish the construction. Lemma 5. Given a graph G with m edges and k active vertices W , a 2-edge equivalent of G of size O(k), H, can be constructed in O(m) time. Proof. We can find all the cut edges and 2-edge connected components in O(m) time using depth-first search [23], and reduce the resulting structure to a tree H using Lemma 3. On H, we repeatedly apply Lemma 4 to obtain H ′. In H ′, all leaves are active, and any inactive internal vertex has degree at least 3. Therefore the number of such vertices can be bounded by O(k), giving a total size of O(k). 3.2 Bi-connectivity All cut-vertices (articulation points) can also be identified using DFS, leading to a structure known as the block-tree. However, several modifications are needed to adapt the ideas from Section 3.1. The main difference is that we can no longer replace each bi-connected component with a single vertex in H, since cutting such vertices corresponds to cutting a much larger set in G. Instead, we will need to replace the bi-connected components with simpler bi-connected graphs such as cycles. Lemma 6. Replacing a bi-connected component with a cycle containing all its cut-vertices and active vertices gives a 2-vertex equivalent graph. Proof. As this mapping maintains the bi-connectivity of the component, it does not introduce any new cut-vertices. Therefore, G and H have the same set of cut vertices and the same block-tree structure. Note that the actual order the active vertices appear in does not matter, since they will never be separated. The claim follows similarly to Lemma 3. The block-tree also needs to be shrunk in a similar manner. Note that the fact that blocks are connected by shared vertices along with Lemma 6 implies the removal of inactive leaves. Any leaf component with no active vertices aside from its cut vertex can be reduced to the cut vertex, and therefore be removed. The following is an equivalent of the degree two removal part of Lemma 4. Lemma 7. Two bi-connected components C1 and C2 with no active vertices that share cut vertex w and are only incident to one other cut vertex each, u and v respectively, can be replaced by an edge connecting u and v to create a 2-vertex equivalent graph. Proof. As we have removed only w, any cut vertex in H is also a cut vertex in G. As C1 and C2 contain no active vertices, this cut would induce the same partition of active vertices. For the cut given by removing w in G, removing u in H gives the same cut since C1 has no active vertices (which in turn implies that u is not active). Note that the removal of u may break the graph into more pieces, but our definition of cuts allows us to place these pieces on two sides of the cut arbitrarily. Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 9 Note that Lemma 6 may need to be applied iteratively with Lemma 7 since some of the cut vertices may no longer be cut vertices due to the removal of components attached to them. Lemma 8. Given a graph G with m edges and k active vertices W , a 2-vertex equivalent of G of size O(k), H, can be constructed in O(m) time. Proof. We can find all the initial block-trees using depth-first search [23]. Then we can apply Lemmas 6 and 7 repeatedly until no more reductions are possible. Several additional observations are needed to run these reduction steps in O(m) time. As each cut vertex is removed at most once, we can keep a counter in each component about the number of cut vertices on it. Also, the second time we run Lemma 6 on a component, it's already a cycle, so the reductions can be done without examining the entire cycle by tracking it in a doubly linked list and removing vertices from it. It remains to bound the size of the final block-tree. Each leaf in the block-tree has at least one active vertex that's not its cut vertex. Therefore, the block-tree contains at most O(k) leaves and therefore at most O(k) internal components with 3 or more cut vertices, as well as O(k) components containing active ver- tices. If these components are connected by paths with 4 or more blocks in the block tree, then the two middle blocks on this path meet the condition of Lemma 8 and should have been removed by Lemma 7. This gives a bound of O(k) on the number of blocks, which in turn implies an O(k) bound on the number of cut vertices. The edge count then follows from the fact that Lemma 6 replaces each component with a cycle, whose number of edges is linear in the number of vertices. 4 3-Edge Connectivity We now extend our algorithms to 3-edge connectivity. Our starting point is a statement similar to Lemma 3, namely that we can contract all 3-edge connected components. Lemma 9. Let S be a 3-edge connected component in G. Then contracting all vertices in S to a single vertex s in H, and endpoints of edges correspondingly, creates a 3-edge equivalent graph. Proof. A two-edge cut will not separate a 3-edge connected component. There- fore all active vertices in S fall on one side of the cut, to which vertex s may also fall. The proof follows analogously to Lemma 3. Such components can also be identified in O(m) time using depth-first search [36], so the preprocessing part of this algorithm is the same as with the 2-connectivity cases. However, the graph after this shrinking step is no longer a tree. Instead, it is a cactus, which in its simplest terms can be defined as: Definition 2. A cactus is an undirected graph where each edge belongs to at most one cycle. 10 Peng et al. On the other hand, cactuses can also be viewed as a tree with some of the vertices turned into cycles6. Such a structure essentially allows us to repeat the same operations as in Section 3 after applying the initial contractions. Lemma 10. A connected undirected graph with no nontrivial 3-edge connected component is a cactus. Due to space restrictions, we save the proof for Appendix B. With this structural statement, we can then repeat the reductions from the 2-edge equivalent algorithm from Section 3.1 to produce the 3-edge equivalent graph. Lemma 11. Given a graph G with m edges and k active vertices W , a 3-edge equivalent of G of size O(k), H, can be constructed in O(m) time. Proof. Lemma 10 means that we can reduce the graph to a cactus after O(m) time preprocessing. First consider the tree where the cycles are viewed as vertices. Note that in this view, a vertex that's not on any cycle is also viewed as a cycle of size 1. This can be pruned in a manner analogous to Lemma 4: 1. Cycles containing no active vertices and incident to 1 or 2 other cycles can be contracted to a single vertex. 2. Inactive single-vertex cycles incident to 1 other cycle can be removed. This procedure takes O(m) time and produces a graph with at most O(k) leaves. Correctness of the first rule follows by replacing a cut of the two edges within an inactive cycle by a cut of the single contracted vertex with one of its neighbors. The second rule does not affect any cuts separating W . It remains to reduce the length of degree 2 paths and the sizes of the cycles themselves. As in Lemma 4, all vertices of degree 2 can be replaced by an edge between its two neighbors. This bounds the length of degree 2 paths and reduces the size of each cycle to at most twice its number of incidences with other cycles. This latter number is in turn bounded by the number of leaves of the tree of cycles. Hence, this contraction procedure reduces the total size to O(k). We remark that this is not identical to iteratively removing inactive vertices of degrees at most 2. With that rule, a cycle can lead to a duplicate edge between pairs of vertices, and a chain of such cycles needs to be reduced in length. References 1. Abboud, A., Dahlgaard, S.: Popular conjectures as a barrier for dynamic planar graph algorithms. In: IEEE 57th Annual Symposium on Foundations of Computer Science. pp. 477 -- 486 (10 2016) 6 Some 'virtual' edges are needed in this construction, because a vertex can still belong to multiple cycles. Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 11 2. Abboud, A., Williams, V.V.: Popular conjectures imply strong lower bounds for dynamic problems. In: Proceedings of the 2014 IEEE 55th Annual Symposium on Foundations of Computer Science. pp. 434 -- 443. FOCS '14 (2014) 3. Abboud, A., Williams, V.V., Yu, H.: Matching triangles and basing hardness on an extremely popular conjecture. In: Proceedings of the Forty-Seventh Annual ACM on Symposium on Theory of Computing, STOC 2015. pp. 41 -- 50 (2015) 4. Abraham, I., Durfee, D., Koutis, I., Krinninger, S., Peng, R.: On fully dynamic graph sparsifiers. In: 2016 IEEE 57th Annual Symposium on Foundations of Com- puter Science (FOCS). pp. 335 -- 344 (Oct 2016) 5. Assadi, S., Khanna, S., Li, Y., Tannen, V.: Dynamic sketching for graph optimiza- tion problems with applications to cut-preserving sketches. In: FSTTCS (2015) 6. Bienstock, D., Monma, C.L.: On the complexity of covering vertices by faces in a planar graph. SIAM J. Comput. 17(1), 53 -- 76 (Feb 1988) 7. Bringmann, K., Kunnemann, M., Nusser, A.: Frechet distance under translation: Conditional hardness and an algorithm via offline dynamic grid reachability. CoRR abs/1810.10982 (2018), https://arxiv.org/abs/1810.10982 8. Dahlgaard, S.: On the hardness of partially dynamic graph problems and connec- tions to diameter. In: 43rd International Colloquium on Automata, Languages, and Programming (2016) 9. Di Battista, G., Tamassia, R.: On-line graph algorithms with spqr-trees. In: Pro- ceedings of the seventeenth international colloquium on Automata, languages and programming. pp. 598 -- 611. New York, NY, USA (1990) 10. Durfee, D., Gao, Y., Goranci, G., Peng, R.: Fully dynamic spectral vertex sparsi- fiers and applications. In: Proceedings of the thirtieth annual ACM symposium on Theory of computing. STOC '19, ACM (2019) 11. Durfee, D., Kyng, R., Peebles, J., Rao, A.B., Sachdeva, S.: Sampling random span- ning trees faster than matrix multiplication. In: Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing. pp. 730 -- 742 (2017) 12. Eppstein, D.: Offline algorithms for dynamic minimum spanning tree problems. J. Algorithms 17(2), 237 -- 250 (Sep 1994) 13. Eppstein, D., Galil, Z., Italiano, G.F., Nissenzweig, A.: Sparsification -- a technique for speeding up dynamic graph algorithms. J. ACM 44(5), 669 -- 696 (Sep 1997) 14. Eppstein, D., Galil, Z., Italiano, G.F., Spencer, T.H.: Separator-based sparsification ii: edge and vertex connectivity. In: Siam Journal on Computing (2006) 15. Fafianie, S., Hols, E.M.C., Kratsch, S., Quyen, V.A.: Preprocessing under uncer- tainty: Matroid intersection. In: 41st International Symposium on Mathematical Foundations of Computer Science (MFCS 2016). vol. 58, pp. 35:1 -- 35:14 (2016) 16. Fafianie, S., Kratsch, S., Quyen, V.A.: Preprocessing under uncertainty. In: 33rd Symposium on Theoretical Aspects of Computer Science (STACS 2016). vol. 47, pp. 33:1 -- 33:13 (2016) 17. Goranci, G., Henzinger, M., Peng, P.: The power of vertex sparsifiers in dynamic graph algorithms. In: European Symposium on Algorithms (ESA). pp. 45:1 -- 45:14 (2017) 18. Goranci, G., Henzinger, M., Peng, P.: Dynamic effective resistances and approxi- mate schur complement on separable graphs. In: 26th Annual European Sympo- sium on Algorithms (ESA 2018). vol. 112, pp. 40:1 -- 40:15 (2018) 19. Goranci, incre- mental (2018), https://drive.google.com/file/d/1SJrbzuz_szMwsBfeBZfGUWkDEbZKAGD5/view Henzinger, via G., algorithms M., local Saranurak, T.: Fast sparsifiers. CoRR 12 Peng et al. 20. Holm, J., de Lichtenberg, K., Thorup, M.: Poly-logarithmic deterministic fully- dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and bicon- nectivity. In: Proceedings of the thirtieth annual ACM symposium on Theory of computing. pp. 79 -- 89. STOC '98, ACM, New York, NY, USA (1998) 21. Holm, J., Rotenberg, E., Thorup, M.: Dynamic bridge-finding in O(log2 n) amor- tized time. In: Symposium on Discrete Algorithms (SODA) (2018) 22. Holm, J., Rotenberg, E., Wulff-Nilsen, C.: Faster fully-dynamic minimum spanning forest. In: Bansal, N., Finocchi, I. (eds.) Algorithms - ESA 2015. pp. 742 -- 753. Springer Berlin Heidelberg, Berlin, Heidelberg (2015) 23. Hopcroft, J.E., Tarjan, R.E.: Dividing a graph into triconnected components. SIAM J. Comput. 2(3), 135 -- 158 (1973) 24. Huang, S.E., Huang, D., Kopelowitz, T., Pettie, S.: Fully dynamic connectivity in O(log n(log log n)2) amortized expected time. In: Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms. pp. 510 -- 520 (2017) 25. Kapron, B., King, V., Mountjoy, B.: Dynamic graph connectivity in polylogarith- mic worst case time. SODA (2013) 26. Karczmarz, A., Lacki, J.: Fast and simple connectivity in graph timelines. In: Dehne, F., Sack, J.R., Stege, U. (eds.) Algorithms and Data Structures: 14th In- ternational Symposium, WADS 2015. pp. 458 -- 469 (2015) 27. Karger, D.R.: Minimum cuts in near-linear time. J. ACM 47(1), 46 -- 76 (Jan 2000) 28. Kratsch, S., Wahlstrom, M.: Representative sets and irrelevant vertices: New tools for kernelization. In: Proceedings of the 2012 IEEE 53rd Annual Symposium on Foundations of Computer Science. pp. 450 -- 459. FOCS '12 (2012) 29. Lacki, J., Sankowski, P.: Reachability in graph timelines. ITCS (2013) 30. Li, H., Patterson, S., Yi, Y., Zhang, Z.: Maximizing the number of in a connected graph. CoRR abs/1804.02785 (2018), spanning trees https://arxiv.org/abs/1804.02785 31. Li, H., Zhang, Z.: Kirchhoff index as a measure of edge centrality in weighted networks: Nearly linear time algorithms. In: Symposium on Discrete Algorithms (SODA). pp. 2377 -- 2396 (2018) 32. Molina, A., Sandlund, B.: personal communication 33. Patracscu, M., Demaine, E.D.: Lower bounds for dynamic connectivity. In: Pro- ceedings of the thirty-sixth annual ACM symposium on Theory of computing. pp. 546 -- 553. STOC '04, ACM, New York, NY, USA (2004) 34. Peng, R., Sandlund, B., Sleator, D.D.: Offline dynamic higher connectivity. CoRR abs/1708.03812 (2017), http://arxiv.org/abs/1708.03812 35. Thorup, M.: Near-optimal fully-dynamic graph connectivity. In: Proceedings of the thirty-second annual ACM symposium on Theory of computing. pp. 343 -- 350. STOC '00, ACM, New York, NY, USA (2000) 36. Tsin, Y.H.: Yet another optimal algorithm for 3-edge-connectivity. Journal of Dis- crete Algorithms 7(1), 130 -- 146 (2009) 37. Weiskircher, R.: New Applications of SPQR-Trees in Graph Drawing. Ph.D. thesis, Universitat des Saarlandes (2002) 38. Westbrook, J., Tarjan, R.: Maintaining bridge-connected and biconnected compo- nents on-line. Algorithmica 7, 433 -- 464 (1992) 39. Wulff-Nilsen, C.: Fully-dynamic minimum spanning forest with improved worst- case update time. In: Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC. pp. 1130 -- 1143 (2017) Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 13 A Tri-connectivity Tri-connectivity queries involving s and t ask for the existence of a separation pair {u, v} whose removal disconnects s from t. In this section we will extend our techniques to offline tri-connectivity. To do so, we rely on a tree-like structure for the set of separation pairs in a bi-connected graph, the SPQR tree [23,9]. We review these structures in Section A.1 and show how to trim them in Section A.2. As these trees require that the graphs are bi-connected, we extend this subroutine to our full construction in Section A.3. A.1 SPQR Trees We now review the definition of SPQR Trees. We will follow the model given in Chapter 2 of [37]. For a more thorough description of SPQR Trees, please refer to [37]. SPQR trees are based on the definition of a split pair, which generalizes separation pairs by allowing the extra case of {u, v} being an edge of G. A split component of the split pair {u, v} is either an edge connecting them, or a maximal connected subgraph G′ of G such that removing {u, v} does not disconnect G′. The SPQR tree is defined recursively on a graph G with a special split pair {s, t}. This process can be started by picking an arbitrary edge as the root. Each node µ in the tree T has an associated graph denoted as its skeleton, skeleton(µ), and is associated with an edge in the skeleton of its parent ν, called the virtual edge of µ in skeleton(ν). In this way, each virtual edge of a node ν corresponds to a child of ν. For contrast, we will also use real edges to denote edges that are present in G. whose skeleton is G itself. -- Trivial Case: if G is a single edge from s to t, then T contains a single Q-node -- Series Case: If the removal of the (virtual) edge st creates cut-vertices, then these cut vertices partition G into blocks G1 . . . Gk and the block-tree has a cycle-like structure. The root of T is then an S-node, and skeleton(µ) is the cycle containing these cut vertices with virtual edges corresponding to the blocks. -- Parallel Case: If the split pair {s, t} creates split components G1 . . . Gk with k ≥ 2, the root of T is a P-node and the skeleton contains k parallel virtual edges from s to t corresponding to the split components. -- Rigid Case: If none of the above cases apply, then the root of T is an R-node µ and skeleton(µ) is a tri-connected graph where each edge corresponds to a split pair {si, ti}, and the corresponding child contains the union of all split components generated by this pair. Note that by this construction, each edge in the SPQR tree corresponds to a split-pair. An additional detail that we omitted is that the construction of R- nodes picks only the split pairs that are maximal w.r.t. the edge st. This detail is 14 Peng et al. unimportant to our trimming routine, but is discussed in [37]. Our algorithm acts directly upon the SPQR tree, and we make use of several important properties of this tree in our reduction routines. When viewed as an unrooted tree, the SPQR tree is unique with all leaves as Q-nodes. For simplicity, we will refer to this tree with all Q-nodes removed as the simplified SPQR tree, or Tsimple. Also, it suffices to work on the skeletons of nodes, and the only candidates for separation pairs that we need to consider are: 1. Two cut vertices in an S-node. 2. The split pair corresponding to a P-node. 3. Endpoints of an edge in an R-node. A.2 Trimming SPQR trees We now show how to convert a bi-connected graph with k active vertices to a 3- vertex equivalent with O(k) vertices and edges. Our algorithm makes a sequence of modifications on the SPQR trees similar to the trimming from Section 3. We will call a vertex u internal to a node µ of the SPQR tree if u is contained in the split graph of µ, and u is not part of the split pair associated with µ. We call a vertex u exact to a node µ if it is internal to µ but not to any descendants of µ. Exact vertices provide a way to count nodes according to active vertices without reusing active vertices for multiple nodes. We first give a way to remove split components with no internal active ver- tices, which we will refer to as inactive split components. Lemma 12. Consider an inactive non-Q split component G′ produced by the split pair {u, v}. We may create a 3-vertex equivalent graph H by the following replacement rule: if u and v are ≥ 3-vertex connected in G, we may replace G′ with the edge uv; otherwise, we may replace G′ with a vertex x and edges ux, vx. Proof. Consider a cut in G. If u and v are on the same side of the cut, an equivalent cut exists in H by placing u, v, and possibly x on the same side of the cut. Similarly, a cut in G that removes either u or v can be made in H by removing the same vertex. If a cut in G separates u and v, u and v are not ≥ 3-vertex connected in G and a vertex w in G′ must have been removed since G′ connects u and v. Removing x instead of w creates an equivalent cut in H. In the other direction, if u and v were ≥ 3-vertex connected in G, also no cut in H separates u and v. If u and v were not ≥ 3-vertex connected in G, there exists a vertex w in G′ whose removal separates u and v in G′. Therefore the cut in H produced by vertices {x, z} for some z /∈ G′ that separates u and v can be made in G by removing {w, z} instead. All other cuts in H can be formed in G by placing G′ on the same side as any remaining vertex in {u, v}. An important consequence of Lemma 12 is that an inactive split component is a leaf in Tsimple. Because of this, it will be easier to think of inactive split Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 15 components in the same way we think of Q-nodes. We define the tree Tsimple′ as the tree Tsimple with inactive split component leaves removed. Every leaf µ in Tsimple′ must have an internal active vertex u. Furthermore, any vertex internal to a node η is only internal to ancestors and possibly descendants of η. Since µ is a leaf in Tsimple′ , it has no descendants. It follows that u is exact for µ and the tree Tsimple′ has O(k) leaves. We will use this to bound the number of leaves in T . However, if G contains an R-node whose skeleton contains a complete graph between active vertices, the number of leaves in T can still be Ω(k2). Therefore, we need another rule to process each skeleton of Tsimple′ so that we can bound its size by the number of its exact active vertices and split components. Lemma 13. There exists a constant c0 such that any node µ in Tsimple′ whose skeleton contains a total of k exact active vertices and virtual edges corresponding to active split components can be replaced by a node whose skeleton contains c0·k vertices/edges to give a 3-vertex equivalent graph. In other words, the number of children of µ in T is at most c0 · k. Proof. We consider the cases where the node is of type S, P, R separately. If the node is a P-node, it suffices to consider the case where there are 3 or more inactive split components incident to the cut pair. Removing at most 2 vertices from these components will leave at least one of them intact, and there- fore not change the connectivity between the separation pair, and therefore the other components. Therefore, all except 3 of these components can be discarded. If the node is an S-node, any virtual edge in the cycle corresponding to an inactive split component that's not incident to two active vertices is replaced by actual edges via Lemma 12. Furthermore, two consecutive real edges in the cycle connecting three inactive vertices can be reduced to a single edge by removing the middle vertex in a manner analogous to Lemma 4. Therefore the size of the cycle is proportional to the number of exact active vertices and active split components. For an R-node, we can identify all vertices that are either exact and active, or are incident to virtual edges corresponding to active split components. Then we can simply connect these vertices together using a tri-connected graph of linear size (e.g. a wheel graph) and add the active split components back between their respective separation pairs. Every cut in the new skeleton with a child in Tsimple can be produced by the original graph, and the only cuts in the original graph that can't be produced in the new one are cuts isolating an inactive component. Therefore the two graphs are 3-vertex equivalent. Before we can bound the number of nodes in Tsimple′ , we must eliminate long paths where a node has only one active child, which in turn has only one active child, etc. This is only possible if there exists an active vertex (vertices) internal to each split component, otherwise by Lemma 12, a node with no internal active vertices becomes a leaf. Since the internal active vertex (vertices) are shared amongst all ancestors, there is no way to associate the active vertex with a 16 Peng et al. constant number of SPQR nodes. The replacement rule in this Lemma provides a way to get around this. Lemma 14. Let µ1, µ2, and µ3 be a parent-child sequence of SPQR nodes where µ2 and µ3 are associated with split pairs {u, v} and {x, y} respectively, µ3 is the single active child of µ2, µ2 is the single active child of µ1, and either none of u, v, x, and y are active or u = x and is active. We may replace µ2 with µ3, effectively replacing vertex u with x and v with y. Proof. In G, cuts induced by the removal of {u, v} and {x, y} both give the same partition of active vertices. Therefore, we only need one in H, which is given by the cut {x, y}. All other cuts in G not present in H only separate inactive split components, which need not be represented in H. In the other direction, every cut in H is still present in G. Thus the new graph H preserves 3-vertex equivalence. We can now bound the number of nodes in Tsimple′ after no reductions via Lemmas 12, 13, and 14 are possible. Lemma 15. Consider a graph G where no reductions via Lemmas 12, 13, and 14 are possible. There is a constant c1 such that the number of nodes in G's SPQR tree T is no more than c1 · k, where k is the total number of active vertices in G. Proof. As explained earlier, the tree Tsimple′ has O(k) leaves. To bound the total number of nodes, we must consider the length of a path of degree 2 nodes in Tsimple′ . If a node µ on this path has a split pair {u, v} with an active vertex, say u, internal to its parent η (implying η does not have u in its split pair), then u is exact for η and we may associate u with η. Otherwise, consider two adjacent degree 2 nodes to which this does not apply. The parent may have an active vertex in its split pair not shared with its child, however then its child cannot have an active vertex in its split pair or else it fits the above situation (the active vertex in the child's split pair is internal to the parent). Therefore this can only happen once until the parent and child have at most one active vertex shared in their split pairs, and the procedure of Lemma 14 may be used to replace the parent node with the child. It follows that we may associate each active vertex along this path to a constant number of SPQR nodes. Since the number of nodes of degree ≥ 3 in a tree is bounded by the number of leaves, the above shows Tsimple′ has O(k) nodes. We now consider the full tree T . This tree adds inactive split components with a constant number of Q-node leaves as well as Q-node leaves themselves to active split components. By Lemma 13, for any node µ in Tsimple′ , we add at most c0 · k extra children to µ in T , where k is the sum of active vertices exact to µ and the number of active split components, which are children of µ in Tsimple′ . The sum of the degrees of all the vertices in Tsimple′ is O(k), therefore the number of extra nodes in T is also O(k). Therefore T has O(k) nodes. Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 17 We now consider applying Lemmas 12, 13, and 14 on G to produce a 3-vertex equivalent graph H in linear time. Lemma 16. Given a bi-connected graph G and k active vertices W , we may find the SPQR tree associated with G and apply the reduction rules given by Lem- mas 12, 13, and 14 until exhaustion in linear time. From this can be constructed a graph H 3-vertex equivalent to G with O(k) vertices and edges. Proof. The SPQR tree can be found in linear time [6]. Lemma 15 shows that continued application of Lemmas 12, 13, and 14 produces an SPQR tree T with O(k) nodes. As each leaf of T is an edge of the graph it represents, this shows the resulting graph represented has O(k) vertices and edges. The rules given by Lemmas 12, 13, and 14 can be applied until exhaustion in O(m) time. First, we may apply Lemma 12 by traversing each split component of T and applying the lemma when possible. Next, we may apply Lemma 13 by a similar traversal. Finally, the rule of Lemma 14 can be applied by keeping a stack of the SPQR nodes of a depth-first traversal of the SPQR tree T . All three rules require a single traversal of T each and thus can be done in O(m) total time. A.3 Constructing the Full Equivalent We now extend this trimming routine for bi-connected graphs to arbitrary graphs. By an argument similar to that at the start of Section 3, we may assume that G is connected. Therefore we need to work on the block-tree in a manner similar to Section 3.2. We first show that we may invoke the trimming routine from Section A.2 on each bi-connected component. Lemma 17. Let B be a bi-connected component in G and B ′ be a 3-vertex equivalent graph for B where the active vertices consist of all cut vertices and active vertices in B. Replacing B with B ′ gives H that's 3-vertex equivalent to G. Proof. By symmetry of the setup it suffices to show that any cut in G has an equivalent cut in H. Since B is two-connected, any cut in B that does not remove at least 2 vertices in B results in all vertices of B on the same side of the cut. This means any vertex in B that's not a cut-vertex in G can be added without changing the cut. This also means that removing these vertices has the same effect in G and H. Therefore it suffices to consider cuts that remove 2 vertices in B. By assump- tion, there exists a cut in H that results in the same set of active vertices in C, and cut vertices incident to B on one side. The structure of the block tree gives that the rest of the graph is connected to B via one of the cut vertices, and the side that this cut vertex is on dictates the side of the cut that part is on. Therefore, the rest of the graph, and therefore the active vertices not in B will be partitioned the same way by this cut. 18 Peng et al. It remains to reduce the block tree, which we do in a way analogous to Section 3.2. However, the proofs need to be modified for separation pairs instead of a single cut edge/vertex. Lemma 18. A bi-connected component containing no active vertices and in- cident to only one cut vertex can be removed (while keeping the cut-vertex) to create a 3-vertex equivalent graph. Proof. Any cut in G can be mapped over to H by removing the same set of vertices (minus the ones in this component). Given a cut in H, removing the same set of vertices in G results in a cut with this component added to one side. As there are no active vertices in this cut, the cut separates the active vertices in the same manner. Long paths of bi-connected components can be handled in a way similar to Lemma 7. Lemma 19. Two bi-connected components C1 and C2 with no active vertices that share cut vertex w and are only incident to one other cut vertex each, u and v respectively, can be replaced by an edge connecting u and v, preserving 3-vertex equivalence. Proof. As there is a path from u to v through these components and w, a min- imum cut that separates W in G either removes one of u, v, or w, or has uv on the same side. In the first case, removing u or v leads to the same cut as none of them are active, while in the second case the edge uv does not cross the cut. Since uv is connected by an edge in H, in a cut in H they're either on the same side, or one of u or v is removed. In either case, an equivalent cut in G can be formed by assigning what remains of C1 and C2 to the same side as any remaining vertex. Our final construction can be obtained by applying these routines to the block tree first, then Lemma 17. Lemma 20. Given a graph G with m edges and k active vertices W , a 3-vertex equivalent of G of size O(k), H, can be constructed in O(m) time. Proof. By a proof similar to Lemma 8, applying Lemmas 18 and 19 repeatedly leads to a 3-vertex equivalent graph H whose block-tree contains O(k) compo- nents and cut vertices. The total number of cut vertices and active vertices summed over all bi- connected components is O(k). Therefore, applying Lemma 17 on each compo- nent gives the size bound. B Omitted Proofs Proof (Proof of Lemma 10). We prove by contradiction. Let G be a graph with no nontrivial 3-edge connected component. Suppose there exists two simple cycles a and b in G with more than one vertex, and thus at least one edge, in common. Optimal Offline Dynamic 2, 3-Edge/Vertex Connectivity 19 Call the vertices in the first simple cycle a1, . . . , an and the second simple cycle b1, . . . , bm, in order along the cycle. Since these cycles are not the same, there must be some vertex not common to both cycles. Without loss of generality, assume (by flipping a and b) that b is not a subset of a, and (by shifting b cyclically) that b1 is only in b and not a. Now let bf irst be the first vertex after b1 in b that is common to both cycles, so f irst def = min i bi ∈ a. and let blast be the last vertex in b common to both cycles last def = max i bi ∈ a. (1) (2) The assumption that these two cycles have more than 1 vertex in common means that f irst < last. (3) We claim bf irst and blast are 3-edge connected. We show this by constructing three edge-disjoint paths connecting bf irst and blast. Since both bf irst and blast occur in a, we may take the two paths formed by cycle a connecting bf irst and blast, which are clearly edge-disjoint. By construction, vertices blast+1, . . . , bm, b1, . . . , bf irst−1 (4) are not shared with a. Thus they form a third edge-disjoint path connecting bf irst and blast, and so the claim follows. Therefore, a graph with no 3-edge connected vertices, and thus no nontrivial 3-edge connected component has the property that two simple cycles have at most one vertex in common.
1708.09080
2
1708
2018-06-25T00:58:54
Dynamic Graph Coloring
[ "cs.DS" ]
In this paper we study the number of vertex recolorings that an algorithm needs to perform in order to maintain a proper coloring of a graph under insertion and deletion of vertices and edges. We present two algorithms that achieve different trade-offs between the number of recolorings and the number of colors used. For any $d>0$, the first algorithm maintains a proper $O(\mathcal{C} d N^{1/d})$-coloring while recoloring at most $O(d)$ vertices per update, where $\mathcal{C}$ and $N$ are the maximum chromatic number and maximum number of vertices, respectively. The second algorithm reverses the trade-off, maintaining an $O(\mathcal{C} d)$-coloring with $O(d N^{1/d})$ recolorings per update. The two converge when $d = \log N$, maintaining an $O(\mathcal{C} \log N)$-coloring with $O(\log N)$ recolorings per update. We also present a lower bound, showing that any algorithm that maintains a $c$-coloring of a $2$-colorable graph on $N$ vertices must recolor at least $\Omega(N^\frac{2}{c(c-1)})$ vertices per update, for any constant $c \geq 2$.
cs.DS
cs
Dynamic Graph Coloring∗ Luis Barba† Jean Cardinal‡ Matias Korman§ Stefan Langerman‡ Andr´e van Renssen¶ Marcel Roeloffzen(cid:107) Sander Verdonschot∗∗ Abstract In this paper we study the number of vertex recolorings that an algorithm needs to perform in order to maintain a proper coloring of a graph under insertion and deletion of vertices and edges. We present two algorithms that achieve different trade-offs between the number of recolorings and the number of colors used. For any d > 0, the first algorithm maintains a proper O(CdN 1/d)-coloring while recoloring at most O(d) vertices per update, where C and N are the maximum chromatic number and maximum number of vertices, respectively. The second algorithm reverses the trade-off, maintaining an O(Cd)-coloring with O(dN 1/d) recolorings per update. The two converge when d = log N , maintaining an O(C log N )-coloring with O(log N ) recolorings per update. We also present a lower bound, showing that any algorithm that maintains a c-coloring of a 2-colorable graph on N vertices must recolor at least Ω(N c(c−1) ) vertices per update, for any constant c ≥ 2. 2 1 Introduction It is hard to underestimate the importance of the graph coloring problem in computer science and combinatorics. The problem is certainly among the most studied questions in those fields, and countless applications and variants have been tackled since it was first posed for the special case of maps in the mid-nineteenth century. Similarly, the maintenance of some structures in dynamic graphs has been the subject of study of several volumes in the past couple of decades [2, 3, 13, 21, 22, 24]. In this setting, an algorithmic graph problem is modelled in the dynamic environment as follows. There is an online sequence of insertion and deletion of edges or vertices, and our goal is to maintain the solution of the graph problem after each update. A trivial way to maintain this solution is to run the best static algorithm for this problem after each update; however, this is clearly not optimal. A dynamic graph algorithm seeks to maintain some clever data structure for the underlying problem such that the time taken to update the solution is much smaller than that of the best static algorithm. In this paper, we study the problem of maintaining a coloring in a dynamic graph undergoing insertions and deletions of both vertices and edges. At first sight, this may seem to be a hopeless task, since there exist near-linear lower bounds on the competitive factor of online graph coloring algorithms [11], a restricted case of the dynamic setting. In order to break through this barrier, we allow a "fair" number of vertex recolorings per update. We focus on the combinatorial aspect of the problem – the trade-off between the number of colors used versus the number of recolorings per update. We present a strong general lower bound and two simple algorithms that provide complementary trade-offs. 1.0.1 Definitions and Results. Let C be a positive integer. A C-coloring of a graph G is a function that assigns a color in {1, . . . ,C} to each vertex of G. A C-coloring is proper if no two adjacent vertices are assigned the same color. We ∗An extended abstract of this paper appeared in the proceedings of the 15th Algorithms and Data Structures Symposium (WADS 2017) [1]. M. K. was partially supported by MEXT KAKENHI grant Nos. 12H00855, and 17K12635. M. K., A. v. R. and M. R. were supported by JST ERATO Grant Number JPMJER1201, Japan. L. B. was supported by the ETH Postdoctoral Fellowship. S. V. was partially supported by NSERC and the Carleton-Fields postdoctoral award. S. L. is Directeur de Recherches du F.R.S.-FNRS. †Dept. of Computer Science, ETH Zurich, [email protected] ‡D´epartment d'Informatique, Universit´e Libre de Bruxelles, Brussels, Belgium. {jcardin,stefan.langerman}@ulb.ac.be §Tohoku University, Sendai, Japan. [email protected] ¶University of Sydney, Sydney, Australia. [email protected] (cid:107)TU Eindhoven, Eindhoven, Netherlands. [email protected] ∗∗School of Computer Science, Carleton University, Ottawa, Canada. [email protected] 1 say that G is C-colorable if it admits a proper C-coloring, and we call the smallest such C the chromatic number of G. A recoloring algorithm is an algorithm that maintains a proper coloring of a simple graph while that graph undergoes a sequence of updates. Each update adds or removes either an edge or a vertex with a set of incident edges. We say that a recoloring algorithm is c-competitive if it uses at most c · Cmax colors, where Cmax is the maximum chromatic number of the graph during the updates. For example, an algorithm that computes the optimal coloring after every update is 1-competitive, but may recolor every vertex for every update. At the other extreme, we can give each vertex a unique color, resulting in a linear competitive factor for an algorithm that (re)colors at most 1 vertex per update. In this paper, we investigate intermediate solutions that use more than C colors but recolor a sublinear number of vertices per update. Note that we do not assume that the value C is known in advance, or at any point during the algorithm. In Section 2, we present two complementary recoloring algorithms: an O(dN 1/d)-competitive algorithm with an amortized O(d) recolorings per update, and an O(d)-competitive algorithm with an amortized O(dN 1/d) recolorings per update, where d is a positive integer parameter and N is the maximum number of vertices in the graph during a sequence of updates. Interestingly, for d = Θ(log N ), both are O(log N )- competitive with an amortized O(log N ) vertex recolorings per update. Using standard techniques, the algorithms can be made sensitive to the current (instead of the maximum) number of vertices in the graph. In addition, we present de-amortized versions of both algorithms in Section 3. These de-amortized versions have the same competitive ratio and recolorings per update as the amortized versions. We provide lower bounds in Section 4. In particular, we show that for any recoloring algorithm A using c colors, there exists a specific 2-colorable graph on N vertices and a sequence of m edge c(c−1) ) vertex recolorings. Thus, any insertions and deletions that forces A to perform at least Ω(m · N x-competitive recoloring algorithm performs in average at least Ω(N x(2x−1) ) recolorings per update. 2 1 To allow us to focus on the combinatorial aspects, we assume that we have access to an algorithm that, at any time, can color the current graph (or an induced subgraph) using few colors. Of course, finding an optimal coloring of an n-vertex graph is NP-complete in general [15] and even NP-hard to approximate to within n1− for any  > 0 [26]. Still, this assumption is not as strong as it sounds. Most practical instances can be colored efficiently [6], and for several important classes of graphs the problem is solvable or approximable in polynomial time, including bipartite graphs, planar graphs, k-degenerate graphs, and unit disk graphs [17]. 1.0.2 Related results. Dynamic graph coloring. The problem of maintaining a coloring of a graph that evolves over time has been tackled before, but to our knowledge, only from the points of view of heuristics and experimental results. This includes for instance results from Preuveneers and Berbers [20], Ouerfelli and Bouziri [18], and Dutot et al. [9]. A related problem of maintaining a graph-coloring in an online fashion was studied by Borowiecki and Sidorowicz [5]. In that problem, vertices lose their color, and the algorithm is asked to recolor them. Online graph coloring. The online version of the problem is closely related to our setting, except that most variants of the online problem only allow the coloring of new vertices, which then cannot be recolored later. Near-linear lower bounds on the best achievable competitive factor have been proven by Halld´orsson and Szegedy more than two decades ago [11]. They show their bound holds even when the model is relaxed to allow a constant fraction of the vertices to change color over the whole sequence. This, however, does not contradict our results. We allow our algorithms to recolor all vertices at some point, but we bound only the number of recolorings per update. Algorithms for online coloring with competitive factor coming close, or equal to this lower bound have been proposed by Lov´asz et al. [16], Vishwanathan [25], and Halld´orsson [10]. Dynamic graphs. Several techniques have been used for the maintenance of other structures in dynamic graphs, such as spanning trees, transitive closure, and shortest paths. Surveys by Demetrescu et al. [7, 8] give a good overview of those. Recent progress on dynamic connectivity [14] and approximate single-source shortest paths [12] are witnesses of the current activity in this field. Data structure dynamization. Our bucketing algorithms are very much inspired by standard techniques for the dynamization of static data structures, pioneered by Bentley and Saxe [23, 4], and by Overmars and van Leeuwen [19]. 2 1.1 Outline In this section, we describe the intuition behind the two complementary recoloring algorithms presented in this paper: the small and the large bucket algorithms. Both algorithms partition the vertices of the graph into a set of buckets. Each bucket has C colors that are not used by any other bucket. These colors are used to properly color the subgraph induced by the vertices the bucket contains. This guarantees that the entire graph is always properly colored. Recall however that we assume that our algorithms have no prior knowledge of the value of C. The small-buckets algorithm uses many "small" buckets. This causes it to use more colors, but fewer recolorings per operation. The buckets are grouped into d levels (for some integer d > 0), each containing roughly n1/d buckets, and all buckets on the same level have the same capacity (roughly ni/d for level i). (Here n denotes the current number of vertices.) Since each bucket uses at most the first C colors of its unique set of colors, the small-buckets algorithm uses a total of O(dN 1/d · C) colors. The idea of the algorithm is simple: every time that an edge is added, we remove one of its endpoints from the bucket it lies in, and we move it to an empty bucket in the first level. At some point this operation "fills" the first level of buckets by filling all buckets at that level. Then all the vertices in this level are promoted to the next level. This promotion can be propagated again at the next level if that is also filled. If this propagation reaches the top level, a global recoloring is performed. Using amortization arguments, we can show that the algorithm performs O(d) amortized recolorings per update. Intuitively, it suffices to move and recolor a constant number of vertices from each level during each update. Our second algorithm uses larger buckets and thus uses fewer colors, but more recolorings per operation. Intuitively, a big bucket is the result of merging all buckets on one level of the small-buckets algorithm. Thus, we get d buckets, corresponding to the d levels used above, where bucket i has size roughly n(i+1)/d. Since each bucket uses C colors, the big-buckets algorithm uses a total of O(d · C) colors. The number of recolorings per insertion however is larger as each insertion triggers a recoloring of the smallest bucket. Whenever a bucket becomes full, it is emptied into the next bucket, which is in turn recolored. If this propagation reaches the top level, a global recoloring is performed. We show that the big-buckets algorithm performs O(dN 1/d) amortized recolorings per update. Using standard de-amortization techniques, we are able to obtain the same bounds in the worst-case for both algorithms. For the lower bound, consider a graph consisting of three stars with n/3 vertices each. If a recoloring algorithm wants to maintain a 2-coloring of this graph, then two of the stars will have the same color scheme. By linking their roots, we force the algorithm to recolor at least n/3 vertices and removing the added edge brings us back to the initial state with the three 2-colored stars, two of them having the same color scheme. Repeating this process shows that any recoloring algorithm that maintains a 2-coloring needs to perform Ω(n) vertex recolorings per update. If we want to maintain a c-coloring instead, then this idea can be extended and used in different phases. We start constructing trees that are formed by merging stars with the same coloring scheme. Our construction builds up larger and larger trees through updates and with every step forces the algorithm to either recolor many vertices or use new colors. Eventually the algorithm has used up all its colors and is forced to recolor a large number of vertices. 2 Upper bound: Recoloring-algorithms Before describing the specific strategies, we first introduce some concepts and definitions that are common to all our algorithms. It is easy to see that deleting a vertex or edge never invalidates the coloring of the graph. As such, our algorithms do not perform any recolorings when vertices or edges are deleted. The same is true when an edge is inserted between two vertices of different color, leaving only the insertion of an edge between two vertices of the same color, and the insertion of a new vertex, connected to a given set of current vertices, as interesting cases. In our algorithms, we simplify this even further, by implementing the edge insertion case as deleting one of its endpoints and re-inserting it with its new set of adjacent edges. Therefore both the description of the algorithms and the proofs in this section consider only vertex insertions. Our algorithms partition the vertices into a set of buckets, each of which has its own set of colors that it uses to color the vertices it contains. This set of colors is completely distinct from the sets used by other buckets. Since all our algorithms guarantee that the subgraph induced by the vertices inside each bucket is properly colored, this implies that the entire graph is properly colored at all times. The algorithms differ in the number of buckets they use and the size (maximum number of vertices) of each bucket. Typically, there is a sequence of buckets of increasing size, and one reset bucket that 3 can contain arbitrarily many vertices and that holds vertices whose color has not changed for a while. Initially, the size of each bucket depends on the number of vertices in the input graph. As vertices are inserted and deleted, the current number of vertices changes. When certain buckets are full, we reset everything, to ensure that we can accommodate the new number of vertices. This involves emptying all buckets into the reset bucket, computing a proper coloring of the entire graph, and recomputing the sizes of the buckets in terms of the current number of vertices. We refer to the number of vertices during the most recent reset as NR, and we express the size of the buckets using s = (cid:100)N 1/d R (cid:101), where d > 0 is an integer parameter that allows us to achieve different trade-offs between the number of colors and number of recolorings used. Since s = O(N 1/d), where N is the maximum number of vertices thus far, we state our bounds in terms of N . Note that it is also possible to keep NR within a constant factor of the current number of vertices by triggering a reset whenever the current number of vertices becomes too small or too large. Standard amortization techniques can be used to show that this would cost only a constant number of additional amortized recolorings per insertion or deletion, although deamortization would be more complicated. We omit these details for the sake of simplicity. 2.1 Small-buckets algorithm Our first algorithm, called the small-buckets algorithm, uses a lot of colors, but needs very few recolorings. In addition to the reset bucket, the algorithm uses ds buckets, grouped into d levels of s buckets each. All buckets on level i, for 0 ≤ i < d, have capacity si (see Fig. 1). Initially, the reset bucket contains all vertices, and all other buckets are empty. Throughout the execution of the algorithm, we ensure that every level always has at least one empty bucket. We call this the space invariant. Figure 1: The small-buckets algorithm uses d levels, each with s buckets of capacity si, where i is the level, s = (cid:100)N 1/d R (cid:101), and NR is the number of vertices during the last reset. When a new vertex is inserted, we place it in any empty bucket on level 0. The space invariant guarantees the existence of this bucket. Since this bucket has a unique set of colors, assigning one of them to the new vertex establishes a proper coloring. Of course, if this was the last empty bucket on level 0, filling it violates the space invariant. In that case, we gather up all s vertices on this level, place them in the first empty bucket on level 1 (which has capacity s and must exist by the space invariant), and compute a new coloring of their induced graph using the set of colors of the new bucket. If this was the last free bucket on level 1, we move all its vertices to the next level and repeat this procedure. In general, if we filled the last free bucket on level i, we gather up all at most s · si = si+1 vertices on this level, place them in an empty bucket on level i + 1 (which exists by the space invariant), and recolor their induced graph with the new colors. If we fill up the last level (d − 1), we reset the structure, emptying each bucket into the reset bucket and recoloring the whole graph. Theorem 1. For any integer d > 0, the small-buckets algorithm is an O(dN 1/d)-competitive recoloring algorithm that uses at most O(d) amortized vertex recolorings per update. Proof. The total number of colors is bounded by the maximum number of non-empty buckets (1+d(s−1)), multiplied by the maximum number of colors used by any bucket. Let C be the maximum chromatic number of the graph. Since any induced subgraph of a C-colorable graph is also C-colorable, each bucket requires at most C colors. Thus, the total number of colors is at most (1 + d(s − 1))C, and the algorithm is O(dN 1/d)-competitive. To analyze the number of recolorings, we use a simple charging scheme that places coins in the buckets and pays one coin for each recoloring. Whenever we place a vertex in a bucket on level 0, we give d + 2 coins to that bucket. One of these coins is immediately used to pay for the vertex's new color, leaving d + 1 coins. In general, we maintain the invariant that each non-empty bucket on level i has si · (d − i + 1) coins. 4 1si∞s111sisis1si1 When we merge the vertices on level i into a new bucket on level i + 1, we pay a single coin for each vertex that changes color. Since each bucket had si · (d − i + 1) coins, and we recolored at most s · si = si+1 vertices, our new bucket has at least s · si · (d − i + 1) − si+1 = si+1 · (d − (i + 1) + 1) coins left, satisfying the invariant. When we fill up level d − 1, we reset the structure and recolor all vertices. At this point, the buckets on level d − 1 have a total of s · sd−1 · (d − (d − 1) + 1) = 2sd coins, and no more than sd vertices. Since all new vertices are inserted on level 0, and vertices are moved to the reset bucket only during a reset, the number of vertices in the reset bucket is at most NR. Since sd = (cid:100)N 1/d R )d = NR, we have enough coins to recolor all vertices. Thus, we require no more than d + 2 = O(d) amortized recolorings per update. R (cid:101)d ≥ (N 1/d 2.2 Big-buckets algorithm Figure 2: Besides the reset bucket, the big-buckets al- gorithm uses d buckets, each with capacity si+1, where i is the bucket number. Our second algorithm, called the big-buckets algo- rithm, is similar to the small-buckets algorithm, ex- cept it merges all buckets on the same level into a single larger bucket. Specifically, the algorithm uses d buckets in addition to the reset bucket. These buckets are numbered sequentially from 0 to d − 1, with bucket i having capacity si+1, see Fig. 2. Since we use far fewer buckets, an upper bound on the total number of colors drops significantly, to (d + 1)C. Of course, as we will see later, we pay for this in the number recolorings. Similar to the space invariant in the small-buckets algorithm, the big-buckets algorithm maintains the high point invariant: bucket i always contains at most si+1 − si vertices (its high point). When a new vertex is inserted, we place it in the first bucket. Since this bucket may already contain other vertices, we recolor all its vertices, so that the subgraph induced by these vertices remains properly colored. This revalidates the coloring, but may violate the high point invariant. If we filled bucket i beyond its high point, we move all its vertices to bucket i + 1 and compute a new coloring for this bucket. We repeat this until the high point invariant is satisfied, or we fill bucket d − 1 past its high point. In the latter case we reset, adding all vertices to the reset bucket and computing a new coloring for the entire graph. Theorem 2. For any integer d > 0, the big-buckets algorithm is an O(d)-competitive recoloring algorithm that uses at most O(dN 1/d) amortized vertex recolorings per update. Consider what happens when we place a vertex into bucket 0. Proof. The bound on the number of colors follows directly from the fact that we use d buckets in addition to the reset bucket. Hence, we use at most (d + 1)C colors at any point in time, making the algorithms O(d)-competitive. We proceed to analyze the number of recolorings per update. As in the small-buckets algorithm, we give coins to each bucket that we then use to pay for recolorings. In particular, we ensure that bucket i always has Pi = (cid:100)ki/si(cid:101) · si+1 · (d − i) coins, where ki is the number of vertices in bucket i. Initially, the bucket has P0 = (cid:100)k0/s0(cid:101)· s1· (d− 0) = k0sd coins. As a result of the insertion, we need to recolor all k0 + 1 vertices, and the invariant requires that the bucket has (k0 + 1)sd coins afterwards. By the high point invariant, we have that 1 + k0 ≤ s, so we can bound the number of coins we need to pay per update by k0 + 1 + sd ≤ (d + 1)s. Recall that this insertion may trigger a promotion of all vertices in bucket 0 to bucket 1, and that this could propagate until the high point invariant is satisfied again. When we merge bucket i into bucket i + 1, we need to recolor all vertices in these two buckets. This will be paid for by the coins stored in the smaller bucket. At this point, the high point invariant gives us that bucket i contains at least ki ≥ si+1 − si + 1 vertices. Thus, since (cid:100)ki/si(cid:101) ≥ (cid:100)(si+1 − si + 1)/si(cid:101) = s, bucket i has at least Pi = (cid:100)ki/si(cid:101) · si+1 · (d − i) ≥ si+2 · (d − i) coins. At the same time, bucket i + 1 has Pi+1 = (cid:100)ki+1/si+1(cid:101)· si+2· (d− i− 1) coins, and needs to gain at most si+2 · (d− i− 1) coins, as it gains at most si+1 vertices. This leaves si+2 · (d− i)− si+2 · (d− i− 1) = si+2 coins to pay for the recoloring. Since bucket i + 1 contained no more than si+2 − si+1 vertices by the high-point invariant, and we added at most si+1 new ones, this suffices to recolor all vertices involved and maintain the coin invariant. Finally, we perform a reset when bucket d− 1 passes its high point. In that case, bucket d− 1 contains at least sd − sd−1 + 1 vertices and therefore has at least (cid:100)(sd − sd−1 + 1)/sd−1(cid:101) · sd · (d − d + 1) = sd+1 5 ssi∞sd coins. Since the reset bucket contains at most NR ≤ sd vertices, we need to recolor at most 2sd vertices. As s = (cid:100)N 1/d R (cid:101) ≥ 2 if NR ≥ 2, we have enough coins to pay for all these recolorings. Therefore we can maintain the coloring with (d + 1)s = O(dN 1/d) amortized recolorings per update. 3 De-amortization In this section, we show how to de-amortize the algorithms presented in Section 2. We distinguish between the two different strategies. 3.1 Shadow vertices To de-amortize the two algorithms, we simulate the amortized version using fake vertices, called shadow vertices. Each real vertex v either has a unique shadow vertex sh(v), representing its state (color and location) in the amortized version, or has no shadow vertex, if it would be in the same location and have the same color in the amortized algorithm. When an update happens, we first move the shadow vertices exactly as the amortized algorithm would (creating new shadow vertices for real vertices without a shadow if needed), and then move and recolor some real vertices to match their shadows, removing the shadows. We call the first step the simulation step, and the second step the move step. Since we only count recolorings of real vertices, only the move step has any actual cost - we just use the simulation step to keep track of where vertices need to go. The only difference between the simulated versions of the amortized algorithms and the algorithms as presented in Section 2 is that the value for s is not allowed to decrease after a reset. Thus, s = (cid:100)N 1/d R (cid:101), where NR is the maximum number of vertices during any reset so far. 3.2 Small-buckets algorithm The de-amortized version of the small-buckets algorithm uses the same buckets as the amortized version, except for an additional reset bucket. At each stage of the algorithm there is one primary reset bucket and one secondary reset bucket. The primary reset bucket contains shadow vertices and real vertices without a shadow, whose colors correspond to the reset bucket in the amortized version. The secondary reset bucket contains real vertices with a shadow in the primary reset bucket. During a reset, the primary and secondary reset buckets change roles. As before, we discuss only vertex insertion. Recall that the amortized algorithm places a new vertex v in an empty bucket on level 0, and then iteratively merges full levels into higher ones, possibly triggering a reset if the last level fills up. During the simulation step, the de-amortized algorithm mimics this. Note that for the purpose of the simulation, we ignore real vertices with a shadow and instead operate on their shadow vertices. Thus, a level is considered full if every bucket contains either a shadow vertex or a real vertex without a shadow. On the other hand, whenever the amortized algorithm uses an empty bucket, we require that that bucket contains no real vertices at all, not even ones with a shadow. We show later that such a bucket is always available when needed. We first create a new shadow vertex for v and place it in an empty bucket on level 0. Then, if this level is full, we create a shadow vertex for every real vertex on this level without one, and move all shadow vertices to an empty bucket on level 1. Here, we color them with the new bucket's colors so that their induced graph is properly colored. If this fills up the new level, we repeat this until we reach a level that is not full, or we fill up the last level. In the latter case, we trigger a reset. During a reset, we create a new shadow vertex for all real vertices without one and move all shadow vertices into the secondary reset bucket, computing a proper coloring for them. At this point, the primary and secondary reset buckets switch roles. As in the amortized algorithm, we also recompute the value of s. If s increases, we add additional empty buckets and increase the capacity of the current buckets (recall that we do not allow s to decrease in the de-amortized versions). All of this happens during the simulation step. During the move step, we perform the actual recolorings. We first move and recolor the inserted vertex v to its shadow: moving it into the bucket containing sh(v), giving it the color of sh(v), and removing sh(v). Then we move and recolor one vertex from each level to its shadow. Specifically, for each level, we consider all buckets containing only real vertices with a shadow. Among those buckets, we pick the bucket with the least number of vertices and move and recolor one of its vertices to its shadow. Finally, we check the secondary reset bucket for vertices with a shadow and move and recolor one if found. Thus, we recolor at most d + 2 vertices per update. 6 Analysis We prove correctness by arguing that an empty bucket is available when needed. Lemma 1. After every update, there is at least one empty bucket on level 0. Proof. Since the lemma is true for the amortized version by the space invariant, we know that after the simulation step there is at least one bucket on level 0 that is either empty, in which case we are done, or contains a real vertex with a shadow. In this case, the move step will empty one such bucket. Lemma 2. Let ti be the number of updates since the last time level i was full, or the last reset, whichever is more recent. Then there is a bucket on level i + 1 that does not contain any shadow vertices and contains at most max(0, si+1 − ti) real vertices, each with a shadow. Proof. We prove this by induction on ti. The base case ti = 0 follows from the space invariant of the amortized version, since a bucket that is empty in the amortized version will only contain real vertices with a shadow, and each bucket has capacity si+1, which cannot decrease during resets. For the inductive step ti > 0, we know that before this update level i + 1 had a bucket without shadow vertices that was either completely empty (if ti > si+1), or had at most si+1 − (ti − 1) real vertices, each with a shadow. If the bucket was already empty, we are done. Otherwise, note that during the simulation step, the only time new vertices are created on level i + 1 is when level i fills up, which did not happen, as ti > 0. During a move step, we move and recolor one vertex from a bucket without shadow vertices and with the least number of real vertices, each with a shadow. Therefore, there must now be a bucket without shadow vertices and with at most si+1 − ti real vertices, each with a shadow. Lemma 3. At least si+1 updates are required for level i to fill up again after a reset or after it has filled up. Proof. Note that levels only fill up during the simulation step. Therefore this is a property of the amortized version of the algorithm. We prove the lemma by induction on i. Since each update creates at most one vertex on level 0, and there are s buckets, the lemma holds for level 0. Vertices on level i > 0 are only created when level i − 1 fills up. By induction, this happens at most every si updates, and each occurrence creates these vertices in only one bucket. Since there are s buckets on level i, it takes at least si+1 updates for it to fill up. By combining Lemmas 2 and 3 we get the following corollary. Corollary 1. When level i fills up, there is an empty bucket on level i + 1 (for 0 ≤ i < d − 1). Lemma 4. When a reset happens, the secondary reset bucket is empty. Proof. Initially, the entire point set is contained in the primary reset bucket, and the secondary one is empty. Since only a reset can create shadow vertices in a reset bucket, the lemma holds at the first reset. When a subsequent reset happens, we have performed at least sd ≥ NR updates in order to fill up level d− 1 by Lemma 3. Since we move one vertex from the secondary reset bucket to the primary reset bucket during each move step, and the secondary reset bucket contains at most NR vertices, this bucket will be empty when the next reset happens. This shows that an empty bucket is available when needed, completing the correctness proof. The additional reset bucket increases the number of colors we use by C compared to the amortized algorithm, giving the following result. Theorem 3. For any integer d > 0, the de-amortized small-buckets algorithm is an O(dN 1/d)-competitive recoloring algorithm that uses at most d + 2 vertex recolorings per update. 3.3 Big-buckets algorithm As for the small-buckets algorithm, the de-amortized big-buckets algorithm splits the work into a simulation step, in which we move and recolor shadow vertices according to the amortized algorithm, and a move step in which we move and recolor a small number of real vertices to their shadows. The main difference is that we double all buckets, instead of just the reset bucket. There is a primary and secondary version of every bucket, each with its own set of colours. The primary buckets contain shadow vertices and real vertices without a shadow, while the secondary buckets contain only real vertices with a shadow. The simulation step acts only on the primary buckets, while the move step takes real vertices from the secondary buckets to their shadows in the primary buckets. The primary and secondary bucket on a level 7 (a) (b) (c) Figure 3: One vertex insertion in the de-amortized big-buckets algorithm. (a) Before the update. (b) During the simulation step the new vertex causes the first two levels to fill up, creating shadow vertices in the secondary third bucket and swapping the roles of these bucket pairs. (c) During the move step we move and recolor up to s vertices from each level. switch roles when new shadow vertices are added to the level. We prove that this happens only when the secondary bucket is empty. Recall that the high point invariant states that bucket i contains at most si+1 − si vertices. When a vertex is inserted, the amortized big-bucket algorithm tries to place it in bucket 0. If this violates the high point invariant, the bucket is emptied into the bucket on the next level, and so on, until we reach a level where the high point invariant is not violated. If such a level does not exist, we trigger a reset. The de-amortized algorithm simulates this as follows. During the simulation step, we find the first level i where we can insert the new vertex and all vertices on lower levels without violating the high point invariant. We give all these vertices, along with the vertices in the primary bucket of level i, a shadow in the secondary bucket of level i and compute a coloring for them, see Fig. 3. We then switch the roles of the primary and secondary buckets for all levels involved. During the move step, we move and recolor v to its shadow. In addition, we move and recolor up to s vertices from each level's secondary bucket and the secondary reset bucket to their shadows. If we cannot find a level to insert the new vertex without violating the high point invariant, we reset. This involves discarding all current shadow vertices and creating a new shadow vertex in the secondary reset bucket for each real vertex, computing a coloring for these vertices, and switching the primary and secondary reset buckets. We also recompute s and increase the bucket sizes if necessary. Analysis For correctness, the only thing we need to show is that, when we place shadow vertices in a secondary bucket on level i, that bucket is empty. A similar argument shows that the secondary reset bucket is empty whenever the high point invariant would fail for level d − 1. Lemma 5. When an update causes us to place shadow vertices in the secondary bucket of level i, that bucket is empty. Proof. Since the buckets on level 0 contain fewer than s vertices, the move step after each update empties the secondary bucket. For i > 0, recall that we only place shadow vertices here if the high point invariant would have been violated at level i − 1, which means that there are at least si − si−1 + 1 real vertices in the levels before i. Moreover, none of these vertices have a shadow, since each level's secondary bucket is empty by induction, and the primary bucket contains only real vertices without a shadow. Recall that, whenever we place shadow vertices in the secondary bucket of level i, we do this for all of the vertices on the lower levels. Thus, these si − si−1 + 1 vertices were inserted after the secondary bucket was last filled. Since each move step moves s vertices from the secondary bucket into the primary bucket, and since the buckets on level i contain no more than si+1 − si vertices by the high point invariant, the secondary bucket will be empty before the current insertion. The number of colors used is doubled compared to the amortized version, but the number of recolorings per operation is the same: 1 for the inserted vertex, at most s − 1 for level 0, and at most s for every other level and the reset bucket. Theorem 4. For any integer d > 0, the de-amortized big-buckets algorithm is an O(d)-competitive recoloring algorithm that uses at most (d + 1)s = O(dN 1/d) vertex recolorings per update. 8 4 Lower bound In this section we prove a lower bound on the amortized number of recolorings for any algorithm that maintains a c-coloring of a 2-colorable graph, for any constant c ≥ 2. We say that a vertex is c-colored if it has a color in [c] = {1, . . . , c}. For simplicity of description, we assume that a recoloring algorithm only recolors vertices when an edge is inserted and not when an edge is deleted, as edge deletions do not invalidate the coloring. This assumption causes no loss of generality, as we can delay the recolorings an algorithm would perform in response to an edge deletion until the next edge insertion. The proof for the lower bound consists of several parts. We begin with a specific initial configuration and present a strategy for an adversary that constructs a large configuration with a specific colouring and then repeatedly performs costly operations in this configuration. In light of this strategy, a recoloring algorithm has a few choices: it can allow the configuration to be built and perform the recolorings required, it can destroy the configuration by recoloring parts of it instead of performing the operations, or it can prevent the configuration from being built in the first place by recoloring parts of the building blocks. We show that all these options require an amortized large number of recolorings. 4.1 Maintaining a 3-coloring To make the general lower bound easier to understand, we first show that to maintain a 3-coloring, we need at least Ω(n1/3) recolorings on average per update. Lemma 6. For any sufficiently large n and any m ≥ 2n1/3, there exists a forest with n vertices, such that for any recoloring algorithm A, there exists a sequence of m updates that forces A to perform Ω(m · n1/3) vertex recolorings to maintain a 3-coloring throughout this sequence. Proof. Let A be any recoloring algorithm that maintains a 3-coloring of a forest under updates. We use an adversarial strategy to choose a sequence of updates on a specific forest with n nodes that forces A to recolor "many" vertices. We start by describing the initial forest structure. Figure 4: (left) A 1-configuration is any forest that has many 1-trees as induced subgraphs. (right) A 2-tree is constructed by connecting the roots of many 1-trees. A 1-tree is a rooted (star) tree with a distinguished vertex as its root and n2/3 − 1 leaf nodes attached to it. Initially, our forest consists of n1/3 pairwise disjoint 1-trees, which account for all n vertices in our forest. The sequence of updates we construct never performs a cut operation among the edges of a 1-tree. Thus, the forest remains a 1-configuration: a forest of rooted trees with the n1/3 independent 1-trees as induced subgraphs; see Fig. 4 (left). We require that the induced subtrees are not upside down, that is, the root of the 1-tree should be closer to the root of the full tree than its children. Intuitively, a 1-configuration is simply a collection of our initial 1-trees linked together into larger trees. Let F be a 1-configuration. We assume that A has already chosen an initial 3-coloring of F . We assign a color to each 1-tree as follows. Since each 1-tree is properly 3-colored, the leaves cannot have the same color as the root. Thus, a 1-tree T always has at least n2/3−1 leaves of some color C, and C is different from the color of the root. We assign the color C to T . In this way, each 1-tree is assigned one of the three colors. We say that a 1-tree with assigned color C becomes invalid if it has no children of color C left. Notice that to invalidate a 1-tree, algorithm A needs to recolor at least n2/3−1 of its leaves. Since the coloring uses only three colors, there are at least n1/3 3 X. In the remainder, we focus solely on these 1-trees. 1-trees with the same assigned color, say 2 2 A 2-tree is a tree obtained by merging n1/3 9 1-trees with assigned color X, as follows. First, we cut the edge connecting the root of each 1-tree to its parent, if it has one. Next, we pick a distinguished 1-tree with root r, and connect the root of each of the other n1/3 9 − 1 1-trees to r. In this way, we obtain a 2-tree whose root r has n2/3 − 1 leaf children from the 1-tree of r, and n1/3 9 − 1 new children that are the roots 9 .........n2/3−1leaves...n1/31-trees.........n2/3−1leavesn1/391-trees...... of other 1-trees; see Fig. 4 (right) for an illustration. This construction requires n1/3 and at most n1/3 9 edge deletions (if every 1-tree root had another parent in the 1-configuration). 9 − 1 edge insertions 9 ) = 2n1/3 We build 3 such 2-trees in total. This requires at most 6( n1/3 updates. If none of our 1-trees became invalid, then since our construction involves only 1-trees with the same assigned color X, no 2-tree can have a root with color X. Further, since the algorithm maintains a 3-coloring, there must be at least two 2-trees whose roots have the same color. We can now perform a matching link, by connecting the roots of these two trees by an edge (in general, we may need to perform a cut first). To maintain a 3-coloring after a matching link, A must recolor the root of one of the 2-trees and either recolor all its non-leaf children or invalidate a 1-tree. If no 1-tree has become invalidated, this requires at least n1/3 recolorings, and we again have two 2-trees whose roots have the same color. Thus, we can perform another matching link between them. We keep doing this until we either performed n1/3 6 matching links, or a 1-tree is invalidated. 9 3 Therefore, after at most n1/3 updates ( 2n1/3 for the construction of the 2-trees, and n1/3 3 3 matching links), we either have an invalid 1-tree, in which case A recolored at least n2/3−1 performed n1/3 forced A to perform at least Ω(n2/3) vertex recolorings, using at most n1/3 updates. 6 matching links, which forced at least n1/3 9 = n2/3 · n1/3 54 2 6 for the nodes, or we recolorings. In either case, we Since no edge of a 1-tree was cut, we still have a valid 1-configuration, where the process can be restarted. Consequently, for any m ≥ 2n1/3, there exists a sequence of m updates that starts with a 1-configuration and forces A to perform (cid:98) m 4.2 On k-trees n1/3(cid:99)Ω(n2/3) = Ω(m · n1/3) vertex recolorings. We are now ready to describe a general lower bound for any number of colors c. The general approach is the same as when using 3 colors: We construct trees of height up to c+1, each excluding a different color for the root of the merged trees. By now connecting two such trees, we force the algorithm A to recolor the desired number of vertices. 2(c−k) 2(c−k) Figure 5: A k-tree is constructed by connecting the roots of a large number of (k − 1)-trees. A 0-tree is a single node, and for each 1 ≤ k ≤ c, a k-tree is a tree obtained recursively by merging 2 · n 2 · n c(c−1) (k − 1)-trees as follows: Pick a (k − 1)-tree and let r be its root. Then, for each of the c(c−1) − 1 remaining (k − 1)-trees, connect their root to r with an edge; see Fig. 5 for an illustration. c(c−1) − 1 j-trees, called As a result, for each 0 ≤ j ≤ k − 1, a k-tree T consists of a root r with 2 · n the j-subtrees of T , whose root hangs from r. The root of a j-subtree of T is called a j-child of T . By construction, r is also the root of a j-tree which we call the core j-tree of T . 2(c−j−1) Whenever a k-tree is constructed, it is assigned a color that is present among a "large" fraction of its (k − 1)-children. Indeed, whenever a k-tree is assigned a color ck, we guarantee that it has at least c · n (k − 1)-children of color ck. We describe later how to choose the color that is assigned to a k-tree. 2(c−k) c(c−1) We say that a k-tree that was assigned color ck has a color violation if its root no longer has a (k − 1)-child with color ck. We say that a k-tree T becomes invalid if either (1) it has a color violation or (2) if a core j-tree of T has a color violation for some 1 ≤ j < k; otherwise we say that T is valid. Observation 1. To obtain a color violation in a k-tree constructed by the above procedure, A needs to recolor at least (cid:108) 2 vertices. 2(c−k) c(c−1) (cid:109) (cid:108) 2 (cid:109) c · n (cid:109) 2(c−k) c(c−1) (cid:108) 2 Proof. Let T be a valid k-tree constructed by the above procedure. Assume that T was assigned color (k − 1)-children of color ck when its color ck and recall that by definition, T had at least was assigned. Therefore, in order for T to have a color violation, A needs to change the color of at least c · n Notice that a valid c-colored k-tree of color ck cannot have a root with color ck. Formally, color ck is blocked for the root of a k-tree if this root has a child with color ck. In particular, the color assigned to a k-tree and the colors assigned to its core j-trees for 1 ≤ j ≤ k − 1 are blocked as long as the tree is valid. vertices. c · n 2(c−k) c(c−1) (cid:108) 2 (cid:109) 10 ···{{{{n2/c0-treesn2(c−2)c(c−1)1-treesn2(c−k+1)c(c−1)(k−2)-treesn2(c−k)c(c−1)(k−1)-trees 4.3 On k-configurations A 0-configuration is a set F0 of c-colored nodes, where F0 = T0 = αn, for some sufficiently large constant α which will be specified later. For 1 ≤ k < c, a k-configuration is a set Fk of Tk k-trees, where (4c)k · n1−(cid:80)k α 2(c−i) c(c−1) . i=1 Tk = Note that the trees of a k-configuration may be part of m-trees for m > k. If at least Tk k-configuration are valid, then the configuration is valid. 2 k-trees in a For our construction, we let the initial configuration F0 be an arbitrary c-colored 0-configuration in which each vertex is c-colored. To construct a k-configuration Fk from a valid (k − 1)-configuration Fk−1, consider the at least Tk−1 valid (k − 1)-trees from Fk−1. Recall that the trees of Fk−1 may be part of larger trees, but since we consider edge deletions as "free" operations we can separate the trees. Since each of these trees has a color assigned, among them at least Tk−1 2c have the same color assigned to them. Let ck−1 denote this color. 2 2(c−k) c(c−1) (k − 1)-trees, to obtain Fk we merge Tk−1 2c (k − 1)-trees of Because each k-tree consists of 2 · n color ck−1 into Tk k-trees, where Tk = Tk−1 2c · 1 2(c−k) c(c−1) = 2 · n (4c)k · n1−(cid:80)k α 2(c−i) c(c−1) . i=1 (cid:106) 2 (cid:107) Once the k-configuration Fk is constructed, we perform a color assignment to each k-tree in Fk as c(c−1) − 1 c-colored (k − 1)-children, we assign τ a color follows: For a k-tree τ of Fk whose root has 2 · n that is shared by at least children of its assigned color. After these color assignments, if each (k − 1)-tree used is valid, then each of the Tk k-trees of Fk is also valid. Thus, Fk is a valid configuration. Moreover, for Fk to become invalid, A would need to invalidate at least Tk of these (k− 1)-children. Therefore, τ has at least (cid:107) c(c−1) − 1 2(c−k) (cid:106) 2 c · n c · n 2(c−k) c(c−1) 2(c−k) 2 of its k-trees. Observation 2. Let τ be a valid j-tree with color cj assigned to it. If r is the root of τ , then r has at least one (j − 1)-child with color cj. The following result shows how colors are distributed inside a valid k-tree. Lemma 7. Let Fk be a valid k-configuration. For each 1 ≤ j < k, each core j-tree of a valid k-tree of Fk has color cj assigned to it. Moreover, ci (cid:54)= cj for each 1 ≤ i < j < k. Proof. The proof goes by induction on k. For k = 0 the results holds trivially. Assume the result holds for k − 1. When constructing Fk−1 from Fk, we know that each (k− 1)-tree in Fk is assigned the same color ck−1. Moreover, by the induction hypothesis, for each 1 ≤ j < k − 1, each core j-tree of a valid (k − 1)-tree in Fk−1 had color cj assigned to it. Thus, each core j-tree of a valid k-tree also has color cj assigned to it. We now show that ci (cid:54)= cj for each i < j. Let τj be a core j-tree of a valid k-tree in Fk with color cj. Since every core j-tree of a valid k-tree is also valid, τj is a valid j-tree. Therefore, there is a (j − 1)-child, say r, of τk of color cj. Let τj−1 be the (j − 1)-subtree of τj rooted at r. Since τj−1 has color cj−1 assigned to it by the first part of this lemma, we know that its root cannot have color cj−1. Therefore, cj (cid:54)= cj−1 and hence, we can assume that i < j − 1. By construction and since i < j − 1, we know that r is also the root of its core i-tree, say τi. Because τi is valid and has color ci, it must have an (i − 1)-child v of color ci. Since r is the root of τi, r and v are adjacent. Because r has color cj while v has color ci, and since Fk is c-colored, we conclude that ci (cid:54)= cj. We also provide bounds on the number of updates needed to construct a k-configuration. Lemma 8. Using Θ((cid:80)k to construct a k-configuration from a j-configuration, we need Θ((cid:80)k j-configuration. Proof. To merge Tk−1 2c i=j Ti) = Θ(Tj) edge insertions, we can construct a k-configuration from a valid (k − 1)-trees to into Tk k-trees, we need Θ(Tk−1) edge insertions. Thus, in total, i=j Ti) = Θ(Tj) edge insertions. 11 4.4 Reset phase Throughout the construction of a k-configuration, the recoloring-algorithm A may recolor several vertices which could lead to invalid subtrees in Fj for any 1 ≤ j < k. Because A may invalidate some trees from Fj while constructing Fk from Fk−1, one of two things can happen. If Fj is a valid j-configuration for each 1 ≤ j ≤ k, then we continue and try to construct a (k + 1)-configuration from Fk. Otherwise a reset is triggered as follows. Let 1 ≤ j < k be an integer such that Fi is a valid i-configuration for each 0 ≤ i ≤ j − 1, but Fj is not valid. Since Fj was a valid j-configuration with at least Tj valid j-trees when it was first constructed, we know that in the process of constructing Fk from Fj, at least Tj 2 j-trees where invalidated by A. We distinguish two ways in which a tree can be invalid: (1) the tree has a color violation, but all its j−1-subtrees are valid and no core i-tree for 1 ≤ i ≤ j−1 has a color violation; or (2) A core i-tree has a color violation for 1 ≤ i ≤ j − 1, or the tree has a color violation and at least one of its (j − 1)-subtrees is invalid. In case (1) the algorithm A has to perform fewer recolorings, but the tree can be made valid again with a color reassignment, whereas in case (2) the j-tree has to be rebuild. 2(c−i) 2(c−j) 2(c−j+1) c · n c · n c(c−1) − 1. Let Y0, Y1 and Y2 respectively be the set of j-trees of Fj that are either valid, or are invalid by case 2 j-trees were invalidated, we know that Y1 + Y2 > Tj (1) or (2) respectively. Because at least Tj 2 . c(c−1) − 1 vertices to create the color violation on Moreover, for each tree in Y1, A recolored at least 2 this j-tree by Observation 1. For each tree in Y2 however, A created a color violation in some i-tree for i < j. Therefore, for each tree in Y2, by Observation 1, the number of vertices that A recolored is at least c(c−1) − 1 > 2 2 c · n Case 1: Y1 > Y2. Recall that each j-tree in Y1 has only valid (j − 1)-subtrees by the definition of Y1. Therefore, each j-tree in Y1 can be made valid again by performing a color assignment on it while performing no update. In this way, we obtain Y0 + Y1 > Tj 2 valid j-trees, i.e., Fj becomes a valid j-configuration contained in Fk. Notice that when a color assignment is performed on a j-tree, vertex recolorings previously performed on its (j − 1)-children cannot be counted again towards invalidating this tree. Since we have a valid j-configuration instead of a valid k-configuration, we "wasted" some edge insertions. We say that the insertion of each edge in Fk that is not an edge of Fj is a wasted edge insertion. By Lemma 8, to construct Fk from Fj we used Θ(Tj) edge insertions. That is, Θ(Tj) edge insertions became wasted. However, while we wasted Θ(Tj) edge insertions, we also forced A to perform c(c−1) . Ω(Y1·n c(c−1) ) vertex recolorings per wasted edge insertion. Finally, we Therefore, we can charge A with Ω(n remove each edge corresponding to a wasted edge insertion, i.e., we remove all the edges used to construct Fk from Fj. Since we assumed that A performs no recoloring on edge deletions, we are left with a valid j-configuration Fj. c(c−1) ) vertex recolorings. Since 1 ≤ j < k ≤ c−1, we know that n c(c−1) ) = Ω(Tj·n c(c−1) ≥ n 2(c−j) 2(c−j) 2 2(c−j) 2 2(c−j+1) = 4c · n Case 2: Y2 > Y1. In this case Y2 > Tj 2(c−j) c(c−1) , we conclude that A was charged Ω(n 4 . Recall that Fj−1 is a valid (j − 1)-configuration by our choice of j. In this case, we say that the insertion of each edge in Fk that is not an edge of Fj−1 is a wasted edge insertion. By Lemma 8, we constructed Fk from Fj−1 using Θ(Tj−1) wasted edge insertions. However, 2(c−j+1) c(c−1) ) while we wasted Θ(Tj−1) edge insertions, we also forced A to perform Ω(Y2· n 2(c−j+1) vertex recolorings. That is, we can charge A with Ω( Tj c(c−1) ) vertex recolorings per wasted edge insertions. Since Tj−1 c(c−1) ) vertex recolorings per Tj wasted edge insertion. Finally, we remove each edge corresponding to a wasted edge insertion, i.e., we go back to the valid (j − 1)-configuration Fj−1 as before. Regardless of the case, we know that during a reset consisting of a sequence of h wasted edge insertions, c(c−1) ) vertices. Notice that each edge insertion is counted we charged A with the recoloring of Ω(h · n as wasted at most once as the edge that it corresponds to is deleted during the reset phase. A vertex recoloring may be counted more than once. However, a vertex recoloring on a vertex v can count towards invalidating any of the trees it belongs to. Recall though that v belongs to at most one i-tree for each 0 ≤ i ≤ c. Moreover, two things can happen during a reset phase that count the recoloring of v towards the invalidation of a j-tree containing it: either (1) a color assignment is performed on this j-tree or (2) this j-tree is destroyed by removing its edges corresponding to wasted edge insertions. In the former case, c(c−1) ) = Ω(Tj · n Tj−1 · n 2 2 12 we know that v needs to be recolored again in order to contribute to invalidating this j-tree. In the latter case, the tree is destroyed and hence, the recoloring of v cannot be counted again towards invalidating it. Therefore, the recoloring of a vertex can be counted towards invalidating any j-tree at most c times throughout the entire construction. Since c is assumed to be a constant, we obtain the following result. Lemma 9. After a reset phase in which h edge insertions become wasted, we can charge A with Ω(h · n c(c−1) ) vertex recolorings. Moreover, A will be charged at most O(1) times for each recoloring. 2 After a reset, we consider our new valid j- or (j − 1)-configuration (depending on the above case), and continue our construction trying to reach a c-configuration. 4.5 Constructing a c-tree If A stops triggering resets, then at some point we reach a (c − 1)-configuration. In this section, we describe what happens when constructing a c-configuration from this (c − 1)-configuration. Recall that a color ci is blocked for the root of a k-tree if this root has a child with color ci. Lemma 10. Let Fk be a valid k-configuration. Then colors {c1, c2, . . . , ck−1} are blocked for the root of each valid k-tree in Fk. Proof. Let τ be a valid k-tree in Fk with root r. Recall that τ is also the root of a valid j-tree for each 1 ≤ j < k. Let τj be the j-tree rooted at r. By Lemma 7, we know that τj was assigned color cj. By Observation 2, r has a child of color cj. Therefore, r has color cj blocked. In summary, r has colors {c1, c2, . . . , ck−1} blocked. A valid (c − 1)-configuration Fc−1 consists of at least Tc−1 (4c)c−1 · n1−(cid:80)c−1 Tc−1 = α i=1 2 2(c−i) c(c−1) = O(1). valid (c − 1)-trees, where Therefore, by choosing α sufficiently large, we can guarantee that Fc−1 consists of at least 2(c + 1) valid (c − 1)-trees. Because Fc−1 is valid, half of its (c + 1)-trees are valid, i.e., it consists of at least (c + 1) valid (c − 1)-trees. Because each of these trees has a color assigned to it, among them at least two valid (c − 1)-trees τ and τ(cid:48) have the same color assigned to them. Since Fc−1 is a valid (c − 1)-configuration, Lemma 10 implies that each valid (c − 1)-tree in Fc−1 has colors {c1, . . . , cc−2} blocked. Let cc−1 denote the color assigned to τ and τ(cid:48). Note that the roots of τ and τ(cid:48) have color cc−1 blocked by Observation 2. Moreover, since both τ and τ(cid:48) have colors {c1, . . . , cc−2} blocked, we conclude that their roots have the same color. c(c−1) = 2 valid (c − 1)-trees and add an edge connecting their roots. Since the roots of τ and τ(cid:48) have the same color, A needs to recolor one of them, say r. However, to recolor r with color ci, it must recolor each child of r with color ci. That is, in the core i-tree rooted at r, r ends with no children of color ci. Since this i-tree has color ci assigned to it by Lemma 7, this makes the core i-tree rooted at r invalid and triggers a reset. Therefore, every time we reach a c-configuration we guarantee that a reset is triggered. To construct a c-tree, we consider these 2 · n 2(c−c) Theorem 5. Let c be a constant. For any sufficiently large integers n and α depending only on c, and any m = Ω(n) sufficiently large, there exists a forest F with αn vertices, such that for any recoloring c(c−1) ) vertex recolorings algorithm A, there exists a sequence of m updates that forces A to perform Ω(m· n to maintain a c-coloring of F . Proof. Use the construction described in this section until m updates have been performed. Let m(cid:48) be the number of edge insertions during this sequence of m updates. Notice that m(cid:48) can only be deleted if it was first inserted and we start with a graph having no edges. ≤ m ≥ m/2 as an edge c(c−1) ) vertex recolorings per wasted edge insertion by Lemma 9. Because the graph in our construction consists of at most O(n) edges at all times, at most O(n) of the performed edge insertions are non-wasted. Since every other edge insertion is wasted during a reset, we know that A recolored Ω((m(cid:48) ≥ m/2 and since m = Ω(n), our results follows. During the construction, A can be charged with Ω(n c(c−1) ) vertices. Because m(cid:48) − n) · n 2 2 2 13 5 Conclusion In this paper we introduced the first method for recoloring few vertices so as to maintain a proper coloring of a large graph with theoretical guarantees. These results give rise to a number of open problems. The obvious one being to close the gap between the upper bounds achieved by our algorithms and the lower bound construction. This question is open even for the case of dynamic forests. It is also worth investigating if a similar lower bound construction can give improved lower bounds for graphs with a higher chromatic number. Another thing to note is that our algorithms use the maximum chromatic number. This is undesirable when the graph starts with high chromatic number, but after a number of operations has far lower chromatic number, for example because a number of edges of a large clique are deleted. In this case, an upper bound on the number of colors and recolorings that uses the current chromatic number instead of the maximum would be better. Finally, there are a number of different models to consider. For example, can we improve the algorithms when we support only a subset of the operations, such as only vertex insertion? A number of operations can be simulated using the other operations (for example, vertex removal can be effectively achieved by removing all edges to the vertex and ignoring it in the rest of the execution), however this changes the number of operations we execute, possibly allowing fewer recolorings per operation. Similarly, it is interesting to see what happens when we allow different operations, such as edge flips on triangulations or edge slides for trees? References [1] L. Barba, J. Cardinal, M. Korman, S. Langerman, A. van Renssen, M. Roeloffzen, and S. Verdonschot. Dynamic graph coloring. In 15th Alg. Data Structures Symp., volume 10389 of Lecture Notes in Comput. Sci., pages 97–108, 2017. [2] S. Baswana, M. Gupta, and S. Sen. Fully dynamic maximal matching in O(log n) update time. SIAM J. on Comp., 44(1):88–113, 2015. [3] S. Baswana, S. Khurana, and S. Sarkar. Fully dynamic randomized algorithms for graph spanners. ACM Trans. on Alg., 8(4):35, 2012. [4] J. L. Bentley and J. B. Saxe. Decomposable searching problems I: static-to-dynamic transformation. J. Alg., 1(4):301–358, 1980. [5] P. Borowiecki and E. Sidorowicz. Dynamic coloring of graphs. Fundamenta Informaticae, 114(2):105– 128, 2012. [6] O. Coudert. Exact coloring of real-life graphs is easy. In Proc. 34th Design Autom. Conf., pages 121–126. ACM, 1997. [7] C. Demetrescu, D. Eppstein, Z. Galil, and G. F. Italiano. Dynamic graph algorithms. In M. J. Atallah and M. Blanton, editors, Algorithms and Theory of Computation Handbook. Chapman & Hall/CRC, 2010. [8] C. Demetrescu, I. Finocchi, and P. Italiano. Dynamic graphs. In D. Mehta and S. Sahni, editors, Handbook on Data Structures and Applications, Computer and Information Science. CRC Press, 2005. [9] A. Dutot, F. Guinand, D. Olivier, and Y. Pign´e. On the decentralized dynamic graph-coloring problem. In Proc. Worksh. Compl. Sys. and Self-Org. Mod., 2007. [10] M. M. Halld´orsson. Parallel and on-line graph coloring. J. Alg., 23(2):265–280, 1997. [11] M. M. Halldrsson and M. Szegedy. Lower bounds for on-line graph coloring. Theo. Comp. Sci., 130(1):163 – 174, 1994. [12] M. Henzinger, S. Krinninger, and D. Nanongkai. A subquadratic-time algorithm for decremental single-source shortest paths. In Proc. 25th ACM-SIAM Symp. on Discr. Alg., pages 1053–1072, 2014. 14 [13] J. Holm, K. De Lichtenberg, and M. Thorup. Poly-logarithmic deterministic fully-dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and biconnectivity. J. ACM, 48(4):723–760, 2001. [14] B. M. Kapron, V. King, and B. Mountjoy. Dynamic graph connectivity in polylogarithmic worst case time. In Proc. 24th ACM-SIAM Symp. on Discr. Alg., pages 1131–1142, 2013. [15] R. M. Karp. Reducibility among combinatorial problems. In Complexity of computer computations, pages 85–103. Plenum, New York, 1972. [16] L. Lov´asz, M. E. Saks, and W. T. Trotter. An on-line graph coloring algorithm with sublinear performance ratio. Discr. Math., 75(1-3):319–325, 1989. [17] M. V. Marathe, H. Breu, H. B. Hunt, III, S. S. Ravi, and D. J. Rosenkrantz. Simple heuristics for unit disk graphs. Networks, 25(2):59–68, 1995. [18] L. Ouerfelli and H. Bouziri. Greedy algorithms for dynamic graph coloring. In Proc. Int. Conf. on Comm., Comp. and Control App., pages 1–5, 2011. [19] M. H. Overmars and J. van Leeuwen. Worst-case optimal insertion and deletion methods for decomposable searching problems. Inf. Process. Lett., 12(4):168–173, 1981. [20] D. Preuveneers and Y. Berbers. ACODYGRA: an agent algorithm for coloring dynamic graphs. In Symb. Num. Alg. Sci. Comp., pages 381–390, 2004. [21] L. Roditty and U. Zwick. Improved dynamic reachability algorithms for directed graphs. In Proc. 43rd IEEE Sym. Found. Comp. Sci., pages 679–688, 2002. [22] L. Roditty and U. Zwick. Dynamic approximate all-pairs shortest paths in undirected graphs. In Proc. 45th IEEE Sym. Found. Comp. Sci., pages 499–508, 2004. [23] J. B. Saxe and J. L. Bentley. Transforming static data structures to dynamic structures (abridged version). In Proc. 20th Symp. Found. Comp. Sci., pages 148–168, 1979. [24] M. Thorup. Fully-dynamic min-cut. Combinatorica, 27(1):91–127, 2007. [25] S. Vishwanathan. Randomized online graph coloring. J. Alg., 13(4):657–669, 1992. [26] D. Zuckerman. Linear degree extractors and the inapproximability of max clique and chromatic number. Theory Comp., 3:103–128, 2007. 15
1203.3415
5
1203
2013-04-19T03:03:37
acc-Motif Detection Tool
[ "cs.DS" ]
Network motif algorithms have been a topic of research mainly after the 2002-seminal paper from Milo \emph{et al}, that provided motifs as a way to uncover the basic building blocks of most networks. In Bioinformatics, motifs have been mainly applied in the field of gene regulation networks. This paper proposes new algorithms to exactly count isomorphic pattern motifs of sizes 3, 4 and 5 in directed graphs. Let $G(V,E)$ be a directed graph with $m=|E|$. We describe an $O({m\sqrt{m}})$ time complexity algorithm to count isomorphic patterns of size 3. In order to count isomorphic patterns of size 4, we propose an $O(m^2)$ algorithm. To count patterns with 5 vertices, the algorithm is $O(m^2n)$. The new algorithms were implemented and compared with FANMOD and Kavosh motif detection tools. The experiments show that our algorithms are expressively faster than FANMOD and Kavosh's. We also let our motif-detecting tool available in the Internet.
cs.DS
cs
acc-Motif Detection Tool L. A. A. Meira V. R. M´aximo Faculty of Technology, Institute of Science and Technology, University of Campinas, Federal University of Sao Paulo, Sao Pauo, Brazil Sao Pauo, Brazil A. L. Fazenda A. F. da Concei¸cao Institute of Science and Technology, Institute of Science and Technology, Federal University of Sao Paulo, Federal University of Sao Paulo, Sao Pauo, Brazil Sao Pauo, Brazil November 10, 2018 Abstract Background: Network motif algorithms have been a topic of research mainly after the 2002-seminal paper from Milo et al, that provided motifs as a way to uncover the basic building blocks of most networks. In Bioin- formatics, motifs have been mainly applied in the field of gene regulation networks field. Results: This paper proposes new algorithms to exactly count iso- morphic pattern motifs of sizes 3, 4 and 5 in directed graphs. Let G(V, E) be a directed graph with m = E. We describe an O(m√m) time complexity algorithm to count isomorphic patterns of size 3. In order to count isomorphic patterns of size 4, we propose an O(m2) algorithm. To count patterns with 5 vertices, the algorithm is O(m2n). Conclusion: The new algorithms were implemented and compared with FANMOD and Kavosh motif detection tools. The experiments show that our algorithms are expressively faster than FANMOD and Kavosh's. We also let our motif-detecting tool available in the Internet. keywords: network motifs, complex networks, algorithm design and analysis, counting motifs, detecting motifs, motifs, discovery, motif iso- morphism. 1 Background Network Motifs, or simply motifs, correspond to small patterns that recurrently appear in a complex network [2]. They can be considered as the basic building blocks of complex networks and their understanding may be of interest in sev- 1 eral areas, such as Bioinformatics [10, 12], Communication [25], and Software Engineering [11]. Finding network motifs has been a matter of attention mainly after the 2002-seminal paper from Milo et al. [16], that proposed motifs as a way to uncover the structural design of complex networks. Nowadays, the design of efficient algorithms for network motif discovery is an up-to-date research area. Several surveys about motif detection algorithms were published in recent years [6, 21, 24]. 1.1 Problem statement This paper formally addresses the following three problems: Problem 1.1 (Motifs-3) Given a directed graph G(V, E), the problem Motifs- 3 consists in counting the number of connected induced subgraphs of G of size 3 grouped by the 13 isomorphic distinct graphs of size 3. Problem 1.2 (Motifs-4) Given a directed graph G(V, E), the problem Motifs- 4 consists in counting the number of connected induced subgraphs of G of size 4 grouped by the 199 isomorphic distinct graphs of size 4. Problem 1.3 (Motifs-5) Given a directed graph G(V, E), the problem Motifs- 5 consists in counting the number of connected induced subgraphs of G of size 5 grouped by the 9364 isomorphic distinct graphs of size 5. 1.2 Related work and tools The algorithms for motif detection can be based on two main approaches: ex- act counting or heuristic sampling. As these names might suggest, the for- mer approach performs a precise count of the isomorphic pattern frequency. The latter uses statistics to estimate frequency value. Several exact search- based algorithms and tools can be found in the literature, such as MAVisto [22], NeMoFinder [4], Kavosh [8] and Grochow and Kellis [7]. Examples of sampling- based algorithms are MFinder [9, 17], FANMOD [23] and MODA [19]. In 2010, Marcus and Shavitt [13, 14] provided an exactly algorithm O(m2) to count network motifs of size 4 in undirected graphs. In Section 2.4, Figure 3 shows the only six connected isomorphic patterns with 4 vertices, that can be labeled as: tailed triangle, 4-cycle, 4-cycle with chord, 4-clique, 4-path and Claw. In fact, the paper provided six independent algorithms; each one devoted to count an undirected isomorphic pattern. Some ideas of Marcus and Shavitt are present in our approach. However, this paper provides a solution to directed graph cases. Furthermore, this work also solves 5-sized motifs. A short version of this paper of this work appears in [15]. 1.3 Our approach: combinatorial acceleration This paper presents faster exact algorithms to Motif-3, Motif-4 and Motif-5 problems. Basically, two main techniques are applied to improve computational 2 complexity: first, our algorithm compute the number of isomorphic patterns instead of listing induced subgraphs; second, our method does not actually check isomorphism. The algorithms associate an integer variable with each isomorphic pattern and increment it directly. Our algorithm was evaluated on transcription of biological networks (bacte- ria E. coli and the yeast S. cerevisiae) and public dataset networks with up to 13,000 vertices and 100,000 edges. The results are summarized on Tables 8, 9 and 10. Such tables show a significant improvement in performance for Motif- 3, Motif-4 and Motif-5. The acc-Motif was able to solve instances considered unfeasible in the current programs, which takes several days to be solved even in probabilistic models. We believe that the technique can be extended for detecting motifs of higher sizes. The program was implemented in Java and it is made available as freeware in http://www.ft.unicamp.br/∼meira/accmotifs. 1.4 Paper organization The remaining of this paper is organized as follows: Section 2 describes the implemented algorithms; Section 2.1 depicts the notation used, Section 2.2 in- troduces the new approach starting by the simple case of counting isomorphic patterns of size 3, and Sections 2.4 and 2.5 show the method applied to count- ing isomorphic patterns of size 4 in undirected and directed graphs, respectively. Subsections 2.6 and 2.7 are dedicated to count isomorphic patterns of size 5. Section 3 presents the computational results, in comparison to other well-known tools available. Finally, Section 4 presents the conclusion and our view of future work. 2 Implementation The existing exact algorithms to find network motifs are generally extremely costly in terms of CPU time and memory consumption, and present restrictions on the size of motifs [8]. According to Cirielo and Guerra [6], motif algorithms typically consist of three steps: (i) listing connected subgraphs of k vertices in the original graph and in a set of randomized graphs; (ii) grouping them into isomorphic classes; and (iii) determining the statistical significance of isomorphic subgraph classes by comparing their frequencies to those of an ensemble of random graphs. The core of this paper focuses on items (i) and (ii). Section 2.1 presents the notation in use. Section 2.2 describes the algorithm to Motif-3 problem. Sections 2.4 and 2.5 describe the algorithm to Motif-4 problem. Sections 2.6 and 2.7 describe the algorithm to Motif-5 problem. 3 2.1 Notation and definitions Let G(V, E) be a directed graph with n = V vertices and m = E edges. Assuming that m ≥ n− 1. If (u, v) ∈ E and (v, u) ∈ E, we say it is a bidirected edge. Alternatively, if only (u, v) ∈ E, we say it is a directed edge. Given a vertex v ∈ V , we partitioned the neighbors of v in three disjoint sets: δ∗(v), δ+(v) and δ−(v), as follows: δ∗(v), δ+(v), δ−(v), u ∈   if (u, v) ∈ E and (v, u) ∈ E if (v, u) ∈ E and (u, v) 6∈ E if (u, v) ∈ E and (v, u) 6∈ E It means that δ∗(v) are the vertices with a bidirected edge to v. The vertices with edges directed from v are in δ+(v) and the vertices with edges directed to v are in δ−(v). Sometimes, for convenience, we consider an undirected version of G(V, E) called G∗(V, E∗) where {u, v} ∈ E∗ if and only if (u, v) ∈ E or (v, u) ∈ E, or both. Therefore, we replace directed or bidirected edges of G by a single undirected edge in G∗. Let us define δ(v) as the neighbors of v, thus u ∈ δ(v) if and only if {u, v} ∈ E∗. Note that δ(v) = δ∗(v) ∪ δ+(v) ∪ δ−(v). Given two disjoint sets A ⊆ V and B ⊆ V , we define δ∗(A, B) as the set of bidirected edges between the sets A and B and δ+(A, B) as the directed edges from A to B. We also define δ∗(A, A) for a single set A as the bidirected edges (u, v) with u ∈ A and v ∈ A and δ+(A, A) as directed edges with u ∈ A and v ∈ A. We define the adjacency of a set of vertices V ′ ⊆ V as adj(V ′) = {∪v∈V ′ δ(v)} \ V ′. 2.2 Counting isomorphic patterns of size 3 To simplify notation usage, Table 1 defines a set of auxiliary variables related to a vertex v. The symbol Av = δ∗(v) represents the set of bidirected neighbors of v, Bv = δ+(v) is the set of directed neighbors from v, and Cv = δ−(v) is the set of directed neighbors to v. The sets Av, Bv and Cv define a partition of vertices in v adjacency. For simplicity of notation, if the vertex v is clear the superscript of v can be removed. The number of bidirected neighbors of v is given by nv a. The number of a,b. The notation m′ is used to represent the a,b is the number of bidirected edges directed edges from Av to Bv is mv number of bidirected edges, for example, m′v between A and B and m′ The algorithm to count 3-sized motifs is derived from Theorem 2.2. However, in order to provide it with a better understanding, the following definition is needed: aa is the number of bidirected edges inside Av. Definition 2.1 (v-Patterns) Given a directed graph G(V, E), we define v-Patterns, for any v ∈ V , as a set of induced subgraphs with three vertices, 4 {v, x, y}, where x and y are in δ(v), which means all induced subgraphs with the vertex v and more two vertices in its adjacency. The same definition is valid for the case of undirected graph. To illustrate the combinatorial optimization technique used in this paper, let us start by analyzing a simple case. Consider a star graph GS(V S, ES) with center vc and neighbors Avc , Bvc and Cvc as described in Figure 1. Frequency a nvc nvc a nvc nvc nvc b nvc (cid:18)nvc 2 (cid:19) (cid:18)nvc 2 (cid:19) (cid:18)nvc 2 (cid:19) Pattern o ↔ o → o o ↔ o ← o o → o → o o ↔ o ↔ o o ← o → o o → o ← o Avc Bvc Cvc b c c vc a b c Figure 1: Star graph and its sets. Isomorphic pattern frequencies ont the right. A naive algorithm to motif counting will compute all vertices in δ(vc) com- bined two by two. We argue that it is possible to compute the isomorphic patterns in GS in constant time O(1), since we have precomputed the auxiliary variables of Table 1. Figure 1 brings an insight about how our algorithm works. It shows, in a simple example, that it is possible to count isomorphic patterns without explicit listing all of them. The right side of the figure depicts all possible patterns and occurrence frequencies in the star graph GS. It is possible to achieve, for instance, a number of exactly nvc b occurrences of pattern "o ↔ o → o", which means a pattern with a center vertex linked to the left neighbor vertex by a bidirected edge and linked to the right neighbor by an edge directed to it. The algorithm to count isomorphic patterns in a general graph derives from a nvc the following theorem. Theorem 2.2 Let G(V, E) be a general graph and v any vertex in V . The patterns occurrences in set v-Patterns are given by Table 2. Proof. This theorem is proved by induction. Observe that the v-Patterns set con- siders the patterns containing v and two vertices in δ(v). Let G′(E′, V ′) be the graph G induced by v ∪ δ(v). The basic case is if the G′ is a star graph. In this case, the v-Patterns frequencies are equal to Figure 1 on the right. Table 2 corresponds to it if all mv variables are zero, which is the case in G′. 5 The number of pattern "o → o → o" in the original G′ is nv Suppose that a new (x, y) directed edge is added to G′ where x and y are in δ(v). The new graph has edges E′ ∪ (u, v). At this moment, our sole interest is devoted to subgraph patterns that contain the vertex v. c . If the new directed edge (x, y) has x ∈ Cv and y ∈ Bv, one pattern "o → o → o " is removed and a cyclic pattern is added. The added pattern is shown in Table 2, Line 13. If u ∈ A and v ∈ A one pattern "o ↔ o ↔ o" is removed and another is added. The added pattern is shown in Table 2, Line 11. For each edge added in δ(v), one pattern containing v is removed and another pattern containing v is added. b nv A straightforward generalization is observed for an arbitrary number of c,b directed edges are added from Cv to Bv. The c,b occurrences arise added edges. Suppose mv number of "o → o → o" decreases mv from a new one, which can be seen in Table 2, Line 13. c,b units and exactly mv Thus, given a graph G(V, E), for each vertex v ∈ V , it is possible to ob- tain the v-Patterns frequencies using Theorem 2.2. Table 2 shows this pattern frequency (see variable definition in Table 1). If the variables of Table 1 were preprocessed, it is possible to calculate all isomorphic patterns of size 3 containing a vertex v ∈ V and two other neighbors of v in O(1). The pattern containing v, a neighbor of v, and a non-neighbor of v will be ignored by the v-Patterns set. Fortunately, valid patterns involving these vertices could be computed by their center vertex at another moment. Patterns related to C3 will be considered three times each. The pattern C3 is in the v-Patterns set of vertices v1, v2 and v3 in C3. Therefore, a simple correction must be applied. The final counter of C3 related isomorphic patterns must be divided by three to provide the correct value. The Algorithm 1 counts motifs patterns of size 3. In fact, the algorithm does not perform any isomorphic matching. The algorithm creates a vector h with thirteen integers and initializes them with zero. In this vector, the pattern "o ↔ o → o" is arbitrarily associated with h[0], the pattern "o ↔ o ← o" is arbitrarily associated with h[1], "o → o → o" with h[2], and so on. The algorithm computes Table 2 frequencies for each v ∈ V . The frequencies of Table 2 are incremented in vector h directly. The algorithm output is vector h, containing thirteen isomorphic pattern frequencies. The complexity of the algorithm is dominated by Line 2, which computes variables in Table 1. All operations in Algorithm 1, except Line 2, are O(n). The next section shows how to compute Line 2 in O(m√m). 2.3 Preprocessing Table 1 This section argues that, given a directed graph G(V, E), it is possible to com- pute Table 1 sets and variables in O(a(G)m), where a(G) is the arboricity of the undirected version of G. Arboricity was introduced by Nash-Williams [18], 6 Input: Directed graph G(V, E) Output: Histogram to 13 isomorphic patterns to motifs of size 3 1 Create a histogram data structure to count isomorphic patterns 2 Calculate the variables of Table 1 to all vertices. 3 foreach v ∈ V do 4 5 Calculate the number of patterns involving vertex v using frequencies of Table 2. For each pattern, add this frequency counter to histogram. 6 end 7 if The undirected version of the pattern is the cycle graph C3 then 8 Divide the frequency counter by 3 9 end 10 return The histogram. Algorithm 1: Count 3 Sized Patterns Algorithm. the arboricity a(G) of a graph G is the minimum number of forests into which its edges can be partitioned. It is known [5] that a(G) = O(√E) to any graph, so the execution complexity is also O(m√m). First, for each vertex v ∈ V , create three sets Av,Bv, and Cv. Algorithm 2 describes how to compute such variables in O(m). Input: Directed graph G(V, E) Output: Variables Av,Bv, and Cv and nv a, nv b and nv c for all v ∈ V 2 (Av,Bv,Cv) ← (∅,∅,∅) 1 foreach v ∈ V do 3 end 4 foreach bidirected (u, v) ∈ E do Au ← Au ∪ {v} Av ← Av ∪ {u} 5 6 9 7 end 8 foreach directed (u, v) ∈ E do 10 Bu ← Bu ∪ {v} Cv ← Cv ∪ {u} 11 end 12 foreach v ∈ V do 14 end b , nv a, nv (nv 13 c ) ← (Av,Bv,Cv) Algorithm 2: Create {Av,Bv,Cv} variables. Algorithm 3 computes variables {mv c,c}. The complexity is dom- inated by Line 5, the algorithm that lists all triangles in an undirected graph. If Chiba and Nishizek algorithm [5] is used to list all triangles, an O(a(G)m) algorithm is obtained, where a(G) is the arboricity of G. a,a, . . . , m′v It is possible to notice that, in essence, Algorithm 3 is processing all triangles 7 Input: Directed graph G(V, E) Output: Variables {mv a,a, . . . , m′v c,c}. 3 All variables in {mv 1 Let G∗(V, E∗) be the undirected version of G(V, E). 2 foreach v ∈ V do c,c} start with zero. 4 end 5 List all triangles of G∗(V, E∗) and save in variable T 6 foreach triangle (v1, v2, v3) ∈ T do a,a, . . . , m′v 7 Let (v, x, y) ← (v1, v2, v3) If vertices Var to increment if (x, y) ∈ E is bidirect Var to increment If (x, y) ∈ E is direct a,a m′v a,a b,a c,a m′v m′v m′v a,b and m′v a,c and m′v b,a and m′v x ∈ Av and y ∈ Av x ∈ Av and y ∈ Bv x ∈ Av and y ∈ Cv x ∈ Bv and y ∈ Av x ∈ Bv and y ∈ Bv x ∈ Bv and y ∈ Cv x ∈ Cv and y ∈ Av x ∈ Cv and y ∈ Bv x ∈ Cv and y ∈ Cv Do the same to (v, x, y) ← (v2, v1, v3) and to (v, x, y) ← (v3, v1, v2) mv mv mv mv mv mv mv mv c,b m′v c,c b,c and m′v c,a and m′v c,b and m′v m′v m′v m′v m′v b,b m′v c,c b,b b,c a,b a,c a,b c,b a,c b,c c,a b,a 8 9 end Algorithm 3: Create {mv a,a, . . . , m′v c,c} variables. in G(V, E). Each increment in mv a,b is an operation in a triangle containing v and two connected neighbors. We remark the existence of more straightforward implementations of Algorithm 3, but the use of Chiba and Nishizek algorithm [5] to list all triangles as a subroutine simplifies the complexity analysis. Thus, it is possible to conclude that the Algorithm 1, which solves the Motifs- 3 problem, presents an O(a(G)m) time complexity. The memory used in the algorithm is linear in relation to the memory used to represent G(V,E). 2.4 Counting isomorphic patterns of size 4 in undirected graphs To show our solution of Motif-4 problem, let us start with an undirected version of the problem. The directed case involves more details and will be considered in Section 2.5. Similarly to the previous section, the following definition needs to be known beforehand: Definition 2.3 (e-Patterns) Given a directed graph G(V, E), we define an e-Patterns, for any e ∈ E, as a set of patterns with four vertices, {u, v, v1, v2}, 8 where (u, v) = e and v1 and v2 are in adj({u, v}). The e-Patterns set has pat- terns with the edge e and more two vertices in its adjacency. The same applies to the undirected graph. The approach to count patterns with four vertices is countingt e-Patterns to all e ∈ E. Let us define Z e = δ(u) ∩ δ(v) \ {u, v} as the vertices adjacent to u and v, X e = δ(u) \ (Z e ∪ {v}) as the vertices only in u adjacency, and Y e = δ(v) \ (Z e ∪ {u}) as the vertices only in v adjacency. If the edge e is clear it can be omitted from the superscript. We define ne z as the sizes X e, Y e and Z e, respectively. See Figure 2. The Ck is the cycle graph with k vertices, the Sk is the star graph with a center and k leaves, and the Kk is the complete graph of size k. The Kk \{e} is the complete Kk graph without an arbitrary edge e. The Pk is the path graph with k vertices. y and ne x, ne Z e Pattern P4 x ↔ C3 S3 Frequency nxny (nx + ny)nz v Y e X e u 2 (cid:19) 2 (cid:19) +(cid:18)ny (cid:18)nx 2 (cid:19) (cid:18)nz Figure 2: Sets associated with e = {u, v} and e-Patterns frequency of the graph on the left. K4 \ {e} The algorithm to count isomorphic patterns derives from the following the- orem. Theorem 2.4 Let G(V, E) be a general undirected graph and e = {u, v} any edge in E. The patterns occurrences in set e-Patterns is given by Table 3. Proof. This theorem is also proved by induction in the number of edges. Let G′ be the graph G induced by {u, v}∪ adj({u, v}). The basic case is if G′ is the graph in Figure 2. In this case, the e-Patterns frequencies are equal to Figure 2 on the right. Table 3 corresponds to it if all me variables are zero, which is true for the graph at issue. If one edge e′ is added into X e, one e-Patterns S3 has to be replaced by one e-Patterns x ↔ C3. The same applies to Y e. If one edge is added to Z e, one e-Patterns K4 \ {e} has to be replaced by one e-Patterns K4. If one edge is added between X e and Y e, one e-Patterns P4 needs to be removed and one e-Patterns C4 must be added. If one edge is added between X e or Y e to Z e, one e-Patterns x ↔ C3 has to be deleted and one e-Patterns K4 \ {e} must be added. Let me x,y be the number of edges between sets X e and Y e. Similarly 9 Figure 3: Patterns and its edges. The pattern is in e-Patterns of edges in bold. See Definition 2.3. consider variables me x,z, me e-Patterns frequency to e = {u, v}. x,x, me z,z. Thus, Table 3 presents the y,y, me y,z, and me The algorithm to count isomorphic patterns of size four will sum up the e-Patterns frequencies for all e ∈ E. Similarly to Section 2.2, the pattern containing {u, v}, a neighbor of u or v and a non-neighbor of u and v is not considered in e-Patterns set. It applies to pattern P4 and a non-central edge and pattern x ↔ C3 and one edge in C3. Fortunately, these patterns will be considered later for other edges. An induced subgraph pattern can be considered in distinct e-Patterns sets. So, the final histogram needs a small correction. If a pattern appears at the e-Patterns set for a of its edges, the number of occurrences in the final histogram must be divided by a. The following fact describe this situation. Fact 2.5 Based on Definition 2.3 and Figure 3, the C4 patterns are considered by four edges. It is in e-Patterns for each of its four edges. The P4 is in the e-Patterns set only for the central edge. The S3 is in e-Patterns for each of its three edges. The tailed triangle is in e-Patterns in three of its four edges. The K4 \ {e} is in e-Patterns for each of its five edges and K4 is in e-Patterns in each of its six edges. The Algorithm 4 counts 4-sized subgraphs grouped by isomorphic patterns. The complexity is dominated by Line 3, the time to calculate the needed vari- ables. All other steps are O(m). As in the previous section, there is no isomorphism detecting algorithm. The histogram is represented by a vector h with 6 positions. The algorithm associates each pattern with an arbitrary hard coded position in the vector. For instance, patterns (P4, x ↔ C3, S3, C4, K4 \ {e}, K4) may be related with (h[0], h[1], h[2], h[3], h[4], h[5]), respectively. To sum the e-Patterns occurrences for a specific e ∈ E it is sufficient to update the integer variables in the vector h using Table 3 rule. The algorithm output is the histogram vector containing pattern frequencies. The Algorithm 5 computes the needed variables, according to Line 3 of Algorithm 4. The algorithm has an O(m) complexity for each e ∈ E. The 10 Input: Undirected graph G(V, E) Output: Histogram to 6 isomorphic patterns to motifs of size 4 1 Create a histogram to count isomorphic patterns 2 foreach e ∈ E do 3 4 5 Calculate variables ne Calculate the frequency of e-Patterns using Table 3. For each pattern, add its frequency counter to histogram. x,x, me x,y, me z, me x,z, me y,y, me x, ne y, ne y,z, me z,z. 6 end 7 if The histogram pattern is (See Fact 2.5.): 8 9 x ↔ C3 or S3: Divide the frequency counter by 3 C4: Divide the frequency counter by 4 10 K4 \ {e}: Divide the frequency counter by 5 11 K4: Divide the frequency counter by 6 12 return The histogram. Algorithm 4: Count 4 Sized Patterns Algorithm. x, ne y and ne variables ne z are simpler so their calculus was omitted. Note that checking whether x ∈ Z e for an arbitrary vertex x ∈ V and edge e = {u, v} is equivalent to checking whether (x, u) ∈ E and (x, v) ∈ E, and can be performed in O(1). Checking whether x ∈ X e and x ∈ Y e is a similar procedure. Input: Undirected graph G(V, E) and an edges e ∈ E Output: Variables {me x,x, . . . , me z,z}. x,x, . . . , me z,z} start with zero. Var to increment 1 All variables in {me 2 foreach (x, y) ∈ E do If vertices x ∈ X e and y ∈ X e x ∈ X e and y ∈ Y e x ∈ X e and y ∈ Z e x ∈ Y e and y ∈ Y e x ∈ Y e and y ∈ Z e x ∈ Z e and y ∈ Z e 3 x,x me me me me me me x,y x,z y,y y,z z,z 4 end 5 return The computed variables. Algorithm 5: Create {me x,x, . . . , me z,z} variables for a given e ∈ E. We can conclude that Algorithm 4 counts 4-sized subgraphs grouped by isomorphic patterns in O(m2) in an undirected graph G(V, E). Moreover, the additional memory to store the variables is Θ(m) 11 2.5 Counting isomorphic patterns of size 4 in directed graphs No new concept is needed to extend the previous algorithm to the directed version. However, a large number of sets and variables have to be dealt with. Variables and sets related to an edge e are presented next. Considering an edge e = (u, v), it is possible to define 15 sets associated with it. 1, Be 1 , Ae 2, Be 1, C e 2, C e T e = {Ae 2 , AAe, ABe, AC e, BAe, BBe, BC e, CAe, CBe, CC e} defined as follows (see Figure 4): AAe ← Au ∩ Av, ABe ← Au ∩ Bv, AC e ← Au ∩ Cv, BAe ← Bu ∩ Av, BBe ← Bu ∩ Bv, BC e ← Bu ∩ Cv, CAe ← Cu ∩ Av, CBe ← Cu ∩ Bv, and CC e ← Cu ∩ Cv. AB AC AA BA A1 B1 C1 BB u v BC CA CB A2 B2 C2 CC Figure 4: Fifteen sets associated with an edge e = (u, v). We also have sets Ae 1 ← Au \ (δ(v)∪{v}), Be 1 ← Bu \ (δ(v)∪{v}) and C e 2 ← Av\(δ(u)∪{u}), Be Cu\(δ(v)∪{v}). Finally, we have Ae and C e 2 ← Cv \ (δ(u) ∪ {u}). 1 belongs to an outside edge from u, a vertex v2 ∈ C e 1 ← 2 ← Bv\(δ(u)∪{u}) The sets in T e make a partition of e adjacency. For instance, a vertex in v1 ∈ Be 2 belongs to an inside edge to v. A vertex in v3 ∈ ABe belongs to a bidirected edge to u and an outside edge from v. T as T. Given two sets Ti, Tj ∈ T , we define me Ti,Tj as the number of bidirected edges between Ti and Tj. In other words, for all Ti,Tj ← δ∗(Ti, Tj). Thus, if Ti = AAe Ti, Tj ∈ T e, me AA,AA is the number of directed edges inside AAe. If and Tj = AAe then me Ti = Ae A1,A2 is the number of bidirected edges between Ae as the number of directed edges from Ti to Tj and m′e Given a set T ∈ T e, we define ne Ti,Tj ← δ+(Ti, Tj) and m′e Ti,Tj 1 and Tj = Ae 2, then m′e 1 and Be 2. Preprocessing these variables is the core technique used to accelerate our algorithm. The variables are processed only once, then they are used to infer the occurrence of motifs. 12 Consider an edge e = (u, v) and its neighbor sets; for each e ∈ E, the algo- rithm will analyze and count the e-Patterns (see Definition 2.3). The patterns containing edge e and a vertex not linked to e are ignored by the e-Patterns set. Fortunately, all patterns are considered at least by one of its edges, as discussed in Figure 3. Patterns that are considered in more than one e-Patterns must to be corrected at the end of the algorithm as in the undirected case. Consider a simple graph G′ as G(V, E) induced in {u, v}∪ δ(u)∪ δ(v). Con- sider no edges between δ(u) and δ(v). This graph is similar to Figure 4. Note that the set e-Patterns contains vertices {u, v} plus two vertices {v1, v2} in δ(u) ∪ δ(v). Assume that (u, v) is bidirected. To discover the pattern associated with {u, v, v1, v2}, it is sufficient to know which sets in T e are associated with v1 and v2. For instance, if v1 ∈ A1 and v2 ∈ A1, the associated pattern is S3. If v1 ∈ AAe and v2 ∈ AAe, the associated pattern is K4 \ {e}. Let pattern(Ti, Tj) for all Ti, Tj ∈ T e be the pattern related to {u, v, v1, v2}, where e = (u, v) and v1 ∈ Ti and v2 ∈ Tj. The pattern(Ti, Tj) for all Ti and Tj is shown in Table 4. The algorithm requires the following fact: Fact 2.6 Let G′ be any graph containing a bidirected edge e = (u, v) more vertices in (u, v) adjacency. Assume there are no edges in δ(u) ∪ δ(v). If it is considered a pattern {u, v, v1, v2}, where v1, v2 belong to the same set T ∈ T e, there are (cid:0)nT 2 (cid:1) occurrences of pattern(T, T ). If v1 ∈ Ti and v2 ∈ Tj for distinct Ti, Tj ∈ T e, there are nTi nTj occurrences of pattern(Ti, Tj). More formally, the frequency of pattern P , f req(P ), containing {u, v} in G′ is X 2 (cid:19) + (cid:18)nT Ti,Tj ∈T e:i<j,P =pattern(Ti,Tj ) T ∈T e:pattern(T,T )=P nTi nTj . f req(P ) = X It is necessary to define variations of matrix pattern(Ti, Tj). If a directed edge (v1, v2) is added in (u, v) adjacency, where v1 ∈ Ti and v2 ∈ Tj, one pattern is removed and one pattern is created. The removed pattern is defined as pattern(Ti, Tj) and the created pattern is defined as pattern→(Ti, Tj). If edge (v1, v2) is bidirected, the created pattern is defined as pattern↔(Ti, Tj). If v1 ∈ Tj and v2 ∈ Ti, the created pattern is pattern←(Ti, Tj). Figure 5 shows the patterns created when an edge is added between Ti = Ae 1 and Tj = AA. There is a straightforward generalization to other possibilities of Ti and Tj. The following theorem is used by the algorithm. Theorem 2.7 Let G(V, E) be a general directed graph and e = (u, v) a bidi- rected edge in E. The patterns occurrences in set e-Patterns is given by the following sum: Start all frequency patterns as zero. foreach T ∈ T e do Increase pattern(T, T ) occurrence by (cid:0)nT Increase pattern↔(T, T ) occurrence by m′ T,T Increase pattern→(T, T ) occurrence by mT,T 2 (cid:1) − mT,T − m′ T,T 13 Table 4 (Ae pattern(Ae pattern→(Ae pattern←(Ae pattern↔(Ae 1, AAe) v2 1, AAe) v2 1, AAe) v2 v1 u v1 u v1 u 1, AAe) v2 1, AAe) v2 v1 u v1 u v v v v v Figure 5: Variations of matrix pattern(Ti, Tj) for Ti = Ae 1 and Tj = AAe. Increase pattern(Ti, Tj) occurrence by nTi nTj − m′ end foreach Ti, Tj ∈ T e, i < j do Increase pattern↔(Ti, Tj) occurrence by m′ Ti,Tj Increase pattern→(Ti, Tj) occurrence by mTi,Tj Increase pattern←(Ti, Tj) occurrence by mTj ,Ti end Ti,Tj − mTi,Tj − mTj ,Ti Proof. This theorem is also proved by induction in the number of edges. Let G′ be the graph G induced by {u, v}∪adj({u, v}). Suppose that (u, v) is bidirected. The basic case is if G′ does not contain edge in adj({u, v}). In this case, the e-Patterns frequencies are given, by construction, by Fact 2.6. The proposed sum is equal to Fact 2.6 if all me variables are zero, which is the case for the graph at issue. If one directed edge (v1, v2) is added into T ∈ T e, one occurrence of pattern(T, T ) is removed and one occurrence of pattern→(T, T ) is added. If one bidirected edge (v1, v2) is added into T ∈ T e, one occurrence of pattern(T, T ) is removed and one occurrence of pattern↔(T, T ) is added. If one directed edge (v1, v2) is added into two distinct sets Ti, Tj ∈ T e, one occurrence of pattern(Ti, Tj) is removed and one occurrence of pattern→(Ti, Tj) If the added edge is (v2, v1), the incremented pattern occurrence is added. is pattern←(Ti, Tj). If (v1, v2) is bidirected, the incremented occurrence is pattern↔(Ti, Tj). replace the bidirected edge (u, v) by a directed one. If the edge e = (u, v) is directed, the pattern associated with {u, v, v1, v2} In this must case, the new patterns for v1 ∈ Ti and v2 ∈ Tj are represented by pattern′(Ti, Tj), pattern′→(Ti, Tj), pattern′←(Ti, Tj), pattern′↔(Ti, Tj) instead of pattern(Ti, Tj), pattern→(Ti, Tj), pattern←(Ti, Tj), pattern↔(Ti, Tj). The results are the same for a directed edge (u, v). and e = Corollary 2.8 Let G(V, E) in set (u, v) a directed edge e-Patterns but using pattern′(Ti, Tj), pattern′→(Ti, Tj), pattern′←(Ti, Tj), pattern′↔(Ti, Tj) instead The patterns occurrences be a general directed can be calculated analogous to Theorem 2.7, in E. graph 14 of pattern(Ti, Tj), pattern→(Ti, Tj), pattern←(Ti, Tj), pattern↔(Ti, Tj) for any Ti, Tj ∈ T e. Algorithm 6 is used to count patterns of size 4 by summing the e-Patterns for all e ∈ E and make a correction if the same induced has been was considered many times. Input: Directed graph G(V, E) Output: Histogram to 199 isomorphic patterns to motifs of size 4 1 Create a histogram to count isomorphic patterns 2 foreach e ∈ E do Calculate the sets X e for all X e ∈ T e. Calculate the variables mx,y and m′ x,y for all X e, Y e ∈ T e. Calculate the frequency involving e and two neighbors using Lemma 2.7 or Corollary 2.8. For each pattern, add this frequency counter to histogram. 3 4 5 6 7 8 end 9 if the the pattern is related to: 10 11 x ↔ C3 or S3: Divide the frequency counter by 3 C4: Divide the frequency counter by 4 12 K4 \ {e}: Divide the frequency counter by 5 13 K4: Divide the frequency counter by 6 14 return The histogram. Algorithm 6: Count 4 Sized Patterns Algorithm. As in the undirected case, no isomorphism-detecting processing is used. The resultant histogram is represented by a vector of integers h with 199 position, one for each distinct isomorphic pattern of size 4. It is necessary to preprocess matrices pattern(, ), pattern→(, ), etc., associating each pattern with an arbi- trary position in h. For instance, it is possible to set the pattern(A1, A2) to h[0]. The pattern(A1, A1) and pattern(A2, A2) are isomorphic so they can both be associated with h[1]. As a final result, each pattern in the matrices must be hard coded in association with a position in the vector h of the histogram, which will be the program output. The complexity of the algorithm is dominated by lines 3 and 4, since all other lines are O(m). We argue that an algorithm similar to Algorithm 5 in Section 2.4, can calculate the needed variables in O(m2). Thus, it is possible to conclude that the proposed algorithm is an O(m2) algorithm to calculate motifs of size 4 in a directed graph. 2.6 Counting 5-sized patterns in undirected graphs In this section the strategy is extended to motifs of size 5. The following defi- nition is required: 15 Definition 2.9 (P3-Patterns) Let P3 be the path graph with three vertices p1, p2, p3 ∈ V . Given an undirected graph G(V, E), we define a P3-Patterns for any P3 induced in G(V, E) as a set of patterns with five vertices, {p1, p2, p3, v1, v2}, where v1 and v2 are vertices in adj({p1, p2, p3}). The P3-Patterns set has patterns with an induced P3 plus two vertices in its ad- jacency. Definition 2.10 (K3-Patterns) Let K3 be the clique with vertices p1, p2, p3 ∈ V . Given an undirected graph G(V, E), we define a K3-Patterns for any K3 induced in G(V, E) as a set of patterns with five vertices, {p1, p2, p3, v1, v2}, where v1 and v2 are in adj({p1, p2, p3}). The K3-Patterns set has patterns with an induced K3 plus two vertices in its adjacency. The approach to count patterns with five vertices is to count P3-Patterns and K3-Patterns patterns to all P3 and K3 induced in G(V, E). The time to compute the patterns frequency in P3-Patterns and K3-Patterns sets is O(1), considering some preprocessed variables. The adjacency of K3 and P3 will be partitioned in seven groups. See Figure 6. Let K3 and P3 be composed by (p1, p2, p3) and assume that p2 is the central vertex in the P3 case. Let us define Z = δ(p1) ∩ δ(p2) ∩ δ(p3) \ {p1, p2, p3} as the vertices adjacent to p1, p2 and p3, X1 = δ(p1) \ (δ(p2) ∪ δ(p3)) the vertices only in p1 adjacency, X2 = δ(p2) \ (δ(p1) ∪ δ(p3)) the vertices only in p2 adjacency, and X3 = δ(p3) \ (δ(p1)∪δ(p2)) the vertices only in p3 adjacency. Let Y12 = δ(p1)∩δ(p2)\(Z∪p3) be the vertices only in p1 and p2 adjacency, Y13 = δ(p1)∩ δ(p3)\ (Z ∪ p2) be the vertices only in p1 and p3 adjacency, and Y23 = δ(p2) ∩ δ(p3) \ (Z ∪ p1) be the vertices only in p2 and p3 adjacency. Let Q = {X1, X2, X3, Y12, Y13, Y23, Z}. We define nx1, nx2 and nx3 as the sizes X1, X2 and X3, respectively, ny12 , ny13 and ny23 as the sizes Y12, Y13 and Y23, respectively, and nz as the size of Z. Let mS1,S2 be the number of edges between sets S1 and S2 for all S1, S2 ∈ Q. Table 5 contains the K3-Patterns frequencies for the graph in Figure 6. The algorithm to count isomorphic patterns derives from the following the- orem. Theorem 2.11 Let G(V, E) be a general undirected graph. The pattern occur- rence in set K3-Patterns, for any induced clique (p1, p2, p3), is given by Table 6. For any induced P3 = (p1, p2, p3), the pattern occurrence in P3-Patterns is given by Table 7. Proof. This theorem is similar to theorems 2.2 and 2.4. It is also proved by induction in the number of edges. Consider the K3-Patterns set. To the P3-Patterns set, the proof is the same. Let G′ be the graph G induced by {p1, p2, p3}∪ adj({p1, p2, p3}). The basic case is if G′ has no edges between vertices in the adj({p1, p2, p3}). This graph is similar to the graph in Figure 6. In this case, the K3-Patterns frequency are equal to Table 5. Table 6 corresponds to it if all m variables are zero. 16 X2 p2 Z Y12 Y23 p1 p3 X1 Y13 X3 Figure 6: Sets associated with P3 or K3. {p1, p2, p3} is a K3, otherwise, it is a P3. If the dashed line is considered, Figure 7: The pattern C5 is in P3-Patterns of P3 in bold. It is necessary to divide the final C5 frequency by 5. If one edge e′ is added into X1, one K3-Patterns pattern has to be replaced by another. The removed pattern is in Table 6, Line 1. The pattern added is in Table 6, Line 11. The same applies to other sets in {X1, X2, X3, Y12, Y13, Y23, Z}. If one edge is added in Z, one pattern (Table 6, Line 10) has to be replaced by one K5. If one edge is added between X1 and X3, one pattern needs to be removed (Table 6, Line 2) and other pattern must be added (Table 6, Line 12). Thus, by a straightforward induction in edges in adj({p1, p2, p3}), Table 6 presents the frequency of the set K3-Patterns. The algorithm to count isomorphic patterns of size five will list all K3 and P3 induced in G(V, E) and summing up K3-Patterns and P3-Patterns frequencies for all induced K3 and P3. An induced subgraph pattern can be considered in distinct K3-Patterns and P3-Patterns sets. Thus, the final histogram needs a small correction. If a pattern appears a times as a K3-Patterns or a P3-Patterns, the final histogram result must be divided by a. For instance, it is shown that C5 is considered in 5 distinct P3-Patterns. See Figure 7. The correction analysis needs to be considered for all 5-sized isomorphic patterns. The Algorithm 7 counts subgraph patterns of size 5. In lines 2 and 3, a list of all P3 and K3 induced in G(V, E) is computed. Algorithm 8 does this 17 Input: Undirected graph G(V, E) Output: Histogram to 21 isomorphic patterns to motifs of size 5 1 Create a histogram to count isomorphic patterns 2 List all induced K3 = (p1, p2, p3) and save in K. 3 List all induced P3 = (p1, p2, p3) and save in P. 4 foreach t ∈ K ∪ P do 5 6 7 8 9 10 Calculate the number of edges between S1 and S2, mS1,S2 Calculate sets Q = {X1, X2, X3, Y12, Y13, Y23, Z}. foreach S1, S2 ∈ Q do end Calculate the frequency involving t and two neighbors using tables 6 and 7 . For each pattern, add this frequency to histogram. 11 end 12 foreach pattern in the histogram do 13 Divide the frequency by the constant a, correcting the repetition in several P3-Patterns and K3-Patterns 14 end 15 return The histogram. Algorithm 7: Count 5 Sized Patterns Algorithm. Line 5, of Algorithm 7, task in O(P{u,v}∈E δ(v) +δ(v)). As δ(u) +δ(v) = O(n), the complexity of Algorithm 8 is O(mn). Note that the size of K and P are bounded by Θ(nm). sets Q = {X1, X2, X3, Y12, Y13, Y23, Z} for a single P3 or K3. This cost is domi- nated by δ(p1) + δ(p2) + δ(p3) = O(n). It is a simple intersection of sets procedures and can be efficiently computed using a hash. As in the previous section, no isomorphism detecting algorithm is used. The histogram is represented by a vector h with 21 positions. The algorithm associates each pattern with an arbitrary hard coded position in the vector. calculating consists the Algorithm 9 computes the needed variables, according to Line 7 of Algo- rithm 7. The algorithm has an O(m) complexity for each induced K3 and P3. We can conclude that Algorithm 7 counts isomorphic pattern motifs of size 5 in O(m2n) in an undirected graph G(V, E). Moreover, the additional memory to store the variables is Θ(mn). 2.7 Counting 5-sized patterns in directed graphs Similarly to Section 2.5, no new concept is needed to extend the previous al- gorithm to the directed version. Both algorithms are very similar. The main difference is that the directed case requires dealing with a large number of sets. The neighborhood of (p1, p2, p3) is partitioned in 63 sets. It is necessary to cal- culate how many edges are found between each 2,016 combinations of two such sets. The histogram vector has 9,364 positions, one for each distinct isomorphic 18 Input: Undirected graph G(V, E) Output: The set P of all induced P3 and K of all induced K3 in G(V, E). 1 Set P ← ∅, K ← ∅. 2 foreach e = {u, v} ∈ E do foreach x ∈ adj({u, v}) do P ← P ∪ {(x, u, v)} 3 4 5 6 7 8 9 if (x,u,v) is a P3 and (x,u,v) is not considered yet then end if (x,u,v) is a K3 and (x,u,v) is not considered yet then K ← K ∪ {(x, u, v)} end 10 end 11 end 12 return K and PAlgorithm 8: List all induced P3 and K3. pattern. Regardless of such difficulty, the algorithm deal with sets. The number of sets or set combinations in the neighborhood of (p1, p2, p3) is always O(1). The following definitions are required: Definition 2.12 Let R be a set of all isomorphic patterns of size 3. The set R contains thirteen elements: R =   p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p3 , p2 p1 p3 , p2 p1 p3 , p2 p1 p3 , p2 p1 p3 , p3 , p3 , p3 , p3 p1 , p2 p3 p3   Definition 2.13 (∆-Patterns) Let ∆ be one element in R. Given a directed graph G(V, E), we define a ∆-Patterns for any (p1, p2, p3) induced in G(V, E) and isomorphic to ∆, as a set of patterns with five vertices, {p1, p2, p3, v1, v2}, where v1 and v2 are vertices in adj({p1, p2, p3}). A ∆-Patterns is a set of patterns with an induced ∆ plus two vertices in its adjacency. Considering a pattern ∆ ∈ R, it is possible to define 63 sets associated with it. Consider three variables α, β and γ with domain {A, B, C,∅}. The variables α, β and γ define the neighborhood of a given vertex with respect to p1, p2 and p3, respectively. Consider the vertices in adj({p1, p2, p3}). The Algorithm 10 partitions such vertices in 63 sets. If v ∈ set(A, A, A), it is in the set with bidirected edges to p1, p2 and p3. If v ∈ set(∅,∅, C), it is not connected to p1, not connected to p2 and connected to p3 by a directed edge to p3. Let Q = {set(α, β, γ) ∀α, β, γ ∈ {A, B, C,∅}}. Given a set T ∈ Q, we as the number define nT as T. Given two sets Ti, Tj ∈ Q, we define mTi,Tj The role of partition is simple. 19 Input: Undirected graph G(V, E) and a conneceted (p1, p2, p3) ∈ K ∪ P Output: Variables {mx1,x1 , mx1,x2 , . . . , mz,z}. Var to increment 1 All variables in {mx1,x1 , mx1,x2 , . . . , mz,z} start with zero. 2 foreach (x, y) ∈ E do If vertices x ∈ X1 and y ∈ X1 x ∈ X1 and y ∈ X2 x ∈ X1 and y ∈ X3 x ∈ X1 and y ∈ Y12 ... x ∈ Z and y ∈ Y23 x ∈ Z and y ∈ Z mx1,x1 mx1,x2 mx1,x3 mx1,y12 3 ... mz,y23 mz,z 4 end 5 return The computed variables. Algorithm 9: Create {mx1,x1 , mx1,x2 . . . , mz,z} variables for a given e ∈ E. Ti,Tj of directed edges from Ti to Tj and m′ as the number of bidirected edges between Ti and Tj. In other words, for all Ti, Tj ∈ Q, mTi,Tj ← δ+(Ti, Tj) and Ti,Tj ← δ∗(Ti, Tj). Thus, if Ti = set(A, A, A) and Tj = set(A, A, A) then m′ If mset(A,A,A),set(A,A,A) is the number of directed edges inside set(A, A, A). Ti = set(A, A, A) and Tj = set(∅,∅, C) then m′ set(A,A,A),set(∅,∅,C) is the number of bidirected edges between set(A, A, A) and set(∅,∅, C). As in Section 2.5, preprocessing these variables is the core technique used to accelerate our algorithm. The variables are processed only once. Next, they are used to calculate the occurrence of motifs. Consider a pattern ∆ ∈ R and its neighboring sets; for each ∆ induced in G(V, E), the algorithm will analyze and count the ∆-Patterns (see Definition 2.13). The patterns that are considered in more than one ∆-Patterns must to be corrected at the end of the algorithm, as in the undirected case. Consider a simple graph G′ as G(V, E) induced in {p1, p2, p3} ∪ adj({p1, p2, p3}), where (p1, p2, p3) is isomorphic to ∆. Consider no edges in adj({p1, p2, p3}). To discover the pattern associated with {p1, p2, p3, v1, v2}, it is sufficient to known ∆ and which sets in Q are associated with v1 and v2. Let K3 be the complete graph of size 3, K5 \ e be the complete graph of size 5 with one arbitrary bidirected edge removed and Pn be the path graph with n vertices. All edges in K3, K5 \ e and Pn are bidirected. For instance, if v1 ∈ set(A, A, A) and v2 ∈ set(A, A, A) and ∆ = K3, the associated pattern is K5 \ e. If v1 ∈ set(A,∅,∅) and v2 ∈ set(∅,∅, A), and ∆ = P3, the associated pattern is P5. Let pattern(∆, Ti, Tj) for all ∆ ∈ R and Ti, Tj ∈ Q be the pattern related to {p1, p2, p3, v1, v2}, where (p1, p2, p3) is isomorphic to ∆ and v1 ∈ Ti and v2 ∈ Tj. The pattern(∆, Ti, Tj) has a simple rule to be created, but 20 Input: Directed graph G(V, E) and an induced connected subgraph (p1, p2, p3) Output: The vertices in adj({p1, p2, p3}) partitionated in 63 sets. set(α, β, γ) ← ∅ 1 foreach α ∈ {A, B, C,∅},β ∈ {A, B, C,∅},γ ∈ {A, B, C,∅} do 3 end 4 foreach v ∈ adj({p1, p2, p3}) do 2 5 6 7 8 If v ∈ If v ∈ If v ∈       A(p1), α ← A B(p1), α ← B α ← C C(p1), α ← ∅ o.c. , A(p2), β ← A β ← B B(p2), β ← C C(p2), β ← ∅ o.c. , A(p3), γ ← A γ ← B B(p3), γ ← C C(p3), γ ← ∅ o.c. , set(α, β, γ) ← set(α, β, γ) ∪ {v} 9 end 10 return set(α, β, γ) for all α, β and γ in {A, B, C,∅}. The set set(∅,∅,∅) is empty and can be ignored. Algorithm 10: Algorithm to compute sets Q of a given pattern (p1, p2, p3) ∈ R. it is a matrix with 13 × 63 × 63 dimensions, resulting in a matrix with 51,597 precomputed patterns. The following fact is closely related to Fact 2.6. Fact 2.14 Consider a graph induced in {p1, p2, p3} isomorphic to ∆ ∈ R. Let G′ be any graph containing an induced isomorphic pattern ∆ ∈ R plus two vertices in ∆ adjacency. Assume there are no edges in adj({p1, p2, p3}). If it is considered a pattern {p1, p2, p3, v1, v2}, where v1, v2 belong to the same set T ∈ Q, there are (cid:0)nT 2 (cid:1) occurrences of pattern(∆, T, T ). If v1 ∈ Ti and v2 ∈ Tj for distinct Ti, Tj ∈ Q, there are nTi nTj occurrences of pattern(∆, Ti, Tj). More formally, the frequency of pattern P contained in ∆-Patterns is f req(P ) = X T ∈Q:pattern(∆,T,T )=P 2 (cid:19) + (cid:18)nT Ti,Tj ∈Q:i<j,P =pattern(∆,Ti,Tj ) X nTi nTj . Exactly as in Section 2.5, it is necessary to define variations of matrix pattern(∆, Ti, Tj). If a directed edge (v1, v2) is added in adj({p1, p2, p3}), where v1 ∈ Ti and v2 ∈ Tj, one pattern(∆, Ti, Tj) is removed and another pattern is created. The created pattern is defined as pattern→(∆, Ti, Tj). If v1 ∈ Tj and 21 v2 ∈ Ti, the created pattern is pattern←(∆, Ti, Tj). If edge (v1, v2) is bidirected, the created pattern is defined as pattern↔(∆, Ti, Tj). Figure 8 shows the pat- terns created when ∆ = P3 and an edge is added between Ti = set(A, B,∅) and Tj = set(∅,∅, C). There is a straightforward generalization to other possibilities of Ti and Tj in Q and ∆ ∈ R. The following lemma is used by the algorithm. Lemma 2.15 Let G(V, E) be a general directed graph and ∆ ∈ R an induced connected graph of size 3. The patterns occurrences in set ∆-Patterns is given by the following sum: Start all frequency patterns as zero. foreach T ∈ Q do Increase pattern(∆, Ti, Tj) occurrence by nTi nTj − m′ Ti,Tj − mTi,Tj − 2 (cid:1) − mT,T − m′ T,T Increase pattern(∆, T, T ) occurrence by (cid:0)nT Increase pattern↔(∆, T, T ) occurrence by m′ T,T Increase pattern→(∆, T, T ) occurrence by mT,T end foreach Ti, Tj ∈ Q, i < j do mTj ,Ti Increase pattern↔(∆, Ti, Tj) occurrence by m′ Ti,Tj Increase pattern→(∆, Ti, Tj) occurrence by mTi,Tj Increase pattern←(∆, Ti, Tj) occurrence by mTj ,Ti end Proof. Similar to Theorem 2.7. The Algorithm 11 counts patterns of size 5 by summing the ∆-Patterns for all ∆ ∈ R induced in G(V, E). The algorithm applies a correction if the same induced subgraph has been considered many times. Note that the sum in Lemma 2.15 takes O(1), assuming precomputed variables. As in the previous cases, there is no isomorphism-detecting algorithm. It is necessary to preprocess matrices pattern(, ,), pattern→(, ,) and pattern←(,„) associating each pattern with an arbitrary position in the histogram. Such ma- trices are computed once. Every execution of acc-Motif uses the same matrices. The complexity of the algorithm is dominated by lines 6 and 8. Algorithm 10 computes the sets Q for a given (p1, p3, p3) in O(δ(p1) + δ(p2) + δ(p3)) = O(n). Algorithm 9 can be also adapted to compute the required variables in O(m) for a given (p1, p2, p3). Since all other lines are O(1) for ∆-Patterns, we conclude that the proposed algorithm is an O(m2n) algorithm to calculate 5-sized motifs in directed graphs. 3 Results and Discussion This section compares the computational results of our algorithm, that we called acc-Motif (accelerated Motif), with FANMOD [23] and Kavosh [8]. The tools 22 Input: Directed graph G(V, E) Output: Histogram to 9364 isomorphic patterns to motifs of size 5 1 Create a histogram to count isomorphic patterns 2 Create an empty list L∆ for all ∆ ∈ R 3 List all connected (p1, p2, p3) induced in G(V, E) and add to the correspondent L∆ 4 foreach ∆ ∈ R do foreach t ∈ L∆ do Calculate sets Q = {set(α, β, γ) ∀α, βγ ∈ {A, B, C,∅}}. foreach S1, S2 ∈ Q do end Calculate the frequency in ∆-Patterns using Lemma 2.15 Calculate the number of edges between S1 and S2, mS1,S2 end 12 end 13 foreach pattern in the histogram do 5 6 7 8 9 10 11 14 Divide the frequency by the constant a, correcting the repetition in several ∆-Patterns 15 end 16 return The histogram. Algorithm 11: Count 5 Sized Patterns Algorithm. FANMOD and Kavosh were chosen because they are two of the fastest available motif finder programs [24]. The instances were arbitrarily selected from a wide range of motif applica- tions. They are selected from open complex network databases such as Pajek and Uri Alon datasets [1, 3]. We preprocessed the instances, removing vertices with zero neighbors. The implemented algorithms are devised to motifs of sizes 3, 4 and 5. To ensure replicability and better evaluation, we have provided the input tested graphs and the java byte-code of implemented algorithms available at http://www.ft.unicamp.br/∼meira/accmotifs. All the tests were performed in an Intel(R) Core(TM)2 Quad CPU Q8200, 2.33 GHz, 2 GB RAM, using an algorithm implemented in Java language. We set FANMOD and Kavosh with the full enumeration parameter. Thus, FANMOD, Kavosh and acc-Motif solve the same problem, which consists in counting all subgraph of the selected size. The final histogram is exactly the same for a given graph, ensuring the correctness of acc-Motif. Tables 8, 9 and 10 show the execution time of FANMOD, Kavosh and acc-Motif for k equal to 3, 4 and 5, respectively. The algorithm is executed in the original graph and in a set of random graphs. The number of random graphs is 100, 10 and 5 for k equal to 3, 4 and 5, respectively. The time reported is the average considering the original and the random graphs. In this experiment, only the execution time is considered to enumerate all subgraphs. The time to generate the random graphs is not considered. 23 Each round consists in the subgraph enumeration in the original and in the random graphs. We repeated the execution by five rounds per instance. Tables 8, 9 and 10 contain the average and the deviation factor of these five measurements. We limited the CPU time to 5 hours per graph for the sake of convenience. In tables 8, 9 and 10, it is possible to observe that the proposed algorithms were expressively faster than FANMOD and Kavosh in almost all tested instances. For k = 3 and instance Airport [20], acc-Motif spent 35± 0.2ms/graph, Kavosh spent 1, 250 ± 6ms/graph and FANMOD spent 5, 772 ± 2ms/graph. For k = 4 and instance ODLIS [3], acc-Motif spent 2, 605 ± 115ms/graph, Kavosh spent 210, 015 ± 837ms/graph and FANMOD spent 630, 936 ± 2, 914ms/graph. For k = 5 and instance California [3], acc-Motif spent 76±0.4 s/graph, Kavosh spent 1, 532 ± 12s/graph and FANMOD spent 2, 376 ± 12s/graph. The performance gain of acc-Motif was consistently observed in all tested instances. 4 Conclusion Three new exact algorithms were presented to calculate motifs using combinato- rial techniques. The algorithms have complexity O(m√m) to count isomorphic patterns of size 3 and O(m2) to count isomorphic patterns of size 4 and O(m2n) to count isomorphic patterns of size 5. Computational results show that the pro- posed exact algorithms are expressively faster than the known techniques (e.g., FANMOD or Kavosh). 5 Availability and requirements Project name: acc-Motif - Accelerated Motif Detection Using Combinatorial Techniques Project home page: http://www.ft.unicamp.br/∼meira/accmotifs. Operating system(s): Platform independent Programming language: Java Other requirements: e.g. Java 1.6. 1GB Ram. License: Freeware. Any restrictions to use by non-academics: None. 6 Authors' contributions All authors are involved in algorithms discussion and manuscript writing. L. A. A. Meira and V. R. M´aximo are involved in the java implementation. 24 7 Acknowledgements The authors would like to thank Professor Paulo Bandiera Paiva by initial prob- lem statement and data acquisition. This research was partially supported by CNPq-Brazil. 8 Competing interests The authors declare that they have no competing interests. References [1] Uri Alon. Molecular cell biology lab: Dataset. http://www.weizmann.ac.il/mcb/UriAlon/groupNetworksData.html, 2012. [2] A.L. Barabasi and RE Crandall. Linked: The new science of networks. American journal of Physics, 71:409, 2003. [3] Vladimir Batagelj and Andrej Mrvar. Pajek datasets. http://vlado.fmf.uni-lj.si/pub/networks/data/, 2006. [4] Jin Chen, Wynne Hsu, Mong Li Lee, and See-Kiong Ng. Nemofinder: dis- secting genome-wide protein-protein interactions with meso-scale network motifs. In Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining, KDD '06, pages 106 -- 115, New York, NY, USA, 2006. ACM. [5] Norishige Chiba and Takao Nishizeki. Arboricity and subgraph listing algorithms. SIAM J. Comput., 14(1):210 -- 223, February 1985. [6] G. Ciriello and C. Guerra. A review on models and algorithms for motif discovery in protein -- protein interaction networks. Briefings in functional genomics & proteomics, 7(2):147 -- 156, 2008. [7] Joshua A. Grochow and Manolis Kellis. Network motif discovery using subgraph enumeration and symmetry-breaking. In Proceedings of the 11th annual international conference on Research in computational molecular biology, RECOMB'07, pages 92 -- 106, Berlin, Heidelberg, 2007. Springer- Verlag. [8] Z. Kashani, H. Ahrabian, E. Elahi, A. Nowzari-Dalini, E. Ansari, S. Asadi, S. Mohammadi, F. Schreiber, and A. Masoudi-Nejad. Kavosh: a new algo- rithm for finding network motifs. BMC bioinformatics, 10(1):318, 2009. [9] N. Kashtan, S. Itzkovitz, R. Milo, and U. Alon. Efficient sampling algo- rithm for estimating subgraph concentrations and detecting network motifs. Bioinformatics, 20(11):1746 -- 1758, July 2004. 25 [10] Celine Lefebvre, Wei Keat Lim, Katia Basso, Riccardo Dalla Favera, and Andrea Califano. A context-specific network of protein-dna and protein- protein interactions reveals new regulatory motifs in human b cells. In Proceedings of the joint 2006 satellite conference on Systems biology and computational proteomics, RECOMB'06, pages 42 -- 56, Berlin, Heidelberg, 2007. Springer-Verlag. [11] Zhang Lin, Qian Guanqun, and Zhang Li. Clustering analysis of mo- tif significance profile in software networks. In Proceedings of the 10th WSEAS International Conference on Mathematical Methods and Computa- tional Techniques in Electrical Engineering, pages 145 -- 147, Stevens Point, Wisconsin, USA, 2008. World Scientific and Engineering Academy and So- ciety (WSEAS). [12] Michael Lones and Andy Tyrrell. Regulatory motif discovery using a pop- IEEE/ACM Transactions on ulation clustering evolutionary algorithm. Computational Biology and Bioinformatics, 4:403 -- 414, 2007. [13] Dror Marcus and Yuval Shavitt. Efficient counting of network motifs. In Proceedings of the 2010 IEEE 30th International Conference on Distributed Computing Systems Workshops, ICDCSW '10, pages 92 -- 98, Washington, DC, USA, 2010. IEEE Computer Society. [14] Dror Marcus and Yuval Shavitt. Rage - a rapid graphlet enumerator for large networks. Computer Networks (COMNET, Elsevier), to appear., March 2012. [15] Luis A. A. Meira, Vinicius R. M´aximo, ´Alvaro L. Fazenda, and Arlindo F. da Concei¸cao. A New Approach to Count Pattern Motifs Using Combi- natorial Techniches. In The 8th International Conference on Signal Image Technology -- Workshop on Complex Network, November 2012. [16] R. Milo, S. Shen-Orr, S. Itzkovitz, N. Kashtan, D. Chklovskii, and U. Alon. Network motifs: Simple building blocks of complex networks. Science, 298:824 -- 887, 2002. [17] Kashtan N., Itzkovitz S., Milo R., and Alon U. Network motif detection tool: mfinder tool guide. Technical report, Department of Molecular Cell Biology and Computer Science and Applied Mathematics, Weizman Insti- tute of Science, Israel, 2005. [18] C.S.J.A. Nash-Williams. Decomposition of finite graphs into forests. Jour- nal of the London Mathematical Society, 1(1):12 -- 12, 1964. [19] S. Omidi, F. Schreiber, and A. Masoudi-Nejad. Moda: An efficient algo- rithm for network motif discovery in biological networks. Genes Genet. Syst, 84:385 -- 395, 2009. [20] Tore Opsahl. Datasets tore opsahl. http://toreopsahl.com/datasets/#usairports, 2012. 26 [21] Pedro Ribeiro, Fernando Silva, and Marcus Kaiser. Strategies for network motifs discovery. In Proceedings of the 2009 Fifth IEEE International Con- ference on e-Science, E-SCIENCE '09, pages 80 -- 87, Washington, DC, USA, 2009. IEEE Computer Society. [22] F. Schreiber and H. Schwobbermeyer. Mavisto: a tool for the exploration of network motifs. Bioinformatics, 21(17):3572 -- 3574, 2005. [23] S. Wernicke and F. Rasche. Fanmod: a tool for fast network motif detection. Bioinformatics, 22(9):1152 -- 1153, 2006. [24] Elisabeth Wong, Brittany Baur, Saad Quader, and Chun-Hsi Huang. Bio- logical network motif detection: principles and practice. Brief Bioinform, 2011. [25] Kai-Hsiang Yang, Kun-Yan Chiou, Hahn-Ming Lee, and Jan-Ming Ho. Web appearance disambiguation of personal names based on network mo- tif. In Proceedings of the 2006 IEEE/WIC/ACM International Conference on Web Intelligence, WI '06, pages 386 -- 389, Washington, DC, USA, 2006. IEEE Computer Society. Av = δ∗(v) nv a = Av Bv = δ+(v) nv b = Bv a,b = δ+(Av,Bv) mv b,a = δ+(Bv,Av) mv a,a = δ+(Av,Av) mv a,b = m′v m′v a,a = δ∗(Av,Av) b,a = δ∗(Av,Bv) a,c = δ+(Av,Cv) mv c,a = δ+(Cv,Av) mv b,b = δ+(Bv,Bv) mv b,b = δ∗(Bv,Bv) m′v Table 1: Variables to vertex v. a,c = m′v m′v c,a = δ∗(Av,Cv) m′v Cv = δ−(v) nv c = Cv b,c = δ+(Bv,Cv) mv c,b = δ+(Cv,Bv) mv c,c = δ+(Cv,Cv) mv m′v c,c = δ∗(Cv,Cv) b,c = m′v c,b = δ∗(Bv,Cv) m′v pattern(∆, Ti, T 2) pattern→(∆, Ti, T 2) pattern←(∆, Ti, T 2) pattern↔(∆, Ti, T 2) v1 v2 v1 v2 v1 v2 v1 v2 p1 p3 p1 p3 p1 p3 p1 p3 p2 p2 p2 p2 Figure 8: Variations of matrix pattern(∆, Ti, Tj) for Ti = set(A, B,∅) and Tj = set(∅,∅, C). 27 Pattern o ↔ o → o o ↔ o ← o o → o → o o ↔ o ↔ o o ← o → o o → o ← o Frequency a,b − mv a,c − mv b,c − mv b,a − m′v c,a − m′v c,b − m′v b,c a,b a,c nv anv b − mv nv anv c − mv c − mv b nv nv (cid:18)nv 2 (cid:19) − mv (cid:18)nv 2 (cid:19) − mv (cid:18)nv 2 (cid:19) − mv a c b a,a a,a − m′v b,b − m′v c,c − m′v b,b c,c Line 1 2 3 4 5 6 Pattern Frequency Line o o o o o o o o o o o o o o o o o o o o o m′v a,a mv b,c mv a,b + m′v c,c mv b,a + mv a,c + m′v c,b m′v a,b + m′v a,c + mv a,a mv c,a + m′v b,b mv c,b + mv b,b + mv c,c 7 8 9 10 11 12 13 Table 2: Isomorphic pattern frequencies involving vertex v and two neighbors. Pattern P4 x ↔ C3 S3 K4 \ {e} C4 K4 (ne x + ne y)ne x z − me x,z − me (cid:18)ne 2 (cid:19) +(cid:18)ne (cid:18)ne 2 (cid:19) + me z Frequency y − me nxne x,x + me x,y y,y y y,z + me 2 (cid:19) − me x,x − me x,z + my,z − me me me y,y z,z x,y z,z Table 3: e-Patterns frequencies for e = {u, v}. If the top blue edge is ignored, this table represents pattern(Ti, Tj) Table 4: for all Ti, Tj ∈ T e. Symmetric side omitted. 28 Pattern Frequency (cid:0)nx1 2 (cid:1) +(cid:0)nx2 2 (cid:1) +(cid:0)nx3 2 (cid:1) nx1 nx2 + nx1 nx3 + nx2 nx3 nx1(ny12 + ny13) + nx2(ny12 + ny23) + nx3(ny13 + ny23) nx1 ny23 + nx2 ny13 + nx3 ny23 (nx1 + nx2 + nx3)nz (cid:0)ny12 2 (cid:1) +(cid:0)ny13 2 (cid:1) +(cid:0)ny23 2 (cid:1) ny12 ny13 + ny12ny23 + ny13ny23 (ny12 + ny13 + ny23 )nz (cid:0)nz 2 (cid:1) Table 5: K3-Patterns frequencies for the graph of Figure 6. P3-Patterns fre- quencies are analogous. 29 Pattern Frequency Line 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 (cid:1) +(cid:0)nx3 2 (cid:1) − mx1,x1 − mx2,x2 − mx3,x3 (cid:0)nx1 2 (cid:1) +(cid:0)nx2 nx1 nx2 + nx1 nx3 + nx2 nx3 − mx1,x2 − mx1,x3 − mx2,x3 nx1 (ny12 + ny13) + nx2(ny12 + ny23) + nx3(ny13 + ny23) −mx1,y12 − mx1,y13 − mx2,y12 − mx2,y23 − mx3,y13 − mx3,y23 nx1 ny23 + nx2 ny13 + nx3 ny23 − mx1,y23 − mx2,y13 − mx3,y12 (nx1 + nx2 + nx3)nz − mx1,z − mx2,z − mx3,z (cid:0)ny12 2 (cid:1) +(cid:0)ny13 ny12 ny13 + ny12ny23 + ny13ny23 − my12,y13 − my12,y23 − my13,ny23 +mx1,y12 + mx1,y13 + mx2,y12 + mx2,y23 + mx3,y13 + mx3,y23 2 (cid:1) − my12,y13 − my12,y23 − my13,y23 2 (cid:1) +(cid:0)ny23 (ny12 + ny13 + ny23 )nz − my12,z − my13,z − my23,z mx1,z + mx2,z + mx3,z + my12,y13 + my12,y23 + my13,y23 + mny12 ,ny23 + mny13 ,ny23 mny12 ,ny13 (cid:0)nz 2 (cid:1) − mzz + my12,z + my13,z + my23,z mx1,x1 + mx2,x2 + mx3,x3 mx1,x2 + mx1,x3 + mx2,x3 mx1,y23 + mx2,y13 + mx3,y12 mz,z Table 6: K3-Patterns frequencies in a general graph. 30 Pattern Frequency 2 (cid:1) − mx1,x1 − mx3,x3 (cid:0)nx1 2 (cid:1) +(cid:0)nx2 (cid:0)nx2 2 (cid:1) − mx2,x2 − mx3,x3 nx1 nx2 + nx2 nx3 − mx1,x2 − mx2,x3 nx1 nx3 − mx1,x3 nx1 ny12 + nx3 ny23 − mx1,y12 − mx3,y23 nx1 ny13 + nx3 ny13 + nx2 ny13 − mx1,y13 − mx3,y13 − mx2,y13 + mx1,x2 + mx2,x3 nx1 ny23 + nx3 ny12 − mx1,y23 − mx3,y12 + mx1,x1 + mx3,x3 nx2 ny12 + nx2 ny23 − mx2,y12 − mx2,y23 + mx2,x2 (nx1 + nx3 )nz − mx1,z − mx3,z + mx1,y12 + mx3,y23 nx2 nz +(cid:0)ny12 (cid:0)ny13 2 (cid:1) − my13,y13 + mx1,y23 + mx2,y13 + mx3,y12 + mx3,y13 + m12,13 ny13ny23 + ny12ny13 − my13,y23 − my12,y13 ny12ny23 − my12,y23 ny12nz + ny23nz − my12,z − my23,z + mx1,z + mx3,z + my12,y23 ny13nz − my13 (cid:0)nz 2 (cid:1) − mz,z 2 (cid:1) − mx2,z − my12,y12 − my23,y23 + mx2,y12 + mx2,y23 2 (cid:1) +(cid:0)ny23 z,+my13,y13 + m13,23 mx1,x3 mx2,z my12,y12 + my23,y23 my12,z + my13,z + my23,z mz,z Table 7: P3-Patterns frequencies in a general graph. 31 Grafos E.coli [1] CSphd [3] Yeast [1] Roget [3] Epa [3] California [3] Facebook [20] ODLIS [3] PairsFSG [3] Airport [20] Foldoc [3] (n,m) (418, 519) (1882, 1740) (688, 1079) (1022, 5074) (4271, 8965) (6175, 16150) (1899, 20296) (2900, 18241) (5018, 63608) (1574, 28236) (12905, 109092) acc-Motif (ms) Famod (ms) Kavosh (ms) 4.5 ± 0.02 5.3 ± 0.03 11.5 ± 0.07 30.2 ± 0.4 202.4 ± 0.6 316.3 ± 0.5 576 ± 2 957 ± 2 1, 915 ± 3 1, 250 ± 6 2, 148 ± 5 0.13 ± 0.005 0.68 ± 0.009 0.25 ± 0.005 2.1 ± 0.06 4.4 ± 0.08 11.3 ± 0.14 14.2 ± 0.29 18.0 ± 0.27 105 ± 6 35 ± 0.2 183 ± 0.3 8.0 ± 0.003 9.7 ± 0.001 22.7 ± 0.03 52.7 ± 0.01 387.8 ± 0.1 632.4 ± 0.1 1, 446 ± 0.6 3, 150 ± 2 3, 883 ± 14 5, 772 ± 2 7, 481 ± 24 Table 8: Execution time to count isomorphic patterns of size 3 by processed graph using acc-Motif, FANMOD and Kavosh. Grafos E.coli [1] CSphd [3] Yeast [1] Roget [3] Epa [3] California [3] Facebook [20] ODLIS [3] PairsFSG [3] Airport [20] Foldoc [3] (n,m) (418, 519) (1882, 1740) (688, 1079) (1022, 5074) (4271, 8965) (6175, 16150) (1899, 20296) (2900, 18241) (5018, 63608) (1574, 28236) (12905, 109092) acc-Motif (ms) 3.7 ± 0.6 7.4 ± 0.2 7.8 ± 0.1 58 ± 1.3 200 ± 7.4 772 ± 64 2135 ± 75 2, 605 ± 115 9, 097 ± 114 10, 106 ± 130 10, 047 ± 30 Famod (ms) 221.0 ± 0.2 104.5 ± 0.3 573.7 ± 0.9 930.8 ± 1.2 26, 613 ± 49 37, 484 ± 101 147, 713 ± 169 630, 936 ± 2, 914 334, 025 ± 454 794, 227 ± 1091 1, 179, 759 ± 3, 066 Kavosh (ms) 124.0 ± 0.7 59.1 ± 0.5 278.1 ± 0.8 520.1 ± 2.1 13, 739 ± 15 19, 280 ± 110 59, 064 ± 277 210, 015 ± 837 181, 957 ± 617 163, 678 ± 1, 065 259, 935 ± 690 Table 9: Execution time to count isomorphic patterns of size 4 by processed graph using acc-Motif, FANMOD and Kavosh. 32 Grafos E.coli [1] CSphd [3] Yeast [1] Roget [3] Epa [3] California [3] Facebook [20] ODLIS [3] PairsFSG [3] Airport [20] Foldoc [3] (n,m) (418, 519) (1882, 1740) (688, 1079) (1022, 5074) (4271, 8965) (6175, 16150) (1899, 20296) (2900, 18241) (5018, 63608) (1574, 28236) (12905, 109092) acc-Motif (s) FANMOD (s) 5.6 ± 0.02 1.3 ± 0.03 12.9 ± 0.07 17.4 ± 0.06 1, 696 ± 6 2, 376 ± 12 14, 378 ± 10 > 13h > 13h > 13h > 13h 0.1 ± 0.01 0.1 ± 0.002 0.3 ± 0.003 2 ± 0.005 32.3 ± 0.1 76 ± 0.4 505 ± 6 835 ± 2.6 2, 334 ± 2.3 3, 058 ± 14 2, 965 ± 3.2 Kavosh (s) 3.5 ± 0.03 0.76 ± 0.01 7.5 ± 0.1 11.3 ± 0.07 1, 052 ± 5.9 1, 532 ± 12 6, 343 ± 25 > 13h 23, 036.62 ± 23.6 18, 278.96 ± 37.66 > 13h Table 10: Execution time to count isomorphic patterns of size 5 by processed graph using acc-Motif, FANMOD and Kavosh. 33
1809.01759
1
1809
2018-09-05T22:52:51
Multi-finger binary search trees
[ "cs.DS" ]
We study multi-finger binary search trees (BSTs), a far-reaching extension of the classical BST model, with connections to the well-studied $k$-server problem. Finger search is a popular technique for speeding up BST operations when a query sequence has locality of reference. BSTs with multiple fingers can exploit more general regularities in the input. In this paper we consider the cost of serving a sequence of queries in an optimal (offline) BST with $k$ fingers, a powerful benchmark against which other algorithms can be measured. We show that the $k$-finger optimum can be matched by a standard dynamic BST (having a single root-finger) with an $O(\log{k})$ factor overhead. This result is tight for all $k$, improving the $O(k)$ factor implicit in earlier work. Furthermore, we describe new online BSTs that match this bound up to a $(\log{k})^{O(1)}$ factor. Previously only the "one-finger" special case was known to hold for an online BST (Iacono, Langerman, 2016; Cole et al., 2000). Splay trees, assuming their conjectured optimality (Sleator and Tarjan, 1983), would have to match our bounds for all $k$. Our online algorithms are randomized and combine techniques developed for the $k$-server problem with a multiplicative-weights scheme for learning tree metrics. To our knowledge, this is the first time when tools developed for the $k$-server problem are used in BSTs. As an application of our $k$-finger results, we show that BSTs can efficiently serve queries that are close to some recently accessed item. This is a (restricted) form of the unified property (Iacono, 2001) that was previously not known to hold for any BST algorithm, online or offline.
cs.DS
cs
Multi-finger binary search trees Parinya Chalermsook1, Mayank Goswami2, László Kozma3, Kurt Mehlhorn4, and Thatchaphol Saranurak5 1 Aalto University, Finland. [email protected] 2 Queens College, City University of New York. [email protected] 3 TU Eindhoven, Netherlands. [email protected] 4 MPI für Informatik, Saarbrücken, Germany. [email protected] 5 KTH Royal Institute of Technology, Sweden. [email protected] Abstract We study multi-finger binary search trees (BSTs), a far-reaching extension of the classical BST model, with connections to the well-studied k-server problem. Finger search is a popular tech- nique for speeding up BST operations when a query sequence has locality of reference. BSTs with multiple fingers can exploit more general regularities in the input. In this paper we consider the cost of serving a sequence of queries in an optimal (offline) BST with k fingers, a powerful benchmark against which other algorithms can be measured. We show that the k-finger optimum can be matched by a standard dynamic BST (having a single root-finger) with an O(log k) factor overhead. This result is tight for all k, improving the O(k) factor implicit in earlier work. Furthermore, we describe new online BSTs that match this bound up to a (log k)O(1) factor. Previously only the "one-finger" special case was known to hold for an online BST (Iacono, Langerman, 2016; Cole et al., 2000). Splay trees, assuming their conjectured optimality (Sleator and Tarjan, 1983), would have to match our bounds for all k. Our online algorithms are randomized and combine techniques developed for the k-server problem with a multiplicative-weights scheme for learning tree metrics. To our knowledge, this is the first time when tools developed for the k-server problem are used in BSTs. As an application of our k-finger results, we show that BSTs can efficiently serve queries that are close to some recently accessed item. This is a (restricted) form of the unified property (Iacono, 2001) that was previously not known to hold for any BST algorithm, online or offline. 1998 ACM Subject Classification F.2.2 Nonnumerical Algorithms, E.1 Data Structures Keywords and phrases binary search trees, dynamic optimality, finger search, k-server Digital Object Identifier 10.4230/LIPIcs.arXiv.2018. 1 Introduction 8 1 0 2 p e S 5 ] S D . s c [ 1 v 9 5 7 1 0 . 9 0 8 1 : v i X r a The binary search tree (BST) is the canonical comparison-based implementation of the dictionary data type for maintaining ordered sets. Dynamic BSTs can be re-arranged after every access via rotations and pointer moves starting from the root. Various ingenious techniques have been developed for dynamically maintaining balanced BSTs, supporting search, insert, delete, and other operations in time O(log n), where n is the size of the dictionary (see e.g. [31, § 6.2.2], [40, § 5]). In several applications where the access sequence has strong locality of reference, the worst-case bound is too pessimistic (e.g. in list merging, adaptive sorting, or in various geometric problems). A classical technique for exploiting locality is finger search. In finger © Parinya Chalermsook, Mayank Goswami, László Kozma, Kurt Mehlhorn, Thatchaphol Saranurak; licensed under Creative Commons License CC-BY arXiv. Editor: ..; Article No. ; pp. :1 -- :26 Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany XX:2 Multi-finger binary search trees search trees, the cost of an access is typically O(log d),1 where d is the difference in rank between the accessed item and a finger (d may be much smaller than n). The finger indicates the starting point of the search, and is either given by the user, or (more typically) it points to the previously accessed item. Several special purpose tree-like data structures have been designed to support finger search.2 In 1983, Sleator and Tarjan [49] introduced Splay trees, a particularly simple and elegant "self-adjusting" BST algorithm. In 2000, Cole et al. [16, 15] showed that Splay matches (asymptotically) the efficiency of finger search, called in this context the dynamic finger property. This is remarkable, since Splay uses no explicit fingers; every search starts from the root. The result shows the versatility of the BST model, and has been seen as a major (and highly nontrivial) step towards "dynamic optimality", the conjecture of Sleator and Tarjan that Splay trees are constant-competitive. BSTs can also adapt to other kinds of locality. The working set property [49] requires the amortized cost of accessing x to be O(log t), where t is the number of distinct items accessed since the last access of x. Whereas dynamic finger captures proximity in keyspace, the working set property captures proximity in time. In 2001, Iacono [26] proposed a unified property that generalizes both kinds of proximity. Informally, a data structure with the unified property is efficient when accessing an item that is close to some recently accessed item. It is not known whether any BST data structure has the unified property. Recently, Iacono and Langerman [28] studied the lazy finger property (Bose et al. [8]), and showed that an online algorithm called Greedy BST3 satisfies it. The lazy finger property requires the amortized cost of accessing x to be O(d), where d is the distance (number of edges) from the previously accessed item to x in the best static reference tree. This property is stronger than the dynamic finger property [8], and it is not known to hold for Splay. In this paper we study a generalization of the lazy finger property; instead of a single finger stationed at the previously accessed item, we allow k fingers to be moved around arbitrarily. An access is performed by moving any of the fingers to the requested item. Cost is proportional to the total distance traveled by the fingers. We assume that the fingers move according to an optimal strategy, in an optimally chosen static tree, with a priori knowledge of the entire access sequence. The cost of this optimal offline execution with k fingers is an intrinsic measure of complexity of a query sequence, and at the same time a benchmark that algorithms in the classical model can attempt to match. Parameter k describes the strength of the bound: the case k = 1 is the lazy finger, at the other extreme, at k = n, each item may have its own finger, and all accesses are essentially free. Our main result is a family of new online4 dynamic BST algorithms (in the standard model, where every access starts at the root), matching the k-finger optimum on sufficiently long sequences, up to an overhead factor with moderate dependence on k and no dependence on the dictionary size or on the number of accesses in the sequence. Our online BST combines three distinct techniques: (1) an offline, one-finger BST simula- tion of a multi-finger execution (the technique is a refinement of an earlier construction [18]), 1 To simplify notation, we let log (x) denote log2 (max{2, x}). 2 The initial 1977 design of Guibas et al. [23] was refined and simplified by Brown and Tarjan [10] and by Huddleston and Mehlhorn [25]. Further solutions include [51, 50, 32, 30], see also the survey [9]. Randomized treaps [46] and skip lists [43] can also support finger search. 3 Greedy BST was discovered by Lucas in 1988 [37] and later independently by Munro [42]. Demaine et al. [17] transformed it into an online algorithm. 4 An online BST algorithm can base its decisions only on the current and past accesses. An offline algorithm knowns the entire access sequence in advance. P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:3 (2) online k-server algorithms that can simulate the offline optimal multi-finger strategy, and (3) a multiplicative-weights scheme for learning a tree metric in an online fashion. The fact that "vanilla" BSTs can, with a low overhead, simulate a much more powerful computational model further indicates the strength and versatility of the BST model. As an application, we show that our online BST algorithms satisfy a restricted form of the unified property; previously no (online or offline) BST was known to satisfy such a property. If there is a constant-competitive BST algorithm, then it must match our k-finger bounds. The two most promising candidates, Splay and Greedy BST (see e.g. [27]) were only shown (with considerable difficulty) to satisfy variants of the one-finger, i.e. lazy finger property. To obtain our online BSTs competitive for other values of k, we combine sophisticated tools developed for other online problems, as well as our refinement of a previous (highly nontrivial) construction for simulating multiple fingers. These facts together may hint at the formidable difficulty (more pessimistically: the low likelihood) of attaining dynamic optimality by simple and natural BST algorithms such as Splay or Greedy. BST and finger models. Main results. Now, we introduce the formal statements of our results. In the dynamic BST model a sequence of keys is accessed in a binary search tree (BST), and after each access, the tree can be reconfigured via a sequence of rotations and pointer moves starting from the root. (There exist several alternative but essentially equivalent models, see [52, 17].) Denote the space of keys (or elements) by [n]. For a sequence X = (x1, . . . , xm) ∈ [n]m, denote by OPT(X) the cost of the optimal offline BST for accessing X.5 Arguably the most important question in the BST model is the dynamic optimality conjecture, i.e. the existence of an online BST whose cost is O(OPT(X)) for every X. A BST optimality property is an inequality between OPT(X) and some function f(X), that holds in the BST model. (If OPT(X) ≤ f(X) for all X is a BST optimality property, then every O(1)-competitive algorithm must cost at most O(f(X)).) Several natural BST properties have been suggested over the last few decades. For instance, t log xt−j, where j ∈ [n] is a fixed element (finger). The static optimality property [49] is OPT(X) = O(SO(X)), where SO(X) = minR i dR(xi). Here R is a static BST, and dR(x) is the depth of x in R. t log xt−xt+1, and for working set [49], t log ρt(xt), where ρt(a) is the number of distinct keys accessed between time t the static finger property [49] states OPT(X) = O(SF(X)), for SF(X) =P For the dynamic finger property [49], DF(X) =P WS(X) =P unified bound is defined as UB(X) = P In 2001, Iacono [26] initiated the study of a property that would "unify" the latter two notions of efficiency and exhibited a data structure (not a BST) achieving this property. This t mint0<t log(xt − xt0 + ρt(xt0)). Dynamic finger and working set are in general, not comparable. On the other hand, UB(X) ≤ DF(X), and UB(X) ≤ WS(X) clearly hold, justifying the name of the unified bound. Despite several attempts, the question whether the unified bound is a valid BST property remains unclear; it was shown in [20] that OPT(X) = O(UB(X)+ m log log n), and in [11, 26] that the unified bound is valid in some other (non-BST) models6. and the last time at which a was accessed (all keys assumed accessed at time zero). P We show that a unified bound with "bounded time-window" holds in the BST model: (cid:73) Theorem 1. For every integer ' ≥ 1, every sequence X and some fixed function β(·), OPT(X) ≤ β(') · UB', where UB' =X min t0∈[t−',t) t log(cid:0)xt − xt0 + ρt(xt0)(cid:1). 5 To avoid technicalities, we only consider access (i.e. successful search) operations and assume m ≥ n. 6 Another attempt to study the bounds related to the unified bound was done in [24]. arXiv 2018 XX:4 Multi-finger binary search trees Observe that UB(X) = UBm(X) ≤ ··· ≤ UB1(X) = DF(X). Prior to our work it was not known whether the theorem holds when ' = 2, i.e. no known BST property subsumes this property even when ' = 2. Thus, Theorem 1 establishes the first BST property that combines the efficiencies of time- and keyspace-proximity without an additive term.7 Recently Bose et al. [8] introduced the lazy finger property, LF(X) = minR i dR(xi, xi+1). Here distance is measured in a static reference BST R, optimally chosen for the entire sequence. The lazy finger bound can be visualized as follows: accesses are performed in the reference tree by moving a unique finger from the previously accessed item to the requested item. The lazy finger property is rather strong: Bose et al. show that it implies the dynamic finger and static optimality properties, which in turn imply static finger. P Our main tool in proving Theorem 1 is a generalization of the lazy finger property allowing multiple fingers. The model is motivated by the famous k-server problem. For an input sequence X ∈ [n]m and a static BST R with nodes associated with the keys in [n], we have k servers located initially at arbitrary nodes in R. At time t = 1, . . . , m, the request xt arrives, and we move a server of our choice to the node of R that stores xt. The cost for serving a sequence X is equal to the total movement in R to serve the sequence X. Denote by Fk R(X) the cost of the optimal (offline) strategy that serves sequence X in R with k servers, minimized over all possible initial server locations. Let Fk(X) = minR Fk R(X). We call Fk(X) the k-finger cost of X. We remark that the value of Fk R(X) is polynomial- time computable for each R, k ∈ N, and X ∈ [n]m by dynamic programming. Clearly, F1(X) ≥ F2(X) ≥ ··· ≥ Fn(X) holds for all X. We first show that one can simulate any k-finger strategy in the BST model, in a near-optimal manner. In particular, we prove the following tight result. (cid:73) Theorem 2. OPT(X) ≤ O(log k) · Fk(X). The proof of Theorem 2 is a refinement of an earlier argument [18], improving the overhead factor from O(k) to O(log k). The logarithmic dependence on k is, in general, the best possible. To see this, consider a sequence S of length m, over k distinct items with average cost Ω(log k) (e.g. a random sequence from [k]m does the job). While OPT(S) = Θ(m log k), clearly Fk(X) = O(m), as each of the k items can be served with its own private finger. In the definition of Fk(X) we assume a static reference tree R for the k-finger execution. The offline BST simulation in the proof of Theorem 2 works in fact (with the same overhead) even if R is dynamic, i.e. if the multi-finger adversary can perform rotations at any of the fingers. In this case, however, the k-finger bound is too strong to be useful; already the k = 1 case captures the dynamic BST optimum. Our next result is the online counterpart of Theorem 2. In this case, the restriction that R is static is essential. (cid:73) Theorem 3. There exists an online randomized BST algorithm whose cost for serving X ∈ [n]m, is O(cid:0)(log k)7(cid:1) · Fk(X) + ρ(n), for some fixed function ρ(·). The result can be interpreted as follows. On sufficiently long access sequences, there is an online BST algorithm (in fact, a family of them) competitive with the k-finger bound, up to an overhead factor with moderate dependence on k. The randomized algorithm (as is standard in the online setting) assumes an oblivious adversary that does not know in advance the outcomes of the algorithm's random coin-flips. The use of randomness seems essential to our approach. We propose as intriguing open questions to find a deterministic online BST with comparable guarantees and to narrow the gap between the online and offline results. 7 The proof of Theorem 1 implies in fact a stronger, weighted form, which we omit for ease of presentation. P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:5 Due to its substantial amount of computation (outside the BST model), our online algorithm is of theoretical interest only. Nonetheless, the connection with the k-server problem allows us to "import" several techniques to the BST problem; some of these, such as the double coverage heuristic for k-server [14] are remarkably simple and may find their way to practical BST algorithms. The strength of the k-finger model lies in the k-server abstraction. In order to establish a BST property of the form OPT(X) ≤ β(') · O(g(X)), it is now sufficient to prove F'(X) ≤ (β(')/ log ') · O(g(X)). In other words, our technique reduces the task of bounding the cost in the BST model to designing k-server strategies, which typically admits much cleaner combinatorial arguments. We illustrate this approach by showing that the unified property with a fixed time-window holds in the BST model. (cid:73) Theorem 4. For some fixed functions α(·), γ(·), we have: Fα(')(X) ≤ γ(') · UB'. Theorems 4 and 2 together imply Theorem 1. Moreover, Theorem 3 implies that the property holds for online BST algorithms (we later specify the involved functions). The k-finger approach can be used to show further BST properties. For example, we connect decomposability (refer to § 4 for definitions) and finger properties by showing that even one finger is enough to obtain the traversal property in significantly generalized form. (cid:73) Theorem 5. Let X be a d-decomposable sequence. Then F1(X) = O(log d) · X. As a corollary, using the recent result by Iacono and Langermann [28], we resolve an open problem in [13], showing that Greedy costs at most O(log d) · X on every d-decomposable sequence, matching the lower bound in [13].8 In another direction, we connect multiple fingers and generalized monotone sequences. In [13], we showed that OPT(X) ≤ X · 2O(d2) on every d-monotone sequence X; a sequence is d-monotone if it can be decomposed into d increasing or d decreasing sequences. Using the k-finger technique, we show the stronger BST property OPT(X) ≤ O(d log d) · X. Concerning simple and natural BST algorithms (Splay and Greedy), we give evidence that the strongest results in the literature may still be far from settling the dynamic optimality conjecture. To this end, we describe a class of sequences for which increasing the number of fingers by one can create an Ω(log n) gap. More precisely, we show the following: (cid:73) Theorem 6. For every integer k, there is a sequence Sk such that Fk−1(Sk) = Ω( n but Fk(Sk) = O(n). k log(n/k)) Theorem 6 shows that the multi-finger bounds form a fine-grained hierarchy. For small k, our online algorithm (Theorem 3) can match these bounds (up to a constant factor). However, any online BST (such as Splay or Greedy) must also match the dependence of O(log k) in the upper bound of O(log k) · F k(X), in order to be constant-competitive. Techniques. The k-server problem. The k-server problem, introduced by Manasse, McGeoch, and Sleator [38] in 1988 is a central problem in online algorithms: Is there an online deterministic strategy for serving a sequence of requests by moving k servers around, with a total movement cost at most k times the optimal offline strategy? The question in its original form, for arbitrary metric spaces, remains open. Nonetheless, the problem has inspired a wealth of results and a rich set of techniques, many of which have 8 Independently of our work, Goyal and Gupta [22] showed the same result using a charging argument. arXiv 2018 XX:6 Multi-finger binary search trees found applications outside the k-server problem. A full survey is out of our scope, we refer instead to some prominent results [21, 34, 47, 44, 3, 2], and the surveys [6, § 10, § 11], [33]. Most relevantly for us, Chrobak and Larmore [14] gave in 1991, an intuitive, deterministic, k-competitive algorithm for tree metrics, and the very recently announced breakthrough of Lee [35], building on Bubeck et al. [12], gives an O(cid:0)(log k)6(cid:1)-competitive randomized algorithm for arbitrary metrics. Our online BST algorithm relies on an online k-server in an almost black box fashion (the metric space underlying the k-server instance is induced by a static reference BST). Thus, improvements for k-server would directly yield improvements in our bounds. Despite the depth and generality of k-server (e.g. it also models the caching/paging problem), to our knowledge it has previously not been related to the BST problem.9 It is known that in an arbitrary metric space with at least k + 1 points, no deterministic online algorithm may have a competitive ratio better than k. In the randomized case the lower bound Ω(log k/ log log k) holds, see e.g. [33]. (The lower bounds thus apply for a metric induced by a BST, for all k < n.) These results imply a remarkable separation between the k-server and BST problems. Dynamic optimality would require, by Theorem 2, a BST cost of O(log k) · Fk. To match this, an online BST may not implicitly perform a deterministic k-server execution, since, in that case its overhead would have to be Ω(k). This indicates that improving Theorem 3 will likely require tools significantly different from k-server, which is surprising, given the similarity of the two formulations. Our online BST learns the metric induced by the optimal reference tree using a multi- plicative weights update (MWU) scheme. The technique has a rich history, and a recent emergence as a powerful algorithmic tool (we refer to the survey of Arora, Hazan, and Kale [1]). MWU or closely related techniques have been used previously in data structures (including for BST-related questions), see e.g. [5, 4, 27, 29]. Specifically, Iacono [27] obtains, using MWU, an online BST that is constant-competitive on sufficiently long sequences, if any online BST is constant-competitive. As we relate online BSTs with an offline strategy, the results are not directly comparable. Further open questions and structure of the paper. The main open question raised by our work is whether natural algorithms such as Splay or Greedy match the properties of our new BST algorithms. (This must be the case, if Splay and Greedy are, as conjectured, O(1)-competitive). We suggest the following easier questions. Do Splay or Greedy satisfy the unified bound with a time-window of 2 steps? Does Splay satisfy the lazy finger or the 2-monotone bounds? Does Greedy satisfy the 2-finger bound? Except for Theorems 2 and 5, the factors in our results are not known to be tight. Improving them may reveal new insight about the power and limitations of the BST model. In § 2 we describe our offline BST simulation. In § 3 we describe our new family of online algorithms. In § 4 we prove the main applications and further observations. 2 Offline simulation of multi-finger BSTs (Theorem 2) Let k ∈ N , let T be a BST on [n], and let X = (x1, . . . , xm) ∈ [n]m be an access sequence. A k-finger strategy consists of a sequence ~f ∈ [k]m where ft ∈ [k] specifies the finger that 9 In his work on a generalized k-server problem, Sitters [48] asks whether the work-function (WF) technique [34] for k-server may have relevance for BSTs. Indeed, we can use WF as an O(k)-competitive component of our online BSTs, but for our special case of tree-metrics, the technique of [14] is much simpler. Whether WF may be used (in different ways) to obtain competitive BSTs remains open. P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:7 T, ~f ,~'(X) = Pm serves access xt. Let ~' ∈ [n]k be the initial vector, where 'i ∈ [n] gives the initial location of finger i. The cost of strategy ( ~f , ~') is Fk t=1(1 + dT (xt, xσ(ft,t))) where σ(i, t) = max{j < t fj = i} is the location of finger i before time t, and σ(i, 1) = 'i. Let Fk T (X) = min ~f ,~' Fk T (X) is the k-server optimum for serving X in the metric space of the tree T. (Note that the tree is unweighted, and the distance dT (·,·) counts the number of edges between two nodes in T.) T (X). It is clear form the definition that F1(X) ≥ F2(X) ≥ ··· ≥ We define Fk(X) = minT Fk Fn(X) = m for all X. T, ~f ,~'(X). In other words, for a fixed BST T on keyset [n], Fk Observe that we implicitly assume that during every access at most one server moves. In addition, we may assume that if some server is already placed at the requested node, then no movement happens. Algorithms with these two restrictions are called lazy. As argued in the k-server literature (see e.g. [33]), non-lazy server movements can always be postponed to a later time, keeping track of the "virtual" locations of servers. In other words, every k-server algorithm can be simulated by a lazy algorithm, without additional cost. We therefore assume throughout the paper that k-server/k-finger executions are lazy. Consider some (lazy) k-finger execution ( ~f , ~') in tree T, for access sequence X. We can view ~f as an explicit sequence of elementary steps S = S k , where in each step we move one of the fingers to its parent or to one of its children in T. We further allow S to contain rotations at a finger in T (although k-finger strategies as described above do not generate rotations). The position of a finger is maintained during a rotation. T, ~f ,~' We show how S can be simulated in a standard dynamic BST. If in S a finger visits a node, then the (single) pointer in the BST also visits the corresponding node, therefore all accesses are correctly served in the BST. Every elementary step in S is mapped to (amortized) O(log k) elementary steps (pointer moves and rotations) in the BST. This immediately implies Theorem 2, since, if we can simulate an arbitrary k-finger execution, then indeed we can simulate the optimal k-finger execution on the best static tree. Assuming that the intial conditions T and ~' are known, the steps of S are simulated one-by-one, without any lookahead. Thus, insofar as the k-finger execution is online, the BST execution is also online (this fact is used in § 3). Let us describe simulation by a standard BST T 0 of a k-finger execution S in a BST T. The construction is a refinement of the one given by Demaine et al. [18], see also [19]. (We improve the overhead factor from O(k) to O(log k).) The main ingredients are: (1) Making sure that each item with a finger on it in T has depth at most O(log k) in T 0. (In [18], each finger may have depth up to O(k) in T 0.) (2) Implementing a deque data structure within T 0 so that each finger in T can move to any of its neighbors, or perform a rotation, with cost O(log k) amortized. (In [18], this cost is O(1) amortized.) Given these ingredients, to move a finger f to its neighbor x in T, we can simply access f from the root of T 0 in O(log k) steps, and then move f to x in T 0 in O(log k) amortized steps, with a similar approach for a rotation at f. Hence, the overhead factor is O(log k). We sketch the main technical ideas, postponing the details to Appendix A. Consider the tree S induced by the current fingers and the paths connecting them in T. The tree S consists of finger-nodes and non-finger nodes of degree 3 (both types of nodes are called pseudo-fingers), and paths of non-finger nodes of degree 2 connecting pseudo-fingers with each other, called tendons. Tendons can be compressed into a BST structure that allows their traversal between the two endpoints in O(1) steps. We maintain S as a root-containing subtree of our BST T 0, called the hand. Due to the compression of the tendons, the relevant part of S has size O(k). The description so far, including the terminology, is identical to the one in [18, § 2]. Our construction differs in the arXiv 2018 XX:8 Multi-finger binary search trees fact that it maintains the hand, i.e. the compressed representation of S as a balanced BST. This guarantees the reachability of fingers in O(log k) instead of O(k) steps, i.e. property (1). When a finger in T moves or performs a rotation, the designation of some (pseudo)finger, or tendon nodes may change. Such changes can be viewed as the insertion or deletion of items in the tendons. As these operations happen only at certain places within the tendons, they can be implemented efficiently. We implement tendons with the same BST-based deque as [18]. The construction appears to be folklore, we describe it in Appendix A.1 for completeness. We depart again from [18], as the operation affecting the (pseudo)finger and tendon nodes can trigger a re-balancing of the hand, which may again require O(log k) operations to fix, i.e. property (2). Any efficient balancing strategy (e.g. red-black tree) may be used. 3 Online simulation of multi-finger BSTs (Theorem 3) Consider the optimal (offline) k-finger execution ~f for access sequence X ∈ [n]m, with static reference tree T and initial finger-placement ~'. We wish to simulate it by a dynamic online BST. The construction proceeds in two stages: (1) A simulation of ~f by a sequence S of steps that describe finger-movements and rotations-at-fingers, starting from an arbitrary BST T0 and arbitrary finger locations ~'0. The sequence S is online, i.e. it is constructed without knowledge of the optimal initial state T,~', and it correctly serves the sequence X, as its elements are revealed one-by-one. (2) A step-by-step simulation of S by a standard BST algorithm using the result of § 2. Since S is online, the BST algorithm is also online. As before, we denote by Fk(X) = Fk T, ~f ,~'(X) the cost of the optimal offline execution. Observe that this is exactly the k-server optimum with the tree metric defined by T and initial configuration of servers ~'. If T and ~' were known, we could conclude part (1) by running an arbitrary online k-server algorithm defined on tree metrics. To this end, we mention two online k-server algorithms, the deterministic "double coverage" algorithm of Chrobak and Larmore [14] (Algorithm A) and the very recently announced randomized algorithm of Lee [35, 12] (Algorithm B). It is known that the cost of Algorithms A, resp. B is at most k-times, resp. O((log k)6) times Fk. We only describe Algorithm A, as it is particularly intuitive. To obtain the claimed result, we need the much more complex Algorithm B. (By using Algorithm A we get an overall factor O(k log k).) During the execution of Algorithm A, given a current access request xt, call those servers (fingers) active, whose path to xt in T does not contain another server. If several servers are in the same location, one of them is chosen arbitrarily to be active. Algorithm A serves xt as follows: as long as there is no server on xt, move all active servers one step closer to xt. Observe that as servers move, some of them may become inactive. Algorithm A (as described) may need to move multiple servers during one access. It can, however, easily be transformed into a lazy algorithm, as discussed in § 2. Remains the issue that the optimal initial T and ~' are not known. Let B1, . . . , BN be instances of an online k-server algorithm (in our case Algorithm B), one for each combination of initial tree T and initial server-placement ~'. Note that N = O(4n · nk). Let M be a "meta-algorithm" that simulates all Bj's for j = 1, . . . , N, competitive on sufficiently long input with the best Bj. Algorithm M processes X in epochs of length M = n log n, executing in the i-th epoch, for i = 1, . . . ,dm/Me, some Bτ(i) according to a (randomized) choice τ(i). Suppose that ~'∗ and T ∗ describe the state of Bτ(i) chosen by M at the beginning of the i-th epoch. To switch to the state ~'∗, T ∗, M takes O(n log n) elementary steps: (1) rotate the current tree to a balanced tree using any of the fingers (O(n) steps), (2) move all fingers P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:9 to their location in ~'∗ (k times O(log n) steps), (3) use an arbitrary finger f to rotate the tree to T ∗ (O(n) steps), (4) move f back to its location in ~'∗ (O(n) steps). Since M = n log n, the cost of switching can be amortized over the epoch. The choice of Bτ(i) for epoch i is done according to the multiplicative-weights (MW) technique [1], based on the past performance of the various algorithms. Our experts are the online executions B1, . . . , BN, our i-th event is the portion of X revealed in the i-th epoch, the loss of the j-th expert for the i-th event is the cost of Bj in the i-th epoch. Let Cmax denote the maximum possible loss of an expert for an event (we may assume Cmax ≤ n · M). It follows from the standard MW-bounds [1, Thm. 2.1], that for an arbitrary ε ∈ (0, 1), the cost of M on X is at most minj(1 + ε)Cj + Cmax · ln N , where Cj is the cost of expert Bj for the entire X; in particular, Bj may correspond to the optimal offline choice ~', T, in which case Cj = O((log k)6) · Fk(X). Thus, for e.g. ε = 1/2, we obtain that the cost of M on X is at most O((log k)6) · Fk(X) + O(n3 log2 n). The output of M is an online sequence SM of rotations and finger moves, starting from an arbitrary initial state T0 and ~'0. Note that while M needs to evaluate the costs and current states for all experts in all epochs (an extraordinary amount of computation), only one of the experts interacts with the tree at any time. Thus, SM is a standard sequence of steps which can be simulated by a standard BST algorithm according to Theorem 2, at the cost of a further O(log k) factor. This concludes the proof of Theorem 3. ε Applications of the multi-finger property 4 In this section we show that every BST algorithm that satisfies the k-finger property also satisfies the unified bound with fixed time-window (Application 1), is efficient on decomposable sequences (Application 2), and on generalized monotone sequences (Application 3). Application 1. Combined space-time sensitivity (Theorem 4). Recall the definition of UB' in Theorem 1 for a sequence X = (x1, . . . , xm) ∈ [n]m. We connect this quantity with the k-finger cost, from which Theorem 4 immediately follows. (cid:73) Theorem 7. For every ', F ('!)(X) = O('!) · UB'(X). Since we are only concerned with the case when ' is constant, we may drop the term ρt(xt0) in the definition of UB' (whose value is always between 1 and '). We prove Theorem 7 via another bound in which distances are measured in a static reference BST: '-DistTreeT (X) = min i−'≤j<i {dT (xi, xj) + 1}. 10 mX i=1 (cid:73) Lemma 8. minT '-DistTreeT (X) = O(UB'(X)). Proof. By [46, Thm. 4.7], there is a randomized BST T such that the expected distance between elements i and j is E[d T (i, j)] = Θ(log i − j). Therefore, mX mX '-DistTreeT (X) ≤ E[ E[ min i−'≤j<i {d T (xi, xj) + 1}] min i−'≤j<i i=1 min i−'≤j<i {E[d T (xi, xj) + 1]} = {O(log xi − xj)} = O(UB'(X)). (cid:74) min T ≤ mX i=1 {d T (xi, xj) + 1}] = mX min i−'≤j<i i=1 i=1 10 We let x0 denote the root of T , and distances involving negative indices are defined to be +∞. arXiv 2018 XX:10 Multi-finger binary search trees It is now sufficient to show that F('!) describe an ('!)-finger strategy in T for serving X with the given cost. T (X) = O('!) · '-DistTreeT (X), for all X and T, i.e. to At a high level, our strategy is the following: (1) Define a virtual tree T (X) whose nodes are the requests xi for i = 1, . . . , m. The virtual tree captures the proximities between the requests, with each xi having as parent the nearest request xj within a fixed time-window before time i. Edges in T (X) are given as weights the distances between requests in T. Note that the virtual tree is not necessarily binary. (2) Define a recursive structural decomposition of the tree T (X), with the property that certain blocks of this decomposition contain requests in non-overlapping time-intervals. (3) Describe a multi-finger strategy on T (X) for serving the requests, which induces a multi-finger strategy on T with the required cost. (The strategy takes advantage of the decomposition in (2).) We describe the steps more precisely, deferring some details to Appendix B. The virtual tree. Given a number ', X ∈ [n]m, and a BST T over [n] with root r, the virtual tree T = T (', T, X) is a rooted tree with vertex-set {(i, xi) i ∈ [m]} ∪ {(0, x0)}, where x0 = r is the root of T and (0, x0) is the root of T . The parent of a non-root vertex (i, xi) in T is (j, xj) = arg minj∈[i−',i){dT (xi, xj)}. In words, (j, xj) is the request at most ' steps before (i, xi), closest to xi (in T). For each edge e = ((j, xj), (i, xi)), we define the weight wT (e) = dT (xi, xj) + 1. For each subtree H of T , let wT (H) be the total weight of its edges. Observe that wT (T ) = '-DistTreeT (X). Structure and decomposition of the virtual tree. We say that a vertex (i, xi) is before (or earlier than) (j, xj) if i < j, otherwise it is after (or later than). For every subtree H of T we denote the earliest vertex in H as start(H) and the latest vertex in H as end(H). The time-span of H, denoted span(H), is (t1, t2] where (t1, xt1) = start(H) and (t2, xt2) = end(H), and H is active at time t if t ∈ span(H). We describe a procedure to decompose T (', T, X) into directed paths (for the purpose of analysis), defining the key notions of i-body and i-core. The procedure is called on a subtree H of T , and the top-level call is decompose(T , '). procedure decompose(H, i): 1. If H has no edges, return. 2. Let C(H) be the path from start(H) to end(H). 3. Call C(H) an i-core of H, and call H the i-body of C(H). 4. For each connected component H0 in H \ C(H) invoke decompose(H0, i − 1). Observe that T itself is an '-body. Each i-body H consists of its i-core C(H) and a set of (i − 1)-bodies that are connected components in H \ C(H). For each of those (i − 1)-bodies H0, we say that H is a parent of H0, defining a tree-structure over bodies. Observe that the number of ancestor bodies of an i-body (excluding itself) is ' − i. We make a sequence of further structural observations about the virtual tree and its decomposition. (cid:73) Lemma 9 (B.1). (ii) The i-cores of the decomposition, for 1 ≤ i ≤ ', partition the vertices of T . (iii) Let H be an i-body. At any time during the time-span of H, among the (i − 1)-bodies with parent H at most i − 1 are active. (iv) Let H be an i-body. The (i − 1)-bodies with parent H can be partitioned into (i − 1) groups H1, . . . ,Hi−1 such that, for 1 ≤ j ≤ i − 1 and H0, H00 ∈ Hj, the time-spans of H0 and H00 are disjoint. (i) At every time t, there are at most ' active edges in T (', T, X). P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:11 The strategy for moving fingers. For two vertices (i, xi) and (j, xj) in the virtual tree T = T (', T, S), moving a finger f from (i, xi) to (j, xj) means the following: let P = ((i1, xi1), . . . , (ik, xik)) be the unique path from (i, xi) = (i1, xi1) to (j, xj) = (i', xi') in T . For j = 1, . . . , k − 1, we iteratively move a finger f from xij to xij+1 using dT (xij , xij+1) steps. Hence, the total number of steps is at most wT (P). By serving an access in an i-body H, we mean that, for each (j, xj) ∈ V (H), at time j there is a finger move to xj in T. For each i ≤ ', let nf(i) be the number of fingers used for serving accesses in an i-body. We define nf(1) = 1 and nf(i) = 1 + (i − 1) · nf(i − 1), thus, by induction, nf(i) ≤ i! for all i ≤ '. We now describe the strategy for moving fingers. Let F be a set of fingers where F = nf('). At the beginning all fingers are at (0, x0). (In the reference tree T, all fingers are initially at the root x0.) For 1 ≤ j ≤ m, we call access(T , F, (j, xj)), defined below for an i-body H, set of fingers F, and u ∈ V (H). 1, . . . , H0 ') = (a1, a2] and span(H0 move F from end(H) to start(H). '0}. For each ', if span(H0 procedure access(H, F, u): Let C = C(H) be the i-core of H, with C = {u1, . . . , uk0}, where uk is before uk+1 for each k. For 1 ≤ j ≤ i − 1, let Hj be the j-th group of the (i − 1)-bodies with parent H (Hj defined in Lemma 9(iv)). The i-bodies in Hj are ordered by their time-span. That is, suppose Hj = {H0 '+1) = (b1, b2], then a2 ≤ b1. Fingers in F are divided into i groups F1, . . . , Fi−1,{fi}, where Fj = nf(i−1), for j ≤ i − 1, and fi is a single finger. 1. If u ∈ C, then move fi to u from the predecessor node of u in C. If u = end(H), then 2. Else let u ∈ V (H0)\ V (C) where H0 ∈ Hj. If u = start(H0) and H0 is the first (i−1)-body in Hj, move Fj from start(H) to start(H0). Perform access(H0, Fj, u). If u = end(H0) and if H0 is the last in Hj then move Fj from start(H0) to end(H). Otherwise, if u = end(H0) and there is a next (i − 1)-body H00 in Hj, then move Fj from start(H0) to start(H00). In order to give the reader more intution, we give an alternative description. A 1-body H consists only of its 1-core C(H). We use one finger and move it through C(H). For i > 1, an i-body H decomposes in its i-core C(H) and i − 1 groups H1 to Hi−1 of (i − 1)-bodies. Initially, we have nf(i) fingers on start(H). We use one finger to move down the i-core. We use a group Fj of nf(i − 1) fingers for the j-group Hj. Let H1, . . . Hp be the (i − 1)-cores in Hj. We first move Fj to start(H1). Then we use the strategy recusively to move Fj through H1. Once the group of fingers has reached end(H1), we move them to start(H2), and so on. Once the fingers have reached end(Hp), we move them back to start(H). We coordinate (this is not really necessary) the movement of the fingers by the order of the accesses in the access sequence X. From the description of access it is clear that all accesses in T are served and that nf(') fingers are sufficient. It remains to bound the total number of steps all fingers move. For an i-body H, let cost(H) be the total cost of calling access(H, F, u) for all u ∈ H. Let H denote the set of (i − 1)-bodies with parent H. Let C+(H) denote the i-core C(H) augmented with the edges connecting C(H) to the (i − 1)-bodies in H. Then: (cid:73) Lemma 10 (B.2). cost(H) ≤ 2 · nf(i) · wT (C+(H)) +P H0∈H cost(H0). By induction, we obtain cost(H) ≤ 2 · i! · wT (H). (For i = 1 we have H = C(H).) Since nf(') ≤ '!, we have that F('!) have cost(T ) ≤ 2 · ('!) · wT (T ) = 2 · ('!) · '-DistTreeT (X), concluding the proof. (X) ≤ cost(T ). By the previous claim we T (X) ≤ Fnf(') T arXiv 2018 XX:12 Multi-finger binary search trees blocks [ai, bi] such that (S Application 2. Decomposable sequences (Theorem 5). Let σ = (σ(1), . . . , σ(n)) be a permutation. For a, b : 1 ≤ a < b ≤ n, we say that [a, b] is a block of σ if {σ(a), . . . , σ(b)} = {c, . . . , d} for some integer c, d ∈ [n]. A block partition of σ is a partition of [n] into k i[ai, bi]) ∩ N = [n]. For such a partition, for each i = 1, . . . , k, consider a permutation σi ∈ Sbi−ai+1 obtained as an order-isomorphic permutation when restricting σ on [ai, bi]. For each i, let qi ∈ [ai, bi] be a representative element of i. The permutation σ ∈ [k]k that is order-isomorphic to {σ(q1), . . . , σ(qk)} is called a skeleton of the block partition. We may view σ as a deflation σ[σ1, . . . , σk]. A permutation σ is d-decomposable if σ = (1), or σ = σ[σ1, . . . , σd0] for some d0 ≤ d and each permutation σi is d-decomposable (we refer to [13] for alternative definitions). Permutations that are 2-decomposable are called separable [7], and this class includes preorder traversal sequences [49] as a special case. for serving a d-decomposable sequence X in T with cost O(log d) · X. (Appendix C.) To show Theorem 5, it is sufficient to define a reference tree T and a one-finger strategy Combined with the Iacono-Langerman result [28] that Greedy BST has the lazy finger property, we conclude that the cost of Greedy on any d-decomposable sequence X is at most O(log d) · X. The result is tight and strengthens our earlier bound [13] of X · 2O(d2). Application 3. Generalized monotone sequences. A sequence X ∈ [n]m is k-monotone, if it can be partitioned into k subsequences (not necessarily contiguous), all increasing or all decreasing. This property has been studied in the context of adaptive sorting, and special- purpose structures have been designed to exploit the k-monotonicity of input sequences (see e.g. [41, 36]). Our results show that BSTs can also adapt to such structure. (cid:73) Theorem 11. Let X be a k-monotone sequence. Then Fk(X) = O(k) · X. It follows that OPT(X) ≤ O(k log k) · X for k-monotone sequences.11 The simulation is straightforward. Let {X1, . . . , Xk} be a partitioning of X into increasing sequences (such a partition can be found online). Let T be an arbitrary static BST over [n]. Consider k fingers f1, . . . , fk, initially all on 1. For accessing xj ∈ Xi, move finger fi to xj. Observe that over the entire sequence X, each finger does only an in-order traversal of T, taking O(n) steps. Thus, Fk A lower bound of Ω(n log k) follows from enumerative results: for sufficiently large n, the number of k-monotone permutations X ∈ [n]n is at least kΩ(n) (implied by e.g. [45]). Therefore, by a standard information-theoretic argument (see e.g. [5, Thm. 4.1]), there exists a k-monotone permutation X ∈ [n]n with OPT(X) = Ω(n log k). T (X) = O(nk). Further results. We state our hierarchy result (Theorem 6), also implying a weak separation between k-finger bounds and "monotone" bounds. (cid:73) Theorem 12 (Appendix E). For all k and infinitely many n, there is a k-monotone sequence Sk of length n, such that: F k−1(Sk) = Ω( n F k(Sk) = O(n) (independent of k). In addition, we show a separation between the k-finger property and the working set property, showing that for all k and infinitely many n, there are sequences S and S0 of length n, such that WS(S) = o(Fk(S)), and Fk(S0) = o(WS(S)). (Appendix F.) k log(n/k)) 11 The result holds, in fact, for the more general case, when each Xi is either increasing or decreasing. P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:13 Acknowledgements Parinya Chalermsook is supported by European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (grant agreement No. 759557) and by Academy of Finland Research Fellows, under grant No. 310415. László Kozma is supperted through ERC consolidator grant No. 617951. Thatchaphol Saranurak is supported by European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme under grant agreement No 715672, and by the Swedish Research Council (Reg. No. 2015-04659). We thank Nikhil Bansal and Greg Koumoutsos for insightful discussions. arXiv 2018 XX:14 Multi-finger binary search trees A Offline BST simulation A.1 BST simulation of a deque (cid:73) Lemma 13. The minimum and maximum element from a BST-based deque can be deleted in O(1) amortized operations. Proof. The simulation is inspired by the well-known simulation of a queue by two stacks with constant amortized time per operation ([39, Exercise 3.19]). We split the deque at some position (determined by history) and put the two parts into structures that allow us to access the first and the last element of the deque. It is obvious how to simulate the deque operations as long as the sequences are non-empty. When one of the sequences becomes empty, we split the other sequence at the middle and continue with the two parts. A simple potential function argument shows that the amortized cost of all deque operations is constant. Let '1 and '2 be the length of the two sequences, and define the potential Φ = '1 − '2. As long as neither of the two sequences are empty, for every insert and delete operation both the cost and the change in potential are O(1). If one sequence becomes empty, we split the remaining sequence into two equal parts. The decrease in potential is equal to the length of the sequence before the splitting (the potential is zero after the split). The cost of splitting is thus covered by the decrease of potential. The simulation by a BST is easy. We realize both sequences by chains attached to the root. The right chain contains the elements in the second stack with the top element as the right child of the root, the next to top element as the left child of the top element, and so on. (cid:74) A.2 Extended hand To describe the simulation precisely, we borrow terminology from [18, 19]. Let T be a BST with a set F of k fingers f1, . . . , fk. For convenience we assume the root of T to be one of the fingers. Let S(T, F) be the Steiner tree with terminals F. A knuckle is a connected component of T after removing S(T, F), i.e. a hanging subtree of T. Let P(T, F) be the union of fingers and the degree-3 nodes in S(T, F). We call P(T, F) the set of pseudofingers. A tendon τx,y is the path connecting two pseudofingers x, y ∈ P(T, F) (excluding x and y) such that there is no other z ∈ P(T, F) inside. We assume that x is an ancestor of y. The next terms are new. For each tendon τx,y, there are two half tendons, τ < x,y, τ > x,y containing all elements in τx,y which are less than y and greater than y respectively. Let H(T, F) = {τ < For each τ ∈ H(T, F), we can treat τ as an interval [min(τ), max(τ)] where min(τ), max(τ) are the minimum and maximum elements in τ respectively. For each f ∈ P(T, F), we can treat f as an trivial interval [f, f]. Let E(T, F) = P(T, F) ∪ H(T, F) be the set of intervals defined by all pseudofingers P(T, F) and half tendons H(T, F). We call E(T, F) an extended hand12. Note that when we treat P(T, F) ∪ H(T, F) as a set of elements, such a set is exactly S(T, F). So E(T, F) can be viewed as a partition of S(T, F) into pseudofingers and half-tendons. Figure 1 illustrates these definitions. We first state two facts about the extended hand. x,y, τ > x,y τx,y is a tendon} be the set of all half tendons. (cid:73) Lemma 14. Given any T and F where F = k, there are O(k) intervals in E(T, F). 12 In [18], the hand is defined only over the pseudofingers. P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:15 Figure 1 The pseudofingers are b, d, and h. The half-tendons τ < intervals in E(T, F ) are [a, a], [b, b], [c, c], [d, d], [f, g], and [h, h]. h,b and τ > h,b are a and g, f. The Proof. Note that P(T, F) ≤ 2k because there are k fingers and there can be at most k nodes with degree 3 in S(T, F). Consider the graph where pseudofingers are nodes and tendons are edges. That graph is a tree. So H(T, F) = O(k) as well. (cid:74) (cid:73) Lemma 15. Given any T and F, all the intervals in E(T, F) are disjoint. Proof. Suppose that there are two intervals τ, x ∈ E(T, F) that intersect each other. One of them, say τ, must be a half tendon. Because the intervals of pseudofingers are of length zero and they are distinct, they cannot intersect. We write τ = {t1, . . . , tk} where t1 < ··· < tk. Assume w.l.o.g. that ti is an ancestor of ti+1 for all i < k, and so tk is an ancestor of a pseudofingers f where tk < f. Suppose that x is a pseudofinger and tj < x < tj+1 for some j. Since tj is the first left ancestor of tj+1, x cannot be an ancestor of tj+1 in T. So x is in the left subtree of tj+1. But then tj+1 is a common ancestor of two pseudofingers x and f, and tj+1 must be a pseudofinger which is a contradiction. Suppose next that x = {x1, . . . , x'} is a half tendon where x1 < ··· < x'. We claim that either [x1, x'] ⊂ [tj, tj+1] for some j or [t1, tk] ⊂ [xj0, xj0+1] for some j0. Suppose not. Then there exist two indices j and j0 where tj < xj0 < tj+1 < xj0+1. Again, xj0 cannot be an ancestor of tj+1 in T, so xj0 is in the left subtree of tj+1. We know either xj0 is the first left ancestor of xj0+1 or xj0+1 is the first right ancestor of xj0. If xj0 is an ancestor of xj0+1, then xj0+1 < tj+1 which is a contradiction. If xj0+1 is the first right ancestor of xj0, then tj+1 is not the first right ancestor of xj0 and hence xj0+1 < tj+1 which is a contradiction again. Now suppose w.l.o.g. [x1, x'] ⊂ [tj, tj+1]. Then there must be another pseudofinger f0 in the (cid:74) left subtree of tj+1, hence τ cannot be a half tendon, which is a contradiction. A.3 The structure of the simulating BST In this section, we describe the structure of the BST T 0 that we maintain given a k-finger BST T and the set of fingers F. For each half tendon τ ∈ H(T, F), let T 0 τ be the tree with min(τ) as a root which has max(τ) as a right child. max(τ)'s left child is a subtree containing the remaining elements τ \ {min(τ), max(τ)}. We implement a BST simulation of a deque on this subtree as defined in Appendix A.1. By Lemma 15, intervals in E(T, F) are disjoint and hence they are totally ordered. Since E(T, F) is an ordered set, we can define T 0 E0 to be a balanced BST such that its elements correspond to elements in E(T, F). Let T 0 E be the BST obtained from T 0 E0 by arXiv 2018 abcddfgh XX:16 Multi-finger binary search trees replacing each node a in T 0 τ. That is, suppose that the parent, left child, and right child are aup, al and ar respectively. Then the parent in T 0 E of min(τ) is al and the right child in T 0 E0 that corresponds to a half tendon τ ∈ H(T, F) by T 0 τ which is min(τ) is aup. The left child in T 0 E of max(τ) is ar. E as its top part and each knuckle of T hangs from T 0 E of the root of T 0 The BST T 0 has T 0 E, and hence in T 0. way. (cid:73) Lemma 16. Each element corresponding to pseudofinger f ∈ P(T, F) has depth O(log k) in T 0 Proof. By Lemma 14, E(T, F) = O(k). So the depth of T 0 corresponding to a pseudofinger f ∈ P(T, F), observe that the depth of a in T 0 twice the depth of a in T 0 E0 is O(log k). For each node a E is at most (cid:74) E0 by the construction of T 0 E. E in a determined A.4 The cost for simulating the k-finger BST We finally prove the claim on the cost of our BST simulation, which immediately implies Theorem 2. That is, we prove that whenever one of the fingers in a k-finger BST T moves to its neighbor or rotates, we can update the maintained BST T 0 to have the structure as described in the last section with cost O(log k). We state two observations which follow from the structure of our maintained BST T 0 τ with cost O(1) amortized. described in A.3. The first observation follows immediately from Lemma 13. (cid:73) Lemma 17. For any half tendon τ ∈ H(T, F), we can insert or delete the minimum or maximum element in T 0 Next, it is convenient to define a set A, called active set, as a set of pseudofingers, the roots of knuckles whose parents are pseudofingers, and the minimum or maximum of half tendons. (cid:73) Lemma 18. When a finger f in a k-finger BST T moves to its neighbor or rotates with its parent, the extended hand E(T, F) = P(T, F) ∪ H(T, F) is changed as follows. 1. There are at most O(1) half tendons τ ∈ H(T, F) whose elements are changed. Moreover, for each changed half tendon τ, either the minimum or maximum is inserted or deleted. The inserted or deleted element a was or will be in the active set A. 2. There are at most O(1) elements added or removed from P(T, F). Moreover, the added or removed elements were or will be in the active set A. (cid:73) Lemma 19. Let a ∈ A be an element in the active set. We can move a to the root with cost O(log k) amortized. Symmetrically, the cost for updating the root r to become some element in the active set is O(log k) amortized. Proof. There are two cases. If a is a pseudofinger or a root of a knuckle whose parent is pseudofinger, we know that the depth of a was O(log k) by Lemma 16. So we can move a to root with cost O(log k). Next, if a is the minimum or maximum of a half tendon τ, we know that the depth of the root of the subtree T 0 τ is O(log k). Moreover, by Lemma 17, we can delete a from T 0 τ) with cost O(1) amortized. Then we move a to root with cost O(log k) worst-case. The total cost is then O(log k) amortized. The proof for the (cid:74) second statement is symmetric. (cid:73) Lemma 20. When a finger f in a k-finger BST T moves to its neighbor or rotates with its parent, the BST T 0 can be updated accordingly with cost O(log k) amortized. τ (make a a parent of T 0 P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:17 Proof. According to Lemma 18, we separate our cost analysis into two parts. For the fist part, let a ∈ A be the element to be inserted into a half tendon τ. By Lemma 19, we move a to root with cost O(log k) and then insert a as a minimum or maximum element in T 0 τ with cost O(log k). Deleting a from some half tendon with cost O(log k) is symmetric. For the second part, let a ∈ A be the element to be inserted into a half tendon τ. By E0 with (cid:74) Lemma 19 again, we move a to root and move back to the appropriate position in T 0 cost O(log k). We also need rebalance T 0 E0 but this also takes cost O(log k). Finally, we describe the BST simulation of a k-finger execution with overhead O(log k). Let A be an arbitrary k-finger execution in BST T. Whenever there is an update in T (i.e. a finger moves to its neighbor or rotates), we update the BST T 0 according to Lemma 20 with cost O(log k) amortized. The BST T 0 is maintained so that its structure is as described in Appendix A.3. By Lemma 16, we can access any finger f of T from the root of T 0 with cost O(log k). Therefore, the cost of the BST execution is at most O(log k) times the cost of A. This concludes the proof. B Missing proofs for Application 1 B.1 Proof of Lemma 9 Part (i) Suppose that there is some time t when there are '0 > ' edges {(jk, xjk), (ik, sik)}'0 k=1 such that jk < t ≤ ik for all k ≤ '0. Since each node has a unique parent, i1, . . . , i'0−1, i'0 must be distinct and hence max1≤k≤'0 ik ≥ t + '0 − 1 ≥ t + '. Thus max1≤k≤'0 jk ≥ t, a contradiction. Part (ii) By construction, the cores are edge-disjoint, and every vertex belongs to some core (the recurrence ends on singleton vertices only). It remains to show that when decompose(H, 0) is called during the execution of decompose(T , '), H has no edges, i.e. there is no i-core or i-body with i ≤ 0. To see this, define the sequence of graphs H0, . . . , H' where H' = T (', T, X), Hi−1 is a connected component of Hi\C(Hi), and H0 = H. Recall that span(K) denotes the time-span of K. By definition of C(Hi), we have span(Hi−1) ⊆ span(Hi). Suppose for contradiction that H0 has an edge. Denote span(H0) = (t1, t2], where t1 < t2. For all 0 ≤ i ≤ ', it holds that span(Hi) ⊇ (t1, t2]. Let t ∈ (t1, t2]. We have that C(Hi) contains an edge ((ai, xai), (bi, xbi)) where ai < t ≤ bi for all 0 ≤ i ≤ '. Since C(Hi) are edge-disjoint, this contradicts part (i). Part (iii) Suppose there are i active (i − 1)-bodies H0 i of H at time t. Since H is an i-body, there are ' − i ancestors A1, . . . , A'−i of H. For each of the cores C ∈ {C(H0 i), C(H), C(A1), . . . , C(A'−i)} which is a set of size ' + 1, there is an edge (a, sa), (b, sb) where a < t ≤ b. This contradicts part (i). 1), . . . , C(H0 1, . . . , H0 arXiv 2018 XX:18 Multi-finger binary search trees Part (iv) We construct the decomposition greedily. Consider the (i − 1) bodies H0 ordered by start(H0) and put H0 into the group Hj for the smallest index j such that the time-span of H0 is disjoint from the time-spans of all members of the group. Assume that this process opens up i0 > i − 1 groups. Then there are (i − 1)-bodies H0 1 to H0 i0 (one per group) such that the time-span of the i-body H intersects the time-spans of H0 1 to H0 i0, contradicting part (iii). B.2 Proof of Lemma 10 We analyze the total cost of calling access(H, F, u) for all u ∈ V (H). The total cost due to H0∈H cost(H0). The remaining operations amount to moving nf(i) fingers from start(H) to end(H) and back, along the i-core C(H). The cost of this is exactly 2·nf(i)· wT (C(H)). In addition we need to traverse, using nf(i−1) fingers, the edges connecting C(H) to start(H0), twice for all H0 ∈ H. The total cost thus recursive calls in Step 2 is accounted by the termP becomes at most 2 · nf(i) · wT (C+(H)) +P We argue now by induction that for an i-body H, we have cost(H) ≤ 2 · i! · wT (H). For H0∈H cost(H0). i = 1, H = C(H) = C+(H). Thus, by the inductive step: cost(H) ≤ 2 · nf(1) · wT (C+(H)) ≤ 2 · wT (H). For the general inductive step: cost(H) ≤ 2 · nf(i) · wT (C+(H)) + X ≤ 2 · i! · wT (C+(H)) + X ≤ 2 · i! ·(cid:16) wT (C+(H)) + X H0∈H H0∈H H0∈H = 2 · i! · wT (H). cost(H0) 2 · (i − 1)! · wT (H0) wT (H0)(cid:17) C Decomposable Sequences (cid:73) Lemma 21. Let X = (x1, . . . , xn) be a k-decomposable permutation of length n. Then F1(X) ≤ 4(X − 1)dlog ke. Proof. It is sufficient to define a reference tree T for which F1 T (X) achieves such bound. We remark that the tree will have auxiliary elements. We construct T recursively. If X has length one, then T has a single node and this node is labeled by the key in X. Clearly, F1 T (X) = 0. Otherwise, let X = X[X1, . . . , Xj] with j ∈ [k] be the outermost partition of X. Denote by Ti the tree for Xi that has been inductively constructed. Let T0 be a BST of depth at most dlog je and with j leaves. Identify the i-th leaf with the root of Ti and assign keys to the internal nodes of T0 such that the resulting tree is a valid BST. Let ri be the root of Ti, 0 ≤ i ≤ j and let r = r0 be the root of T. Then P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:19 dT (r, x1) ≤ dlog ke + dT1(r1, x1) dT (r, xn) ≤ dlog ke + dTj(rj, xn) ( dT (xt−1, xt) ≤ dT'(xt−1, xt) 2dlog ke + dT'(r', xt−1) + dT'+1(r'+1, xt) if xt−1, xt ∈ X' if xt−1 ∈ X' and xt ∈ X'+1, and hence F1 T (X) = dT (r, x0) +X ≤ 2j dlog ke + X ≤ (2j − 4j + 4 X t≥2 1≤'≤j 1≤'≤j dT (xt−1, xt) + dT (xn, r) (X') ≤ 2j dlog ke + X F1 T' X')dlog ke ≤ 4(X − 1)dlog ke , 4(X' − 1)dlog ke 1≤'≤j where the last inequality uses j ≥ 2. (cid:74) the minimum over all BSTs T that contain the keys [n] (but the size of T can be much larger D Finger bounds with auxiliary elements Recall that F(X) is defined as the minimum over all BSTs T on [n] of FT (X). It is convenient to define a slightly stronger finger bound that also allows auxiliary elements. DefinebF(X) as than n). We definebFk(X) as the k-finger bound when the tree is allowed to have auxiliary (cid:73) Theorem 22. For any integer k, Fk(X) = Θ(bFk(X)) for all X. Proof. It is clear thatbFk(X) ≤ Fk(X). We only need to show the converse. elements. We argue that the two definitions are equivalent. Let T be a BST (with auxiliary elements) such that Fk P the optimal finger strategy on T. Let [n] ∪ Q be the elements of T where Q is the set of auxiliary elements in T. For each a ∈ [n] ∪ Q, let dT (a) be the depth of key a in T, and let w(i) = 4−dT (i). For any two elements i and j and set Y ⊆ [n] ∪ Q, let wY [i : j] be the sum k∈Y ∩[i,j] w(k) of the weights of the elements in Y between i and j (inclusive). For any i, j ∈ [n] ∪ Q such that i ≤ j, we have T (X) = bFk(X). Denote by ~f log w[n]∪Q[i : j] min(w(i), w(j)) = O(dT (i, j)), where dT (i, j) is the distance from i to j in T. So, this same bound also holds when considering only keys in [n]. That is, for i, j ∈ [n], we have w[n][i : j] min(w(i), w(j)) = O(dT (i, j)). log Given the weight of {w(a)}a∈[n], the BST T 0 (without auxiliary elements) is constructed by invoking Lemma 23. We bound the term Fk m−1X t=1 w[n][xt : xσ(ft,t)] T 0(X) (using strategy ~f) by m−1X min(w(xi), w(xσ(ft,t)))) = O( T (X)) = O(bFk(X)). T 0(X) = O(Fk t=1 where X = (x1, . . . , xm). Therefore, Fk(X) ≤ Fk O(X t dT 0(xσ(ft,t), xt)) = O( lg dT (xσ(ft,t), xt)) = O(Fk T (X)) (cid:74) arXiv 2018 XX:20 Multi-finger binary search trees (cid:73) Lemma 23. Given a weight function w(·), and W =P i∈[n] w(i), there is a deterministic construction of a BST Tw such that the depth of every key i ∈ [n] is dTw(i) = O(log W w(i)). Proof. Let w1, . . . wn be a sequence of weights. We show how to construct a tree in which the depth of element ' is O(log w[1 : ']/ min(w1, w')). For i ≥ 1, let ji be minimal such that w[1 : ji] ≥ 2iw1. Then w[1 : ji − 1] < 2iw1 and w[ji−1 + 1 : ji] ≤ 2i−1w1 + wji. is a tree in which element ' has depth O(log 2i−1w1/w'). Let Ti be the following tree. The right child of the root is the element ji. The left subtree (cid:18) O spine to the left. In this way the depth of the root of Ti is O(i). The entire tree has w1 in the root and then a long right spine. The trees Ti hang off the Consider now an element ' in Ti. Assume first that ' 6= ji. The depth is i + log 2i−1w1 (cid:18) (cid:18) w[1 : '] For ' = ji, the depth is min(w1, w') min(w1, w') min(w1, w') = O i + log = O log 2i−1w1 2i−1w1 (cid:19) = O (cid:18) (cid:19) (cid:19) (cid:18) (cid:19) w' (cid:19) . (cid:18) (cid:19) O (i) = O log 2iw1 w1 = O log w[1 : ji] min(w1, wji) . (cid:74) E Proof of Theorem 6 Let n be an integer multiple of k and ' = n/k. Consider the tilted k-by-' grid Sk. More precisely, the access sequence is defined as: 1, ' + 1, . . . , ' · (k − 1) + 1, 2, ' + 2, . . . , (k − 1)' + 2,. . . , (k − 1)' + '. We denote the elements of Sk as si, for i = 1, . . . , n. To see the geometry of this sequence, one may view it as a partitioning of the keys [n] into "blocks" Bi : i = 1, . . . , k where Bi contains the keys in {'(i − 1) + 1, '(i − 1) + 2, . . . , 'i}, so we have i=1 Bi = [n]. The sequence Sk consists of an interleaving of an increasing Bi = ' and Sk with k leaves. Each leaf of T0 corresponds to the keys(cid:8)' · (i − 1) + 1 traversal of each block. (cid:73) Lemma 24. Fk(Sk) = O(n). Proof. The main idea is to use each finger to serve only the keys inside blocks and to use a separate finger for each block. (recall that there are k blocks and k fingers.) We create a reference tree T and argue that Fk T (Sk) = O(n). Let T0 be a BST of height O(log k) and i=1. The non-leafs of T0 are assigned arbitrary fractional keys that are consistent with the BST properties. For each i ∈ [k], path Pi is defined as a BST with key ' · (i − 1) + 1 (i.e. the smallest key in block Bi) at the root, where for each j = 0, . . . , (' − 1), the key '(i − 1) + j has '(i − 1) + (j + 1) as its only (right) child. The final tree T is obtained by hanging each path Pi as a left subtree of a leaf ' · (i − 1) + 1 2. The k-finger strategy is simple: The i-th finger only takes care of the elements in block Bi. The cost for the first access in block Bi is O(log k), and afterwards, (cid:74) the cost is only O(1) per access. So the total access cost is O( n (cid:9)k k log k + n) = O(n). 2 The rest of this section is devoted to proving the following: (cid:73) Theorem 25. Fk−1(Sk) = Ω( n k log(n/k)) P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:21 Let T be an arbitrary reference tree. We argue that Fk−1 (Sk) = Ω( n k log(n/k)). T A finger configuration ~f = (f(1), . . . , f(k − 1)) ∈ [n]k−1 specifies to which keys the fingers are currently pointing. Any finger strategy can be described by a sequence ~f1, . . . , ~fn, where ~ft is the configuration after element st is accessed. As before, we assume w.l.o.g. the following lazy update strategy: (cid:73) Lemma 26. For each time t, the configurations ~ft and ~ft+1 differ at exactly one position. In other words, we only move the finger that is used to access st+1. We view the input sequence Sk as having ' phases: The first phase contains the sub- sequence 1, ' + 1, . . . , '(k − 1) + 1, and so on. Each phase is a subsequence of length k that accesses keys starting in block bset1 and so on, until the block Bk. (cid:73) Lemma 27. For each phase p ∈ {1, . . . , '}, there is a time t ∈ [(p−1)k+1, p·k] such that st is accessed by finger j such that ft−1(j) and ft(j) are in different blocks, and ft−1(j) < ft(j). That is, this finger moves to the block Bb, b = t mod k, from some block Bb0, where b0 < b, in order to serve st. Proof. Consider the accesses in blocks B1, . . . , Bk in order. After the access in B1, we have a finger in B1 and hence at most k − 2 fingers in blocks B2, . . . , Bk. If the access to B2 is served by a finger being in block B1 before the acces, we are done. Otherwise, it is server by a finger being in blocks B≥2 before the access. Then we have two fingers in blocks B≤2 after the access and at most k − 3 fingers in blocks B≥3. Continuing in this way, we will find the (cid:74) desired access. For each phase p ∈ ['], let tp denote the time for which such a finger moves across the blocks from left to right; if they move more than once, we choose tp arbitrarily. Let J = {tp}' p=1. For each finger j ∈ [k − 1], each block i ∈ [k] and block i0 ∈ [k] : i < i0, let J(j, i, i0) be the set containing the time t for which finger f(j) is moved from block Bi to k = ', due to the lemma. Let P(j, i, i0) denote the phases p for which tp ∈ J(j, i, i0). block Bi0 to access st. Let c(j, i, i0) = J(j, i, i0). Notice thatP (cid:73) Lemma 28. P j,i,i0:c(j,i,i0)≥16 c(j, i, i0) ≥ n/2k if n = Ω(k4). j,i,i0 c(j, i, i0) = n Proof. There are only at most k3 triples (j, i, i0), so the terms for which c(j, i, i0) < 16 contribute to the sum at most 16k3. This means that the sum of the remaining is at least n/k − 16k3 ≥ n/2k if n satisfies n = Ω(k4). (cid:74) From now on, we consider the sets J0 and J0(j, i, i0) that only concern those c(j, i, i0) with c(j, i, i0) ≥ 16 instead. (cid:73) Lemma 29. There is a constant η > 0 such that the total access cost during the phases P(j, i, i0) is at least ηc(j, i, i0) log c(j, i, i0). Once we have this lemma, everything is done. Since the function g(x) = x log x is convex, we apply Jensen's inequality to obtain: X j,i,i0 1 J0 ηc(j, i, i0) log c(j, i, i0) ≥ η · n 2kJ0 · log(n/2kJ0). Note that the left side is the term E[g(x)], while the right side is g(E(x)). Therefore, the total access cost is at least ηn 8k log(n/2k). We now prove the lemma. arXiv 2018 XX:22 Multi-finger binary search trees Proof of Lemma 29. We recall that, in the phases P(j, i, i0), the finger-j moves from block Bi to Bi0 to serve the request at corresponding time. For simplicity of notation, we use J and C to denote J(j, i, i0) and c(j, i, i0) respectively. Also, we use f to denote the finger-j. For each t ∈ J, let at ∈ Bi be the key for which the finger f moves from at to st when accessing st ∈ Bi0. Let J = {t1, . . . , tC} such that at1 < at2 < . . . < atC. Let R be the lowest common ancestor in T of keys in [atbC/2c+1, atC]. (cid:73) Lemma 30. For each r ∈ {1, . . . ,bC/2c}, the access cost of str and stC−r is together at least min{dT (R, str), dT (R, stC−r)}. Proof. Let ur be the lowest common ancestor between atr and str. Then the cost of accessing str is at least dT (ur, str). If str is in the subtree rooted at R, then ur must be an ancestor of R (because atr < atbC/2c < atC < str) and hence dT (ur, str) ≥ dT (R, str). Thus the cost it at least dT (R, str). Otherwise, we know that str is outside of the subtree rooted at R, and so is stC−r. On the other hand, atC−r is in such subtree, so moving the finger from atC−r to (cid:74) stC−r must touch R, therefore costing at least dT (R, stC−r). element vr ∈(cid:8)str , stC−r vertex R, we conclude that this sum is at leastP Lemma 30 implies that, for each r = 1, . . . ,bC/2c, we pay the distance between some r dT (R, vr). Applying the fact that (i) vr's are different and (ii) there are at most 3d vertices at distance d from a (cid:74) (cid:9) to R. The total such costs would beP r dT (R, vr) ≥ Ω(C log C). F Working set and k-finger bounds are incomparable We show the following theorem. (cid:73) Theorem 31. (1) There exists a sequence S such that WS(S) = o(Fk(S)), and (2) There exists a sequence S 0 such that Fk(S 0) = o(WS(S 0)). The sequence S 0 above is straightforward: For k = 1, just consider the sequential access 1, . . . , n repeated m/n times. For m large enough, the working set bound is Ω(m log n). However, if we start with the finger on the root of the tree which is just a path, then the lazy finger bound is O(m). The k-finger bound is always less than lazy finger bound, so this sequence works for the second part of the theorem. The existence of the sequence S is slightly more involved (the special case for k = 1 was proved in [8]), and is guaranteed by the following theorem, the proof of which comprises the remainder of this section. (cid:73) Theorem 32. For all k = O(n1/2−), there exists a sequence S of length m such that WS(S) = O(m log k) whereas F k(S) = Ω(m log(n/k)). We construct a random sequence S and show that while WS(S) = O(m log k) with probability one, the probability that there exists a tree T such that Fk T (S) ≤ cm log3(n/k) is less than 1/2 for some constant c < 1. This implies the existence of a sequence S such that for all trees T , Fk The sequence is as follows. We have Y phases. In each phase we select 2k elements Ri = {ri j}2k j=1 uniformly at random from [n]. We order them arbitrarily in a sequence Si, and access [Si]X/2k (access Si X/2k times). The final sequence S is a concatenation of the sequences [Si]X/2k for 1 ≤ i ≤ Y . Each phase has X accesses, for a total of m = XY accesses overall. We will choose X and Y appropriately later. T (S) = Ω(m log(n/k)). P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:23 Working set bound. One easily observes that WS(S) = O(Y (2k log n+(X−2k) log(2k))), because after the first 2k accesses in a phase, the working set is always of size 2k. We choose X such that the second term dominates the first, say X ≥ 5k log n log 2k. We then have that the working set bound is O(XY log k) = O(m log k), with probability one. j, ri k-finger bound. Fix a BST T . We classify the selection of the set Ri as being d-good for T if there exists a pair ri ' ∈ Ri such that their distance in T is less than d. The following lemma bounds the probability of a random selection being d-good for T . (cid:73) Lemma 33. Let T be any BST. The probability that Ri is d-good for T is at most 8k23d/n. Proof. We may assume 8k23d/n < 1 as the claim is void otherwise. We compute the probability that a selection Ri is not d-good first. This happens if and only if the balls of radius d around every element ri j are disjoint. The volume of such a ball is at most 3d, so we can bound this probability as P[Ri is not d-good for T ] = Π2k−1 i=1 ⇒ P[Ri is d-good for T ] ≤ 1 − (cid:18) (cid:19) n n ≥ (cid:18) 1 − i3d (cid:19)2k (cid:19)2k (cid:18) 1 − 2k3d ≤ 1 − exp(cid:0)−8k23d/n(cid:1) 1 − 2k3d (cid:18) 1 − 2k3d (cid:18) = 1 − exp 2k ln n n ≤ 8k23d/n, (cid:19)(cid:19) where the last two inequalities follow from ln(1−x) > −2x for x ≤ 1/2 (note that 8k23d/n < 1 implies 2k3d/n ≤ 1/2) and ex > 1 + x, respectively. (cid:74) Observe that if Ri is not d-good, then the k-finger bound of the access sequence [Si]X/2k is Ω(d(X − k)) = Ω(dX). This is because in every occurrence of Si, there will be some k elements out of the 2k total that will be outside the d-radius balls centered at the current k fingers. We call the entire sequence S d-good for T if at least half of the sets Ri are d-good for T . Thus if S is not d-good, then FkT (S) = Ω(XY d). (cid:73) Lemma 34. P[S is d-good for T ] ≤(cid:16) 32k23d (cid:19)Y /2 (cid:19)(cid:18)8k23d (cid:18) Y P[S is d-good for T ] ≤ n (cid:17)Y /2 . Y /2 n ≤ 4Y /2 Proof. By the previous lemma and by definition of goodness of S, we have that (cid:18)8k23d (cid:19)Y /2 n (cid:18)32k23d n = (cid:19)Y /2 . (cid:74) The theorem now follows easily. Taking a union bound over all BSTs on [n], we have P[S is d-good for some BST T ] ≤ 4n (cid:18)32k23d (cid:19)Y /2 n . arXiv 2018 XX:24 Multi-finger binary search trees Now set Y = 2n. We have that P[∃ a BST T : FkT (S) ≤ md/4] ≤ 4n (cid:18)32k23d (cid:19)n n . Putting d = log3 n 256k2 gives that for some constant c < 1, P[∃ a BST T : FkT (S) ≤ c(m log(n/k))] ≤ 4n (cid:18)32k23d (cid:19)n n = 1/2 which implies that with probability at least 1/2 one of the sequences in our random con- struction will have k-finger bound that is Ω(m log(n/k)). The working set bound is always O(m log k). This establishes the theorem. 1 References Sanjeev Arora, Elad Hazan, and Satyen Kale. The multiplicative weights update method: a meta-algorithm and applications. Theory of Computing, 8(1):121 -- 164, 2012. 2 Nikhil Bansal, Niv Buchbinder, Aleksander Madry, and Joseph Naor. A polylogarithmic- competitive algorithm for the k-server problem. J. ACM, 62(5):40:1 -- 40:49, 2015. 3 Yair Bartal and Eddie Grove. The harmonic k-server algorithm is competitive. J. ACM, 47(1):1 -- 15, 2000. 4 Avrim Blum and Carl Burch. On-line learning and the metrical task system problem. In Proceedings of the Tenth Annual Conference on Computational Learning Theory, COLT 1997, Nashville, Tennessee, USA, July 6-9, 1997., pages 45 -- 53, 1997. 5 Avrim Blum, Shuchi Chawla, and Adam Kalai. Static optimality and dynamic search- optimality in lists and trees. Algorithmica, 36(3):249 -- 260, 2003. 7 8 6 Allan Borodin and Ran El-Yaniv. Online computation and competitive analysis. Cambridge University Press, 1998. Prosenjit Bose, Jonathan F Buss, and Anna Lubiw. Pattern matching for permutations. Information Processing Letters, 65(5):277 -- 283, 1998. Prosenjit Bose, Karim Douïeb, John Iacono, and Stefan Langerman. The power and limit- ations of static binary search trees with lazy finger. In Algorithms and Computation - 25th International Symposium, ISAAC 2014, Jeonju, Korea, December 15-17, 2014, Proceedings, pages 181 -- 192, 2014. 9 Gerth Stølting Brodal. Finger search trees. In Handbook of Data Structures and Applica- tions. 2004. 10 Mark R. Brown and Robert Endre Tarjan. Design and analysis of a data structure for representing sorted lists. SIAM J. Comput., 9(3):594 -- 614, 1980. 12 11 Mihai Bădoiu, 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. Sébastien Bubeck, Michael B. Cohen, James R. Lee, Yin Tat Lee, and Aleksander Madry. k-server via multiscale entropic regularization. In STOC, 2018. 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. 14 Marek Chrobak and Lawrence L. Larmore. An optimal on-line algorithm for k-servers on 13 trees. SIAM J. Comput., 20(1):144 -- 148, 1991. P. Chalermsook, M. Goswami, L. Kozma, K. Mehlhorn and T. Saranurak XX:25 15 R. Cole. On the dynamic finger conjecture for splay trees. part ii: The proof. SIAM Journal on Computing, 30(1):44 -- 85, 2000. 18 16 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. Erik D. Demaine, Dion Harmon, John Iacono, Daniel M. Kane, and Mihai Patraşcu. The geometry of binary search trees. In SODA 2009, pages 496 -- 505, 2009. Erik D. Demaine, John Iacono, Stefan Langerman, and Özgür Özkan. 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. Erik D. Demaine, Stefan Langerman, and Eric Price. Confluently persistent tries for efficient version control. Algorithmica, 57(3):462 -- 483, 2010. Jonathan Derryberry and Daniel Dominic Sleator. Skip-splay: Toward achieving the uni- fied bound in the BST model. In Algorithms and Data Structures, 11th International Symposium, WADS 2009, Banff, Canada, August 21-23, 2009. Proceedings, pages 194 -- 205, 2009. 19 17 20 21 Amos Fiat, Yuval Rabani, and Yiftach Ravid. Competitive k-server algorithms. J. Comput. Syst. Sci., 48(3):410 -- 428, 1994. 22 Navin Goyal and Manoj Gupta. On dynamic optimality for binary search trees. CoRR, 23 24 25 26 27 28 abs/1102.4523, 2011. 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, May 4-6, 1977, Boulder, Colorado, USA, pages 49 -- 60, 1977. John Howat, John Iacono, and Pat Morin. The fresh-finger property. CoRR, abs/1302.6914, 2013. Scott Huddleston and Kurt Mehlhorn. A new data structure for representing sorted lists. Acta Inf., 17:157 -- 184, 1982. John Iacono. Alternatives to splay trees with o(log n) worst-case access times. In Pro- ceedings of the Twelfth Annual Symposium on Discrete Algorithms, January 7-9, 2001, Washington, DC, USA., pages 516 -- 522, 2001. John Iacono. In Space-Efficient Data Structures, Streams, and Algorithms, volume 8066 of Lecture Notes in Computer Science, pages 236 -- 250. Springer Berlin Heidelberg, 2013. John Iacono and Stefan Langerman. Weighted dynamic finger in binary search trees. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, pages 672 -- 691, 2016. In pursuit of the dynamic optimality conjecture. 29 Adam Tauman Kalai and Santosh Vempala. Efficient algorithms for online decision prob- lems. J. Comput. Syst. Sci., 71(3):291 -- 307, 2005. 30 Haim Kaplan and Robert Endre Tarjan. Purely functional representations of catenable sorted lists. In Proceedings of the Twenty-Eighth Annual ACM Symposium on the Theory of Computing, Philadelphia, Pennsylvania, USA, May 22-24, 1996, pages 202 -- 211, 1996. 31 Donald E. Knuth. The Art of Computer Programming, Volume 3: (2nd Ed.) Sorting and Searching. Addison Wesley Longman Publishing Co., Inc., Redwood City, CA, USA, 1998. S. Rao Kosaraju. Localized search in sorted lists. In Proceedings of the 13th Annual ACM Symposium on Theory of Computing, May 11-13, 1981, Milwaukee, Wisconsin, USA, pages 62 -- 69, 1981. Elias Koutsoupias. The k-server problem. Computer Science Review, 3(2):105 -- 118, 2009. Elias Koutsoupias and Christos H. Papadimitriou. On the k-server conjecture. J. ACM, 42(5):971 -- 983, 1995. 33 34 32 arXiv 2018 XX:26 Multi-finger binary search trees 35 37 James R. Lee. abs/1711.01789, 2017. Fusible HSTs and the randomized k-server conjecture. CoRR, 36 Christos Levcopoulos and Ola Petersson. Sorting shuffled monotone sequences. Inf. Com- put., 112(1):37 -- 50, 1994. Joan M. Lucas. Canonical forms for competitive binary search tree algorithms. Tech. Rep. DCS-TR-250, Rutgers University, 1988. 38 Mark S. Manasse, Lyle A. McGeoch, and Daniel Dominic Sleator. Competitive algorithms for server problems. J. Algorithms, 11(2):208 -- 230, 1990. 39 K. Mehlhorn and P. Sanders. Algorithms and Data Structures: The Basic Toolbox. Springer, 2008. 40 Kurt Mehlhorn. Data Structures and Algorithms 1: Sorting and Searching, volume 1 of EATCS Monographs on Theoretical Computer Science. Springer, 1984. 42 41 Alistair Moffat and Ola Petersson. An overview of adaptive sorting. Australian Computer Journal, 24(2):70 -- 77, 1992. J.Ian Munro. On the competitiveness of linear search. In Mike S. Paterson, editor, Al- gorithms - ESA 2000, volume 1879 of Lecture Notes in Computer Science, pages 338 -- 345. Springer Berlin Heidelberg, 2000. 44 43 William Pugh. Skip lists: A probabilistic alternative to balanced trees. Commun. ACM, 33(6):668 -- 676, 1990. Prabhakar Raghavan and Marc Snir. Memory versus randomization in on-line algorithms. IBM Journal of Research and Development, 38(6):683 -- 708, 1994. 45 Amitai Regev. Asymptotic values for degrees associated with strips of Young diagrams. Advances in Mathematics, 41(2):115 -- 136, 1981. 46 Raimund Seidel and Cecilia R. Aragon. Randomized search trees. Algorithmica, 16(4/5):464 -- 497, 1996. Steven S. Seiden. A general decomposition theorem for the k-server problem. Inf. Comput., 174(2):193 -- 202, 2002. 48 René Sitters. The generalized work function algorithm is competitive for the generalized 47 2-server problem. SIAM J. Comput., 43(1):96 -- 125, 2014. 49 Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary search trees. J. ACM, 32(3):652 -- 686, 1985. 50 Robert Endre Tarjan and Christopher J. Van Wyk. An o(n log log n)-time algorithm for triangulating a simple polygon. SIAM J. Comput., 17(1):143 -- 178, 1988. 51 Athanasios K. Tsakalidis. Avl-trees for localized search. Information and Control, 67(1- 52 R. Wilber. Lower bounds for accessing binary search trees with rotations. SIAM Journal 3):173 -- 194, 1985. on Computing, 18(1):56 -- 67, 1989.
1705.02822
2
1705
2017-05-10T11:32:23
Rank Vertex Cover as a Natural Problem for Algebraic Compression
[ "cs.DS" ]
The question of the existence of a polynomial kernelization of the Vertex Cover Above LP problem has been a longstanding, notorious open problem in Parameterized Complexity. Five years ago, the breakthrough work by Kratsch and Wahlstrom on representative sets has finally answered this question in the affirmative [FOCS 2012]. In this paper, we present an alternative, algebraic compression of the Vertex Cover Above LP problem into the Rank Vertex Cover problem. Here, the input consists of a graph G, a parameter k, and a bijection between V (G) and the set of columns of a representation of a matriod M, and the objective is to find a vertex cover whose rank is upper bounded by k.
cs.DS
cs
Rank Vertex Cover as a Natural Problem for Algebraic Compression∗ S. M. Meesum† Fahad Panolan‡ Saket Saurabh†‡ Meirav Zehavi‡ Abstract The question of the existence of a polynomial kernelization of the Vertex Cover Above LP problem has been a longstanding, notorious open problem in Parameterized Complexity. Five years ago, the breakthrough work by Kratsch and Wahlstrom on representative sets has finally answered this question in the affirmative [FOCS 2012]. In this paper, we present an alternative, algebraic compression of the Vertex Cover Above LP problem into the Rank Vertex Cover problem. Here, the input consists of a graph G, a parameter k, and a bijection between V (G) and the set of columns of a representation of a matriod M , and the objective is to find a vertex cover whose rank is upper bounded by k. 1 Introduction The field of Parameterized Complexity concerns the study of parameterized problems, where each problem instance is associated with a parameter k that is a non-negative integer. Given a parameterized problem of interest, which is generally computationally hard, the first, most basic question that arises asks whether the problem at hand is fixed-parameter tractable (FPT). Here, a problem Π is said to be FPT if it is solvable in time f (k)·XO(1), where f is an arbitrary function that depends only on k and X is the size of the input instance. In other words, the notion of FPT signifies that it is not necessary for the com- binatorial explosion in the running time of an algorithm for Π to depend on the input size, but it can be confined to the parameter k. Having established that a problem is FPT, the second, most basic question that follows asks whether the problem also admits a polynomial kernel. A concept closely related to kernelization is one of polynomial compression. Here, a problem Π is said to admit a polynomial compression if there exist a problem bΠ and a polynomial-time algorithm such that given an instance (X, k) of Π, the algorithm outputs ∗Supported by Parameterized Approximation, ERC Starting Grant 306992, and Rigorous Theory of Preprocessing, ERC Advanced Investigator Grant 267959. †The Institute of Mathematical Sciences, HBNI, Chennai, India. {meesumsaket}@imsc.res.in ‡Department of Informatics, University of Bergen, Norway. {fahad.panolanmeirav.zehavi}@ii.uib.no 1 compression is a mathematical concept that aims to analyze preprocessing procedures in an equivalent instance ( bX,bk) of bΠ, where bX = bkO(1) and bk ≤ k. Roughly speaking, a formal, rigorous manner. We note that in case Π = bΠ, the problem is further said to admit a polynomial kernelization, and the output ( bX,bk) is called a kernel. The Vertex Cover problem is (arguably) the most well-studied problem in Parame- terized Complexity [10, 7]. Given a graph H and a parameter k, this problem asks whether H admits a vertex cover of size at most k. Over the years, a notable number of algorithms have been developed for the Vertex Cover problem [2, 1, 11, 25, 5, 3, 6]. Currently, the best known algorithm solves this problem in the remarkable time 1.2738k · nO(1) [6]. While it is not known whether the constant 1.2738 is "close" to optimal, it is known that unless the Exponential Time Hypothesis (ETH) fails, Vertex Cover cannot be solved in time 2o(k) · nO(1) [16]. On the other hand, in the context of kernelization, the picture is clear in the following sense: It is known that Vertex Cover admits a kernel with O(k2) ver- tices and edges [2], but unless NP ⊆ co-NP/poly, it does not admit a kernel with O(k2−ǫ) edges [9]. We remark that it is also known that Vertex Cover admits a kernel not only of size O(k2), but also with only 2k vertices [5, 20], and it is conjectured that this bound might be essentially tight [4]. It has become widely accepted that Vertex Cover is one of the most natural test beds for the development of new techniques and tools in Parameterized Complexity. Un- fortunately, the vertex cover number of a graph is generally large -- in fact, it is often linear in the size of the entire vertex set of the graph [10, 7]. Therefore, alternative parameteriza- tions, known as above guarantee parameterizations, have been proposed. The two most well known such parameterizations are based on the observation that the vertex cover number of a graph H is at least as large as the fractional vertex cover number of H, which in turn is at least as large as the maximum size of a matching of H. Here, the fractional vertex cover number of H is the solution to the linear program that minimizes Pv∈V (H) xv subject to the constraints xu + xv ≥ 1 for all {u, v} ∈ E(H), and xv ≥ 0 for all v ∈ V (H). Accord- ingly, given a graph H and a parameter k, the Vertex Cover Above MM problem asks whether H admits a vertex cover of size at most µ(H) + k, where µ(H) is the maximum size of a matching of H, and the Vertex Cover Above LP problem asks whether H admits a vertex cover of size at most ℓ(H) + k, where ℓ(H) is the fractional vertex cover number of H. On the one hand, several parameterized algorithms for these two problems have been developed in the last decade [28, 27, 8, 24, 21]. Currently, the best known algorithm for Vertex Cover Above LP, which is also the best known algorithm Vertex Cover Above MM, runs in time 2.3146k · nO(1) [21]. On the other hand, the question of the existence of polynomial kernelizations of these two problems has been a longstanding, no- torious open problem in Parameterized Complexity. Five years ago, the breakthrough work by Kratsch and Wahlstrom on representative sets has finally answered this question in the affirmative [19]. Up to date, the kernelizations by Kratsch and Wahlstrom have remained the only known (randomized) polynomial compressions of Vertex Cover Above MM 2 and Vertex Cover Above LP. Note that since ℓ(H) is necessarily at least as large as µ(H), a polynomial compression of Vertex Cover Above LP also doubles as a poly- nomial compression of Vertex Cover Above MM. We also remark that several central problems in Parameterized Complexity, such as the Odd Cycle Transversal problem, are known to admit parameter-preserving reductions to Vertex Cover Above LP [21]. Hence, the significance of a polynomial compression of Vertex Cover Above LP also stems from the observation that it simultaneously serves as a polynomial compression of additional well-known problems, and can therefore potentially establish the target problem as a natural candidate to express compressed problem instances. Recently, a higher above-guarantee parameterization of Vertex Cover, resulting in the Vertex Cover Above Lov´asz-Plummer, has been introduced by Garg and Philip [12]. Here, given a graph H and a parameter k, the objective is to determine whether H admits a vertex cover of size at most (2ℓ(H) − µ(H)) + k. Garg and Philip [12] showed that this problem is solvable in time 3k · nO(1), and Kratsch [18] showed that it admits a (randomized) kernelization that results in a large, yet polynomial, kernel. We remark that above-guarantee parameterizations can very easily reach bars beyond which the problem at hand is no longer FPT. For example, Gutin et al. [14] showed that the parameterization of Vertex Cover above m/∆(H), where ∆(H) is the maximum degree of a vertex in H and m is the number of edges in H, results in a problem that is not FPT (unless FPT=W[1]). Our Results and Methods. In this paper, we present an alternative, algebraic compres- sion of the Vertex Cover Above LP problem into the Rank Vertex Cover problem. We remark that Rank Vertex Cover was originally introduced by Lov´asz as a tool for the examination of critical graphs [22]. Given a graph H, a parameter ℓ, and a bijection between V (G) and the set of columns of a representation of a matroid M , the objective of Rank Vertex Cover is to find a vertex cover of H whose rank, which is defined by the set of columns corresponding to its vertices, is upper bounded by ℓ. Note that formal definitions of the terms used in the definition of Rank Vertex Cover can be found in Section 2. We obtain a (randomized) polynomial compression of size O(k7 + k4.5 log(1/ε))1, where ε is the probability of failure. Here, by failure we mean that we output an instance of Rank Vertex Cover which is not equivalent to the input instance. In the first case, we can simply discard the output instance, and return an arbitrary instance of constant size; thus, we ensure that failure only refers to the maintenance of equivalence. Our work makes use of properties of linear spaces and matroids, and also relies on elementary probability theory. One of the main challenges it overcomes is the conversion of the methods of Lov´asz [22] into a procedure that works over rationals with reasonably small binary encoding. 1 O hide factors polynomial in log k 3 2 Preliminaries We use N to denote the set of natural numbers. For any n ∈ N, we use [n] as a shorthand for {1, 2, . . . , n}. In this paper, the notation F will refer to a finite field of prime size. Accordingly, Fn is an n-dimensional linear space over the field F, where a vector v ∈ Fn is a tuple of n elements from the field F. Here, the vector v is implicitly assumed to be represented as a column vector, unless stated otherwise. A finite set of vectors S over the field F is said to be linearly independent if the only solution to the equation Pv∈S λvv = 0, where it holds that λv ∈ F for all v ∈ S, is the one that assigns zero to all of the scalars λv. A set S that is not linearly independent is said to be linearly dependent. The span of a set of vectors S, denoted by S (or span(S)), is the set {Pv∈S αvv : αv ∈ F}, defined over the linear space Fn. For a graph G, we use V (G) and E(G) to denote the vertex set and the edge set of G, respectively. We treat the edge set of an undirected graph G as a family of subsets of size 2 (cid:1). An independent set in a graph G is a set of vertices X such 2 of V (G), i.e. E(G) ⊆ (cid:0)V (G) that for all u, v ∈ X, it holds that {u, v} /∈ E(G). For a graph G and a vertex v ∈ V (G), we use G \ v to denote the graph obtained from G after deleting v and the edges incident with v. 2.1 Matroids Definition 1. A matroid X is a pair (U,I), where U is a set of elements and I is a set of subsets of U , with the following properties: (i) ∅ ∈ I, (ii) if I1 ⊂ I2 and I2 ∈ I, then I1 ∈ I, and (iii) if I1, I2 ∈ I and I1 < I2, then there is x ∈ (I2 \ I1) such that I1 ∪ {x} ∈ I. A set I ′ ∈ I is said to be independent; otherwise, it is said to be dependent. A set B ∈ I is a basis if no superset of B is independent. For example, Ut,n = ([n],{I : I ⊆ [n],I ≤ t}) forms a matroid known as a uniform matroid. For a matroid X = (U,I), we use E(X),I(X) and B(X) to denote the ground set U of X, the set of independent sets I of X, and the set of bases of X, respectively. Here, we are mainly interested in linear matroids, which are defined as follows. Given a matroid X = (U,I), a matrix M having U columns is said to represent X if (i) the columns of M are in bijection with the elements in U , and (ii) a set A ⊆ U is independent in X if and only if the columns corresponding to A in M are linearly independent. Accordingly, a matroid is a linear matroid if it has a representation over some field. For simplicity, we use the same symbol to refer to a matroid M and its representation. For a matrix M and some subset B of columns of M , we let M [⋆, B] denote the submatrix of M that is obtained from M be deleting all columns not in B. The submatrix of M over a subset of rows R and a subset of columns B is denoted using M [R, B]. We proceed by stating several basic definitions related to matroids that are central to our work. For this purpose, let X = (U,I) be a matroid. An element x ∈ U is called a loop if it does not belong to any independent set of X. If X is a linear matroid, then loops correspond to zero column vectors in its representation. An element x ∈ U is called 4 a co-loop if it occurs in every basis of X. Note that for a linear matroid X, an element x is a co-loop if it is linearly independent from any subset of U \ {x}. For a subset A ⊆ U , the rank of A is defined as the maximum size of an independent subset of A, that is, rankX (A) := maxI ′⊆A{I ′ : I ′ ∈ I}. We remove the subscript of rankX (A), if the matroid is clear from the context. The rank function of X is the function rank : 2U → N that assigns rank(A) to each subset A ⊆ U . Note that this function satisfies the following properties. 1. 0 ≤ rank(A) ≤ A, 2. if A ⊆ B, then rank(A) ≤ rank(B), and 3. rank(A ∪ B) + rank(A ∩ B) ≤ rank(A) + rank(B). A subset F ⊆ U is a flat if rank(F ∪ {x}) > rank(F ) for all x /∈ F . Let F be the set of all flats of the matroid X. For any subset A of U , the closure A is defined as A = TF ∈F{F : A ⊆ F}. In other words, the closure of a set is the flat of minimum rank containing it. Let F be a flat of the matroid X. A point x ∈ F is said to be in general position on F if for any flat F ′ of X, if x is contained in span(F ′ \ {x}) then F ⊆ F ′. Deletion and Contraction. The deletion of an element u from X results in a matroid X ′, denoted by X \ u, with ground set E(X ′) = E(X) \ {u} and set of independent sets I(X ′) = {I : I ∈ I(X), u /∈ I}. The contraction of a non-loop element u from X results in a matroid X ′, denoted by X/u, with ground set E(X ′) = E(X)\{u} and set of independent sets I(X ′) = {I \ {u} : u ∈ I and I ∈ I(X)}. Note that B is a basis in X/u if and only if B ∪ {u} is a basis in X. When we are considering two matroids X and X/u, then for any subset T ⊆ E(X) \ {u}, T represents the closure of T with respect to the matroid X. A matroid can be also be represented by a ground set and a rank function, and for our purposes, it is sometimes convenient to employ such a representation. That is, we also use a pair (U, r) to specify a matroid, where U is the ground set and r is rank function. Now, we prove several lemmata regarding operations on matroids, which are used later in the paper. Observation 1. Let M be a matroid, u ∈ E(M ) be a non-loop element in M and v be a co-loop in M . Then, rank(M/u) = rank(M ) − 1 and v is a co-loop in M/u. Given a matrix (or a linear matroid) A and a column v ∈ A, by moving the vector v to another vector u, we refer to the operation that replaces the column v by the column u in A. Lemma 1. Let X = (U,I) be a linear matroid, W ⊆ U , and let u, v /∈ W be two elements that are each a co-loop in X. Let X ′ be the linear matroid obtained by moving u to a general position on the flat spanned by W . Then, v is also a co-loop in X ′. 5 Proof. Let u′ denote the vector to which u was moved (that is in general position on the span of W ). Notice that the only modification performed with respect to the vectors of X is the update of u to u′. Suppose, by way of contradiction, that v is not a co-loop in X ′. Then, there exists a set of elements S ⊆ E(X ′), where v /∈ S, whose span contains v. If u′ /∈ S, then S ⊆ U , which implies that v was not a co-loop in X. Since this results in a contradiction, we have that u′ ∈ S. As u′ is in the span of W , v must be in the span of (W ∪ S) \ {u′}. Since (W ∪ S) \ {u′} ⊆ U and v /∈ (W ∪ S) \ {u′}, we have thus reached a contradiction. We remark that the proof of Lemma 1 does not require the vector u to be moved to a general position on the flat, but it holds true also if u is moved to any vector in span(W). Lemma 2. Let X = (U,I) be a matroid and u ∈ U be an element that is not a loop in X. If v ∈ U is a co-loop in X, then v is also a co-loop in the contracted matroid X/u. Proof. Suppose, by way of contradiction, that v is not a co-loop in X/u. Then, there exists an independent set I ∈ I(X/u), where v /∈ I, whose span contains v. In particular, this implies that I ∪ {v} is a dependent set in X/u. By the definition of contraction, I ∪ {u} is an independent set in X. As v is a co-loop in X, I ∪{u, v} is also an independent set in X. By the definition of contraction, I ∪ {v} is an independent set in X/u, which contradicts our previous conclusion that I ∪ {v} is a dependent set in X/u. Lemma 3 (Proposition 3.9 [13]). Let v be an element in a matroid X = (U,I), which is not a loop in X. Let T be a subset of U such that v ∈ T . Then, rankX (T ) = rankX/v(T \{v})+1. if T is a set of elements in a matroid X = (U,I) such that an element v ∈ U is contained in the span of T , then the rank of T in the contracted matroid X/v is smaller by 1 than the rank of T in X. The lemma above can be rephrased as follows: 3 Compression Our objective is to give a polynomial compression of Vertex Cover Above LP. More precisely, we develop a polynomial-time randomized algorithm that given an instance of Vertex Cover Above LP with parameter k and ε > 0, with probability at least 1 − ε outputs an equivalent instance of Rank Vertex Cover whose size is bounded by a polynomial in k and ǫ. It is known that there is a parameter-preserving reduction from Vertex Cover Above LP to Vertex Cover Above MM such that the parameter of the output instance is linear in the parameter of the original instance [19]. Thus, in order to give a polynomial compression of Vertex Cover Above LP to Rank Vertex Cover where the size of the output instance is bounded by O(k7 + k4.5 log(1/ε)), it is enough to give a polynomial compression of Vertex Cover Above MM to Rank Vertex Cover with the same bound on the size of the output instance. For a graph H, we use µ(H) 6 and β(H) to denote the maximum size of a matching and the vertex cover number of H, respectively. Let (G, k) be an instance of Vertex Cover Above MM. Let n = V (G) and In denote the n× n identity matrix. That is, In is a representation of Un,n. Notice that (G, k) is a Yes-instance of Vertex Cover Above MM if and only if (G, In, µ(G) + k), with any arbitrary bijection between V (G) and columns of In, is a Yes-instance of Rank Vertex Cover. In summary, to give the desired polynomial compression of Vertex Cover Above LP, it is enough to give a polynomial compression of instances of the form (G, In, µ(G) + k) of Rank Vertex Cover where the size of the output instance is bounded by O(k7 + k4.5 log(1/ε)). Here, the parameter is k. For instances of Rank Vertex Cover, we assume that the columns of the matrix are labeled by the vertices in V (G) in a manner corresponding to a bijection between the input graph and columns of the input matrix. As discussed above, we again stress that now our objective is to give a polynomial compression of an instance of the form (G, In, µ(G) + k) of Rank Vertex Cover to Rank Vertex Cover, which can now roughly be thought of as a polynomial kernelization. We achieve the compression in two steps. 1. In the first step, given (G, M = In, µ(G) + k), in polynomial time we either conclude that (G, In, µ(G) + k) is a Yes-instance of Rank Vertex Cover or (with high probability of success) output an equivalent instance (G1, M1, ℓ) of Rank Vertex Cover where the number of rows in M1, and hence rank(M1), is upper bounded by O(k3/2). More over we also bound the bits required for each entry in the matrix to be O(k5/2 + log(1/ε)) This step is explained in Section 3.2. Notice that after this step, the graph G1 need not be bounded by kO(1). 2. In the second step, we work with the output (G1, M1, ℓ) of the first step, and in polynomial time we reduce the number of vertices and edges in the graph G1 (and hence the number of columns in the matrix M1). That is, output of this step is an equivalent instance (G2, M2, ℓ) where the size of G2 is bounded by O(k3). This step is explained in Section 3.3. Throughout the compression algorithm, we work with Rank Vertex Cover. Notice that the input of Rank Vertex Cover consists of a graph G, an integer ℓ, and a linear representation M of a matroid with a bijection between V (G) and the set of columns of M . In the compression algorithm, we use operations that modify the graph G and the matrix M simultaneously. To employ these "simultaneous operations" conveniently, we define (in Section 3.1) the notion of a graph-matroid pair. We note that the definition of a graph- matroid pair is the same as a pre-geometry defined in [22], and various lemmas from [22] which we use here are adapted to this definition. We also define deletion and contraction operations on a graph-matroid pair, and state some properties of these operations. 7 3.1 Graph-Matroid Pairs We start with the definition of a graph-matroid pair. Definition 2. A pair (H, M ), where H is a graph and M is a matroid over the ground set V (H), is called a graph-matroid pair. Notice that there is natural bijection between V (H) and E(M ), which is the identity map. Now, we define deletion and contraction operations on graph-matroid pairs. Definition 3. Let P = (H, M ) be a graph-matroid pair, and let u ∈ V (H). The deletion of u from P , denoted by P \ u, results in the graph-matroid pair (H \ u, M \ u). If u is not a loop in M , then the contraction of u in P , denoted by P/u, results in the graph-matroid pair (H \ u, M/u). For an edge e ∈ E(H), P \ e represents the pair (H \ e, M ) We remark that matroid deletion and contraction can be done time polynomial in the size of ground set for a linear matroid. For details we refer to [13, 26]. Definition 4. Given a graph-matroid pair P = (H, M ), the vertex cover number of P is defined as τ (P ) = min{rankM (S) : S is a vertex cover of H}. For example, if M is an identity matrix (where each element is a co-loop), then τ (P ) is the vertex cover number of H. Moreover, if we let M be the uniform matroid Ut,n such that t is at least the size of the vertex cover number of H, then τ (P ) again equals the vertex cover number of H. Let P = (H, M ) be a graph-matroid pair where M is a linear matroid. Recall that M is also used to refer to a given linear representation of the matroid. For the sake of clarity, we use vM to refer explicitly to the column vector associated with a vertex v ∈ V (H). When it is clear from context, we use v and vM interchangeably. Lemma 4 (see Proposition 4.2 in [22]). Let P = (H, M ) be a graph-matroid pair and v ∈ V (H) such that the vector vM is a co-loop in M , where M is a linear matroid. Let P ′ = (H, M ′) be the graph-matroid pair obtained by moving vM to a vector vM ′ in general position on a flat containing the neighbors of v, NH (v). Then, τ (P ′) = τ (P ). Proof. Note that the operation in the statement of the lemma does not change the graph H. The only change occurs in the matroid, where we map an co-loop vM to a vector lying in the span of its neighbors. It is clear that such an operation does not increase the rank of any vertex cover. Indeed, given a vertex cover T of H, in case it excludes v, the rank of T is the same in both M and M ′, and otherwise, since vM is an co-loop, the rank of T cannot increase when M is modified by replacing vM with any other vector. Thus, τ (P ′) ≤ τ (P ). For the other inequality, let T be the set of vectors corresponding to a minimum rank vertex cover of the graph H in the graph-matroid pair P ′ (where we have replaced the vector vM by the vector vM ′). In what follows, note that as we are working with linear matroids, the closure operation is the linear span. We have the following two cases: 8 Case 1: vM ′ /∈ T In this case T is still a vertex cover of H with the same rank. Thus, τ (P ′) = rankM ′(T ) = rankM (T ) ≥ τ (P ). Case 2: vM ′ ∈ T Here, we have two subcases: • If vM ′ /∈ T \ {vM ′}, then note that τ (P ′) = rankM ′(T ) = rankM ′(T \ {vM ′}) + 1 = rankM ((T \ {vM ′}) ∪ {vM}) ≥ τ (G). The third equality follows because vM is an co-loop. • If vM ′ ∈ T \ {vM ′}, then as vM ′ is in general position on the flat of its neighbors, by definition this means that all of the neighbors of vM ′ are also present in T \ {vM ′}. Since vM and vM ′ have the same neighbors (as the graph H has not been modified), all of the neighbors of vM belong to in T \ vM ′. Thus, T \ {vM ′} is a vertex cover of H. Therefore, τ (P ′) = rankM ′(T ) = rankM ′(T ) = rankM ′(T \ vM ′) = rankM (T \ vM ′) ≥ τ (P ). The second equality crucially relies on the observation that rank of a set is equal to the rank of the span of the set. This completes the proof of the lemma. Lemma 5 (see Proposition 4.3 in [22]). Let P = (H, M ) be a graph-matroid pair, and let v be a vertex of H that is contained in a flat spanned by its neighbors. Let P ′ = P/v. Then, τ (P ′) = τ (P ) − 1. Proof. Recall that the contraction of a vertex v in P results in the graph-matroid pair P ′ = (H \ v, M/vM ), i.e. the vertex is deleted from the graph and contracted in the matroid. Denote the contracted matroid M/vM by M ′. We first prove that τ (P ) ≤ τ (P ′) + 1. Let T be a minimum rank vertex cover in P ′, i.e. rankM ′(T ) = τ (P ′). Let W be a maximum sized independent set in I(M ′) contained in T . Then, by the definition of contraction, W ∪ {v} is a maximum sized independent set in I(M ) contained in T ∪ {v}. Moreover, T ∪ {v} is a vertex cover in H, and therefore we get that τ (P ) ≤ rankM (T ∪ {v}) = W ∪ {v} = rank′ Now we prove that τ (P ′) ≤ τ (P ) − 1. Assume that T is a minimum rank vertex cover of P . In case v /∈ T , it holds that all of the neighbors of v must belong T to cover edges incident to v. By our assumption, v is in the span of its neighbors in M . Therefore, v necessarily belongs to the span of T . Note that T \{v} is a vertex cover of H ′. By Lemma 3, we have that τ (P ) = rankM (T ) = rankM ′(T \ {v}) + 1 ≥ τ (P ′) + 1. This completes the proof. M (T ) + 1 = τ (P ′) + 1. 3.2 Rank Reduction In this section we explain the first step of our compression algorithm. Formally, we want to solve the following problem. 9 Rank Reduction Input: An instance (G, M = In, µ(G) + k) of Rank Vertex Cover, where n = V (G). Output: An equivalent instance (G′, M ′, ℓ) such that the number of rows in M ′ is at most O(k3/2). Here, we give a randomized polynomial time algorithm for Rank Reduction. More precisely, along with the input of Rank Reduction, we are given an error bound ε > 0, and the objective is to output a "small" equivalent instance with probability at least 1− ε. We start with a reduction rule that reduces the rank by 2. Reduction Rule 1 (Vertex Deletion). Let (P, ℓ) be an instance of Rank Vertex Cover, where P = (G, M ) is a graph-matroid pair. Let v ∈ V (G) be a vertex such that vM is a co-loop in M . Let M1 be the matrix obtained after moving the vM to a vector vM1 in general position on the flat spanned by NG(v). Let P1 = (G, M1) and let P ′ = P1/vM1. Then output (P ′, ℓ − 1) Lemma 6. Reduction Rule 1 is safe. Proof. We need to show that (P, ℓ) is a Yes-instance if and only if (P ′, ℓ−1) is a Yes-instance, which follows from Lemmata 4 and 5. Lemma 7. Let (P, ℓ) be an instance of Rank Vertex Cover, where P = (G, M ) is a graph-matroid pair. Let (P ′, ℓ − 1) be the output of Reduction Rule 1, where P ′ = (G′, M ′). Then rank(M ′) = rank(M ) − 2. Proof. In Reduction Rule 1, we move a co-loop vM of M to a vector vM1, obtaining a matrix M1. Note that vM1 lies in the span of NG(v), and therefore vM1 is not a co-loop in M1. Hence, we have that rank(M1) = rank(M )−1. By the definition of general position, it holds that vM1 is not a loop in M1. Notice that M ′ = M1/vM1. Therefore, by Observation 1, rank(M ′) = rank(M1) − 1 = rank(M ) − 2. The following lemma explain how to apply Reduction Rule 1 efficiently. Later we will explain (Lemma 10) how to keep the bit length of each entries in the matrix bounded by polynomial in k. Lemma 8. Let M be a linear matroid with E(M ) = n and let p > 2n be an integer. Then, Reduction Rule 1 can be applied in polynomial time with success probability at least 1 − 2n p . The number of bits required for each entry in the output representation matrix is O(log p) times the number of bits required for each entry in the input representation matrix2. 2We remark that we are unaware of a procedure to derandomize the application of Reduction Rule 1. 10 Proof. Let F be the set of columns in M corresponding to NG(v). Using formal indeter- minates x = {xh : h ∈ F}, obtain a vector g(x) = Ph∈F xhh. Suppose the values of the indeterminates have been fixed to some numbers x∗ such that for any independent set I ∈ M which does not span F , I ∪ {g(x∗)} is also independent. We claim that g(x∗) is in general position on F . By definition, if g(x∗) is not in general position, then there exists a flat F ′ with g(x∗) ∈ F ′ \ {g(x∗)} but it does not contain F . Let I be a basis of F ′\{g(x∗)}, clearly I does not span F but I ∪ {g(x∗)} is a dependent set, which is a contradiction due to the choice of x∗. Let I be an independent set which does not span F . We need to select x in such a way that DR,I (x) = det(M [R, I ∪ {g(x)}]) is not identically zero for some R. First of all, note that there is a choice of R for which the polynomial DR,I (x) is not identically zero and has total degree one. This is so because DR,I (x) = Ph∈F xh det(M [R, I ∪ {h}]); if it is identically zero for every R, then det(M [R, I ∪ {h}]) = 0 which implies that every element h ∈ F is spanned by I. Thus, this case does not arise due to the choice of I. If we choose x ∈ [p]F uniformly at random, for some number p, then the probability that DR,I (x) = 0 is at most 1 p by Schwartz-Zippel Lemma. The number of independent sets in M , which does not span F , is at most 2n. By union bound, the probability that DR,I (x) = 0 for some I, an independent set of M , is at most 2n p . Therefore, the success probability is at least 1 − 2n p . most double the matrix size, this gives us the claimed bit sizes. The procedure runs in polynomial time and the process of matroid contraction can at In the very first step of applying Reduction Rule 1, the theorem above makes the bit sizes O(log p). On applying the the rule again the bit length of entries double each time due to Gaussian elimination performed for the step of matroid contraction. This can make the numbers very large. To circumvent this, we show that given a linear matroid (U,I) of low rank and where the ground set U is small, along with a representation matrix M over the field R, for a randomly chosen small prime q, the matrix M mod q is also a linear representation of M (see Lemma 9). To prove this result, we first observe that for any number n, the number of distinct prime factors is bounded by O(log n). Observation 2. There is a constant c such that number of distinct prime factors of any number n, denoted by ω(n), is at most c log n. The well-known prime number theorem implies that Proposition 1. There is a constant c such that the number of distinct prime numbers smaller than or equal to n, denoted by π(n), is at least c n log n . Lemma 9. Let X = (U,I) be a rank r linear matroid representable by an r × n matrix M over R with each entry between −nc′r(1/δ) and nc′r(1/δ) for some constants c′ and δ. Let ε > 0. There is a number c ∈ O(log 1 ε ) such that for a prime number q chosen uniformly at 11 ε random from the set of prime numbers smaller than or equal to c n2r+3(n log n+log(1/δ))2 , the matrix Mq = M mod q over R represents the matroid X with probability at least 1 − ε n . Proof. To prove that Mq is a representation of X (with high probability), it is enough to show that for any basis B ∈ B(X), the corresponding columns in Mq are linearly independent. For this purpose, consider some basis B ∈ B(X). Since B is an independent set in M , we have that the determinant of M [⋆, B], denoted by det(M [⋆, B]), is non-zero. The determinant of Mq[⋆, B] is equal to det(M [⋆, B]) mod q. Let a = det(M [⋆, B]), and let b = a mod q. The value b is equal to zero only if q is prime factor of b. Since the absolute value of each entry in M is at most nc′r(1/δ), the absolute value of a is upper bounded by r!nc′r2 (1/δ)r. By Observation 2, the number of prime factors of a is at most c1(log(r!) + c′r2 log n + r log(1/δ)) for some constant c1. The total number of bases in X is at most nr. Hence the cardinality of the set F = {z : z is a prime factor of det(M [⋆, B]) for some B ∈ B(X)} is at most nr · c1(log(r!) + c′r2 log n + r log(1/δ)) ≤ c2nr+1(n log n + log(1/δ)) for some constant c2. By Proposition 1, there is a constant c3 such that the number of prime factors less than or equal to c n2r+3(n log n+log(1/δ))2 is at least ε t = c3c n2r+3(n log n + log(1/δ))2 ε log( n2r+3(n log n+log(1/δ))2 ) ε . The probability that Mq is not a representation of X (denote it by Mq 6≡ M ) is, Pr[Mq 6≡ M ] = Pr[q ∈ F ] ≤ F t For any ε > 0, there is a number c ∈ O(log 1 ε n . This completes the proof of the lemma. c2 c3c · ≤ ε log( n2r+3(n log n+log(1/δ))2 ) nr+1(n log n + log(1/δ)) · ε ) such that the above probability is at most ε n By combining Lemmata 8 and 9, we can apply Reduction Rule 1, such that each entry in the output representation matrix has bounded value. ǫ , where c ∈ O(log 1 ǫ ). Lemma 10. Given ε > 0, Reduction Rule 1 can be applied in polynomial time with success probability at least 1 − ε n . Moreover, each entry in the output representation matrix is at most c n2r+3(n log n+log(1/ǫ))2 Proof. Let M be the input representation matrix. Let ǫ′ = ε/(2n). Now we apply Lemma 8 using p > 2n ǫ′ . Let M ′ be the output representation matrix of Lemma 8. By Lemma 8, M ′ represents M with probability at least 1 − ǫ′. Observe that the absolute values of matrix entries are bounded by the value of q as given in Lemma 9, thus each entry in M ′ has absolute value bounded by nc′n/ǫ2 for some constant c′. Now, applying Lemma 9 again completes the proof. 12 We would like to apply Reduction Rule 1 as may times as possible in order to obtain a "good" bound on the rank of the matroid. However, for this purpose, after applying Reduction Rule 1 with respect to some co-loop of the matroid, some other co-loops need to remain co-loops. Thus, instead of applying Reduction Rule 1 blindly, we choose vectors vM whose vertices belong to a predetermined independent set. To understand the advantage behind a more careful choice of the vectors vM , suppose that we are given an independent set U in the graph G such that every vertex in it is a co-loop in the matroid. Then, after we apply Reduction Rule 1 with one of the vertices in U , it holds that every other vertex in U is still a co-loop (by Lemma 1 and Observation 1). In order to find a large independent set (in order to apply Reduction Rule 1 many times), we use the following two known algorithmic results about Vertex Cover Above MM. Lemma 11 ([21]). There is a 2.3146k · nO(1)-time deterministic algorithm for Vertex Cover Above MM. Recall that for a graph G, we let β(G) denote the vertex cover number of G. Lemma 12 ([23]). For any ǫ > 0, there is a randomized polynomial-time approximation algorithm that given a graph G, outputs a vertex cover of G of cardinality at most µ(G) + O(√log n)(β(G) − µ(G)), with probability at least 1 − ǫ. In what follows, we also need the following general lemma about linear matroids. Lemma 13 ([13]). Let M be an a× b matrix representing some matroid. If M ′ is a matrix consisting of a row basis of M then M ′ represents the same matroid as M . We are now ready to give the main lemma of this subsection. Lemma 14. There is a polynomial time randomized algorithm that given an instance (G, M = In, µ(G) + k) of Rank Vertex Cover and ε > 0, with probability at least 1 − ε outputs an equivalent instance (G′, M ′, ℓ) of Rank Vertex Cover such that the number of rows in M ′ is at most O(k3/2). Here, M ′ is a matrix over the field R where each entry is O(k5/2 + log(1/ε)) bits long. Proof. Recall that n = V (G). If k ≤ log n, then we use Lemma 11 to solve the problem in polynomial time. Next, we assume that log n < k. Let δ = ε/2. Now, by using Lemma 12, in polynomial time we obtain a vertex cover Y of G of size at most µ(G) + c′√log n · k ≤ µ(G) + c′ · k3/2, with probability at least 1 − δ, where c′ is some constant. If we fail to compute such a vertex cover, then we output an arbitrary constant sized instance as output; and this will happen only with probability at most δ. Otherwise, let S = V (G) \ Y . Since Y is a vertex cover of G, we have that S is an independent set of G. Hence, S ≥ n − (µ(G) + c′ · k3/2). Since M = In, all the elements of M , including the ones in S, are co-loops in M . Now, we apply Reduction Rule 1 with the elements of S (one by one). By Lemma 1 and Observation 1, after each application of Reduction Rule 1, 13 the remaining elements in S are still co-loops. In particular, we apply Reduction Rule 1 S many times. Let (G′, M ′, ℓ) be the instance obtained after these S applications of Reduction Rule 1 using Lemma 10 (substituting ε = δ in Lemma 10). By Lemma 7, we know that after each application of Reduction Rule 1, the rank reduces by 2. Hence, rank(M ′) = rank(M ) − 2S = n − 2(cid:16)n − (µ(G) + c′ · k3/2)(cid:17) = −n + 2µ(G) + 2c′ · k3/2 ≤ 2c′ · k3/2 (because 2µ(G) ≤ n). During each application of Reduction Rule 1, by Lemma 13, we can assume that the number of rows in the representation matrix is exactly same as the rank of the matrix. Now, we return (G′, M ′, ℓ) as the output. Notice that the number of rows in M ′ is at most O(k3/2). Now, we analyze the probability of success. As finding the approximate vertex cover Y using Lemma 12 fails with probability at most δ = ε 2 , in order to get the required success probability of 1 − ε, S applications of Reduction Rule 1 should succeed with probability at least 1 − ε 2 . We suppose that the matrix M = In is over the field R. Recall that the instance (G′, M ′, ℓ) is obtained after S applications of Reduction Rule 1. The failure probability of each application of Reduction Rule 1 is at most δ n . Hence, by union bound the probability failure in at least one application of Reduction Rule 1 is at most δ. Hence the total probability of success is at least 1 − (δ + δ) = 1 − ε. By Lemma 10 each entry in the output representation matrix is at most c n2r+3(n log n+log(2/ε))2 . Hence the bits required to represent an entry in M ′ is at most O(r log n + log(2/ε)) = O(k5/2 + log(1/ε)). ε 3.3 Graph Reduction In the previous subsection we have seen how to reduce the number of rows in the matroid. In this subsection we move to second step of our compression algorithm. That is, to reduce the size of the graph. Formally, we want to solve the following problem. Graph Reduction Input: An instance (G′, M, ℓ) of Rank Vertex Cover such that the number of rows in M is at most O(k Output: An equivalent instance (G′′, M ′, ℓ) such that V (G′′),E(G′′) ≤ O(k3) 2 ) 3 Here, we give an algorithm to reduce the number of edges in the graph. Having reduced the number of edges, we also obtain the desired bound on the number of vertices (as isolated vertices are discarded). Towards this, we first give some definitions and notations. In this section, we use F to denote either a finite field or R. 14 Definition 5 (Symmetric Square). For a set of vectors S over a field F, the symmetric square, denoted by S(2), is defined as S(2) = {uvT + vuT : u, v ∈ S}, where the operation is matrix multiplication. The elements of S(2) are matrices. We can define the rank function r(2) : S(2) → Z by treating the matrices as "long" vectors over the field F. With a rank function r(2), the pair (S(2)), r(2)) forms a matroid. For details we refer the reader to [22]. The dot product of two column vectors a, b ∈ Fn is the scalar aT b and is denoted by ha, bi. Two properties of dot product are (i)ha, bi = hb, ai and (ii)ha, b + ci = ha, bi + ha, ci. Definition 6. Given a vector space Fd and a subspace F of Fd, the orthogonal space of F is defined as F ⊥ = {x ∈ Fd : hy, xi = 0 for all y ∈ F}. The following observation can be proved using associativity of matrix multiplication and dot product of vectors. Observation 3. Let u, v, w be three n-length vectors. Then, uvT w = hv, wiu. Definition 7 (2-Tuples Meeting a Flat). For a flat F in a linear matroid S (here S is a set of vectors), the set of 2-tuples meeting F is defined as F2 := {uvT + vuT : v ∈ F, u ∈ S}. For the sake of completeness, we prove the following lemmata using elementary tech- niques from linear algebra. Lemma 15 (see Proposition 2.8 in [22]). For any flat F in a linear matroid S with rank function r, it holds that F2 (the set of 2-tuples meeting F ) forms a flat in the matroid (S(2), r(2)). Proof. Suppose, by way of contradiction, that F2 is not a flat. Then, there exist a, b ∈ S such that e = abT + baT ∈ S(2) is not in F2 and As e lies in the span of F2, there exist scalars λuv such that r(2)(F2 ∪ {e}) = r(2)(F2). abT + baT = X u∈F,v∈S λuv(uvT + vuT ). (1) Note that neither a nor b belongs to F , because if at least one of them belongs to F , then e lies in F2 (by the definition of F2). Therefore, F 6= S and it is a proper subspace of S, which implies that F ⊥ is non-empty (follows from Proposition 13.2 in [17]). Pick an element x ∈ F ⊥. By right multiplying the column matrix x with the terms in Equation 1, 15 we get abT x + baT x = X hb, xia + ha, xib = X = X u∈F,v∈S u∈F,v∈S u∈F,v∈S λuv(uvT x + vuT x) λuvhv, xiu + hu, xiv λuvhv, xiu (2) The second equality follows from Observation 3, and the third equality follows from the fact that hu, xi = 0 (because u ∈ F and x ∈ F ⊥). Now, by taking dot product with x, from Equation 2, we have that 2ha, xihb, xi = X u∈F,v∈S λuvhv, xihu, xi = 0 (3) The last equality follows from the fact that hu, xi = 0. As the choice of x was arbitrary, Equations 2 and 3 hold for all x ∈ F ⊥. By Equation 3, for all x ∈ F ⊥, at least one of hb, xi or ha, xi is zero. If exactly one of hb, xi or ha, xi is zero for some x ∈ F ⊥, then at least one of a or b is a linear combination of vectors from F (by Equation 2) and hence it belongs to F , which is a contradiction (recall that we have argued that both a and b do not belong to the flat F ). Now, consider the case where both hb, xi and ha, xi are zero for all x ∈ F ⊥. Then, both a and b belong to F ⊥⊥. Since F ⊥⊥ = F (in the case F is over a finite field, see Theorem 7.5 in [15]), again we have reached a contradiction. For a graph-matroid pair P = (H, M ) (here M represents a set of vectors), define E(P ) ⊆ M (2) as E(P ) = {uvT + vuT : {u, v} ∈ E(H)}. Note that E(P ) forms a matroid with the same rank function as the one of M (2). Moreover, the elements of E(P ) are in correspondence with the edges of H. For simplicity, we refer to an element of E(P ) as an edge. Using Lemma 15, we prove the following lemma. Lemma 16 (see Proposition 4.7 in [22]). Let P = (H, M ) be a graph-matroid pair, and let r(2) be the rank function of E(P ). For an edge e that is not a co-loop in (E(P ), r(2)), it holds that τ (P \ e) = τ (P ). Proof. The deletion of edges cannot increase the vertex cover number, thus τ (P \e) ≤ τ (P ). Next, we show that it also holds that τ (P \ e) ≥ τ (P ). Let T be a vertex cover of H \ e. Notice that T is a flat in M . Denote e = {u, v} and F = T . If at least one of u or v lies in F , then F is a vertex cover of H and hence τ (P \ e) ≥ τ (P ). Hence, to conclude the proof, it is sufficient to show that at least one of u or v lies in F . Suppose, by way of contradiction, that u, v /∈ F . Then, the edge e = uvT + vuT does not belong to F2 (the set of 2-tuples meeting F ). By Theorem 16, we 16 have that F2 is a flat in (M (2), r(2)). Since F is a vertex cover of H \ e, by the definition of F2 and E(P ), we have that E(P ) \ {e} ⊆ F2. Recall that e is not a co-loop in (E(P ), r(2)). This implies that e belongs to the closure of E(P )\{e}, and hence it belongs to its superset F2. We have thus reached a contradiction. This completes the proof. Using Lemma 16, we get the following bound on the number of edges analogously to Theorem 4.6 in [22]. Lemma 17. Let (H, M, ℓ) be an instance of Rank Vertex Cover and r = rank(M ). Applying the reduction given by Lemma 16 on (H, M ) exhaustively results in a graph with 2 (cid:1) edges. at most (cid:0)r+1 Proof. Observe that the dimension of the matroid (E(P ), r(2)) is bounded by (cid:0)r+1 matroid (E(P ), r(2)), and hence the graph has at most (cid:0)r+1 the reduction given by Lemma 16 deletes any edge that is not a co-loop in this matroid. In other words, once the reduction can no longer be applied, every edge is a co-loop in the 2 (cid:1) edges. 2 (cid:1), and Lemma 17 bounds the number of edges of the graph. To bound the number of vertices in the graph, we apply the following simple reduction rule. Reduction Rule 2. Let (G, M, ℓ) is an instance of Rank Vertex Cover. For v ∈ V (G) of degree 0 in G, output (G \ v, M \ v, ℓ). Reduction Rule 2 and Lemma 17 lead us to the main result of this subsection: Corollary 1. There is a polynomial time algorithm, which given an instance (G′, M ′, ℓ) of Rank Vertex Cover such that the number of rows in M is at most O(k 2 ), outputs an equivalent instance (G′′, M ′′, ℓ) such that V (G′′),E(G′′) = O(k3). Here, M ′′ is a restriction of M ′. 3 By combining both the steps we get a polynomial compression of size O(k7 + k4.5 log(1/ε)) for Vertex Cover Above LP. 4 Conclusion In this paper, we presented a (randomized) polynomial compression of the Vertex Cover Above LP problem into the algebraic Rank Vertex Cover problem. With probability at least 1−ε, the output instance is equivalent to the original instance and it is of bit length O(k7 + k4.5 log(1/ε)). Here, the probability ε is part of the input. Recall that having our polynomial compression at hand, one also obtains polynomial compressions of additional well-known problems, such as the Odd Cycle Transversal problem, into the Rank Vertex Cover problem. Finally, we note that we do not know how to derandomize our polynomial compression, and it is also not known how to derandomize the polynomial kernelization by Kratsch 17 and Wahlstrom [19]. Thus, to conclude our paper, we would like to pose the following intriguing open problem: Does there exist a deterministic polynomial compression of the Vertex Cover Above LP problem? References [1] R. Balasubramanian, M. R. Fellows, and V. Raman. An improved fixed-parameter algorithm for vertex cover. Information Processing Letters, 65(3):163 -- 168, 1998. [2] J. F. Buss and J. Goldsmith. Nondeterminism within p. SIAM J. Comput., 22(3):560 -- 572, June 1993. [3] L. S. Chandran and F. Grandoni. Refined memorization for vertex cover. Information Processing Letters, 93(3):125 -- 131, 2005. [4] J. Chen, H. Fernau, I. A. Kanj, and G. Xia. Parametric duality and kernelization: Lower bounds and upper bounds on kernel size. SIAM J. Comput., 37(4):1077 -- 1106, Nov. 2007. [5] J. Chen, I. A. Kanj, and W. Jia. Vertex cover: Further observations and further improvements. Journal of Algorithms, 41(2):280 -- 301, 2001. [6] J. Chen, I. A. Kanj, and G. Xia. Improved upper bounds for vertex cover. Theoretical Computer Science, 411(40-42):3736 -- 3756, 2010. [7] M. Cygan, F. V. Fomin, L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, and S. Saurabh. Parameterized algorithms. Springer, 2015. [8] M. Cygan, M. Pilipczuk, M. Pilipczuk, and J. O. Wojtaszczyk. On multiway cut parameterized above lower bounds. ACM Trans. Comput. Theory, 5(1):3:1 -- 3:11, May 2013. [9] H. Dell and D. Van Melkebeek. Satisfiability allows no nontrivial sparsification unless the polynomial-time hierarchy collapses. Journal of the ACM (JACM), 61(4):23, 2014. [10] R. G. Downey and M. R. Fellows. Fundamentals of Parameterized Complexity. Texts in Computer Science. Springer, 2013. [11] R. G. Downey, M. R. Fellows, and U. Stege. Parameterized complexity: A framework for systematically confronting computational intractability. In Contemporary trends in discrete mathematics: From DIMACS and DIMATIA to the future, volume 49, pages 49 -- 99, 1999. 18 [12] S. Garg and G. Philip. Raising the bar for vertex cover: Fixed-parameter tractability above A higher guarantee. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2016,, pages 1152 -- 1166. SIAM, 2016. [13] G. Gordon and J. McNulty. Matroids: A Geometric Introduction. Cambridge Univer- sity Press, 2012. Cambridge Books Online. [14] G. Gutin, E. J. Kim, M. Lampis, and V. Mitsou. Vertex cover problem parameterized above and below tight bounds. Theory of Computing Systems, 48(2):402 -- 410, 2011. [15] R. Hill. A First Course in Coding Theory. Oxford Applied Linguistics. Clarendon Press, 1986. [16] R. Impagliazzo, R. Paturi, and F. Zane. Which problems have strongly exponential complexity? Journal of Computer and System Sciences, 63:512 -- 530, 2001. [17] S. Jukna. Extremal Combinatorics: With Applications in Computer Science. Texts in Theoretical Computer Science. An EATCS Series. Springer Berlin Heidelberg, 2011. [18] S. Kratsch. A randomized polynomial kernelization for vertex cover with a smaller parameter. In 24th Annual European Symposium on Algorithms, ESA 2016, volume 57 of LIPIcs, pages 59:1 -- 59:17. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2016. [19] S. Kratsch and M. Wahlstrom. Representative sets and irrelevant vertices: New tools In Foundations of Computer Science (FOCS), 2012 IEEE 53rd for kernelization. Annual Symposium on, pages 450 -- 459. IEEE, 2012. [20] M. Lampis. A kernel of order 2k − c log k for vertex cover. Information Processing Letters, 111(23):1089 -- 1091, 2011. [21] D. Lokshtanov, N. Narayanaswamy, V. Raman, M. Ramanujan, and S. Saurabh. Faster parameterized algorithms using linear programming. ACM Transactions on Algo- rithms (TALG), 11(2):15, 2014. [22] L. Lov´asz. Flats in matroids and geometric graphs. Combinatorial Surveys, pages 45 -- 86, 1977. [23] S. Mishra, V. Raman, S. Saurabh, S. Sikdar, and C. R. Subramanian. The com- plexity of konig subgraph problems and above-guarantee vertex cover. Algorithmica, 61(4):857 -- 881, 2011. [24] N. Narayanaswamy, V. Raman, M. Ramanujan, and S. Saurabh. Lp can be a cure for parameterized problems. In STACS'12 (29th Symposium on Theoretical Aspects of Computer Science), volume 14, pages 338 -- 349. LIPIcs, 2012. 19 [25] R. Niedermeier and P. Rossmanith. Upper bounds for vertex cover further improved. In Annual Symposium on Theoretical Aspects of Computer Science, pages 561 -- 570. Springer Berlin Heidelberg, 1999. [26] J. G. Oxley. Matroid Theory (Oxford Graduate Texts in Mathematics). Oxford Uni- versity Press, Inc., New York, NY, USA, 2006. [27] V. Raman, M. Ramanujan, and S. Saurabh. Paths, flowers and vertex cover. In European Symposium on Algorithms, pages 382 -- 393. Springer Berlin Heidelberg, 2011. [28] I. Razgon and B. O'Sullivan. Almost 2-sat is fixed-parameter tractable. Journal of Computer and System Sciences, 75(8):435 -- 450, 2009. 20
1102.1783
2
1102
2011-03-27T17:20:00
Don't Rush into a Union: Take Time to Find Your Roots
[ "cs.DS", "cs.CC" ]
We present a new threshold phenomenon in data structure lower bounds where slightly reduced update times lead to exploding query times. Consider incremental connectivity, letting t_u be the time to insert an edge and t_q be the query time. For t_u = Omega(t_q), the problem is equivalent to the well-understood union-find problem: InsertEdge(s,t) can be implemented by Union(Find(s), Find(t)). This gives worst-case time t_u = t_q = O(lg n / lglg n) and amortized t_u = t_q = O(alpha(n)). By contrast, we show that if t_u = o(lg n / lglg n), the query time explodes to t_q >= n^{1-o(1)}. In other words, if the data structure doesn't have time to find the roots of each disjoint set (tree) during edge insertion, there is no effective way to organize the information! For amortized complexity, we demonstrate a new inverse-Ackermann type trade-off in the regime t_u = o(t_q). A similar lower bound is given for fully dynamic connectivity, where an update time of o(\lg n) forces the query time to be n^{1-o(1)}. This lower bound allows for amortization and Las Vegas randomization, and comes close to the known O(lg n * poly(lglg n)) upper bound.
cs.DS
cs
Don't Rush into a Union: Take Time to Find Your Roots Mihai Patras¸cu AT&T Labs Mikkel Thorup AT&T Labs Abstract We present a new threshold phenomenon in data structure lower bounds where slightly reduced update times lead to exploding query times. Consider incremental connectivity, letting tu be the time to insert an edge and tq be the query time. For tu = Ω(tq), the problem is equivalent to the well-understood union -- find problem: INSERTEDGE(s, t) can be implemented by UNION(FIND(s), FIND(t)). This gives worst-case time tu = tq = O(lg n/ lg lg n) and amortized tu = tq = O(α(n)). By contrast, we show that if tu = o(lg n/ lg lg n), the query time explodes to tq ≥ n1−o(1). In other words, if the data structure doesn't have time to find the roots of each disjoint set (tree) during edge insertion, there is no effective way to organize the information! For amortized complexity, we demonstrate a new inverse-Ackermann type trade-off in the regime tu = o(tq). A similar lower bound is given for fully dynamic connectivity, where an update time of o(lg n) forces the query time to be n1−o(1). This lower bound allows for amortization and Las Vegas randomization, and comes close to the known O(lg n · (lg lg n)O(1)) upper bound. 1 1 0 2 r a M 7 2 ] S D . s c [ 2 v 3 8 7 1 . 2 0 1 1 : v i X r a 1 Introduction We present a new threshold phenomenon in data structure lower bounds where slightly reduced update times lead to exploding query times. Previous trade-offs where smooth and much weaker. The new explosive lower bounds are found hidden in some very well-studied problems: incremental and fully-dynamic connectivity. 1.1 Our Results The union -- find problem is to support the following operations on a collection of disjoint sets, starting from n singleton sets {1}, . . . , {n}: FIND(v) : Return an element in the same set as v that uniquely identifies the set. (This is called the root, or the representative of the set.) UNION(u, v) : Join the sets identified by u and v, assuming these are roots of their own sets. The terminology for this problem stems from the usual implementation as a forest, in which each tree represents a set. FIND involves walking to the root of v's tree, potentially doing useful work (path compres- sion). UNION simply involves adding an edge between the roots (whose direction is usually determined by the size of each subtree, cf. union by rank). The union -- find problem has been studied into excruciating detail and is now essentially understood. From an amortized perspective, Tarjan [Tar75] showed that a sequence of n − 1 unions and m finds can be supported in time O(n + mα(m, n)). See [TvL84, Pou90] for different analyses and trade-offs between amortized running times. From a worst-case perspective, the classic union-by-rank gives union in constant time and find in O(log n) time. Trade-offs were addressed by Blum [Blu86], with an improvement by Smid [Smi90]. They show that, if the time for union is bounded by tUNION, FIND can be supported in worst-case O(lg n/ lg tUNION). Finally, Alstrup et al. [ABAR99] showed that the amortized and worst-case trade-offs can be achieved simultaneously. These bounds are known to be optimal in the powerful cell-probe model (see below for a review of the lower bounds). Here we consider an obvious strengthening of the problem, where we allow: LINK(u, v) : Join the sets containing u and v if these sets are different. The link -- find problem is a natural way to solve one of the most basic graph problems: incremental connectivity. This is the problem of maintaining an undirected graph under edge insertions and connectivity queries. New edges may link arbitrary nodes, possibly introducing cycles. Two nodes are connected if they find the same identifier. We now consider the worst-case trade-offs for link-find and incremental connectivity. Since link-find solves incremental connectivity, we want upper-bounds are for link-find and lower-bounds for incremental connectivity. Let tLINK be the link time and tFIND be the find time. In the regime tLINK ≥ tFIND, the problem can be solved by union -- find, since we have time to find the roots of u and v and union them if they are different. Using the upper bounds for union -- find, we obtain tFIND = O(lg n/ lg tu), and in particular the balanced point tLINK = tFIND = O(lg n/ lg lg n). If we insist on tLINK = o(tFIND), union -- find no longer suffices. In fact, we show a surprisingly abrupt trade-off that essentially signifies the "end of data structuring" even for incremental connectivity: Theorem 1. Any data structure for incremental connectivity over n vertices that supports edge insertions in worst-case time tLINK = o( lg n lg lg n ) must have worst-case query time tFIND ≥ n1−o(1) in the cell-probe model with cells of O(lg n) bits. 1 By reduction, we get the same trade-off for link -- find. This can be contrasted with the very smooth trade- off for union -- find, tFIND = O(lg n/ lg tUNION), e.g., the standard union-by-rank with O(1)-time UNION and O(lg n)-time FIND. Our result shows a remarkable dependence of edge insertion on the FIND operation. As soon as a new link doesn't have time to locate the roots, the query degenerates into almost linear time. We will also analyze the amortized bounds for link -- find, which are again weaker than those for union -- find when tq ≥ tu, but the bounds are less striking. We show a similar computational phenomenon for fully dynamic connectivity where both edge inser- tions and deletions. In this fully-dynamic case, we hit the wall even when we amortize. Theorem 2. Any data structure for fully dynamic connectivity in a graph of n vertices with update time tu = o(lg n) must have query time tq ≥ n1−o(1). This bound allows amortization and Las Vegas randomization (expected running times), and holds in the cell-probe model with cells of O(lg n) bits. Thorup [Tho00] has an almost matching upper bound of tu = O(lg n · (lg lg n)3) and tq = o(lg n). This data structure uses both Las Vegas randomization and amortization. Supporting both LINK and UNION. To fully appreciate the difficulty of finding roots, consider a data structure that supports both a traditional UNION update between roots and LINK between arbitrary nodes. We know from previous works that if UNION takes tUNION time, then the best worst-case query time is Θ(log n/ log tUNION). This holds both for find-root and connecitivity queries. We can always implement links with find-root and union in O(log n/ log tUNION + tUNION) time, and this preserves the query time. However, in the case where the query time dominates the union time, that is, tUNION = o(log n/ log tUNION), we would like to avoid finding the roots, and get a query time closer to tUNION. A similar phenomenon appeared in connection with union-find with deletions. Kaplan et al. [KST02b] considered this problem but wanted bounds where n represented the size of the actual tree(s) involved in an operation. All worst-case bounds are trivially local, and [KST02b] proved refined the standard amortized analysis to work locally, though the bound becomes a bit weird with the standard notation: α(n) is OK, but otherwise, it becomes α(n · ⌈M/N ⌉, n) amortized time per find where M and N are the global number of finds and unions, respectively. With the notation from [ARG+05], the local amortized find bound is O(α⌈M/N ⌉(n)). They showed how to augment union-find with a delete operation if we when deleting an element x, first find the root and then perform a local rebuilding step in the tree that x is deleted from. For tu = O(1), this gave them both find-root and delete in O(log n) time. Similar to our case, they asked if the deletion time could be made better than this find time. For the deletions, the answer was yes. Alstrup et al. [ARG+05] proved that deletions could be supported locally in constant time without affecting the O(log n) bound on the query time. Back to our union-find with links problem, as in the deletions case, we would like to support LINK better than FIND without affecting the FIND bound. Here we show that any such positive result is totally impossible. If we try to beat the query time, supporting links in tLINK = o(log n/ log tUNION) time, then the query time explodes from tFIND = O(log n/ log tu) to tFIND ≥ n1−o(1) time. 1.2 Lower Bounds Many of the early lower bounds for union -- find were in (restricted versions of) the pointer machine model [Tar79, Ban80, Pou96, Blu86]. In STOC'89, Fredman and Saks [FS89] were the first to show dynamic lower bounds in the cell-probe model. They studied the partial sums problem and the union -- find problem. The partial sums problem asks 2 to maintain an array A[1 . . n] under pointwise updates and queries for a prefix sum: Pi≤k A[i]. For partial sums and for worst-case union -- find, Fredman and Saks showed a lower bound of tq = Ω(lg n/ lg(tu lg n)). For amortized union -- find, they gave an optimal inverse-Ackermann lower bound. A different proof of the same bounds was given by Ben-Amram and Galil in FOCS'91 [BAG01]. In STOC'99, Alstrup, Ben-Amram and Rauhe [ABAR99] improved the trade-off for union -- find to tq = Ω(lg n/ lg tu), which was also the highest known trade-off for any problem. In STOC'02, Kaplan, Shafrir and Tarjan [KST02a] showed that the optimal worst-case and amortized trade-offs for union -- find also hold for a weaker Boolean version where the user specifies set identifiers and where we only have membership queries. From a lower bound perspective, the tricky part is that the query output is a single bit. Identifiers can always be viewed as special elements of sets. Thus they get the same lower bound trade-off for incremental connectivity: edges are only added between current set identifiers, and connectivity queries are between arbitrary nodes and current set identifiers. This lower-bound trade-off for incremental connec- tivity is tight when tu = Ω(tq), matching the previously mentioned upper-bounds for link -- find. However, by our Theorem 1, the incremental connectivity queries hit a wall when the update time becomes lower. The work of Patras¸cu and Demaine from STOC'04 [PD06] gives the best trade-offs known today, for any explicit problem. They considered partial sums and fully dynamic connectivity, and showed that, if max{tu, tq} = O(B lg n), then min{tu, tq} = Ω(logB n). In particular, their bounds implied max{tu, tq} = Ω(lg n), whereas previous results implied max{tu, tq} = Ω(lg n/ lg lg n). These bounds are easily seen to be optimal for the partial sums problem. The standard solution is to create an ordered binary tree with leaf set [n]; each internal node maintains the sum of its children. Updates and queries are trivially supported in Θ(log n) time. To get a trade-offs, we can instead use a B-tree with degree B. The time of an update is the height of the tree, which is O(logB n). However, to answer a query, we need to add up all left siblings from the path to the root, so the query time is O(B logB n). Our results significantly improve the known trade-offs in the regime of fast query times. Note that the previous strongest bounds from [PD06] could at most imply tq = Ω(nε) even for constant update time. Here ε depends on the constant in the update time. For example, allowing only 4 cell probes for the updates, 16 ). Our Theorem 2 says for another problem [PD06, careful inspection] gets a query lower bound of Ω(n that we with o(log n) probes get a query lower bound ≥ n1−o(1) queries. 1 The trade-offs of [PD06] are optimal in the full range for the partial sums problem. For incremental and fully dynamic connectivity, the previous mild trade-offs [KST02a, PD06] are optimal in the regime tu ≫ tq; it is only the regime of fast updates that causes the abrupt transitions in Theorems 1 and 2. Lower bounds beyond the balanced tree. The previous lower-bounds we discussed are essentially all showing that the we cannot do much better than maintaining information in a balanced tree. All operations follow well-understood paths to the roots. Trade-offs were obtained by increasing the degree, decreasing the height: the faster of updates and queries would just follow the path to the root while the slower would have to consider siblings on the way. The lower bounds from [PD06] are best possible in this regard. Our stronger trade-offs for incremental and fully-dynamic connectivity shows that there is no such sim- ple way of organizing information; that the links between arbitrary vertices changes the structure too much if the update times is not long enough, we cannot maintain the balanced information tree. 2 Simulation by Communication Games Results Generally, for the data structure problems considered, we are going to find an input distribution that will make any deterministic algorithm perform badly on the average. This also implies expected lower bounds 3 for randomized algorithms. Consider an abstract dynamic problem with operations UPDATE(ui) and QUERY(qi). Assume the se- quence of operations is of fixed length, and that the type of each operation (query versus update) is fixed a priori. The "input" ui or qi of the operation is not fixed yet. Let IA and IB be two adjacent intervals of operations, and assume that every input ui or qi outside of IA ∪ IB has been fixed. What remains free are the inputs XA during interval IA and XB during interval IB. These inputs (XA, XB) follow a given distribution D. It is natural to convert this setting into a communication game between two players: Alice receives XA, Bob receives XB, and their goal is to answer the queries in XB (which depend on the updates in XA). In our applications below, the queries will be Boolean, and it will even be hard for the players to compute the and of all queries in the IB interval. Each player is deterministic, and the two players can exchange bits of information. The last bit communicated should be the final answer of the game, which here is the and of the queries in IB. The complexity of the game is defined as the total communication (in bits) between the players, in expectation over D. We will work in the cell-probe model with w-bit cells; in the applications below, w = Θ(lg n). For notational convenience, we assume the data structure must read a cell immediately before writing it (but it may choose to read a cell without rewriting it). Let WA be the set of cells written during time interval IA, and RB be the set of cells read during interval IB. Lemma 3. For any p ≥ 0, the communication game can be solved by a zero-error protocol with complexity ED(cid:2)WA · O(lg 1 p ) + O(w) ·(cid:0)WA ∩ RB + pRB(cid:1)(cid:3). Proof. Alice first simulates the data structure on the interval IA. The memory state at the beginning of IA is fixed. After this simulation Alice constructs a Bloom filter [Blo70] with error (false positive) probability p for the cells WA. The hash functions needed by the Bloom filter can be chosen by public coins, which can later be fixed since we are working under a distribution. Alice's first message is the Bloom filter, which requires WA · O(lg 1 Bob will now attempt to simulate the data structure on IB. The algorithm may try to read a cell of the p ) bits. following types: • a cell previously written during IB: Bob already knows its contents. • a cell that is positive in the Bloom filter: Bob sends the address of the cell to Alice, who replies with its contents; this exchange takes O(w) bits. • a cell that is negative in the Bloom filter: Bob knows for sure that the cell was not written during IA. Thus, he knows its contents, since it comes from the old fixed memory snapshot before the beginning of IA. With this simulation, Bob knows all the his answers and can transmit the final bit telling if they are all true. The number of messages from Bob is WA ∩ RB (true positives) plus an expected number of false positives of at most pRB. We will use the simulation to obtain lower bounds for WA ∩ RB, comparing the complexity of the protocol with a communication lower bound. This simulation works well when WA ∩ RB ≈ WA ∪ RB/ lg n lg n , and make the term WA ∩ RB dominate. Unfortunately, it does not work in the regime WA ∩ RB ≈ WA ∪ RB/ lg n, since one of the terms proportional to WA or RB will dominate, for any p. lg lg n, since we can use p ≈ 1 To give a tighter simulation, we use a stronger communication model: nondeterministic complexity. In this model, a prover sends a public proof Z to both Alice and Bob. Alice and Bob independently decide 4 whether to accept the message, and they can only accept if the output of the communication game is "true" (i.e. all queries in IB return true). In this model Alice and Bob do not communicate with each other. Alice's answer is a deterministic function fA(XA, Z) of her own input and the public proof. Similarly, we have Bob's answer fB(XB, Z). For the protocol to be correct, fA(XA, Z) and fB(XB, Z) may only both be true if this is the answer to the game. Our goal for the prover is to define a short public proof Z(XA, XB) that will lead Alice and Bob to the desired answer fA(XA, Z(XA, XB)) ∧ fB(XB, Z(XA, XB)). The complexity of the protocol is the of the game should be the and of all queries in IB. Since we are working under a distribution, the bit length of the prover's message Z(XA, XB) is a random variable, and we define the complexity of the protocol as its expectation. Lemma 4. The communication game can be solved by a nondeterministic protocol with complexity ED(cid:2)O(w) · WA ∩ RB + O(WA ∪ RB)(cid:3). Proof. We will use a retrieval dictionary (a.k.a. a Bloomier filter, or a dictionary without membership). Such a dictionary must store a set S from universe U with k bits of associated data per element of S. When queried for some x ∈ S, the dictionary must retrieve x's associated data. When queried about x /∈ S, it may return anything. One can construct retrieval dictionaries with space O(kS + lg lg U ); see e.g. [DP08]. The message Z(XA, XB) of the prover will consist of the addresses and contents of the cells X = WA ∩ RB, taking O(w) bits each. In addition, he will provide a retrieval dictionary for the symmetric difference WA∆RB = (WA \ RB) ∪ (RB \ WA). In this dictionary, every element has one associated bit of data: zero if the cell is from WA \ RB and one if from RB \ WA. The dictionary takes O(lg w + WA ∪ RB) bits. Alice first simulates the data structure on IA. Then she verifies that all cells X were actually written (X ⊆ WA), and their content is correct. Furthermore, she verifies that for all cells from WA \X, the retrieval dictionary returns zero. If some of this fails, she rejects with a false. Bob simulates the data structure on IB. The algorithm may read cells of the following types: • cells previously written during IB: Bob knows their contents. • cells from X: Bob uses the contents from public proof (Alice verified these contents). • cells for which the retrieval dictionary returns one: Bob uses the contents from the fixed memory snapshot before the beginning of IA (Alice verified she didn't write such cells). • cells for which the retrieval dictionary return zero: Bob rejects. The prover is trying to cheat, since in a correct simulation all cells of RB \ X has a one bit in the dictionary. If neither player rejects, we know that RB \ X is disjoint from WA \ X, so the simulation of Bob is correct. Finally Bob rejects if any of his answers are false. 3 Lower Bound for Incremental Connectivity Theorem 5. Any data structure for incremental connectivity over n vertices that supports edge insertions between roots in worst-case time tUNION = o( lg n lg lg n ) and arbitrary edge insertions in worst-case time tLINK = o( lg n lg lg n ) must have query time tFIND ≥ n1−o(1). Let ε = o(1) be such that tUNION = o(ε2 lg n/ lg lg n). Define B = lg2 n, C = nε, and M = n1−ε. The starting point of our hard instance is essentially taken from Fredman and Saks' seminal pa- per [FS89]. The hard instance will randomly construct a forest of M trees. Each tree will be a perfect 5 tree of degree B and height logB(n/M ). On layer 0 of the forest we have the M roots. On layer i, we have exactly M · Bi vertices with Bi vertices from each tree. We can describe the edges between level i and i − 1 as a function fi : [M · Bi] → [M · Bi−1] that is balanced: for each x ∈ [M Bi−1], (fi)−1(x) = B. We will use the following convenient notation for composition: f≥i = fi ◦ fi+1 ◦ · · · . For example, the ancestor on level i − 1 of leaf x is f≥i(x). Our hard instance will insert the edges describing fi's in bottom-up fashion (i.e. by decreasing i, from the largest level up to the roots). We call "epoch i" the period of time when the edges fi are inserted. Let Wi (respectively Ri) be the cells written (respectively, read) in epoch i. Observe that Wi+Ri ≤ M ·BitUNION. last written in epoch i. We will use the following convenient notation for set union: W≤i =Sj≤i Wj. The cells Wi \ W<i are those All the above edges where added in union-find style from roots of current trees, and indeed the above constitutes the hard case for union-find from [FS89]. At this point [FS89] shows that finding a root from a random leaf would entail reading cells from most epochs in Ω(log n/ log B) expected time. Our goal is to show that linking arbitrary vertices may lead to much more expensive queries. We will describe some very powerful metaqueries that combines links to roots and leaves with a few connectivity to reveal far more information than if we only had the regular connectivity queries. The metaqueries will be provably hard to answer, so if the links are done too quickly, the queries must be very slow. Our graph contains C additional special vertices, conceptually colored with the colors 1 . . C. Each colored vertex is connected to M/C nodes on level 0 (the final roots of our trees). This is done in a fixed pattern: colored vertex 1 is connected to roots 1, . . . , M/C; colored vertex 2 to the next M/C roots; etc. These edges can be inserted at the very beginning of the execution, prior to any interesting updates. At the end of epoch 1 all trees are complete. In this state, we say the root color of a vertex is the color that its root is connected to. Conceptually, the hard distribution colors a random set Q of exactly M leaves and verifies that these are the root colors. To implement this test by incremental connectivity operations (LINK), we first link each query leaf to the proposed colored vertex. Then, for i = 2 . . C, we query whether colored vertex i is connected to colored vertex i − 1, and then insert an edge between these two color nodes. The metaquery returns "true" iff all connectivity queries are negative. We claim that if the metaquery answers true, the coloring of Q must be consistent with the coloring of the roots. Indeed, if some leaf is colored i and its root is colored j 6= i, this inconsistency is caught at step max{i, j}. At this step, everything with color ≤ max{i, j} − 1 has been connected into a tree, so the connectivity query will return true. Let χ(Q) be the coloring of leaves in Q that matches their root colors. In the hard distribution, the metaquery always receives proposed colors from χ(Q), so it should answer true. Nevertheless, the data structure will need to do a lot of work to verify this. Let RQ be the cells read during the metaquery. We have RQ ≤ C · tq + 2M · tUNION. The main claim of our proof is: Lemma 6. For any i ∈ {1, . . . , logB(n/M )}, we have E[RQ ∩ (Wi \ W<i)] = Ω(εM ). joint by construction, so Pi Before we prove the lemma, we show that it implies our lower bound. The sets Wi \ W<i are dis- E[RQ ∩ (Wi \ W<i)] ≤ E[RQ]. Remember that we have logB(n/M ) = O(log(nε)/ lg lg n) = O(ε lg n/ lg lg n) epochs. Thus E[RQ] = Ω(M · ε2 lg n/ lg lg n). But we always have RQ ≤ C · tq + 2M · tu = Ctq + o(M ε2 lg n lg lg n ), by choice of ε. It follows that Ctq is the dominant term in E[RQ], so tq = Ω(M ε2(lg n/ lg lg n)/C) ≥ n1−2ε. 6 Proof of Lemma 6. Fix i. We will prove the stronger statement that the lower bound holds no matter how we fix the edges outside epoch i (all fj's for j 6= i). To dominate the work of later epochs i − 1, . . . , 1, we consider Bi i.i.d. metaqueries. Choose sets Q1, Q2, . . . , QBi independently, each containing M uniformly chosen leaves. Starting from the memory state where all trees are completely built and the roots have been colored, we simulate each metaquery (Qj, χ(Qj)) in isolation. We do not need to write any cells in this simulation, for the cell-probe model has unbounded state to remember intermediate results and in our hard distribution there is no operation after the metaquery. Thus the simulations of the different metaqueries do not influence each other. Let R⋆ be the cells read by all Bi metaqueries. By linearity of expectation, E[R⋆ ∩ (Wi \ W<i)] ≤ Bi · E[RQ ∩ (Wi \ W<i)]. Let Q⋆ =Sj Qj. Since we have fixed all f>i, asking about the root color of a leaf q ∈ Q⋆ is equivalent to asking about the root color of node f>i(q) on level i. Claim 7. We have E[f>i(Q⋆)] ≥ (1 − 1 e )M Bi. Proof. Each leaf x in some Qj is chosen uniformly, so its ancestor f<i(x) is also uniform. The M · Bi trials are independent (for different Qj, Qk), or positively correlated (inside the same Qj, since the leaves must be distinct). Thus, we expect to collect (1 − 1/e)M Bi distinct ancestors. By the Markov bound f>i(Q⋆) ≥ 1 sequence (Q1, Q2, . . . , QBi W<i)] by at most (1 − 2/e)−1 = O(1). ) to a value that achieves f>i(Q⋆) ≥ 1 2 M Bi with probability at least 1 − 2/e. Thus we may fix the 2 M Bi while increasing E[R⋆ ∩ (Wi \ The only remaining randomness in our instance are the edges fi from epoch i and the proposed colorings χ(Qj) given to each metaquery Qj. To be valid, these colorings are functions of fi, for as soon as we know fi, we know the whole forest including the root colors of all the leaves in the different Qj. The metaquery colors have to agree on common leaves, so they provide us a coloring χ(Q∗). With fi yet unknown, we claim that χ(Q⋆) has a lot of entropy: Claim 8. H(χ(Q⋆)) = Ω(M Bi lg C). Proof. Let X be the unknown coloring of all vertices on level i. We claim it has entropy H(X) = M Bi · log2 C − O(C lg n). We have not fixed anything impacting this coloring so X is a random balanced vector from [C]M Bi. Indeed, any balanced coloring is equiprobable, because the coloring of the roots is balanced, all trees have the same sizes, and fi is a random balanced function. We claim that it has entropy H(X) = M Bi · log2 C − O(C lg n). The number of balanced colorings is given by the multinomial coefficient M Bi (cid:0) M Bi/C, M Bi/C, ...(cid:1). This is the central multinomial coefficient, so it is the largest. It must therefore be at least a fraction (M Bi)−C ≥ n−C of the sum of all multinomial coefficients. This sum is C M Bi (the total number of possible colorings), so H(X) ≥ log2(C M Bi /nC ) = M Bi log2 C − C log2 n. We argue that H(χ(Q⋆)) = Ω(M Bi lg C). Indeed, χ(Q⋆) reveals the coloring of vertices f<i(Q⋆) on 2 M Bi. Given χ(Q⋆), to encoding X, we just write all other colors explicitly 2 M Bi log2 C ≥ M Bi log2 C − C lg2 n − 2 M Bi log2 C bits. Therefore H(χ(Q⋆)) ≥ H(X) − 1 level i, which number at least 1 using 1 1 2 M Bi log2 C = Ω(M Bi lg C). We consider the communication game in which Alice represents the time of epoch i (her private input is XA = fi), and Bob represents the time of epochs i − 1, . . . , 1 and the metaqueries (his private input is XB = χ(Q⋆)). Their goal is to determine whether all the metaqueries return true. Claim 9. Any zero-error protocol must have average case bit complexity Ω(M Bi lg C). 7 Proof. We turn our attention to the communication game. The set of inputs of Alice and Bob that lead to a fixed transcript of the communication protocol forms a combinatorial rectangle. More precisely, a transcript t represents a sequence of transmissions between Alice and Bob. On Alice's side, there will be a certain set X t A of inputs making her follow t provided that Bob follows t, and we have a corresponding input set X t B from Bob. Inputs XA and XB will lead to t if and only if (XA, XB) ∈ X t B. Since the players must verify XB = χ(Q⋆) and the protocol has zero error, the rectangle cannot contain two inputs of Bob with different χ(Q⋆), that is, X t B = 1 for all valid t. Thus the transcript for a coloring χ(Q⋆) is unique with no smaller entropy. A × X t We will use Lemma 3 to obtain a communication protocol, setting the rate of false positives in the Bloom filter to p = 1/ lg n. The cells written in Alice's interval are precisely Wi; the cells read in Bob's interval are R<i ∪ R⋆ where R⋆ is the union of the cells read by all the metaqueries. By Lemma 3, the communication complexity is: E(cid:2)(R<i ∪ R⋆) ∩ Wi · O(lg n) + Wi · O(lg lg n) + 1 ≤ E[R⋆ ∩ Wi] · O(lg n) + O(M Bitu · lg lg n) + O(M Bi−1tu · lg n) + O(R⋆) lg n R<i ∪ R⋆ · O(lg n)(cid:3) We compare this to the lower bound of Ω(M Bi lg C) = Ω(M Bi · ε lg n) from Claim 9. Remember that tu = o(ε2 lg n/ lg lg n), so the second term is o(M Biε2 lg n), which is asymptotically lower than the lower bound. Also, we set B = lg2 n, so the third term is o(M Bi). Finally, we have R⋆ = O(BiM tu). To see this, recall that R⋆ ≤ Bi(M tu +Ctq), so if the statement was false, we would have BiCtq = ω(BiM ) and tq = ω(M/C) = ω(n1−2ε). Since O(BiM tu) is also low order term, the first term must dominate, which means E[R⋆ ∩ (Wi \ W<i)] = Ω(M Biε). Therefore, E[R⋆ ∩ (Wi \ W<i)] = Ω(εM ). This completes the proof of Lemma 6 from which we got our lower bound for incremental connectivity. 4 Lower Bound for Dynamic Connectivity Theorem 10. Any data structure for dynamic connectivity in graphs of n vertices that has (amortized) update time tu = o(lg n) must have (amortized) query time tq ≥ n1−o(1). Let ε be such that tu = o(ε2 lg n), and define M = n1−ε and C = nε. The shape of our graphs is depicted in Figure 1. The vertices are points of a grid [M ] × [n/M ]. The edges of our graph are matchings between consecutive columns. Let π1, . . . , πn/M −1 be the permutations that describe these matchings. We let π≤j = πj ◦ πj−1 ◦ · · · ◦ π1. Node i in the first column is connected in column j + 1 to π≤j(i). The graph also contains C special vertices, which we imagine are colored with the colors 1, . . . , C. At all times, a colored vertex is connected to a fixed set of M/C vertices in the first column. (For concreteness, colored vertex 1 is connected to vertices 1, . . . , M/C; colored vertex 2 to the next M/C vertices; etc.) We will allow two meta-operations on this graph: UPDATE and QUERY. Initially, all permutations are the identity (i.e. all edges are horizontal). UPDATE(j, πnew) reconfigures the edges between columns j and j + 1: it sets πj to the permutation πnew. This entails deleting M edges and inserting M edges, so UPDATE takes time 2M · tu. QUERY(j, x) receives a vector χ ∈ [C]M , which it treats as a proposed coloring for vertices on column j. The goal of the query is to test whether this coloring is consistent with the coloring of the vertices in the first column. More specifically, a node i of color a in the first column must have χ[π<j(i)] = a. A QUERY can be implemented efficiently by connectivity operations. First each vertex i in column j is connected to the colored vertex χ[i]. Then, for i = 2 . . M, we run a connectivity query to test whether colored vertex i is 8 π1 π2 π3 π4 π5 π6 Figure 1: The shape of our graphs. connected to colored vertex i − 1. If so, QUERY return false. Otherwise, it inserts an edge between colored vertices i and i − 1 and moves to the next i. At the end, QUERY deletes all vertices it had inserted. The total cell-probe complexity of QUERY is O(M ) · tu + C · tq. It is easy to observe that this procedure correctly tells whether the colorings are consistent (as in our instance of incremental connectivity). We will now describe the hard distribution over problem instances. We assume n M − 1 is a power of two. Let σ be the bit-reversal permutation on {0, . . . , n M − 2}: σ(i) is the reversal of i, treated as a vector of log2( n M − 1, we execute an UPDATE to position j = σ(i) + 1, and a QUERY to the same position j. The update sets πj to a new random permutation. The query always receives the consistent coloring, and should answer true. The total running time is M − 1) bits. For i = 0, . . . , n T ≤ n/M (2M tu + O(M )tu + Ctq) = O(ntu + (n/M )Ctq). If we can prove a lower bound T = ω(ntu), then this will yield a high lower bound for tq. For the lower bound proof, we consider a perfect ordered binary tree with n/M − 1. The leaves are associated with the pairs of UPDATE and QUERY operations in time order. Let W (v) (respectively R(v)) be the set of cells written (respectively, read) while executing the operations in the subtree of v. Note that W (v) ⊆ R(v), since we have assumed a cell must be read before it is written. Our main claim is: Lemma 11. Let v be a node with 2k leaves in its subtree, and let vL, vR be its left and right children. Then E[W (vL) ∩ R(vR) + 1 lg n W (vL) ∪ R(vR)] = Ω(k · εM ). running time is T ≥ Pv Before we prove the lemma, we use it to derive the desired lower bound. We claim that the total expected E[W (vL) ∩ R(vR)], where the sum is over all nodes in our lower bound tree. Consider how a fixed instance is executed by the data structure. We will charge each read operation to a node in the tree: the lowest common ancestor of the time when the instruction executes, and the time when the cell was last written. Thus, each W (vL) ∩ R(vR) corresponds to (at least) one read instruction, so there is no double-counting in the sum. Ω( n M lg n We now sum the lower bound of Lemma 11 over all nodes; observe that Pv kv = Θ( n the tree has n/M − 1 leaves. We obtain Pv T . This is because Pv M ), since E[W (vL) ∪ R(vR)] = M · εM ). The first term is at most T , as explained above. In the second term is also bounded by M since every cell probe is counted once for every M · εM ) = Ω(ε2n lg n). In our construction, the E[W (vL) ∪ R(vR)] ≤ T lg n M lg n ancestor of the time it executes. Thus 2T ≥ Ω( n E[W (vL) ∩ R(vR)] + 1 lg nPv M lg n 9 total running time was T = O(ntu + n nC M tq = Ω(ε2n lg n), so tq > M/C = n1−2ε = n1−o(1). M Ctq). Since tu = o(ε2 lg n), the second term must dominate: Proof of Lemma 11. We will prove the stronger statement that the lower bound holds no matter how we fix the updates outside node vL. We transform the problem into the natural communication game: Alice receives the update permutations in the subtree vL and Bob receives the colorings of the queries in the subtree vR (the updates are fixed). They have to check whether all queries are positive in the sequence of UPDATE and QUERY operations defined by their joint input. We apply Lemma 4 to construct a nondeterministic communication protocol for this problem, with complexity E[W (vL) ∩ R(vR) · O(lg n) + O(W (vL) ∪ R(vR))]. The conclusion of Lemma 11 follows by comparing this protocol to the following communication lower bound: Lemma 12. The game above has nondeterministic (average-case) communication complexity Ω(kM lg C). Proof. Let XA and XB be the inputs of the two players. For any choice of XA, there is a unique sequence of colorings XB that Bob should accept. As in the proof of Lemma 9, we conclude that the public proof is an encoding of XB so we can lower bound the complexity via H(XB). Let JA and JB be the columns touched (updated and queried) in Alice's input and in Bob's input. Bob's input consists of the coloring of column j, for each j ∈ JB. This is π<j applied to the fixed coloring in the first column. Since JA and JB are defined by the bit-reversal permutation, we know that they interleave perfectly: between every two values in the sorted order of JB, there is a unique value in JA. Thus, the coloring for different j ∈ JB are independent random variables, since an independent uniform permutation from JA is composed into π<j compared to all indices from JB below j. Each coloring is uniformly distributed among balanced colorings, so it has entropy M lg C − O(C lg M ) (c.f. proof of Claim 8). We conclude that H(XB) = Ω(kM lg C). 5 Amortized link-find bounds In this section we consider the amortized complexity of the link-find problem which is like the union-find problem except that we can link arbitrary nodes, not just roots. In link-find, we may not necessarily have an obvious notion of a root that we can find. The fundamental requirement to a component is that if we call find from any vertex in it, we get the same root as long as the component is not linked with other components. Let u be the number of updates and q the number of queries. With union-find, the complexity over the whole sequence is Θ(α(q, u)q) if q ≥ u, and Θ(α(q, q)q + u) if q ≤ u. With link-find, we get the same complexity when q ≥ u, but a higher complexity of Θ(α(q, u)u) when q ≤ u. Thus, with link-find, we get a symmetric formula in q and u of Θ(α(max{q, u}, min{q, u}) max{q, u}). (1) We get the upper-bound in (1) via a very simple reduction to union-find. 5.1 The link-find data structure Nodes have three types: free, leaf, and union nodes. A leaf node has a pointer to a neighboring union node, and the union nodes will participate in a standard union-find data structure. The parent of a leaf is the union 10 node it points to. The parent of a union node is as in the union-find structure and the parent of a root is the root itself. All nodes start as free nodes. We preserve the invariant that if a component has a free node, then all nodes in the component are free. To perform a find on a free node v, we scan the component of v. If it is a singleton, we just return it. Otherwise, assuming some initial tie-breaking order, we make the smallest node in the component a union node and all other nodes leaf nodes pointing to is. The union node which is its own root is returned. All this is paid for by the nodes that lost their freedom. To perform a find on a non-free node, we perform it on the parent which is in the union-find data structure. We now consider the different types of links. When we perform link between two free nodes, nothing happens except that an edge is added in constant time. If we link a free node v with a non-free node w, we make all nodes in the components of v leaves pointing to the parent of w. This is paid for by the new leaves. If we link two non-free nodes, we first perform a find from their parents which are union nodes. If they have different roots we unite them. This completes the description of our link-find data structure which spends linear time reducing to a union-find data structure. A union node requires a find on a non-singleton node, so the number of union nodes is at most min{q, u}. Concerning finds in the union-find data structure, we get one for each original find on a non-free node. In addition, we get two finds for each link of two non-free nodes, adding up to at most q + 2u finds. Our total complexity is therefore O(u + q + α(q + 2u, min{q, u})(q + 2u)) = O(α(max{q, u}, min{q, u}) max{q, u}). We are going to present a matching lower bound. 5.2 The link-find data structure for a forest We will now show that it is the links between nodes in the same components that makes link-find harder than union-find in the sense that if no such links appear, we get the same O-bound as with union-find. The modification to the above link-find reduction is simple. Using standard doubling ideas, we can assume that u and q are known in advance. If q ≥ u, we are already matching the union-find bound, so assume q ≤ u. To do a find on a free node, we again scan its component. However, if it has less than α(q, q) nodes, we just return the smallest but leaving the component free. Otherwise, as before, we make the smallest node a union node and all other nodes leaf nodes pointing to it. This is the only change to our link-find algorithm. In the case where the component has α(q, q) nodes, we clearly pay only O(α(q, q)) for a find. The advantage is that we now create at most u/α(q, q) union nodes. Links involving a free node have linear total cost, and now, when we perform a link of non-free nodes, we know they are from different components to be united, so this will reduce the number of union roots by one. Hence we get at most 2u/α(q, q) finds resulting from these links. Thus, in the union-find data structure, we end up with q + 2u/α(q, q) finds and u/α(q, q) unions. The total cost is O(u + q + α(q + 2u/α(q, q), u/α(q, q))(q + 2u/α(q, q)) = O(α(q, q)q + n) time. The simplification uses that α is increasing in its first and decreasing in its second argument, and that the whole time bound is linear if q ≤ u/α(q, q). 11 References [ABAR99] Stephen Alstrup, Amir M. Ben-Amram, and Theis Rauhe. Worst-case and amortised optimality in union-find. In Proc. 31st ACM Symposium on Theory of Computing (STOC), pages 499 -- 506, 1999. [ARG+05] Stephen Alstrup, Theis Rauhe, Inge Li Gørtz, Mikkel Thorup, and Uri Zwick. Union-find with constant time deletions. In Proc. 32nd International Colloquium on Automata, Languages and Programming (ICALP), pages 78 -- 89, 2005. [BAG01] Amir M. Ben-Amram and Zvi Galil. A generalization of a lower bound technique due to Fred- man and Saks. Algorithmica, 30(1):34 -- 66, 2001. See also FOCS'91. [Ban80] Lech Banachowski. A complement to tarjan's result about the lower bound on the complexity of the set union problem. Information Processing Letters, 11(2):59 -- 65, 1980. [Blo70] [Blu86] [DP08] Burton H. Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422 -- 426, 1970. Norbert Blum. On the single-operation worst-case time complexity of the disjoint set union problem. SIAM Journal on Computing, 15(4):1021 -- 1024, 1986. See also STACS'85. Martin Dietzfelbinger and Rasmus Pagh. Succinct data structures for retrieval and approximate membership. In Proc. 35th International Colloquium on Automata, Languages and Program- ming (ICALP), pages 385 -- 396, 2008. [FS89] Michael L. Fredman and Michael E. Saks. The cell probe complexity of dynamic data structures. In Proc. 21st ACM Symposium on Theory of Computing (STOC), pages 345 -- 354, 1989. [KST02a] Haim Kaplan, Nira Shafrir, and Robert Endre Tarjan. Meldable heaps and boolean union-find. In Proc. 34th ACM Symposium on Theory of Computing (STOC), pages 573 -- 582, 2002. [KST02b] Haim Kaplan, Nira Shafrir, and Robert Endre Tarjan. Union-find with deletions. In Proc. 13th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 19 -- 28, 2002. [PD06] [Pou90] [Pou96] Mihai Patras¸cu and Erik D. Demaine. Logarithmic lower bounds in the cell-probe model. SIAM Journal on Computing, 35(4):932 -- 963, 2006. See also SODA'04 and STOC'04. Johannes A. La Poutr´e. New techniques for the union-find problems. In Proc. 1st ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 54 -- 63, 1990. Johannes A. La Poutr´e. Lower bounds for the union-find and the split-find problem on pointer machines. Journal of Computer and System Sciences, 52(1):87 -- 88, 1996. See also STOC'90. [Smi90] Michiel H. M. Smid. A data structure for the union-find problem having good single-operation complexity. ALCOM: Algorithms Review, Newsletter of the ESPRIT II Basic Research Actions Program, 1990. [Tar75] Robert Endre Tarjan. Efficiency of a good but not linear set union algorithm. Journal of the ACM, 22(2):215 -- 225, 1975. 12 [Tar79] Robert Endre Tarjan. A class of algorithms which require nonlinear time to maintain disjoint sets. Journal of Computer and System Sciences, 18(2):110 -- 127, 1979. See also STOC'77. [Tho00] Mikkel Thorup. Near-optimal fully-dynamic graph connectivity. In Proc. 32nd ACM Sympo- sium on Theory of Computing (STOC), pages 343 -- 350, 2000. [TvL84] Robert Endre Tarjan and Jan van Leeuwen. Worst-case analysis of set union algorithms. Journal of the ACM, 31(2):245 -- 281, 1984. 13 Appendix α. Lower Bounds for Amortized Link -- Find We will now sketch a proof for the lower-bound in (1) with u link updates and q find queries. When q ≥ u, we get this from the union-find lower bound of Ω(α(q, u)q) from [FS89]. However, for q ≪ u, we need to prove a higher lower-bound than that for union-find. The lower bound we want in this case is Ω(α(u, q)u). We would get the desired lower bound if we could code a union-find problem with Ω(q) updates and Ω(u) queries. We cannot make such a black-box reduction, but we can do it inside the proof construction from [FS89]. We will only present the idea in the "reduction". For a real proof one has to carefully examine the whole proof from [FS89] to verify that nothing really breaks. The lower bound construction from [FS89] proceeds in rounds. We start with singleton roots. In a union round, we pair all current roots randomly, thus halving the number of roots. In a find round, we perform a number of finds on random leaves. The number of finds are adjusted depending on the actions of the data structure. From [KST02a] we know that the lower bound also holds if the finds just have to verify the current root of a node. In our case, we will start with n roots. In a union-round, we just link roots as in union-find. However, in a find round, instead of calling find from a leaf v, we link v to its current root r. We want to turn this leaf-root link into a verification. We will not do that for the individual links, but we will do it for the find-round as a whole (one needs to verify that this batching preserves the lower-bound). At the end of the find-round, we simply perform a find on each root. All these finds should return the root itself. If one of the links (v, r) had gone to the wrong root and r′ was the correct root, then r and r′ would be connected in the same tree, which means that they cannot both be roots. One of the finds would therefore return a different root. If the union-find problem we code used f finds, then our link-find solution ends up with u = n − 1 + f link updates and q = n − 1 find verifications, hence with the desired lower bound of Ω(α(f, n)f ) = Ω(α(u, q)u). 14 1 1 0 2 r a M 7 2 ] S D . s c [ 2 v 3 8 7 1 . 2 0 1 1 : v i X r a Don't Rush into a Union: Take Time to Find Your Roots Mihai Patras¸cu Mikkel Thorup [email protected] [email protected] September 10, 2018 Abstract We present a new threshold phenomenon in data structure lower bounds where slightly reduced update times lead to exploding query times. Consider incremental connectivity, letting tU be the time to insert an edge and tq be the query time. For tU = Ω(tq), the problem is equivalent to the well-understood union -- find problem: INSERTEDGE(s, t) can be implemented by UNION(FIND(s), FIND(t)). This gives worst-case time tU = tq = O(lg n/ lg lg n) and amortized tU = tq = O(α(n)). By contrast, we show that if tU = o(lg n/ lg lg n), the query time explodes to tq ≥ n1−o(1). In other words, if the data structure doesn't have time to find the roots of each disjoint set (tree) during edge insertion, there is no effective way to organize the information! For amortized complexity, we demonstrate a new inverse-Ackermann type trade-off in the regime tU = o(tq). A similar lower bound is given for fully dynamic connectivity, where an update time of o(lg n) forces the query time to be n1−o(1). This lower bound allows for amortization and Las Vegas randomization, and comes close to the known O(lg n · (lg lg n)O(1)) upper bound. 1 Introduction We present a new threshold phenomenon in data structure lower bounds where slightly reduced update times lead to exploding query times. Previous trade-offs where smooth and much weaker. The new explosive lower bounds are found hidden in some very well-studied problems: incremental and fully-dynamic connectivity. For incremental connectivity, the explosion is only in the worst-case. For the fully-dynamic case we also get an explosion in the amortized bounds. 1.1 Incremental connectivity and union-find The incremental connectivity problems considers a graph G with vertex set {1, ..., n}. Starting with no edges in G, we support the following operations: CONNECTED(u, v) : Tells if u and v are connected in G. INSERTEDGE(u, v) : Adds the edge (u, v) to G. The obvious way to implement incremental connectivity is the classic union -- find data structure which supports the following operations on a collection of disjoint sets, starting from n singleton sets {1}, . . . , {n}: FIND(v) : Return a "root" representing the set containing v. UNION(u, v) : Both u and v should be roots of sets, i.e. FIND(u) = u and FIND(v) = v. The operation creates the union of the sets and returns its new root. 1 The terminology for the union -- find problem stems from the usual implementation as a forest of rooted trees where each tree spans a set. FIND involves walking up to the root of v's tree, potentially doing useful work like path compression on the way. UNION simply adds an edge between the roots whose direction is usually determined by the size or rank of sets. Given a union -- find data structure, we can implement incremental connectivity as: CONNECTED(u, v) : Is FIND(u) = FIND(v)? INSERTEDGE(u, v) : UNION(FIND(u), FIND(v)). For now our focus is on worst-case bounds, but shall return to inverse-Ackermann style amortized bounds in Section 5. From a worst-case perspective, the classic union-by-rank gives union in constant time and find in O(log n) time. Trade-offs were addressed by Blum [6], with an improvement by Smid [14]. They show that, if the time for union is bounded by tU, FIND can be supported in worst-case O(lg n/ lg tU). This trade-off is known to be optimal in the powerful cell-probe model [1] (see below for a review of the lower bounds). Implementing incremental connectivity with union -- find, we do not benefit if UNION is faster than FIND. The natural solution is to balance the times, supporting all operations in O(log n/ log log n) time. But do we really need to take time to find the roots before entering the union? What happens if we try to reduce the update time, e.g., can we as in the plain union -- find problem do updates in constant time and queries in logarithmic time? The answer is a resounding no: any improvement in the O(log n/ log log n) update time for insertions will make the connectivity query time explode. Theorem 1. Any data structure for incremental connectivity over n vertices that supports edge insertions in worst-case time o( lg n lg lg n ) must have worst-case connectivity query time n1−o(1) in the cell-probe model with cells of O(lg n) bits. 1.2 Combining union with general links To describe the full power of our lower bound, we will augment union -- find with a natural link operation. To formally define the problem, we need a convention on the representatives in union -- find. When we start, all elements are singletons, each being its own representative. Now define: LINK(u, v) : Here u and v are arbitrary elements of sets. If these sets are different (FIND(u) 6= FIND(v)), the operation creates a new set that is the union of the two old sets, whose representative is the old FIND(u). The two old sets are destroyed. Thus, if r = FIND(u) before the call, then afterwards FIND(u) = r = FIND(v). UNION(u, v) : This operation is a special case of LINK(u, v), where the caller of the function makes a guarantee that before the call, both u and v are the representatives of their own sets, i.e., FIND(u) = u and FIND(v) = v. Afterwards, FIND(u) = u = FIND(v) This semantics of choosing representatives can be supported by any union -- find data structure with a constant overhead, as one can maintain a translation table between the representatives chosen by the data structure and the ones mandated in our definition. Now LINK is a direct generalization of UNION to the case where the arguments may not be representatives. It has the obvious implementation LINK(u, v) = UNION(FIND(u), FIND(v)), with the running time tL ≤ tU + 2tF. If we choose to support UNION in time tU, the standard union -- find data structures can support FIND in ). ) time. This immediately implies a running time for LINK of tL = O(tU +tF) = O(tU + lg n lg tU tF = O( lg n lg tU 2 Our basic question is whether LINK "requires" a FIND operation, i.e. whether one can support tL = o(tF). This question only arises in the regime tU = o( lg n lg lg n ), as otherwise tU dominates the running time of tL (which is necessary, as UNION is a special case of LINK by definition). As a particular example, if we support UNION in constant time, both LINK and FIND take O(lg n) time by known results. An intriguing question is: with UNION in constant time, can we implement links in sublogarithmic time while preserving efficient (say, polylogarithmic) query time? To prove the strongest lower bounds, we prefer to work with a weaker query than FIND: CONNECTED(u, v) : Are u and v in the same set, i.e. FIND(u) = FIND(v)? The link -- connected problem is identical to incremental connectivity. Lower bounds for CONNECTED queries immediately translate into lower bounds for FIND queries. From now on, we consider the mixed union -- link -- connected problem (whose update/query trade-offs turn out to be identical to union -- link -- find). We prove that if LINK does not have enough time to run a FIND query (with the classic running times), the data structure cannot organize information effectively and the connectivity query time explodes to essentially linear time: lg lg n ) worst-case time and LINK in tL = ) worst-case time, must have worst-case CONNECTED (and FIND) query time tQ ≥ n1−o(1) in the Theorem 2. Any data structure supporting UNION in tU = o( lg n o( lg n log tU cell-probe model with cells of O(lg n) bits. With union and link running in o(log n/ log log n) time, the theorem reproves the query lower bound of Theorem 1. A question of similar flavor appeared in connection with union-find with deletions. Links and deletions have the common issue that they apply to arbitrary elements, hence that we do not a priori know what tree we are in. Kaplan et al. [10] considered the union-delete-find problem but wanted local bounds were n is the size of the actual trees involved in an operation. All the above mentioned worst-case bounds are local, but this would be lost if we tried implementing deletions with global rebuilding. Kaplan et al. [10] showed how to augment union-find with a delete operation if we when deleting an element x, first find the root and then perform a local rebuilding step in the tree that x is deleted from. With union in constant time, they implemented both find and delete in O(log n) time. Similar to our case, they asked if the deletion time could be improved while preserving the logarithmic query time. In the case of deletions, the answer was the strongest possible "yes." Alstrup et al. [2] proved that both unions and deletions could be supported locally in constant time while preserving the local logarithmic query time. 1.3 Fully-dynamic connectivity We show a similar computational phenomenon for fully dynamic connectivity with both edge insertions and deletions. In this fully-dynamic case, we hit the wall even if amortization is allowed. Theorem 3. Any data structure for fully dynamic connectivity in a graph of n vertices with update time tu = o(lg n) must have query time tq ≥ n1−o(1). This bound allows amortization and Las Vegas randomization (expected running times), and holds in the cell-probe model with cells of O(lg n) bits. Thorup [18] has an almost matching upper bound of tU = O(lg n · (lg lg n)3) and tq = o(lg n). This data structure uses both Las Vegas randomization and amortization. 3 1.4 Lower Bounds Many of the early lower bounds for union -- find were in (restricted versions of) the pointer machine model [16, 3, 12, 6]. In STOC'89, Fredman and Saks [8] were the first to show dynamic lower bounds in the cell-probe model. They studied the partial sums problem and the union -- find problem. The partial sums problem asks to maintain an array A[1 . . n] under pointwise updates and queries for a prefix sum: Pi≤k A[i]. For partial sums and for worst-case union -- find, Fredman and Saks showed a lower bound of tq = Ω(lg n/ lg(tU lg n)). For amortized union -- find, they gave an optimal inverse-Ackermann lower bound. A different proof of the same bounds was given by Ben-Amram and Galil in FOCS'91 [4]. In STOC'99, Alstrup, Ben-Amram and Rauhe [1] improved the trade-off for union -- find to tq = Ω(lg n/ lg tU), which was also the highest known trade-off for any problem. In STOC'02, Kaplan, Shafrir and Tarjan [9] showed that the optimal worst-case and amortized trade-offs for union -- find also hold for a weaker Boolean version where the user specifies set identifiers and where we only have membership queries. From a lower bound perspective, the tricky part is that the query output is a single bit. Identifiers can always be viewed as special elements of sets. Thus they get the same lower bound trade-off for incremental connec- tivity: edges are only added between current set identifiers, and connectivity queries are between arbitrary nodes and current set identifiers. This lower-bound trade-off for incremental connectivity is tight when tU = Ω(tq), matching the previously mentioned upper-bounds for link -- find. However, by our Theorem 1, the incremental connectivity queries hit a wall when the update time becomes lower. The work of Patras¸cu and Demaine from STOC'04 [13] gives the best trade-offs known today, for any explicit problem. They considered partial sums and fully dynamic connectivity, and showed that, if max{tU, tq} = O(B lg n), then min{tU, tq} = Ω(logB n). their bounds implied max{tU, tq} = Ω(lg n), whereas previous results implied max{tU, tq} = Ω(lg n/ lg lg n). In particular, These bounds are easily seen to be optimal for the partial sums problem. The standard solution is to create an ordered binary tree with leaf set [n]; each internal node maintains the sum of its children. Updates and queries are trivially supported in Θ(log n) time. To get a trade-offs, we can instead use a B-tree with degree B. The time of an update is the height of the tree, which is O(logB n). However, to answer a query, we need to add up all left siblings from the path to the root, so the query time is O(B logB n). Our results significantly improve the known trade-offs in the regime of fast query times. Note that the previous strongest bounds from [13] could at most imply tq = Ω(nε) even for constant update time. Here ε depends on the constant in the update time. For example, allowing only 4 cell probes for the updates, [13, 16 ). Our Theorem 3 says for another problem that we careful inspection] gets a query lower bound of Ω(n with o(log n) probes get a query lower bound ≥ n1−o(1) queries. 1 The trade-offs of [13] are optimal in the full range for the partial sums problem. For incremental and fully dynamic connectivity, the previous mild trade-offs [9, 13] are optimal in the regime tU ≫ tq; it is only the regime of fast updates that causes the abrupt transitions in Theorems 1 and 3. Lower bounds beyond the balanced tree The previous lower-bounds we discussed are essentially all showing that the we cannot do much better than maintaining information in a balanced tree. All operations follow well-understood paths to the roots. Trade-offs were obtained by increasing the degree, decreasing the height: the faster of updates and queries would just follow the path to the root while the slower would have to consider siblings on the way. The lower bounds from [13] are best possible in this regard. Our stronger trade-offs for incremental and fully-dynamic connectivity shows that there is no such sim- ple way of organizing information; that the links between arbitrary vertices changes the structure too much if the update times is not long enough, we cannot maintain the balanced information tree. 4 2 Simulations by Communication Games Generally, for the data structure problems considered, we are going to find an input distribution that will make any deterministic algorithm perform badly on the average. This also implies expected lower bounds for randomized algorithms. Consider an abstract dynamic problem with operations UPDATE(ui) and QUERY(qi). Assume the se- quence of operations is of fixed length, and that the type of each operation (query versus update) is fixed a priori. The "input" ui or qi of the operation is not fixed yet. Let IA and IB be two adjacent intervals of operations, and assume that every input ui or qi outside of IA ∪ IB has been fixed. What remains free are the inputs XA during interval IA and XB during interval IB. These inputs (XA, XB) follow a given distribution D. It is natural to convert this setting into a communication game between two players: Alice receives XA, Bob receives XB, and their goal is to answer the queries in XB (which depend on the updates in XA). In our applications below, the queries will be Boolean, and it will even be hard for the players to compute the and of all queries in the IB interval. Each player is deterministic, and the two players can exchange bits of information. The last bit communicated should be the final answer of the game, which here is the and of the queries in IB. The complexity of the game is defined as the total communication (in bits) between the players, in expectation over D. We will work in the cell-probe model with w-bit cells; in the applications below, w will be Θ(lg n). Let WA be the sets of cells written / read during time interval IA. We consider all cells touched by the algorithm during interval IB in order. If a cell is read before being written, we include it in the set RB; if a cell is first written, include it in the set WB. Lemma 4. For any p ≥ 0, the communication game can be solved by a zero-error protocol with complexity ED(cid:2)WA · O(lg 1 p ) + O(w) ·(cid:0)RB ∩ (WA \ WB) + pRB(cid:1)(cid:3). Proof. Alice first simulates the data structure on the interval IA. The memory state at the beginning of IA is fixed. After this simulation Alice constructs a Bloom filter [5] with error (false positive) probability p for the cells WA. The hash functions needed by the Bloom filter can be chosen by public coins, which can later be fixed since we are working under a distribution. Alice's first message is the Bloom filter, which requires WA · O(lg 1 Bob will now attempt to simulate the data structure on IB. The algorithm may try to read a cell of the p ) bits. following types: • a cell previously written during IB: Bob already knows its contents. • a cell that is positive in the Bloom filter: Bob sends the address of the cell to Alice, who replies with its contents; this exchange takes O(w) bits. • a cell that is negative in the Bloom filter: Bob knows for sure that the cell was not written during IA. Thus, he knows its contents, since it comes from the old fixed memory snapshot before the beginning of IA. With this simulation, Bob knows all the his answers and can transmit the final bit telling if they are all true. The number of messages from Bob is RB ∩ (WA \ WB) (true positives) plus an expected number of false positives of at most pRB. We will use the simulation to obtain lower bounds for WA ∩ RB, comparing the complexity of the protocol with a communication lower bound. This simulation works well when WA ∩ RB ≈ WA ∪ RB/ lg n lg n , and make the term WA ∩ RB dominate. Unfortunately, it does not lg lg n, since we can use p ≈ 1 5 work in the regime WA ∩ RB ≈ WA ∪ RB/ lg n, since one of the terms proportional to WA or RB will dominate, for any p. To give a tighter simulation, we use a stronger communication model: nondeterministic complexity. In this model, a prover sends a public proof Z to both Alice and Bob. Alice and Bob independently decide whether to accept the message, and they can only accept if the output of the communication game is "true" (i.e. all queries in IB return true). In this model Alice and Bob do not communicate with each other. Alice's answer is a deterministic function fA(XA, Z) of her own input and the public proof. Similarly, we have Bob's answer fB(XB, Z). For the protocol to be correct, fA(XA, Z) and fB(XB, Z) may only both be true if this is the answer to the game. Our goal for the prover is to define a short public proof Z(XA, XB) that will lead Alice and Bob to the desired answer fA(XA, Z(XA, XB)) ∧ fB(XB, Z(XA, XB)). The complexity of the protocol is the of the game should be the and of all queries in IB. Since we are working under a distribution, the bit length of the prover's message Z(XA, XB) is a random variable, and we define the complexity of the protocol as its expectation. Lemma 5. The communication game can be solved by a nondeterministic protocol with complexity ED(cid:2)O(w) · WA ∩ RB + O(WA ∪ RB)(cid:3). Proof. We will use a retrieval dictionary (a.k.a. a Bloomier filter, or a dictionary without membership). Such a dictionary must store a set S from universe U with k bits of associated data per element of S. When queried for some x ∈ S, the dictionary must retrieve x's associated data. When queried about x /∈ S, it may return anything. One can construct retrieval dictionaries with space O(kS + lg lg U ); see e.g. [7]. The message Z(XA, XB) of the prover will consist of the addresses and contents of the cells X = WA ∩ RB, taking O(w) bits each. In addition, he will provide a retrieval dictionary for the symmetric difference WA∆RB = (WA \ RB) ∪ (RB \ WA). In this dictionary, every element has one associated bit of data: zero if the cell is from WA \ RB and one if from RB \ WA. The dictionary takes O(lg w + WA ∪ RB) bits. Alice first simulates the data structure on IA. Then she verifies that all cells X were actually written (X ⊆ WA), and their content is correct. Furthermore, she verifies that for all cells from WA \X, the retrieval dictionary returns zero. If some of this fails, she rejects with a false. Bob simulates the data structure on IB. The algorithm may read cells of the following types: • cells previously written during IB: Bob knows their contents. • cells from X: Bob uses the contents from public proof (Alice verified these contents). • cells for which the retrieval dictionary returns one: Bob uses the contents from the fixed memory snapshot before the beginning of IA (Alice verified she didn't write such cells). • cells for which the retrieval dictionary return zero: Bob rejects. The prover is trying to cheat, since in a correct simulation all cells of RB \ X has a one bit in the dictionary. If neither player rejects, we know that RB \ X is disjoint from WA \ X, so the simulation of Bob is correct. Finally Bob rejects if any of his answers are false. 3 Lower Bound for Union -- Link -- Find and Incremental Connectivity This section proves Theorem 2: 6 lg lg n ) worst-case time and LINK in tL = ) worst-case time, must have worst-case CONNECTED query time tQ ≥ n1−o(1) in the Any data structure supporting UNION in tU = o( lg n o( lg n log tU cell-probe model with cells of w = O(lg n) bits. With hindsight, define: ε = max((cid:18)tU lg lg n lg n (cid:19)1/2 ,(cid:18) tL lg tU lg n (cid:19)1/4) = o(1). Also define B = t1/ε U . We will later need: tU ≤ tL ≤ ε2 lg n lg lg n ε3 lg n lg B = ε4 lg n lg tU (1) (2) Finally, we define two parameters C = nε and M = n1−ε. The starting point of our hard instance is essentially taken from Fredman and Saks' seminal paper [8]. The hard instance will randomly construct a forest of M trees. Each tree will be a perfect tree of degree B and height logB(n/M ). On layer 0 of the forest we have the M roots. On layer i, we have exactly M · Bi vertices with Bi vertices from each tree. We can describe the edges between level i and i − 1 as a function fi : [M · Bi] → [M · Bi−1] that is balanced: for each x ∈ [M Bi−1], (fi)−1(x) = B. We will use the following convenient notation for composition: f≥i = fi ◦ fi+1 ◦ · · · . For example, the ancestor on level i − 1 of leaf x is f≥i(x). Our hard instance will insert the edges describing fi's in bottom-up fashion (i.e. by decreasing i, from the largest level up to the roots). We call "epoch i" the period of time when the edges fi are inserted. Let Wi (respectively Ri) be the cells written (respectively, read) in epoch i. All the above edges are added in union -- find style from roots of current trees, i.e. the hard instance only runs UNION operations for this part of the construction. More precisely, before epoch i the future roots vi−1,· on level i − 1 are singletons, and for each level i node vi,j, we execute UNION(vi−1,fi(j), vi,j). It follows that Wi + Ri ≤ M · BitU. We last written in epoch i. will use the following convenient notation for set union: W≤i = Sj≤i Wj. The cells Wi \ W<i are those The above constitutes the hard case for union -- find from [8]. At this point [8] show that running FIND on a random leaf requires reading cells from most epochs, hence forcing the expected time of FIND to be Ω(lg n/ lg B). Our goal is to show that linking arbitrary vertices may lead to much more expensive queries (even if we only allow Boolean connectivity queries). We will describe some very powerful metaqueries that combines links to roots and leaves with a few connectivity queries to reveal far more information than if we only had the regular connectivity queries. The metaqueries will be provably hard to answer, so if the links are done too quickly, the queries must be very slow. Our graph contains C additional special vertices a1, ..., aC , conceptually colored with the colors 1 . . C. Each colored vertex ai is now linked to M/C nodes on level 0 (the final roots of our trees). This is done in a fixed pattern: colored vertex 1 is connected to roots 1, . . . , M/C; colored vertex 2 to the next M/C roots; etc. We say the root color of a vertex is the color that its root is connected to. Conceptually, the hard distribution colors a random set Q of exactly M leaves and verifies that these are the root colors. To 7 implement this test, we run LINK between each query leaf and the proposed colored vertex. Then, for i = 2 . . C, we run a CONNECTED query asking whether colored vertex i is connected to colored vertex i − 1, followed by inserting an edge between these two color vertices. The metaquery returns "true" iff all connectivity queries return negative answers. We claim that if the metaquery answers true, the coloring of Q must be consistent with the coloring of the roots. Indeed, if some leaf is colored i and its root is colored j 6= i, this inconsistency is caught at step max{i, j}. At this step, everything with color ≤ max{i, j} − 1 has been connected into a tree, so the connectivity query will return true. Let χ(Q) be the coloring of leaves in Q that matches their root colors. In the hard distribution, the metaquery always receives proposed colors from χ(Q), so it should answer true. Nevertheless, the data structure will need to do a lot of work to verify this. Let RQ be the cells read during the metaquery. We have RQ ≤ C · tQ + 2M · tL. The main claim of our proof is: Lemma 6. For any i ∈ {1, . . . , logB(n/M )}, we have E[RQ ∩ (Wi \ W<i)] = Ω(εM ). by construction (they contain the cells last written in epoch i), so E[RQ] ≥ Pi Before we prove the lemma, we show how it implies our lower bound. The sets Wi \ W<i are disjoint E[RQ ∩ (Wi \ W<i)]. Remember that we have logB(n/M ) = O(logB(nε)/ lg B) = O(ε logB n) epochs. Thus E[RQ] = Ω(M · ε2 logB n). We compare this to the worst-case upper bound RQ ≤ C · tQ + 2M · tL. By assumption of Theorem 2, tL = o( lg n ). By (2) we have tL ≤ ε3 logB n = o(ε2 logB n), ensuring that the second term log tU of the upper bound is negligible. It follows that C ·tQ = Ω(M ·ε2 logB n), hence tQ = Ω(ε2M/C logB n) = n1−2ε · ω(tL) ≥ n1−o(1). Proof of Lemma 6 Fix i. We will prove the stronger statement that the lower bound holds no matter how we fix the edges outside epoch i (all fj's for j 6= i). To dominate the work of later epochs i − 1, . . . , 1, we consider Bi i.i.d. metaqueries. Choose sets Q1, Q2, . . . , QBi independently, each containing M uniformly chosen leaves. Starting from the memory state where all trees are completely built and the roots have been colored, we simulate each metaquery (Qj, χ(Qj)) in isolation. We do not need to write any cells in this simulation, for the cell-probe model has unbounded state to remember intermediate results and in our hard distribution there is no operation after the metaquery. Thus the simulations of the different metaqueries do not influence each other. Let R⋆ be the cells read by all Bi metaqueries. By linearity of expectation, E[R⋆ ∩ (Wi \ W<i)] ≤ Bi · E[RQ ∩ (Wi \ W<i)]. (3) Let Q⋆ =Sj Qj. Since we have fixed all f>i, asking about the root color of a leaf q ∈ Q⋆ is equivalent to asking about the root color of node f>i(q) on level i. Claim 7. We have E[f>i(Q⋆)] ≥ (1 − 1 e )M Bi. Proof. Each leaf x in some Qj is chosen uniformly, so its ancestor f<i(x) is also uniform. The M · Bi trials are independent (for different Qj, Qk), or positively correlated (inside the same Qj, since the leaves must be distinct). Thus, we expect to collect (1 − 1/e)M Bi distinct ancestors. By the Markov bound f>i(Q⋆) ≥ 1 sequence (Q1, Q2, . . . , QBi W<i)] by at most (1 − 2/e)−1 = O(1). ) to a value that achieves f>i(Q⋆) ≥ 1 2 M Bi with probability at least 1 − 2/e. Thus we may fix the 2 M Bi while increasing E[R⋆ ∩ (Wi \ 8 The only remaining randomness in our instance are the edges fi from epoch i and the proposed colorings χ(Qj) given to each metaquery Qj. To be valid, these colorings are functions of fi, for as soon as we know fi, we know the whole forest including the root colors of all the leaves in the different Qj. The metaquery colors have to agree on common leaves, so they provide us a coloring χ(Q∗). With fi yet unknown, we claim that χ(Q⋆) has a lot of entropy: Claim 8. H(χ(Q⋆)) = Ω(M Bi lg C). Proof. Let X be the unknown coloring of all vertices on level i. We claim it has entropy H(X) = M Bi · log2 C − O(C lg n). We have not fixed anything impacting this coloring so X is a random balanced vector from [C]M Bi. Indeed, any balanced coloring is equiprobable, because the coloring of the roots is balanced, all trees have the same sizes, and fi is a random balanced function. We claim that it has entropy H(X) = M Bi · log2 C − O(C lg n). The number of balanced colorings is given by the multinomial coefficient (cid:0) M Bi/C, M Bi/C, ...(cid:1). This is the central multinomial coefficient, so it is the largest. It must therefore be at least a fraction (M Bi)−C ≥ n−C of the sum of all multinomial coefficients. This sum is C M Bi (the total number of possible colorings), so H(X) ≥ log2(C M Bi /nC ) = M Bi log2 C − C log2 n. M Bi We argue that H(χ(Q⋆)) = Ω(M Bi lg C). Indeed, χ(Q⋆) reveals the coloring of vertices f<i(Q⋆) on 2 M Bi. Given χ(Q⋆), to encoding X, we just write all other colors explicitly 2 M Bi log2 C ≥ M Bi log2 C − C lg2 n − 2 M Bi log2 C bits. Therefore H(χ(Q⋆)) ≥ H(X) − 1 level i, which number at least 1 using 1 1 2 M Bi log2 C = Ω(M Bi lg C). We consider the communication game in which Alice represents the time of epoch i (her private input is XA = fi), and Bob represents the time of epochs i − 1, . . . , 1 and the metaqueries (his private input is XB = χ(Q⋆)). Their goal is to determine whether all the metaqueries return true. Claim 9. Any zero-error protocol must have average case bit complexity Ω(M Bi lg C). Proof. We turn our attention to the communication game. The set of inputs of Alice and Bob that lead to a fixed transcript of the communication protocol forms a combinatorial rectangle. More precisely, a transcript t represents a sequence of transmissions between Alice and Bob. On Alice's side, there will be a certain set X t A of inputs making her follow t provided that Bob follows t, and we have a corresponding input set X t B from Bob. Inputs XA and XB will lead to t if and only if (XA, XB) ∈ X t B. Since the players must verify XB = χ(Q⋆) and the protocol has zero error, the rectangle cannot contain two inputs of Bob with different χ(Q⋆), that is, X t B = 1 for all valid t. Thus H(t) ≥ H(χ(Q⋆). A × X t We will use Lemma 4 to obtain a communication protocol, setting the rate of false positives in the Bloom filter to p = 1 . The cells written in Alice's interval are precisely Wi; the cells read in Bob's interval are R<i ∪ R⋆ where R⋆ is the union of the cells read by all the metaqueries. By Lemma 4, the communication complexity is: lg2 n + Wi · O(lg 1 p ) + pR<i ∪ R⋆ · O(w)(cid:3) E(cid:2)(R<i ∪ R⋆) ∩ (Wi \ W<i) · O(w) ≤ E(cid:2)R⋆ ∩ (Wi \ W<i) + R<i(cid:3) · O(w) ≤ E(cid:2)R⋆ ∩ (Wi \ W<i)(cid:3) · O(w) + O(M Bi−1tUw) + O(M Bi · tU lg lg n) + O(M Bi · tLw lg2 n + O(Wi lg lg n) + R⋆ · O(pw) ) 9 (4) π1 π2 π3 π4 π5 π6 Figure 1: The shape of our graphs. We compare this to the lower bound of Ω(M Bi lg C) = Ω(M Bi · ε lg n) from Claim 9. We will now argue all the terms of (4) except the first are asymptotically negligible compared to the lower bound. Inspecting the terms in order: • Since ε = o(1), we have B = t1/ε • By (1), U = ω(tU/ε), implying M Bi−1 · tUw = o(M Bi · ε lg n), M Bi · tU lg lg n ≤ M Bi ε2 lg n lg lg n lg lg n = o(M Bi · ε lg n) • the last term is always o(M Bi), since tL = o(lg n) and w = O(lg n). As these terms of (4) are dominated by the lower bound, we obtain E[R⋆ ∩ (Wi \ W<i)] = Ω(εM Bi). From (3), linearity of expectation implies E[RQ ∩ (Wi \ W<i)] ≥ E[R⋆ ∩ (Wi \ W<i)]/Bi, so we have completed the proof of Lemma 6 by showing E[RQ ∩ (Wi \ W<i)] = Ω(εM ). As shown earlier, Lemma 6 implies the desired lower bound of Theorem 2. 4 Lower Bound for Dynamic Connectivity Theorem 10. Any data structure for dynamic connectivity in graphs of n vertices that has (amortized) update time tU = o(lg n) must have (amortized) query time tq ≥ n1−o(1). Let ε be such that tU = o(ε2 lg n), and define M = n1−ε and C = nε. The shape of our graphs is depicted in Figure 1. The vertices are points of a grid [M ] × [n/M ]. The edges of our graph are matchings between consecutive columns. Let π1, . . . , πn/M −1 be the permutations that describe these matchings. We let π≤j = πj ◦ πj−1 ◦ · · · ◦ π1. Node i in the first column is connected in column j + 1 to π≤j(i). The graph also contains C special vertices, which we imagine are colored with the colors 1, . . . , C. At all times, a colored vertex is connected to a fixed set of M/C vertices in the first column. (For concreteness, colored vertex 1 is connected to vertices 1, . . . , M/C; colored vertex 2 to the next M/C vertices; etc.) We will allow two meta-operations on this graph: UPDATE and QUERY. Initially, all permutations are the identity (i.e. all edges are horizontal). UPDATE(j, πnew) reconfigures the edges between columns j and j + 1: it sets πj to the permutation πnew. This entails deleting M edges and inserting M edges, so UPDATE takes time 2M · tU. 10 QUERY(j, x) receives a vector χ ∈ [C]M , which it treats as a proposed coloring for vertices on column j. The goal of the query is to test whether this coloring is consistent with the coloring of the vertices in the first column. More specifically, a node i of color a in the first column must have χ[π<j(i)] = a. A QUERY can be implemented efficiently by connectivity operations. First each vertex i in column j is connected to the colored vertex χ[i]. Then, for i = 2 . . M, we run a connectivity query to test whether colored vertex i is connected to colored vertex i − 1. If so, QUERY return false. Otherwise, it inserts an edge between colored vertices i and i − 1 and moves to the next i. At the end, QUERY deletes all vertices it had inserted. The total cell-probe complexity of QUERY is O(M ) · tU + C · tq. It is easy to observe that this procedure correctly tells whether the colorings are consistent (as in our instance of incremental connectivity). We will now describe the hard distribution over problem instances. We assume n M − 1 is a power of two. Let σ be the bit-reversal permutation on {0, . . . , n M − 2}: σ(i) is the reversal of i, treated as a vector of log2( n M − 1, we execute an UPDATE to position j = σ(i) + 1, and a QUERY to the same position j. The update sets πj to a new random permutation. The query always receives the consistent coloring, and should answer true. The total running time is M − 1) bits. For i = 0, . . . , n T ≤ n/M (2M tU + O(M )tU + Ctq) = O(ntU + (n/M )Ctq). If we can prove a lower bound T = ω(ntU), then this will yield a high lower bound for tq. For the lower bound proof, we consider a perfect ordered binary tree with n/M − 1. The leaves are associated with the pairs of UPDATE and QUERY operations in time order. Let W (v) (respectively R(v)) be the set of cells written (respectively, read) while executing the operations in the subtree of v. Note that W (v) ⊆ R(v), since we have assumed a cell must be read before it is written. Our main claim is: Lemma 11. Let v be a node with 2k leaves in its subtree, and let vL, vR be its left and right children. Then E[W (vL) ∩ R(vR) + 1 lg n W (vL) ∪ R(vR)] = Ω(k · εM ). running time is T ≥ Pv Before we prove the lemma, we use it to derive the desired lower bound. We claim that the total expected E[W (vL) ∩ R(vR)], where the sum is over all nodes in our lower bound tree. Consider how a fixed instance is executed by the data structure. We will charge each read operation to a node in the tree: the lowest common ancestor of the time when the instruction executes, and the time when the cell was last written. Thus, each W (vL) ∩ R(vR) corresponds to (at least) one read instruction, so there is no double-counting in the sum. Ω( n M lg n We now sum the lower bound of Lemma 11 over all nodes; observe that Pv kv = Θ( n the tree has n/M − 1 leaves. We obtain Pv T . This is because Pv M ), since E[W (vL) ∪ R(vR)] = M · εM ). The first term is at most T , as explained above. In the second term is also bounded by M since every cell probe is counted once for every M · εM ) = Ω(ε2n lg n). In our construction, the M Ctq). Since tU = o(ε2 lg n), the second term must dominate: E[W (vL) ∪ R(vR)] ≤ T lg n M lg n ancestor of the time it executes. Thus 2T ≥ Ω( n total running time was T = O(ntU + n nC M tq = Ω(ε2n lg n), so tq > M/C = n1−2ε = n1−o(1). E[W (vL) ∩ R(vR)] + 1 lg nPv M lg n Proof of Lemma 11 We will prove the stronger statement that the lower bound holds no matter how we fix the updates outside node vL. We transform the problem into the natural communication game: Alice receives the update permutations in the subtree vL and Bob receives the colorings of the queries in the subtree vR (the updates are fixed). They have to check whether all queries are positive in the sequence of UPDATE and QUERY operations defined by their joint input. 11 We apply Lemma 5 to construct a nondeterministic communication protocol for this problem, with complexity E[W (vL) ∩ R(vR) · O(lg n) + O(W (vL) ∪ R(vR))]. The conclusion of Lemma 11 follows by comparing this protocol to the following communication lower bound: Lemma 12. The game above has nondeterministic (average-case) communication complexity Ω(kM lg C). Proof. Let XA and XB be the inputs of the two players. For any choice of XA, there is a unique sequence of colorings XB that Bob should accept. As in the proof of Lemma 9, we conclude that the public proof is an encoding of XB so we can lower bound the complexity via H(XB). Let JA and JB be the columns touched (updated and queried) in Alice's input and in Bob's input. Bob's input consists of the coloring of column j, for each j ∈ JB. This is π<j applied to the fixed coloring in the first column. Since JA and JB are defined by the bit-reversal permutation, we know that they interleave perfectly: between every two values in the sorted order of JB, there is a unique value in JA. Thus, the coloring for different j ∈ JB are independent random variables, since an independent uniform permutation from JA is composed into π<j compared to all indices from JB below j. Each coloring is uniformly distributed among balanced colorings, so it has entropy M lg C − O(C lg M ) (c.f. proof of Claim 8). We conclude that H(XB) = Ω(kM lg C). 5 Amortized link-find bounds The union -- find problem has been studied into excruciating detail and is now essentially understood. From an amortized perspective, Tarjan [15] showed that a sequence of n−1 unions and m finds can be supported in time O(n + mα(m, n)). See [17, 11] for different analyses and trade-offs between amortized running times. From a worst-case perspective, the classic union-by-rank gives union in constant time and find in O(log n) time. Trade-offs were addressed by Blum [6], with an improvement by Smid [14]. They show that, if the time for union is bounded by tUNION, FIND can be supported in worst-case O(lg n/ lg tUNION). Finally, Alstrup et al. [1] showed that the amortized and worst-case trade-offs can be achieved simultaneously. These bounds are known to be optimal in the powerful cell-probe model (see below for a review of the lower bounds). A similar phenomenon appeared in connection with union-find with deletions. Kaplan et al. [10] con- sidered this problem but wanted bounds where n represented the size of the actual tree(s) involved in an operation. All worst-case bounds are trivially local, and [10] proved refined the standard amortized analysis to work locally, though the bound becomes a bit weird with the standard notation: α(n) is OK, but other- wise, it becomes α(n · ⌈M/N ⌉, n) amortized time per find where M and N are the global number of finds and unions, respectively. With the notation from [2], the local amortized find bound is O(α⌈M/N ⌉(n)). They showed how to augment union-find with a delete operation if we when deleting an element x, first find the root and then perform a local rebuilding step in the tree that x is deleted from. For tU = O(1), this gave them both find-root and delete in O(log n) time. Similar to our case, they asked if the deletion time could be made better than this find time. For the deletions, the answer was yes. Alstrup et al. [2] proved that deletions could be supported locally in constant time without affecting the O(log n) bound on the query time. Back to original In this section we consider the amortized complexity of the link-find problem which is like the union-find problem except that we can link arbitrary nodes, not just roots. In link-find, we may not necessarily have an obvious notion of a root that we can find. The fundamental requirement to a component is that if we call find from any vertex in it, we get the same root as long as the component is not linked with other components. 12 Let u be the number of updates and q the number of queries. With union-find, the complexity over the whole sequence is Θ(α(q, u)q) if q ≥ u, and Θ(α(q, q)q + u) if q ≤ u. With link-find, we get the same complexity when q ≥ u, but a higher complexity of Θ(α(q, u)u) when q ≤ u. Thus, with link-find, we get a symmetric formula in q and u of Θ(α(max{q, u}, min{q, u}) max{q, u}). (5) We get the upper-bound in (5) via a very simple reduction to union-find. 5.1 The link-find data structure Nodes have three types: free, leaf, and union nodes. A leaf node has a pointer to a neighboring union node, and the union nodes will participate in a standard union-find data structure. The parent of a leaf is the union node it points to. The parent of a union node is as in the union-find structure and the parent of a root is the root itself. All nodes start as free nodes. We preserve the invariant that if a component has a free node, then all nodes in the component are free. To perform a find on a free node v, we scan the component of v. If it is a singleton, we just return it. Otherwise, assuming some initial tie-breaking order, we make the smallest node in the component a union node and all other nodes leaf nodes pointing to is. The union node which is its own root is returned. All this is paid for by the nodes that lost their freedom. To perform a find on a non-free node, we perform it on the parent which is in the union-find data structure. We now consider the different types of links. When we perform link between two free nodes, nothing happens except that an edge is added in constant time. If we link a free node v with a non-free node w, we make all nodes in the components of v leaves pointing to the parent of w. This is paid for by the new leaves. If we link two non-free nodes, we first perform a find from their parents which are union nodes. If they have different roots we unite them. This completes the description of our link-find data structure which spends linear time reducing to a union-find data structure. A union node requires a find on a non-singleton node, so the number of union nodes is at most min{q, u}. Concerning finds in the union-find data structure, we get one for each original find on a non-free node. In addition, we get two finds for each link of two non-free nodes, adding up to at most q + 2u finds. Our total complexity is therefore O(u + q + α(q + 2u, min{q, u})(q + 2u)) = O(α(max{q, u}, min{q, u}) max{q, u}). We are going to present a matching lower bound. 5.2 The link-find data structure for a forest We will now show that it is the links between nodes in the same components that makes link-find harder than union-find in the sense that if no such links appear, we get the same O-bound as with union-find. The modification to the above link-find reduction is simple. Using standard doubling ideas, we can assume that u and q are known in advance. If q ≥ u, we are already matching the union-find bound, so assume q ≤ u. 13 To do a find on a free node, we again scan its component. However, if it has less than α(q, q) nodes, we just return the smallest but leaving the component free. Otherwise, as before, we make the smallest node a union node and all other nodes leaf nodes pointing to it. This is the only change to our link-find algorithm. In the case where the component has α(q, q) nodes, we clearly pay only O(α(q, q)) for a find. The advantage is that we now create at most u/α(q, q) union nodes. Links involving a free node have linear total cost, and now, when we perform a link of non-free nodes, we know they are from different components to be united, so this will reduce the number of union roots by one. Hence we get at most 2u/α(q, q) finds resulting from these links. Thus, in the union-find data structure, we end up with q + 2u/α(q, q) finds and u/α(q, q) unions. The total cost is O(u + q + α(q + 2u/α(q, q), u/α(q, q))(q + 2u/α(q, q)) = O(α(q, q)q + n) time. The simplification uses that α is increasing in its first and decreasing in its second argument, and that the whole time bound is linear if q ≤ u/α(q, q). References [1] S. Alstrup, A. M. Ben-Amram, and T. Rauhe. Worst-case and amortised optimality in union-find. In Proc. 31st ACM Symposium on Theory of Computing (STOC), pages 499 -- 506, 1999. [2] S. Alstrup, T. Rauhe, I. L. Gørtz, M. Thorup, and U. Zwick. Union-find with constant time deletions. In Proc. 32nd International Colloquium on Automata, Languages and Programming (ICALP), pages 78 -- 89, 2005. [3] L. Banachowski. A complement to Tarjan's result about the lower bound on the complexity of the set union problem. Information Processing Letters, 11(2):59 -- 65, 1980. [4] A. M. Ben-Amram and Z. Galil. A generalization of a lower bound technique due to Fredman and Saks. Algorithmica, 30(1):34 -- 66, 2001. See also FOCS'91. [5] B. H. Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422 -- 426, 1970. [6] N. Blum. On the single-operation worst-case time complexity of the disjoint set union problem. SIAM Journal on Computing, 15(4):1021 -- 1024, 1986. See also STACS'85. [7] M. Dietzfelbinger and R. Pagh. Succinct data structures for retrieval and approximate membership. In Proc. 35th International Colloquium on Automata, Languages and Programming (ICALP), pages 385 -- 396, 2008. [8] M. L. Fredman and M. E. Saks. The cell probe complexity of dynamic data structures. In Proc. 21st ACM Symposium on Theory of Computing (STOC), pages 345 -- 354, 1989. [9] H. Kaplan, N. Shafrir, and R. E. Tarjan. Meldable heaps and boolean union-find. In Proc. 34th ACM Symposium on Theory of Computing (STOC), pages 573 -- 582, 2002. [10] H. Kaplan, N. Shafrir, and R. E. Tarjan. Union-find with deletions. In Proc. 13th ACM/SIAM Sympo- sium on Discrete Algorithms (SODA), pages 19 -- 28, 2002. 14 [11] J. A. L. Poutr´e. New techniques for the union-find problems. In Proc. 1st ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 54 -- 63, 1990. [12] J. A. L. Poutr´e. Lower bounds for the union-find and the split-find problem on pointer machines. Journal of Computer and System Sciences, 52(1):87 -- 88, 1996. See also STOC'90. [13] M. Patras¸cu and E. D. Demaine. Logarithmic lower bounds in the cell-probe model. SIAM Journal on Computing, 35(4):932 -- 963, 2006. See also SODA'04 and STOC'04. [14] M. H. M. Smid. A data structure for the union-find problem having good single-operation complexity. ALCOM: Algorithms Review, Newsletter of the ESPRIT II Basic Research Actions Program, 1990. [15] R. E. Tarjan. Efficiency of a good but not linear set union algorithm. Journal of the ACM, 22(2):215 -- 225, 1975. [16] R. E. Tarjan. A class of algorithms which require nonlinear time to maintain disjoint sets. Journal of Computer and System Sciences, 18(2):110 -- 127, 1979. See also STOC'77. [17] R. E. Tarjan and J. van Leeuwen. Worst-case analysis of set union algorithms. Journal of the ACM, 31(2):245 -- 281, 1984. [18] M. Thorup. Near-optimal fully-dynamic graph connectivity. In Proc. 32nd ACM Symposium on Theory of Computing (STOC), pages 343 -- 350, 2000. Appendix α. Lower Bounds for Amortized Link -- Find We will now sketch a proof for the lower-bound in (5) with u link updates and q find queries. When q ≥ u, we get this from the union-find lower bound of Ω(α(q, u)q) from [8]. However, for q ≪ u, we need to prove a higher lower-bound than that for union-find. The lower bound we want in this case is Ω(α(u, q)u). We would get the desired lower bound if we could code a union-find problem with Ω(q) updates and Ω(u) queries. We cannot make such a black-box reduction, but we can do it inside the proof construction from [8]. We will only present the idea in the "reduction". For a real proof one has to carefully examine the whole proof from [8] to verify that nothing really breaks. The lower bound construction from [8] proceeds in rounds. We start with singleton roots. In a union round, we pair all current roots randomly, thus halving the number of roots. In a find round, we perform a number of finds on random leaves. The number of finds are adjusted depending on the actions of the data structure. From [9] we know that the lower bound also holds if the finds just have to verify the current root of a node. In our case, we will start with n roots. In a union-round, we just link roots as in union-find. However, in a find round, instead of calling find from a leaf v, we link v to its current root r. We want to turn this leaf-root link into a verification. We will not do that for the individual links, but we will do it for the find-round as a whole (one needs to verify that this batching preserves the lower-bound). At the end of the find-round, we simply perform a find on each root. All these finds should return the root itself. If one of the links (v, r) had gone to the wrong root and r′ was the correct root, then r and r′ would be connected in the same tree, which means that they cannot both be roots. One of the finds would therefore return a different root. If the union-find problem we code used f finds, then our link-find solution ends up with u = n − 1 + f link updates and q = n − 1 find verifications, hence with the desired lower bound of Ω(α(f, n)f ) = Ω(α(u, q)u). 15
1301.4952
2
1301
2013-04-25T20:00:55
Single and multiple consecutive permutation motif search
[ "cs.DS" ]
Let $t$ be a permutation (that shall play the role of the {\em text}) on $[n]$ and a pattern $p$ be a sequence of $m$ distinct integer(s) of $[n]$, $m\leq n$. The pattern $p$ occurs in $t$ in position $i$ if and only if $p_1... p_m$ is order-isomorphic to $t_i... t_{i+m-1}$, that is, for all $1 \leq k< \ell \leq m$, $p_k>p_\ell$ if and only if $t_{i+k-1}>t_{i+\ell-1}$. Searching for a pattern $p$ in a text $t$ consists in identifying all occurrences of $p$ in $t$. We first present a forward automaton which allows us to search for $p$ in $t$ in $O(m^2\log \log m +n)$ time. We then introduce a Morris-Pratt automaton representation of the forward automaton which allows us to reduce this complexity to $O(m\log \log m +n)$ at the price of an additional amortized constant term by integer of the text. Both automata occupy $O(m)$ space. We then extend the problem to search for a set of patterns and exhibit a specific Aho-Corasick like algorithm. Next we present a sub-linear average case search algorithm running in $O(\frac{m\log m}{\log\log m}+\frac{n\log m}{m\log\log m})$ time, that we eventually prove to be optimal on average.
cs.DS
cs
Single and multiple consecutive permutation motif search Djamal Belazzougui1, Adeline Pierrot2, Mathieu Raffinot2, and St´ephane Vialette3 1 Department of Computer Science, FI-00014 University of Helsinki, Finland 2 LIAFA, Univ. Paris Diderot - Paris 7, 75205 Paris Cedex 13, France 3 LIGM CNRS UMR 8049, Universit´e Paris-Est, France [email protected] Abstract. Let t be a permutation (that shall play the role of the text) on [n] and a pattern p be a sequence of m distinct integer(s) of [n], m ≤ n. The pattern p occurs in t in position i if and only if p1 . . . pm is order- isomorphic to ti . . . ti+m−1, that is, for all 1 ≤ k < (cid:96) ≤ m, pk > p(cid:96) if and only if ti+k−1 > ti+(cid:96)−1. Searching for a pattern p in a text t consists in identifying all occurrences of p in t. We first present a forward automaton which allows us to search for p in t in O(m2 log log m + n) time. We then introduce a Morris-Pratt automaton representation of the forward automaton which allows us to reduce this complexity to O(m log log m + n) at the price of an additional amortized constant term by integer of the text. Both automata occupy O(m) space. We then extend the problem to search for a set of patterns and exhibit a specific Aho-Corasick like algorithm. Next we present a sub-linear average case search algorithm running in O time, that we eventually prove to be optimal on average. (cid:16) m log m (cid:17) log log m + n log m m log log m 1 Introduction Two sequences are order-isomorphic if the permutations required to sort them are the same. A sequence p is said to be a pattern (or occurs) within a sequence t if t has a subsequence that is order-isomorphic to p. Pattern involvement per- mutations and sequences has now become a very active area of research [9]. However, only few results on the complexity of finding patterns in permutations and sequences are known. It appears to be a difficult problem to decide of two given permutations π and σ whether σ occurs in π, and in this generality the problem is NP-complete [6]. For σ ∈ Sm and π ∈ Sn, the O(nm) time brute-force algorithm was improved to O(n0.47m+o(m)) time in [2]. There are several ways in which this notion of permutation patterns may be generalized, and we focus here on consecutive patterns (i.e. the match is required to consist of contiguous elements) [9]. A sequence p is said to be a consecutive pattern or consecutively occurs within a sequence t if t has a substring that is order-isomorphic to p. Searching for a pattern p in a text t consists in identifying all occurrences of p in t. Recently, using a modification of the classical Knuth-Morris-Pratt string 3 1 0 2 r p A 5 2 ] S D . s c [ 2 v 2 5 9 4 . 1 0 3 1 : v i X r a 2 matching algorithm, a O(n + m log m) time algorithm has been proposed for checking if a given sequence t of length n contains a substring which is order- isomorphic to a given pattern p of length m [10]. The time complexity reduces to O(n + m) time under the assumption that the symbols of the pattern can be sorted in O(m) time. The set of all integers from 1 to n is written [n]. Let t be a permutation of length n and p be a sequence of m ≤ n distinct integers in [n]. First we present a forward automaton which allows us to search for p in t in O(m2 log log m + n) time. Next, we introduce a Morris-Pratt automaton representation [8] of the for- ward automaton which allows us to reduce this complexity to O(m log log m + n) at the price of an additional amortized constant term by integer of the text. Both automata occupy O(m) space. We then extend the problem to search for a set of patterns and exhibit a specific Aho-Corasick like algorithm. Finally we present a sub-linear average case search algorithm running in O(n log m/ log log m) time that we eventually prove to be optimal on average. Let us define some notations. The set of all permutations on [n] is denoted by Sn. Let Σn = [n]. Abusing notations, we consider in this paper permutations of Sn as strings without symbol repetition, and we denote by Σ∗ n the set of all strings without symbol repetition (including the empty string), where each symbol is an integer in [n]. A prefix (resp. suffix, factor) u of p is a string such that p = uw, w ∈ Σ∗ n. We also denote w the number of integer(s) in a string w, w ∈ Σ∗ n. We eventually denote pr the reverse of p, that is, the string formed by the symbols of p read in the reverse order. We denote by p≡ the set of words of Σ∗ n which are order-isomorphic to p. n. (resp. p = wu, w ∈ Σ∗ n, p = wuz, w, z ∈ Σ∗ The following property is useful for designing automaton transitions. n and w = w1 . . . w(cid:96) ∈ Σ∗ Property 1. Let p = p1 . . . pm ∈ Σ∗ n, (cid:96) < m, such that w is order-isomorphic to p1 . . . p(cid:96), and let α ∈ Σ. Testing if wα is order-isomorphic to p1 . . . p(cid:96)p(cid:96)+1 can be performed in constant time storing only a pair of integers. Proof. The pair of integers (x1, x2) is determined as follows: x1 ≤ (cid:96) is the greatest number such that px1 is the position of one of the largest integer in p1..p(cid:96) which is smaller than p(cid:96)+1, if any. Otherwise, we fix x1 arbitrarily to −∞. Let x2 ≤ (cid:96) be the greatest position of one of the smallest integer in p1..p(cid:96) which is larger than p(cid:96)+1, if any. Otherwise, we fix x2 to +∞. Now, it suffices to test (cid:117)(cid:116) if wx1 < α < wx2 to verify if wα is order-isomorphic to p1 . . . p(cid:96)+1 We define a function rep(p = p1 . . . pm, j) which returns a pair of integers (x1, x2) that represents the pair defined in property 1 for the prefix of length j of a motif p. 2 Tools Before proceeding, we first describe some useful data structures we shall use as basic subroutines of our algorithms. The problem called predecessor search problem is defined as follows: given a set S = {x1, x2, . . . xn} ⊂ [u] (u is called the size of the universe), we support the following query: given an integer y return its 3 predecessor in the set S, namely the only element xi such that xi ≤ y ≤ xi+1 4. In addition, in the dynamic case, we also support updates: add or remove an element from the set S. The standard data structures to solve the predecessor search are the balanced binary search trees [1,5]. They use linear space and support queries and updates in worst-case O(log n) time. However, there exists better data structures that take advantage of the structure of the integers to get better query and update time. Specifically, the Van-Emde-Boas tree [13] supports queries and updates in (worst-case) time O(log log u) using O(u) space. Using randomization, the y-fast trie achieves linear space with queries supported in time O(log log u) and updates supported in randomized O(log log u) time. The problem has received series of improvements which culminated with Andersson and Thorup's result [4]. They achieve linear space with queries and updates log log n )) (the update time is still randomized). A special case occurs when space n is available and the set of keys S is known to be smaller than logc n for some constant c. In this case all operations are supported in worst-case constant time using the atomic-heap [14]. (cid:113) log n supported in O(min(log log u, 3 Forward search automaton The problem we consider is to search for a motif p in a permutation t without preprocessing the text itself. By analogy to the simpler case of the direct search n) p≡. We then of a word p in text t, we build an automaton that recognizes (Σ∗ prove its size to be linear in the length of the pattern. We formally define our forward search automaton FD(p) built on p = p1 . . . pm as follows: -- m + 1 states corresponding to each prefix (including the empty prefix) of p, state 0 is initial, state m is terminal; -- m forward transitions from state j to j + 1 labelled by rep(p, j + 1); -- bt backward transitions δ(x, [i, j]), where x numbers a state, 0 ≤ x ≤ m, i ∈ 1, . . . , x∪−∞, j ∈ 1, . . . , x∪+∞, defined the following way: δ(x, [i, j]) = q if and only if for all pi < α < pj (resp. k = α < pj if i = −∞, pi < α if j = +∞), the longest prefix of p that is order-isomorphic to a suffix of p1 . . . pxα is p1 . . . pq. We also impose some constraints on outgoing transitions. Let x be a given state corresponding to the prefix p1 . . . px. Let us sort all pi, 1 ≤ i ≤ x and consider the resulting order pi0 = −∞ < pi1 < . . . < pik < +∞ = pik+1. We build one outgoing transition for each interval [pij , pij+1], excepted if pij+1 = pij + 1. Also we merge transitions from the same state to the same state that are labeled by consecutive intervals. It is obvious that the resulting automaton recognizes a given pattern in a permutation by reading one by one each integer and choose the appropriate transition. Figure 1 shows such an automaton. 4 By convention, if all the elements of S are smaller than y, then return −∞ and if they are larger than y then return xn 4 Fig. 1. Forward automaton built on p = 4 12 6 16 10. State 0 is initial and state 5 is terminal. The main result on the structure of the forward automaton is the following. Lemma 1. The number of transitions of the forward automaton built on p1 . . . pm is linear in m. Lemma 1 combined with the fact that the outgoing transitions from each state q are sorted accordingly to the closest proximity to q of their arrival state leads to the following lemma. Lemma 2. Searching for a consecutive motif p = p1 . . . pm in a permutation t = t1 . . . tn using a forward automaton built on p takes O(n) time. We can build the forward automation in O(m2 log log m) time. However, we defer the proof of this construction for the following reason. This O(m2 log log m) complexity might be too large for long patterns. Nevertheless, we show below that we can compute in a first step a type of Morris-Pratt coding of this au- tomaton which can either (a) be directly used for the search for the pattern in the text and will preserve the linear time complexity at the cost of an amortized constant term by text symbol, or (b) be developed to build the whole forward automaton structure. Therefore we present and build a new automaton MP that is a Morris-Pratt representation of the forward automaton. The idea is to avoid building all back- ward transitions by only considering a special backward single transition from each state x, x > 0 named failure transition. We formally define our automaton MP (p) built on p = p1 . . . pm the following way: -- m + 1 states corresponding to each prefix (including the empty prefix) of p, state 0 is initial, state m is terminal; -- m forward transitions from state j to j + 1 labelled by rep(p, j + 1); -- m failure transitions (non labelled) defined by: a failure transition connects a state j > 0 to a state k < j if and only if p1 . . . pk is the largest order- isomorphic border of p1 . . . pj. +∞]∞−[,,1[2]+∞],2[+∞],2[,2[4]∞−[,1]∞−[,1]∞−[,3]∞−[,3],5[4]+∞],4[+∞],4[∞−[,5],3[2],3[2]012345,1[+∞] 5 Fig. 2. MP automaton built on p = (4, 12, 6, 16, 10). State 0 is initial and state 5 is terminal. Backward transitions are failure transitions. Reading a text t through the MP representation of the forward automaton is performed the following way. Let us assume we reached state x < m and we read a symbol ti at position i of the text. Let [k, (cid:96)] = rep(p, x + 1). If ti ∈ [ti−m+k, ti−m+l] we follow the forward transition and the new current state is x + 1. Otherwise, we fail reading ti from x and we retry from state q = fail(x) and so-on until (a) either q is undefined, in which case we start again from state 0, either (b) a forward transition from q to q + 1 works, in which case the next current state is q + 1. Lemma 3. Searching for a pattern p in a text t1 . . . tm using the Morris-Pratt representation of the forward automaton built on p is O(n) time. In order to prove lemma 3 we need to focus on the classical notion of border that we extend to our framework. n,w < p that is Definition 1. Let p ∈ Σ∗ order-isomorphic to a suffix of p but also order-isomorphic to a prefix of p. n. A border of p is a word wΣ∗ The construction of the forward automation relies of the maximal border of each prefix that is followed by an appropriate integer in the pattern. The Morris-Pratt approach is based on the following property: Property 2. A border of a border is a border. This property allows us to replace the direct transition of the forward algo- rithm by a search along the borders, from the longest to the smallest, to identify the longest one that is followed by the appropriate integer. We prove now that we can build the Morris-Pratt representation of the forward automaton efficiently. Lemma 4. Building an Morris-Pratt representation of the forward automa- ton on a consecutive motif p = p1 . . . pm can be performed in (worst-case) O(m log log m) time. Lemma 3 and 4 allow us to state the main theorem of this section. Theorem 1. Searching for a consecutive motif p = p1 . . . pm in a permutation t = t1 . . . tn can be done in O(m log log m + n) time. The Morris-Pratt representation of the forward automaton permits to search directly in the text at the price of larger amortized complexity (considering the constant hidden by the O notation) than that required by searching with the forward automaton directly. If the real time cost of the search phase is an issue, the forward automaton can be built form its Morris-Pratt representation as follows. +∞]∞−[,,1[2]+∞],2[,3[2]012345,1[+∞] 6 Property 3. Building the forward automaton of a consecutive motif p = p1 . . . pm can be performed in O(m2 log log m) time. An interesting point is that the construction of the forward automaton from its Morris-Pratt representation can also be performed in a lazy way, that is, when reading the text. The missing transitions are then built on the fly when needed. 4 Multiple worst case linear motif searching We can extend the previous problem defined for a single pattern to a set of patterns S. We note by d the number of patterns, by m the total length of the patterns and by r the length of the longest pattern. For this problem we adapt the Aho-Corasick automaton [3] (or AC automaton for short). The AC automaton is a generalization of the MP automaton to a set of multiple patterns. We note by P the set of prefixes of strings in S. In order to simplify the description we will assume that the set of patterns S is prefix-free. That is, we will assume that no pattern is prefix of another. Extending the algorithm to the case where S is non- prefix free, should not pose any particular issue. The states of the AC automaton are defined in the same way as in the MP automaton. Each state t in the AC automaton corresponds uniquely to a string p ∈ P . The forward transitions are defined as follows: there exists a forward transition connecting state s to each state corresponding to an element pc ∈ P (where c is a single symbol). Thus this definition of the forward transitions matches essentially the definition of the forward transitions in the MP automaton. The failure transitions are defined as follows: a failure transition a state s corresponding a string p to the state s(cid:48) corresponding to the longest string q such that q ∈ P and q (cid:54)= p. The matching using the AC automaton is done in the same way as in the MP automaton using the forward and failure transitions. 4.1 Our extension of the AC automaton We could use exactly the same algorithm as the one used previously for our variant of the MP automaton with few differences. We describe our modification to AC automaton to adapt it to the case of consecutive permutation matching. An important observation is that we could have two or more elements of P that are both of the same length and order-isomorphic. Those two elements should have a single corresponding state in the AC automaton. Thus, if two or more elements of P are order-isomorphic then we keep only one of them. For the forward transitions, we can a associate a pair of positions (x1, x2) to each forward transition. Then we can check which transition is the right one by checking the condition ti−m+x1 < ti < ti−m+x2 for every pair (x1, x2) and take the corresponding transition. The main problem with this approach is that the time taken would grow to O(d) time to determine which transition to take which can lead to a large complexity if d is very large. Our approach will instead be based 7 on using a binary search tree (or more sophisticated predecessor data structure). With the use of a binary search tree, we can achieve O(log m) time to decide which transition to take. More precisely, each time we read T [i] we insert the pair (ti, i) into the binary search tree. The insertion uses the number ti as a key. Now suppose that we only pass through forward transitions. Then a transition at step i is uniquely determined by: (1) the current state s corresponding to an element p ∈ P ; (2) the position of the predecessor of ti among ti−p . . . ti−1. To determine the predecessor of ti among ti−p . . . ti−1, the binary search tree should contain precisely the p pairs corresponding to ti−p] . . . ti−1. If the predecessor of ti in the binary search tree is a pair (tj, j), we then conclude that the element p[p − j + 1] is the predecessor of ti in p. In order to maintain the binary search tree we must do the following actions during passing through a failure or a forward transition: (1) whenever we pass through a forward transition at a step i we insert the pair (ti, i); (2) whenever we pass through a failure transition from a state corresponding to a prefix p1 to a state corresponding to a prefix p2, then we should remove from the binary tree all the pairs corresponding to the symbols ti−p1 . . . ti−p2. It should be noted that each removal or insertion of a pair into the binary search tree takes O(log r) time. The upper bound O(log r) comes from the fact that we never insert more than r elements in the binary search tree. Since in overall we are doing O(n) insertions or removals, the amortized time should simplify to O(n log r). Finally if we replace binary search tree with a more ef- ficient predecessor data structure, we will be able to achieve randomized time O(n · t) where t = min(log log n, log log r , d) is the time needed to do an op- eration on the predecessor data structure (see section 2 for details). We use the linear space version of the predecessor data structure which guarantees only randomized performance but uses O(r) additional space only. We thus have the following theorem : (cid:113) log r Theorem 2. Searching for set of d consecutive motifs of maximal length r and whose AC automaton has been built and where the longest pattern is of length r can be done in randomized O(nt) time, where t = min(log log n, log log r , d). (cid:113) log r Preprocessing. We now show that the preprocessing phase can be done in worst-case O(m log log r) time. As before our starting point will be to sort all the patterns and reduce the range of symbols of each pattern of length (cid:96) from range [n] to the range [1..(cid:96)]. This takes worst-case time O(m log log r). Recall that two or more elements of P of the same length and order-isomorphic should be associated with the same state in the AC automaton. In order to identify the order-isomorphic elements of P , we will carry a first step called nor- malization. It consists in normalizing each pattern. A pattern p is normalized by replacing each symbol pj by the pair rep(p = p1 . . . pj−1, j) (consisting in the positions of the predecessor and successor among symbols p1 . . . pj−1). This can be done for all patterns in total O(m log log r) time. In the next step, we build a trie on the set of normalized patterns. This takes linear time. The trie naturally determines the forward transitions. More precisely any node in the trie 8 will represent a state of the automaton and the the labeled trie transitions will represent follow transitions. Note that unlike the forward automaton (or the MP automaton) there could be more than one outgoing forward transition from each node. In order to en- code the outgoing transition from each node, we will make use of a hash table that stores all the transitions outgoing from that node. More precisely for each transition labeled by the pair rep(p = p1 . . . pj−1, j) and directed to a state q, the hash table will associate the key p1 associated with the value q. Now that the next transitions have been successfully built, the final step will be to build the failure transitions and this takes more effort. In order to build the failure transitions we decompose the trie into r layers. The first layer consists in the nodes of the trie that represent prefixes of length 1. The second layer consist in all the nodes that represent prefixes of length 2, etc. Next, we will reuse the same algorithm that was used in 4 to build the MP automaton but adapted to work on the AC automaton. Instead of using a single predecessor data structure we will use multiple predecessor data structures and attach a pointer to a predecessor data structure at each trie node. A node of the original non compacted trie will share the same predecessor with its parent, iff it is the only child of its parent. The following building phases will no longer reuse the normalized patterns, but instead reuse the original patterns. To each node, we attach a pointer to one of the original pattern. More precisely if a node has a single child, then his pattern pointer will be the same as its (only) child pattern pointer. If a node has more than one child (in which case it is called a branching node), then it will point to the shortest pattern in its subtree. If a node is a leaf then it will directly point to the corresponding pattern. A predecessor data structure of a node whose pattern pointer points to a pattern of length u will have capacity to hold u keys from universe u and thus will use O(u) space. This is justified by the fact that the predecessor data structure will only hold at most u elements of the patterns and each element value is at most u (recall that the pattern is a permutation of length u). In order to bound the total number of predecessor data structures and their total size, we consider a compacted version of the trie (Patricia trie), where each node with a single child is merged with that single child. A node in the original (non-compacted) trie with two of more children is called branching node. It is clear that the set of nodes of a patricia (compacted) trie are precisely the branching nodes and the leaves of the original trie. It is a well known fact that a Patricia trie with r leaves has at most 2r − 1 nodes in total. Thus the total number of predecessor data structures will be upper bounded by 2r − 1. During the building if a node at layer t has a single child, then that single child at level t + 1 will inherit the predecessor data structure of its parent. Otherwise if the node v at level t has two or more children at level t + 1, then a predecessor data structure is created for each child u. Then if the predecessor data structure of v contains exactly k elements, those elements are precisely xt+1−k . . . xt, where x is string pointed by v. We will insert the k 9 elements yt+1−k . . . yt into the predecessor data structure of u, where y the string pointed by u. In order to bound the total space used by the predecessor data structures, we notice that the total capacities of all predecessor data structures is O(m). This can easily be proved. Because we know that the total length of all patterns is bounded by m, we will also know that the total cumulative length of all strings pointed by branching node is also upper bounded by m. This is because precisely the pointed strings are precisely the shortest strings in the subtrees rooted by the branching node. The same holds for the leaves as the capacities of their respective predecessor data structures will be no more than the total length of the patterns that correspond to the leaves which is O(m). We finally need to bound the total construction time which is dominated by the operations on the predecessor data structures. The time is clearly bounded by O(m log log r). This is by a straightforward argument: as the total sum of the pointed strings is O(m), and we know that each element of a pointed string can only be inserted or deleted once, and furthermore each insert/delete cost precisely O(log log r) worst-case time, we conclude that the total time spent in the predecessor data structure is worst case O(m log log r). We thus have the following theorem: Theorem 3. Building the AC automaton for a set of d consecutive motifs of total length m and where the longest motif is of length r can be done in worst-case O(m log log r) time. 5 Single sublinear average-case motif searching Algorithm forward takes O(n + m log log m) time in the worst case time but also on average. We present now a very simple and efficient average case-algorithm which takes O( m log m log log m + n log m m log log m ) time. In order to search for a pattern p in t, we first build a tree T of all isomorphic- order factors of pr of length 3.5 log m log log m . T is built by inserting each such factor one after the other in a tree and building the corresponding path if it does not already exist. The construction of this tree requires O( m log m log log m ) time (details are given below). The search phase is performed through a window of size m that is shifted along the text. For each position of this window, b = 3.5 log m log log m symbols are read backward from the end of the window in the tree T . Two cases may occurs: (i) either the factor is not recognized as a factor of pr. This means that no occurrence of p might overlap this factor and we can surely shift the search window after the last symbol of this factor; (ii) either the factor is recognized, in which case we simply check if the motif is present using a naive O(m) algorithm, and we repeat this test for the next O(m/2) symbols. This might require O(m2/2) steps in the worst case. Figure 3 illustrates the first case. Let us analyze the average complexity of our algorithm, in a Bernoulli model with equiprobability of letters, that is, every position in the text and the paper is independent of the others and the probability of a symbol to appear is 1/σ. 10 Fig. 3. First case: the motif wr is not recognized in the tree T , which implies that no occurrence of p can overlap w and the search window can surely be shifted after the first symbol of w. We also consider that b < m/2 since we are interested in analyzing the average complexity for pattern long enough. We count the average number of symbol comparisons required to shift the search window of m/2 symbols to the right. As there are 2n/m such segments of length m/2 symbols in n, we will simply multiply the resulting complexity by 2n/m to gain the whole average complexity of our algorithm. There might be O(b!) distinct motifs that could appear in the text while this number is bounded by m − b + 1 in the pattern (one by position). Thus, with a probability bounded by m−b+1 we will recognize the segment of the text as a factor of p and enter case 2. In which case, moving the search window of m/2 symbols to the right using the naive algorithm will require O(m2/2) worst case time. b! In the other case which occurs with probability at least 1 − m−b+1 , shifting the search window by m/2 symbols to the right only requires reading b numbers. The average complexity (in terms of number of symbol reading and compar- b! isons) for shifting by m/2 symbols is thus (upper) bounded by A = O((m2/2) m − b + 1 b! + b(1 − m − b + 1 b! )) and the whole complexity by O((2n/m)A). By expanding and simplifying A we get that A = O(b + O(m3/2b!)). Now using the famous Stirling approxi- mation ln(m!) = m ln m − m + O(ln m), it is not difficult to prove that b! = 2b log b−b log e+O(log b) = Ω(m3) and thus A = O(b) and the whole average time complexity (in terms of number of symbol reading and comparisons) turns out to be O( n log m m log log m ). 5.1 Implementation details The tree T can actually be built in O( m log m log log m ) time by using appropriate data structures. Recall that the tree T recognizes all the factors of pr of length 3.5 log m log log m . To implement T , we use the same AC automaton presented in previous section to build the tree T , but with two differences: we only need forward transitions log m log log m . Thus the cost is upper and the length of any pattern is bounded by log log m · t), where t is the time needed to do an operation on the bounded by O( m log m 3.5 log m/log(log m)safe shiftm/2wmsearch window of size 11 predecessor data structure (maximum of the times needed for inserts/deletes and searches) We now turn our attention to the cost of the matching phase. From the previous section, we know that the total complexity in terms of number of symbol reading and comparisons is O( n log m m log log m ). The total cost of the matching phase is dominated by the multiplication of the total number of text symbols read multiplied by the cost of a transition in the AC automaton which itself is dominated by the time to do an operation on a predecessor data structure. The m log log m · t), where t is the time total cost of the matching phase is thus O( n log m needed to do an operation on the predecessor data structure. (cid:16) (cid:17) Now the performance of both matching and building phases crucially depend on the used predecessor data structure. If a binary search tree is used then t = = O(log log m) and the total matching time becomes O(nt) = O log log m log log m O(n log log m), and the total building time becomes O(m log m). However, we can do better if we work in the word-RAM model. Namely, we can use the atomic-heap (see section 2) which would add additional o(m) words of space and support all operations (queries, inserts and deletes) in constant time on sets of size logO(1) m. In our case, we have a set of size O( log m log log m ) and thus the operations can be supported in constant time. We thus have the following theorem: Theorem 4. Searching for a consecutive motif p = p1 . . . pm in a permutation t = t1 . . . tn can be done in average O( m log m log log m + n log m m log log m ) time. 6 Average optimality m n logΣ m We prove in this section a lower bound on the average complexity of any con- secutive motif matching algorithm. The proof of this bound is inspired by that of Yao [15] which proved on average lower bound of O( ) for matching a pattern of length m in a text of length n, both taken on a alphabet Σ. We prove in our case of interest an average lower bound of O( n log m m log log m ) considering all permutations over [1 . . . n] to be equiprobable. As this average complexity is reached by the algorithm we designed in the previous section, this bound is tight. We begin to circumscribe our problem on small segments of length 2m− 1 of the text into which we search for. Precisely, following [15,11], we divide our text in (cid:98)n/(2m− 1)(cid:99) contiguous and no-overlapping segments si, 1 ≤≤ (cid:98)n/(2m− 1)(cid:99), such that si(t) = t(2m−1)(i−1)+1 . . . t(2m−1)i. When searching for a pattern in t, there might be occurrences overlapping two blocks. But as we are interested on a lower bound, the following lemma allows us to focus on all segments. Lemma 5. A lower bound for finding a pattern p inside all segments si(t) is also a lower bound to the problem of searching for all occurrences of p in t. We now prove that instead of focusing on all segments si(t), we can focus on obtaining a lower bound to search p in any single segment and then extend the 12 lover bound on searching for p inside this segment to searching for p inside all segments, and thus, using the previous lemma, to the whole text. Lemma 6. The average time for searching for p inside all segments si(t) is (cid:98)n/(2m−1)(cid:99) times the average time for searching for p inside any such segment. previous lemma, the whole average complexity is(cid:80)(cid:98)n/(2m−1)(cid:99) Let E(t) be the average complexity for searching p in any segments. Using the E(t) = (cid:98)n/(2m− 1)(cid:99)E(t) = Ω(n/m)E(t). We now prove a lower bound for E(t), which, using the two previous lemma, gives us a lower bound for the whole problem. Let Pm((cid:96)) the number of permu- tations of size m that can be discarded using a sliding window of size m over a text of size 2m − 1 and checking only 0 < (cid:96) ≤ m positions in this window. Lemma 7 (Counting lemma). Let 0 < (cid:96) ≤ m. Then (cid:19)(cid:100) m−1 (cid:96)2 (cid:101) (cid:18) i=1 Pm((cid:96)) ≤ m! 1 − 1 (cid:96)! . m! (cid:96)! Let us consider now the whole set Sm of permutations of length m which contains m! such permutations. Given 1 < l(m) ≤ m, this set is the union of two distinct set Pm((cid:96)) and Sm \ Pm((cid:96)), that is the set of motifs discarded by a certificate of length l (or by l accesses) and the others. For all pattern in Pm((cid:96)), the average complexity to be discarded is counted 1. For any other motif in Sm \ Pm((cid:96)), the average complexity is at least l + 1. Pm((cid:96))+(m!−Pm((cid:96)))(l+1) The average complexity for discarding all patterns in Sm is thus C(m) = . We aim to find l(m) that maximizes this expression when m grows, which will provide us a lower bound for the whole average com- plexity. Now let us consider a fixed l(m). We need to lower bound C(m). As C(m) decreases when Pm((cid:96)) increases, this lower bound is minimal when Pm((cid:96)) is as large as possible. Then, as the counting lemma states that Pm((cid:96)) ≤ . We , C(m) is minimal when Pm((cid:96)) = m!(cid:0)1 − 1 m!(cid:0)1 − 1 (cid:1)(cid:100) m−1 (cid:96)2 (cid:101) (cid:1)(cid:100) m−1 (cid:96)2 (cid:101) now arbitrarily impose 98/100 ≤ Pm((cid:96)) C(m) ≥ l − 98/100l + 1 = Ω(l). We want to compute l(m) such that m! ≤ 99/100. With the left constraint, (cid:18) (cid:19)(cid:100) m−1 (cid:96)2 (cid:101) m! (cid:7) × 1 Let us impose (cid:6) m−1 n!(a−n)! xn = 1 + ax + γ where a =(cid:6) m−1 our equation using the classical formula (1 + x)a = 1 + ax + a(a−1) l! ≤ 1/10 (ineq.1). This allows us to approximate 2! x2 + . . . + i!(a−i)! xi. It is easy to see that inequality (1) implies that γ converges and is dominated by its first term which is bounded a(a−1) 2! x2 ≤ 1/200. We thus deduce that (1 + x)a ∈ [1 + ax, 1 + ax + 1/200] which implies that (1 + x)a − 1/200 ≤ 1 + ax ≤ (1 + x)a. l! and γ =(cid:80)n (cid:7), x = −1 i=2 ≤ 99/100. 98/100 ≤ Pm((cid:96)) = 1 − 1 (cid:96)! (cid:96)2 (cid:96)! a! (cid:96)2 a! 13 100 , 99 From (1 + x)a = replacing a and x in 1 + ax we get : m! Pm((cid:96)) ∈ [ 98 100 ], we obtain 98 200 ≤ 1 + ax ≤ 99 100 . By 100 − 1 (cid:25) (cid:24) m − 1 98 100 − 1 200 = 195/200 ≤ 1 − (cid:96)2 × 1 l! ≤ 99/100. We prove in appendix that l = b log m inequalities and inequality (1). Thus O( n log m average complexity for searching for a consecutive motif in a permutation. log log m with b = 1 + o(1) verify these two m log log m ) is a lower bound of the whole Acknowledgements We would like to thanks Carine Pivoteau, Cyril Nicaud and Elie de Panafieu for checking parts of our calculus. References 1. M. AdelsonVelskii and E.M. Landis. An algorithm for the organization of infor- mation. Defense Technical Information Center, 1963. 2. S. Ahal and Y. Rabinovich. On Complexity of the Subpattern Problem. SJDM, 22(2):629 -- 649, 2008. 3. A. V. Aho and M. J. Corasick. Efficient string matching: An aid to bibliographic search. Commun. ACM, 18(6):333 -- 340, 1975. 4. A. Andersson and M. Thorup. Dynamic ordered sets with exponential search trees. J. ACM, 54(3):13, 2007. 5. R. Bayer. Symmetric binary b-trees: Data structure and maintenance algorithms. Acta informatica, 1(4):290 -- 306, 1972. 6. P. Bose, J.F.Buss, and A. Lubiw. Pattern matching for permutations. Information Processing Letters, 65(5):277 -- 283, 1998. 7. Y. Han. Deterministic sorting in o(nlog log n) time and linear space. In STOC, pages 602 -- 608, 2002. 8. JR. J.H. Morris and Vaughan R. Pratt. A linear pattern-matching algorithm. Technical report, Univ. of California, Berkeley, 1970. 9. S. Kitaev. Patterns in Permutations and Words. EATCS. Springer, 2011. 10. M. Kubica, Kulczy´nski, J. Radoszewski, W. Rytter, and T. Wale´n. A linear time algorithm for consecutive permutation pattern matching. Information Processing Letters, 2013. To appear. 11. G. Navarro and K. Fredriksson. Average complexity of exact and approximate multiple string matching. TCS, 321(2-3):283 -- 290, 2004. 12. I. Simon. String matching algorithms and automata. In J. Karhumaki, H. Maurer, and Rozenberg G, editors, Results and Trends in Theoretical Computer Science, number 814 in LNCS, pages 386 -- 395, 1994. 13. P. van Emde Boas. Preserving order in a forest in less than logarithmic time and linear space. Inf. Process. Lett., 6(3):80 -- 82, 1977. 14. D. E. Willard. Examining computational geometry, van emde boas trees, and hashing from the perspective of the fusion tree. SIAM J. Comput., 29(3):1030 -- 1049, December 1999. 15. A. C. Yao. The complexity of pattern matching for a random string. SIAM Journal on Computing, 8(3):368 -- 387, 1979. 14 Appendix . Proof (Of Lemma 1). Point 1. We adapt the technique of [12] to our framework. Let q = δ(x, [i, j]) a backward transition from x to q such that q ≥ 2. Then p1 . . . pq−1 is order- isomorphic to the suffix of p1 . . . px of length q − 1. But either (a) p1 . . . pq is not order-isomorphic with p1 . . . px, or (b) x = m (x is the last state of the automaton. Let (cid:96) = x − q. We prove now a contrario that no other backward transition q(cid:48) = δ(x(cid:48), [i(cid:48), j(cid:48)]) such that q(cid:48) ≥ 2 can accept the same difference (cid:96)(cid:48) = x(cid:48) − q(cid:48) = (cid:96). Let q(cid:48) = δ(x(cid:48), [i(cid:48), j(cid:48)]) be such a transition and consider without lost of generality that 2 ≤ q(cid:48) < q. Then p1 . . . pq(cid:48)−1 would be order-isomorphic to the suffix of p1 . . . px(cid:48) of length q−(cid:48) 1, and p1 . . . pq(cid:48) must not be order-isomorphic to p1 . . . px(cid:48)px(cid:48)+1. However, as 2 ≤ q(cid:48) < q, p1 . . . pq(cid:48) is a prefix of p1 . . . pq−1, and as l(cid:48) = l(cid:48), p1 . . . pq−1 is order-isomorphic to the prefix of p1 . . . px of length q(cid:48), which is exactly p1 . . . px(cid:48)px(cid:48)+1. This leads to a contradiction and for a given 1 ≤ (cid:96) < m, there exists at most one backward transition q = δ(x, [i, j]), q ≥ 2 such that x − q = (cid:96). This bounds the number of such backward transition to m − 2. Let N (x) be the number of backward transitions q = δ(x, [i, j]) from x such that q ≥ 2. Point 2. We consider now all backward transitions 1 = δ(x, [i, j]) reaching state 1. We denote such a transition a 1-transition. Note that state 0 is never reached by any transition because any two integers are always order-isomorphic. The key observation is that from each state x source of the transition, the number of such 1-transitions from x is bounded by N (x) + 2. This is true since 1-transitions and other transitions must be interleaved to cover [−∞, +∞]. Therefore, as the total number of N (x) is bounded by m − 2, the number of 1-transitions is bounded by 2m − 4. Point 3. The number of forward transitions is m + 1, thus the whole number of transitions is bounded by 4m − 5. (cid:117)(cid:116) . Proof (Of Lemma 2). Searching for p in t using the forward automaton of p can be easily done reading all symbols of the text one after the other. But at each state one must identify the right outgoing transition, which normally requires to search in a list or an AVL tree. This would add a polylog factor to all integer reading and thus the complexity would be of the form O(n.polylog(m)). 15 However, the structure of the forward automaton combined with the fact that we imposed all outgoing transitions of each node to be sorted increasingly to the length of the transition allow us to amortize the search complexity of the searching phase along the permutation. The resulting search phase complexity is O(n) time. Indeed, let us search t through the automaton, reading one symbol at a time reaching a current state x. Let us assume we read the text until position i and we want to match ti+1. We test if ti+1 belongs to the interval [i, j] labeling x + 1 = δ(x, [i, j]) if x < m. If yes, we follow this forward transition. If not, we test each backward transition from x in increasing length order. Fig. 4. Amortized complexity of the forward search. The search starts again from q. On this instance l = 3 and q + 3 < x. The important point to notice is that after having identified the right back- ward transition from x for ti+1 reaching state q (there must be one), the search for ti+2 starts from q < x. Moreover, we associate all l transitions qk = δk(x, [i, j]) touched before finding the right one to its ending state which verifies q < qk < x. Thus q + (cid:96) < x. This point is illustrated in Figure 4. As the search starts again from q and that at most one forward transition is passed through by text sym- bol, the total number of forward and backward transitions touched or passed (cid:117)(cid:116) through when reading the whole text t = t1 . . . tn is thus bounded by 2n. . Proof (Proof of lemma 3). . Exactly as in the case of a classical text, we amortize the complexity of the search over the number of transitions we pass through and the number of reinitialisations of the search we do if no more failure transition is available. Each time we pass through a failure transition, we decrease the state from where we will go on the search if the state is validated. Thus, there can be at most as many failure transitions passed through during the whole reading of the text as the number of forward transitions that has been passed through. Since this number is at most the size of the text, the total number of transitions touched is at most 2n. Then, if after a descent from failure transition to failure transition no more outgoing transition exists, we reinitialise the search to state qxnew search from qq1qq23 16 1. Thus there are at most n such reinitialisations and the total complexity of (cid:117)(cid:116) transitions and states touched is bounded by 3n. . Proof (Of Lemma 4). Before processing, the pattern we first reduce the range of the keys from [n] to [m]. This is done in deterministic O(m log log m) times by first sorting the keys using the fastest integer sorting algorithm due to Han [7], and then replacing each key by its rank obtained from the sorting. We then process the pattern in left-to-right in m steps and at each step j determine the failure and forward transitions outgoing of state j. We use two predecessor data structures that require O(m) words of space and support insert, delete and query operations (a query operation returns both the predecessor and the successor) in (worst-case) time O(log log m). As we move forward in the pattern, we insert each symbol in both predecessor data structures (except for the first symbol which is only inserted in the first predecessor data structure). The difference between the two predecessor data structures is that the first one will only get insertions while the second one can also get deletions. The first is used to determine forward transitions while the second one is used to determine failure transitions. We now show how we determine the transitions at each step j. The forward transitions connecting state j to state j + 1 is labeled by rep(p, j + 1). The latter is determined by doing a predecessor search for pj+1 on the first predecessor data structure. This gives us both the predecessor and successor of pj+1 among p1 . . . pj which is exactly rep(p, j + 1). The failure transition is determined in the following way. If the target state of the failure transitions of state j − 1 is state i. Then we do a predecessor query on the the second predecessor data structure. If the pair of returned prefixes is precisely rep(p, i + 1), then we can make i + 1 as a target for state j. Otherwise we take the failure transition of state j − 1. If that transitions leads to a state k, then we remove the symbols pj−i..pj−k from the second predecessor data (cid:117)(cid:116) structure. . Proof (Of Property 3). We first build the Morris-Pratt representation in O(m log log m) time. We then consider each state x > 0 corresponding to the p1 . . . px from left to right and for each such state we expand its backward transitions. Let us sort all pi, 1 ≤ i ≤ x and consider the resulting order pi0 = −∞ < pi1 < . . . < pik < +∞ = pik+1. We build one outgoing transition for each interval [pij , pij+1 ], 17 excepted if pij+1 = pij + 1. This transition is computed as follows. Let q be the image state of the failure transition from x. We pick a value z in [pij , pij+1] an search for z from q. Let q(cid:48) be the new state reached. We create a backward transition form x to q(cid:48) labeled [pij , pij+1]. After this process we created at most m2 edges in at most O(m2 log log m) time. We now merge backward transitions from the same state to the same state that are labeled by consecutive intervals. This required at most O(m2) time. (cid:117)(cid:116) The whole algorithm thus requires O(m2 log log m) time. . Proof (Of Lemma 5). Let A be an algorithm to search for p in t running in O(l) time. It can be converted in an algorithm to search for p inside all si(t) also running in O(t) since: (a) it suffices to remove all occurrences overlapping two segments and occurrences in the last few remaining symbols of t out of a segment; and (b) in O(l) time, only at most O(l) such occurrences can be reported, so only O(l) occurrences might have to be discarded; and (c) testing if an occurrence is overlapping two segments can be done in constant O(l) time. The extra work required to remove all overlapping occurrences is therefore also O(l), and thus A can be converted in an O(l) algorithm to search for p inside all segments si(t). This implies that a lower bound for this last problem is also a lower bound for A. . Proof (Of Lemma 6). All segments si(t) are identically distributed, indepen- dently of each other. Thus the average time for searching for p in any segment is the same. As the expected time is the sum of the expected time to search for p in all segments, the sum commutes and the expected time becomes (cid:98)n/(2m− 1)(cid:99) (cid:117)(cid:116) times the average expected time to search for p in any segment. . 18 Proof (Of Lemma 7). Let 1 ≤ i1 < i2 . . . < i(cid:96) ≤ m be the position of the accesses. For 0 ≤ j ≤ d, we define Bj = {b b ∈ {1, 2, . . . , m} and j + b = it for some 1 ≤ t ≤ (cid:96)} . t[j + (cid:96)]. We then show that we can find J ⊂ {0, 1, . . . , d}, J =(cid:6)d/(cid:96)2(cid:7), such that Note that Bj ≤ (cid:96) for 1 ≤ j ≤ d. Also, for any p ∈ Pm((cid:96)), since it is canceled by the (cid:96) accesses considering isomorphic orders, for all shift j there is a mismatch, i.e. there exists two positions k, (cid:96) ∈ Bj such that p[k] > p[(cid:96)] and t[j + k] < Bj1 ∩ Bj2 = ∅ for j1 (cid:54)= j2 in J. to find at least(cid:6)d/(cid:96)2(cid:7) such sets. We prove in fact that jk ≤ (cid:96)2(k − 1) as long as We use a greedy procedure to find J. Let j1 = 0. Inductively, suppose that we have found j1 . . . jk−1. Then jk is obtained by finding the smallest j such that Bj is disjoint from the unions of the previous positions we have already chosen, namely B = Bj1 ∪ Bj2 ∪ . . . Bjk1 . We claim that this procedure allows us (cid:96)2(k− 1) ≤ d. Observe that B contains at most (cid:96)(s− 1) positions. We thus claim that at least one of the sets in F = {B0, B1, . . . , B(cid:96)2(s−1)} is disjoint from B. If not, for each r, 0 ≤ r ≤ (cid:96)2(s − 1) there exists a pair (b, it) such that b ∈ Br ∩ B and r + b = it for some 1 ≤ t ≤ (cid:96). So there must exists at least (cid:96)2(s− 1) + 1 such pairs, one for each set Br. But the total number of such pair is no more than B · (cid:96) ≤ (cid:96)2(s − 1), a contradiction. in J. To prove the lemma, consider a random pattern p from Sm (the set of permutations of size m). Then for all shift j ∈ {0 . . . d}, there is a mismatch. So Now take J ⊂ {0, 1, . . . , d}, J =(cid:6)d/(cid:96)2(cid:7), such that Bj1 ∩ Bj2 = ∅ for j1 (cid:54)= j2 P (p ∈ Pm(ψ)) = P (∀j ∈ {1 . . . d}, there is a mismatch) ≤ P (∀j ∈ J, there is a mismatch). Notice that for each j ∈ {1 . . . d}, the probability that there is no mismatch with 1Bj! which is the probability that the permutation formed by the p at shift j is non-(cid:63) symbol is the good one. Since all the sets Bj for j ∈ J are disjoints, we have P (p ∈ Pm((cid:96))) ≤(cid:89) ≤(cid:89) j∈J P (there is a mismatch at shift j) (cid:18) (cid:19)(cid:100) d (cid:96)2(cid:101) (1 − 1 Bj! ) ≤ 1 − 1 (cid:96)! j∈J concluding the proof since Sm = m! . (cid:117)(cid:116) . Here we prove that (cid:96) = b log m inequalities for m large enough:(cid:6) m−1 (cid:7) × 1 (cid:25) (cid:24) m − 1 (cid:96)! ≤ 1/10 (ineq.1) and × 1 (cid:96)! ≤ 99 100 ≤ 1 − 195 200 . (cid:96)2 (cid:96)2 log log m with some b = 1 + o(1) verify the following 19 from R≥2 to R≥1 verifying that Γ (n + 1) = n! for all n ∈ N. Let's recall that the Gamma function of Euler Γ is an increasing bijection Thus the function s (cid:55)→ s2Γ (s + 1) is an increasing bijection from R≥1 to R≥1. For all m ≥ 1, this allows to define s ∈ R≥1 such that s2Γ (s + 1) = 50m. Thus s → ∞ when m → ∞. Then we set b = s × log log m log m . Taking (cid:96) = s, then we have (cid:96) = b log m Let us prove that (cid:96) satisfied the desired inequalities. We have (cid:96)2 × (cid:96)! = s2Γ (s + 1) = 50m. log log m . 100 for m large enough. This proves the desired inequalities since 1/50 ≤ 1/40 = 1 − 195/200 ≤ 1/10. (cid:96)2 50 and (cid:6) m−1 (cid:96)2 (cid:7) × 1 Thus (cid:6) m−1 (cid:7) × 1 (cid:96)! ≤ m 50m ≤ 1 (cid:96)! ≥ m−1 50m ≥ 1 Let us prove now that b = 1 + o(1). By the Stirling inequality, we have that F (s) < Γ (s + 1) < 2F (s) with 2π exp(G(s)) < s2Γ (s + 1) < 2 2π exp(G(s)) . . e √ 2πs. (cid:1)s √ F (s) =(cid:0) s with G(s) = −s +(cid:0)s + 5 (cid:17) (cid:16) 25√ We deduce that 25m√ 2π Thus 2 (cid:1) log(s). < exp(G(s)) < 50m√ 2π . √ (cid:16) 50√ (cid:17) b = 1 + o(1). 2π 2π + log m. + log m < G(s) < log Therefore log Recall that f (m) ∼ g(m) means that f (m) = g(m) + o(g(m)) when m → ∞. Thus we have G(s) ∼ log m. It is then enough to prove that G(s) ∼ b log m. Indeed this imply b ∼ 1, i.e., But G(s) = −s +(cid:0)s + 5 As G(s) = −s +(cid:0)s + 5 (cid:1) log(s) = s log s + o(s log s). (cid:1) log(s) we then have: (cid:16) b log m Thus s = o(G(s)), i.e., s = o(log m). Since s = b log m Moreover log s = log b + log log m − log log log m = log log m + o(log log m). log log m , this means that b = o(log log m) (cid:17)(cid:16) (cid:17) 2 2 G(s) = − b log m Thus G(s) ∼ b log m, concluding the proof. log log m + 5 log log m + 2 log log m + o(log log m)
1309.4396
1
1309
2013-09-17T17:14:49
Routing Directions: Keeping it Fast and Simple
[ "cs.DS", "cs.DB" ]
The problem of providing meaningful routing directions over road networks is of great importance. In many real-life cases, the fastest route may not be the ideal choice for providing directions in written, spoken text, or for an unfamiliar neighborhood, or in cases of emergency. Rather, it is often more preferable to offer "simple" directions that are easy to memorize, explain, understand or follow. However, there exist cases where the simplest route is considerably longer than the fastest. This paper tries to address this issue, by finding near-simplest routes which are as short as possible and near-fastest routes which are as simple as possible. Particularly, we focus on efficiency, and propose novel algorithms, which are theoretically and experimentally shown to be significantly faster than existing approaches.
cs.DS
cs
Routing Directions: Keeping it Fast and Simple Dimitris Sacharidis Institute for the Mgmt. of Information Systems "Athena" Research Center Athens, Greece [email protected] Panagiotis Bouros Department of Computer Science Humboldt-Universität zu Berlin Berlin, Germany [email protected] 3 1 0 2 p e S 7 1 ] S D . s c [ 1 v 6 9 3 4 . 9 0 3 1 : v i X r a ABSTRACT The problem of providing meaningful routing directions over road networks is of great importance. In many real-life cases, the fastest route may not be the ideal choice for providing directions in written/spoken text, or for an unfamiliar neigh- borhood, or in cases of emergency. Rather, it is often more preferable to offer "simple" directions that are easy to mem- orize, explain, understand or follow. However, there exist cases where the simplest route is considerably longer than the fastest. This paper tries to address this issue, by find- ing near-simplest routes which are as short as possible and near-fastest routes which are as simple as possible. Partic- ularly, we focus on efficiency, and propose novel algorithms, which are theoretically and experimentally shown to be sig- nificantly faster than existing approaches. Categories and Subject Descriptors H.2.8 [Database Management]: Database Applications -- Spatial databases and GIS General Terms Algorithms Keywords shortest path, turn cost, near-shortest path 1. INTRODUCTION Finding the fastest route on road networks has received a renewed interest in the recent past, thanks in large part to the proliferation of mobile location-aware devices. How- ever, there exist many real-life scenarios in which the fastest route may not be the ideal choice when providing routing directions. As a motivating example, consider the case of a tourist asking for driving directions to a specific landmark. Since the tourist may not be familiar with the neighborhood, it makes more sense to offer directions that involve as few turns as possible, instead of describing in detail an elaborate fastest route. As another example, consider an emergency situation, e.g., natural disaster, terrorist attack, which re- quires an evacuation plan to be communicated to people on the site. Under such circumstances of distress and disor- ganization, it is often desirable to provide concise, easy to memorize, and clear to follow instructions. In both scenarios, the simplest route may be more prefer- able than the fastest route. As per the most common inter- pretation [21], turns (road changes) are assigned costs, and the simplest route is the one that has the lowest total turn cost, termed complexity. For simplicity, in the remainder of this work, we assume that all turns have equal cost equal to 1; the generalization to non-uniform costs is straightforward. In some road networks, the simplest and the fastest route may be two completely different routes. Consider for ex- ample a large city, e.g., Paris, that has a large ring road encircling a dense system of streets. The simplest route be- tween two nodes that lie on (or are close to) the ring, would be to follow the ring. On the other hand, the fastest route may involve traveling completely within the enclosing ring. As a result the length of the simplest route can be much larger than that of the fastest route, and vice versa. Surprisingly, with the exception of [13], the trade-off be- tween length and complexity in finding an optimal route has not received sufficient attention. Our work addresses this is- sue by studying the problem of finding routes that are as fast and as simple as possible. In particular, we first study the fastest simplest problem, i.e., of finding the fastest among all simplest routes, which was the topic of [13]. We show that although, for this prob- lem, a label-setting method (a variant of the basic Dijk- stra's algorithm) cannot be directly applied on the road net- work, it is possible to devise a conceptual graph on which it can. In fact, our proposed algorithm is orders of magnitude faster than the baseline solution. Moreover, using a similar methodology, it is possible to efficiently solve the simplest fastest problem. Subsequently, we investigate the length-complexity trade- off and introduce two novel problems that relax the con- straint that the returned routes must be either fastest or simplest. The fastest near-simplest problem is to find the fastest possible route whose complexity is not more than 1 +  times larger than that of the simplest route. On the other hand, the simplest near-fastest problem is to find the simplest possible route whose length is not more than 1 +  times larger than that of the fastest route. These near-optimal problems are significantly more diffi- cult to solve compared to their optimal counterparts. The reason is that there cannot exist a principle of optimality, exactly because the requested routes are by definition sub- optimal in length and complexity. Therefore, one must ex- haustively enumerate all routes, and only hope to devise pruning criteria to quickly discard unpromising sub-routes. We propose two algorithms, based on route enumeration, for finding the simplest near-fastest route; their extension for the fastest near-simplest problem is straightforward. The first follows a depth-first search principle in enumerating paths, whereas the second is inspired by A∗ search. Both al- gorithms apply elaborate pruning criteria to eliminate from consideration a large number of sub-routes. Our experimen- tal study shows that they run in less than 400 msec in net- works of around 80,000 roads and 110,000 intesections. The remainder of the paper is organized as follows. Sec- tion 2 formally defines the problems and reviews related work. Section 3 discusses the fastest simplest, and Section 4 the simplest near-fastest problem. Then, Section 5 presents our experimental study and Section 6 concludes the paper. 2. PRELIMINARIES Section 2.1 presents the necessary definition, while Sec- tion 2.2 reviews relevant literature. 2.1 Definitions Let V denote a set of nodes representing road intersec- tions. A road r is a sequence of distinct nodes from V . Let R denote a set of roads, such that all nodes appear in at least one road, and any pair of consecutive nodes of some road do not appear in any other, i.e., the roads do not have overlapping subsequences. For a node n ∈ V , the notation R(n) ⊆ R represents the non-empty subset of roads that contain n. For two consecutive nodes ni, nj of some road r, the notation R(ni, nj) is a shorthand for r. Definition 1. The road network of R is the directed graph GR(V, E), where V is the set of nodes, and E ⊆ V × V contains an edge eij = (ni, nj) if ni, nj are consecutive nodes in some road. A road network is associated with two cost functions. The length function L assigns to each edge a cost representing its length, i.e., the travel time or distance between them; formally, L : E → R+ maps each edge (ni, nj) to the length L(ni, nj) of the road segment ni to nj. The complexity function C assigns to each turn from road ri to road rj via node nx, which lies on both ri and rj, the cost of making the turn. Formally, C : V ×R×R → R+ maps (nx, ri, rj) to complexity C(nx, ri, rj) from ri to rj via nx. A route ρ = (na, nb, . . . ) is a path on graph GR, i.e., a sequence of nodes from V , such that for any two consecutive nodes, say ni, nj, there exists an edge eij in E. The length L(ρ) of a route ρ is the sum of the lengths for each edge it contains, and represents the total travel time or distance covered along this route; formally, L(ρ) = L(ni, nj). (1) (cid:88) (ni,nj )∈ρ A route from source ns to target nt is called a fastest route if its length is equal to the smallest length of any route from ns to nt. Given a parameter , a route from ns to nt is called an near-fastest route if its length is at most (1 + ) times that of the fastest route from ns to nt. Figure 1: An example road network of seven roads ra -- rg, where five routes ρ1 -- ρ5 from node ns to nt are depicted. Table 1: Costs of routes in Figure 1 road length complexity type ρ1 ρ2 ρ3 ρ4 ρ5 10 40 20 30 40 4 1 3 2 2 SF FS SNF ( = 1) FNS ( = 1) -- The complexity C(ρ) of a route ρ is the sum of complexities for each turn it contains; formally C(ρ) = C(nj, R(ni, nj), R(nj, nk)), (2) (cid:88) (ni,nj ,nk)∈ρ where ni, nj, nk are three consecutive nodes in ρ, and R(ni, nj), R(nj, nk) are the (unique) roads containing seg- ments (ni, nj) and (nj, nk), respectively. A route from ns to nt is called a simplest route if its complexity is equal to the lowest complexity of any route from ns to nt. Given a parameter , a route from ns to nt is called a near-simplest route if its complexity is at most (1 + ) times that of the simplest route from ns to nt. Note that the complexity of a simplest route can be 0, i.e., when no road changes exist. In this case, all near-simplest routes must also have complexity 0. To address this, one could simply change the definition of complexity to be the number of roads in a route, and thus at least 1. In the remainder of this paper, we ignore this case, and simply use the original definition of complexity. This work deals with the following problems. To the best of our knowledge only the first has been studied before in literature [13]. Problem 1. [Fastest Simplest Route] Given a source ns and a target nt, find a route that has the smallest length among all simplest routes from ns to nt. Problem 2. [Simplest Fastest Route] Given a source ns and a target nt, find a route that has the smallest com- plexity among all fastest routes from ns to nt. Problem 3. [Fastest Near-Simplest Route] Given a source ns and a target nt, find a route that has the smallest length among all near-simplest routes from ns to nt. Problem 4. [Simplest Near-Fastest Route] Given a source ns and a target nt, find a route that has the lowest complexity among all near-fastest routes from ns to nt. Note that the first two problems are equivalent to the last two, respectively, if we set  = 0. We next present an example illustrating these problems. nsntn6n1n4n8n5n2n11n3n10⇢1⇢2⇢3⇢4rardrerfrgrbrarc⇢5n7n9 Example 1. Consider the road network of Figure 1 con- sisting of 7 two-way roads ra -- rg. Note that all roads have either a north-south or an east-west direction, except road ra, which is a ring-road and is thus depicted with a stronger line. The figure also portrays 11 road intersections n1 -- n11 with hollow circles, and two special nodes, the source ns, drawn with filled circle, and the target nt, drawn with a filled circle inside a larger hollow one. Next, consider five possible routes ρ1 -- ρ5 starting from ns and ending at nt, which are drawn in Figure 1, and whose lengths and complexities are shown in Table 1. Observe that ρ1 is the fastest route from ns to nt with length 10, and, moreover, it has the lowest complexity 4 among all other fastest route (no other exists). Thus, ρ1 is the simplest fastest route and the answer to Problem 2. On the other hand, ρ2 is the fastest simplest route and the answer to Problem 1, as it has the lowest complexity 1, following the ring-road to reach the target. But its length, 40, is quite large compared to the other possible routes. Assume  = 1 for the complexity, so that a near-simplest route can have complexity at most twice that of the sim- plest route, i.e., 2. Observe that two routes ρ4 and ρ5 are near-simplest. Among them ρ is the fastest, and is thus the answer to Problem 3. Moreover, assume  = 1 for the length as well, so that a near-fastest route can have length at most twice that of the fastest route, i.e., 20. Notice that only ρ3 is near-fastest and thus is the answer to Problem 4. Observe that if we set  = 2 for the length, near-fastest routes can have length as large as 30. In this case, ρ3 and ρ4 are near- fastest, with the latter being the simplest near- fastest. 2.2 Related Work Dijkstra [7] showed that the fastest route problem exhibits a principle of sub-route optimality and proposed its famous dynamic programming method for finding all fastest routes from a given source. Bi-directional search [17], i.e., initiating two parallel searches from the source and the target can sig- nificantly expedite finding the fastest source-to-target route. Since this early work around the 60's, numerous network pre- processing techniques exist today, including landmarks [11], reach [12], multi-level graphs [20], graph hierarchies [19, 9], graph partitioning [16], labelings [1], and their combinations [2, 3, 6], which are capable of speeding up Dijkstra's algo- rithm by orders of magnitude in several instances. The problem of finding the simplest route was first studied in [5], and more recently in [21, 8]. The basic idea behind these methods, is to construct a pseudo-dual graph of the road network, where road segments become the nodes, the turns between two consecutive road segments become the edges, which are assigned turn costs. Then, finding the sim- plest route reduces to finding the shortest path on the trans- formed graph. In contrast, the recent work of [10] solves the simplest route problem directly on the road network. Note that Problem 1 differs with respect to the simplest route problem, as it request a specific simplest route, that with the smallest length. The aforementioned methods return any simplest route. To the best of our knowledge, only the work in [13] ad- dresses Problem 1, as it proposes a solution that first finds all simplest routes and then selects the fastest among them. The proposed method serves as a baseline approach to our solution for Problem 1 and is detailed in Section 3.1. Problems 3 and 4 are related to the problem of finding the near-shortest paths on graphs [4, 15]. This paper differs with that line of work in two ways. First, the studied problems involve two cost metrics, length and complexity. Second, their solution is a single route, instead of all possible near- optimal routes. Problems 3 and 4 are also related to multi-objective short- est path problems (see e.g., [18, 14]), which specify more than one criteria and may return sub-optimal routes. This paper differs with that line of work again in two ways. First, they request a single route. Second, the studied problems introduce a hard constraint on the length or complexity of a solution. Nonetheless, an interesting extension to our work would be to return all routes that capture different length- complexity trade-offs. 3. FASTEST SIMPLEST ROUTE This section discusses Problem 1, and introduces an al- gorithm that takes advantage of the principle of sub-route optimality to expedite the search. Solving Problem 2 is sim- ilar, and thus details are omitted. We first present a recent baseline solution in Section 3.1, and then discuss our ap- proach in Section 3.2. 3.1 Baseline Solution The work in [13] was the first to address the fact that there can exist multiple simplest routes with greatly varying length, and proposes a solution to finding the fastest among them. This method, which we denote as BSL, operates on a graph that models the intersections of the roads in R. Definition 2. The intersection graph of R is the undirected graph GI (R, I), where R is the set of roads; and I ⊆ R × R × V contains intersection (nx, ri, rj) if ri ∈ R(nx) and rj ∈ R(nx), i.e., node nx belongs to both roads ri and rj. A path on the intersection graph, i.e., a sequence of R vertices such that there exists an intersection in I for any two consecutive vertices in the sequence, is called a road sequence. BSL finds the fastest simplest route from a source node ns to a target node nt. It is based on the observation that a simplest route from ns to nt in the road network is related to a shortest road sequence from a road that contains ns to one that contains nt in the intersection graph. More precisely, BSL operates as follows. 1. For each source road in R(ns), find the number of inter- sections of the shortest road sequence from that source to any of the target roads in R(nt), e.g., using a single- source shortest path algorithm on the intersection graph. 2. Determine the smallest number of intersections among those found in the previous step. This number corre- sponds to the fewest possible intersections in a road se- quence that starts from a source and ends at a target road, and is thus equal to the complexity of the simplest route from ns to nt plus 1. 3. Enumerate (e.g., using depth-limited dfs) all road se- quences from a source to a target road that have exactly as many intersections as the number determined in the previous step. For each road sequence produced, convert it to a route and determine its length. 4. Select the route with the minimum length, i.e., the fastest, among those produced in the previous step. 3.2 The FastestSimplest Algorithm The proposed algorithm operates directly on the road net- work. However, a direct application of a Dijkstra-like (label- setting [7]) method is not possible, because the principle of sub-route optimality does not hold. In particular, this prin- ciple suggests that if node nx is in the fastest simplest route from ns to nt then any fastest simplest sub-route from ns to nx can be extended to a fastest simplest route from nx to nt. In comparison, it is easy to see that the principle holds for fastest route (shortest paths), as all fastest sub-routes can be extended to fastest routes. We give a counter-example for the principle of optimality on fastest simplest routes using the road network of Figure 1. Consider the routes ρ2 = (ns, n6, n8, n11, n10, nt) and ρ5 = (ns, n7, n11, n10, nt). The sub-route ρ(cid:48) 5 = (ns, n7, n11) of ρ5 has length 20 and complexity 1, as it involves a single turn from road rf to rc via node n7. Similarly, the sub-route ρ(cid:48) 2 = (ns, n6, n8, n11) of ρ2 has length 20 and complexity 1, as it involves a single turn from rf to ra via node n6. Therefore, both sub-routes are fastest simplest from ns to n11. However, the extension of ρ(cid:48) 5 does not give a fastest simplest route from ns to nt; ρ5 makes an additional turn at node n11 compared to ρ2. This violates the principle of optimality for fastest simplest routes. Therefore, a Dijkstra-like method, which directly exploits this principle of optimality, cannot be applied. For instance, such a method could reach n11 first via rc and subsequently ignore any other path reaching n11, including the sub-route via ra, and thus missing the optimal route from ns to nt. To address the aforementioned lack of sub-route optimal- ity, we construct a conceptual expanded graph, on which the principle optimality holds. Additionally, we show that expanded routes on this graph are uniquely associated with routes on the road network. We emphasize that the ex- panded graph is only a conceptual structure used for pre- sentation purposes, and that the proposed algorithm does not make use of it as it operates directly on the road net- work. Definition 3. The expanded graph of GR(V, E) is the di- rected graph GE (V (cid:48), E(cid:48)), where V (cid:48) ⊆ V × R contains an expanded node (nx, ri) if ri ∈ R(nx); E(cid:48) ⊆ V (cid:48) × V (cid:48) contains an edge ((nx, ri), (ny, rj)) if ri ∈ R(nx) and rj ∈ R(nx) (ri and rj could be the same road), and additionally nx, ny are consecutive nodes in rj. An expanded route ρE = ((na, ri), (nb, rj), . . . ) is a path on the expanded graph GE . Each expanded edge can be associated with a length and a turn cost. Therefore, it is possible to define the following costs for an expanded route. The length L(ρE ) of an expanded route ρE is the sum of the lengths associated with each expanded edge; formally, An important property regarding the length and complex- ity of an expanded route is the following. Note that a similar propery does not generally hold for routes on the road net- work GR. Lemma 1. Let ρ1E be an expanded route from (ns, ri) to (nx, ry), and ρ2E be an expanded route from (nx, ry) to (nt, rj). If ρ1E ρ2E denotes the concatenation of the two expanded routes, then, it holds that L(ρ1E ρ2E ) = L(ρ1E )+L(ρ2E ), and C(ρ1E ρ2E ) = C(ρ1E ) + C(ρ2E ). Proof. The proof follows because both the length and com- plexity functions are defined independently for each expanded edge of an expanded route. It should be apparent that expanded routes are closely related with (non-expanded) routes. First, let us examine the GR to GE relationship, which is one to many. We associate a route ρ from ns to nt on the road network GR to a set E(ρ) of expanded routes on GE , which only differ in their first and last expanded nodes. Particularly, for an expanded route ρE ∈ E(ρ), its first expanded node is (ns, ri), where ri ∈ R(ns), the last expanded node is (nt, rj), where rj ∈ R(nt), and the k-th expanded node (for k > 1) is (nk, R(nk−1, nk)), where nk−1, nk are the (k−1)-th, k-th nodes in ρ, respectively, and R(nk−1, nk) is the unique road that contains the edge (nk−1, nk). Conversely, an expanded route ρE is associated with a unique route ρ. ρ, denoted as ρ∗ (ns, R(ns, ns+1)) as its first expanded node, and (nt, R(nt−1, nt)) as its last expanded node, where ns+1 is the second node in route ρ, R(ns, ns+1) is the unique road containing edge (ns, ns+1), nt−1 is the second-to-last node in route ρ, and R(nt−1, nt) is the unique road containing edge (nt−1, nt). Given a route ρ, we define the special expanded route of E , to be the expanded route in E(ρ) that has An even more important property is the following. t−1(cid:88) Lemma 2. The length of a route ρ is equal to the length of any expanded route ρE ∈ E(ρ). The complexity of a route ρ is equal to the complexity of the special expanded route E ∈ E(ρ). ρ∗ Proof. For convenience, assume that ρ = (n1, n2, . . . , nt). Then, the length of the route is L(ρ) = L(nk, nk+1), and t−1(cid:88) k=1 C(nk, R(nk−1, nk), R(nk, nk+1)). its complexity is C(ρ) = k=2 An expanded route of ρ is ρE = ((n1, rs), . . . , (nk, R(nk−1, nk)), . . . , (nt, re)), of an expanded route is L(ρE ) = (cid:80)t−1 where rs ∈ R(n1) and re ∈ R(nt). Observe that the length k=1 L(nk, nk+1), which is equal to L(ρ). Hence, the first part of the lemma holds. The special expanded route of ρ is ρ∗ E = (cid:88) (cid:88) L(ρE ) = ((nx,ri),(ny ,rj ))∈ρE L(nx, ny). (3) ((n1, R(n1, n2)), . . . , (nk, R(nk−1, nk)), . . . , (nt, R(nt−1, nt))). The complexity of the special expanded route is Similarly, the complexity C(ρE ) of an expanded route ρE is the sum of the turn costs associated with each expanded edge; formally, ∗ E ) = C(n1, R(n1, n2), R(n1, n2)) C(ρ t−1(cid:88) + C(nk, R(nk−1, nk), R(nk, nk+1)) C(ρE ) = ((nx,ri),(ny ,rj ))∈ρE C(nx, ri, rj). (4) k=2 = 0 + C(ρ), where the first term is zero because the turn cost on the same road is zero. Hence the second part of the lemma also holds. Next, let us examine the GE to GR relationship, which is many to one. We associate an expanded route ρE from (ns, ri) to (nt, rj) to a unique route ρ = E−1(ρE ) from ns to nt on GR, such that the k-th node (for any k) of ρ is nk, where (nk, rx) is the k-th expanded node of ρE . Lemma 3. The length of an expanded route ρE is equal to the length of the route ρ = E−1(ρE ). The complexity of a route ρE is not smaller than the complexity of the route ρ = E−1(ρE ). Proof. For convenience, assume that the expanded route is ρE = ((n1, r1), (n2, r2), . . . , (nt, rt)). Then, its length is L(ρE ) = L(nk, nk+1), and its complexity is C(ρE ) = t−1(cid:88) k=1 C(nk, rk, rk+1). The route on GR is ρ = E−1(ρE ) = (n1, n2, . . . , nt), and has length L(ρ) = L(nk, nk+1) = L(ρE ), which proves t−1(cid:88) k=1 the first part of the lemma. The complexity of the non expanded route ρ is t−1(cid:88) k=1 C(ρ) = = k=2 t−1(cid:88) t−1(cid:88) t−1(cid:88) k=2 C(nk, R(nk−1, nk), R(nk, nk+1)) C(nk, rk, rk+1) C(nk, rk, rk+1) − C(n1, r1, r2) = =C(ρE ) − C(n1, r1, r2) ≤ C(ρE ), k=1 since R(nk−1, nk) = rk and R(nk, nk+1) = rk+1, which proves the second part of the lemma. We next introduce a lexicographic total order, which ap- plies to routes or expanded routes. Note that in this section, we use this order exclusively for expanded routes. Given two routes ρ1, ρ2, we say that ρ1 is FS-shorter than ρ2 and de- note as ρ1 <F S ρ2 if C(ρ1) < C(ρ1) or if C(ρ1) = C(ρ1) and L(ρ1) < L(ρ1). Intuitively, being FS-shorter implies being simpler or as simple but faster. The following theorem presents an important property re- garding this order on expanded routes. Theorem 1. Let ρF S be a fastest simplest route on GR from ns to nt, and let ρF S∗ denote its special expanded route. It holds that there exists no other expanded route that starts from (ns, ri) and ends at (nt, rj), for any ri ∈ R(ns) and rj ∈ R(nt) that is FS-shorter than ρF S∗ E . E Proof. We prove by contradiction. Suppose there exists an E from (ns, ri) to (nt, rj), for some ri ∈ expanded route ρ(cid:48) R(ns) and rj ∈ R(nt), such that it is FS-shorter than ρF S∗ . Therefore, one of the two conditions are true: E (cid:48) E ) < C(ρF S∗ E C(ρ ), or (5) (cid:48) E ) = C(ρF S∗ E C(ρ ) and L(ρ (cid:48) E ) < L(ρF S∗ E ). (6) Consider the route ρ(cid:48) = E−1(ρ(cid:48) that L(ρ(cid:48)) = L(ρ(cid:48) ρF S∗ E Lemma 2 that L(ρF S∗ E ). From Lemma 3, we have E ). Moreover, since is the special expanded route of ρF S, we have from ) = C(ρF S). E ) and C(ρ(cid:48)) ≤ C(ρ(cid:48) ) = L(ρF S) and C(ρF S∗ E E Using these relationships, the two conditions become (cid:48) C(ρ ) < C(ρF S), or (7) (cid:48) (cid:48) C(ρ ) = C(ρF S) and L(ρ (8) which imply that ρ(cid:48) is either simpler than ρF S or as sim- ple but faster. Therefore, ρF S cannot be a fastest simplest route, which is a contradiction. ) < L(ρF S), Theorem 1 implies that to find a fastest simplest route on GR, it suffices to find a FS-shortest expanded route on GE . The following theorem shows that a principle of optimality holds for FS-shortest expanded routes on GE . Theorem 2. Let ρE denote an FS-shortest expanded route from (ns, ri) to (nt, rj) that passes through (nx, ry). Further- more, let ρ1E denote its sub-route from (ns, ri) to (nx, ry), and ρ2E its sub-route from (nx, ry) to (nt, rj). It holds that both ρ1E and ρ2E are FS-shortest. Moreover, if ρ1(cid:48) E is an- other FS-shortest expanded route from (ns, ri) to (nx, ry), then ρ1(cid:48) E ρ2E is an FS-shortest expanded route from (ns, ri) to (nt, rj). Proof. Suppose ρ1E is not an FS-shortest expanded route from (ns, ri) to (nx, ry). Then there exists another expanded route, say ρ1∗ E , that is FS-shorter. From Lemma 1, it is easy to see that ρ1∗ E ρ2E is FS-shorter than ρE , which is a contradic- tion as the latter is FS-shortest. A similar argument holds for ρ2E . Hence the first part of the theorem is proved. Regarding expanded route ρ1(cid:48) E , observe that since it is FS- shortest it has the same length and complexity with ρ1E . Then by Lemma 1, ρ1(cid:48) E ρ2E has the same length and complex- ity with ρE . Therefore, it has to be also FS-shortest, which proves the second part of the theorem. The key point in Theorem 2 is that it holds for any ex- panded route on GE . In contrast, this does not hold for routes on the road network GR, as we have argued in the beginning of this section. Given Theorem 2, we can apply a Dijkstra's algorithm, or any variant, to find the FS-shortest expanded route on GE . Then, from Theorem 1, we immediately obtain a fastest simplest route on GR. In what follows, we present the FastestSimplest (FS) al- gorithm, a label- setting method (a generalization of Dijk- stra's algorithm) for finding a fastest simplest route on GR, which operates directly on the road network and constructs directly routes, instead of expanded routes. The pseudocode of the FS algorithm is depicted in Algo- rithm 1. Although FS operates on the road network GR, it updates labels for expanded nodes. A label λ(n, r) for expanded node (n, r) is equal to (cid:104)n, rlen, cpl, nprev, rprev(cid:105) and represents an expanded route from (ns, ri), for some ri ∈ R(ns), up to (n, r). In particular, len, cpl are the length and complexity of this expanded route, while (nprev, rprev) is the second-to-last expanded node. Note that this expanded route is FS-shortest only when it is explicitly marked as fi- nal. FS uses a minheap H to guide the search, visiting nodes of GR. An entry of H is a label, and its key is the label's length, complexity pair (len, cpl). Labels in H are ordered using the FS-shorter total order. At each iteration, FS deheaps a label, marks it final and advances the search frontier. For any road ri ∈ R(ns), the algorithm initializes the heap with the label (ns, ri0, 0, n∅, ri) (lines 1 -- 3). The dummy node n∅ signifies that ns is the first node in any route con- structed. The algorithm proceeds iteratively, deheaping labels until the heap is depleted (line 4), or the label involving the target is deheaped (line 7). Assume (nx, rilen, cpl, nw, rh) is the deheaped label (line 5). As explained before, this label is finalized (line 6). If the label does not involve the target, FS expands the current route (represented by the deheaped label) consider- ing each outgoing edge (nx, ny) of nx (line 8), and each road rj that contains ny (line 9). If the label λ(ny, rj) does not exist (line 10), its label is ini- tialized with length equal to len plus the distance L(nx, ny) of the outgoing edge, and with complexity equal to cpl plus the complexity C(ny, ri, rj) of transitioning from road ri to rj via node ny (lines 11 -- 12). Otherwise, if label λ(ny, rj) exists but is not final (line 13), it is retrieved (line 14). The label will be updated if the extension of the current expanded route is FS-shorter that the one currently represented in the label (lines 15 -- 17). The fastest simplest route can be retrieved with standard backtracking. We keep all deheaped labels, and then start- ing from the label containing the target, we identify the previous expanded node (from the information stored in the label) and retrieve its label, until the source is reached. Theorem 3. The FS algorithm correctly finds a fastest sim- plest route from ns to nt. Proof. We first show that FS finds a FS-shortest expanded route, say ρF SE , among those from any (ns, ri) to any (nt, rj), where ri ∈ R(ns) and rj ∈ R(nt). Consider a virtual ex- panded node (ns, r∅) that has outgoing edges to all (ns, ri) for ri ∈ R(ns), with length and complexity set to 0. Ob- serve that the FS algorithm uses a label-setting method (Theorem 2) to find an FS-shortest expanded route from (ns, r∅) to any expanded target node (nt, rj), where rj ∈ R(nt). This expanded route has length and complexity ex- actly equal to ρF SE . By Theorem 1 ρF SE is the special expanded route of a fastest simplest route from ns to nt, which concludes the proof. Analysis. Let δ = maxn∈V R(n) denote the maximum de- gree of the road network GR, i.e., the maximum number of roads a node can belong to. Note that there exist not more than δV labels, i.e., (n, r) pairs. In the worst case, Fastest- Simplest performs an enheap and deheap operation for each label. Furthermore, in the worst case, FastestSimplest ex- amines each edge δ times, one for each label of a node. For each examination, it may update δ labels, in the worst case. Therefore, there is a total of δ2E updates, in the worst case. Assuming a Fibonacci heap, the time complexity of FastestSimplest is O(δ2E + δV log V ) amortized. More- over, since the heap may contain an entry for each label, the space complexity is O(δV ). Algorithm 1: FastestSimplest Input: road network GR; function L; function C; source ns; target nt Output: length fsL and complexity fsC of fastest simplest Variables: minheap H with entries (cid:104)n, rlen, cpl, nprev, rprev(cid:105), route from ns to nt keys (len, cpl), and compare function <F S 1 foreach ri that contains ns do 2 λ(ns, ri) ← (cid:104)ns, ri0, 0, n∅, ri(cid:105) enheap λ(ns, ri) in H 3 (cid:104)nx, rilen, cpl, nw, rh(cid:105) ← deheap 4 while H not empty do 5 6 mark λ(nx, ri) as final 7 if nx is nt then break else foreach edge (nx, ny) do foreach road rj that contains ny do if λ(ny, rj ) does not exist then λ(ny, rj ) ← (cid:104)ny, rjlen + L(nx, ny), cpl + C(ny, ri, rj ), nx, ri(cid:105) enheap λ(ny, rj ) 8 9 10 11 12 13 14 15 16 else if λ(ny, rj ) is not final then (cid:48) , cpl , nu, rh(cid:105) ← λ(ny, rj ) (cid:104)ny, rjlen (cid:48) if (cid:48) (len + L(nx, ny), cpl + C(ny, ri, rj )) <F S (len then λ(ny, rj ) ← (cid:104)ny, rjlen+L(nx, ny), cpl+C(ny, ri, rj ), nx, ri(cid:105) update λ(ny, rj ) (cid:48) ) , cpl 17 return (fsL, fsC) ← (len, cpl) Discussion. Thanks to Theorem 2, the FS algorithm essen- tially solves a shortest path problem defined on the expanded graph directly on the road network. It is thus possible to substitute the underlying basic label-setting method method with a more efficient variant. Bi- directional search and all graph preprocessing techniques, discussed in Section 2.2, are compatible and can expedite the underlying method. 4. SIMPLEST NEAR-FASTEST ROUTE This section studies Problem 4; the solution to Problem 2 is similar and details are omitted. Unlike the case of finding the simplest fastest or the fastest simplest route, there can exist no principle of optimality, exactly because the solution to Problem 4 is not an optimal route for any definition of optimality. Therefore, one has to enumerate all routes from source to target, and rely on bounds and pruning criteria to eliminate sub-routes that cannot be extended to simplest near-fastest route. We propose two algorithms, which differ in the way they enumerate paths. The first, detailed in Section 4.1, is based on depth-first search, while the second, detailed in Section 4.2, is inspired by A∗ search. 4.1 DFS-based Traversal This section details the SimplestNearFastest-DFS (SNF- DFS) algorithm for finding the simplest near-fastest route. Its key idea is to enumerate all routes from source to target by performing a depth-first search, eliminating in the process routes which are longer than (1+) times the fastest (similar to the algorithm of [4] for near-fastest routes), or have larger complexity than the best found so far. SNF-DFS requires information about the simplest fastest as well as the fastest simplest path from any node to the target. To obtain this information, it invokes two procedures AllFastestSimplest and AllSimplestFastest. The AllFastestSimplest procedure is a variation of the FastestSimplest algorithm (Section 3) that solves the single- source fastest simplest route problem, i.e., it computes the length and complexity of the fastest simplest route from a given source to any other node. Only a small change to the original algorithm is necessary. Recall that when deheaping a label λ(nx, ri), it is marked as final. Observe that when the first label associated with nx is deheaped, the algorithm has found the fastest simplest path from ns to nx. (This was in fact the termination condition of Algorithm 1: stop when a label associated with the target is deheaped.) Therefore, the AllFastestSimplest procedure explicitly marks nx as visited at its first encounter, and stores the length and complexity of the current path. The procedure only terminates when the heap empties. The AllSimplestFastest procedure is derived from the Sim- plestFastest algorithm in the same way that AllFastestSim- plest is from FastestSimplest, and thus details are omitted. Note that there arises a small implementation detail. Re- call that the SNF-DFS algorithm requires the costs all fastest simplest routes ending at a particular node (the target), whereas AllFastestSimplest returns the costs of all fastest simplest routes starting from a particular node. Therefore, to obtain the appropriate info, SNF-DFS invokes the All- FastestSimplest procedure using a graph obtained from GR by inverting the direction of its edges. The same holds for the invokation of the AllSimplestFastest procedure. In the following, we assume that the length fsL[ ] and com- plexity fsC[ ] of all fastest simplest routes to the target nt, and the length sfL[ ] and complexity sfC[ ] of all simplest fastest routes to nt, are given. The SNF-DFS algorithm applies two pruning criteria to avoid examining all routes from ns to nt. Lemma 4. Let ρ be a route from ns to nx. If L(ρ) + sfL[nx] > (1 + ) · sfL[ns], then any extension of ρ towards nt is not a simplest near-fastest route. Proof. Any extension of ρ towards nt must have length at least L(ρ) + sfL[nx], since sfL[nx] is the shortest length of any route from nx to nt. Therefore, the condition of the lemma implies that no extension of ρ is near-fastest, hence neither simplest near-fastest. Lemma 5. Let ρ be a route from ns to nx. Further, let snfC+ be an upper bound on the complexity of a simplest near-fastest route from ns to nt. If C(ρ) + fsC[nx] > snfC+, then any extension of ρ towards nt is not a simplest near- fastest route. Proof. Any extension of ρ towards nt must have complexity at least C(ρ)+sfC[nx], since sfC[nx] is the lowest complexity of any route from nx to nt. Therefore, the condition of the lemma implies that no extension of ρ has better complexity that an upper bound on the complexity of the simplest near- fastest route, hence cannot be simplest near- fastest. The next lemma computes an upper bound of the com- plexity of a simplest near-fastest route. Lemma 6. Let ρ be a route from ns to nx. If L(ρ) + fsL[nx] ≤ (1 + )· sfL[ns], then snfC+ = C(ρ) + 1 + fsC[nx] is an upper bound on the complexity of a simplest near-fastest route. Proof. Consider a simplest extension ρ(cid:48) of ρ towards nt, i.e., it has the lowest possible complexity. Observe that its length is L(ρ(cid:48)) = L(ρ) + fsL[nx]. Hence the condition of the lemma implies that ρ(cid:48) is a near-fastest route. So, its complexity is an upper bound on the complexity of a simplest near-fastest route. We next show that the complexity of ρ(cid:48) is at most C(ρ) + 1 + fsC[nx], which will conclude the proof. Let ny be the node following nx in ρ(cid:48), and nw be the node preceding nx in ρ. Then, the complexity of ρ(cid:48) is C(ρ(cid:48)) = C(ρ) + C(nx, R(nw, nx), R(nx, ny)) + fsC[nx]. Since the turn cost C(nx, R(nw, nx), R(nx, ny)) is bounded by 1, any simplest extension of ρ towards nt has complexity at most C(ρ) + 1 + fsC[nx], which in turn is an upper bound on the complexity of a simplest near-fastest route. We are now ready to describe in detail the SNF-DFS al- gorithm, whose pseudocode is shown in Algorithm 2. It per- forms a depth-first search on the road network, eliminating routes according to the two criteria described previously, and computing an upper bound for the complexity of the fastest near-simplest route. SNF-DFS uses a stack S to implement depth-first search. At each point in time, the entries in the stack S form exactly a single route starting from ns. An entry of S has the form (cid:104)nlen, cpl, nprev(cid:105), and corresponds to a route ending at node n with length len, complexity cpl and whose second-to-last node is nprev. SNF-DFS marks certain nodes as in_route, and certain edges as traversed. Particularly, a node is marked as in_route if an entry for this node is currently in the stack. This mark- ing helps avoid cycles in routes. An edge (na, nb) is marked as traversed if an entry for na is in the stack (not necessar- ily the last), whereas an entry for nb is not in S, but was at some previous iteration right above the entry for na. This marking helps avoid revisiting routes. Initially, SNF-DFS invokes the AllSimplestFastest and All- FastestSimplest procedures (lines 1 -- 2). Then, if the fastest simplest route from ns to nt is near-shortest, i.e., has length less than (1 + ) · sfL[ns], then it is not only a candidate route but actually the solution, as there can be no other route with lowest complexity. Hence, SNF-DFS terminates (lines 3 -- 4). Otherwise, a candidate route is the fastest simplest route, which is definitely near-fastest. Therefore, an upper bound on complexity is computed as snfC+ = sfC[ns] (line 5). The stack is initialized with an entry for the source node ns (line 6). Then SNF-DFS proceeds iteratively until the stack is empty (line 7). At each iteration the top entry of the stack is examined (but not popped) (line 8). Let this entry be for node nx and correspond to a route ρ. If node nx is not marked as in_route although it is at the top of the stack, this means that this is the first time SNF-DFS encounters it (line 9). For this first encounter, the algorithm applies the pruning criterion of Lemma 5. If it holds (line 10) then no route that extends ρ will be examined, and hence the entry is popped from the stack. Otherwise, if nx is the target (lines 11 -- 13), ρ constitutes a candidate solution and its complexity is compared against the best known (line 12). Subsequently, the entry is popped, as there is no need to extend the current route ρ any farther. If the entry is not popped, node nx is marked as in_route. If node nx is not in_route, SNF-DFS looks for an outgo- ing edge (nx, ny) such that it is not traversed and ny is not in_route (line 16). If no such edge is found, then all routes, with no cycles, that extend ρ have been either considered or pruned. Hence the top entry of the stack is popped (line 18), and nx is marked as not in_route (line 19). Additionally, all outgoind edges of nx are marked as not traversed (lines 20 -- 21). Otherwise, such an outgoing edge (nx, ny) is found. Then, the algorithm checks if the two pruning criteria (Lemmas 4, 5) apply (line 22). If either does, then the edge (nx, ny) is marked as traversed (line 27). Otherwise (lines 23 -- 26), the algorithm checks if Lemma 6 applies, and appropriately updates the complexity bound snfC+ if necessary (line 24). Finally, SNF-DFS creates an entry for node ny and pushes it in the stack (line 25), while marking (nx, ny) as traversed (line 26). The actual simplest near-fastest route can be retrieved with standard backtracking; details are omitted. Theorem 4. The SNF-DFS algorithm correctly finds a sim- plest near-fastest route from ns to nt. Proof. We first show that if the pruning criteria were not applied, the algorithm would enumerate all possible routes from ns to nt. This is true, because SNF-DFS would per- form a depth-first traversal constructing each time an acyclic route consisting of possibly all edges until nt is reached (line 11). The marking on edges guarantees that when the al- gorithm backtracks (performs a pop operation), a different route is followed. Eventually, when the stack empties the algorithm would have constructed all routes from ns to nt. We finally argue that all pruned routes cannot be sub- routes of a simplest near-fastest route. This holds because pruning is performed based on Lemmas 4 and 5, and the bound of Lemma 6. Analysis. The complexities of AllSimplestFastest and All- FastestSimplest are the same as those of SimplestFastest and FastestSimplest, respectively, namely O(δ2E+δV log V ) amortized time and O(δV ) space. Let L(ρSF ) denote the length of the fastest route, and ∆d the smallest distance of any edge. At any time the stack of SimplestNearFastest corresponds to a sub-route of some near-fastest route. The number of edges in a near-fastest route can be at most (1 + )L(ρSF )/∆d (but not more than E). Therefore, the space complexity of the road network traversal is O((1 + )L(ρSF )/∆d) = O(E), since at each time a single route is maintained in the stack. In the worst case, the traversal may examine all possible routes from ns to nt having (1 + )L(ρSF )/∆d edges. The number of such routes is k = (cid:0) (cid:1); in practice E (1+)L(ρSF )/∆d this is a much smaller number. The number of push or pop operations is in the worst case equal to the total length of all possible near-fastest routes from source to target. Since there can be k such routes, the time complexity is O(k(1 + )L(ρSF )/∆d). Overall, the time complexity of SNF-DFS is O(δ2E + δV log V + k(1 + )L(ρSF )/∆d) amortized, while its space complexity is O(δV + (1 + )L(ρSF )/∆d). Discussion. The running time of SNF-DFS depends on large part on the two procedures AllSimplestFastest and All- FastestSimplest. In the following, we discuss a variant of the Algorithm 2: SimplestNearFastest-DFS Input: road network GR; mapping C; source ns; target nt; value  Output: length snfL and complexity snfC of simplest Variables: stack S with entries (cid:104)nlen, cpl, nprev(cid:105) near-fastest route from ns to nt 1 (sfL[ ], sfC[ ]) ← AllSimplestFastest(GR, C, nt) 2 (fsL[ ], fsC[ ]) ← AllFastestSimplest(GR, C, nt) 3 if 4 fsL[ns] ≤ (1 + ) · sfL[ns] then return (snfL, snfC) ← (fsL[ns], fsC[ns]) 5 (snfL+, snfC+) ← (sfL[ns], sfC[ns]) 6 push (ns0, 0, n∅) 7 while S not empty do 8 (cid:104)nxlen, cpl, nw(cid:105) ← top if nx not in_route then 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 if cpl + fsC[nx] > snfC+ then pop else if nx is nt then if cpl < snfC+ then (snfL+, snfC+) ← (len, cpl) pop else mark nx as in_route else find an outgoing edge (nx, ny) that is not traversed and ny is not in_route if no such edge is found then pop mark nx as not in_route foreach outgoing edge (nx, ny) do mark (nx, ny) as not traversed else if len + L(nx, ny) + sfL[ny] ≤ (1+)·sfL[ns] and cpl + C(ewx, exy, nx) + fsC[ny] < snfC+ then if len + L(nx, ny) + fsL[ny] ≤ (1+)·sfL[ns] then (snfL+, snfC+) ← (len + L(nx, ny) + fsL[ny], cpl + C(ewx, exy, nx) + 1 + fsC[ny]) push (cid:104)nylen + L(nx, ny), cpl + C(ewx, exy, nx), nx(cid:105) mark (nx, ny) as traversed 25 else mark (nx, ny) as traversed 26 return (snfL, snfC) ← (snfL+, snfC+) algorithm that does not invoke these procedures. The key idea is to relax the requirement for explicit calculation of the length and complexity of all simplest fastest and fastest simplest routes, and instead require a method for calculat- ing their lower and upper bounds. Such a method can be straightforwardly adapted from landmark-based techniques, e.g., [11]. Note that in the extreme case, no bounds are nec- essary. Clearly, the pruning criteria of Lemmas 4 and 5 can be straightforwardly adapted to use bounds instead; note that their pruning power is reduced. Similarly, Lemma 6 can also be adapted, which results however in a less tight upper bound. Details are omitted. 4.2 A∗-based Traversal This section describes the SimplestNearFastest-A∗ (SNF- A∗) algorithm for finding a simplest near-fastest route, which is inspired by A∗ search. The key idea is to use bounds on the complexity in order to guide the search towards the sim- plest among the near-fastest routes. Similar to the dfs-like algorithm, SNF-A∗ applies Lem- mas 4, 5 to prune unpromising routes, and Lemma 6 to compute an upper bound on the complexity of a simplest near-fastest route. On the other hand, contrary to the dfs- like algorithm, SNF-A∗ terminates when it enounters the target node for the first time, because it can guarantee that all unexamined routes have more complexity. The SNF-A∗ algorithm uses a heap to guide the search, containing node labels. An important difference with re- spect to the methods of Section 3, is that to guarantee cor- rectness, there may be multiple labels per node, each corre- ) = C(ρ(cid:48))+C(nx, R(nw(cid:48) , nx), R(nx, ny))+ 10 11 sponding to different routes from the source to that node. The reason is that there is no principle of optimality for near-fastest routes. Still, labels belonging to certain routes can be eliminated, as the following lemma suggests. Lemma 7. Let ρ, ρ(cid:48) be two routes from ns to nx. If L(ρ(cid:48)) > L(ρ) and C(ρ(cid:48)) > C(ρ) + 1, then ρ(cid:48) cannot be a sub-route of a simplest near-fastest route from ns to any nt. Proof. Let nw (resp. nw(cid:48) ) be the second-to-last node of route ρ (resp. ρ(cid:48)). We prove by contradiction. Assume that ρ(cid:48) is a sub-route of a simplest near-fastest route ρF S(cid:48) . Let ρx be the sub-route of ρF S(cid:48) starting from node nx and ending at nt, an let ny be its second node, after nx. Then, L(ρF S(cid:48) ) = L(ρ(cid:48))+L(ρx), and C(ρF S(cid:48) C(ρx). Since in the best case, a turn cost can be zero, we have that C(ρF S(cid:48) ) ≥ C(ρ(cid:48)) + C(ρx). Now consider route ρF S = ρρx, where L(ρF S) = L(ρ) + L(ρx), and C(ρF S) = C(ρ) + C(nx, R(nw, nx), R(nx, ny)) + C(ρx). Since in the worst case, a turn cost can be one, we have that C(ρF S) ≤ C(ρ)+1+C(ρx). From the conditions of the lemma, we derive that L(ρF S) < L(ρF S(cid:48) ) and C(ρF S) < C(ρF S(cid:48) ). This implies that ρF S is near-fastest, as it has length less than a near-fastest route. Moreover, it has less complexity than ρF S(cid:48) is simplest near-fastest. , which is a contradiction as ρF S(cid:48) The set of labels for a node nx is denoted by Λ(nx). Let λ (resp. λ(cid:48)) be the label corresponding to a route ρ (resp. ρ(cid:48)) ending at node nx. If the conditions of Lemma 7 hold for ρ and ρ(cid:48), we write λ ≺ λ(cid:48). Clearly, there is no need to keep a label λ(cid:48) ∈ Λ(nx) if there is another label λ ∈ Λ(nx) such that λ ≺ λ(cid:48). An important difference to the label-setting method for Problem 1 is that a heap entry (label) (cid:104)nlen, cpl, nprev(cid:105) in SNF-A∗ is sorted according to the FS-shorter total order (see Section 3) on pair (len + fsL[n], cpl + fsC[n]), as it would in A∗ search. The pseudocode of SNF-A∗ is shown in Algorithm 3. Ini- tially, it invokes the AllSimplestFastest and AllFastestSim- plest procedures to obtain arrays fsL[ ], fsC[ ], sfL[ ], and sfC[ ] (lines 1 -- 2). Subsequently, if the fastest simplest route from ns to nt is near-shortest, it is the solution, and hence, SNF-DFS terminates (lines 3 -- 4). Otherwise, a candidate route is the fastest simplest route, which is definitely near- fastest. Therefore, an upper bound on complexity is com- puted as snfC+ = sfC[ns] (line 5). The heap is initialized with an entry for the source node ns (line 6). Then SNF-A∗ proceeds iteratively until the heap is empty (line 7). Let (cid:104)nxlen, cpl, nw(cid:105) be the deheaped label at some iteration (line 8). If nx is the target, the algorithm terminates (lines 9 -- 11). The reason is that because of the order in the heap, all remaining labels correspond to routes, which when extended via the simplest route to the target, have larger complexity. Hence, Lemma 5 applies to them. If nx is not the target, each outgoing edge (nx, ny) is ex- amined (line 12), and a label λ for the route to ny is created (line 13). Subsequently, each other label λ(cid:48) regarding node ny is considered (lines 15 -- 17). In particular, the algorithm applies Lemma 7 for the routes of labels λ and λ(cid:48), removing labels if necessary. If the route for label λ survives, then the pruning criteria of Lemmas 4 and 5 are applied (line 18). If the label still Algorithm 3: SimplestNearFastest-A∗ Input: road network GR; mapping C; source ns; target nt; value  Output: length snfL and complexity snfC of simplest Variables: minheap H with entries (cid:104)nlen, cpl, nprev(cid:105), keys near-fastest route from ns to nt (len+f sL[n], cpl+f sC[n]), compare function <F S 1 (sfL[ ], sfC[ ]) ← AllSimplestFastest(GR, C, nt) 2 (fsL[ ], fsC[ ]) ← AllFastestSimplest(GR, C, nt) 3 if 4 fsL[ns] ≤ (1 + ) · sfL[ns] then return (snfL, snfC) ← (fsL[ns], fsC[ns]) 5 (snfL+, snfC+) ← (sfL[ns], sfC[ns]) 6 enheap (cid:104)ns0, 0, n∅(cid:105) in H 7 while H not empty do 8 (cid:104)nxlen, cpl, nw(cid:105) ← deheap if nx is nt then 9 (snfL+, snfC+) ← (len, cpl) break 12 13 14 15 16 17 18 19 20 else foreach edge (nx, ny) do (cid:48) ∈ Λ(ny) do (cid:48) then remove λ λ ← (cid:104)nylen + L(nx, ny), cpl + C(ewx, exy, nx), nx(cid:105) pruned ← false foreach entry λ if λ ≺ λ pruned ← true if not pruned and len + L(nx, ny) + sfL[ny] ≤ (1+)·sfL[ns] and cpl + C(ewx, exy, nx) + fsC[ny] < snfC+ then (cid:48) ≺ λ then (cid:48) else if λ if len + L(nx, ny) + fsL[ny] ≤ (1+)·sfL[ns] then (snfL+, snfC+) ← (len + L(nx, ny) + fsL[ny], cpl + C(ewx, exy, nx) + 1 + fsC[ny]) enheap λ 21 return (snfL, snfC) ← (snfL+, snfC+) survives, then Lemma 6 is applied to compute an upper bound on the complexity of a solution (lines 19 -- 20). Finally, the surviving label λ is enheaped (line 21). As before, the actual simplest near-fastest route can be retrieved with standard backtracking; details are omitted. Theorem 5. The SNF-A∗ algorithm correctly finds a sim- plest near-fastest route from ns to nt. Proof. We first show that if the pruning criteria and the ter- mination condition were not applied, the algorithm would enumerate all possible routes from ns. This is true because when a label is deheaped for node nx, a route is identified, which is subsequently extended by considering all the neigh- bors of nx. Note that multiple labels for node nx might be deheaped, corresponding to different routes, possibly with cycles. The fact that the heap entries are sorted by the FS- shorter order, i.e., primarily by complexity and secondarily by length, and the fact that a route with cycles is always not FS-shorter than its acyclic counterpart, ensures that the al- gorithm does not fall into an endless loop traversing a cycle, and will eventually examine all routes. Next, we show that all pruned labels correspond to routes that cannot be sub-routes of a simplest near-fastest route. This is true, because pruning is performed based on Lem- mas 4, 5 and 7 and the bound of Lemma 6. Finally, we show that when SNF-A∗ terminates (line 11), a simplest near-fastest route is identified. Let ρ denote the route that corresponds to the deheaped label λ for the target nt. Observe that ρ is near-fastest, because otherwise its label λ would not be enheaped at line 21 (pruned by Lemmma 4). We finally argue that ρ has the lowest complexity among all near-fastest routes. This holds due to the FS-shorter order of the heap. All other routes to nt have complexity not less than ρ's. Analysis. AllSimplestFastest and AllFastestSimplest re- quire O(δ2E + δV log V ) amortized time and O(δV ) In the worst case, the algorithm may examine all space. (cid:1) possible routes from ns to nt having at k =(cid:0) E (1+)L(ρSF )/∆d most (1 + )L(ρSF )/∆d edges. Each node of the road net- work may be assigned up to k labels, one per possible route. The number of enheap and deheap operations equals the number of labels kV . Furthermore, the number of update operations is equal to k2 per edge, for a total of k2E. As- suming a Fibonacci heap, the time complexity of the traver- sal is O(k2E + kV log V ) amortized. Moreover, since the heap may contain an entry for each label, the space com- plexity is O(kV ). Overall, the time complexity of SNF-A∗ is O(δ2E + δV log V + k2E + kV log V ) amortized, while its space complexity is O(δV + kV ). Discussion. Similarly to the case of SNF-DFS, the invoca- tion of the AllSimplestFastest and AllFastestSimplest pro- cedures is not necessary for SNF-A∗. 5. EXPERIMENTAL EVALUATION This section, presents an experiment evaluation of our methodology for Problems 1 -- 4. Section 5.1 details the setup of our analysis. Section 5.2 qualitatively compares the pro- posed methods, and Section 5.3 studies the scalability. 5.1 Setup Our experimental analysis involves both real and synthetic road networks. We use the real road networks of the fol- lowing cities taken from OpenStreetMap: Oldeburg (OLB), Berlin (BER), Vienna (VIE) and Athens (ATH), contain- ing 1, 672 roads and 2, 383 intersections, 15, 246 roads and 25, 321 intersections, 20, 224 roads and 27, 563 intersections, and 76, 896 roads and 108, 156 intersections, respectively. The weighted average degree of an intersection in these road networks is 2.09, 2.15, 2.17 and 2.19, respectively. To study the scalability of our methodology we also gen- erated synthetic road networks by populating the OLB road network. The idea is the following. In an attempt to capture the structure of a real network, a synthetic road network is defined as a set of neighborhoods connected to each other through a backbone road network. OLB is used to capture the internal road network of a neighborhood. Figure 2 pic- tures the 24 intersections used to enter/exit the internal road network of a neighborhood from/to the backbone. Finally, to construct a backbone network we consider two different topologies. The grid-based topology of degree τ is constructed by 2τ roads, τ 2 intersections, and defines (τ−1)2 neighborhoods. On the other hand, a ring-based topology of Figure 2: The OLB road network and its 24 en- trances/exits. (a) (b) Figure 3: Examples of backbone networks: (a) grid- based with 10 roads, (b) ring-based with 16 roads. degree τ is constructed by 4(τ + 1) roads, 4τ intersections, and defines 4(τ − 1) + 1 neighborhoods. Figure 3(a) and (b) show an example of a grid-based and a ring-based backbone road network of degrees 5, and 3, respectively. The grid- based backbone consists of 10 roads connected through 25 intersections and defines 16 neighborhoods, while the ring- based backbone consists of 16 roads connected through 12 intersections and defines 9 neighborhoods. To assess the performance of the routing methods, we measure their average response time and the average num- ber of routes examined over 1, 000 queries. Finally, in case of the simplest near-fastest and the fastest near-simplest route problems, we test the methods varying  inside {0.01, 0.05, 0.1, 0.2, 0.3}. 5.2 Comparison of Routing Methods The first set of experiments involves the OLB, BER, VIE, and ATH real road networks with the purpose of identifying the best method for each of the problems at hand. Table 2 demonstrates the results for the fastest simplest and the simplest fastest route problems. We first observe that FS outperforms BSL by several orders of magnitude. In fact, we managed to execute BSL only on the smallest road network (OLB) due to its extremely high response time. This is expected as BSL needs to enumerate an enormous number of routes to identify the final answer. On the other hand, we observe that FS, SF identify the corresponding routes in less than half a second for all real networks. Finally, we investigate which is the best method for the fastest near-simplest and the simplest near-fastest route prob- lems. Note that for the purpose of this experiment we include two additional methods termed FNS-A∗-WB and SNF-A∗-WB. These algorithms follow the same principle as FNS-A∗ and SNF-A∗ respectively, without however invoking the AllFastestSimplest and AllSimplestFastest procedures (equivalently they assume sf L[n] = sf C[n] = f sL[n] = f sC[n] = 0 for any node n). In addition, note that be- cause of their high response time, we were able to execute FNS-DFS and SNF-DFS only on the smallest road network, OLB. Figure 4 clearly shows that FNS-A∗ and SNF-A∗ are In fact the dominant methods for the problems at hand. with the exception of the smallest road network, OLB, they outperform their competitors by at least one order of mag- nitude. The superiority of FNS-A∗ (SNF-A∗) over FNS-A∗- WB (SNF-A∗-WB) supports our decision to invoke the All- FastestSimplest and AllSimplestFastest procedures before the actual search takes place. We also observe that as  increases, the response time of the methods that solve simplest near-fastest route problem decreases. Specifically, the response time of SNF-A∗-WB al- ways decreases while the time of SNF-A∗ first increases and after  = 0.1 or  = 0.2 it drops. Note that this trend is also followed by the average number of routes examined by the methods. The reason for is that the larger  is, the more Table 2: Real road networks: performance analysis for solving Problems 1 and 2. road network Response time (sec) Routes examined Response time (sec) Routes examined Response time (sec) Routes examined BSL FS SF OLB BER VIE ATH 68.7 − − − 121, 236, 000 − − − 0.003 0.055 0.057 0.346 2286.82 27226.3 29301.8 117, 973 0.003 0.040 0.042 0.207 2418.35 27611.7 29250.8 120, 329 routes have acceptable length and thus need to be exam- ined. At the same time, however, it is more likely to early identify a candidate answer, which can enhance the pruning mechanism and thus accelerate the query evaluation. 5.3 Scalability Tests In the last set of experiments we study the scalability of the best methods identified in the previous section, i.e., FS, SF, FNS-A∗ and SNF-A∗. For this purpose, we generate synthetic road networks varying the degree of the topol- ogy τ , and thus, the size of the road network. Particu- larly, for a grid-based backbone network τ takes values inside {2, 3, 4, 5}, while for a ring-based backbone inside {1, 2, 3, 4}. Figure 5 reports on the scalability tests. As expected, the response time of all methods increases when the degree of the topology increases. Even for the expensive fastest near- simplest and the simplest near-fastest route problems, our methods always identify the answer in less than half a sec- ond for  = 0.1. Although we do not include figures for other values of , our experiments show that this holds for every other combination of τ and . 6. CONCLUSION This paper dealt with finding routes that are as simple and as fast as possible. In particular, it studied the fastest sim- plest, simplest fastest, fastest near-simplest, and simplest near-fastest problems, and introduced solutions to thems. The proposed algorithms are shown to be efficient and prac- tical in both real and synthetic datasets. Acknowledgments. This research was partially supported by the German Research Foundation (DFG) through the Research Training Group METRIK, grant no. GRK 1324, and the European Commission through the project "Simple- Fleet", grant no. FP7-ICT-2011-SME-DCL-296423. 7. REFERENCES [1] I. Abraham, D. Delling, A. V. Goldberg, and R. F. Werneck. A hub-based labeling algorithm for shortest paths in road networks. In Experimental Algorithms, pages 230 -- 241. Springer, 2011. [2] R. Bauer and D. Delling. Sharc: Fast and robust unidirectional routing. Journal of Experimental Algorithmics (JEA), 14:4, 2009. [3] R. Bauer, D. Delling, P. Sanders, D. Schieferdecker, D. Schultes, and D. Wagner. Combining hierarchical and goal-directed speed-up techniques for dijkstra's algorithm. Journal of Experimental Algorithmics (JEA), 15:2 -- 3, 2010. [4] T. H. Byers and M. S. Waterman. Determining all optimal and near-optimal solutions when solving shortest path problems by dynamic programming. Operations Research, 32(6):1381 -- 1384, 1984. [5] T. Caldwell. On finding minimum routes in a network with turn penalties. Communications of the ACM, 4(2):107 -- 108, 1961. [6] D. Delling, A. V. Goldberg, A. Nowatzyk, and R. F. Werneck. Phast: Hardware-accelerated shortest path trees. Journal of Parallel and Distributed Computing, 2012. [7] E. W. Dijkstra. A note on two problems in connexion with graphs. Numerische mathematik, 1(1):269 -- 271, 1959. [8] M. Duckham and L. Kulik. "simplest" paths: Automated route selection for navigation. In Conference On Spatial Information Theory (COSIT), pages 169 -- 185, 2003. [9] R. Geisberger, P. Sanders, D. Schultes, and D. Delling. Contraction hierarchies: Faster and simpler hierarchical routing in road networks. In Experimental Algorithms, pages 319 -- 333. Springer, 2008. [10] R. Geisberger and C. Vetter. Efficient routing in road networks with turn costs. In Experimental Algorithms, pages 100 -- 111. Springer, 2011. [11] A. V. Goldberg and C. Harrelson. Computing the shortest path: A search meets graph theory. In Proceedings of the sixteenth annual ACM-SIAM symposium on Discrete algorithms, pages 156 -- 165. Society for Industrial and Applied Mathematics, 2005. [12] R. J. Gutman. Reach-based routing: A new approach to shortest path algorithms optimized for road networks. In ALENEX/ANALC, pages 100 -- 111, 2004. [13] B. Jiang and X. Liu. Computing the fewest-turn map directions based on the connectivity of natural roads. International Journal of Geographical Information Science, 25(7):1069 -- 1082, 2011. [14] H.-P. Kriegel, M. Renz, and M. Schubert. Route skyline queries: A multi-preference path planning approach. In ICDE, pages 261 -- 272, 2010. [15] W. Matthew Carlyle and R. Kevin Wood. Near-shortest and k-shortest simple paths. Networks, 46(2):98 -- 109, 2005. [16] R. H. Mohring, H. Schilling, B. Schutz, D. Wagner, and T. Willhalm. Partitioning graphs to speedup dijkstra's algorithm. Journal of Experimental Algorithmics (JEA), 11:2 -- 8, 2007. [17] T. A. J. Nicholson. Finding the shortest route between two points in a network. The Computer Journal, 9(3):275 -- 280, 1966. [18] A. Raith and M. Ehrgott. A comparison of solution strategies for biobjective shortest path problems. Computers & Operations Research, 36(4):1299 -- 1331, 2009. [19] P. Sanders and D. Schultes. Highway hierarchies hasten exact shortest path queries. In Algorithms -- Esa  (a) OLB  (b) BER  (c) VIE  (d) ATH Figure 4: Real road networks: performance analysis for solving Problems 3 and 4. τ (a) grid-based τ (b) grid-based τ (c) ring-based τ (d) ring-based Figure 5: Synthetic road networks: scalability tests for  = 0.1. 2005, pages 568 -- 579. Springer, 2005. [20] F. Schulz, D. Wagner, and C. Zaroliagis. Using multi-level graphs for timetable information in railway systems. In ALENEX, pages 43 -- 59. Springer, 2002. [21] S. Winter. Modeling costs of turns in route planning. GeoInformatica, 6(4):345 -- 361, 2002. 0.01 0.1 10.010.050.10.20.3Response time (sec)SNF-DFSSNF-A*-WBSNF-A* 0.1 1 100.010.050.10.20.3Response time (sec)FNS-A*-WBFNS-A* 0.1 1 100.010.050.10.20.3Response time (sec)FNS-A*-WBFNS-A* 1 10 1000.010.050.10.20.3Response time (sec)SNF-A*-WBSNF-A* 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.092345Response time (sec)SFFS 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.42345Response time (sec)SNF-A*FNS-A* 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.091234Response time (sec)SFFS 0 0.05 0.1 0.15 0.2 0.25 0.3 0.351234Response time (sec)SNF-A*FNS-A*
1610.09146
1
1610
2016-10-28T09:45:31
Performance evaluation of explicit finite difference algorithms with varying amounts of computational and memory intensity
[ "cs.DS", "cs.DC", "cs.MS", "physics.comp-ph", "physics.flu-dyn" ]
Future architectures designed to deliver exascale performance motivate the need for novel algorithmic changes in order to fully exploit their capabilities. In this paper, the performance of several numerical algorithms, characterised by varying degrees of memory and computational intensity, are evaluated in the context of finite difference methods for fluid dynamics problems. It is shown that, by storing some of the evaluated derivatives as single thread- or process-local variables in memory, or recomputing the derivatives on-the-fly, a speed-up of ~2 can be obtained compared to traditional algorithms that store all derivatives in global arrays.
cs.DS
cs
Performance evaluation of explicit finite difference algorithms with varying amounts of computational and memory intensity 6 1 0 2 t c O 8 2 ] S D . s c [ 1 v 6 4 1 9 0 . 0 1 6 1 : v i X r a Satya P. Jammya,∗, Christian T. Jacobsa, Neil D. Sandhama aAerodynamics and Flight Mechanics Group, Faculty of Engineering and the Environment, University of Southampton, University Road, Southampton, SO17 1BJ, United Kingdom Abstract Future architectures designed to deliver exascale performance motivate the need for novel algorithmic changes in order to fully exploit their capabilities. In this paper, the performance of several numerical algorithms, characterised by varying degrees of memory and computational intensity, are evaluated in the context of finite difference methods for fluid dynamics problems. It is shown that, by storing some of the evaluated derivatives as single thread- or process-local variables in memory, or recomputing the derivatives on-the-fly, a speed-up of ∼2 can be obtained compared to traditional algorithms that store all derivatives in global arrays. Keywords: Computational Fluid Dynamics; Finite Difference Methods; Algorithms; Exascale; Parallel Computing; Performance 1. Introduction Explicit finite difference methods are an important class of numerical methods for the solution of partial or ordinary differential equations. For example, they are used for numerically solving the governing equations in computational fluid dynamics (CFD), astrophysics, seismic wave simulations, financial simulations, etc. In CFD they are used by many researchers for the Direct Numerical Simulation (DNS) or Large Eddy Simulation (LES) of compressible flows. DNS is often performed to study boundary layers, aerofoils (involving both ∗Corresponding author. E-mail address: [email protected] Preprint submitted to Journal of Computational Science September 18, 2018 hydrodynamics and noise computations) [1], mixing analysis [2], shock-wave boundary layer interactions [3] or benchmark test cases such as the Taylor- Green vortex [4], decaying homogeneous isotropic turbulence, etc. Even with the advances in computing hardware during the past decade, the current capabilities of DNS are limited to moderate Reynolds number flows [5]. It is expected that computing architectures will be capable of exaFLOPs (1018 Floating Point Operations) by 2018 and 30 exaFLOPs by 2030 [6]. Exascale architectures have the capability to perform DNS of the aforemen- tioned examples (amongst others) at higher Reynolds numbers, or potentially wall-modelled LES of the full model of an aircraft at operating Reynolds numbers. However, while there is a consensus [6] that future architectures would not look much like the present IBM Blue Gene, Cray, or IBM Produc- tive, it is hard to predict the architectural design of such exascale systems. For example, they are expected to comprise less memory per core than the existing architectures. Exploiting the full potential of the exascale architec- tures poses many challenges to researchers, such as the sustainability of the solver's implementation with the uncertainty of architectures, the need for new revolutionary algorithms/numerical methods, increasing computation to communication ratio and the likelihood of I/O bottlenecks. To address the problem of sustainability, taking into account the uncer- tainty in future architectures, one solution adopted by the CFD community involves decoupling the work of a domain scientist and a computational/- computer scientist [7]. In this approach, Domain Specific Languages (DSL) are developed by the computational/computer scientists, and the specifics of the problem and the numerical solution method are specified in the DSL by the domain scientist. Using source-to-source translation the numerical solver is targetted towards different parallel hardware backends (e.g. MPI, CUDA, OpenMP, OpenCL, and OpenACC) [8, 9]. This ensures that, for new archi- tectures, only the backend that interfaces with the new architecture needs to be written and supported by the translator. The underlying implementation of the solver remains the same, thereby introducing a separation of concerns. On the algorithms front, a lot of effort has gone into rewriting CFD solvers to exploit the available FLOPS of existing architectures. While the architectures have changed drastically in the last decade, algorithms have not advanced at a similar pace [6]. Some algorithmical changes have been attempted by [10, 11] to reduce the data transfer on Graphics Processing Units (GPUs), but a complete and detailed study on the performance of such algorithms on the existing CPU-based architectures is currently lack- ing. A first step towards exascale computing would be to evaluate the per- formance of algorithms characterised by varying intensities of memory usage 2 and computational cost on current CPU-based architectures for a relevant hydrodynamic test case, solved using a finite difference scheme. To facilitate these investigations, the capabilities of the recently devel- oped OpenSBLI framework [12] are extended to easily generate algorithms with varying amounts of computational and memory intensity. OpenSBLI is a framework for the automated derivation and parallel execution of finite difference-based models. It is written in Python and uses SymPy to generate a symbolic representation of the governing equations and discretisation. The framework generates OPS-compliant C code that is targetted towards MPI via the OPS active library [9]. A similar approach can also be applied to any set of compute-intensive equations solved using finite difference methods. The aims of this paper are to: (a) study the performance of various algorithms on current multi-core CPU-based architectures, (b) identify the best possible algorithm for the solution of explicit finite difference methods on current multi-core CPU-based architectures, and (c) demonstrate the ease at which algorithmic manipulations can be achieved with OpenSBLI framework to overcome the challenges exascale architectures can pose. The rest of the paper is organised as follows. The various algorithms are described in section 2. The validation of the algorithms is presented in section 3. The performance and scaling results are presented in section 4. Some conclusions are drawn in section 5. 2. Algorithms All the algorithms presented in this paper solve the three-dimensional un- steady compressible Navier-Stokes equations, with constant viscosity, given by ∂ρ ∂t = − ∂ ∂xj [ρuj] , = − ∂ ∂xj [ρuiuj + pδij − τij] , ∂ρui ∂t (1) (2) (3) and ∂ρE ∂t = − ∂ ∂xj [ρEuj + ujp − qj − uiτij] , for the conservation of mass, momentum and energy, respectively. The quan- tity ρ is the fluid density, ui is the velocity vector, p is pressure and E the total energy. The stress tensor τij is defined as, − 2 3 (cid:18) ∂ui 1 Re (cid:19) τij = (4) δij ∂uk ∂xk + ∂uj ∂xi ∂xj , 3 where δij is the Kronecker Delta and Re is the Reynolds number. The heat flux term qj is given by, qj = 1 (γ − 1) M2 Pr Re ∂T ∂xj , (5) where, T is temperature, M is the Mach number of the flow, Pr is Prandtl number and γ is the ratio of specific heats. The pressure and temperature are given by, (cid:18) (cid:19) p = (γ − 1) ρE − 1 2 ρu2 j , (6) (7) and T = γM2p ρ , (cid:19) (cid:18) ∂ respectively. The variables that are advanced in time (ρ, ρui, ρE) are re- ferred to as the conservative variables, and the right-hand sides (RHS) in the mass, momentum and energy equations are referred to as the residuals of the equations. The mass, momentum and energy equations are discretised in space using a fourth-order central finite-difference scheme and a low storage Runge-Kutta (RK) scheme with three stages of temporal discretisation. For improved stability, the convective terms in the governing equations are rewritten using the formulation of [13], ∂ ∂xj ρφuj = 1 2 ρφuj + uj ∂ ∂xj ρφ + ρφ ∂ ∂xj ∂xj uj , (8) where φ is 1, ui or internal energy (e) for the mass, momentum and energy equations, respectively. To improve the stability of the present scheme, the viscous terms in the momentum and energy equations are expanded to second derivatives as used by [2, 10, 14]. A generic pseudo-code of the solution algorithm is shown in figure 2. The time loop is the most computationally expensive part of the algorithm. It consists of evaluating the primitive variables (p, ui, T ), spatial derivatives, the residual for each equation and advancing the solution in time. This is achieved by iterating over the solution points of the grid, referred to as the grid loop in the rest of the paper. Various algorithms used for the evaluation of the residual of the equations are presented herein. Starting with a memory-intensive algorithm representing a typical handwritten CFD solver, the amount of memory used and the computational intensity are varied, either by re-evaluating the derivatives on-the-fly or evaluating the 4 set-the-initial-condition for each-iteration do save-state for each-rk-substep do evaluate-u_i,p,T evaluate-the-derivatives evaluate-the-residual-of-the-equations boundary-conditions advance-solution-in-time end for // end of rk sub loop end for // end of iteration loop Figure 1: Pseudo-code for the solution of the compressible Navier-Stokes equations. derivatives using process-local variables. In all the algorithms presented, the primitive variables are evaluated and stored in memory. Baseline algorithm (BL). This algorithm incorporates features similar to a typical handwritten static algorithm (i.e. the derivatives in the residual of each equation are evaluated and stored in memory as arrays of grid point values; these are referred to as work arrays in the rest of the paper) on CPUs, to run as a sequential or parallel using MPI or OpenMP. For multi- threaded parallel programs, this requires the algorithm to be thread-safe in order to avoid race conditions; these occur when a variable is updated in the grid loop and the updated variable is used to update another variable in the same loop. For example, in the evaluation of the primitive variables from the conservative variables, the equation for pressure (6) is dependent on the evaluated velocity components, and the equation for temperature (7) is dependant on the evaluated pressure. When running on threaded architectures, this potentially results in race conditions. This means that temperature could be evaluated before evaluating the pressure, and pressure could be evaluated before the velocity components are evaluated. Similar candidates for race conditions exist in the update equations (which advance the conservative variables forward in time) of the RK scheme. To remove the race conditions, the code is generated such that no variable is updated and used in the same loop. This is achieved by separating the evaluations into multiple loops over grid points. For example, in the evalua- tion of primitive variables, the velocity components (u0, u1, u2) are grouped into a single loop as the evaluations are independent, but the pressure and temperature are evaluated in different loops. 5 When generating the code that implements the BL algorithm, the first and second derivatives in the equations are evaluated and stored in work arrays in order to compute the RHS residual. The evaluation of the derivative of a combination of variables (e.g ∂(ρu0u0)/∂x0) is achieved in two stages. In the first stage the function ρu0u0 is evaluated and stored in a work array. In the second stage the derivative of the work array is evaluated using the central finite difference formula, and this result is stored in a new work array. The work array used in the first stage is not freed in memory, but is overwritten/reused when evaluating other quantities. The baseline algorithm is optimised such that computationally-expensive divisions are minimised. Rational numbers (e.g. finite difference stencil weights) and all the negative powers of constants in the equations are evalu- ated and stored at the start of the simulation. Typically, these are γ−1, Pr−1, Re−1, and so on. 1 ndim=3 # Problem dimension 2 # Define the c o m p r e s s i b l e Navier−Stokes 3 mass="Eq( Der ( rho , t ) ,− Skew ( rho ∗u_j , x_j ) ) " 4 momentum="Eq( Der ( rhou_i , t ) ,−Skew ( rhou_i ∗u_j , x_j )−Der (p , x_i )+Der ( 5 energy="Eq( Der ( rhoE , t ) ,−Skew ( rhoE∗u_j , x_j )−Conservative ( p∗u_j , in E i n s t e i n n o t a t i o n . tau_i_j , x_j ) ) " x_j )+Der ( q_j , x_j )+Der ( u_i∗tau_i_j , x_j ) ) " −(2/3)∗ KD( _i , _j ) ∗ Der (u_k , x_k) ) ) " 6 e q u a t i o n s =[mass , momentum , energy ] 7 # S u b s t i t u t i o n s 8 s t r e s s _ t e n s o r="Eq( tau_i_j , ( 1 / Re) ∗( Der ( u_i , x_j )+ Der ( u_j , x_i ) 9 heat_flux="Eq( q_j , ( 1 / ( ( gama−1)∗Minf∗Minf∗Pr∗Re) ) ∗Der (T, x_j ) ) " 10 s u b s t i t u t i o n s =[ s t r e s s _ t e n s o r , heat_flux ] 11 # Define a l l 12 c o n s t a n t s =["Re" , "Pr" , "gama" , "Minf" ] 13 # Define c o o r d i n a t e d i r e c t i o n symbol i n the e q u a t i o n s t h i s w i l l be x_i , x_j , the c o n s t a n t s ( x ) x_k f o r the v a r i a b l e s used in the e q u a t i o n s 14 coordinate_symbol="x" 15 # Formulas 16 v e l o c i t y="Eq( u_i , rhou_i / rho ) " 17 p r e s s u r e="Eq(p , ( gama−1) ∗( rhoE − (1/2) ∗ rho ∗( u_j∗u_j ) ) ) " 18 temperature="Eq(T, gama∗Minf∗Minf/ rho ) " 19 formulas =[ v e l o c i t y , p r e s s u r e , temperature ] 20 # Create the problem and expand the e q u a t i o n s . 21 problem=Problem ( equations , s u b s t i t u t i o n s , ndim , constants , coordinate_symbol , metrics , formulas ) 22 ex_eq=problem . get_expanded ( problem . e q u a t i o n s ) 23 ex_form=problem . get_expanded ( problem . formulas ) 24 s s=Central ( 4 ) # Fourth−order c e n t r a l d i f f e r e n c i n g 25 t s=RungeKutta ( 3 ) # Third−order RK scheme 26 # Create a numerical g r i d o f s o l u t i o n p o i n t s 6 f o r i i n range ( l e n ( l e n g t h ) ) ] 27 np =[64]∗ ndim ; d e l t a s =[2.0∗ p i /np [ i ] 28 g r i d=Grid ( ndim , { ' d e l t a ' : d e l t a s , ' number_of_points ' : np }) 29 # Perform the d i s c r e t i s a t i o n 30 sd=S p a t i a l D i s c r e t i s a t i o n ( ex_eq , ex_form , grid , s s ) 31 td=T e m p o r a l D i s c r e t i s a t i o n ( ts , grid , constant_dt=True , sd ) 32 # Boundary c o n d i t i o n s 33 bc=PeriodicBoundaryCondition ( g r i d ) 34 f o r dim in range ( ndim ) : 35 36 # Constant 37 i c s =["Eq( g r i d . work_array ( rho ) , 1 . 0 ) " , "Eq( g r i d . work_array ( rhou0 ) bc . apply ( td . p r o g n o s t i c _ v a r i a b l e s , dim ) c o n d i t i o n s i n i t i a l , 1 . 0 ) " , "Eq( g r i d . work_array ( rhou1 ) , 0 . 0 ) " , "Eq( g r i d . work_array ( rhou2 ) , 0 . 0 ) " , "Eq( g r i d . work_array ( rhoE ) , 1 . 0 ) " ] 38 i c s=G r i d B a s e d I n i t i a l i s a t i o n ( grid , i n i t i a l _ c o n d i t i o n s ) 39 i o=FileIO ( td . p r o g n o s t i c _ v a r i a b l e s )# I /O 40 # Simulation parameters 41 var =[ ' n i t e r ' , 'Re ' , ' Pr ' , 'gama ' , ' Minf ' , ' p r e c i s i o n ' , 'name ' , ' d e l t a t ' 42 v a l u e s = [ 1 0 0 0 , 1 6 0 0 , 0 . 7 1 , 1 . 4 , 0 . 1 , " double " , " t e s t " ,3.385∗10∗∗ −3] 43 sp=d i c t ( z i p ( vars , v a l u e s ) )# d i c t i o n a r y 44 code=OPSC( grid , sd , td , bc , i c s , io , sp )#code g e n e r a t i o n ] Listing 1: Key lines of the setup file for obtaining the BL algorithm. A sample setup file used to generate an implementation of this algorithm in OpenSBLI is shown in listing 1. All the algorithms presented next are also optimised to reduce computationally expensive divisions. The setup file for other algorithms is similar to the BL algorithm with extra attributes to control the combinations of memory used and computational intensity. Recompute All algorithm (RA). In contrast to the BL algorithm, the evalu- ation of pressure and temperature are first rewritten using the conservative variables, (cid:32) p = (γ − 1) ρE − 1 2 ρ (cid:18) and γ (γ − 1) M2 T = γM2p ρ = ρE − 1 2 ρ ρ (cid:18) ρuj ρ (cid:19)2(cid:33) (cid:16) ρuj , (cid:17)2(cid:19) ρ , (9) (10) within the code to avoid race condition errors while fusing loops for the evaluation of the primitive variables. Then, to evaluate the residual of the equation, all the continuous spatial derivatives in the residual are replaced by their respective finite difference formulas in the code generation stage. This differs from the BL algorithm in that, instead of evaluating the deriva- tives to work arrays and using them to compute the RHS residual, the code 7 for each-solution-point do double t1 = central difference formula for ∂u0/∂x0 double t2 = central difference formula for ∂u1/∂x1 ... residual = t1 + t2 ... end for Figure 2: Pseudo-code for residual evaluation using SN algorithm. generation process directly replaces the derivatives by their respective finite difference formulas such that they are recomputed every time. This algorithm results in a code in which no work arrays are used for storing the derivatives. The memory required for this algorithm is therefore the least of all algorithms and the computational intensity is the highest of all. The control parameters to generate code for this algorithm are shown in listing 2. 1 g r i d = Grid ( ndim , { " d e l t a " : d e l t a s , " number_of_points" : np }) 2 g r i d . s t o r e _ d e r i v a t i v e s = False # Do not s t o r e d e r i v a t i v e s Listing 2: Control parameters to generate the code for RA algorithm. Store None algorithm (SN). This algorithm is similar to the RA algorithm. The difference is that, in the loop over grid points where the residuals are evaluated, each derivative in the RHS is evaluated to a single thread- or process-local variable. These variables are then used to update the residuals on a point-by-point basis, rather than storing all evaluations in a global- scope, grid-sized work array. To generate the code that implements this algorithm in OpenSBLI, the grid attribute local_variables should be set to True along with the control parameters given in listing 2. The pseudo-code for the residual evaluation as described here is provided in figure 2. The memory footprint of this algorithm is similar to that of the RA algorithm, but is slightly less computationally-intensive. This is because, for example, if a derivative is evaluated to a process-local variable then it can be reused if that derivative appears in any of the equations more than once. Recompute Some algorithm (RS). In this algorithm, some of the derivatives (in this case, the first derivatives of the velocity components) are stored in work arrays and the remaining derivatives are replaced by their respective finite difference formulas in the residual. The evaluation of primitive vari- ables follows the same procedure as the RA algorithm. Listing 3 shows the 8 control parameters used to generate code for the RS algorithm. The memory usage for this algorithm is moderate, i.e. it is more than the RA algorithm but less than the BL algorithm. 1 g r i d = Grid ( ndim , { " d e l t a " : d e l t a s , " number_of_points" : np }) 2 g r i d . s t o r e _ d e r i v a t i v e s = False # Do not s t o r e d e r i v a t i v e s 3 g r i d . d e r i v a t i v e s _ t o _ s t o r e = s e t ( problem . get_expanded_term_in_equations ( "Der ( u_i , x_j ) " ) ) Listing 3: Control parameters to generate the code for the RS algorithm Store Some algorithm (SS). This algorithm is a fusion of the RS and SN algorithms, such that the derivatives that are not stored in the RS algorithm are evaluated and stored in thread- or process-local variables as per the SN algorithm. Listing 4 shows the control parameters used to generate code for this algorithm. Compared to the SN algorithm, an additional nine work arrays would be required for the SS algorithm for the 3D cases, and an additional four work arrays for 2D cases, since the first derivatives of the velocity components are now stored. 1 g r i d = Grid ( ndim , { " d e l t a " : d e l t a s , " number_of_points" : np }) 2 g r i d . s t o r e _ d e r i v a t i v e s = False 3 g r i d . d e r i v a t i v e s _ t o _ s t o r e = s e t ( problem . get_expanded_term_in_equations ( "Der ( u_i , x_j ) " ) ) 4 g r i d . l o c a l _ v a r i a b l e s = True Listing 4: Control parameters in setup file to generate the code for the SS algorithm. 3. Validation The baseline (BL) algorithm is validated for a 3D compressible Taylor- Green vortex problem, to check the correctness of the solver. The initial conditions and the post-processing procedure are described in [4]. The simu- lations are performed in a cube of non-dimensional length 2π, with periodic boundary conditions in all three directions for grids containing 643, 1283, 2563 and 5123 solution points. The Mach number, Prandtl number and Reynolds number of the flow are taken as 0.1, 0.71 and 1600, respectively. The non- dimensional time-step for the 643 grid size was set to 3.385 × 10−3, and was halved for each increase in the grid size by a factor of 23. Double-precision is used throughout all simulations presented in this paper. Figure 3 shows the evolution of kinetic energy and enstrophy compared with the reference data [15]. The results from the BL algorithm agree very well with the reference data for the 5123 case. For computational expedi- ence, the other algorithms are validated on the 1283 grid. For each one, the 9 Figure 3: Left: Evolution of the integral of kinetic energy. Right: Evolution of the integral of enstrophy. results relative to the BL algorithm are found to be the same up to machine precision. 4. Performance evaluation After checking that the results from the various algorithms match, the performance of the different algorithms were evaluated using the same Taylor- Green vortex test case described in section 3. All simulations are performed on ARCHER (the UK National Supercomputing Service) and the code that implements the various algorithms is compiled using the Cray C compiler (version 2.4.2) with the -O3 optimisation flag. Each ARCHER node com- prises 24 cores, with each MPI process being mapped to its own individual core. All simulations for performance evaluation purposes are run in par- allel using 24 MPI processes/cores (one ARCHER node). The run-time of the time iteration loop was recorded for 500 iterations and is summarised in table 1 for a range of grid sizes. Nx Ny Nz 64 64 128 128 256 256 64 128 256 BL 16.21 182.55 1561.52 RA 9.29 98.18 765.42 RS 10.76 97.36 802.76 SN 8.44 90.72 693.66 SS 9.78 88.95 685.25 Table 1: Total run-time in seconds for different grid sizes for all algorithms on ARCHER using 24 MPI processes. The data in table 1 is plotted in figure 4; from this figure it can be inferred that when the amount of memory access is reduced, the current CPU-based 10 05101520Non-dimensionaltime0.000.020.040.060.080.100.120.14IntegratedkineticenergyBL643BL1283BL2563BL5123Reference05101520Non-dimensionaltime0.0000.0020.0040.0060.0080.0100.0120.014IntegratedenstrophyBL643BL1283BL2563BL5123Reference Figure 4: Left: Figure showing data in table 1. Right: speed-up of algorithms normalised with the BL algorithm. architectures perform better, even though the computational intensity of such algorithms is higher. The baseline algorithm is a factor of ∼2 slower than all the other algorithms presented in this paper. For larger grid sizes the benefit of the SS algorithm becomes more pronounced. 4.1. Scaling Strong scaling tests were performed for the best performing algorithm (i.e. the SS algorithm) on ARCHER for the test problem with a total of 1.07×109 grid points and the runtime of the time iteration loop was recorded for 10 iterations. Figure 5 shows the strong scaling results on ARCHER up to 73,728 MPI processes/cores (i.e. 3,072 ARCHER nodes). The minimum number of processes required for running the problem is 120. The algorithm shows a near-linear scaling (speed-up of 2) until 36,864 MPI processes (i.e. 1,536 ARCHER nodes) and thereafter the speed-up is ∼ 1.5 as the process count doubles. Weak scaling tests were also performed for the SS algorithm. Here, the number of MPI processes was varied from 192 to 65,856 (i.e. 8 to 2,744 ARCHER nodes), while the number of grid points per MPI process was kept fixed at 643 and the runtime of the time iteration loop was recorded for 10 iterations. The largest grid size considered comprises ∼17 billion solution points. Figure 6 demonstrates that the normalised run-time is near-ideal. 5. Conclusion In this paper the automated code generation capabilities of the OpenS- BLI framework have been extended to easily modify the memory usage and 11 64312832563Numberofgridpoints02004006008001000120014001600Totalrun-time(s)BLAlgorithmRAAlgorithmRSAlgorithmSNAlgorithmSSAlgorithm64312832563Numberofgridpoints1.01.52.02.53.0Normalisedspeed-upRAAlgorithmRSAlgorithmSNAlgorithmSSAlgorithm Figure 5: Strong scaling of the SS algorithm on ARCHER up to 73,728 cores using 1.07× 109 grid points. The run-time has been normalised by that of the 120-process case. computational intensity of the solution algorithm. It was found that the baseline (BL) algorithm featured in traditional CFD codes, in which all derivatives are evaluated and stored in work arrays, is not the best algorithm in terms of performance on current multi-core CPU-based architectures. Re- computing all or some of the derivatives performs better than the baseline algorithm. The best algorithm found here for the solution of the compress- ible Navier-Stokes equations is to store only the first derivatives of velocity components in work arrays, and compute the remaining spatial derivatives and store them in thread- or process-local variables. The run-time of such an algorithm has been shown to be ∼2 times smaller than the BL algorithm. Through the use of modern code generation techniques in the OpenSBLI framework, it has been demonstrated that by changing just a few attributes (three in this case) in the problem setup file, different algorithms with vary- ing degrees of memory and computational intensity can be readily generated automatically. The methodology presented in this paper can also be used to find the best possible algorithm for other existing architectures such as GPUs or Intel Xeon Phi coprocessors. Moreover, existing numerical models that use finite difference methods for the solution of any governing equations can be optimised for the current CPU-based architectures. When exascale systems 12 1282565121024204840968192163843276865536Numberofprocesses012481632641282565121024Normalizedrun-timeSSAlgorithmIdeal Figure 6: Weak scaling of the SS algorithm on ARCHER with 643 grid points per MPI process up to 65,856. The results have been normalised by the run-time from the 192- process case. become available, depending on their architecture and amount of available memory, users can readily tune the memory and computational intensity in the OpenSBLI framework to determine the best performing algorithm on such systems. 6. Acknowledgements SPJ was supported by an EPSRC grant entitled "Future-proof massively- parallel execution of multi-block applications" (EP/K038567/1). CTJ was supported by a European Union Horizon 2020 project grant entitled "Ex- aFLOW: Enabling Exascale Fluid Dynamics Simulations" (grant reference 671571). The data behind the results presented in this paper will be avail- able from the University of Southampton's institutional repository. The authors acknowledge the use of the UK National Supercomputing Service (ARCHER), with computing time provided by the UK Turbulence Consor- tium (EPSRC grant EP/L000261/1). 13 2565121024204840968192163843276865536Numberofprocesses0.50.60.70.80.91.01.1Normalisedrun-timeSSAlgorithmIdeal References References [1] L. E. Jones, R. D. Sandberg, Acoustic and hydrodynamic analysis of the flow around an aerofoil with trailing-edge serrations, Journal of Fluid Mechanics 706 (2012) 295 -- 322. doi:10.1017/jfm.2012.254. [2] S. Pirozzoli, M. Bernardini, S. Marié, F. Grasso, Early evolution of the compressible mixing layer issued from two turbulent streams, Journal of Fluid Mechanics 777 (2015) 196 -- 218. doi:10.1017/jfm.2015.363. [3] B. Wang, N. D. Sandham, Z. Hu, W. Liu, Numerical study of oblique shock-wave/boundary-layer interaction considering sidewall ef- fects, Journal of Fluid Mechanics 767 (2015) 526 -- 561. doi:10.1017/ jfm.2015.58. [4] J. DeBonis, Solutions of the Taylor-Green Vortex Problem Using High- Resolution Explicit Finite Difference Methods, 51st AIAA Aerospace Sciences Meeting including the New Horizons Forum and Aerospace Exposition (February) (2013) 1 -- 9. doi:10.2514/6.2013-382. [5] W. C. Reynolds, Whither Turbulence? Turbulence at the Crossroads: Proceedings of a Workshop Held at Cornell University, Ithaca, NY, March 22 -- 24, 1989, Springer Berlin Heidelberg, Berlin, Heidelberg, 1990, Ch. The potential and limitations of direct and large eddy simu- lations, pp. 313 -- 343. doi:10.1007/3-540-52535-1_52. [6] J. Slotnick, A. Khodadoust, J. Alonso, D. Darmofal, W. Gropp, E. Lurie, D. Mavriplis, CFD Vision 2030 Study: A Path to Revolution- ary Computational Aerosciences, Nasa Cr-2014-21878 (March) (2014) 1 -- 73. [7] C. T. Jacobs, M. D. Piggott, Firedrake-Fluids v0.1: numerical mod- elling of shallow water flows using an automated solution framework, Geoscientific Model Development 8 (3) (2015) 533 -- 547. doi:10.5194/ gmd-8-533-2015. [8] F. Rathgeber, G. R. Markall, L. Mitchell, N. Loriant, D. A. Ham, C. Bertolli, P. H. Kelly, PyOP2: A High-Level Framework for Performance-Portable Simulations on Unstructured Meshes, in: High Performance Computing, Networking Storage and Analysis, SC Com- panion, IEEE Computer Society, 2012, pp. 1116 -- 1123. 14 [9] I. Z. Reguly, G. R. Mudalige, M. B. Giles, D. Curran, S. McIntosh- Smith, The OPS Domain Specific Abstraction for Multi-Block Struc- tured Grid Computations, in: Proceedings of the 2014 Fourth Interna- tional Workshop on Domain-Specific Languages and High-Level Frame- works for High Performance Computing, IEEE Computer Society, 2014, pp. 58 -- 67. doi:10.1109/WOLFHPC.2014.7. [10] F. Salvadore, M. Bernardini, M. Botti, GPU accelerated flow solver for direct numerical simulation of turbulent flows, Journal of Computa- tional Physics 235 (2013) 129 -- 142. doi:10.1016/j.jcp.2012.10.012. [11] J. C. Thibault, Implementation of a Cartesian Grid Incompressible Navier-Stokes Solver on Multi-Gpu Desktop Platforms Using Cuda, New Horizons (May) (2009) 1 -- 15. [12] C. T. Jacobs, S. P. Jammy, N. D. Sandham, OpenSBLI: A framework for the automated derivation and parallel execution of finite difference solvers on a range of computer architectures, Journal of Computational Science, SubmittedarXiv:1609.01277. [13] G. A. Blaisdell, E. T. Spyropoulos, J. H. Qin, The effect of the formu- lation of nonlinear terms on aliasing errors in spectral methods, Ap- plied Numerical Mathematics 21 (3) (1996) 207 -- 219. doi:10.1016/ 0168-9274(96)00005-0. [14] N. Sandham, Q. Li, H. Yee, Entropy Splitting for High-Order Numer- ical Simulation of Compressible Turbulence, Journal of Computational Physics 178 (2) (2002) 307 -- 322. doi:10.1006/jcph.2002.7022. [15] Z. Wang, K. Fidkowski, R. Abgrall, F. Bassi, D. Caraeni, A. Cary, H. Deconinck, R. Hartmann, K. Hillewaert, H. Huynh, N. Kroll, G. May, P.-O. Persson, B. van Leer, M. Visbal, High-order cfd methods: current status and perspective, International Journal for Numerical Methods in Fluids 72 (8) (2013) 811 -- 845. doi:10.1002/fld.3767. 15
1207.5200
3
1207
2013-10-18T22:15:51
Improved Concentration Bounds for Count-Sketch
[ "cs.DS" ]
We present a refined analysis of the classic Count-Sketch streaming heavy hitters algorithm [CCF02]. Count-Sketch uses O(k log n) linear measurements of a vector x in R^n to give an estimate x' of x. The standard analysis shows that this estimate x' satisfies ||x'-x||_infty^2 < ||x_tail||_2^2 / k, where x_tail is the vector containing all but the largest k coordinates of x. Our main result is that most of the coordinates of x' have substantially less error than this upper bound; namely, for any c < O(log n), we show that each coordinate i satisfies (x'_i - x_i)^2 < (c/log n) ||x_tail||_2^2/k with probability 1-2^{-Omega(c)}, as long as the hash functions are fully independent. This subsumes the previous bound and is optimal for all c. Using these improved point estimates, we prove a stronger concentration result for set estimates by first analyzing the covariance matrix and then using a median-of-median-of-medians argument to bootstrap the failure probability bounds. These results also give improved results for l_2 recovery of exactly k-sparse estimates x^* when x is drawn from a distribution with suitable decay, such as a power law or lognormal. We complement our results with simulations of Count-Sketch on a power law distribution. The empirical evidence indicates that our theoretical bounds give a precise characterization of the algorithm's performance: the asymptotics are correct and the associated constants are small. Our proof shows that any symmetric random variable with finite variance and positive Fourier transform concentrates around 0 at least as well as a Gaussian. This result, which may be of independent interest, gives good concentration even when the noise does not converge to a Gaussian.
cs.DS
cs
Improved Concentration Bounds for Count-Sketch∗ Gregory T. Minton MIT Eric Price MIT Abstract We present a refined analysis of the classic Count-Sketch streaming heavy hitters algo- estimate (cid:98)x of x. The standard analysis shows that this estimate (cid:98)x satisfies (cid:107)(cid:98)x− x(cid:107)2∞ < (cid:107)x[k] (cid:107)2 rithm [CCF02]. Count-Sketch uses O(k log n) linear measurements of a vector x ∈ Rn to give an 2/k , that most of the coordinates of (cid:98)x have substantially less error than this upper bound; namely, where x[k] is the vector containing all but the largest k coordinates of x. Our main result is for any c < O(log n), we show that each coordinate i satisfies ((cid:98)xi − xi )2 < x[k] 2 c 2 k log n with probability 1 − 2−Ω(c) , as long as the hash functions are fully independent. This subsumes the previous bound and is optimal for all c. Using these improved point estimates, we prove a stronger concentration result for set estimates by first analyzing the covariance matrix and then using a median-of-median-of-medians argument to bootstrap the failure probability bounds. These results also give improved results for (cid:96)2 recovery of exactly k-sparse estimates x∗ when x is drawn from a distribution with suitable decay, such as a power law or lognormal. We complement our results with simulations of Count-Sketch on a power law distribution. The empirical evidence indicates that our theoretical bounds give a precise characterization of the algorithm’s performance: the asymptotics are correct and the associated constants are small. Our proof shows that any symmetric random variable with finite variance and positive Fourier transform concentrates around 0 at least as well as a Gaussian. This result, which may be of independent interest, gives good concentration even when the noise does not converge to a Gaussian. · 3 1 0 2 t c O 8 1 ] S D . s c [ 3 v 0 0 2 5 . 7 0 2 1 : v i X r a ∗This work began when both authors were funded by internships at Microsoft Research. GM received further support from Hertz Foundation and National Science Foundation Fellowships, and EP received further support from a Simons Fellowship. 1 Introduction (1) The heavy hitters problem and the closely related sparse recovery problem are two of the most fundamental problems in the field of sketching and streaming algorithms [CCF02, CM06, GI10, CH10, Mut05]. The goal is to efficiently identify and estimate the k largest coordinates of an n-dimensional vector using a linear sketch Ax of x, where A ∈ Rm×n has m = O(k logc n) rows. guarantee: this is a bound for the estimate (cid:98)x recovered from Ax which is of the form The strongest commonly used formal guarantee for the quality of such an estimate is the (cid:96)∞/(cid:96)2 (cid:107)(cid:98)x − x(cid:107)2∞ ≤ (cid:107)x[k](cid:107)2 2/k , where x[k] denotes the vector obtained from x by replacing its largest k coordinates with 0. The classic approach for this problem is the Count-Sketch algorithm of Charikar et al. [CCF02], which uses m = O(k log n) measurements and satisfies (1) with 1 − 1/nΘ(1) probability. It is simple, practical, and gives the best known theoretical performance in many settings. It also pioneered a technique—hashing with random signs and estimating using medians—that forms the basis for several subsequent works on sparse recovery [GLPS10, IPW11, HIKP12, Gan12]. fully characterized and understood. Specifically, we prove that the quality of the approximation (cid:98)x Our result. We show that, despite the popularity of Count-Sketch, its performance has not been the worst-case error of (cid:98)x, we prove that most coordinates of (cid:98)x have asymptotically smaller error given by Count-Sketch is better than the standard bound (1) suggests. While (1) gives a bound on than this worst case. The Count-Sketch of a vector x using R rows of C columns is defined as follows. For u ∈ [R], (cid:88) we choose hash functions hu : [n] → [C ] and su : [n] → {±1}. The sketch is yu,v = su (i)xi , which consists of RC linear measurements. The estimate (cid:98)x is given by i:hu (i)=v (cid:98)xi = median su (i)yu,hu (i) . u Setting C = O(k) and R = O(log n), [CCF02] proves that (1) holds with 1 − 1/nΘ(1) probability. the point estimates (cid:98)xi resulting from Count-Sketch, assuming the hash functions are fully random: Our main result is the following strengthening of the analysis in [CCF02] for the accuracy of Theorem 4.1. Consider the estimate (cid:98)x of x from Count-Sketch using R rows and k ≥ 2 columns, (cid:34) (cid:35) with ful ly random hash functions. For any t ≤ R and each index i, ((cid:98)xi − xi )2 > (cid:107)x[k](cid:107)2 2 k The standard analysis [CCF02] proves this bound in the special case of t = R; one then gets (1) by setting t = R = Θ(log n) and applying a union bound. We show in Theorem 8.1 that our stronger result is optimal; it gives the best possible failure probability for all t ≤ O(log(n/k)) and all linear sketches. Theorem 4.1 shows that the average squared error of a set is 1/R times the previously known bound, i.e., the bound coming from (1). We extend this in Theorem 6.5 to show concentration when estimating a set of coordinates, so that the total squared error over the set satisfies our improved bound with high probability. < 2e−Ω(t) . Pr · t R 1 Implications. Often, one performs Count-Sketch in order to estimate the largest k coordinates of x. In this case, the bound (1) gives an optimal result for arbitrary vectors x [PW11] but not necessarily for common distributions on x. A particularly important distribution is the power law or Zipfian distribution, which is the standard distribution to analyze for sparse recovery [CCF02, CM05, CRT06, BCDH10]. Consider again Count-Sketch with R = Θ(log n) rows. We show that if x follows the power law xi = i−α for some constant α > 0.5, then the error in estimating the largest k coordinates is 1/ log n times the previously known bound with high probability (see Theorem 7.1 for details). The same result holds for other common distributions such as lognormals or exponentials. Previous work [Pri11] combined Count-Sketch with another sketch to get the same bound as in Theorem 7.1, but our result here applies directly to the output of Count-Sketch. This is impor- tant because Count-Sketch is an algorithm that is used in practice, while chains of algorithms are less likely to be used—especially because years later we may discover that the original algorithm performed as well as the chain! For example, Google uses Count-Sketch to estimate the largest k coordinates of x for their “top table”, a core language feature of their MapReduce programming language Sawzall [PDGQ05]. Because many datasets Google encounters (for example, the fre- quency of URLs on the web) are distributed as power laws or lognormals [Mit04, BKM+00, CM05], Theorem 7.1 directly applies to their setting. Experiments. Finally, we complement our analysis with simulations of Count-Sketch on a power law distribution. These show that, unlike previous results, Theorem 4.1 and Theorem 7.1 correctly characterize the asymptotic performance of point and top-k estimates, respectively. Furthermore, the constants involved are small: between 1/2 and 2. We also find that Count-Sketch has asymp- totically less error than Count-Min, an alternative sketch algorithm. Limitations. Our analysis requires that the hash functions be fully random. This is unfortunate because fully random hash functions would take up more space than the sketch itself, but there are reasons why this constraint is not too problematic. One reason is that Nisan’s pseudorandom number generator [Nis92] lets us store the hash functions with only a log n factor increase in space. Then if we wish to run Count-Sketch on multiple different vectors, we can reuse the hash functions. A second reason is that one expects bounded independence to suffice as long as the vector x itself has sufficient entropy. A result of this form is known [MV08] when supp(x) is drawn at random from a much larger domain. For example, if supp(x) contains n1/3 random coordinates out of n, then [MV08] implies near-uniformity with 4-wise independence. Our Techniques Our basic strategy is to translate the problem of bounding Count-Sketch error into a problem of proving a strong concentration result for a certain class of random variables. In more detail, the argument proceeds as follows. The error (cid:98)xi − xi is, by definition, the median This, in turn, we solve by analyzing the Fourier transform of such variables. over rows of error terms coming from the different coordinates which hash to the same column as i. For each row, we separate the error term into contributions from (i) the largest k coordinates j ∈ [k ] and we bound the error of type (ii) with our concentration result. We then get a bound on (cid:98)xi − xi and (ii) the remaining coordinates j ∈ [k ]. The error of type (i) is zero with constant probability, by using Chernoff bounds to conclude that if each of R symmetric random variables has a (cid:112)c/R chance of being small, then the median has a 1 − 2e−c/2 chance of being small. This proves strong bounds for the error of point estimates; we then analyze the pairwise dependence of said errors to conclude a bound on the error of sets. 2 The concentration result we prove is a bound of the form Pr[X < ] > Ω(), where X has variance 1 and is a sum of independent random variables, each of which is symmetric and zero with probability at least 1/2 (Corollary 3.2). Such a bound certainly holds in the limit as X converges √ √ to a Gaussian, but we need it to be true before X converges. To see why this is subtle, consider the sum of n independent ±1/ √ n variables. The Berry-Ess´een theorem gives our bound for  > 1/ n, √ but the bound is actually false for  < 1/ n when n is odd. When n is even, we can pair up the variables to get n/2 independent {0, ±2/ n} variables. These variables are zero with 1/2 probability, so our bound applies for arbitrarily small . What distinguishes even n from odd n? The key for our argument is that, for a symmetric random variable X with at least 1/2 proba- bility of being 0, the Fourier transform of X is nonnegative. The Fourier transform of the triangle filter max{1 − x/, 0} is also nonnegative. We use the convolution theorem to translate the ex- pectation of the triangle filter into an integral in Fourier space, and then use positivity to note that we can bound that integral over all Fourier space by the integral over small frequencies. This we control directly by using the quadratic Taylor series approximation to cos x. Because a lower bound on the expectation of the triangle filter also gives a lower bound on Pr[X < ], this proves what we want. The above techniques let us prove Theorem 4.1, which shows that, for Count-Sketch with O(log n) rows and k columns, the squared error in point estimates of individual coordinates i is exponentially distributed with mean µ2/ log n, where µ2 is the previously known bound. We generally want to estimate multiple coordinates at a time, though, so we proceed to bound the average error over sets of coordinate estimates. It follows easily from Theorem 4.1 that the average error is µ2/ log n in expectation; however, one might expect to get this error with high probability, since averages tend to concentrate as the size of the set grows. Getting strong concen- tration is difficult because the errors in different coordinates are not independent. To handle this, we resort to the following approach. Consider sets of size k . We first show that the error coming from collisions with small coordinates can be replaced by independent noise, and then we define a variant of Count-Sketch which is pairwise independent. By bounding the difference of regular Count-Sketch and this pairwise independent variant, we get a bound on the covariance matrix of the errors for each coordinate in our set. We then apply Chebyshev’s inequality, getting µ2/ log n error with failure probability O(k−1/14 ) (Proposition 5.1). This bound is nontrivial but falls well short of the “high probability” standard of O(1/kc ) failure probability for arbitrary constant c. √ However, there is a kludge that gives the (cid:101)Θ(1/kc ) failure probability we want. Consider running Unfortunately, while a more refined bound on the covariance matrix could improve the exponent, no approach based on Chebyshev’s inequality can prove better than a 1/ k failure probability. Count-Sketch. Some analysis shows that this boosts the failure probability from (cid:101)Θ(k−1/14 ) to the desired (cid:101)Θ(1/kc ) (Corollary 6.3). Our goal, though, is to analyze the simple Count-Sketch algorithm O(c) Count-Sketches in parallel and taking the (coordinate-wise) median of the results of each that people actually use instead of this hackish variant. Notice that the kludge uses the same set of measurements as Count-Sketch with an O(c) factor more rows, but then performs recovery by estimating each coordinate as a median (over chunks) of medians (within chunks), rather than Count-Sketch’s direct medians. To complete the argument we show, via our “Median3 Lemma” medians. Thus true Count-Sketch also satisfies the desired (cid:101)Θ(1/kc ) bound on the failure probability (Lemma 6.4), that taking medians directly cannot be much worse than computing the median of (Theorem 6.5); in summary, the weak bound we get from bounding the covariance matrix bootstraps into a better bound. 3 2 Preliminaries Notation We use f (cid:38) g to denote f = Ω(g) and f (cid:46) g to denote f = O(g). In the statement of Theorem 4.1, x[k] denotes the vector consisting of all but the largest k coordinates of x. More generally, we think of the coordinates of x as being sorted, x1 ≥ x2 ≥ · · · ≥ xn . This is purely a notational convenience, possible because Count-Sketch is invariant under permutation of coordinates. Given a real-valued random variable X , its Fourier transform is the function √−1 ]. F (t) = E[e2πX t In general F (t) is complex-valued. However, our random variables are all symmetric; in this case F (t) is real-valued and equals E[cos(2πX t)]. 3 Concentration Lemmas The following is the key lemma for our proof. Lemma 3.1. Let X be a symmetric, real-valued random variable with variance 1, and suppose that its Fourier transform F (t) is nonnegative. Then, for  ≤ 1, Pr[X < ] (cid:38) . 2 x2 holds for all x ∈ R, we have Proof. Because cos x ≥ 1 − 1 F (t) ≥ E[1 − 1 2 (2πX t)2 ] = 1 − 2π2 t2 ∀ t ∈ R. (cid:40) 2 for t ∈ [− 1 In particular, F (t) ≥ 1 2π , 1 2π ]. Let T (x) be the triangle filter 1 − 1  x if x <  otherwise 0 T (x) = (cid:90) ∞ and recall the Fourier transform relation sin2 (πt) −∞ π2 t2  (cid:90) ∞ Using this relation and switching the order of integration, sin2 (πt) −∞ π2 t2  The integrand is nonnegative, so we get a lower bound on E[T (X )] by integrating only over the 2π ]. On this interval we have F (t) ≥ 1 interval [− 1 2 and, because  < π , sin2 (πt) 2π , 1 is bounded below (cid:90) 1/(2π) π2 t2  by its value at t = 1/(2π). Putting this together, we find that sin2 (πt) F (t) dt (cid:38) sin2 (/2) −1/(2π) π2 t2   For  ≤ 1 we have sin2 (/2) (cid:38) . Now noting that Pr[X < ] ≥ E[T (X )] completes the proof. 0] ≥ 1/2 for each i. Set X = (cid:80)n  Corollary 3.2. Let {Xi : i ∈ [n]} be independent symmetric random variables such that Pr[Xi = i=1 Xi and σ2 = E[X 2 ]. For  ≤ 1, Pr[X < σ ] (cid:38) . √−1 dt. e2πxt E[T (X )] = F (t) dt. E[T (X )] ≥ . T (x) = 4 Proof. For each i ∈ [n], let pi = Pr[Xi = 0]. The Fourier transform of Xi is Fi (t) = pi + (1 − a symmetric random variable with nonnegative Fourier transform (cid:81)n pi ) E[cos(2πXi t) Xi (cid:54)= 0] ≥ pi + (1 − pi )(−1). Because pi ≥ 1/2, this is nonnegative. Now X/σ is i=1 Fi (t/σ) and with variance E[(X/σ)2 ] = 1; applying Lemma 3.1 to it gives the desired bound. Note that Lemma 3.1 is not true without the positivity assumption; in particular, as we observed in the introduction, Corollary 3.2 is not true when Pr[Xi = 0] is small. Indeed, it seems intuitive that we get strong concentration around 0 as a consequence of the large probability of each individual variable being 0. We also remark that there are analogs of Lemma 3.1 and Corollary 3.2 using only first moment bounds. The proof is nearly identical, so we omit it. We also need the following lemma for concentration of medians. (cid:20)(cid:12)(cid:12)(cid:12)(cid:12)median (cid:12)(cid:12)(cid:12)(cid:12) ≥ x (cid:21) Lemma 3.3. Suppose X1 , . . . , Xt are independent symmetric random variables such that, for some x, p > 0, we have Pr[Xi < x] > p for al l i ∈ [t]. Then < 2e−tp2 /2 . Pr Xi i∈[t] Pr[Ei = 1] < (1 − p)/2, so E[(cid:80)t Proof. Let Ei denote the indicator for the event that Xi ≥ x. Because Xi is symmetric we have (cid:34) t(cid:88) (cid:35) i=1 Ei ] < t/2 − pt/2. The Ei are independent, so by a Chernoff bound we have that Ei ≥ t < e−2(pt/2)2 /t = e−tp2 /2 . Pr 2 i=1 The same bound applies to the event that at least t/2 of the Xi are less than −x, and if neither event occurs then the median is in the interval (−x, x). Pr Tu = 4 Count-Sketch Theorem 4.1. Consider the estimate (cid:98)x of x from Count-Sketch using R rows and k ≥ 2 columns, (cid:34) (cid:35) with ful ly random hash functions. For any t ≤ R and each index i, ((cid:98)xi − xi )2 > (cid:107)x[k](cid:107)2 · < 2e−Ω(t) . t 2 k R (cid:26) su (j )xj Proof. Fix i ∈ [n]. For each row u and coordinate j ∈ [n], define if hu (j ) = hu (i) (cid:88) otherwise. 0 j∈[k]\{i} Xu,j = (cid:88) Xu,j and Hu = j∈[k]\{i} (cid:98)xi − xi = median Then, by definition, Hu + Tu . u Each random variable Xu,j is symmetric, equals 0 with probability 1 − 1/k ≥ 1/2, and otherwise (cid:80) equals ±xj . Moreover, for each row u, the random variables {Xu,j } are independent. Thus E[T 2 u ] = (cid:35) (cid:34) j /k ≤ (cid:107)x[k](cid:107)2 j∈[k]\{i} x2 2/k , so Corollary 3.2 shows that (cid:107)x[k](cid:107)2√ k For each row u, define Xu,j . Tu <  · Pr (cid:38)  5 (cid:38) . < 2e−Ω(R2 ) . (cid:107)x[k](cid:107)2√ k for all  ≤ 1. Furthermore, Hu = 0 with probability at least (1 − 1/k)k ≥ 1/4, i.e., with constant (cid:34) (cid:35) probability. Since Hu is independent of Tu , this means that (cid:107)x[k](cid:107)2√ Hu + Tu <  · k (cid:35) Pr (cid:34) Therefore Lemma 3.3 implies (cid:98)xi − xi >  · Setting  = (cid:112)t/R yields the desired result. Pr 5 Concentration for Sets Theorem 4.1 shows that each individual error ((cid:98)xi − x)2 has a constant chance of being less than O(1/R) times the (cid:96)2∞ bound. One would reasonably suspect that the average error over large sets would satisfy this bound with high probability. This is in fact true. The following result is proven Proposition 5.1. Fix a constant t > 0 and consider the estimate (cid:98)x of x from Count-Sketch using in Appendix A. R rows and C = ck columns, log k (cid:46) R, for sufficiently large (depending on t) constant c. For any (cid:34) (cid:35) set S ⊂ [n] with S ≤ k , (cid:107)(cid:98)xS − xS (cid:107)2 2 > t · S · 1 R The analysis leading to Proposition 5.1 is excessively lossy but, as we will see presently, we can improve the resulting bound after the fact so that the loss is only temporary. (cid:46) 1 S 1/14 Pr (cid:107)x[k](cid:107)2 2 k · . 6 Improving the Probability Bound To get a better bound on the failure probability than Proposition 5.1, we first consider the procedure of running Count-Sketch a constant number of times in parallel and taking the median of the resulting estimates. Using this procedure lets us improve the exponent in the failure probability to any desired constant. Lemma 6.1. Let x(1) , . . . , x(r) be vectors in Rn and let x ∈ Rn be the coordinate-wise median of √ {x(1) , . . . , x(r)}. If at least a 3/4 fraction of the variables x(i) satisfy (cid:107)x(i)(cid:107)2 < C , then (cid:107)x(cid:107)2 < C 3. Proof. Choose 3r/4 indices i satisfying (cid:107)x(i)(cid:107)2 < C ; call these indices “good”. Fix a coordinate j . For at least r/2 indices i we have xj ≤ x(i) j and for at least r/2 we have xj ≥ x(i) j ; thus (using the j ≤ (x(i) first group if xj ≥ 0 and the second group if xj < 0) for at least r/2 indices i we have x2 j )2 . (cid:88) (cid:88) Of these, at least r/2 − r/4 = r/4 must also be good. Hence j )2 ≤ 1 j ≤ mean j )2 ≤ 1 (x(i) (x(i) x2 r/4 r/4 good i s.t. j ≤(x(i) good i good i s.t. x2 j )2 j ≤(x(i) x2 j )2 2 ≤ 3 mean(good i)(cid:107)x(i)(cid:107)2 Summing over the coordinates j gives (cid:107)x(cid:107)2 2 < 3C 2 . (x(i) j )2 = 3 mean good i (x(i) j )2 . 6 We remark in passing that there is a generalization of Lemma 6.1 in which one replaces Euclidean balls with convex, coordinate-wise symmetric sets. Lemma 6.2. Suppose {X1 , . . . , Xr } are independent random variables taking values in Rn . Let X be the random variable obtained by taking the coordinate-wise median of {X1 , . . . , Xr }. √ If Pr[(cid:107)Xi(cid:107)2 < C ] ≥ 1 − p for each i, then Pr[(cid:107)X (cid:107)2 < C 3] ≥ 1 − (11p)r/4 . (cid:1)pr/4 ≤ (4ep)r/4 ≤ (11p)r/4 . Thus, with probability at least 1 − (11p)r/4 , at least is at most (cid:0) r Proof. Let Ei denote the event that (cid:107)Xi(cid:107)2 ≥ C . The probability that at least r/4 of the Ei occur √ r/4 a 3/4 fraction of the variables Xi satisfy (cid:107)Xi(cid:107)2 < C . When this holds we have (cid:107)X (cid:107)2 < C 3 by Corollary 6.3. Fix a real constant t > 0 and a positive integer d and consider the estimate (cid:98)x of Lemma 6.1. x coming from running 56d instances of Count-Sketch in paral lel, each using R rows and C = ck columns (for sufficiently large — depending d and t — constant c), and then taking the coordinate- (cid:35) (cid:34) wise median of the 56d resulting estimates. Suppose log k (cid:46) R. For any set S ⊂ [n] with S ≤ k , (cid:107)(cid:98)xS − xS (cid:107)2 (cid:107)x[k](cid:107)2 2 > t · S · 1 · (cid:46) 1 2 Pr S d . R k Proof. For i ∈ [56d] let (cid:98)xi denote the estimate from the ith instance of Count-Sketch. Using (cid:34) (cid:35) Proposition 5.1 we can choose c such that (cid:107)((cid:98)xi )S − xS (cid:107)2 (cid:107)x[k](cid:107)2 · · S · 1 (cid:46) 1 t 2 . Pr 2 > S 1/14 k 3 R We now get the desired result by applying Lemma 6.2 to the random variables {((cid:98)xi − x)S }i . We now conclude the section by showing that the bound in Corollary 6.3 applies to Count- Sketch itself. The key is the following combinatorial observation, which can be summarized as “the median of the median-of-medians is the median!” Lemma 6.4 (Median3 ). Let {a1 , . . . , an} be a list of n = k(cid:96) real numbers with n odd. Consider the set Π of al l partitions π = {S1 , . . . , S(cid:96)} of [n] into blocks of size k . Then median π∈Π median b∈[(cid:96)] median i∈Sb ai = median i∈[n] ai . Proof. As medians depends only on the relative orderings, without loss of generality we may as- sume that the set {ai} is symmetric about 0 (e.g., take ai = −(n + 1)/2 + i). Both sides of the desired equality are invariant under permutation of coordinates; hence they are both invariant Theorem 6.5. Fix a constant d, and consider the estimate (cid:98)x of x from Count-Sketch using R rows under negation of the elements ai and so are both zero. and C = ck columns, for sufficiently large (depending on d) constant c. Suppose log k (cid:46) R. For (cid:34) (cid:35) any set S ⊂ [n] with S ≤ k , (cid:107)(cid:98)xS − xS (cid:107)2 2 > S · 1 R (cid:107)x[k](cid:107)2 2 k Pr · (cid:46) 1 S d . 7 Proof. Let π be a partition of [R] into 56d blocks of size R/(56d) and let (cid:98)xπ denote the estimate obtained by running Count-Sketch separately on each block and then taking the median of the results (as in Corollary 6.3). Define (cid:107)x[k](cid:107)2 B = S · 1 · 2 and let Eπ be the indicator for the event (cid:107)((cid:98)xπ − x)S (cid:107)2 k R (cid:34) 2 > 1 3 B . Define (cid:107)((cid:98)xπ − x)S (cid:107)2 p = 4 Pr[Eπ = 1] = 4 Pr 2 > By Corollary 6.3, we can choose the constant c so that p (cid:46) 1/ S d . E[(cid:80) π Eπ ] ≤ N p/4, and so Pr[(cid:80) with at least 1 − p probability) that (cid:80) This holds for any partition π . Letting N denote the number of such partitions, we have π Eπ ≤ N/4. Then, letting (cid:101)x be the coordinate-wise median π Eπ > 1 4 N ] < p by Markov’s inequality. Suppose now (as happens of (cid:98)xπ over all partitions π , we have (cid:107)((cid:101)x − x)S (cid:107)2 2 ≤ B by Lemma 6.1. But (cid:101)x = (cid:98)x by the Median3 Lemma (Lemma 6.4). Putting this together, we have (cid:107)(cid:98)xS − xS (cid:107)2 2 ≤ B with probability at least 1 − p, which is exactly what we wanted. (cid:107)x[k](cid:107)2 2 k (cid:35) . 1 3 · S · 1 R · 7 Concentration for Compressible Signals One key application of Count-Sketch is to compute a table estimating the largest k coordinates of x [PDGQ05]. Some questions arise about the proper metric for evaluating such estimates. For continuous distributions, distinguishing the kth and (k + 1)st largest coordinates is both difficult from x to the nearest x(cid:48) which has the same top k coordinates as (cid:98)x. That is, if Hk (x) denotes the and not very important. We choose to measure the “distance to validity,” meaning the distance restriction of x to its k largest components, then we denote the “top-k estimation error” of (cid:98)x by Ek (x, (cid:98)x) := x(cid:48) :Hk (x(cid:48) )=Hk ((cid:98)x) (cid:107)x − x(cid:48)(cid:107)2 . (2) min The basic (cid:96)∞/(cid:96)2 guarantee (1) gives that, with R = Θ(log n) and C = O(k), Count-Sketch satisfies Ek (cid:46) (cid:107)x[k](cid:107)2 2 . By [PW11], this is optimal on worst-case inputs x. However, real-world signals are not worst-case. In fact, signals are likely to be well approximated by power law or lognormal distributions [Mit04, BKM+00, CM05], and sparsity is mainly useful because such signals are, in fact, sparse [CRT06, BCDH10]. In this section we consider recovery of signals with suitable decay: that is, signals where xk − √ x2k (cid:38) (cid:107)x[k](cid:107)2/ k . This condition is satisfied by any power law distribution xi ≈ i−α with α > 0.5, which is the range of α for which the distribution is sparse (in (cid:96)2 ); the condition is also satisfied by lognormal distributions in the range for which they are sparse. We show that, for such signals, Ek (cid:46) (cid:107)x[k](cid:107)2 2/R with high probability. This gives a factor of R sets of indices, on such distributions the largest k coordinates of (cid:98)x will, with high probability, be improvement over the standard result. The idea is that while Theorem 6.5 only applies to fixed among the largest 2k coordinates of x. Hence we can apply Theorem 6.5 to that fixed set of 2k coordinates. 8 k and fix a constant d. Let (cid:98)x be the result of √ Theorem 7.1. Suppose xk − x2k (cid:38) (cid:107)x[k](cid:107)2/ Count-Sketch using R (cid:38) log n rows and Θ(k) columns, with ful ly random hash functions and constant factors depending on d. Define Ek as in (2). Then Ek (x, (cid:98)x) ≤ 1 (cid:107)x[k](cid:107)2 2 R with 1 − O(1/kd ) probability. we have with 1 − n−Θ(1) probability that (cid:107)(cid:98)x − x(cid:107)2∞ < (cid:107)x[ck](cid:107)2 Proof. Let the number of columns be ck for some constant c. By the standard Count-Sketch bound 2/(ck). Then for sufficiently large c, (cid:98)xi > max((cid:98)xj , xj ) (3) Let x(cid:48) equal (cid:98)x over [2k ] and x over [2k ]. Then by (3) the top k coordinates of (cid:98)x and of x(cid:48) both for all i ∈ [k ] and j ∈ [2k ]. lie among [2k ]; since x(cid:48) = (cid:98)x on this region, the top k coordinates of the two are equal. Hence Ek (x, (cid:98)x) ≤ (cid:107)x − x(cid:48)(cid:107)2 = (cid:107)(cid:98)x[2k] − x[2k](cid:107)2 2 . (cid:107)(cid:98)x[2k] − x[2k](cid:107)2 (cid:107)x[2k](cid:107)2 (cid:46) 1 2k 2 2 R ck with probability at least 1 − O(1/kd ). Setting c large enough gives the result. But by Theorem 6.5, 8 Lower Bound on Point Queries The following is an application of the proof technique of [PW11], using Gaussian channel capacity to bound the number of measurements required for a given error tolerance. x ∈ Rn , there is some vector x and index i for which the estimate (cid:98)x of x satisfies Theorem 8.1. For any 1 ≤ t ≤ log(n/k) and any distribution on O(Rk) linear measurements of (cid:34) (cid:35) ((cid:98)xi − xi )2 > (cid:107)x[k](cid:107)2 > e−Ω(t) . t 2 Pr R k Proof. Suppose without loss of generality that n = k2t (by ignoring indices outside [k2t ]) and that t is larger than some constant. Partition [n] into k blocks of size 2t . Set x = y + w, where y ∈ {0, 1, −1}n has a single random ±1 in each block (so it is k-sparse) and w = N (0,  Rk nt In ) for Suppose that, in expectation over x, A ∈ Rm×n allows recovering (cid:98)x from Ax with some constant  is i.i.d. Gaussian. ((cid:98)xi − xi )2 ≤ t (cid:107)x[k](cid:107)2 2 k R for more than a 1 − 2−2t fraction of the coordinates i. We will show that such an A must have m (cid:38) Rk rows. Yao’s minimax principle then gives a lower bound for distributions on A. With this, the inability to increase t and k while preserving the number of rows gives the desired lower bound on failure probability. (4) 9 First, we show that I (Ax; z ) (cid:38) kt. Let E be the event that (4) holds for more than a 1 − 2−t−2 2 < 2 E[(cid:107)w(cid:107)2 fraction of coordinates i and that (cid:107)w(cid:107)2 2 ] = 2Rk/t. E holds with probability 1 − o(1) > ((cid:98)xi − xi )2 < 2 1/2 probability over x. Conditioned on E , we have for a 1 − 2−t−2 fraction of the coordinates i. Thus, for  = 1/8, if we round (cid:98)xi to the nearest integer i = zi in a 1 − 2−t−2 fraction of the coordinates; hence x∗ we recover x∗ with x∗ i = zi over at least 3/4 of the blocks. We know that z has (t + 1) bits of entropy in each block. This means, conditioned on E , (cid:19) (cid:18) k I (z ; x∗ ) = H (z ) − H (z x∗ ) ≥ k(t + 1) − log( 2(t+1)k/4 ) k/4 ≥ k(t + 1) − k(t + 1)/4 − k log(4e)/4 (cid:38) kt and hence I (Ax; z E = 1) (cid:38) kt by the data processing inequality. But since Pr[E ] ≥ 1/2, I (Ax; z ) ≥ I (Ax; z E ) − H (E ) ≥ I (Ax; z E = 1) Pr[E ] − 1 (cid:38) kt. (5) Second, we show that I (Ax; z ) (cid:46) mt/R. For each row Aj , Aj x = Aj z + Aj w = Aj z + w (cid:48) for w (cid:48) ∼ N (0, (cid:107)Aj (cid:107)2 2 Rk/(nt)). We also have Ez [(Aj z )2 ] = (cid:107)A(cid:107)2 2k/n. Hence Aj x is an additive white Gaussian noise channel with signal-to-noise ratio E[(Aj z )2 ] E[w (cid:48)2 ] t R = . By the Shannon-Hartley Theorem, this channel has capacity I (Aj x; z ) ≤ 1 t t log(1 + ) < R R 2 and thus, by linearity and independence of w (cid:48) (as in [PW11]), I (Ax; z ) (cid:46) mt/R (cid:46) t/R Combining (5) and (6) gives m (cid:38) Rk . 9 Simulation (6) Theorems 4.1 and 7.1 give asymptotic upper bounds on the error of Count-Sketch estimates. The- orem 8.1 shows that there exists a distribution on inputs for which Theorem 4.1 gives the correct asymptotics. However, this does not show that the asymptotics are correct on common input distributions, or that these asymptotics appear at practical input sizes. To address these questions, in this section we discuss empirical results demonstrating that, on the most common model of input distributions, • Theorems 4.1 and 7.1 give the right asymptotics; • the constants involved are small; and • the estimates are better than those of Count-Min, an alternative estimation algorithm. 10 9.1 Simulation Details We draw x ∈ Rn from the Pareto (Type I) distribution with parameter α = 1.25, chosen because Pareto distributions are common in large data sets and α ∈ [1, 1.5] is typical [CSN09, Mit04]. This distribution is given by Pr[xi > t] = (µ/t)α µ = n−1/α(cid:112)2/α − 1 independently for each i, where the scaling parameter is chosen so that E[(cid:107)x[k](cid:107)2 2 ] ≈ k1−2/α = k−0.6 . (Note that, for k ≥ 10 and large n, the error in the approximation E[(cid:107)x[k](cid:107)2 2 ] ≈ k1−2/α is less than 1%.) estimates (cid:98)x of x. We will analyze the distributions of point error and top-k estimation error, as We then perform Count-Sketch with R rows and C columns, for various R and C , to get Ep = (cid:98)xi − xi distributions over x and the Count-Sketch. Point error is defined as for a random coordinate i. For top-k estimation error Ek , we use the definition (2) from §7. We will study the behavior of Ek and Ep for large n as a function of R, C , and k , in order to • (Theorem 4.1) After removing n2−Ω(R) probability mass, the point estimation error (cid:98)xi − xi empirically verify the following specific claims. has expectation E[(cid:107)x[C ](cid:107)2 ] E[(cid:107)x[C ](cid:107)2 2 ]1/2 √ √ (cid:39) ≈ 1 R.5C .8 =: mR,C RC RC Pr[(cid:98)xi − xi > tmR,C ] ≤ e−Ω(t2 ) . and decays like a Gaussian: E[Ep ] (cid:39) (a) Distribution of Ep /mR,C for various R, C . Note that it is nearly independent of R and C . (b) Same as (a), but with Count-Min added for com- parison. Note that Count-Min has larger error than Count-Sketch. Figure 1: Histograms of the point error Ep 11 0.00.20.40.60.81.01.21.41.6The ratio cxi−xi/mR,C0.00.51.01.52.02.53.0Probability densityDistribution of errors, 10 trials at n=1000000R=20, C=20R=20, C=30R=20, C=50R=20, C=100R=20, C=200R=20, C=500R=20, C=1000R=20, C=2000R=20, C=5000R=20, C=10000R=50, C=20R=50, C=30R=50, C=50R=50, C=100R=50, C=200R=100, C=20R=100, C=30R=100, C=50R=100, C=100R=100, C=200R=200, C=20R=200, C=30R=200, C=50R=200, C=100R=500, C=20R=500, C=30R=1000, C=20051015202530The ratio cxi−xi/mR,C0.00.51.01.52.02.53.0Probability densityComparison to Count-MinCount-Sketch (all)Count-Min: R=20, C=100Count-Min: R=20, C=20Count-Min: R=100, C=100Count-Min: R=100, C=20 • (Theorem 7.1) After removing n2−Ω(R) probability mass, the top-k estimation error has ex- √ pectation E[Ek ] (cid:39) Furthermore, as k increases, Ek concentrates more strongly about its mean: Pr[Ek > 2 E[Ek ]] (cid:46) 1/k . kmR,C . Our results are presented in the form of a series of figures. √ (a) Distribution of Ek /(mR,C k) for multiple C . Once C is large enough, the distribution is fairly static. √ (b) Distribution of Ek /(mR,C k) for multiple R. Once R is large enough, the distribution is fairly static. √ (c) E[Ek ]/(mR,C (d) E[Ek ]/(mR,C k) as a function of R. Above some thresh- k) as a function of C . Above some thresh- old (depending on R), the mean remains fixed at a constant. old (depending on C ), the mean remains fixed at a constant. √ Figure 2: Experimental results for the top-k error Ek 12 0123456789Ek/(mR,Cpk)0.00.20.40.60.81.01.21.4Probability densityDistribution of Ek for various C with n=10000, k=25, R=50C=20C=50C=100C=200C=500C=1000024681012Ek/(mR,Cpk)0.00.20.40.60.81.01.21.4Probability densityDistribution of Ek for various R with n=10000, k=25, C=100R=10R=20R=50R=100R=200R=500R=1000R=2000R=4000101102103C012345678Mean of Ek/(mR,Cpk)Mean of Ek as a function of C, with n=10000, k=25R=20R=50R=200100101102103104R05101520Mean of Ek/(mR,Cpk)Mean of Ek as a function of R, with n=10000, k=25C=50C=100C=200C=500 √ (a) Distribution of Ek /(mR,C k) for varying k . For small k , as k increases the distribution becomes narrower and remains roughly in place. For larger k , as k increases the distribution instead shifts to the right. (b) The variance of Ek / E[Ek ], as a distribution over k . It appears to be approximated well by 0.6/k . Figure 3: Experimental results for the variation of the top-k error Ek Figure 1(a) shows the probability density function of Ep/mR,C for n = 106 and many different pairs (R, C ). We find that the PDFs all look fairly similar, and match a Gaussian with constant standard deviation. For comparison, Figure 1(b) shows the equivalent error when using the Count- Min sketch of Cormode and Muthukrishnan [CM04]. We find that Count-Min gives asymptotically higher error for the estimation of each coordinate. √ We study the distribution of Ek in Figure 2. Figures 2(a) and 2(b) give the probability density functions of Ek /(mR,C k) for various R and C , respectively. In both cases, we find that once R and C reach a threshold, the distribution remains roughly constant—and has a constant mean—as R and C increase beyond that point. Figures 2(c) and 2(d) show how E[Ek ] changes as a function of √ √ √ R and C , respectively. As predicted, we find that Ek /(mR,C k) has constant mean—so Ek scales k) ≈ 3 as mR,C k—after R and C are sufficiently large. The threshold above which Ek /(mR,C allows some trade-off between R and C . At n = 104 and k = 25, we observe that (R, C ) = (26, 100) ≈ (2 log2 n, 4k) is above the threshold. √ In In Figure 3, we consider how well Ek concentrates about its mean as a function of k . 3(a), we plot the PDF of Ek /(mR,C k) for various values of k . We observe that as k increases, the √ distribution becomes more tightly distributed about its mean. However, once k is large enough, our chosen (R, C ) is no longer above the threshold for (n, k), causing the distribution of Ek /(mR,C k) to shift markedly to the right and stop becoming more tightly distributed. In 3(b), we plot the variance of Ek / E[Ek ], as a function of k . We find that it is Θ(1/k), which gives Pr[Ek > 2 E[Ek ]] (cid:46) 1/k . This is the analog of Theorem 6.5. References [BCDH10] R. G. Baraniuk, V. Cevher, M. F. Duarte, and C. Hegde. Model-based compressive sensing. IEEE Transactions on Information Theory, 56, No. 4:1982–2001, 2010. 13 01234567Ek/(mR,Cpk)0.00.20.40.60.81.01.21.4Probability densityDistribution of Ek for various k with n=10000, R=50, C=100k=5k=10k=20k=50k=100020406080100k0.000.050.100.150.200.250.30Variance of Ek/mean(Ek)Variance of Ek as a function of k, for n=10000, R=50C=50C=100C=2000.6/k [BKM+00] A. Broder, R. Kumar, F. Maghoul, P. Raghavan, S. Ra jagopalan, R. Stata, A. Tomkins, and J. Wiener. Graph structure in the web. Comput. Netw., 33(1-6):309–320, 2000. [CCF02] M. Charikar, K. Chen, and M. Farach-Colton. Finding frequent items in data streams. ICALP, 2002. [CH10] [CM04] [CM05] [CM06] G. Cormode and M. Hadjieleftheriou. Methods for finding frequent items in data streams. The VLDB Journal, 19(1):3–20, 2010. G. Cormode and S. Muthukrishnan. Improved data stream summaries: The count-min sketch and its applications. LATIN, 2004. G. Cormode and S. Muthukrishnan. Summarizing and mining skewed data streams. In SDM, 2005. G. Cormode and S. Muthukrishnan. Combinatorial algorithms for compressed sensing. Sirocco, 2006. [CRT06] E. J. Cand`es, J. Romberg, and T. Tao. Stable signal recovery from incomplete and inaccurate measurements. Comm. Pure Appl. Math., 59(8):1208–1223, 2006. [CSN09] Aaron Clauset, Cosma Rohilla Shalizi, and Mark EJ Newman. Power-law distributions in empirical data. SIAM review, 51(4):661–703, 2009. [Gan12] Sumit Ganguly. Precision vs confidence tradeoffs for 2-based frequency estimation in data streams. In Algorithms and Computation, pages 64–74. Springer, 2012. [GI10] A. Gilbert and P. Indyk. Sparse recovery using sparse matrices. Proceedings of IEEE, 2010. [GLPS10] Anna C. Gilbert, Yi Li, Ely Porat, and Martin J. Strauss. Approximate sparse recovery: optimizing time and measurements. In STOC, pages 475–484, 2010. [HIKP12] H. Hassanieh, P. Indyk, D. Katabi, and E. Price. Simple and practical algorithm for sparse fourier transform. SODA, 2012. [IPW11] P. Indyk, E. Price, and D. Woodruff. On the power of adaptivity in sparse recovery. FOCS, 2011. [Mit04] M. Mitzenmacher. A brief history of generative models for power law and lognormal distributions. Internet Mathematics, 1:226–251, 2004. [Mut05] S. Muthukrishnan. Data streams: Algorithms and applications. Now Publishers Inc, 2005. [MV08] M. Mitzenmacher and S. Vadhan. Why simple hash functions work: exploiting the en- tropy in a data stream. In Proceedings of the nineteenth annual ACM-SIAM symposium on Discrete algorithms, pages 746–755. Society for Industrial and Applied Mathematics, 2008. [Nis92] N. Nisan. Pseudorandom generators for space-bounded computation. Combinatorica, 12(4):449–461, 1992. 14 [PDGQ05] R. Pike, S. Dorward, R. Griesemer, and S. Quinlan. Interpreting the data: Parallel analysis with sawzall. Scientific Programming, 13(4):277, 2005. [Pri11] [PW11] E. Price. Efficient sketches for the set query problem. In Proceedings of the Twenty- Second Annual ACM-SIAM Symposium on Discrete Algorithms, pages 41–56. SIAM, 2011. E. Price and D.P. Woodruff. (1+ eps)-approximate sparse recovery. In Foundations of Computer Science (FOCS), 2011 IEEE 52nd Annual Symposium on, pages 295–304. IEEE, 2011. A Proofs for Concentration of Sets In this section our aim is to prove Proposition 5.1. Our approach is to study the pairwise correlations between errors in coordinates. We do this in two parts. We first define a variant of Count-Sketch, which we call tail-independent modified (TIM) Count-Sketch. In TIM Count-Sketch, the error com- ing from collisions with small elements (the “tail error”) is replaced by independent, uniform noise. We then focus on two fixed coordinates and define a further variant, ful ly-independent modified (FIM) Count-Sketch. In FIM Count-Sketch, the errors for our two coordinates of interest are fully independent. We define these variants in such a way that unmodified, TIM, and FIM Count-Sketch can all be sampled with the same randomness, so that they may be compared simultaneously. We then bound the covariance between coordinate errors in TIM Count-Sketch by bounding the differ- ence between TIM and FIM, and use the resulting bound on the error of sets in TIM Count-Sketch to conclude a bound on unmodified Count-Sketch. As in the statement of Proposition 5.1, let S ⊂ [n] be a subset of indices with S ≤ k ; this is the set on which we will study concentration. In the first part of the argument we will work instead with S (cid:48) := S ∪ [k ], the set of interest together with the set of heavy hitters. Let C = ck be the number of columns in our sketch, for sufficiently large constant c. Let R (cid:38) log k be the number of √ √ rows, and let x be the vector we are sketching. Finally, define µ = (cid:107)xS (cid:48) (cid:107)2/ C ≤ (cid:107)x[k](cid:107)2/ C . Observation A.1. Let X be a symmetric random variable and suppose η , σ > 0 are such that, for al l  ≤ 1, Pr[X < σ ] ≥ η. (For instance, if X is a random variable to which Corol lary 3.2 applies and σ2 = E[X 2 ], then one can check that η = 1/7 suffices.) Let U be a symmetric random variable which is uniform on [−1, 1] with probability η and otherwise is ±∞. Then Pr[X < σ ] ≥ Pr[σ U < σ ] for al l . It fol lows that we can sample X and U in such a way that they always have the same sign and satisfy X ≤ σ U . sign s(i). For each column j let Tj = (cid:80) Lemma A.2. As in a row of Count-Sketch, randomly assign to each i ∈ S (cid:48) a column h(i) and a i∈S (cid:48) :h(i)=j s(i)xi . Let L be a subset of (cid:96) ≤ 2k columns. There exist i.i.d. symmetric random variables {Vj : j ∈ L} with the fol lowing properties: (i) Vj is uniform on [−µ, µ] with constant probability and otherwise is ±∞; (ii) Tj and Vj have the same sign; and (iii) Tj ≤ Vj . Proof. Let p = 2(cid:96)/C , so that for each i we have Pr[h(i) ∈ L] = 1 2 p. Recalling that C = ck for sufficiently large c, by taking c ≥ 8 we can ensure p ≤ 1/2. Consider the following alternative procedure for sampling the random variables {Tj : j ∈ L}: for each i ∈ S (cid:48) , decide with probability p if h(i) ∈ L, and if so (1) assign h(i) uniformly to one of the columns j in L and (2) add to Tj a symmetric random variable which is 0 with probability 1/2 and otherwise is ±xi . (The variables {Tj : j (cid:54)∈ L} are not computed.) In other words, for each 15 i ∈ S (cid:48) we double the probability of h(i) ∈ L, but offset that by introducing a 1/2 probability that i contributes zero. It is clear that this is equivalent to the original definition of Tj , so we henceforth work with it. Now condition on the column assignments h(i). Having done so, the variables Tj are indepen- dent. Moreover, each is a sum of independent, symmetric random variables which are 0 with prob- ability 1/2. Thus Corollary 3.2 applies. Let σj be the standard deviation of Tj and let {Uj : j ∈ L} be a set of i.i.d. random variables distributed like the variable U in Observation A.1. Then, by that observation, we can sample Tj so that Tj and Uj have the same sign and Tj ≤ σj Uj . j = (cid:80) Removing the conditioning on column assignments, the dependence between columns manifests i /2 for j ∈ L. Consider the following procedure for in the random variables σ2 i∈S (cid:48) :h(i)=j x2 sampling these variances. 1. Let q ∈ (0, 1) be the solution to the equation (1 − q)(cid:96) = 1 − p. 2. For each i ∈ S (cid:48) , determine preliminary column assignments by, for each column j ∈ L, deciding independently with probability q if i is to be placed in column j . These preliminary assignments may have repetitions and may not assign i to any column. 3. If a coordinate i is assigned to just one column, let that be h(i). If it is assigned to more than one column, then randomly choose one of those columns to be h(i). If it is assigned to j = (cid:80) no columns, then we set h(i) ∈ L, i.e., we effectively just ignore i. i∈S (cid:48) :h(i)=j x2 4. Let σ2 i /2. One can easily check that this is a valid way of sampling. The probability q is the solution to the equation log(1 − p) = (cid:96) log(1 − q); since log(1 − x) = Θ(−x) for x ≤ 1/2 it follows that Let (cid:98)σ2 q = Θ(p/(cid:96)) = Θ(1/C ). 3, i.e., had we not corrected double-assignments. Note that the random variables {(cid:98)σ2 j be the variance that would have been obtained from this procedure had we omitted step j ≤ (cid:98)σ2 j . In particular, we have Tj ≤ (cid:98)σj Uj . j } are i.i.d. j ] = (q/2) (cid:80) The random variables {(cid:98)σ2 j : j ∈ L} have expected value E[(cid:98)σ2 and they satisfy σ2 i∈S (cid:48) x2 i = Θ(µ2 ). Thus, Uj ≤  ·  (cid:38) . for any  ≤ 1, by Markov’s inequality we have Pr[(cid:98)σj Uj ≤ µ] ≥ Pr (cid:2)(cid:98)σ2 j ](cid:3) · Pr (cid:113)E[(cid:98)σ2 j < 4 E[(cid:98)σ2 µ 2 j ] Applying Observation A.1 once more, we find symmetric random variables Vj which are uniform Tj ), and which always satisfy Vj ≥ (cid:98)σj Uj ≥ Tj . These random variables have all the desired on [−µ, µ] with constant probability, which have the same sign as Ui (and thus the same sign as properties. Finally, we note that, as written, the random variables just constructed depend on (cid:96), in that q depends on (cid:96). However, we can remove this dependence by simply choosing the largest q over all (cid:96) ≤ 2k . This gives random variables which satisfy the same bounds but are agnostic about (cid:96). In a moment we will define the tail-independent modified (TIM) Count-Sketch. The main point of TIM Count-Sketch is to replace the actual contributions of the “tail” coordinates [k ] with the independent, uniform random variables in Lemma A.2. There is one additional difference, though: for later use, we invent a notion of “ghost coordinates” for TIM Count-Sketch. We do this for the following reason. In TIM Count-Sketch, when there is a collision between two coordinates in 16 S (cid:48) , we will assign them each a fixed error instead of using the tail noise. Later, when we modify TIM Count-Sketch to achieve full pairwise independence, it will be convenient to have a larger probability of using the fixed error than we get from just collisions between coordinates in S (cid:48) . The right probability for our uses lies somewhere between that which you get from considering collisions amongst S (cid:48) coordinates and that which you get from considering collisions amongst C + 1 coordinates. To achieve this intermediate probability, we fabricate C + 1 − S (cid:48) “ghosts”. These are dummy coordinates whose only purpose is to (maybe) collide with coordinates of S (cid:48) to force them to use the fixed error. To allow us to tune the probability of collision, each ghost may or may not be “real”, according to i.i.d. Bernoulli random variables. Thus the probability of a ghost colliding with a fixed coordinate i is the probability of that ghost being real times the probability that it is assigned the same column as i. We are now ready to give an actual definition. Fix a bound M > 0 (later we will take M = µ) and, for each row, compute estimates as follows. 1. Assign signs s(i) and columns h(i) to the elements of S (cid:48) . 2. Choose signs and columns for the elements of S (cid:48) and, for the columns j occupied by elements of S (cid:48) , let Tj and Vj be as in Lemma A.2. 3. Fabricate C + 1 − S (cid:48) ghost coordinates and, for each, decide independently with probability pghost if that ghost is real. Random choose a column for each ghost that is real. (The probability pghost will be chosen later.) 4. For each coordinate i ∈ S (cid:48) , (a) Let Hi be the sum of s(i)s(j )xj over all j ∈ S (cid:48) with j (cid:54)= i and h(j ) = h(i). (b) Let σ ∈ {±1} be the sign of Hi + s(i)Th(i) (which would be the error in unmodified Count-Sketch). (c) If i is in the same column as j for some j ∈ S (cid:48) , j (cid:54)= i (i.e., if the sum defining Hi is not (d) Otherwise return xi + σ · min{M , (cid:12)(cid:12)Vh(i) (cid:12)(cid:12)} as the estimate for i in this row. empty) or if i is in the same column as a ghost, then return xi + σ · M as the estimate. The final estimate for each coordinate i ∈ S (cid:48) is the median of the estimates in each row. (TIM Count-Sketch only yields estimates for the coordinates in S (cid:48) .) The tail-independence modification can only worsen errors, in the following sense. Observation A.3. Suppose a = {a1 , . . . , an} and b = {b1 , . . . , bn} are sequences such that, for each i ∈ [n], ai and bi have the same sign and satisfy either ai ≤ bi or bi ≥ M . Then median ai and median bi have the same sign and satisfy either median ai ≤ median bi or median bi ≥ M . Lemma A.4. Let (cid:98)xtim be the estimate of x using TIM Count-Sketch and let (cid:98)xum be the estimate using unmodified Count-Sketch. For any subset A ⊂ (−M , M )S which is convex and symmetric Pr[((cid:98)xum − x)S ∈ A] ≥ Pr[((cid:98)xtim − x)S ∈ A]. in each coordinate, Proof. Note that unmodified Count-Sketch can be run simultaneously with TIM Count-Sketch, using the same randomness. Consider a fixed row and a fixed coordinate i ∈ S . Keeping the notation above, the error Etim arising from TIM Count-Sketch is σ · M if there is a collision or σ · min{M , Vh(i) } if not. The error Eum arising from unmodified Count-Sketch is Hi + s(i)Th(i) . 17 Clearly Etim and Eum always have the same sign and satisfy either Eum ≤ Etim or Etim ≥ M . ((cid:98)xum − x)i ≤ ((cid:98)xtim − x)i The final errors in the estimates are medians of these row errors. Thus, by Observation A.3, or else the TIM error is at least M . In other words, given this method of sampling, whenever the error for TIM Count-Sketch is less than M we know that the error for unmodified Count-Sketch is no bigger than the error for TIM Count-Sketch. This clearly proves what we wanted. Now that we have arranged for independence of the tail contributions, the only remaining dependence arises from collisions amongst the elements of S (cid:48) . Fix two coordinates i1 , i2 ∈ S (cid:48) ; we will bound the correlation between the errors in these two coordinates. Analogously to our analysis of σj in Lemma A.2, we can highlight the dependence by first pretending collisions are independent and then correcting double-collisions. More precisely, consider the following alternative mechanism for determining collisions. 2 ] → [0, 1] denote the inverse of the monotone-increasing function p (cid:55)→ p/(1 + p). 1. Let p : [0, 1 2. For starters, declare that i1 and i2 do not collide. (This may change later in the procedure.) 3. For each element j of S (cid:48) \ {i1 , i2} (resp., each ghost) and each of i = i1 , i2 , independently decide with probability p(1/C ) (resp., p(pghost/C )) if j collides with i. Note that, because these decisions are independent, there may well be double-collisions at this stage. 4. If any ghost or coordinate in S (cid:48) collides with both i1 and i2 , then resample everything ac- cording to the correct distribution, conditioned on i1 and i2 colliding. pnc (0) = 1 (C − 1)2 · Θ and 1 − Using this procedure, the event that i1 and i2 end up not colliding is the same as the event that step 3 produced no double-collisions. The probability of this is pnc (pghost ) := Pr[i1 , i2 do not collide] = (1 − p(1/C )2 )S (cid:48) −2 (1 − p(pghost/C )2 )C+1−S (cid:48) . This is a monotone-decreasing function of pghost . Noting that p(1/C ) = 1/(C − 1), we see that (cid:18) (cid:19) (cid:18) k (cid:19)2k (cid:18) (cid:19)S (cid:48) −2 ≥ 1 − 1 (C − 1)2 C (cid:19)C−1 (cid:18) 1 − 1 (C − 1)2 pnc (1) = . By taking C to be a suitably large multiple of k we can arrange for pnc (0) to be at least 1 − 1/C . By a simple calculus exercise, pnc (1) ≤ 1 − 1/C . Thus there is a unique q ∈ [0, 1] such that pnc (q) = 1 − 1/C . We now and henceforth set pghost to this value of q . This is supposed to be an alternative, but equivalent, method for determining collisions. Before continuing, let us check that it is indeed equivalent. Our choice of pghost guaranteed that the new mechanism has the right probability of i1 and i2 colliding; moreover, when they do collide, we explicitly sample according to the correct distribution. Thus, to demonstrate equivalence, we need only to consider the case when i1 and i2 do not collide. Condition on this event and consider the (conditional) probability of some other coordinate j ∈ S (cid:48) \ {i1 , i2} colliding with i1 . Using the = 1 − 1 C 18 original sampling mechanism, this probability is 1/C . Using our alternative sampling mechanism, the probability is Pr[j collides with i1 i1 , i2 do not collide] = Pr[j collides with i1 in step 3 there are no double-collisions in step 3]. The event that there is no double-collision is the intersection of independent events for each element of S (cid:48) \ {i1 , i2} and for each ghost. Of these constituent events, only one is relevant to the conditional probability we want to compute: the event that j does not double-collide. Thus our probability is Pr[j collides with i1 in step 3 j does not collide with both i1 and i2 in step 3] p(1/C ) − p(1/C )2 p(1/C ) 1 1 − p(1/C )2 1 + p(1/C ) C = = = , which is what we wanted. One can similarly check that the probability of a ghost collision is correct. Thus, as claimed, our new scheme is a valid way to sample the collision events. We can now define our last variant of Count-Sketch, fully-independent modified (FIM) Count- Sketch. This only produces estimates for the two coordinates i1 and i2 . For each row, the FIM estimate is computed as follows. We always specify that i1 and i2 will not collide. To determine which elements of S (cid:48) \{i1 , i2} and which ghosts collide with i1 and i2 , we use (1–3) of the “alternative mechanism” above. We omit step 4, so that a given coordinate may collide with both i1 and i2 . Then, for each i ∈ {i1 , i2} and for each coordinate colliding with i, we choose a random sign. (In particular, if some coordinate is supposed to collide with both i1 and i2 , then it is associated with two different, independent random signs.) Using these collision and sign data, we proceed as in (4a–4d) of the description of TIM Count-Sketch to get a row estimate. As always, the final estimate is the median of the row estimates. In each row, the estimates for i1 and i2 produced by FIM Count-Sketch are independent; thus the final estimates are also independent. FIM and, to a lesser extent, TIM Count-Sketch are quite a bit different from unmodified Count- Sketch. However, for a single coordinate they preserve many of the salient features. In particular, all of the properties used in the proof of Theorem 4.1 still hold: rows are independent, the errors in each row are symmetric, and in each row we have (i) with constant probability, there is no collision with [k ] and (ii) the error arising from collisions with [k ] satisfies the bound of Corollary 3.2. Thus, Lemma A.5. Fix i ∈ {i1 , i2} and consider the estimates ((cid:98)xtim )i and ((cid:98)xfim )i of xi from TIM and with the same proof as Theorem 4.1, we have the following bounds. (cid:34) (cid:35) (cid:34) (cid:35) FIM Count-Sketch, respectively. For any t ≤ R we have (((cid:98)xfim )i − xi )2 > (((cid:98)xtim )i − xi )2 > (cid:107)x[k](cid:107)2 (cid:107)x[k](cid:107)2 · < 2e−Ω(t) t t 2 2 and Pr k k R R E[(((cid:98)xtim )i − xi )2 ] (cid:46) µ2 E[(((cid:98)xtim )i − xi )4 ] (cid:46) µ4 Corollary A.6. Suppose M = Θ(µ). Then , , and E[(((cid:98)xfim )i − xi )4 ] (cid:46) µ4 E[(((cid:98)xfim )i − xi )2 ] (cid:46) µ2 R2 R R2 R We can recover TIM Count-Sketch from FIM Count-Sketch by resampling some of the rows. More specifically, we take any row in which some ghost or some element of S (cid:48) collides with both i1 < 2e−Ω(t) . Pr · . , 19 and i2 and resample that row, conditioning on i1 and i2 colliding with each other. The errors for both i1 and i2 in any such row are M in magnitude both before and after resampling. Moreover, for a fixed coordinate i ∈ {i1 , i2} the signs of the errors before and after resampling are independent and uniform. (Note: the signs of the errors for i1 and i2 after resampling are not necessarily Let (cid:98)xfim be the estimate computed by FIM Count-Sketch and let (cid:98)xtim be the result of TIM Count-Sketch, recovered from FIM Count-Sketch as above. Let (cid:101)R be the number of rows that have independent of each other. We assume nothing about their dependence in our argument.) to be resampled to recover TIM Count-Sketch from FIM Count-Sketch. Focusing for the moment and Etim = ((cid:98)xtim − x)i1 . Efim = ((cid:98)xfim − x)i1 on i1 , define the errors We expect (cid:101)R to be reasonably small, and thus we expect the change in moving from FIM to TIM to be small. In particular, we expect Efim and Etim to be close. More specifically, we shall prove the following proposition. . fim )2 ] (cid:46) M 4 tim − E 2 Proposition A.7. Suppose M = Θ(µ). Then E[(E 2 R2k1/7 Since we just want to bound the expected value of a bounded random variable, small probability events can be ignored. Indeed, in general, if X is a random variable bounded by B and E is an event with probability p, then E[X ] = p E[X E ] + (1 − p) E[X E ] ≤ pB + E[X E ]. Thus if we aim to prove E[X ] (cid:46) Y and we know pB (cid:46) Y , then it suffices to prove E[X E ] (cid:46) Y . Specializing to our case, because Efim , Etim ≤ M always holds, this demonstrates that in order to prove Proposition A.7, we may condition away from events that occur with probability O(R−2k−1/7 ). We will refer to such events as “ignorable” and, as the name indicates, freely ignore them. Lemma A.8. If k ≥ R7/2 then Proposition A.7 holds. (cid:18) (cid:19) (cid:18) R (cid:19)R Proof. The probability that a single row is not resampled is pnc = 1 − 1/C , and so Pr[ (cid:101)R = 0] = 1 − 1 = exp(R log(1 − 1/C )) = exp(−RΘ(1/C )) = 1 − Θ . Because C = Ω(k) and k ≥ R7/2 , R/C (cid:46) R/k (cid:46) R−2k−1/7 . Thus (cid:101)R > 0 is an ignorable event. But C C of course if (cid:101)R = 0 then (cid:98)xfim = (cid:98)xtim . This gives the desired bound. Observation A.9. Let a, b, c > 0 be arbitrary. Any event that occurs with probability exp(−Ω(Rbkc )) is ignorable. Moreover, if we suppose that k ≤ Ra , then any event that occurs with probability Lemma A.10. Suppose k ≤ R7/2 . Then, except for ignorable events, (cid:101)R < R/k1/5 . exp(−Ω(Rb )) is ignorable. Proof. Each row is resampled with probability 1/C , and the resampling events for the R rows are independent. Thus, by the Chernoff bound Pr[X ≥ (1 + ) E[X ]] ≤ exp(− E[X ]2/(2 + )) (applied (cid:20) (cid:101)R ≥ R (cid:21) with  = C/k1/5 , which in particular can be taken to be arbitrarily large), ≤ exp(−Ω(R/k1/5 )) = exp(−Ω(R3/10 )). k1/5 This is ignorable by Observation A.9. Pr 20 and so Ce1 ,...,em pm . Ce1 ,...,em E[Y e1 ] · · · E[Y em ], E[(X − N p)r ] = E[(Y1 + · · · + YN )r ] = Let (cid:101)R+ , (cid:101)R0 , (cid:101)R− be the number of rows resampled in which the error increases from −M to M , stays the same, and decreases with M to −M , respectively. Thus (cid:101)R+ + (cid:101)R0 + (cid:101)R− = (cid:101)R. The net effect of resampling is measured by (cid:98)R := (cid:101)R+ − (cid:101)R− . Lemma A.11. Fix a positive integer r. If X is an (N , p) binomial random variable with N p ≥ 1, then E[(X − N p)r ] (cid:46) (N p)r/2 (where the implied constant depends on r). Proof. Let Y be a random variable with Pr[Y = 1 − p] = p and Pr[Y = −p] = 1 − p, and let X − N p = Y1 + · · · + YN where Y1 , . . . , YN are i.i.d. with the same distribution as Y . Then (cid:88) min{r,N }(cid:88) (cid:80) ei=r e1≥···≥em≥1 m=1 where the coefficient Ce1 ,...,em counts the number of ways to choose an r-tuple of elements of an We have E[Y ] = 0, so the terms with ei = 1 (for any i) all vanish. Since (cid:80)m N -element set such that the most common element occurs e1 times, the next most common element occurs e2 times, and so on. i=1 ei = r, this leaves just the terms with m ≤ r/2. Now for any e ≥ 2, we have E[Y e ] = p(1 − p)e + (1 − p)(−p)e ≤ p(1 − p)2 + (1 − p)p2 = p(1 − p) ≤ p, min{r/2,N }(cid:88) (cid:88) (cid:80) ei=r e1≥···≥em≥2 m=1 Now we can compute Ce1 ,...,em by first choosing which m of the N elements occur and then choosing how to arrange them. The number of choices for the former is clearly bounded by N m (cid:46) N m . and the number of choices for the latter is bounded by a function of r only. Thus Ce1 ,...,em Moreover, the number of terms in the second summation is bounded by a function of r only. This min{r/2,N }(cid:88) leaves us with E[(X − N p)r ] (cid:46) N mpm . m=1 Given that N p ≥ 1, the last term in the summation is dominant, giving the desired bound. Lemma A.12. Suppose k ≤ R7/2 . Conditioning away from ignorable events, E[ (cid:98)R4 ] (cid:46) R2/k2/5 . Proof. By reducing (cid:101)R, we may assume without loss of generality that (cid:98)R0 = 0. Thus (cid:98)R is just the value of a discrete random walk of length (cid:101)R. By Lemma A.11 the fourth moment of such a random walk is O( (cid:101)R2 ). Combining this with Lemma A.10 gives the desired bound. then conditioning on the value of (cid:98)R, E[(Etim − Efim )4 ] (cid:46) (M (cid:98)R/R)4 . Lemma A.13. Suppose k ≤ R7/2 and M = Θ(µ). Conditioning away from ignorable events and Proof. First, suppose (cid:98)R = 0. In this case Efim = Etim , so the desired bound holds because both sides are 0. Thus we may suppose (cid:98)R (cid:54)= 0; moreover, by symmetry we may assume (cid:98)R > 0. In this case we have Etim ∈ [Efim , M ]. By Lemma A.5 we see that Pr[Efim > M /2] < e−Ω(R) ; thus, by Observation A.9, the corre- sponding event is ignorable. For the remainder of the proof, assume that it does not happen. E[(X − N p)r ] ≤ 21 Condition for a moment on both the value of Efim and on the set of R/2 rows in which the error for FIM Count-Sketch is above the median. Pick one such row r and consider its error Er . Before the conditioning, using the assumption M = Θ(µ), the distribution for Er consisted of atoms at ±M and Ω(1) probability of being uniform in [−M , M ]. The net effect of our conditioning is to simply condition on Er ≥ Efim . (By conditioning first on r having above-median error, we removed the nontrivial dependence between Efim and Er .) In particular, with Ω(1) probability, Er ∈ [Efim , M ). (And, when this occurs, Er is uniform in that interval.) Applying a Chernoff bound to the R/2 such rows, we see that, with probability 1 − e−Ω(R) , there are Ω(R) rows in which the error lies in (Note that the ignorable events we just conditioned away influence (cid:98)R. We conditioned on them [Efim , M ). Since the failure probability is ignorable, we henceforth assume that this holds. Fix t > 0 and consider the event Et := {Etim > Efim + tM (cid:98)R/R}. Since the difference between TIM and FIM Count-Sketch is just replacing (cid:98)R rows with error −M by rows with error +M , this first to remove that dependence.) event is equivalent to FIM Count-Sketch having fewer than (cid:98)R rows in which the error is in the interval I = [Efim , Efim + tM (cid:98)R/R]. Given the above discussion, there are Ω(R) rows in which the probability of the error lying in that interval is Ω(t (cid:98)R/R). More explicitly, for some constants a and b, there are N := aR rows in which the probability of the error lying in I is (at least) p := bt (cid:98)R/R. particular this implies N p > (cid:98)R ≥ 1, whence the 10th moment of X is O((N p)5 ) by Lemma A.11. Let X be the total number of such rows. Then X is a (N , p) binomial random variable. For It also implies that (cid:98)R < E[X ] = abt (cid:98)R. Thus, by Markov’s inequality, `a la Chebyshev’s inequality, t > t0 := 1/(ab) (i.e., for all t larger than a sufficiently large constant), we have abt > 1. In Pr[Et ] = Pr[X < (cid:98)R] ≤ E[(X − abt (cid:98)R)10 ] (abt (cid:98)R)5 (cid:98)R10 (abt − 1)10 (cid:98)R10 (abt − 1)10 ≤ (abt)5 (cid:46) (abt − 1)10 . For, say, t ≥ 2t0 , this is asymptotically (cid:46) t−5 . (cid:33)4 (cid:32) (cid:90) ∞ M (cid:98)R Using integration by parts, 4t3 · Pr[Et ] dt. E[(Etim − Efim )4 ] = R (cid:90) ∞ (cid:90) 2t0 (cid:90) ∞ 0 Writing the first term is O(1) because t0 is a constant. The second is (cid:46) (cid:82) ∞ 4t3 · Pr[Et ] dt, 4t3 · Pr[Et ] dt + 4t3 · Pr[Et ] dt = 2t0 0 0 t−2 dt, which is also O(1). (cid:33)4 (cid:32) M (cid:98)R 2t0 Thus, as desired, E[(Etim − Efim )4 ] (cid:46) R · . We are now ready to complete the Proof of Proposition A.7. After Lemma A.8 it only remains to handle the case k ≤ R7/2 . Combin- ing Lemmas A.12 and A.13, we have E[(Etim − Efim )4 ] (cid:46) M 4/(R2k2/5 ). Applying Lemma A.5 and the union bound, we see that E[(Etim + Efim )4 ] (cid:46) M 4/R2 . Thus, ≤ (cid:112)E[(Etim − Efim )4 ] E[(Etim + Efim )4 ] tim − E 2 fim )2 ] = E[(Etim − Efim )2 (Etim + Efim )2 ] E[(E 2 (cid:46) M 4 , R2k1/5 22 which gives the desired bound a fortiori. Proposition 5.1. Fix a constant t > 0 and consider the estimate (cid:98)x of x from Count-Sketch using Using these lemmata, we can finally prove the desired result. R rows and C = ck columns, log k (cid:46) R, for sufficiently large (depending on t) constant c. For any (cid:34) (cid:35) set S ⊂ [n] with S ≤ k , (cid:107)(cid:98)xS − xS (cid:107)2 2 > t · S · 1 R Proof. Throughout we condition on the error for each coordinate in S being less than µ. By Theorem 4.1 and a union bound, this occurs with probability 1 − S e−Ω(R) = 1 − k−Ω(1) , so this conditioning can be absorbed into the final bound. In addition to unmodified Count-Sketch, consider running TIM Count-Sketch with M = µ. (cid:40) (cid:41) Define the convex, coordinate-wise symmetric set 2 ≤ t · S · 1 v ∈ (−µ, µ)S : (cid:107)v(cid:107)2 R (cid:46) 1 S 1/14 (cid:107)x[k](cid:107)2 2 k (cid:107)x[k](cid:107)2 2 k A = Pr · . · . Pr S µ2 R Applying Lemma A.4 with this set A shows that unmodified Count-Sketch has at least as high of probability bound for the TIM estimate (cid:98)xtim . 2 = (cid:80) a probability of its error lying in A as TIM Count-Sketch. Thus it suffices to prove the asserted tim,i , where Etim,i := ((cid:98)xtim − x)i . By The error we are studying is (cid:107)((cid:98)xtim − x)S (cid:107)2 i∈S E 2 tim,i ] ≤ aµ2/R for some constant a > 0. Now, by Chebyshev’s inequality, we Corollary A.6, E[E 2 (cid:20) (cid:21) (cid:20) (cid:21) have (cid:107)((cid:98)xtim − x)S (cid:107)2 2 − E[(cid:107)((cid:98)xtim − x)S (cid:107)2 (cid:107)((cid:98)xtim − x)S (cid:107)2 2 > (a + 1) · S µ2 ≤ Pr ≤ Var((cid:107)((cid:98)xtim − x)S (cid:107)2 2 ] > R 2 ) (S µ2/R)2 . (cid:88) (cid:88) Var((cid:107)((cid:98)xtim − x)S (cid:107)2 Thus we need to bound 2 ) = i∈S i1 (cid:54)=i2∈S tim,i ) ≤ E[E 4 tim,i ] (cid:46) µ4/R2 by Corollary A.6. The covariance term is For each i we have Var(E 2 the harder part to control. Fix two coordinates i1 (cid:54)= i2 ∈ S and consider FIM Count-Sketch Efim,j = ((cid:98)xfim − x)ij . Then with respect to those two coordinates. For shorthand write Etim,j for Etim,ij (j = 1, 2) and define fim,1 , E 2 tim,2 ) = Cov(E 2 tim,1 , E 2 Cov(E 2 fim,2 ) tim,2 − E 2 tim,1 − E 2 fim,2 ) + Cov(E 2 + Cov(E 2 fim,2 , E 2 fim,1 , E 2 fim,1 ) tim,1 − E 2 tim,2 − E 2 + Cov(E 2 fim,1 , E 2 The first term vanishes because, by construction, ((cid:98)xfim )i1 and ((cid:98)xfim )i2 are independent. We shall fim,2 ). bound the remaining terms using the Cauchy-Schwarz inequality Cov(X, Y ) ≤ (cid:112)Var(X ) Var(Y ). Cov(E 2 tim,i1 , E 2 tim,i2 ). Var(E 2 tim,i ) + (7) (8) 23 fim,j ) ≤ E[E 4 tim,j − fim,j ] (cid:46) µ4/R2 . By Proposition A.7, Var(E 2 By Corollary A.6 we have Var(E 2 fim,j ) (cid:46) µ4/(R2k1/7 ). Thus E 2 tim,2 ) (cid:46) 2 · tim,1 , E 2 Cov(E 2 µ4 R2k1/14 + µ4 R2k1/7 (cid:46) µ4 R2k1/14 . Substituting back into (8), Var((cid:107)((cid:98)xtim − x)S (cid:107)2 2 ) (cid:46) S · µ4 R2 + S (S − 1) · And finally, substituting this into (7), we get the desired bound. µ4 R2k1/14 14 · µ4 (cid:46) S 2− 1 R2 . 24
1809.03685
2
1809
2018-09-14T23:41:03
Massively Parallel Dynamic Programming on Trees
[ "cs.DS" ]
Dynamic programming is a powerful technique that is, unfortunately, often inherently sequential. That is, there exists no unified method to parallelize algorithms that use dynamic programming. In this paper, we attempt to address this issue in the Massively Parallel Computations (MPC) model which is a popular abstraction of MapReduce-like paradigms. Our main result is an algorithmic framework to adapt a large family of dynamic programs defined over trees. We introduce two classes of graph problems that admit dynamic programming solutions on trees. We refer to them as "(polylog)-expressible" and "linear-expressible" problems. We show that both classes can be parallelized in $O(\log n)$ rounds using a sublinear number of machines and a sublinear memory per machine. To achieve this result, we introduce a series of techniques that can be plugged together. To illustrate the generality of our framework, we implement in $O(\log n)$ rounds of MPC, the dynamic programming solution of graph problems such as minimum bisection, $k$-spanning tree, maximum independent set, longest path, etc., when the input graph is a tree.
cs.DS
cs
Massively Parallel Dynamic Programming on Trees∗ Mahsa Derakhshan‡ MohammadHossein Bateni† Soheil Behnezhad‡ MohammadTaghi Hajiaghayi‡ Vahab Mirrokni† Abstract Dynamic programming is a powerful technique that is, unfortunately, often inherently se- quential. That is, there exists no unified method to parallelize algorithms that use dynamic programming. In this paper, we attempt to address this issue in the Massively Parallel Compu- tations (MPC) model which is a popular abstraction of MapReduce-like paradigms. Our main result is an algorithmic framework to adapt a large family of dynamic programs defined over trees. We introduce two classes of graph problems that admit dynamic programming solutions on trees. We refer to them as "(poly log)-expressible" and "linear-expressible" problems. We show that both classes can be parallelized in O(log n) rounds using a sublinear number of machines and a sublinear memory per machine. To achieve this result, we introduce a series of techniques that can be plugged together. To illustrate the generality of our framework, we implement in O(log n) rounds of MPC, the dynamic programming solution of graph problems such as minimum bisection, k-spanning tree, maximum independent set, longest path, etc., when the input graph is a tree. 8 1 0 2 p e S 4 1 ] S D . s c [ 2 v 5 8 6 3 0 . 9 0 8 1 : v i X r a ∗This is the full version of a paper [8] appeared at ICALP 2018. †Google Research, New York. Email: {bateni,mirrokni}@google.com. ‡Department of Computer Science, University of Maryland. Email: {soheil,mahsaa,hajiagha}@cs.umd.edu. Supported in part by NSF CAREER award CCF-1053605, NSF BIGDATA grant IIS-1546108, NSF AF:Medium grant CCF-1161365, DARPA GRAPHS/AFOSR grant FA9550-12-1-0423, and another DARPA SIMPLEX grant. 1 1 Introduction With the inevitable growth of the size of datasets to analyze, the rapid advance of distributed computing infrastructure and platforms (such as MapReduce, Spark [45], Hadoop [44], Flume [19], etc.), and more importantly the availability of such infrastructure to medium- and even small-scale enterprises via services at Amazon Cloud and Google Cloud, the need for developing better dis- tributed algorithms is felt far and wide nowadays. The past decade has seen a lot of progress in studying important computer science problems in the large-scale setting, which led to either adapt- ing the sequential algorithms to distributed settings or at times designing from scratch distributed algorithms for these problems [3, 4, 17, 21, 18]. Despite this trend, we still have limited theoretical understanding of the status of several fun- damental problems when it comes to designing large-scale algorithms. In fact, even simple and widely used techniques such as the greedy approach or dynamic programming seem to suffer from an inherent sequentiality that makes them difficult to adapt in parallel or distributed settings on the aforementioned platforms. Finding methods to run generic greedy algorithms or dynamic pro- gramming algorithms on MapReduce, for instance, has broad applications. This is the main goal of this paper. Model. We consider the most restrictive variant of the Massively Parallel Computations (MPC) model which is a common abstraction of MapReduce-like frameworks [31, 26, 10]. Let n denote the input size and let m denote the number of available machines which is given in the input.1 At each round, every machine can use a space of size s = (cid:101)O(n/m) and run an algorithm that is preferably linear time (but at most polynomial time) in the size of its memory.2 Machines may only communicate between the rounds, and no machine can receive or send more data than its memory. Im, Moseley, and Sun [29] initiated a principled framework for simulating sequential dynamic programming solutions of Optimal Binary Search Tree, Longest Increasing Subsequence, and Weighted Interval Selection problems on this model. This is quite an exciting development, however, it is not clear whether similar ideas can be extended to other problems and in particular to natural and well-known graph problems. In this paper, we give an algorithmic framework that could be used to simulate many natural dynamic programs on trees. Indeed we formulate the properties that make a dynamic program (on trees) amenable to our techniques. These properties, we show, are natural and are satisfied by many known algorithms for fundamental optimization problems. To illustrate the generality of our framework, we design O(log n) round algorithms for well-studied graph problems on trees, such as, minimum bisection, minimum k-spanning tree, maximum weighted matching, longest path, minimum vertex cover, maximum independent set, facility location, k-center, etc. 1.1 Related Work Though so far several models for MapReduce have been introduced (see, e.g., [22, 4, 25, 26, 30, 38, 40]), Karloff, Suri, and Vassilvitskii [31] were the first to present a refined and simple theoretical model for MapReduce. In their model, Karloff et al. [31] extract only key features of MapReduce and bypass several message-passing systems and parameters. This model has been extended since greater than nδ. 1As standard, we assume there exists a small constant 0 < δ < 1 for which the number of machines is always 2We assume that the available space on each machine is more than the number of machines (i.e., m ≤ s and hence √ m = O( n)). It is argued in [4] that this is a realistic assumption since each machine needs to have at least the index of all the other machines to be able to communicate with them. Also, as argued in [29], in some cases, it is natural to assume the total memory is (cid:101)O(n1+) for a small 0 <  < 1. 2 then [10, 4, 40] (in this paper we mainly use the further refined model by Andoni, Nikolov, Onak, and Yaroslavtsev [4]) and several algorithms both in theory and practice have been developed in these settings, often using sketching [27, 30], coresets [9, 35] and sample-and-prune [32] techniques. Examples of such algorithms include k-means and k-center clustering [6, 9, 28], general submodular function optimization [20, 32, 36] and query optimization [10]. Thanks to their common application to data mining tasks, MapReduce algorithms on graphs have received a lot of attention. In [33] Lattanzi, Moseley, Suri and Vassilvitskii, propose algorithms for several problems on dense graphs. Subsequently other authors study graph problems in the MapReduce model [3, 2, 5, 16, 34, 7, 11, 12] but almost all the solutions apply only to dense graphs. In contrast in this paper we present a framework to solve optimization problems on trees, which are important special cases of sparse graphs. Another related area of research is the design of parallel algorithms. Parallel, and in particular PRAM algorithms, instead of distributing the work-load into different machines, assume a shared memory is accessible to several processors of the same machine. The MPC model is more powerful since it combines parallelism with sequentiality. That is, the internal computation of the machines is free and we only optimize the rounds of communication. In this work, we use this advantage in a crucial way to design a unified and general framework to implement a large family of sequential dynamic programs on MPC. We are not aware of any similar framework to parallelize dynamic programs in the purely parallel settings. Further developments. A remarkable series of subsequent works [14, 24, 37, 15, 13] to this paper show how to design even sublogarithmic round algorithms for graph problems such as maximal matching, maximal independent set, approximate vertex cover, etc., using n1−Ω(1) memory per- machine. This is precisely the regime of parameters considered in this paper. However, these problems mostly enjoy a locality property (i.e., they admit fast LOCAL algorithms) that does not hold for the problems considered in this paper. 1.2 Organization We start with an overview of our results and techniques in Section 2. We give a formalization of dynamic programming classes in Section 3. Then, we describe a main building block of our algorithms, the tree decomposition method, in Section 4. Next, in Section 5, we show how to solve a particular class of problems which we call (poly log)-expressible problems. In Section 6 we show how to solve a more general class of problems, namely, linear-expressible problems. 2 Main Results & Techniques We introduce a class of dynamic programming problems which we call f -expressible problems. Here, f is a function and we get classes such as (poly log)-expressible problems or linear-expressible prob- lems. Hiding a number of technical details, the function f equals the number of bits of information that each node of the tree passes to its parent during the dynamic program. Thus, linear-expressible problems are generally harder to adapt to the MPC model than (poly log)-expressible problems. (poly log)-Expressible problems. Many natural problems can be shown to be (poly log)-expressible. For example, the following graph problems are all (poly log)-expressible if defined on trees: maxi- mum (weighted) matching, vertex cover, maximum independent set, dominating set, longest path, etc. Intuitively, the dynamic programming solution of each of these problems, for any vertex v, 3 computes at most a constant number of values. Our first result is to show that every (poly log)- expressible problem can be efficiently3 solved in MPC. As a corollary of that, all the aforementioned problems can be solved efficiently on trees using the optimal total space of (cid:101)O(n). machine uses a space of size at most (cid:101)O(n/m) and runs an algorithm that is linear in its input Theorem 1. For any given m, there exists an algorithm to solve any (poly log)-expressible problem in O(log n) rounds of MPC using m machines, such that with high probability each size. Proof sketch. The first problem in solving dynamic programs on trees is that there is no guar- antee on the depth of the tree. If the given tree has only logarithmic depth one can obtain a logarithmic round algorithm by simulating a bottom-up dynamic program in parallel, where nodes at the same level are handled in the same round simultaneously. This is reminiscent of certain parallel algorithms whose number of rounds depends on the diameter of the graph. Unfortunately the input tree might be quite unbalanced, with superlogarithmic depth. An extreme case is a path of length n. In this case we can partition the path into equal pieces (despite not knowing a priori the depth of each particular node), handling each piece independently, and then stitching the results together. Complications arise, because the subproblems are not completely independent. Things become more nuanced when the input tree is not simply a path. decomposes the tree into pieces of size at most (cid:101)O(m) (i.e., we can fit each component completely To resolve this issue, we adapt a celebrated tree contraction method to our model. The algorithm on one machine), with small interdependence. Omitting minor technical details, the latter property allows us to almost independently solve the subproblems on different machines. This results in a partial solution that is significantly smaller than the whole subtree; therefore, we can send all these partial solutions to a master machine in the next round and merge them. Linear-Expressible problems. Although many natural problems are indeed (poly log)-expressible, there are instances that are not. Consider for example the minimum bisection problem. In this problem, given an edge-weighted tree, the goal is to assign two colors (blue and red) to the vertices in such a way that minimizes the total weight of the edges between blue vertices and red vertices while half of the vertices are colored red and the other half are blue. In the natural dynamic programming solution of this problem, for a subtree T of size nT , we store O(nT ) different values. That is, for any i ∈ [nT ], the dynamic program stores the weight of the optimal coloring that assigns blue to i vertices and red to the rest of nT − i vertices. This problem is not necessarily (poly log)-expressible unless we find another problem specific dynamic programming solution for it. However, it can be shown that minimum bisection, as well as many other natural problems, including k-spanning-tree, k-center, k-median, etc., are linear-expressible. It is notoriously more difficult to solve linear-expressible problems using a sublinear number of machines and a sublinear memory per machine. However, we show that it is still possible to obtain the same result using a more involved algorithm and a slightly more total memory. Theorem 2 (Main Result). For any given m, there exists an algorithm to solve any linear- expressible problem that is splittable in O(log n) rounds of MPC using m machines, such that with high probability each machine uses a space of size (cid:101)O(n4/3/m). 3Here and throughout the paper, we consider a polylogarithmic round algorithm efficient. 4 Proof sketch. Recall that linear-expressibility implies that the dynamic programming data on each node, can be as large as the size of its subtree (i.e., even up to O(n)). Therefore, even by using the tree decomposition technique, the partial solution that is computed for each component of the tree can be linear in its size. This means that the idea of sending all these partial data to one master machine, which worked for (poly log)-expressible problems, does not work here since when aggregated, they take as much space as the original input. Therefore we have to distribute the merging step among the machines. Assume for now that each component that is obtained by the tree decomposition algorithm is contracted into a node and call this contracted tree. The tree decomposition algorithm has no guarantee on the depth of the contracted tree and it can be super-logarithmic; therefore a simple bottom-up merging procedure does not work. However, it is guaranteed that the contracted tree itself (i.e., when the components are contracted) can be stored in one machine. Using this, we send the contracted tree to a machine and design a merging schedule that informs each component about the round at which it has to be merged with each of its neighbours. The merging schedule ensures that after O(log n) phases, all the components are merged together. The merging schedule also guarantees that the number of neighbours of the components, after any number of merging phases, remains constant. This is essential to allow (almost) independent merging for many linear- expressible problems such as minimum bisection. Observe that after a few rounds, the merged components grow to have up to Ω(n) nodes and even the partial data of one component cannot be stored in one machine. Therefore, even merging the partial data of two components has to be distributed among the machines. For this to be possible, we use a splitting technique of independent interest that requires a further splittability property on linear-expressible problems. Indeed we show that the aforementioned linear-expressible problems, such as minimum bisection and k-spanning tree, have the splittability property, and therefore Theorem 2 implies they can also be solved in O(log n) rounds of MPC. 3 Dynamic Programming Classes To understand the complexity of different dynamic programs in the MPC model, we first attempt to classify these problems. The goal of this section is to introduce a class of problems which we call f -expressible problems. We say a problem P is defined on trees, if the input to P is a rooted tree T , where each vertex v of T may contain data of size up to poly(log n), denoted by v.data.4 Dynamic programming is effective when the solution to the problem can be computed recur- sively. On trees, the recursion is usually defined on the nodes of the tree, where each node computes its data using the data provided by its children. Let DP denote a dynamic program that solves a problem P that is defined on trees. Also let PT be an instance of P and denote its input by T . We use DP (T ) to denote the solution of PT and use DP (v) to denote the dynamic data that DP computes for a vertex v of T . The first property that we define is "binary adaptability". Binary Adaptability. To illustrate when this property holds, consider any vertex v of an in- put tree and a given ordering of its children (u1, u2, . . . , uk) and let D(u) denote the dynamic data of vertex u. As long as the operation to compute the dynamic data of v could be viewed as an aggregation of binary operations over the dynamic data that is provided by its children 4Consider weighted trees as an example of the problems that define an additional data on the nodes (in case the edges are weighted, each vertex stores the weight of its edge to its parent). 5 in the given order, i.e., D(v) = f1(D(u1), f2(D(u2), . . .)), this property is satisfied. (For exam- ple, max{D(u1),D(u2),D(u3)} could be viewed as max{D(u1), max{D(u2),D(u3)}}). Most of the natural dynamic programs satisfy this property. To formally state this property, we first define "binary extensions" of trees and then define a problem to be binary adaptable if there exists a dynamic programming solution that given any binary extension of an input, calculates the solution of the original tree. Definition 3.1 (Binary Extension). A binary tree T b is a binary extension of a tree T if there is a one-to-one (and not necessarily surjective) mapping f : V (T ) → V (T b) such that f (v) is an ancestor of f (u) in T b if v is an ancestor of u in T . We assume the data of each vertex v in T is also stored in its equivalent vertex, f (v) in T b. Intuitively, a binary extension of a tree T is a binary tree that is obtained by adding auxiliary vertices to T in such a way that ensures any ancestor of each vertex remains its ancestor. Definition 3.2 (Binary Adaptability). Let P be a problem that is defined on trees. Problem P is binary adaptable if there exists a dynamic program DP where for any instance PT of P with T as its input tree and for any binary extension T b of T , the output of DP (T b) is a solution of PT . We say DP is a binary adapted dynamic program for P . We are now ready to define f -expressiveness. We will mainly consider (poly log)-expressible and linear-expressible problems in this paper, however the definition is general. f -Expressiveness. This property is defined on the problems that are binary adaptable. Roughly speaking, it specifies how large the data that we store for each subtree should be to be able to merge subtrees efficiently. Definition 3.3 (f -Expressiveness). Let P be a binary adaptable problem and let DP be its binary adapted dynamic program. Moreover, let T b be a binary extension of a given input to P . For a function f , we say P is f -expressible if the following conditions hold. 1. The dynamic data of any given vertex v of T b has size at most (cid:101)O(f (nv)) where nv denotes the number of descendants of v. 2. There exist two algorithms C (compressor), and M (merger) with the following properties. Consider any arbitrary connected subtree T of T b and let v denote the root vertex of T . If for at most a constant number of the leaves of T the dynamic data is unknown (call them the unknown leaves of T ), algorithm C returns a partial data of size at most (cid:101)O(f (nT )) for T (without knowing the dynamic data of the unknown leaves) in time poly(f (nT )) such that if this partial data and the dynamic data of the unknown leaves are given to M, it returns DP (v) in time poly(f (nT )). 3. For two disjoint subtrees T1 and T2 that are connected to each other with one edge, and for subtree T = T1 + T2, if there are at most a constant number of the leaves of T that are unknown, then M(C(T1),C(T2)) returns C(T ) in time poly(f (nT )). We remark that graph problems such as maximum (weighted) matching, vertex cover, maxi- mum independent set, dominating set, longest path, etc., when defined on trees, are all (poly log)- expressible. Also, problems such as minimum bisection, k-spanning tree, k-center, and k-median are linear-expressible on trees. 6 4 Tree Decomposition The goal of this section is to design an algorithm to decompose a given tree T with n vertices into O(m) "components" of size at most (cid:101)O(n/m), such that each component has at most a constant number of "outer edges" to the other components. To do this, we combine a tree contraction (see [39, 1, 23]) method of traditional parallel algorithms with a number of new ideas. Overview. To motivate the need to design an involved decomposition algorithm, we first give hints on why trivial approaches do not work. Perhaps the simplest algorithm that comes to mind for this task, is random sampling. That is, to choose a set of randomly selected edges (or vertices) and temporarily remove them so that the tree is decomposed into a number of smaller components. Note that the main difficulty is that we need to bound the size of the largest component with a high probability. It could be shown that this trivial algorithm, even for the simple case of full binary trees fails. More precisely, it could be shown that the size of the component that contains the root is of size Ω(n) (instead of (cid:101)O(n/m)) with a constant probability. In general, naive random partitioning does not perform well. In contrast, we employ the following algorithm. First, we convert the tree into a binary tree. To do this, we first have to compute the degree of each vertex and then add auxiliary vertices to the graph. After that, our algorithm proceeds in iterations (not rounds). In each iteration, we merge the vertices of the tree based on some local rules and after O(log n) iterations, we achieve the desired decomposition. More precisely, in each iteration, we select a set of joint vertices according to a number of local rules (e.g., the degree of a vertex, status of its parent, etc.) and merge each vertex to its closest selected ancestor. We prove in fact these local rules guarantee that the size of The input, as mentioned before, is a rooted tree T , with n vertices numbered from 1 to n (we call these numbers the indexes of the vertices).5 Each machine initially receives a subset of size the maximum component is bounded by (cid:101)O(n/m) with high probability. (cid:101)O(n/m) of the vertices of T where each vertex object v contains the index of v, denoted by v.index, and the index of its parent, denoted by v.parent. In Section 4.1 we show how universal hash functions allow us to efficiently distribute and access objects in our model. In Section 4.2 we introduce an algorithm to convert the given tree into a "binary-extension" of it. Finally, in Section 4.3 we provide an algorithm to decompose the binary extension. 4.1 Load Balancing via Universal Hash Families We start with the definition of universal hash families, that was first proposed by [43]. Definition 4.1. A family of hash functions H = {h : A → B} is k-universal if for any hash function h that is chosen uniformly at random from H and for any k distinct keys (a1, a2, . . . , ak) ∈ Ak, random variables h(a1), h(a2), . . . , h(ak) are independent and uniformly distributed in B. A k- universal hash function is a hash function that is chosen uniformly at random from a k-universal hash family. The following lemma shows that we can generate a (log m)-universal hash function in constant rounds and store it on all the machines. Roughly speaking, the idea is to generate a small set of random coefficients on one machine and share it with all other machines and then use these coefficients to evaluate the hash function for any given input. 5The assumption that the vertices are numbered from 1 to n is just for the simplicity of presentation. Our algorithms can be adopted to any arbitrary naming of the vertices. 7 Lemma 4.2. For any given k ∈ Z+ where k ≤ poly(n), there exists an algorithm that runs in O(1) rounds of MPC and generates the same hash function h : [1, k] → M on all machines where function h is chosen uniformly at random from a (log m)-universal hash family, and calculating h(.) in a machine takes O(log n) time and space. We mainly use the universal hash functions to distribute objects into machines. Assuming that an object a has an integer index denoted by a.index, we store object a in machine h(a.index) where h is the universal hash function stored on all machines. This also allows other machines to know in which machine an object with a given index is stored. We claim even if the objects to be distributed by a (log m)-universal hash function have different sizes (in terms of the memory that they take to be stored), the maximum load on a machine will not be too much with high probability. To that end, we give the following definitions and then formally state the claim. Definition 4.3. A set A = {a1, a2, . . . , ak} is a weighted set if each element ai ∈ A has an associated non-negative integer weight denoted by w(ai). For any subset B of A, we extend the notion of w such that w(B) =(cid:80) maximum weight among its elements (i.e., maxai∈A w(ai)) is (cid:101)O(n/m). the set of all machines. We define the load of h for a machine m to be lh(m) =(cid:80) Definition 4.5. We call a hash function h : A → M a distributer if A is a weighted set and M is a∈A:h(a)=m w(a). Definition 4.4. A weighted set A = {a1, a2, . . . , ak} is a distributable set if w(A) is O(n) and the a∈B w(a). Moreover we define the maximum load of h to be maxm∈M lh(m). Lemma 4.6. Let h : A → M be a hash function chosen uniformly at random from a (log m)- universal hash function where A is a distributable set and M is the set of machines (i.e., h is a δ log n )δ log n where distributer). The maximum load of h is (cid:101)O(n/m) with probability at least 1 − ( 21/δe m ≥ nδ. The full proof of Lemma 4.6 is differed to Appendix A. The general idea is to first partition the elements of A into O(n/m) subsets S1, S2, . . . , Sk of size O(m) such that the elements are grouped based on their weights (i.e., S1 contains the m elements of A with the lowest weights, S2 contains the m elements in A − S1 with the lowest weights, and so on). Then we show that the maximum load of the objects in any set Si is (cid:101)O(wi) where wi is the weight of the object in Si with the show that(cid:80) maximum weight. Finally using the fact that the objects are grouped based on their weights, we A technique that we use in multiple parts of the algorithm is to distribute the vertices of T i∈[k] wi, which is the total load is (cid:101)O(n/m). among the machines using a (log m)-universal hash function. Definition 4.7. Let T be a given tree and let h : {1, . . . ,V (T )} → M be a mapping of the vertex indexes of T to the machines. We say T is distributed by h if any vertex v of T is stored in machine h(v.index). As a corollary of Lemma 4.2: Corollary 4.8. One can distribute a tree T by a hash function h that is chosen uniformly at random from a (log m)-universal hash family in O(1) rounds in such a way that each machine can evaluate h in O(log n) time and space. 8 4.2 Conversion of T to a Binary Tree The first step towards finding a decomposition of T with the desired properties is to convert it into a binary tree T b that preserves the important characteristics of the original tree (e.g., the ancestors of each vertex must remain to be its ancestors in the binary tree too). possible to find a binary extension of T in constant rounds. Definition 4.9. A rooted tree T (cid:48) is an extension of a given rooted tree T if V (T (cid:48)) = O(V (T )) and there exists a mapping function f : V (T ) → V (T (cid:48)) such that for any v ∈ V (T ), v.index = f (v).index and if u is an ancestor of v in T , f (u) is also an ancestor of f (v) in T (cid:48). The definition of an extension of a tree is as follows. By the end of this section, we prove it is The following lemma proves it is possible to find the degree of all vertices in constant rounds. Lemma 4.10. There exists a randomized algorithm to find the degree of each vertex of a given rooted tree T in O(1) rounds of MPC using m machines, such that with high probability, each machine uses a space of size at most (cid:101)O(n/m) and runs an algorithm that is linear in its memory size. Proof. The first step is to distribute the vertices of T using a (log m)-universal hash function h. By Corollary 4.8 this takes O(1) rounds. Define the local degree of a vertex v on a machine µ to be the the number of children of v that are stored in µ and denote it by dµ,v. We know there are at most (cid:101)O(n/m) vertices with a non-zero local degree in each machine. Hence in one round, every machine can calculate and store the local degree of every such vertex. In the communication phase, every machine µ, for any vertex v such that dµ,v > 0, sends dµ,v to machine h(v). Then in the next round, for any vertex v, machine h(v) will receive the local degree of v on all other machines and can calculate its total degree. We claim with high probability, no machine receives more than (cid:101)O(n/m) data after the commu- nication phase. Define the weight of a vertex v, denoted by w(v), to be min{m, deg(v)}. The weight of a vertex v is an upper bound on the size of communication that machine h(v) receives for vertex v. To see this, observe that a machine sends the local degree of v to h(v) only if this local degree is non-zero, therefore the total communication size for v cannot exceed its degree. On the other hand, the total number of machines is m, hence machine h(v) cannot receive more than m different local degrees for vertex v. We first prove that V (T ) is a distributable set (Definition 4.4) based on weight function w. To (cid:101)O(n/m) (recall that in the model we assumed m is less than the space on each machine and hence m = (cid:101)O(n/m)), and second, the total weight of all vertices is O(n) since(cid:80) see this, note that first, by definition of w, the maximum value that w gets is m, which indeed is v∈V (T ) deg(v) = 2n − 2. By Lemma 4.6, since V (T ) is a distributable set based on w and since h is chosen from a of any machine is (cid:101)O(n/m) with high probability. (log m)-independent hash family, the maximum load of h, i.e., the maximum communication size We are now ready to give a binary extension of T . Lemma 4.11. There exists a randomized algorithm to convert a given rooted tree T to a binary tree T b, an extension of T , in O(1) rounds of MPC using m machines, such that with high probability, each machine uses a memory of size at most (cid:101)O(n/m) and runs an algorithm that is linear in its memory size. 9 Figure 1: An example of converting a tree to a binary extension of it. The gray nodes denote the added auxiliary vertices and the numbers within the nodes denote their indexes. Proof. Our algorithm for converting T to a binary extension of it done in two phases. In the first next phase, we convert T d to a binary extension. Claim 4.12. There exists a randomized algorithm to convert a given rooted tree T to a tree T d, phase, we convert T to an extension of it, T d, with a maximum degree of (cid:101)O(n/m). Then in the with maximum degree (cid:101)O(n/m) that is an extension of T in O(1) rounds of MPC such that with high probability, each machine uses a memory of size at most (cid:101)O(n/m) and runs an algorithm that is linear in its memory size. The detailed proof of Claim 4.12 and the pseudo-code to implement it is given in Appendix A. Intuitively, after calculating the degree of each vertex, we send the index of all vertices with degree more than O(n/m) to all machines (call them high degree vertices). This is possible because there are at most O(m) high degree vertices and m is assumed to be less than the space of each machine. To any high degree vertex v, in the next step, we add a set of at most O(n/m) auxiliary children and set the parent of any previous child of v to be one of these auxiliary vertices that is chosen uniformly at random. The detailed proof of why no machine violates its memory size during the process and how we assign indexes to the auxiliary vertices is differed to Appendix A. The next phase is to convert this bounded degree tree to a binary tree. Claim 4.13. There exists a randomized algorithm to convert a tree T d, with maximum degree (cid:101)O(n/m), to a binary extension of it T b, in O(1) rounds of MPC using m machines, such that with high probability, each machine uses a memory of size at most (cid:101)O(n/m) and runs an algorithm that (cid:101)O(n/m), we can store all the children of any vertex in the same machine (the parent may be stored Again, the detailed proof of Claim 4.13 and a pseudo-code for implementing it in the desired setting is given in Appendix A. Roughly speaking, since the degree of each vertex is at most is linear in its memory size. in another machine). Having all the children of a vertex in the same machine allows us to add auxiliary vertices and locally reduce the number of children of each vertex to at most 2. Figure 1 illustrates how we convert the tree to its binary extension. See Appendix A for more details. binary extension of it in O(1) round of MPC, which with high probability uses (cid:101)O(n/m) time and By Claim 4.12 and Claim 4.13, for any given tree, there exists an algorithm to construct a space. 4.3 Decomposing a Binary Tree We start with the formal definition of decompositions. Definition 4.14. We define a decomposition of a binary tree T b to be a set of O(m) components, where each component contains a subset of the vertices of T b that are connected, and each vertex of T b is in exactly one component. A component ci, in addition to a subset of V (T b) (which we 10 1542129681173115131210144732516178961110 denote by V (ci)) and their "inner edges", i.e., the edges between the vertices in V (ci), contains their "outer edges" (i.e., the edges between a vertex in V (ci) and a vertex in another component) too. The data stored in each component, including the vertices and their inner and outer edges should be of size up to (cid:101)O(n/m). Since the vertices in any component ci are connected, there is exactly one vertex in ci that its parent is not in ci, we call this vertex the root vertex of ci and denote it by ci.root. We also define the index of a component ci to be equal to the index of its root; i.e., ci.index = ci.root.index (recall that we assume every vertex of T b has a unique index). Moreover, by contracting a component we mean contracting all of its vertices and only keeping their outer edges to other components. Since the vertices in the same component have to be connected by definition, the result of contraction will be a rooted tree. We may use this fact and refer to the components as nodes and even say a component ci is the parent (child, resp.) of cj if after contraction, ci is indeed the parent (child, resp.) of cj. Theorem 3. There exists a randomized algorithm to find a decomposition of a given binary tree T b with n vertices using m machines, such that with high probability the algorithm terminates in O(log n) rounds of MPC, and each machine uses a memory of size at most (cid:101)O(n/m) and runs an algorithm that is linear in its memory size. Algorithm 1 gives a sequential view of the decomposition algorithm we use. We first prove some properties of the algorithm, and then using these properties, we prove it can actually be implemented in the desired setting. Algorithm 1 The sequential algorithm for finding a valid MPC decomposition of a given binary tree T b. Require: A binary tree T b. 1: C ← ∅ 2: for each vertex v in T b do (cid:46) C will contain all components. 3: Insert a component containing only v to C. 4: F ← ∅ 5: while C > 14m do S ← ∅ for each component c ∈ C − F do if c is the root component then (cid:46) F will contain the completed components. (cid:46) S will contain the selected components. 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: Add c to S. else if c has exactly two children components then Add c to S. else if the parent component of c is in F then Add c to S. else if c has exactly one child component then Add c to S with probability 0.5. for each component c ∈ C − F − S do d ← Find the closest ancestor of c that is in S. Merge c into d. for every node c in C − F do if c contains at least n/m vertices of T b then Add c to F . 11 The algorithm starts with n components where each component contains only one vertex of T b. Then it merges them in several iterations until there are only O(m) components left. At the end of each iteration, if the size of a component is more than n/m, we mark it as a completed component and never merge it with any other component. This enables us to prove that the components' size does not exceed (cid:101)O(n/m). In the merging process, at each iteration, we "select" some of the components and merge any unselected component to its closest selected ancestor. We select a component if at least one of the following conditions hold for it. 1. It is the root component. 2. It has exactly two children. 3. Its parent component is marked as complete. In addition to these conditions, if a component has exactly one child, we select it with an independent probability of 0.5. Figure 2 illustrates the iterations of Algorithm 1. Figure 2: An example of running Algorithm 1. Each node denotes a component. A gray node denotes a selected component and a black node denotes a completed component. The intuition behind the selecting conditions is as follows. The first condition ensures every unselected component has at least one selected ancestor to be merged to. The second condition ensures no component will have more than two children after the merging step. (To see this, let c1 be a component with two children, c2 and c3. Also let c3 have two children, c4 and c5. If only c3 is not selected and is merged to c1, then the resulting component will have three children c2, c4 and c5.) The third condition ensures the path of a component to its closest selected ancestor does not contain any completed component. This condition is important to keep the components connected. Finally, randomly selecting some of the components with exactly one child ensures the size of no component exceeds (cid:101)O(n/m). (Otherwise, a long chain of components may be merged to one component in one iteration.) We also prove at most a constant fraction of the components are selected at each iteration. This proves the total number of iterations, which directly impacts the number of rounds in the parallel implementation, is logarithmic in the number of vertices. 4.3.1 Properties of Algorithm 1 In this section, we prove some properties of Algorithm 1. These properties will be useful in designing and analyzing the parallel implementation of the algorithm. Many of these properties are defined on the iterations of the while loop at line 5 of Algorithm 1. Any time we say an iteration of Algorithm 1, we refer to an iteration of this while loop. We start with the following definition. Definition 4.15. We denote the total number of iterations of of Algorithm 1 by I. Moreover, for any i ∈ [I], we use Ci and Fi to respectively denote the value of variables C (which contains all components) and F (which contains the completed components) at the start of the i-th iteration. Analogously, we use Si to denote the selected components (S) at the end of the i-th iteration. We also define Ti to be the rooted component tree that is given by contracting all components in Ci (e.g., T1 = T b). 12 12357812111046913141514578910161578 Claim 4.16. For any i ∈ [I − 1], each component c ∈ Ci+1 is obtained by merging a connected subset of the components in Ci. Proof. Observe that if in a step a component v is the closest selected ancestor of component u, it is also the closest selected ancestor of every other component in the path from u to v (denote the set of these components by Pu). We claim if u is merged to v, every component in Pu will also be merged to v in the same step. To see this, note that if there exists a component in Pu that is in Fi or Si, the closest selected ancestor of u would not be v. Hence all of these components will be merged to v and the resulting component will be obtained by merging a connected subset of the components in Ci. The following is a rather general fact that is useful in proving some of the properties of Algo- rithm 1. Fact 4.17. For a given binary tree T , let ki(T ) denote the number of vertices of T with exactly i children. Then k0(T ) = k2(T ) + 1. We claim the components' tree, in all iterations of the while loop, is a binary tree. Claim 4.18. For any i ∈ [I], the component tree Ti is a binary tree. Proof. We use induction to prove this property. We know by Definition 4.15, that T1 = T b and since T b is a binary tree, the condition holds for the base case T1. Assuming that Ti−1 is a binary tree, we prove Ti is also a binary tree. Fix any arbitrary component c in Ci, we prove it cannot have more than two children. Let U = {c1, . . . , ck} be the components in Ci−1 that were merged with each other to create c. For any component cj ∈ U let childU (cj) denote the number of children of cj that are in U and let child(cj) denote the total number of children of cj (no matter if they are in U or not). For any child of c, there is a component in U with a child that is outside of U , therefore to prove c cannot have more than two children it suffices to prove (cid:0)child(cj) − childU (cj)(cid:1) ≤ 2. (1) (cid:88) cj∈U We first prove(cid:80) Hence(cid:80) Next, we prove(cid:80) such edge indicates a parent-child relation in U . Hence(cid:80) Combining (cid:80) cj∈U child(cj) ≤ U + 1. Note that at most one of the components in U has two children in Ti−1 since all vertices with two children are selected in line 11 of Algorithm 1 and if two components are merged at least one of them is not selected (line 16 of Algorithm 1). Therefore other than one vertex in U which might have two children in Ci−1, others have at most one children. cj∈U childU (cj) ≥ U − 1. We know by Claim 4.16 that the components in U are connected to each other. Therefore there must be at least U − 1 edges within them and each cj∈U childU (cj) ≥ U − 1 we obtain Equation 1 cj∈U child(cj) ≤ U + 1 and (cid:80) cj∈U childU (cj) ≥ U − 1. cj∈U child(cj) ≤ U + 1. always holds and therefore Ti is a binary tree. The following property bounds the number of unselected ancestors of a component that is going to be merged to its closest selected ancestor. Claim 4.19. With probability at least 1 − 1/n, for any given i and ci, where i ∈ [I] and ci ∈ Ci− Fi− Si, there are at most 2 log n components in the path from ci to its closest selected ancestor. 13 Proof. We first show with probability 1 − 1/n2, there are at most 2 log n components in the path from c to its closest selected ancestor. To see this, let Pc denote the set of ancestors of c that have distance at most 2 log n to c. We prove with probability 1 − 1/n2 at least one component in Pc is selected. Since, all the children of any component in Fi is in Si, If Pc ∩ Fi (cid:54)= ∅, then Pc ∩ Si (cid:54)= ∅. Otherwise, any component in Pc is selected independently with probability at least 1 and the probability that Pc ∩ Si (cid:54)= ∅ is 1 − 2−2 log n = 1 − 1/n2. In addition we prove that Σi∈[I]Ci − Fi − Si ≤ n, so that we can use union bound over all the components in ∪i∈[I]Ci − Fi − Si. To prove this it suffices to prove that any vertex v ∈ V (T ) is at most the root vertex of one of the components in ∪i∈[I]Ci − Fi − Si. To prove this, let j denote the first iteration that v is the root vertex of a component in Cj − Fj − Sj. In this iteration we merge this component with one of its ancestors, so it can not be root vertex of any other component in ∪i∈[I],i>jCi− Fi− Si. Therefore using union bound over all the components in ∪i∈[I]Ci− Fi− Si, we obtain that with probability at least 1−1/n for any given i and ci, where i ∈ [I] and ci ∈ Ci−Fi−Si, there are at most 2 log n components in the path from ci to its closest selected ancestor. 2 The following property implies that w.h.p. at each round at most a constant fraction of the incomplete components are selected. Claim 4.20. There exists a constant number 0 < c < 1 such that for any i ∈ [K], with probability at least 1 − e−n/24, Si ≤ c · Ci − Fi. Proof. Let Kj(Ci) denote the set of components in Ci with exactly j children. Since each component in K1(Ci) is selected independently with probability 1 2 , by Chernoff bound, in round i, Pr[K1(Ci) ∩ Si > K1(Ci)] ≤ e−n/24. 3 4 The components that are selected in each round are as follows. With probability at least 1 − e−n/24 we choose less than three forths of the components in K1(Ci), the root component, all the components in Kj(Ci), and at most two components for any component in Fi. Therefore, with probability at least 1 − e−n/24, (2) By Fact 4.17, K0(Ci)= K2(Ci) + 1, and by Lemma 4.18, Ti is a binary tree, so Ci = K0(Ci) + K1(Ci) + K2(Ci). Therefore, Si < 1 + K2(Ci) + K1(Ci) + 2Fi. 3 4 1 + K2(Ci) + K1(Ci) < (K2(Ci) + K0(Ci) + 1) + 3 4 K1(Ci) ≤ 3 4 Ci. (3) 3 4 1 2 By equations 2 and 3 with probability at least 1−e−n/24, Si ≤ 3 the proof, it suffices to prove that there exists a constant number 0 < c < 1 such that equation 4Ci+2Fi. Therefore to complete which is equivalent to holds. Since the size of any component in Fi is at least n/m, Fi ≤ m. In addition, by line 3 of Algorithm 1, Ci > 14m, therefore Ci Fi ≥ 14. It is easy to see that the equation Ci + 2Fi ≤ c · Ci − Fi, 3 4 2 − c c − 3/4 ≤ Ci Fi 2 − c c − 3/4 ≤ 14 ≤ Ci Fi holds for c = 5/6, which is a constant number in (0, 1). 14 The following property is a direct corollary of Claim 4.20. Corollary 4.21. With high probability the while loop at line 5 of Algorithm 1, has at most O(log n) iterations. We are now ready to prove each component has at most (cid:101)O(n/m) vertices. Claim 4.22. The size of each components at any iteration of Algorithm 1 is bounded by (cid:101)O(n/m) with high probability. Proof. By Claim 4.16 any component ci ∈ Ci is obtained by merging a connected subset of the components in Ci−1. Let Xi ⊂ Ci−1 denote this subset, and let T (Xi) denote the component tree given by contracting all components in Xi. We first prove that Xi = O(log n). By Claim 4.18, T (Xi) is a binary tree, and by line 16 of Algorithm 1 Xi − T (Xi).root ⊂ Ci−1− Fi−1− Si−1. Note that, any component in Ci−1− Fi−1− Si−1 has at most 1 other component as a child, and T (Xi).root has at most 2 children. In addition, by Claim 4.19, with high probability for any c ∈ Xi − T (Xi).root the distance between c and T (Xi).root is 2 log n. Therefore, with high probability Xi ≤ 4 log n + 1, which is O(log n). In addition, note that Xi ⊂ Ci−1 − Fi−1, and any component in Ci−1 − Fi−1 has size at most O(n/m), hence with high probability ci = Σc∈Xic = (cid:101)O(n/m). 5 (poly log)-Expressible Problems The goal of this section is to prove and give examples of Theorem 1 which we restate below. Theorem 1. For any given m, there exists an algorithm to solve any (poly log)-expressible problem in O(log n) rounds of MPC using m machines, such that with high probability each machine uses a space of size (cid:101)O(n/m) and runs an algorithm that is linear in its input size. Proof. Assume we are given a (poly log)-expressible problem P . We first convert the given tree into a binary extension of it using Lemma 4.11 in O(1) rounds and then decompose the binary extension using Theorem 3 in O(log n) rounds. Note that since any component has at most two children (Claim 4.18), there are at most 2 leaves in any component that is unknown. Therefore we can use the compressor algorithm that is guaranteed to exist since P is assumed to be (poly log)- expressible and store a data of size at most poly log(n) for each component. Then in the next step, since there are at most (cid:101)O(m) components, we can send the partial data of all components into one machine. Then in only one round, we are able to merge all this partial data since the merger algorithm (that is guaranteed to exist since P is (poly log)-expressible) takes polylogarithmic time and space to calculate the answer of the dynamic programming for each of the components and it suffices to start from the leave components and compute the value of the dynamic programming for each of them one by one (all of this is done in one step because we have the data of all the components in one machine). We first formally prove why Maximum Weighted Matching is a (poly log)-expressible problem and therefore as a corollary, it can be solved in O(log n) rounds. Maximum Weighted Matching. An edge-weighted tree T is given in the input. (Let we denote the weight of an edge e.) The problem is to find a sub-graph M of T such that the degree of each vertex in M is at most one and the weight of M (which is(cid:80) e∈M we) is maximized. 15 e∈M b we. weight of an extended matching M b of T b to be(cid:80) At first, we explain the sequential DP that given any binary extension T b (see Definition 4.9) of an input tree T , finds a maximum matching of T and then prove this DP is (poly log)-expressible. Define a subset M b of the edges of T b to be an extended matching if it has the following properties. 1. For any original vertex in T b, at most one of its edges is in M b. 2. For any auxiliary vertex v of T b, at most one of the edges between v and its children is in M b. 3. The edge between an auxiliary vertex v and its parent is in M b if and only if an edge between v and one of its children is in M b. Consider an edge e between a vertex u and its parent v in T b. If u is an auxiliary vertex, we define we to be 0 and if v is an original vertex, we define we to be the weight of the edge between v(cid:48) and its parent where v(cid:48) is the vertex in T that is equivalent to v. Furthermore, we define the Let M b be an extended matching of T b and let M be a matching of T b; we say M b and M are equivalent if for any edge (u, v) ∈ M , every edge between the equivalent vertices of v and u in T b is in M b and vice versa. Let v(cid:48), u(cid:48) ∈ V (T b) denote the equivalent vertices of v, u ∈ V (T ) respectively. If v is the parent of u in T , all the other vertices in the path between v(cid:48) and u(cid:48) are auxiliary by definition of binary extensions. This means all the edges in this path, except for the edge between u(cid:48) and its parent (which is equal to wu,v), have weight 0. Therefore the weight of any extended matching of T b is equal to its equivalent matching of T . Hence, to find the maximum weighted matching of T , one can find the extended matching of T b with the maximum weight. Now, we give a sequential DP that finds the extended matching of T b with the maximum weight. To do so, for any vertex v of T b, define C(v) to be the maximum weight of an extended matching of the subtree of v where at least one edge of v to its children is part of the extended matching (if no such extended matching exists for v set C(v) to be −∞. Also define C(cid:48)(v) to be the maximum weight of an extended matching of the subtree of v where no edge of v to its children is part of the extended matching. The key observation in updating C(v) and C(cid:48)(v) for a vertex v is that if v is connected to one of its original children u, then u should not be connected to its children; if v is To update C(v) and C(cid:48)(v), if v has no children, then C(v) = −∞ and C(cid:48)(v) = 0, also if v has only one child u, then C(v) = w(v,u) and C(cid:48)(v) = 0. W.l.o.g. we consider the following three cases for the case where v has two children u1 and u2. • If u1 and u2 are both original vertices, then C(v) = max{wv,u1 + C(cid:48)(u1) + C(u2), wv,u2 + C(cid:48)(u2) + C(u1)}, C(cid:48)(v) = max{C(u1), C(cid:48)(u1)} + max{C(u2), C(cid:48)(u2)}. • If u1 and u2 are both auxiliary vertices, then C(v) = max{wv,u1 + C(u1) + C(cid:48)(u2), wv,u2 + C(u2) + C(cid:48)(u1)}, C(cid:48)(v) = max{C(cid:48)(u1), C(cid:48)(u2)}. • If u1 is auxiliary and u2 is an original vertex, then C(v) = max (cid:110) wv,u1 + C(u1) + max{C(cid:48)(u2), C(u2)}, wv,u2, +C(cid:48)(u2) + C(cid:48)(u1)}(cid:111) , C(cid:48)(v) = C(cid:48)(u1) + max{C(u2), C(cid:48)(u2)}. 16 and C(v) = max ai∈{0,1} C(cid:48)(v) = max ai∈{0,1} {a0C(u1) + a1C(cid:48)(u1) + a2C(u2) + a3C(cid:48)(u2) + f(cid:48) v(a0, a1, a2, a3)}. Now we prove that the (poly log)-expressiveness property holds for the proposed DP. Consider a subtree T of T b and let u1 and u2 denote the leaves of T with the unknown DP values. We apply the proposed DP rules and calculate the DP values as functions of C(u1), C(cid:48)(u2), C(u2), and C(cid:48)(u2) instead of plain numbers. We claim that for any vertex v of T there exist functions fv, f(cid:48) v : {0, 1}4 → Z such that {a0C(u1) + a1C(cid:48)(u1) + a2C(u2) + a3C(cid:48)(u2) + fv(a0, a1, a2, a3)}, Therefore it suffices to store the values of functions f(cid:48) to evaluate C(v) and C(cid:48)(v). Since fr and f(cid:48) only O(1) different output values to be stored. r and fr for the root vertex r of T to be able r take only 16 different input combinations, there are Corollary 5.1. For any given m, there exists an algorithm to solve the Maximum Weight Matching problem on trees in O(log n) rounds of MPC using m machines, such that with high probability each machine uses a space of size (cid:101)O(n/m) and runs an algorithm that is linear in its input size. Other problems. The dynamic programming solutions of Maximum Independent Set, Minimum Vertex Cover, Longest Path and many other problems are similar to the proposed DP for Maximum Weighted Matching. For example, for the Maximum Independent Set problem, we only need to keep two dynamic data, whether the root vertex of a subtree is part of the independent set in its subtree or not and for each of these cases what is the size of the maximum independent set in the subtree. Roughly speaking, the only major difference in the DP is that we have to change max to sum. Corollary 5.2. For any given m, there exists algorithms to solve the Maximum Independent Set, Minimum Vertex Cover, Longest Path and Dominating Set problems on trees in O(log n) rounds of MPC using m machines, such that with high probability each machine uses a space of size (cid:101)O(n/m) and runs an algorithm that is linear in its input size. 6 Solving Linear-Expressible Problems 6.1 The Splittability Property The main goal of this section is to define a property called "splittability" for linear-expressible problems, that indeed holds for the aforementioned linear-expressible problems and prove, by using a total memory of (cid:101)O(n4/3), we are able to parallelize linear-expressible problems that are splittable in O(log n) rounds. The main reason behind the need to define this extra property for linear- expressible problems, is that in contrast to (poly log)-expressible problems, the partial data of the subtrees in linear-expressible problems might have a relatively large size, hence when merging two subtrees, we are not able to access their partial data in one machine. As a result, we need to be able to distribute the merging step among different machines. It is worth mentioning that we prove the total memory of (cid:101)O(n4/3) is in some sense tight, unless we limit the number of machines to be too small, which defeats the purpose of MapReduce, which is to have maximum possible parallelization. Intuitively, a problem instance P is splittable if it is possible to represent it with a set of n objects such that the output of the problem depends only on the pair-wise relations of these objects. In the DP context, the splittability property is useful for linear-expressible problems. The splittability property ensures that these partial data can be effectively merged using the splitting technique. 17 of T b with nT vertices, a compressor function returns a partial data of size at most (cid:101)O(nT ) if at (cid:126)C(T (cid:48)) of at most (cid:101)O(nT (cid:48)) elements such that for any connected subtrees Definition 6.1 (Splittability). Consider a linear-expressible problem P and a binary adapted dy- namic program DP for it. We know since P is a linear-expressible problem, for any subtree T most a constant number of the leaves of T are unknown. Denote this partial data by C(T ). We say problem P is splittable, if for any given connected subtree T (cid:48) of T b, the partial data C(T (cid:48)) can be represented as a vector T1 and T2 of T b that are connected with an edge (with T being T1 + T2) the following condition holds. There exist two algorithms S (sub unifier) and U (unifier) such that for any consecutive (cid:126)C(T2), partitioning (P1, P2, . . . , Pk1) of 1. Algorithm S(Pi, Qj) returns a vector of size at most Pi + Qj in time poly(Pi + Qj) such (cid:126)C(T1) and any consecutive partitioning (Q1, Q2, . . . , Qk2) of that each element of this vector "affects" at most one element of (cid:126)C(T ). 2. Given the elements in S(Pi, Qj) that "affect" an element a in (cid:126)C(T ) for every 1 ≤ i ≤ k1 and 1 ≤ j ≤ k2, U computes the value of element a using linear space and polynomial time in input size. The linear-expressible problems such as minimum bisection, k-spanning tree, etc., that we have mentioned before are all indeed splittable. For the proof and concrete examples of unifier and sub unifier algorithms see Section 7. 6.2 Solving Splittable Linear-Expressible Problems We show with a slightly more total space (the space on each machine is still sublinear) it is possible to design parallel algorithms in O(log n) rounds for linear-expressible problems if they are splittable. Theorem 2. For any given m, there exists an algorithm to solve any linear-expressible problem defined on trees that is also splittable, in O(log n) rounds of MPC using m machines, such that with high probability each machine uses a space of size (cid:101)O(n4/3/m), and runs an algorithm that is k-spanning tree problems using an overall space of (cid:101)O(n1+) for some constant  < 1. As a corollary of Theorem 2, we give logarithmic round algorithms for minimum bisection, and polynomial in its input size. Our algorithm, similar to the algorithm given for (poly log)-expressible problems starts with de- composing a binary extension of the input tree. However, note that for linear-expressible problems, we cannot store the data of all components in one machine since the space limit will be violated. (The size of the total data would be roughly the same as the size of input.) Therefore we merge the components in multiple rounds. Unfortunately, the components tree could be unbalanced. To overcome this difficulty, we first partition the components tree. This partitioning of the components tree, specifies which components at which rounds, should be merged together. The merging process cannot be done in one machine either. Mainly because the partial data of even one component could be very large. Using the splittability property we distribute the data of the components among the machines and merge them in parallel. We first prove the partitioning lemma and then prove Theorem 2. Definition 6.2 (border vertices). For any subtree T of a given tree T , the border vertices are the set of vertices in V (T ) that are connected with an edge of tree T to a vertex in V (T ) − V (T ). Lemma 6.3. There exists a linear time algorithm that given a binary tree T with nT vertices, and a set of border vertices ST ∈ V (T ) with size at most 3, finds a partitioning PT = (cid:104)H1, H2, . . . , Hc(cid:105) of T , such that V (Hi) ≤ 2nT for any i ≤ c, and the total number of border vertices of any Hi based on (PT , ST ) is at most 3. 3 18 We defer the proof of Lemma 6.3 to the appendix. We are now ready to prove Theorem 2. Proof of Theorem 2. Let T denote the input tree. Since any linear-expressible problem is binary adaptable, there exists a dynamic program DP where for the instance PT of P with T as its input tree and for any binary extension T b of T , the output of DP (T b) is a solution of PT . We convert T to its binary extension T b in O(1) round of MPC such that with high probability each machine solve DP . uses space (cid:101)O(n/m) (see Lemma 4.11). Since the output of DP is a solution of PT , it suffices to O(log n) round of MPC such that with high probability each machine uses (cid:101)O(n/m) time and space. The first stage in this algorithm is decomposing tree T b, which by Theorem 3 is possible in Let C(T b) denote the set of components in decomposition of T b by Definition 4.14, and let T c denote the rooted component tree that is given by contracting all components in C(T b). Roughly speaking, we partition T c to at most three subtrees T 1, T 2, and T 3, such that max3 3T c, i=1 Bi ≤ 3, where Bi denotes the set of border vertices in T i. We find the partial dynamic and max3 data for these partitions recursively and we merge them to find the dynamic data for T c. Algorithm 2 is the overview of this algorithm. i=1 T i ≤ 2 Algorithm 2 1: procedure SolveLinearExpressible(T ) 2: Decompose T b and let C(T b) denote the set of components in decomposition of T b. Let T c be the component tree that is given by contracting all components in C(T b) . GetDynamicData(T c, ∅) 5: procedure GetDynamicData(T , B) if T = 1 then (cid:46) B is the set of border vertices in V (T ) 3: 4: 6: 7: 8: 9: 10: 11: 12: else i=1 Bi ≤ 3 where Bi denotes the set of border vertices in T i. Based on B, compute and return the dynamic data for T . Partition T to partitions T 1, T 2, and T 3, such that (1) max3 for every i in {1, 2, 3} do max3 Di ← GetDynamicData(Ti, Bi) Compute the dynamic data for T , by merging D1, D2, and D3, and return it. i=1 T i ≤ 2 3T , (2) stage halts after O(log nc) steps, so the overall running time of this stage is (cid:101)O(nc) ≤ (cid:101)O(m). At the Partitioning stage. The second stage of our algorithm partitions T c using the algorithm given in Lemma 6.3. Let nc denote the number of vertices of tree T c. Starting from T c, in each step, we partition the remaining subtrees by removing one edge from each and repeat this until we have nc disjoint vertices. Since each sub-tree is split into sub-trees of a constant fraction size of it, this end of this stage, for each edge e of T c, we store in which step it was deleted and use this data to design an algorithm to merge the dynamic data of the sub-trees and finally find an optimal solution for T d. More precisely, after this stage, the edges of T c are partitioned into subsets E1, E2, . . . , E2S where S = O(log n) is the number of steps this stage takes, and for any i ∈ [S], E2i−1 and E2i are respectively the set of edges deleted by Algorithm 3 and Algorithm 4 in the (S − i + 1)-th step of this stage. We store E1, E2, . . . , E2S in any machine in M without violating the memory limits since the total number of edges of T c is at most (cid:101)O(m) The third stage of the algorithm is the merging stage that runs exactly in the reverse order of the previous stage. Starting from single vertices of T c, which are equivalent to components in 19 C(T b), in the first round, the algorithm continues to merge the dynamic data of two subtrees if there exists an edge e ∈ E1 that connects them. Note that the size of any component in C(T b) is at most (cid:101)O(n/m), so it is possible to find its partial dynamic data in one machine. Let vector D(T ) denote the dynamic data (It is the partial dynamic data if there is any unknown data in T .) for any subtree T . Since the maximum number of border vertices for any partition is a constant, by linear-expressible (Definition 3.3) we can store the dynamic data for any partition in linear space to the size of the partition. Moreover by the same definition, if T = T1 + T2 it is possible to construct the dynamic data for T by merging the dynamic data for T1 and T2. Note that to update the dynamic data for any sub-tree T , we have to update O(V (T )) different values, and to update each of them, it is possible that we need more thanO(n/m) space. This unfortunately cannot be done in one machine since it violates the memory limit of O(n1+) on each machine. To handle this issue we use the following method to merge the dynamic data of two components. √ √ i and T r i and T r i and T r j in step r, and let D(T r i )[(k1−1)αi : k1αi] and D(T r j )[(k2−1)αj : k2αj] is assigned to machine µ with index k1 Merging stage. This stage of algorithm takes 2R steps. Intuitively, for any 1 ≤ r ≤ 2R and for any edge in Er that is between two partitions T r j , in the first round of step r we assign any machine a portion of dynamic data of T r j . This machine is responsible to merge these two portions using the function S (sub unifier)in Definition 6.1. Let T r+1 be the subtree i ). More precisely, for any two positive integers k1, k2 ≤ (cid:100)√ which is the result of merging subtrees T r i )[b] denote the b-th m(cid:101) dynamic data element of vector D(T r D(T r m+k2, where for any i, αi = T r i / m. (For any subtree T and any two positive integers a, b such that a < b D(T )[a : b] denotes the sub-vector (D(T )[a], . . . , D(T )[b]).) This machine is responsible to merge the given portion of dynamic data and generate Dµ(T ), such that Dµ(T ) = O(D(T r j )), and any element in Dµ(T ) affects at most one element in D(T ). This is possible by function S. Therefore to compute D(T )[a] for any valid a in one round of MPC it suffices if for every µ ∈ M we have the element in Dµ[T ] that affects D(T )[a] (if there exists any) in the same machine, and then use the function U (unifier). To achieve this for any T r+1 in the set of partitions of T b in round r and for any a ≤ V (T r+1) we assign each D(T r+1)[a] a unique index in [V (T b)] generated based on T r+1 and a. Using this index and a hash function h chosen uniformly at random from a family of log n−universal hash functions, we distribute pairs of (T r+1, a) over all m machines, and c (T r+1) that affects D(T r+1)[a] to the machine µ(cid:48) any machine µ sends at most one element of Dµ iff pair (T r+1, a) is assigned to machine µ(cid:48) using hash function h. Therefore, all the data needed to compute D(T r+1)[a], is gathered in one machine, and in the second round of r-th step, we run function U on all the machines to compute the dynamic data of T r+1. i ) + D(T r Time and space analysis. By Lemma 4.11 and Theorem 3 it is possible to convert any given using m machines, such that with high probability, each machine uses a memory of size at most tree T c is O(m), and the partitioning stage takes S = O(log n) steps, by 6.3 it is possible to do tree to a binary extension of it, and decompose the binary extension in (cid:101)O(log n) rounds of MPC (cid:101)O(n1+/m) and runs an algorithm that is linear in its memory size. Since the size of the component the partitioning stage of the algorithm using (cid:101)O(n1+/m) time and space in O(1) round. (Note that (cid:101)O(m) ≤ (cid:101)O(n1+/m).) In addition, the merging stage of the algorithm takes S = O(log n) round, and the space needed on each machine is (cid:101)O(n1+/m). Since in round r each vertex in T b is at most in one partition, the total size of the partitions in one round is O(n). Note that, the dynamic data of each partition is linear to its size. Therefore when in the first round of any step r ∈ [2R] of merging we assign each machine O(1/ √ m) portion of the dynamic data of each partition, 3 . Since m < n(1+)/2 it is the overall data assigned to each machine is O(n/ m). We set  = 1 √ 20 to each machine in the second round of any step r is (cid:101)O(n1+/m) since we distribute any pair √ m) ≤ O(n1+/m), so computing function Sin each round takes O(n1+/m) easy to see that O(n/ space and poly(n1+/m) time in any machine. Moreover, with high probability the data assigned of partition T in step r and a ≤ T using a hash function h chosen uniformly at random from a family of log n−universal hash functions. The maximum data that any machine receives for any pair (T, a) that is assigned to it by hash function h is at most O(m) and the overall data m) ≤ O(n1+). Therefore by Lemma assigned to all the machines is O(n √ 4.6 with high probability the maximum load over all the machines is (cid:101)O(n1+/m), so each machine takes (cid:101)O(n1+/m) space and poly(n1+/m) time to compute unifier for all the pairs (T, a) that are m). Note that, O(n √ assigned to it in any round. 7 A Concrete Example: Minimum Bisection on Trees We continue the discussion about linear-expressible problems by giving a detailed proof that the minimum bisection problem can be solved in logarithmic rounds. Theorem 4. For any given m, there exists an algorithm to solve the minimum bisection problem in O(log n) rounds of MPC using m machines, such that with high probability each machine uses a space of size (cid:101)O(n4/3/m). Proof. While converting T to binary version of it, for any auxiliary vertex a we set the weight of the edge between a and its parent to be ∞. Note that in any optimal solution for the new tree, the infinity weights enforce all auxiliary vertices to be in the same bisection set that their parents are, thus any solution for the original tree will have the same cost for the binary tree as long as we make sure the auxiliary vertices are in the same set that their parents are (otherwise the cost will be ∞). Recall that in the bisection's solution the number of vertices of the two sets should be equal, hence we have to keep track of the auxiliary vertices that we added to the tree and make sure we do not count them. The dynamic data Dc(Ti)[b], for any partition (sub-tree) Ti, and any possible coloring c of its border vertices into red and blue sets, and any number b ≤ V (Ti), is the minimum cost of partitioning Ti such that the partitions match what is specified in c and there are exactly b non- auxiliary vertices in the blue set. (Recall that the color of auxiliary vertices will have to be the same as their parents or the cost would be ∞). Note that we fix the exact coloring of border vertices by c to make it possible to merge the partial dynamic data for two components. Two components are only connected through their border vertices and if we know how the border vertices are colored, we will know if in a solution we have to add the weight of the edges between border vertices to the cost or not. Note that there are at most 4 border vertices in any partition so there are constant number of possible cases for c. This implies that bisection is linear-expressible. If we define the unifier (U) and the sub unifier (S) functions for the dynamic data stored for each partition we obtain that bisection is also splittable (Definition 6.1). Let T be the result of merging Ti and Tj, and let set D(T (cid:48))[b] denote the set of all Dc(T (cid:48))[b] for any possible coloring c of border vertices in V (T (cid:48)), and any partition T (cid:48). The function S for any consecutive portion of D(Ti) from element D(Ti)[ai] to Dc(Ti)[bi] denoted by D(Ti)[ai : bi], and any consecutive portion of D(Tj) denoted by D(Tj)[aj : bj] is as follows: for any pair ki and kj such that ai ≤ ki ≤ bi , aj ≤ kj ≤ bj, the value of pair (D(Ti)[ki], D(Tj)[kj]) is only related to D(T )[ki + kj]. Therefore, for any possible coloring c of border vertices of T , and any number x such that ai + aj ≤ x ≤ bi + bj, S outputs a value for Dc(T )[x] which is the maximum value for Dc(T )[x] based on the input given to this function. It is easy to see that U for any c is the maximum of all its inputs that match with the color of border vertices c, which is a function polynomial to its input. 21 At the end, maxc Dc(T d)[ n(cid:48) solution we return. 2 ], where n(cid:48) is the number of non-auxiliary vertices of T , is the to solve bisection in (cid:101)O(log n) round of MPC using m machines, such that with high probability each machine uses (cid:101)O(n1+/M) space, and takes O(n2/m) time in each round of the algorithm, for Therefore, by Theorem 2 since bisection is linear- and splittable, there exists an algorithm  = 1 3 . It could be shown that with very similar techniques, the "k-maximum spanning Extensions. tree" problem on a tree could also be solved. In this problem a weighted tree is given and the goal is to find the maximum weighted connected subgraph of the given tree with exactly k vertices. When we convert this tree to a binary tree we only need to make sure that we mark auxiliary vertices such that we do not disconnect them from their parents in the algorithm. Moreover, instead of considering all the possible coloring of the border vertices in bisection, in the dynamic for k-maximum spanning tree, we need to consider all the cases for the connectivity of the border vertices with the maximum weighted tree in the partition. Furthermore, we expect that this idea can be extended to several other problems, including facility location problem, minimum diameter, k partitioning, k-median, and k-center, because they have very similar dynamic programming solutions when the input graph is a tree. Acknowledgements. The authors thank Silvio Lattanzi for fruitful discussions and his help- ful comments. References [1] Karl Abrahamson, Norm Dadoun, David G. Kirkpatrick, and T Przytycka. A simple parallel tree contraction algorithm. Journal of Algorithms, 10(2):287 -- 302, 1989. [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, pages 202 -- 211. ACM, 2015. [3] Kook Jin Ahn, Sudipto Guha, and Andrew McGregor. Analyzing graph structure via lin- ear measurements. In Proceedings of the Twenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms, pages 459 -- 467, 2012. [4] Alexandr Andoni, Aleksandar Nikolov, Krzysztof Onak, and Grigory Yaroslavtsev. Parallel algorithms for geometric graph problems. In Proceedings of the 46th Annual ACM Symposium on Theory of Computing, pages 574 -- 583. ACM, 2014. [5] Bahman Bahmani, Ravi Kumar, and Sergei Vassilvitskii. Densest subgraph in streaming and mapreduce. Proceedings of the VLDB Endowment, 5(5):454 -- 465, 2012. [6] Bahman Bahmani, Benjamin Moseley, Andrea Vattani, Ravi Kumar, and Sergei Vassilvitskii. Scalable k-means++. Proceedings of the VLDB Endowment, 5(7):622 -- 633, 2012. [7] 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 2017, 4-9 December 2017, Long Beach, CA, USA, pages 6867 -- 6877, 2017. 22 [8] MohammadHossein Bateni, Soheil Behnezhad, Mahsa Derakhshan, MohammadTaghi Haji- aghayi, and Vahab Mirrokni. Brief Announcement: MapReduce Algorithms for Massive Trees. In Ioannis Chatzigiannakis, Christos Kaklamanis, D´aniel Marx, and Donald Sannella, editors, 45th International Colloquium on Automata, Languages, and Programming (ICALP 2018), volume 107 of Leibniz International Proceedings in Informatics (LIPIcs), pages 162:1 -- 162:4, Dagstuhl, Germany, 2018. Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik. [9] MohammadHossein Bateni, Aditya Bhaskara, Silvio Lattanzi, and Vahab Mirrokni. Dis- tributed balanced clustering via mapping coresets. In Advances in Neural Information Pro- cessing Systems, pages 2591 -- 2599, 2014. [10] Paul Beame, Paraschos Koutris, and Dan Suciu. Communication steps for parallel query pro- cessing. In Proceedings of the 32nd ACM SIGMOD-SIGACT-SIGAI symposium on Principles of database systems, pages 273 -- 284. ACM, 2013. [11] Soheil Behnezhad, Mahsa Derakhshan, Hossein Esfandiari, Elif Tan, and Hadi Yami. Brief announcement: Graph matching in massive datasets. In Proceedings of the 29th ACM Sym- posium on Parallelism in Algorithms and Architectures, SPAA 2017, Washington DC, USA, July 24-26, 2017, pages 133 -- 136, 2017. [12] Soheil Behnezhad, Mahsa Derakhshan, and MohammadTaghi Hajiaghayi. Brief announcement: Semi-mapreduce meets congested clique. CoRR, abs/1802.10297, 2018. [13] 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. [14] Sebastian Brandt, Manuela Fischer, and Jara Uitto. Breaking the Linear-Memory Barrier in MPC: Fast MIS on Trees with n Memory per Machine. CoRR, abs/1802.06748, 2018. [15] Sebastian Brandt, Manuela Fischer, and Jara Uitto. Matching and MIS for Uniformly Sparse Graphs in the Low-Memory MPC Model. CoRR, abs/1807.05374, 2018. [16] Flavio Chierichetti, Nilesh N. Dalvi, and Ravi Kumar. Correlation clustering in mapreduce. In The 20th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 641 -- 650, 2014. [17] Rajesh Chitnis, Graham Cormode, Hossein Esfandiari, MohammadTaghi Hajiaghayi, Andrew McGregor, Morteza Monemizadeh, and Sofya Vorotnikova. Kernelization via sampling with applications to finding matchings and related problems in dynamic graph streams. In Pro- ceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1326 -- 1344, 2016. [18] Rajesh Hemant Chitnis, Graham Cormode, Mohammad Taghi Hajiaghayi, and Morteza Mon- emizadeh. Parameterized streaming: Maximal matching and vertex cover. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1234 -- 1251, 2015. [19] Jeffrey Dean and Sanjay Ghemawat. MapReduce: Simplified data processing on large clusters. Communications of the ACM, 51(1):107 -- 113, 2008. [20] Alina Ene and Huy L Nguyen. Random coordinate descent methods for minimizing decom- posable submodular functions. In ICML, pages 787 -- 795, 2015. 23 [21] Hossein Esfandiari, Mohammad Taghi Hajiaghayi, Vahid Liaghat, Morteza Monemizadeh, and Krzysztof Onak. Streaming algorithms for estimating the matching size in planar graphs and beyond. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1217 -- 1233, 2015. [22] Jon Feldman, S Muthukrishnan, Anastasios Sidiropoulos, Cliff Stein, and Zoya Svitkina. On distributing symmetric streaming computations. ACM Transactions on Algorithms (TALG), 6(4):66, 2010. [23] Hillel Gazit, Gary L Miller, and Shang-Hua Teng. Optimal tree contraction in the erew model. In Concurrent Computations, pages 139 -- 156. Springer, 1988. [24] Mohsen Ghaffari and Jara Uitto. Sparsifying distributed algorithms with ramifications in massively parallel computation and centralized local computation. CoRR, abs/1807.06251, 2018. [25] Ashish Goel and Kamesh Munagala. Complexity measures for map-reduce, and comparison to parallel computing. arXiv preprint arXiv:1211.6526, 2012. [26] Michael T Goodrich, Nodari Sitchinava, and Qin Zhang. Sorting, searching, and simulation in the mapreduce framework. In International Symposium on Algorithms and Computation, pages 374 -- 383. Springer, 2011. [27] Sudipto Guha, Adam Meyerson, Nina Mishra, Rajeev Motwani, and Liadan O'Callaghan. IEEE transactions on knowledge and data Clustering data streams: Theory and practice. engineering, 15(3):515 -- 528, 2003. [28] Sungjin Im and Benjamin Moseley. Brief announcement: Fast and better distributed mapre- duce algorithms for k-center clustering. In Proceedings of the 27th ACM symposium on Par- allelism in Algorithms and Architectures, pages 65 -- 67. ACM, 2015. [29] Sungjin Im, Benjamin Moseley, and Xiaorui Sun. Efficient massively parallel methods for In Proceedings of the 46th Annual ACM Symposium on Theory of dynamic programming. Computing. ACM, 2017. [30] Daniel M Kane, Jelani Nelson, and David P Woodruff. An optimal algorithm for the dis- tinct elements problem. In Proceedings of the twenty-ninth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems, pages 41 -- 52. ACM, 2010. [31] Howard Karloff, Siddharth Suri, and Sergei Vassilvitskii. A model of computation for mapre- duce. In Proceedings of the twenty-first annual ACM-SIAM symposium on Discrete Algorithms, pages 938 -- 948. Society for Industrial and Applied Mathematics, 2010. [32] Ravi Kumar, Benjamin Moseley, Sergei Vassilvitskii, and Andrea Vattani. Fast greedy al- gorithms in mapreduce and streaming. ACM Transactions on Parallel Computing, 2(3):14, 2015. [33] Silvio Lattanzi, Benjamin Moseley, Siddharth Suri, and Sergei Vassilvitskii. Filtering: a method for solving graph problems in mapreduce. In Proceedings of the 23rd Annual ACM Symposium on Parallelism in Algorithms and Architectures, pages 85 -- 94, 2011. 24 [34] Brendan Lucier, Joel Oren, and Yaron Singer. Influence at scale: Distributed computation of complex contagion in networks. In Proceedings of the 21th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 735 -- 744, 2015. [35] Vahab S. Mirrokni and Morteza Zadimoghaddam. Randomized composable core-sets for dis- In Proceedings of the Forty-Seventh Annual ACM on tributed submodular maximization. Symposium on Theory of Computing, pages 153 -- 162, 2015. [36] Baharan Mirzasoleiman, Amin Karbasi, Rik Sarkar, and Andreas Krause. Distributed sub- modular maximization: Identifying representative elements in massive data. In Advances in Neural Information Processing Systems, pages 2049 -- 2057, 2013. [37] Krzysztof Onak. Round compression for parallel graph algorithms in strongly sublinear space. CoRR, abs/1807.08745, 2018. [38] Andrea Pietracaprina, Geppino Pucci, Matteo Riondato, Francesco Silvestri, and Eli Upfal. Space-round tradeoffs for mapreduce computations. In Proceedings of the 26th ACM interna- tional conference on Supercomputing, pages 235 -- 244. ACM, 2012. [39] Margaret Reid-Miller, Gary L Miller, and Francesmary Modugno. List ranking and parallel tree contraction. Synthesis of Parallel Algorithms, pages 115 -- 194, 1993. [40] Tim Roughgarden, Sergei Vassilvitskii, and Joshua R Wang. Shuffles and circuits:(on lower In Proceedings of the 28th ACM Symposium on bounds for modern parallel computation). Parallelism in Algorithms and Architectures, pages 1 -- 12. ACM, 2016. [41] 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. [42] Salil P Vadhan et al. Pseudorandomness. Foundations and Trends R(cid:13) in Theoretical Computer Science, 7(1 -- 3):1 -- 336, 2012. [43] Mark N Wegman and J Lawrence Carter. New hash functions and their use in authentication and set equality. Journal of computer and system sciences, 22(3):265 -- 279, 1981. [44] Tom White. Hadoop: The Definitive Guide. O'Reilly Media, Inc., 2012. [45] Matei Zaharia, Mosharaf Chowdhury, Michael J. Franklin, Scott Shenker, and Ion Stoica. Spark: Cluster computing with working sets. In Proceedings of the 2Nd USENIX Conference on Hot Topics in Cloud Computing, pages 10 -- 10, 2010. 25 A Omitted Proofs Proof of Lemma 4.2 Proof. We use the following proposition by [42]. Proposition A.1 (Corollary 3.34 in [42]). For any d, p, k ∈ Z+, there is a family of k-wise inde- pendent hash functions H = {h : [d] → {0, 1, . . . , 2p−1}}, from which choosing a random function h takes k · max{log d, p} random bits, and evaluating any function h ∈ H takes time poly(log d, p, k). Recall that we assume the number of machines, m, is a power of two in the model. Therefore we can use Proposition A.1 to choose the hash function h : [k] → M with only max{log k, log m} random bits which we can generate on one machine and share with all other machines. The total n) communication of this machine would be O(m(log k + log m)) which is (cid:101)O(n/m) since m = O( √ and k is poly(n). Proof of Lemma 4.6 To prove Lemma 4.6 we use a known result on the balls and bins problem by [41]. We start with the definition of the balls and bins problem. Definition A.2 (Balls and bins). In an instance of balls and bins problem there are n balls and n bins. Each ball is placed into one of the bins that is chosen uniformly at random. Let random variable Xi with range {1, .., n} denote the bin that the i-th ball is assigned to. In this problem, the load of an arbitrary bin b ∈ [n] is the number of balls assigned to this bin, which is equal to Σn i=1Xi = b. The following claim is based on the result of [41]. Claim A.3. Let li denote load of the i-th bin in an instance of balls and bins problem in which log n )log n. random variables X1, . . . , Xn are (log n)-wise independent, then Pr [maxn Proof. By Theorem 6-(V) in [41] we infer that, given an instance of balls and bins problem in which random variables X1, . . . , Xn are (log n)-wise independent, for any r and η such that r ≥ 1+η+log n, and k ≥ η The following equation holds: i li > 2 log n] ≤ ( 2e Pr [li > r] ≤ eη (1 + η)1+η . bins problem, for any i ∈ [n], Pr [li > 2 log n] ≤ ( e over all n bins we achieve the following result: Using this result, by setting η = log n− 1 and r = 2 log n in the mentioned instance of balls and log n )log n. Given this fact, by taking union bound Pr [ max n i li > 2 log n] ≤ n · Pr [li > 2 log n] = 2log n · ( e log n )log n = ( 2e log n )log n. We are now ready to prove Lemma 4.6. Proof of Lemma 4.6. Our starting point is Lemma A.3. We represent the elements of A as balls and the machines as bins. However, there are two main problems. First, A may be much larger than the number of machines (m), while Lemma A.3 expects the number of balls to be equal to the number of bins. Second, the balls are unweighted in Lemma A.3 whereas the elements of A are weighted. 26 To resolve the above issues, we first partition the elements of A into (cid:100)n/m(cid:101) (= α) subsets S1, S2, . . . , Sα of size m (except the last subset Sα which might have fewer elements if n/m is not an integer) such that the elements are grouped based on their weights. More precisely, S1 contains the m elements of A with the lowest weights, S2 contains the m elements in A− S1 with the lowest weights, and so on. Claim A.4. For m = nδ, with probability at least 1 − ( 21/δe more than O(log m) elements of Si to the same machine. δ log n )δ log n there is no set Si where h maps Proof. Since h is chosen from a (log m)-universal hash function, and since each Si has at most m elements, the machines that the elements in Si are assigned to are (log m)-wise independent. Therefore, by fixing a set Si, we can use Lemma A.3 to prove at most O(log m) elements of Si are assigned to the same machine with probability 1 − (2e/ log m)log m. By taking union bound over the failure probability of all sets we obtain that with probability at least 1 − n m ( 2e log m )log m = 1 − n( e log m )log m = 1 − ( 21/δe δ log n )δ log n there is no set Si where h maps more than O(log m) elements of Si to the same machine. Also let li h(µ) denote the load of h on machine µ from the elements in set Si (i.e., li Let wi = maxa∈Si w(a) denote the weight of the element in Si with the maximum weight. h(µ) = a∈Si:h(a)=µ w(a)). By Claim A.4, with high probability, from any set Si, at most O(log m) ele- ments are mapped to the same machine. Also since the maximum weight of the elements in Si is h(µ) ≤ O(log m · wi) for any i. We know by Definition 4.5 wi we know with high probability that li (cid:80) that lh(µ) =(cid:80)α Therefore the maximum load of h is (cid:101)O(w1 + w2 + . . . + wα). To complete our proof, it suffices to prove w1 + w2 + . . . + wα = O(n/m). To see this, note that w(a) ≥ wi−1 for any a in Si or otherwise a would have been in Si−1 instead of Si. Therefore, h (µ) ≤ O(log m · (w1 + . . . wα)). lh(µ) = l1 h(µ) + . . . + lα i=1 li h(µ), therefore (4) (cid:88) a∈Si which means, w(a) ≥ Si · wi−1 = m · wi−1 ∀i : 1 ≤ i < α, m(w1 + w2 + . . . + wα−1) ≤ α(cid:88) i=2 (cid:88) a∈Si w(a). (5) (6) On the other hand since the total weight of the elements in A is O(n) by Definition 4.4, we obtain and therefore(cid:80)α−1 in A, and consequently wα is not more than n/m, we prove(cid:80)α (7) i=1 wi ≤ O(n/m). Finally since by Definition 4.4 we know the maximum weight m(w1 + w2 + . . . + wα−1) ≤ O(n), i=1 wi ≤ O(n/m) as desired. 27 Proof of Lemma 6.3 Proof. The main idea of the algorithm is to first partition T into two sub-trees T 1 and T 2 such that each of them has at most 2nT 3 vertices. Unfortunately, in case all inherited border vertices of T lie within one of the sub-trees, we may end up having 4 border vertices in one of the sub-trees since the partitioning step creates one new border vertex in each of the sub-trees. To handle this case, we again partition the sub-tree with 4 border vertices into two sub-trees such that they will not have more than 3 border vertices at the end. Let D[v] denote the number of descendants of vertex v (including itself), and let B[v] denote the number of border vertices among these descendants. It is easy to see that there exists linear time bottom-up dynamic algorithms to calculate these two vectors. In the first step, we use Algorithm 3 to find an edge and claim removing it partitions T into two sub-trees T 1 and T 2, where max(V (T 1),V (T 2)) ≤ 2nT 3 . CD[v] ← the child u of v with maximum D[u] Algorithm 3 1: procedure FirstCut(T ) D ← Descendants(T ) for any vertex v of T do 2: nT ← D[T .root] v ← T .root while D[CD[v]] > 2nT v ← CD[v] return edge (v, CD[v]) 3 do 3 ≤ D[u] ≤ 2nT To prove the returned edge e = (v, u) is a desired one, it suffices to prove nT 3 since this yields that the size of the other partition is also less than or equal to 2nT 3 . The condition at Line 7 of Algorithm 3 ensures: (i) D[u] ≤ 2nT 3 . The former inequality is a direct result of the condition; the latter also holds since otherwise v (the parent of u) would not have been updated. Using the second inequality and since u = CD[v] (i.e., the child of v with maximum number of descendants) we can obtain D[u] ≥ D[v]−1 After partitioning T we may end up having one partition with more than 3 border vertices (exactly 4) since removing an edge can add up to one new border vertex to each partition. In this case, let T 1 denote the sub-tree with 4 border vertices. We run Algorithm 4 to partition T 1 into two sub-trees with less than 4 border-vertices. 3 , and (ii) D[v] > 2nT 2 ≥ nT 3 as desired. 3: 4: 5: 6: 7: 8: 9: 4: 5: 6: 7: 8: Algorithm 4 1: procedure SecondCut(T ) B ← BorderVertices(T ) for any vertex v of T do 2: 3: v ← T .root while B[CB[v]] > 2 do v ← CB[v] CB[v] ← the child u of v with maximum B[u] return edge(v, CB[v]) 28 Proof of Claim 4.12 Set ∆ to be (cid:100) n Proof. Algorithm 5 is the implementation of such an algorithm in MPC. Before running this algorithm, we distribute all the vertices in V (T ) over M machines independently and uniformly at random. To construct T d we first add V (T ) vertices to it with the same set of indexes as the vertices in V (T ). These vertices do not have any parent yet, so we assign parents to them later in the algorithm. We will also add some auxiliary vertices to this tree. m(cid:101). For any vertex v ∈ T , let Cv denote the set of children of v in tree T , and let vd denote the vertex equivalent to v in T d, which has the same index as v. If ∆ ≥ Cv for any Cv vertex u ∈ Cv, we set the parent of vertex ud as vd. Otherwise, if ∆ < Cv, we add a set of auxiliary vertices to V (T d), denoted by Av, such that vd is the parent of all the vertices in Av, and ∆ for any vertex u ∈ Cv, we choose one of the auxiliary vertices in Av independently and uniformly at random as the parent of the vertex ud. This guarantees that, for any two vertex u and v that v is an ancestor of u in T , vd is also an ancestor of ud. In addition V (T d) = O(V (T )), so T d is an Cv ∆ ≤ m ≤ O(n/m) = O(∆ log n) , therefore for any vertex v of T , the extension of T . Note that degree of vd is at most O(∆ log n). Moreover, for any two vertices u and v such that Cv > ∆ and u ∈ Av, it is easy to see that by Claim A.3 with high probability the maximum number of vertices from Cv that choose u as the parent for their equivalent vertex in T d, is at most O(∆ log n) since any vertex in Cv choses a vertex in Av independently and uniformly at random. Therefore, the maximum degree in T d is O(∆ log n). To implement this algorithm in MPC, each machine in M needs to have the list of all the vertices in T with degree more than ∆ alongside with the number of children each one's equivalent vertex will have in tree T d . Let Kµ denote the set of such vertices of T in any machine µ ∈ M, and let Sµ be a dictionary with the set of keys Kµ, such that Sµ(v) is the number of children that vertex vd will have in tree T d for any vertex v ∈ Kµ. We assume that each machine has the degree of all the vertices that are stored in it. By Lemma 4.10 we can achieve this in O(1) rounds of MPC. In the first round of the algorithm each machine constructs and sends this dictionary to all machines. In the next round, each machine construct a dictionary S which is the union of all the dictionaries received in round 1, and its own dictionary. (Since the dictionaries have distinct set of keys the union of them is well-defined.) For any vertex v ∈ V (T ) we construct vd in the same machine as v, and using S, we set its parent. In addition, if the degree of v in tree T is more than ∆, we add S(v) ∆ auxiliary vertices as the children of vd in this machine. It is easy to see that the data in dictionary S, suffices to assign a unique index to any auxiliary vertex. After this algorithm terminates each vertex of V (T d) is stored in exactly one machine. To prove that during the algorithm, with high probability no machine violates the memory greater than ∆ in any machine µ ∈ M is O(log n), since it yields that the size of the message each limit of (cid:101)O(n/m), it suffices to prove that with high probability the number of vertices with degree machine sends in round 1 of the algorithm is O(log n), and hence we have (cid:101)O(m) ≤ (cid:101)O(n/m), the ∆ ≤ (cid:101)O(n/m). To ∆ ) ≤ O(m). So, by Claim A.3 with high probability there are at most overall message passing for each machine does not violate the memory limit. Moreover, it indicates that the total number of vertices added to each machine is at most O(log n) · n prove this claim, we use two facts. First, before running the algorithm we uniformly distribute the vertices over all the machines, and second, the total number of the vertices with degree at least ∆ in a tree is at most O( n O(log n) vertices with degree at least ∆ in any machine µ ∈ M. 29 Algorithm 5 An algorithm to convert a given tree T to a bounded degree tree T d, an extension of T Require: given a number ∆ this algorithm converts a tree T whose vertices are distributed over m machines to an extension of it, T d with maximum degree O(∆ log n) set of vertices of T that are stored in this machine. 1: Let µ denote the machine in which this instance of algorithm is running, and let Vµ denote the Let Sµ be a dictionary with the set of keys Kµ = {v.index deg(v) > ∆, v ∈ Vµ}. For any v, such that v.index ∈ Kµ, Sµ(v.index) = (cid:100) deg(v) ∆ (cid:101). Send Sµ and Kµ to all the other machines. 2: round 1: 3: 4: 5: 6: end 7: round 2: 8: K ← ∪i∈MKi (cid:46) Since Kis are distinct, for any i ∈ K S[i] has exactly one value S ← ∪i∈MSi Let D be a dictionary on the same set of keys as S, while for any i ∈ K, D[i] = n + Σj∈S,j<iS[j]. for every v in Vµ do if v.parent ∈ K then Choose x uniformly at random from [S(v.index)]. v.parent ← D[v.parent] + x [n, 2n] assigned to the x-th child of vertex v in T d (cid:46) D[v.parent] + x is a unique index in the range for every v in Kµ do for every j in [S[v]] do Add Vertex(v, D[v] + j) to Vµ . 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: end Proof of Claim 4.13 Proof. Algorithm 6 is the implementation of an algorithm to convert T d to T b in MPC. To construct T b we first add V (T d) vertices to it with the same set of indexes as the vertices in V (T d). These vertices do not have any parent yet, so we assign parents to them later in the algorithm. We will also add some auxiliary vertices to this tree. Let Cv denote the set of children of vertex v, for any v ∈ V (T d), and let vb denote its equivalent vertex in T b . The overall idea in this algorithm is as follows: for any vertex with more than two children we construct a binary tree tv with root vb such that for any u ∈ Cv, ub is a leave in this tree, and V (tv) = 2Cv − 1. Then we add the vertices of tv excluding the root to binary tree T b with the same parent they have in tv. In addition, for any v with less than 3 children we set the parent of its children's equivalent vertices in T b as vb. To implement this algorithm in MPC, we need to have all the children of any vertex in one machine. To achieve this, we first distribute all the vertices in V (T d) over m machines using a hash function h : [V (T b)] → [m] which is chosen uniformly at random from a family of log n-universal hash functions. By Corollary 4.8 it is possible to distribute V (T d) by hash function h in O(1) round of MPC , and using O(log m) time and space on each machine in such a way that each machine can evaluate h in O(log m) time and space. Let Vµ denote the set of vertices that is assigned to an arbitrary machine µ by this distribution. For any vertex v ∈ Vµ let pv denote v's parent, and space, It is possible to find µv for all v ∈ Vµ using (cid:101)O(n/m) time and space in machine µ. We send let µv be the machine that pv ∈ Vµv . Since evaluating h in each machine takes O(log m) time and any vertex v as a message to the machine µv. In this way all the children of any vertex are sent 30 to the same machine. In addition since Cv ≤ (cid:101)O(n/m), by Lemma 4.6 with high probability the total size of the messages received by any machine µ which is equal to ΣvinVµCv is (cid:101)O(n/m). For any vertex v ∈ V (T d) where Cv > 2, we add some auxiliary vertices to T b, which does not have any equivalent vertex in V (T d), so we need to assign an index to them. To make sure that these assigned indexes are unique, any machine µ computes the number of all the auxiliary vertices generated in this machine, which is equal toΣv∈Vµ max(Cv − 2, 0), and send it to all the other machines with index greater than µ.index. It is easy to see that using this received data each machine is able to generate unique indexes for any auxiliary vertex in it. Figure 1 represents how this algorithm works. The gray vertices in this figure are the auxiliary vertices added to the tree. Algorithm 6 An algorithm to convert a given bounded degree tree T d to a binary extension of it, T d Require: In the beginning of the algorithm vertices of the tree T d with maximum degree O(∆ log n) are distributed over m machines using a hash function h. This algorithm converts T d to a binary tree T b, which is an extension of T d. set of vertices of T d that are stored in this machine. 1: Let µ denote the machine in which this instance of algorithm is running, and let Vµ denote the 2: round 1: 3: for every v in Vm do µd = h(v.parent) Send (v.parent, v) to machine µd. Delete v from Vµ. 4: 5: 6: (cid:46) Send it even if µd = µ. Let R denote the set of all the messages received in the previous round. Cv ← {u(v, u) ∈ R} Send Σv∈Vµ max(Cv − 2, 0) to any machine µ(cid:48) such that µ(cid:48).index > µ.index. (cid:46) Cv is the set of all the children of vertex v 7: end 8: round 2: 9: 11: 12: end 13: round 3: 14: 10: 15: 16: 17: 18: 19: 20: 21: Let s denote the summation of all the messages received in the previous round. d ← s + 1 for every v in Vµ do Construct a binary tree bv with root v, leaves Cv, and Cv− 2 inner vertices indexed by (cid:46) Any vertex in a tree that is not a root, nor a leave is considered as an d, . . . , d + Cv − 2. inner vertex. If Cv ≤ 2 there is no inner vertex. d ← d + max(0,Cv − 2) for every vertex u in bv excluding v do Let u.par denote the index of u's parent in the tree bv. Add Vertex(u.par, u.index) to Vm. 22: end 31
1903.08364
1
1903
2019-03-20T07:25:30
A Novel Dynamic Programming Approach to the Train Marshalling Problem
[ "cs.DS" ]
Train marshalling is the process of reordering the railcars of a train in such a way that the railcars with the same destination appear consecutively in the final, reassembled train. The process takes place in the shunting yard by means of a number of classification tracks. In the Train Marshalling Problem (TMP), the objective is to perform this rearrangement of the railcars with the use of as few classification tracks as possible. The problem has been shown to be NP-hard, and several exact and approximation algorithms have been developed for it. In this paper, we propose a novel exact dynamic programming (DP) algorithm for the TMP. The worst-case time complexity of this algorithm (which is exponential in the number of destinations and linear in the number of railcars) is lower than that of the best presently available algorithm for the problem, which is an inclusion-exclusion-based DP algorithm. In practice, the proposed algorithm can provide a substantially improved performance compared to its inclusion-exclusion-based counterpart, as demonstrated by the experimental results.
cs.DS
cs
ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 1 A Novel Dynamic Programming Approach to the Train Marshalling Problem Hossein Falsafain and Mohammad Tamannaei Abstract -- Train marshalling is the process of reordering the railcars of a train in such a way that the railcars with the same destination appear consecutively in the final, reassembled train. The process takes place in the shunting yard by means of a number of classification tracks. In the Train Marshalling Problem (TMP), the objective is to perform this rearrangement of the railcars with the use of as few classification tracks as possible. The problem has been shown to be NP-hard, and several exact and approximation algorithms have been developed for it. In this paper, we propose a novel exact dynamic programming (DP) algorithm for the TMP. The worst-case time complexity of this algorithm (which is exponential in the number of destinations and linear in the number of railcars) is lower than that of the best presently available algorithm for the problem, which is an inclusion-exclusion-based DP algorithm. In practice, the proposed algorithm can provide a substantially improved per- formance compared to its inclusion-exclusion-based counterpart, as demonstrated by the experimental results. Index Terms -- Dynamic Programming, Fixed Parameter Tractability, NP-Hard Combinatorial Optimization Problems, Rail Transportation, Shunting Yards, Train Marshalling Problem I. INTRODUCTION In a shunting yard (a.k.a. classification or marshalling yard), the railcars of an incoming (inbound) train are uncoupled, rearranged, and then reassembled to form an outgoing (out- bound) train [1] -- [4]. A shunting yard consists of multiple parallel classification tracks (a.k.a. auxiliary rails) on which partial outbound trains can be assembled before being pulled together to form an outbound train. In a shunting yard, one primary objective is to rearrange the railcars of an inbound train into groups that share the same destination [3], [5] -- [8]. These groups, which we refer to as blocks, are then coupled together to form a new outbound train. This process is referred to as train marshalling, and is accomplished by means of a number of classification tracks. While a shunting yard has only a limited number of classification tracks, there may be several trains to be processed at the same time. Therefore, it is obvious that the aim should be to keep the number of classification tracks per inbound train as small as possible [6], [9], [10]. In the Train Marshalling Problem (TMP), using as few classification tracks as possible is the only objective [2], [11]. For a detailed survey about other commonly used and more recent train classification methods (from an algorithmic point of view), see [4]. 9 1 0 2 r a M 0 2 ] S D . s c [ 1 v 4 6 3 8 0 . 3 0 9 1 : v i X r a H. Falsafain is with the Department of Electrical and Computer Engineer- ing, Isfahan University of Technology, Isfahan 84156-83111, Iran (e-mail: [email protected]). M. Tamannaei is with the Department of Transportation Engineer- ing, Isfahan University of Technology, Isfahan 84156-83111, Iran (e-mail: [email protected]). Let an inbound train T be given. In the TMP, in its optimization version, the goal is to find the minimum number of classification tracks needed to rearrange the railcars of T in such a way that the railcars sharing the same destination are grouped together. (Obviously, the number of classification tracks needed for a train is never more than the number of destinations.) The decision version of the problem can be stated as follows: Given an inbound train T and a positive integer k, decide whether or not the railcars of T can properly be rearranged by means of at most k classification tracks. The TMP has been proved to be NP-hard (using a re- duction from the numerical matching with target sums prob- lem) [6]. Generally, approaches for solving a particular NP- hard problem can be classified into two main categories: exact and inexact methods. Exact methods are guaranteed to find an optimal solution if one exists (see, e.g., [5], [12], [13]). However, they generally require exponential time in the worst case. If the actual instances are small-to-moderate-sized, such algorithms may be perfectly satisfactory. The worst- case exponential complexity is acceptable if the algorithm is effective and fast enough for the problem instances appearing in the specific application considered [14], [15]. For some interesting discussions on exact algorithms in general, the reader is referred to [15] -- [17]. Inexact techniques, on the other hand, can find reasonable suboptimal solutions in polynomial time. Inexact methods themselves can be grouped into two families: approximation algorithms, which guarantee to return a (suboptimal) solution that is within a certain factor of the op- timal solution (see, e.g., [18], [19]), and heurstic/metahueristic approaches, which do not offer any performance guarantee but have been found to be very successful in solving NP- hard problems (see, e.g., [3], [12], [13], [20] -- [23]). It should be noted that some tractable cases of the TMP have been identified in the literature [24], [25]. In fact, some special cases of an NP-hard problem may be solvable in polynomial time [14]. (Reference [24] is the paper in which the TMP originally posed.) In [25], Dahlhaus et al. showed that the problem is approx- imable within ratio 2. In [11], both online and offline versions of the TMP have been considered. In the offline scenario, some basic results and lower bounds on the optimal solutions have been presented. Furthermore, an analysis of the online version of the problem and a 2-competitive deterministic greedy online algorithm have been provided. It has also be shown that the competitive factor of 2 is indeed best possible among all deterministic online algorithms. In [26], Brueggeman et al. established that the TMP is fixed parameter tractable with respect to the number of classification tracks k. To be more precise, if an inbound train T with n railcars having t different c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 2 destinations, and a positive integer k are given, then for deciding whether or not the railcars of T can be rearranged in an appropriate order by using at most k classification tracks, the algorithm proposed in [26] requires O(2O(k)poly(n)) time and O(n2k28k) space. The algorithm is based on the dynamic programming (DP) paradigm. Finally, very recently, Rinaldi and Rizzi have developed an exact dynamic programming algorithm for the problem in which the TMP is solved as a problem of finding a rainbow path in an edge-colored directed graph [5]. This algorithm, which is based on the principle of inclusion-exclusion, is of time complexity O(nkt22t) and space complexity O(nkt). This implies that the TMP is fixed parameter tractable with the number of destinations t. The readily apparent advantage of this approach is its polynomial space complexity. When used to solve the optimization version of the TMP, in a binary search fashion, the time complexity of the approach becomes O(nt22tU log2 U ), where U is an upper bound on the optimal number of classification tracks. Although elegant, this procedure only returns the value of an optimal solution, i.e. the minimum number of required classification tracks, but not an optimal solution itself. In this paper, we propose a novel exact DP algorithm for the TMP. DP is indeed an approach of great importance in the de- sign of both polynomial-time and exponential-time algorithms [14] -- [17]. In contrast to the exact methods described in [5], [26], our method is developed to directly solve the optimization version of the TMP (i.e., it does not need to make successive calls to a procedure that solves the decision version of the problem).1 The proposed algorithm is capable of finding not only the minimum number of required classification tracks, but also the classification track that each railcar is assigned to, in an optimal solution, as well. The algorithm is of worst-case time complexity O(nt2t) and worst-case space complexity O(n2t). The Numerical experiments presented in Section IV demonstrate that the algorithm substantially outperforms its inclusion-exclusion-based counterpart in terms of computation time. The outline of this paper is as follows. In Section II, we provide some notations, and present a rigorous formulation of the TMP. Section III is dedicated to the presentation of our novel dynamic programming algorithm for the TMP. Section IV is devoted to experimental results, and to numerical comparisons with the best currently available approach to the problem. (We extensively compared our technique with the approach presented in [5].) Finally, some concluding remarks are given in Section V. 1It should be remembered that, there is not a significant difference between the optimization version of the TMP and its decision version. Obviously, an algorithm that can solve the optimization version of the problem, can automatically solve the decision version as well (for any given k ∈ N). On the other hand, if one can solve the decision version of the TMP for any given k, then one can also minimize the number of classification tracks needed to obtain a train of desired property: For a given inbound train T with n railcars having t different destinations, the decision version of the problem is solved repeatedly, by incrementally increasing the value of k from 1. When the answer turns from "no" to "yes", then the solution is at hand. Furthermore, using binary search (instead of linear search), one needs to solve the decision version only for O(log2 U ) different values of k, where U is an upper-bound on the optimal number of classification tracks. II. NOTATIONS AND PROBLEM STATEMENT and (cid:83) We begin this section by introducing some notation that will be used throughout the paper. For a positive integer N ∈ N, we denote by [N ] the set {1, 2, . . . , N}. Each railcar of the train is identified by its index. The order of the railcars in the inbound train corresponds therefore to the sequence (cid:104)1, 2, . . . , n(cid:105). By a block, we refer to an increasing sequence consisting of all railcars that share the same destination. A TMP instance can be described by a triple (n, t,B), where n is the number of railcars of the train, t is the number of destinations, and B is the set of all blocks. (Obviously, B = t B∈B B = [n].) The objective is to find the smallest number of classification tracks by which the inbound train can be rearranged according to the destinations. The railcars are considered one after another according to their order in the inbound train. The railcars assigned to each classification track form a sequence. In fact, each railcar is guided to one of the classification tracks, and placed behind the already sequenced railcars. The outbound train is obtained by reassembling the railcars on the first track (based on their order of arrival) followed by the railcars on the second track and so on. Fig. 1. A depiction of the rearrangement process. The letter 'A' corresponds to the first destination, the letter 'B' corresponds to the second destination, and the letter 'C' corresponds to the third destination. Example 1. Figure 1 depicts an instance of the problem in which n = 9, t = 3, and the set of blocks is B = {(cid:104)1, 3, 5(cid:105),(cid:104)2, 6, 8(cid:105),(cid:104)4, 7, 9(cid:105)}. As can be seen from the figure, to rearrange the railcars according to their destinations, only two classification tracks are needed. The TMP can be stated in an equivalent way, which is more convenient for our purposes:2 Let an instance (n, t,B) of the TMP be given. We define A(n) to be an infinite sequence obtained by concatenating infinitely many copies of the sequence (cid:104)1, 2, . . . , n(cid:105). We refer to each subsequence (cid:104)1, 2, . . . , n(cid:105) of A(n) as a segment. (We will shortly see that each segment corresponds to a classification track.) The entries of A(n) can be seen as unoccupied positions in which the B∈B B = [n] can be placed. Each element of the set [n] must occur exactly once in A(n). The occurrence of elements of (cid:83) 2This alternative statement of the problem has been proposed by Donald E. Knuth, in a personal letter to the authors of [6]. c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. 987654321CACABCBAB86531AABBB9742CCCAInbound Train974286531CCCAAABBBOutbound Train ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 3 the element i ∈ [n] in the κth segment of A(n) is equivalent to the assignment of the ith railcar of the inbound train to the κth classification track. It can readily be verified that a placement in which the elements of every block B ∈ B occur right next to each other, leads to a solution to the given TMP instance, and vice versa. (We refer to such a placement as a solution as well.) More precisely speaking, a placement can be considered as a solution if and only if for every two distinct blocks B and B(cid:48) in B, none of the elements of B occur in the interval occupied by the elements of B(cid:48). It is now clear that, in the alternative statement of the TMP, the aim is to find a placement that uses the minimum number of segments. In other words, the goal is to find a permutation π of the set [t] such that the occurrence of the blocks of B one after another, in the order specified by π, uses the least number of segments. In the following, we stick to the above-described alternative statement of the problem. Example 2. Consider the following instance of the TMP: (n = 17, t = 5, B = {B1 = (cid:104)1, 4, 10(cid:105), B2 = (cid:104)5, 12, 14(cid:105), B3 = (cid:104)11, 13, 17(cid:105), B4 = (cid:104)2, 3, 8, 9(cid:105), B5 = (cid:104)6, 7, 15, 16(cid:105)}). (1) In a solution to the above-given instance, the elements of B1 and B2 may appear in A(17) in the following way: (cid:104). . . , 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 , 11, (cid:124) (cid:123)(cid:122) B1 (cid:124) (cid:125) (cid:123)(cid:122) B2 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, 5 (cid:125) , 6, . . .(cid:105). It should be remarked that we defined a block as an increasing sequence consisting of all railcars that share the same desti- nation, but the element of a block B ∈ B do not necessarily appear in A(n) in an increasing order. The following is an optimal solution for the TMP instance described by (1), which uses three segments: (cid:104)1, 2, 3, 4, 5, 6, 7, 8, 9 , 10, 11, 12, 13, 14, 15, 16, 17 , (cid:124) (cid:124) (cid:123)(cid:122) B4 (cid:123)(cid:122) (cid:124) B1 (cid:125) (cid:125) (cid:124) (cid:124) (cid:123)(cid:122) B5 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 , 11, 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, 5 , B2 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 , 17, . . .(cid:105). (cid:125) (cid:123)(cid:122) B3 (cid:123)(cid:122) (cid:125) (cid:125) (2) This solution is depicted schematically in Figure 2. Before proceeding further, we need to impose a number of simplifying assumptions, which can be made without loss of generality. Let an instance (n, t,B) of the TMP be given. We can confine our attention to those solutions of this instance in which, firstly, there are no "unused positions" before the first element of the first block of B that appears in A(n); secondly, there are no unused positions between the elements of two adjacent blocks; and finally, if B is an arbitrary block in B, then the elements of B occur in A(n) contiguous with each other, i.e., without any unused positions between them. Collectively, the above three cases indicate that we can, without loss of generality, narrow our attention to only those solutions in which there are no positions left unused, neither within the range of appearance of the elements of a single block B ∈ B, nor between the elements of two successive blocks, nor before the first block of B that appears in A(n). Example 3. In a solution to the TMP instance described by (1), the elements of B4 = (cid:104)2, 3, 8, 9(cid:105) may appear in A(17) as follows: (cid:104). . . , 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, . . .(cid:105). But in this placement, there is an unused position between the elements 2 and 8, because the element 3 has not been placed immediately after 2. However, placing the elements of B4 one next to the other, as required by the assumptions, can lead to a solution that is at least as good: (cid:104). . . , 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, . . .(cid:105). As another example, in a solution to the TMP instance given by (1), the elements of the blocks B4 and B5 can appear in A(17) as follows: (cid:104). . . , 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 , 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1, 2, 3 (cid:124) (cid:123)(cid:122) B4 (cid:125) , 4, . . .(cid:105). But in this placement, there are two unused positions between 16 (the last appearance of an element of B5) and 8 (the first appearance of an element of B4), which can contain the elements 2 and 3 of B4. By placing these two elements immediately after 16, we obtain a solution that satisfies our assumptions, and is at least as good: (cid:104). . . , 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 , 17, B4 B5 (cid:124) (cid:123)(cid:122) , 10, . . .(cid:105). 1, 2, 3, 4, 5, 6, 7, 8, 9 (cid:125) impose the condition that none of the elements of (cid:83) We conclude this section by introducing two more notations. Let an instance (n, t,B) of the TMP be given, and let i ∈ [n]. For reasons that will become clear in what follows, we may B∈B B could be placed before the ith position of the first segment of A(n). In the presence of this condition, we specify the instance by a quadruple (n, t,B, i). We will refer to such instances as TMP instances as well. (According to this notation, a TMP instance (n, t,B) can be expressed as (n, t,B, 1).) Finally, in this paper, the notation '+n' symbolizes the usual modulo-n addition, except that if the result is 0, it is replaced by n. Therefore, for example, 16 +17 1 = 17 and 17 +17 1 = 1. III. A DYNAMIC PROGRAMMING APPROACH TO THE TRAIN MARSHALLING PROBLEM Let an instance (n, t,B, i) of the TMP be given, and let B = (cid:104)i1, i2, . . . , i(cid:96)(cid:105) be the first block of B that appears in A(n). The (cid:123)(cid:122) B5 (cid:123)(cid:122) (cid:124) (cid:124) (cid:125) (cid:125) c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 4 Fig. 2. A depiction of the optimal solution (2) to the TMP instance given in (1). The letter 'A' corresponds to the first block, the letter 'B' corresponds to the second block, and so on. first element of B that appears in A(n) is its smallest element that is greater than or equal to i. If no such element exists, then the first occurrence of an element of B in A(n) is i1, which in fact occurs in the second segment. We denote the first occurrence of an element of B in A(n) by α(i, B), and the last occurrence of an element of B in A(n) by ω(i, B). Under the condition that none of the elements of B can be placed before the ith position of the first segment of A(n), there are two different cases to consider. The aim in examining these cases is to investigate what happens when the first available position in the first segment of the sequence A(n) is i, and the block whose elements appear immediately following i is B. The cases are as follows: • Case 1, i ≤ i1 or i(cid:96) < i: In this case, the first element of B that appears in A(n) is i1, the last element of B that appears in A(n) is i(cid:96), and i(cid:96) occurs in the same segment as i1. According to the above-defined notations, we have α(i, B) = i1 and ω(i, B) = i(cid:96). If i(cid:96) < i, then none of the elements of B can be placed in the first segment. Therefore, i1 and i(cid:96) both occur in the second segment. • Case 2, i1 < i ≤ i(cid:96): In this case, we have il < i ≤ il+1 for some l ∈ [(cid:96) − 1]. The first element of B that appears in A(n) is il+1 (i.e., α(i, B) = il+1), and the last element of B that appears in A(n) is il (i.e., ω(i, B) = il). Notice that α(i, B) = il+1 occurs in the first segment, but ω(i, B) = il occurs in the second segment. Therefore, the elements of B appear in A(n) in the following order: (cid:124) (cid:123)(cid:122) il+1, il+2, . . . , i(cid:96)−1, i(cid:96) , i1, i2, . . . , il . In the first segment In the second segment (cid:125) (cid:124) (cid:123)(cid:122) (cid:125) In Case 1, if i(cid:96) < n, then the block B does not completely exhaust its containing segment. This means that there remain n − i(cid:96) positions available in the segment (i.e., i(cid:96) + 1, i(cid:96) + 2, . . . , n), in which the elements of the next block may occur. Otherwise (i.e., if i ≤ i1 and i(cid:96) = n), the block B completely exhausts its containing segment (which is the first segment). This means that the (yet-to-be-placed) block in B that immediately follows B, starts somewhere in the second segment. To distinguish between the cases in which B exhausts the first segment and the cases in which there remains at least one position in the first segment that can be utilized for the placement of the block that follows B, we define an [n] × B (cid:55)→ {0, 1} as follows. (The indicator function δ : symbol × denotes the Cartesian product.) Let i ∈ [n] and B ∈ B be given. δ(i, B) takes the value 1 if ω(i, B) occurs in the last position of the first segment (i.e., ω(i, B) = n) or occurs somewhere in the second segment, and 0 otherwise (i.e., if ω(i, B) occurs in the first segment and ω(i, B) < n). Therefore, (cid:40) δ(i, B) = i ≤ i1 and i(cid:96) < n, 0, 1, otherwise. (3) (cid:83) We are now ready to describe the algorithm. Let (n, t,B) be a given TMP instance. Our algorithm will make use of an n × 2t table K whose rows are labeled by the elements of [n], and whose columns are labeled by the subsets of B. For a nonempty subset B(cid:48) of B, and an integer i ∈ [n], we define K[i,B(cid:48)] (the entry at row i and column B(cid:48) of K) to be the minimum number of segments needed for placing the elements of B(cid:48) in A(n), with the restriction that the first element of B∈B(cid:48) B cannot appear before the ith position of the first segment. It can clearly be seen from the above definition that the goal is in fact to find K[1,B]. The most crucial component of a dynamic programming algorithm is a recurrence relation that expresses the optimal solution to an instance (recursively) in terms of optimal solutions to smaller subinstances. Our aim here is to derive such a recurrence relation. In fact, although we are interested only in K[1,B], we need to find the values of the entries of K corresponding to smaller instances of the problem. One question to be addressed here is that what does small mean in this context? Some notion of the "size" of a subinstance is required here. We sort the subinstances by size (from smallest to largest), and solve them in increasing order of size. As we shall see shortly, the only factor that determines the size of the subinstance corresponding to K[i,B(cid:48)] is indeed the size of B(cid:48). The objective here is to derive a recurrence for K[i,B(cid:48)]. To derive this underlying recurrence relation, we need to c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 C E E B C B C A D D E E B A D D A 16 15 7 6 5 14 12 10 4 1 17 13 11 9 8 3 2 E E E E B B B A A A C C C D D D D 17 13 11 9 8 3 2 C C C D D D D 14 12 10 4 1 B B A A A 16 15 7 6 5 E E E E B Inbound Train Outbound Train ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 5 that none of the elements of(cid:83) consider all possible ways to choose the first block of B(cid:48) that appears in A(n). If B is the first block of B(cid:48) that appears in A(n), then according to our definition of K[i,B(cid:48)], the minimum number of segments needed for placing the elements of the remaining blocks in the sequence A(n) is K[ω(i, B) +n 1,B(cid:48) \ {B}]. Therefore, under the restriction B∈B(cid:48) B is permitted to appear before the ith position of the first segment, if B is the first block of B(cid:48) that appears in A(n), then the blocks of B(cid:48) together occupy δ(i, B) + K[ω(i, B) +n 1,B(cid:48) \{B}] segments. Hence, we have the following recurrence: B∈B(cid:48) {δ(i, B) + K[ω(i, B) +n 1,B(cid:48) \ {B}]} . (4) Therefore, the recursive property that yields the optimal solution value of the original instance of the problem is K[1,B] = minB∈B {δ(1, B) + K[ω(1, B) +n 1,B \ {B}]}. This implies that to obtain the value of an optimal solution to the original instance (n, t,B, 1), we need to determine the optimal solution values of the following t subinstances: for each B ∈ B. (n − B, t − 1,B \ {B}, ω(1, B) +n 1), It remains to specify the initial conditions. We define the initial conditions as K[i,B(cid:48)] = min (cid:40) K[i, ∅] = if i = 1, 0, 1, otherwise. The rationale behind this definition is as follows. Assume that in a solution to a given TMP instance (n, t,B), the (t − 1)th block (i.e., the next-to-last block) of B that appears in A(n), ends at the ith position of the κth segment, i ∈ [n]. If the last block of B that appears in A(n) is B ∈ B, then we have the following equation, which is obtained by setting i = i +n 1 and B(cid:48) = {B} in equation (4): K[i+n 1,{B}] = δ(i+n 1, B)+K[ω(i+n 1, B)+n 1, ∅], (5) There are three cases to consider. The first case indicates that K[1, ∅] = 0, and the second and third cases together imply that if i (cid:54)= 1, then K[i, ∅] = 1: • If ω(i +n 1, B) = n, then we necessarily have K[i +n 1,{B}] = 1. Moreover, according to Equation (3), δ(i+n 1, B) = 1. Now, Equation (5) implies that K[ω(i +n 1, B) +n 1, ∅] = 0. Since ω(i +n 1, B) = n, we have K[1, ∅] = 0. Notice that, in this case, the block B starts and ends at the κth segment. • If ω(i +n 1, B) < n and δ(i +n 1, B) = 0, then we necessarily have K[i +n 1,{B}] = 1. Now, Equation (5) implies that K[ω(i +n 1, B) +n 1, ∅] = 1. In this case, as in the first case, the block B starts and ends at the κth segment. • If ω(i +n 1, B) < n and δ(i +n 1, B) = 1, then we must have K[i +n 1,{B}] = 2. Again, Equation (5) implies that K[ω(i+n 1, B)+n 1, ∅] = 1. In this case, as opposed to the first two cases, the block B either starts at the κth segment and ends at the (κ + 1)th segment, or starts and ends at the (κ + 1)th segment. The (bottom-up table-based) version of our dynamic pro- the Train Marshalling Problem, gramming algorithm for the procedure BOTTOM-UP-DP-TMP, is presented in Algo- rithm 1. The correctness of this algorithm follows directly from (4). Notice that in the table K, the only entry in the column corresponding to B that we need to compute is K[1,B]. Hence, BOTTOM-UP-DP-TMP does not compute all the entries of this column, but only K[1,B] (see line 16). Although this procedure determines the minimum number of classification tracks needed to rearrange the railcars in an appropriate order, it does not directly show how to rearrange them. Therefore, besides the minimum number of needed classification tracks, it returns a table T using which an optimal solution itself can be constructed. (This table provides us with the information we need to do so.) T has its rows indexed by the elements of [n] and its columns indexed by the subsets of B. The entry T [i,B(cid:48)] contains the first block that appears in A(n) in an optimal solution to the TMP instance(cid:0)(cid:12)(cid:12)(cid:83) B∈B(cid:48) B(cid:12)(cid:12) ,B(cid:48) ,B(cid:48), i(cid:1). Using this table, the procedure PRINT-OPTIMAL-SOLUTION, which is shown in Algorithm 2, prints out an optimal solution to a given TMP instance. The rationale behind this procedure is easy to grasp, so we omit a detailed discussion. In BOTTOM-UP-DP-TMP, the time in both the first loop (lines 5 -- 7) and the last loop (line 16) is insignificant compared to the time in the middle loop (lines 8 -- 15), because the middle loop contains various levels of nesting. (The loops are nested four deep.) The time complexity of this nested loop is (cid:18)t (cid:19) j t−1(cid:88) j=1 (cid:19) (cid:18)t − 1 j − 1 t t−1(cid:88) j=1 n j = n = nt (cid:18)t − 1 (cid:19) t−2(cid:88) j j=0 = nt(2t−1−1). Therefore, the time complexity of the whole algorithm is also in O(nt2t). It can easily be verified that the space complexity of the algorithm is O(n2t). If we need only the value of an optimal solution, and not an optimal solution itself, then we do not need to compute the table T anymore. Moreover, in such a case, if Kj denotes the subtable of K consisting of columns whose corresponding subsets of B are of size j, 1 ≤ j ≤ t, then for computing the entries of Kj, we only need the entries of Kj−1. By virtue of this fact, the memory complexity of . (With BOTTOM-UP-DP-TMP can be reduced to O (cid:1)(cid:17) respect to the facts that the number of j-subsets of B is(cid:0)t (cid:1) is the largest of the binomial coefficients (cid:0)t and that (cid:0) t(cid:98) t n(cid:0) t(cid:98) t (cid:1), (cid:1), (cid:16) 2(cid:99) j j 0 ≤ j ≤ t.) 2(cid:99) The time complexity of the procedure BOTTOM-UP-DP- TMP is better than that of the best currently known algorithm for the TMP [5]. However, it still has room for improvement. We will now discuss some modifications that can be made to improve the effectiveness of this procedure. We first state two lemmas. Lemma 1. Let an instance (n, t,B) of the TMP be given. When applying the procedure BOTTOM-UP-DP-TMP to this instance, for each B(cid:48) ⊆ B, the entries K[i +n 1,B(cid:48)], i ∈ (cid:91) B∈B(cid:48) B, are not required to be computed. Proof. It can be observed from lines 11 and 16 of BOTTOM- UP-DP-TMP that for any i ∈ [n] and any B(cid:48) ⊆ B, the c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 6 Algorithm 1 A (bottom-up table-based) dynamic programming algorithm for the TMP. Input: An instance (n, t,B) of the Train Marshalling Problem; Output: The minimum number kopt of classification tracks needed to obtain a desired rearrangement of the railcars, and a (two-dimensional) table T from which an optimal solution can be constructed; Let K be a new table whose rows are labeled from 1 through n, and whose columns are labeled by the subsets of B; Let T be a new table with the same dimensions as K; K[1, ∅] = 0; for i = 2 to n do K[i, ∅] = 1; end for for j = 1 to t − 1 do for all subsets B(cid:48) of B of size j do 1: procedure BOTTOM-UP-DP-TMP(n, t, B) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: end procedure for i = 1 to n do end for end for K[i,B(cid:48)] = minB∈B(cid:48) {δ(i, B) + K[ω(i, B) +n 1,B(cid:48) \ {B}]}; T [i,B(cid:48)] = an arbitrary element of the set argminB∈B(cid:48) {δ(i, B) + K[ω(i, B) +n 1,B(cid:48) \ {B}]}; end for kopt = minB∈B {δ(1, B) + K[ω(1, B) +n 1,B \ {B}]}; T [1,B] = an arbitrary element of the set argminB∈B {δ(1, B) + K[ω(1, B) +n 1,B \ {B}]}; return kopt and T ; Algorithm 2 A procedure for constructing an optimal solution to a given TMP instance using the table T returned by the procedure BOTTOM-UP-DP-TMP. Input: An instance (n, t,B) of the Train Marshalling Problem, and the table T returned by the procedure BOTTOM-UP- DP-TMP; Output: An optimal solution to the given TMP instance; B(cid:48) = B; i = 1; while B(cid:48) (cid:54)= ∅ do B = T [i,B(cid:48)]; Print B; B(cid:48) = B(cid:48) \ {B}; i = ω(i, B) +n 1; 1: procedure PRINT-OPTIMAL-SOLUTION(n, t, B, T ) 2: 3: 4: 5: 6: 7: 8: end while 9: 10: end procedure . Now, B∈B\B(cid:48) B B∈B(cid:48) B(cid:9) = [n] \ entry K[i,B(cid:48)] is required to be computed only if for some h ∈ [n] and some B ∈ B \ B(cid:48), we have i = ω(h, B) +n 1. It is not difficult to verify that {ω(h, B) +n 1 h ∈ [n], B ∈ B \ B(cid:48)} = in the col- umn corresponding to B(cid:48), none of the entries whose row (cid:111) (cid:110) h +n 1 h ∈(cid:83) indices belong to the set (cid:8)h +n 1 h ∈(cid:83) (cid:110) (cid:111) h +n 1 h ∈(cid:83) B(cid:48) ⊆ B be given, and let (cid:96) = (cid:80) sequence whose elements are the elements of (cid:83) Lemma 2. Consider an instance (n, t,B) of the TMP. Let B∈B(cid:48) B. (B denotes the length of B.) Let σ(B(cid:48)) = (cid:104)i1, i2, . . . , i(cid:96)(cid:105) be an increasing B∈B(cid:48) B. If l ∈ [(cid:96) − 1], then for all distinct integers il < i, i(cid:48) ≤ il+1 we have K[i,B(cid:48)] = K[i(cid:48),B(cid:48)]. This fact holds also for all distinct integers 1 ≤ i, i(cid:48) ≤ i1, and all distinct integers i(cid:96) < i, i(cid:48) ≤ n. need to be computed. B∈B\B(cid:48) B of (cid:83) Proof. Let il < i (cid:54)= i(cid:48) ≤ il+1, for some l ∈ [(cid:96) − 1]. In the optimal solutions corresponding to the entries K[i,B(cid:48)] and K[i(cid:48),B(cid:48)], no matter which block occurs first, the first element B∈B(cid:48) B cannot appear before the il+1th position of the first segment. Therefore, due to our definition of the table K, it can be verified that K[i,B(cid:48)] = K[i(cid:48),B(cid:48)] = K[il+1,B(cid:48)]. The proof of the remaining assertions of the lemma (i.e., K[i,B(cid:48)] = K[i(cid:48),B(cid:48)] for 1 ≤ i (cid:54)= i(cid:48) ≤ i1, and K[i,B(cid:48)] = K[i(cid:48),B(cid:48)] for i(cid:96) < i (cid:54)= i(cid:48) ≤ n) is analogous. B∈B(cid:48) B(cid:9) do not need to be computed. long to(cid:8)h +n 1 h ∈(cid:83) (cid:83) The first lemma asserts that, in the column of the table K corresponding to B(cid:48), the entries of the rows whose indices be- The second lemma states that, if σ(B(cid:48)) = (cid:104)i1, i2, . . . , i(cid:96)(cid:105) is an increasing sequence whose elements are the elements of B∈B(cid:48) B, then in the column of the table K correspond- ing to B(cid:48), the entries of the rows whose indices belong c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 7 to {1, 2, . . . , i1} are all equal to each other, the entries of the rows whose indices belong to {il + 2, il + 3 . . . , il+1}, l ∈ [(cid:96) − 1], are all equal to each other, and the entries of the rows whose indices belong to {i(cid:96) + 2, i(cid:96) + 3 . . . , n} are all equal to each other. It should be highlighted that, if for some l ∈ [(cid:96) − 1], il and il+1 are two consecutive integers, then {il + 2, il + 3 . . . , il+1} is empty. Therefore, we do not need to do anything about it, which means even less computational effort. Similarly, if i(cid:96) = n − 1, then {i(cid:96) + 2, i(cid:96) + 3 . . . , n} is empty, and the same conclusion holds. Example 4. Consider the TMP instance given by (1). For the subset B(cid:48) = {B1, B2, B3} of B, we have σ(B(cid:48)) = (cid:104)1, 4, 5, 10, 11, 12, 13, 14, 17(cid:105). Therefore, only four entries in the column corresponding to B(cid:48) need be computed, one corresponding to each of the sets {1}, {3, 4}, {7, 8, 9, 10}, and {16, 17}. The other entries in this column either do not need to be computed at all or require to simply be retrieved according to Lemma 2. Without the aid of the above two lemmas, we need to obtain all n = 17 entries in this column. Now we are ready to present the improved version of our algorithm. The improved version, the procedure MEMOIZED- DP-TMP, which is detailed in Algorithm 3, is indeed a top-down (recursive) memoized version of the procedure BOTTOM-UP-DP-TMP that takes advantage of the results stated in Lemmas 1 and 2. In a bottom-up dynamic- programming algorithm, we fill a table with solutions to all smaller subinstances. But solutions to some of these smaller subinstances may not be necessarily required for obtaining a solution to the original instance. In fact, in a DP framework, we do not necessarily need to solve all the subinstances in order to find an optimal solution to the original problem. It is natural to try to develop an improved mechanism that solves only those subinstances that are necessarily needed. This approach is called Memoization [14]. The procedure MEMOIZED-DP-TMP, shown in Algorithm 3, exactly as in the procedure BOTTOM-UP-DP-TMP, makes use of a table, but it computes the entries of this table in an as-needed fashion. The table is initially filled with −1s. The value −1 indicates that the corresponding subinstance has not yet been solved. Indeed, the table entries initially contain −1 values to indicate that they have not yet been filled in. Whenever the optimal value of a subinstance needs to be obtained, the procedure LOOKUP, shown in Algorithm 3, checks the corresponding entry in the table K first. If the entry is not equal to −1, it is simply retrieved from the table (lines 2 -- 4 of the procedure LOOKUP); otherwise, it is computed by making recursive calls (line 5 of the procedure LOOKUP). The result is then recorded in the table with respect to Lemmas 1 and 2. This means that when the value of the (i,B(cid:48))-entry of K is computed recursively, then the result is stored not only in the entry itself, but also in the entries whose values are equal to that of the (i,B(cid:48))-entry by virtue of Lemmas 1 and 2 (lines 8 -- 20 of the procedure LOOKUP). Notice that the procedure MEMOIZED- DP-TMP only returns the value of an optimal solution. This is for the sake of brevity and clarity. It can easily be modified so that it can produce the table T , which is required as an input to PRINT-OPTIMAL-SOLUTION, as well. IV. COMPUTATIONAL RESULTS This section is devoted to evaluating the performance of the proposed technique against the best currently available approach to the TMP, which is a DP procedure based on the principle of inclusion-exclusion, proposed in [5]. The comparison has been made using 540 randomly generated instances of the TMP, in its optimization version (10 instances for each considered value of n and t).3 No experimental results have been reported in [5]. The following results are therefore based on our own implementation of the algorithm described in [5]. Care was taken to implement the algorithms as efficiently as possible. However, this certainly does not mean that there is no room for improvement. The algorithms have been implemented in Maple 18.00, and the experiments have been carried out on an Intel Core i5-3330 CPU at 3.0 -- 3.2 GHz desktop computer with 4.00 GB of RAM, running Microsoft Windows 8.1 operating system. Before going further, let us describe a simple preprocessing step that, without altering the optimal value, can reduce the number of railcars in the input instance (see [5, Lemma 1]). This consequently can reduce the execution time of the al- gorithms. Let an instance (n, t,B) of the TMP be given. If there exist n(cid:48) ≥ 2 consecutive railcars that all share the same destination, then the instance (n − n(cid:48) + 1, t,B(cid:48)) obtained by keeping only one of these railcars and removing the others, has the same optimal value as the original. Therefore, we can safely shrink the number of railcars in the given instance by repeatedly eliminating all such railcars. A comparison of the average running times (in seconds) of our method (the procedure MEMOIZED-DP-TMP) against those of the method of [5] is tabulated in Table I. As stated above, for each considered value of n and t, 10 instances have been solved. The table reports the average solution time per instance. In all runs, we imposed a time limit of 5000 seconds. In the table, "TLE" stands for "Time Limit Exceeded." It should be noticed that the method of [5] is inherently designed for solving the decision version of the TMP. But it can be employed for solving the optimization version of the problem as well, by means of a binary search procedure, as stated in Section I. The resulting algorithm is of time complexity O(nt22tU log2 U ), where U is an upper- bound on the optimal number of classification tracks. In our implementation of the approach of [5], we have used the 4 + 1 2 upper bound U = min(cid:8)t,(cid:6) n (cid:6) n (cid:7)(cid:9). (Trivially, the minimum (cid:7). See also [5, Theorem 3].) Using a more restrictive number of classification tracks needed for rearranging the railcars in an appropriate order is at most t. Furthermore, it has been shown in [6, Section 3] that the value of an optimal solution to a TMP instance with n railcars is at most 4 + 1 upper bound, can obviously reduce the number of calls to a procedure for solving the decision problem (during the binary 2 3The literature on the Train Marshalling Problem is relatively recent. To our knowledge, there is no benchmark dataset available in the literature for the problem. We therefore created our own dataset, which introduces a rather wide range of TMP instances, with varying values of n and t. We have made all the problem instances, as well as their optimal solutions, available online on the webpage https://github.com/hfalsafain/Train-Marshalling-Problem. All codes will also be made available to download after publication. c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 8 Algorithm 3 A memoized top-down dynamic programming algorithm for the TMP. Input: An instance (n, t,B) of the Train Marshalling Problem; Output: The minimum number of classification tracks needed to obtain a desired rearrangement of the railcars; 1: procedure MEMOIZED-DP-TMP(n, t,B) 2: 3: 4: 5: 6: 7: 8: 9: end procedure Let K be a new table whose rows are labeled from 1 through n, and whose columns are labeled by the subsets of B; Initialize all entries of K to −1; K[1, ∅] = 0; for i = 2 to n do K[i, ∅] = 1; end for return minB∈B {δ(1, B) + LOOKUP(K, ω(1, B) +n 1,B \ {B})}; end if k = minB∈B(cid:48) {δ(i, B) + LOOKUP(K, ω(i, B) +n 1,B(cid:48) \ {B})}; Let (cid:96) =(cid:80) Let σ = (cid:104)i1, i2, . . . , i(cid:96)(cid:105) be an increasing sequence whose elements are the elements of(cid:83) B∈B(cid:48) B; if K[i,B(cid:48)] (cid:54)= −1 then return K[i,B(cid:48)]; B∈B(cid:48) B; if 1 ≤ i ≤ i1 then for i = 1 to i1 do K[i,B(cid:48)] = k; 1: procedure LOOKUP(K, i,B(cid:48)) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: end procedure end if return k; for i = i(cid:96) + 2 to n do K[i,B(cid:48)] = k; end for end for else end for else if il + 2 ≤ i ≤ il+1 for some 1 ≤ l ≤ (cid:96) − 1 then for i = il + 2 to il+1 do K[i,B(cid:48)] = k; search procedure). However, our Algorithm 3 requires much less computation time, even compared to the time required for a single call to the algorithm given in [5] for solving a specific decision problem instance (i.e., for a specific value of k). For some of the considered values of n and t, Table II provides a comparison of the average running times of our procedure MEMOIZED-DP-TMP with those of each of the calls to the procedure described in [5] for solving the decision version of the problem (called as DTMP in [5, Algorithm 3]). As is evident from both Tables I and II, our algorithm substantially outperforms its inclusion-exclusion-based counterpart in terms of computation time. We conclude this section by making a remark concerning the space complexity of our approach. Given a TMP instance (n, t,B) and given k ∈ N, for deciding whether or not the railcars can be rearranged in an appropriate order by using at most k classification tracks, the algorithm described in [5] requires O(nkt22t) time and O(nkt) space. On the other hand, our approach, in its worst-case behavior, requires O(nt2t) time and O(n2t) space for making such a decision. Therefore, from the time complexity point of view, our approach is superior to the approach described in [5]. However, in contrast to the method of [5], our algorithm requires exponential space with respect to t.4 V. CONCLUSIONS In this contribution, we developed a novel dynamic pro- gramming approach to the Train Marshalling Problem (TMP) whose worst-case time complexity is linear in the number of railcars, exponential in the number of destinations. One 4As stated in Section I, the method of [5] does not return an optimal solution itself. In fact, this algorithm, when used for solving the decision version of the TMP, only returns a yes/no answer, and when used for solving the optimization version of the TMP (in the manner descrined in Section I), only computes the value of an optimal solution. On the other hand, as has been discussed in the previous section, our approach not only returns the value of an optimal solution, but also the solution itself. Although typically a dynamic programming algorithm that only returns the value of an optimal solution can easily be modified in such a way that it can return an optimal solution itself [14, Chapter 15], it seems to us that modification of the method of [5] so that it can construct an optimal solution itself leads to an exponential growth in the space complexity. c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 9 A COMPARISON OF THE AVERAGE RUNNING TIMES (IN SECONDS) OF OUR METHOD (THE PROCEDURE MEMOIZED-DP-TMP) AGAINST THOSE OF THE METHOD OF [5]. THE ACRONYM "TLE" STANDS FOR "TIME LIMIT EXCEEDED" TABLE I t = 7 153.997 0.196 249.447 0.245 337.292 0.294 710.131 0.522 1131.708 0.678 0.861 1.055 1.694 2.336 t = 5 12.019 0.042 18.067 0.053 24.219 0.061 50.036 0.075 78.106 0.103 0.119 0.139 0.206 0.288 t = 9 1114.678 1.228 1964.511 1.801 3288.679 2.225 TLE 3.775 TLE 5.260 TLE 7.044 TLE 8.602 TLE 12.958 TLE 17.233 TLE TLE TLE 470.611 144.902 269.347 t = 15 TLE t = 13 TLE 28.991 TLE 49.844 TLE 72.216 TLE t = 11 TLE 7.053 TLE 11.209 TLE 15.588 TLE 27.152 167.992 1157.106 TLE 30.840 227.534 1595.130 TLE 41.290 281.694 1918.972 TLE 48.536 348.833 2341.133 TLE 72.902 493.286 3438.906 TLE 97.056 677.042 4565.083 TLE TLE TLE TLE TLE TLE TLE TLE TLE TLE n 50 75 Approach Rinaldi & Rizzi (2017) Our Algorithm 3 Rinaldi & Rizzi (2017) Our Algorithm 3 100 Rinaldi & Rizzi (2017) Our Algorithm 3 200 Rinaldi & Rizzi (2017) Our Algorithm 3 300 Rinaldi & Rizzi (2017) Our Algorithm 3 400 Rinaldi & Rizzi (2017) 108.283 1599.885 500 Rinaldi & Rizzi (2017) 140.439 2112.443 750 Rinaldi & Rizzi (2017) 231.226 3248.614 Our Algorithm 3 Our Algorithm 3 Our Algorithm 3 Our Algorithm 3 1000 Rinaldi & Rizzi (2017) 334.431 4825.828 TABLE II A COMPARISON OF THE AVERAGE RUNNING TIMES OF OUR PROCEDURE MEMOIZED-DP-TMP WITH THOSE OF EACH OF THE CALLS TO THE PROCEDURE DTMP PRESENTED IN [5, ALGORITHM 3] n 50 500 1000 50 500 1000 50 t 5 5 5 7 7 7 9 100 9 Approach DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] MEMOIZED-DP-TMP DTMP [5, Algorithm 3] k = 2 k = 3 k = 4 k = 2 k = 3 k = 4 k = 2 k = 3 k = 4 k = 3 k = 4 k = 5 k = 6 k = 3 k = 5 k = 6 k = 3 k = 5 k = 6 k = 4 k = 5 k = 6 k = 7 k = 4 k = 6 k = 7 k = 8 MEMOIZED-DP-TMP Time (in secs.) 2.161 3.994 5.864 0.042 22.655 46.047 71.738 0.139 51.017 107.788 175.627 0.288 30.855 45.442 60.072 74.823 0.196 345.878 765.925 1000.639 1.055 737.058 1738.398 2350.372 2.336 269.248 359.379 446.749 555.890 1.228 526.833 897.484 1090.555 1289.678 2.225 noticeable difference between our approach and the previously proposed exact approaches to the TMP is that, in contrast with the previous works, our algorithm is designed to deal directly with the optimization version of the problem. The worst- case time complexity of our method, like that of previous is exponential with respect exact methods, to the number of destinations. However, in practice, our approach performs substantially better than the best currently available approach, which is an inclusion-exclusion-based dynamic programming algorithm. Our algorithm can effectively tackle instances with relatively large values of t. For example, it can solve, to optimality, instances involving 1000 railcars and 15 destina- tions in about 1 1 4 hours. The superior performance of the proposed technique can mainly be attributed to the following two reasons. Firstly, we group together the subinstances that have the same optimal solution. The optimal solution is computed only once for each group. Secondly, we employ the memoization technique to solve only those subinstances whose optimal solutions are necessarily needed to solve the original instance. In fact, the main benefit of this technique is that only those table entries that are needed are computed, whereas in the bottom-up implementation, all table entries get computed blindly. This can significantly reduce the amount of computation necessary. Another advantage of our method compared to its inclusion-exclusion-based counterpart is that our exact algorithm is capable of finding not only the value of an optimal solution (i.e., the minimum number of required classification tracks), but also the solution itself as well. REFERENCES [1] N. Boysen, S. Emde, and M. Fliedner, "The basic train makeup problem in shunting yards," OR Spectrum, vol. 38, pp. 207 -- 233, Jan 2016. [2] N. Boysen, M. Fliedner, F. Jaehn, and E. Pesch, "Shunting yard operations: Theoretical aspects and applications," European Journal of Operational Research, vol. 220, no. 1, pp. 1 -- 14, 2012. [3] J. T. Haahr and R. M. Lusby, "A matheuristic approach to integrate humping and pullout sequencing operations at railroad hump yards," Networks, vol. 67, no. 2, pp. 126 -- 138, 2016. [4] M. Gatto, J. Maue, M. Mihal´ak, and P. Widmayer, "Shunting for dummies: An introductory algorithmic survey," in Robust and Online Large-Scale Optimization, vol. 5868 of Lecture Notes in Computer Science, pp. 310 -- 337, Springer, 2009. [5] F. Rinaldi and R. Rizzi, "Solving the train marshalling problem by inclusion-exclusion," Discrete Applied Mathematics, vol. 217, pp. 685 -- 690, 2017. c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. ACCEPTED ARTICLE - IEEE TRANS. INTELL. TRANSP. SYST. - FALSAFAIN & TAMANNAEI - HTTPS://DOI.ORG/10.1109/TITS.2019.2898476 10 [6] E. Dahlhaus, P. Horak, M. Miller, and J. F. Ryan, "The train marshalling problem," Discrete Applied Mathematics, vol. 103, no. 1, pp. 41 -- 54, 2000. [7] F. Jaehn and S. Michaelis, "Shunting of trains in succeeding yards," Computers and Industrial Engineering, vol. 102, pp. 1 -- 9, 2016. [8] R. Jacob, P. Mrton, J. Maue, and M. Nunkesser, "Multistage methods for freight train classification," Networks, vol. 57, no. 1, pp. 87 -- 105, 2011. [9] J.-A. Adlbrecht, B. Httler, J. Zazgornik, and M. Gronalt, "The train mar- shalling by a single shunting engine problem," Transportation Research Part C: Emerging Technologies, vol. 58, pp. 56 -- 72, 2015. [10] F. Jaehn, J. Rieder, and A. Wiehl, "Minimizing delays in a shunting yard," OR Spectrum, vol. 37, pp. 407 -- 429, Mar 2015. [11] K. Beygang, S. O. Krumke, and F. Dahms, "Train marshalling problem -- algorithms in Wirtschaftsmathematik (WIMA Report), Department of Mathematics, University of Kaiserslautern, 2010. and bounds," Tech. Rep. 132, Report [12] M. Tamannaei and M. Rasti-Barzoki, "Mathematical programming and solution approaches for minimizing tardiness and transportation costs in the supply chain scheduling problem," Computers & Industrial Engineering, vol. 127, pp. 643 -- 656, 2019. [13] M. A. Shafia, M. P. Aghaee, S. J. Sadjadi, and A. Jamili, "Robust train timetabling problem: Mathematical model and branch and bound algorithm," IEEE Transactions on Intelligent Transportation Systems, vol. 13, pp. 307 -- 317, March 2012. [14] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms. MIT Press, 3rd ed., 2009. [15] J. Hromkovic, Algorithmics for Hard Problems: Introduction to Combi- natorial Optimization, Randomization, Approximation, and Heuristics. Berlin, Heidelberg: Springer-Verlag, 2nd ed., 2004. [16] F. V. Fomin and D. Kratsch, Exact Exponential Algorithms. Berlin, Heidelberg: Springer-Verlag, 2010. [17] G. J. Woeginger, "Exact algorithms for NP-hard problems: A survey," in Combinatorial Optimization -- Eureka, You Shrink!: Papers Dedicated to Jack Edmonds 5th International Workshop Aussois, France, March 5 -- 9, 2001 Revised Papers (M. Junger, G. Reinelt, and G. Rinaldi, eds.), (Berlin, Heidelberg), pp. 185 -- 207, Springer Berlin Heidelberg, 2003. [18] L. Deng, M. H. Hajiesmaili, M. Chen, and H. Zeng, "Energy-efficient timely transportation of long-haul heavy-duty trucks," IEEE Transac- tions on Intelligent Transportation Systems, vol. 19, pp. 2099 -- 2113, July 2018. [19] Y. Gao, J. Zhao, B. Zheng, and G. Chen, "Efficient collective spatial keyword query processing on road networks," IEEE Transactions on Intelligent Transportation Systems, vol. 17, pp. 469 -- 480, Feb 2016. [20] X. Meng, J. Li, X. Dai, and J. Dou, "Variable neighborhood search for a colored traveling salesman problem," IEEE Transactions on Intelligent Transportation Systems, vol. 19, pp. 1018 -- 1026, April 2018. [21] X. Hu and E. D. Paolo, "Binary-representation-based genetic algorithm for aircraft arrival sequencing and scheduling," IEEE Transactions on Intelligent Transportation Systems, vol. 9, pp. 301 -- 310, June 2008. [22] K. Liu, L. Feng, P. Dai, V. C. S. Lee, S. H. Son, and J. Cao, "Coding- assisted broadcast scheduling via memetic computing in SDN-based vehicular networks," IEEE Transactions on Intelligent Transportation Systems, vol. 19, pp. 2420 -- 2431, Aug 2018. [23] Z. Zhan, J. Zhang, Y. Li, O. Liu, S. K. Kwok, W. H. Ip, and O. Kaynak, "An efficient ant colony system based on receding horizon control for the aircraft arrival sequencing and scheduling problem," IEEE Transactions on Intelligent Transportation Systems, vol. 11, pp. 399 -- 412, June 2010. [24] Y. Zhu and R. Zhu, "Sequence reconstruction under some order-type constraints," Scientia Sinica Series A, vol. 26, pp. 702 -- 713, 1983. [25] E. Dahlhaus, F. Manne, M. Miller, and J. Ryan, "Algorithms for com- binatorial problems related to train marshalling," in IN PROCEEDINGS OF AWOCA 2000, IN HUNTER VALLEY, pp. 7 -- 16, 2000. [26] L. Brueggeman, M. Fellows, R. Fleischer, M. Lackner, C. Komusiewicz, Y. Koutis, A. Pfandler, and F. Rosamond, "Train marshalling is fixed parameter tractable," in Fun with Algorithms: 6th International Conference, FUN 2012, Venice, Italy, June 4 -- 6, 2012. Proceedings (E. Kranakis, D. Krizanc, and F. Luccio, eds.), (Berlin, Heidelberg), pp. 51 -- 56, Springer, 2012. c(cid:13) 2019 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works.
1802.05239
2
1802
2018-03-03T21:10:25
Efficient Exact Paths For Dyck and semi-Dyck Labeled Path Reachability
[ "cs.DS" ]
The exact path length problem is to determine if there is a path of a given fixed cost between two vertices. This paper focuses on the exact path problem for costs $-1,0$ or $+1$ between all pairs of vertices in an edge-weighted digraph. The edge weights are from $\{ -1, +1 \}$. In this case, this paper gives an $\widetilde{O}(n^{\omega})$ exact path solution. Here $\omega$ is the best exponent for matrix multiplication and $\widetilde{O}$ is the asymptotic upper-bound mod polylog factors. Variations of this algorithm determine which pairs of digraph nodes have Dyck or semi-Dyck labeled paths between them, assuming two parenthesis. Therefore, determining digraph reachability for Dyck or semi-Dyck labeled paths costs $\widetilde{O}(n^{\omega})$. A path label is made by concatenating all symbols along the path's edges. The exact path length problem has many applications. These applications include the labeled path problems given here, which in turn, also have numerous applications.
cs.DS
cs
Efficient Exact Paths For Dyck and semi-Dyck Labeled Path Reachability∗ Phillip G. Bradford† October 15, 2018 Abstract The exact path length problem is to determine if there is a path of a given fixed cost between two vertices. This paper focuses on the exact path problem for costs −1, 0 or +1 between all pairs of vertices in an edge-weighted digraph. exact path solution. Here ω is the best exponent for matrix multiplication and The edge weights are from {−1, +1}. In this case, this paper gives an (cid:101)O(nω) (cid:101)O is the asymptotic upper-bound mod polylog factors. costs (cid:101)O(nω). A path label is made by concatenating all symbols along the path's Variations of this algorithm determine which pairs of digraph nodes have Dyck or semi-Dyck labeled paths between them, assuming two parenthesis. Therefore, determining digraph reachability for Dyck or semi-Dyck labeled paths edges. The exact path length problem has many applications. These applications include the labeled path problems given here, which in turn, also have numerous applications. 1 Introduction Shortest path algorithms are a great success. Many people use them and many vehi- cles are equipped with them. Determining path reachability is also important. Path reachability is often computed using transitive closure. This paper efficiently solves the 0 and ±1 exact path length problem for digraphs whose edges have weights from {−1, +1}. ∗This current paper uses standard definitions of Dyck and semi-Dyck languages. The author's earlier abstracts reversed the Dyck and semi-Dyck definitions. An extended abstract of this paper is in the proceedings of the UEMCON 2017 conference, see [1]. †Department of Computer Science and Engineering, University of Connecticut, Stamford, CT, USA. [email protected], [email protected] 1 Context-free language constrained graph problems are fundamental to a plethora of challenges. This paper gives algorithms for determining Dyck (semi-Dyck) constrained paths on digraphs based on the exact path problem. Dyck and semi-Dyck context- free languages are important. A central application for the exact path problem is for determining Dyck and semi-Dyck constrained paths in digraphs. Here these languages have a single parenthesis type. Definition 1 (Exact path length problem [2]) Consider an integer edge weighted digraph G. Given an integer κ, the EPL (exact path length problem) is to determine whether there is a path between a given pair vertices costing exactly κ. Nykanen and Ukkonen [2] show the general EPL is NP-Complete. They also give a pseudo-polynomial algorithm for the EPL. The current paper uses a special case of the EPL where κ ∈ {−1, 0, +1} and edge costs are from the set {−1, +1}. Given these restricted edge costs, and for κ (cid:54)= 0, applying Nykanen and Ukkonen's algorithm costs O(n3 + nω log κ) time1, see [2]. For κ = 0, their algorithm costs O(n3). Solving this Dyck (semi-Dyck) labeled path problem is interesting due to the close relationship between transitive closure, Boolean and algebraic matrix multiplication, and context-free grammar recognition. For example, Lee [3] gives an equivalence between Context-free parsers and Boolean matrix multiplication algorithms. 1.1 Semi-Dyck and Dyck Constrained Graphs Dyck and semi-Dyck languages are parenthesis languages. Dyck or semi-Dyck lan- guages with two parenthesis symbols and n total parentheses can be parsed in O(n) time and space. However, efficiently computing Dyck (and semi-Dyck) constrained reachability on digraphs seems more challenging. Let D be a Dyck language of one open-parentheses symbol a and one close- parentheses symbol a−1. A sentence w ∈ D iff w can be reduced using right-inverse reduction, e.g. a a−1 = , to the empty string . The Dyck language D is derivable from the grammar: D =⇒  D D a D a−1. Semi-Dyck languages allow reductions using both right-inverses and left-inverses aa−1 = a−1a = . They are derivable from the grammar: S =⇒  SS aSa−1 a−1Sa. Dyck languages generate all strings of balanced parenthesizations. Semi-Dyck lan- guages generate all strings of equal numbers of matching symbols. The next definition is similar to one in [4]. 1All logs are base 2 except where specified otherwise. 2 Definition 2 (Labeled Directed Graph) A labeled directed graph (LDG) is a multi- graph G = (Σ, V, E1) consisting of a set V of vertices and a set E1 ⊆ V × V × Σ of labeled and directed edges. The set Σ contains a grammar's terminals. If the grammar is Dyck (semi-Dyck), then Σ is said to be Dyck (semi-Dyck). Given Definition 2, restrict cycles to having no repeated edges. LDGs are multi- graphs. All LDG edges are augmented with label-costs. So each edge e in G has a label l(e) and a label-cost lc(e). The label-cost function is, if l(e) = a−1 if l(e) = a. (cid:26) −1 lc(e) = +1 A +1 edge and a −1 edge may be joined to form a new 0 label-cost edge for computing an exact path. After some processing, say such a new 0 label-cost edge e is created. Then, the label-cost function extends so lc(e) = 0. This new 0 label-cost edge is added to an augmented edge set in the LDG. Also, ±1 and 0 label-cost edges may be extended by adjoining 0 label-cost edges. The label-costs or costs are written above edges such as e = i w−→ j. Therefore, in general w ∈ {−1, 0, +1}, but at the start of our algorithms assume w ∈ {−1, +1}. 1.2 Previous Work Greenlaw, Hoover, and Ruzzo [5] discuss several formal-language based reachability problems. See also Afrati and Papadimitriou [6], Reps [7], and Ullman and Van Gelder [8]. For example, the LGAP (labeled graph accessibility problem) [5] is a Dyck language with constrained reachability problem on a directed graph G that is P- complete when Σ ≥ 4. Yannakakis [9, p. 237] points out that Valiant's Boolean ma- trix multiplication context-free word recognition algorithm determines single-source la- beled path reachability in DAGs. This means there is an algorithm costing O(nω log n) for finding context-free labeled and unweighted paths in DAGs with n vertices, where ω is the best exponent for n × n matrix multiplication. Very efficient matrix multi- plication algorithms include results of Coppersmith and Winograd [10]; Stothers [11]; Williams [12]; and Le Gall [13]. Currently, the best exponent of square matrix multi- plication is ω < 2.373. Melski and Reps [14] give an O(n3S3) context-free language reachability algo- rithm. Where S is the set of terminals and non-terminals for the input grammar. Barrett, Jacob, and Marathe [4] give an O(n3RN) algorithm for finding the all- pairs shortest paths in context free grammar constrained path problems. Here R is the set of rules and N is the set of non-terminals in Chomsky normal form. This algorithm does not compute shortest paths with negative edge weights. graphs with edge weights from {−1, 0, +1} costing (cid:101)O(nν) where ν = 3+ω Alon, Galil, and Margalit [15] give efficient algorithms for shortest paths on di- 2 . See also 3 Takaoka [16]. A part of Alon, et al.'s algorithm finds zero length directed paths and uses them as short-cuts. It may be possible to extract their 0 length path algorithm for short-cuts as the basis of our work. Nonetheless, Alon, et al.'s directed graph shortest-path algorithm takes (cid:101)O(n2.687) time when ω < 2.373. than (cid:101)O(n2.575), since ω < 2.373. Our algorithm does not solve shortest-path problems. Galil and Margalit [17] extend the results of Alon, et al. [15] and integrate the shortest path distance and shortest path problem. Zwick [18] gives more efficient all- pairs shortest path and path distance algorithms. Zwick's shortest path's cost is better Building on Barrett, et al., Bradford and Thomas [19] give a more efficient context free label constrained shortest path algorithm for graphs with positive and negative edge weights whose unlabeled versions have no negative cycles. Barrett, et al.'s algo- rithm for finding context free label constrained shortest paths with positive and nega- tive edge weights costs O(n5N2R2). Bradford [20] gives a solution to a quickest-path problem for context-free grammars applied to cryptographic routing. Bradford and Choppella [21] use a special-case of Nykanen and Ukkonen's sign-closure algorithm for DAGs with initial edge costs from {−1, +1}, see also Khamespanah, Khosravi, and Sirjani [22]. Further Bradford and Choppella [21] find actual minimum-cost point- to-point Dyck paths in DAGs. Ward, Wiegand, and Bradford [23] give a distributed context-free labeled graph shortest path algorithm also based on [4]. Ward and Wie- gand [24] analyze the complexity of wireless routing metrics as labeled path problems. Chaudhuri [25] gives an O(n3/ log n) algorithm for context-free language reacha- After preprocessing a bidirected tree, Yuan and Eugster [27] give a O(V log V ) bility using an important dynamic-programming speedup method by Rytter [26]. algorithm for finding Dyck reachability in bidirected trees in O(1) per query. Zhang, Lyu, Yuan, Hao and Su [28] improve on Yuan and Eugster's bidirected tree algorithm. Zhang, et al. [28] also give an O(V +E log E) algorithm for determining Dyck reachability for bidirected digraphs. Each Dyck labeled edge in a bidirected digraph has a mirror edge going in the opposite direction and with a complimentary label. See also [29, 30]. Khamespanah, Khosravi, and Sirjani [22] use Nykanen and Ukkonen [2]'s exact path algorithm to improve their model checking algorithms for timed actors in dis- tributed systems. They apply the pseudo-polynomial algorithm's O(n2) path relax- ation cost, while accepting the pre-processing costs of O(n3). Our results break through this O(n3) barrier giving a (cid:101)O(nω) algorithm. In general, Melski and Reps [14] discuss the "O(n3) bottleneck" for context-free program analysis. Our results solidly break through this bottleneck for the Dyck and semi-Dyck cases. Dyck and semi-Dyck languages are also applied to data streaming, see Chakrabarti, Cormode, Kondapally and McGregor [31]. In addition, Tang, et al. [32] apply Dyck- CLF reachability to library summarization. Likewise, there are applications to database path queries, see Grahne, Thomo and Wadge [33]. Choppella and Haynes give an equivalence between unification graphs and Dyck path reachability problems in di- graphs [34]. 4 1.3 Structure of this paper Section 2 gives the foundations for the rest of the paper. Section 3 shows how to find efficient exact 0 cost paths for graphs labeled with flat Dyck and semi-Dyck grammars. Subsection 3.1 leverages Alon, Galil, Margalit's algebraic matrix encoding [15] for our solution. See also Yuval [35]. Where subsection 3.2 gives an exact 0 cost path solution for flat Dyck and flat semi-Dyck grammars. Grid graphs for exact 0 Dyck and semi-Dyck paths are given in section 4. This section has a number of definitions directly in the text. This is to simplify the flow. Finally, subsection 4.1 concludes section 4 giving the general exact 0 path solution. Section 5 extends the exact 0 cost reachability to exact ±1 reachability. 2 Dyck Path Reachability Problem Direct application of standard shortest path [36] and transitive closure [36, 37] algo- rithms to LDGs does not seem to determine 0 reachability. In our instantiation of this challenge, such shortest paths use −1 edge weights or label-costs. That is, some paths may be negative. Indeed, shortest path algorithms gravitate towards negative paths. For this reason, intuitively shortest path algorithms not directly applicable. This paper converts its edge labels to label-costs from {−1, 0, +1}. Therefore, rather than referring to labeled-costs, this paper just discusses edge costs. These costs are generally restricted to {−1, 0, +1}. Next are definitions for sign-closure graphs from Nykanen and Ukkonen [2]. They also define the function sgn, for w ∈ {−1, 0, +1} so that sgn(w) = w. For any LDG G = (Σ, V, E1), let M be a label-cost bound, M = max{lc(e) : e ∈ E1 }. Throughout this paper, M = 1. Definition 3 (Nykanen and Ukkonen [2]) Consider a digraph G = (V, E). The sign-closure of E(G) is unsign(G) which starts with E(unsign(G)) ← E(G), and then apply the rule: v−→ k w−→ j ∈ E(unsign(G)) and sgn(v) (cid:54)= sgn(w) if i then put i v+w−→ j in E(unsign(G)), until it no longer applies. Applying Nykanen and Ukkonen's sign-closure algorithm finds semi-Dyck paths in an LDG. This relates semi-Dyck paths to transitive closure. Changing the if-statement in Definition 3 as follows gives Dyck sign-closure. Given a LDG G, its Dyck sign-closure is unsign≥(G). To get the Dyck sign closure of a graph G, apply the rule 5 v−→ k w−→ j ∈ E(unsign≥(G)) and sgn(v) (cid:54)= sgn(w) and v (cid:54)= −1 if i then put i v+w−→ j in E(unsign≥(G)), until it no longer applies. Nykanen and Ukkonen show the sign-closure graph problem is NP-Complete. Nonetheless, Nykanen and Ukkonen give a O(M 2n3) time pseudo-polynomial algo- rithm for computing a sign-closure graph. This pseudo-polynomial algorithm runs in polynomial time for edge costs restricted to {−1, 0, +1} since M = 1. In particular, when M = 1, computing a sign-closure graph costs O(n3) by [2]. We improve the cost to (cid:101)O(nω). The basic result of the next lemma is mentioned in the proof of Theorem 5 in Nykanen and Ukkonen [2]. Their Theorem 5 assumes their O(M 2n3) sign-closure algorithm. Nykanen and Ukkonen were not discussing Dyck or semi-Dyck languages, but in our context, their result is as follows. Lemma 1 (Nykanen and Ukkonen [2]) Consider an LDG G = (Σ, V, E1) where Σ is Dyck (semi-Dyck) and Σ = 2. In computing a sign-closure with edge costs from {−1, +1}, then new edges added to E(H) may be limited to costs from { −1, 0, +1 }. The case of Dyck languages follows since Dyck languages are also semi-Dyck lan- guages. Given an LDG G, a 0 cost edge (path) is an edge (path) in unsign(G) or unsign≥(G). A 0 cost edge has label-cost computed to be 0 and a 0 cost path has total cost 0. Zero cost paths are semi-Dyck paths in G. A proof of the next lemma follows since semi-Dyck paths along ±1 edges have equal numbers of +1 and −1 values. See also [21]. Lemma 2 Consider the LDG G = (Σ, V, E1) where Σ is semi-Dyck and Σ = 2, then G has a semi-Dyck path between i and j iff in G there is a 0 cost path between i and j. The next definition is well-known. Definition 4 (Non-negative prefix sum) Suppose G is a LDG with a simple weighted path p from i0 to it+1: p = i0 v1−→ i1 v2−→ ··· vt−→ it vt+1−→ it+1. then node ik has prefix sum v1 + ··· + vk from p = i0 to ik along p for k : t + 1 ≥ k ≥ 1. In a path p, if p's prefix sums for all 0 cost subpaths are The prefix sum for i0 is 0. non-negative, then the path p has a non-negative prefix sum. A proof of the next lemma follows a proof of Lemma 2, see also [21, 8]. 6 Lemma 3 Consider the LDG G = (Σ, V, E1) where Σ is Dyck and Σ = 2, then G has a Dyck path between i and j iff in G there is a 0 cost path between i and j having only non-negative prefix sums. The next lemma includes labeled edges going from a node to itself. This paper assumes no self-cycles with repeated edges. Lemma 4 Consider an LDG G = (Σ, V, E1) where Σ is Dyck (semi-Dyck), Σ = 2 with sign-closure unsign≥(G) (unsign(G)). Then all vertices in V have at most 3n outgoing edges. 3 Towards efficient exact 0 cost paths costs 0 in LDGs with {−1, +1} weighted edges in (cid:101)O(nω) operations. This new solution This section gives the background for determining which nodes have exact paths of is expressed as flat Dyck or flat semi-Dyck paths in LDGs. This is done by computing sign-closures of digraphs with {−1, +1} edge weights. In the process, 0 cost edges may be added to these diagraphs. Also, ±1 and 0 edges are extended by 0 cost edges. Our algorithm uses algebraic matrix multiplication of specially coded matrices. These matrix encodings are from Alon, Galil, and Margalit [15]. See also Yuval [35]. Each algebraic matrix multiplication may be done in O(nω log n). This may be improved by a polylog factor, see for example [15, 38, 25, 18, 26]. Alon, Galil, and Margalit's shortest path algorithm [15] starts by finding exact 0 length paths in digraphs with edge costs {−1, 0, +1}. They use these 0 exact paths as shortcuts to find shortest paths. Our algorithm finds {−1, 0, +1} exact paths between all pairs of vertices. Alon, et al.'s digraph shortest path algorithm works for edges with much larger costs. Their digraph shortest path algorithm is substantially more costly than our digraph exact path algorithms. Of course, they solve the shortest path algorithm where we solve a reachability problem. Matrices are written in uppercase and their elements are written in lowercase [18]. Matrix parenthesized superscripts, such as those in {D(−1), D(0), D(+1)} signify differ- ent matrices. These parenthesized powers are not exponentiation. Likewise, matrix elements raised to powers, such as d−1 i,j , are not exponentiated. Rather these superscripts indicate the matrices these elements are from. In this case, d−1 i,j is in D(−1), i,j is in D(0), and d+1 d0 The algorithm in Figure 1 maintains three adjacency matrices D(−1), D(0), and D(+1). These three adjacency matrices allow −1, 0 and +1 edges to go from any vertex to any other vertex. Given an LDG G = (Σ, V, E1), where Σ = 2, define the adjacency matrices D(g) ∈ {D(−1), D(0), D(+1)} whose edge costs are from {−1, 0, +1}. Before iteration (cid:96) = 1, there are no 0 cost edges in D(0). i,j is in D(+1). i,j , d0 i,j, d+1 7  dg i,j = if (i, j) ∈ E(cid:96) and g = −1 = lc(i, j) if (i, j) ∈ E(cid:96) and g = 0 = lc(i, j) and (cid:96) > 1 if (i, j) ∈ E(cid:96) and g = +1 = lc(i, j) −1 0 +1 ∞ otherwise. Subsequently, in each iteration a new edge set E(cid:96) is created in the (cid:96)-th iteration of our main algorithm. At this point, any new {−1, 0, +1} cost paths are placed in E(cid:96) during iteration (cid:96). So, during computation there may be at most three (different) labeled edges directly from any vertex i to any other vertex j. See Lemma 4. Recall, the initial graph edges only have weights from {−1, +1}. The algorithm in Figure 1 implements these equations to find all −1, 0, +1 exact paths. This algorithm is substantially less efficient than Nykanen and Ukkonen [2] applied to graphs with {−1, +1} edges. However, Figure 1's algorithm forms a basis for our more efficient algorithm. Expensive-Digraph-exact-paths: ±1, for the semi-Dyck LDG G = (V, E1) 1. { D(−1), D(0), D(+1) } ← Init-Adjacency-Matrices(G) 2. n ← V 3. for (cid:96) ← 2 to n do for i ← 1 to n do 4. 5. 6. 7. 8. 9. for k ← 1 to n do i,k + d+1 i,k + d0 i,k + d0 k,j) = 0 ∨ (d+1 k,j) = 1 ∨ (d0 k,j) = −1 ∨ (d0 for j ← 1 to n do if (d−1 if (d+1 if (d−1 i,k + d−1 i,k + d+1 i,k + d−1 i,j ← 0 k,j) = 0 then d0 i,j ← +1 k,j) = 1 then d+1 k,j) = −1 then d−1 i,j ← −1 Figure 1: An inefficient −1, 0, +1 exact path algorithm for digraphs with initial edge costs {−1, +1} The function Init-Adjacency-Matrices in Figure 1 initializes each of D(−1), D(0), and D(+1) with sufficiently large values representing no edge and no path. No path and no edge in the algorithm in Figure 1 may be represented by numbers as little as 2. Although, if there is no t to get from i to j, then dt i,j is effectively infinite, for any t ∈ {−1, 0, +1}. Next Init-Adjacency-Matrices represents a −1 edge from i to j in D(−1) by placing −1 in d−1 i,j . Likewise +1 edges are represented in D(+1) by appropriate placement of +1 values. Definition 5 (E1-length) Consider an LDG G = (V, E1) and an exact path p in G. The E1-length of p is the number of E1 edges in p. 8 Exact 0 cost paths have even E1-lengths. Exact ±1 cost paths have odd E1-lengths. The algorithm in Figure 1 may be made a little more efficient. In the next section of this paper, we give a substantially more efficient solution building on this approach. Lemma 5 Consider an LDG G = (Σ, V, E1), where Σ is semi-Dyck with Σ = 2. Then i,j = w, for w ∈ {−1, 0, +1}, for all {i, j} ⊆ V at the termination of Figure 1's algorithm, dw where there is an exact w cost path from i to j. Proof: This is shown by complete induction on the iteration (cid:96) for exact −1, 0 and +1 paths. Basis Immediately after the initial iteration (cid:96) = 2, all 0 exact paths of even E1-length at least 2 are found by line 7. Such exact 0 paths are created by combining adjoining +1 and −1 edges or combining adjoining −1 and +1 edges. An exact 0 path from i to j is recorded in the matrix D(0) by setting d0 In iteration (cid:96) = 3 the exact 0 cost paths from iteration (cid:96) = 2 are combined with adjoining ±1 edges from E1 giving ±1 exact paths. These exact ±1 paths have odd E1-length of at least 3. This is done by lines 8 and 9 and the matrices D(±1) record these exact paths. i,j to 0. Inductive Hypothesis For (cid:96) = 2 and (cid:96) = 3, the next cases hold. Immediately after iteration (cid:96) : (cid:96) ≥ t ≥ 1, for all even t, this algorithm finds all exact 0 cost paths in line 7. By assumption, for all even t, these new exact 0 paths discovered in iteration t have even E1-length of at least t. Line 7 combines adjoining ±1 and ∓1 exact paths from previous iterations and records these paths in D(0). These new exact 0 paths are recorded in D(0). After iteration (cid:96) : (cid:96) ≥ t ≥ 1, for all odd t, this algorithm finds all exact ±1 cost paths in lines 8 and 9. By assumption, for all odd t, these new exact ±1 paths dis- covered in iteration t have odd E1-length of at least t. Lines 8 and 9 combines exact 0 paths and exact ±1 paths from previous iterations. These new exact ±1 paths are recorded in D(±1). Inductive Step Consider the algorithm immediately after iteration (cid:96) + 1 where (cid:96) + 1 is even. By the inductive hypothesis, consider all odd t : (cid:96) ≥ t ≥ 1, the matrices D(±1) contain ±1 exact paths of odd E1-length. Also, all ∓1 exact paths in D(∓1) are of odd E1-length. In iteration (cid:96) + 1, this algorithm combines adjoining ±1 and ∓1 exact paths to form 0 exact paths of even E1-length. Suppose an exact 0 cost path p is discovered in iteration (cid:96) + 1 where p is of E1-length t ≤ (cid:96) − 1. This cannot be the case since by the inductive hypothesis p would have been discovered in iteration t. Consider the algorithm immediately after iteration (cid:96) + 1 where (cid:96) + 1 is odd. By the inductive hypothesis for all even t : (cid:96) ≥ t ≥ 1, the matrices D(0) contain exact 0 paths of even E1-length. Likewise, for odd t : (cid:96) ≥ t ≥ 1, the matrices D(±1) contain 9 ±1 exact ±1 paths of odd E1-length. In this case, the algorithm combines adjoining ±1 (0) exact paths with 0 (±1) exact paths giving new exact ±1 cost paths of odd E1-length. Suppose an exact ±1 cost path p is discovered in iteration (cid:96) + 1 where p is of E1-length t ≤ (cid:96) − 1. This cannot be the case since by the inductive hypothesis p would have been discovered by iteration t. Lemma 6 Consider an LDG G = (Σ, V, E1), where Σ is semi-Dyck with Σ = 2, and i,j = w ∈ {−1, 0, +1}, the algorithm in Figure 1. At the termination of the algorithm, if dw for any {i, j} ⊆ V where there is a w cost exact path from i to j, then the algorithm computed the sign-closure unsign(G). i,j = w, where w ∈ {−1, 0, +1}, for Proof: At the termination of the algorithm dw all {i, j} ⊆ V where there is an exact w cost path from i to j. If unsign(G) is not complete, then some edge from i to j must not have been placed in E(unsign(G)), by applying the sign-closure rule v−→ k w−→ j ∈ E(unsign(G)) and sgn(v) (cid:54)= sgn(w) if i then put i v+w−→ j in E(unsign(G)). Since v (cid:54)= w, then there must be some path from i to j that was not generated by But, i v+w−→ j is an exact v + w ∈ {−1, 0, +1} path from i to j. This exact path the algorithm in Figure 1. must have been found by Lemma 5, completing the proof. i,k + d+1 k,j from the calculation of d0 Nykanen and Ukkonen's sign-closure algorithm [2] finds exact paths in graphs in O(n3) time. The next result shows how to find Dyck exact −1, 0, and +1 paths. This is done by dropping the condition d−1 i,j in Figure 3. Lemma 7 Consider an LDG G = (Σ, V, E1), where Σ is Dyck with Σ = 2, and the algorithm in Figure 1 while dropping the expression (d−1 k,j) = 0 in line 7. At the i,j = w ∈ {−1, 0, +1}, for any {i, j} ⊆ V where there termination of the algorithm, if dw is a w cost Dyck path from i to j, then the algorithm computed the Dyck sign-closure unsign≥(G). Proof: Lemma 5 shows this algorithm finds all −1, 0, and +1 exact paths for any semi-Dyck LDG G. With this in mind, it remains to extend that lemma. The next arguments allows the extension of Lemma 5's induction proof to this Dyck case. i,k + d+1 Lines 7, 8, and 9 in Figure 1, only computing d0 for a 0 cost path or subpath. Clearly computing d+1 sum. Likewise, computing d−1 i,j may create a negative prefix sum i,j cannot have a negative prefix i,j can't compute a negative prefix sum for a 0 cost path 10 Removing the condition (d−1 i,j just extends −1 edges, but does not necessarily contribute or subpath. Computing d−1 to non-Dyck labeled paths. i,j finds all exact w ∈ {−1, 0, +1} cost paths without negative prefix sums. An identical argument as in the proof of Lemma 6 indicates all edges of unsign≥(G) have been found. Thus, this modification computes the Dyck sign-closure. k,j) = 0 in line 7 in the equation for dw i,k + d+1 Intuitively, our approach to improving the algorithm in Figure 1 is anchored in Boolean matrix multiplication for transitive closure. However, starting with graph edges {−1, +1} and computing with the edge weights {−1, 0, +1} seems to preclude Boolean matrix multiplication. Thus, we leverage Alon, Galil, and Margalit [15]. 3.1 AGMY matrix encoding Alon, Galil, and Margalit [15] as well as Yuval [35] supply the basis of our (AGMY) algebraic matrix coding. These AGMY style codings have been very fruitful, see for example [18, 39, 40, 16, 17]. Lemma 4 gives insight into an algebraic matrix product solution. In particular, the AGMY representation uses powers of 3(n + 1) to differentiate {−1, 0, +1} edge 3(n+1) , (3(n + 1))0, 3(n + 1) represent −1, 0, +1 edges, respectively. weights. That is, These AGMY values are sufficiently separated to allow information to be gleaned after an algebraic matrix product. Figure 2 shows how to translate adjacency matrices D(−1), D(0) and D(+1) to an AGMY encoded adjacency matrix. The restriction g (cid:54)= h is from the sign-closure in Definition 3. 1 n(cid:88)  ci,j ← (3(n + 1))dg i,k+dh k,j if dg i,k (cid:54)= ∞ ∧ dh k,j (cid:54)= ∞ k=1 g(cid:54)=h 0 if dg i,k = ∞ ∨ dh k,j = ∞. Figure 2: AGMY matrix coding for algebraic matrix multiplication to simuate one matrix dot product based on Alon, Galil, and Margalit [15]; and Yuval [35] An algebraic matrix product computes the expression in Figure 2 for all i, j : n ≥ i, j ≥ 1, see Figure 3. If dg k,j with 0. This works since no finite power of 3(n + 1) is 0. Initially, an adjacency matrix represents an LDG G with edge costs from {−1, +1}. So at the start of the algorithm, any two vertices i and j may share a −1 and +1 edge k,j = ∞, then replace (3(n + 1))dg i,k = ∞ or dh i,k+dh 11 For all i, j : n ≥ i, j ≥ 1, let i,j ← (3(n + 1))d0 c−1 i,j ← (3(n + 1))d−1 c0 i,j ← (3(n + 1))d0 c+1 i,k+d−1 i,k +d+1 i,k+d+1 k,j + (3(n + 1))d−1 k,j + (3(n + 1))d+1 k,j + (3(n + 1))d+1 i,k +d0 k,j i,k +d−1 k,j i,k +d0 k,j Figure 3: A breakout of computing AGMY matrix values going in each direction. Thus, each element of the initial AGMY coded adjacency matrices starts with values from, { 0, (3(n + 1))1, (3(n + 1))−1, (3(n + 1))1 + (3(n + 1))−1 }. Here the AGMY 0 represents no edge. During the first matrix product, 0 cost edges may appear. They are represented by (3(n + 1))0 = 1. The ideas for the next Lemma are based on Alon, Galil, and Margalit [15]. Lemma 8 Given two n×n AGMY encoded LDG adjacency matrices S and T representing values from {−1, 0, +1}. Consider an algebraic matrix product P = S T and say there is a path of cost pi,j between i and j, then n (3(n + 1))2 + 2(3(n + 1)) + 3 + 2 3(n + 1) + 1 (3(n + 1))2 ≥ pi,j. (cid:20) (cid:21) Proof: While a sign-closure is computed, any two vertices i and j may share up to three edges going in each direction by Lemma 4. In AGMY coding, three outgoing edges are bounded by, B ≤ 1 3(n + 1) + 1 + 3(n + 1). Thus, a single algebraic matrix product produces a new matrix element of at most (3(n + 1))2 + 2(3(n + 1)) + 3 + 2 3(n + 1) + 1 (3(n + 1))2 ≥ B2. (1) The dot-product of row S[i,∗] and column T [∗, j] gives a value of at most, (cid:124) B2 + ··· + B2 (cid:125) (cid:123)(cid:122) 12 the sum of n squares and since there are at most n of these B2 terms, the result holds. 1 Following the AGMY adjacency matrices of Lemma 8, Say there is a path from i to j, then the dot-product of row S[i,∗] and column T [∗, j] is at least AGMY 1 3(n+1). This is the result of combining adjoining −1 and 0 edges. This is because a −1 cost edge is represented by AGMY 1 3(n+1) and a 0 edge is represented by AGMY (3(n + 1))0 = 1. 3(n+1) , 1, 3(n + 1)} in Lemma 8 are removed after each matrix Factors besides { product. These factors represent unnecessary intermediary paths and their growth makes the algorithm too expensive. So, following Alon, et al. [15], see also Zwick [18], our algorithm removes all edges except for AGMY { malization. Normalization removes unnecessary edges for computing the EPL for 0 cost paths. So, immediately after the matrix product in line 5, the adjacency elements are converted back to values from { 3(n+1) , 1, 3(n + 1)}. This is nor- 3(n+1), 1, 3(n + 1)}. The next corollary follows from the upper bound on the representation of each 1 1 adjacency element from Lemma 8. Very similar results are in [15, 18]. Corollary 1 In a single AGMY algebraic matrix multiplication of an LDG's adjacency matrix, each of the resulting matrix elements may be represented in O(log n) bits. New ±1 edges are generated by matrix products and normalization or extending −1−→ k edge ±1 by 0 cost edges. Furthermore, in computing Dyck paths, any edge i may not be joined to k +1−→ j. This is because −1−→ k +1−→ j i is not Dyck. In the case when a −1 edge is made from multiple E1 edges, then this edge repre- sents a path. Therefore, this path has a negative sum. In fact, it is a negative prefix sum. Such a −1 edge is already not Dyck. Thus, it may not start a new Dyck path, though it may follow a +1 edge. Normalization uses the functions in Figure 4. The upper and lower bounds in each function in Figure 4 are determined as follows. Lemma 8 gives upper bounds for detectNegativeOneEdge(edge cost, n). That is, the first operation of detectNegativeOneEdge is to multiply the fractional part of its edge-weight by 3(n + 1) giving the upper-bound (cid:18) 2n 3(n + 1) (cid:19) . 2n = 3(n + 1) 2 An AGMY 3(n+1) term in Equation 1 indicates there are at most two different ways to form a −1 edge edge through a single intermediary vertex. For example, take paths from a vertex i to another vertex j with intermediary k. That is, the two ways 13 1. detectNegativeOneEdge(edge cost, n) 2. 3. 4. check ← 3(n + 1) × fractional part(edge cost) if 2n ≥ check ≥ 1 then return True else return False 1. detectPositiveOneEdge(edge cost, n) 2. 3. 4. check ← truncate(edge cost/3(n + 1)) if 2n ≥ check ≥ 1 then return True else return False 1. detectZeroEdge(edge cost, n) 2. 3. 4. check ← truncate(edge cost) mod 3(n + 1) if 3n ≥ check > 0 then return True else return False Figure 4: Functions used to detect AGMY costs representing {−1, 0, +1} for normalize an AGMY algebraic matrix product 1 1 0−→ k −1−→ k 0−→ j or i −1−→ j. Equation 1 also indicates there is at most one are: i cost −2 edge between any two vertices due to the (3(n+1))2 term. A potential −2 cost edge will not be detected by detectNegativeOneEdge because a single −1 edge that has 3(n+1). Thus, the first operation of detectNegativeOneEdge is AGMY cost of at least to multiply the fractional part of the AGMY edge-weight by 3(n + 1) so the smallest value of a −1 cost edge is 1. The upper and lower bounds in detectPositiveOneEdge and detectZeroEdge are similar. Thus, reset all elements immediately after each recursive doubling step using the functions in Figure 4. The three functions in Figure 4 detect −1, 0 and +1 cost edges following each algebraic AGMY matrix multiplication. These AGMY edges have values as large and complex as those in Lemma 8. After detecting −1, 0 or +1 AGMY edges, more complex pathways are simplified or normalized by replacing them by the appropriate members of { 3(n+1), 1, 3(n + 1)}. Each normalization costs O(n2 log n). 1 (cid:21) . Figure 5 is the critical component of all our results. In Figure 5, Normalize and Divide by 2 removes redundant edges. By Lemma 8, in line 5 the algebraic AGMY matrix multi- plication gives values as large as (cid:20) n (3(n + 1))2 + 2(3(n + 1)) + 3 + 2 3(n + 1) + 1 (3(n + 1))2 Line 6 removes ±1 edges. In line 7, normalization changes ±2 cost edges to ±1 cost edges. Thus, only retaining AGMY encodings for { 3(n+1), 1, 3(n + 1)}. The idea of 1 14 Digraph-flat-exact-paths(G) // G = (Σ, V, E1) is an LDG, Σ is semi-Dyck and Σ = 2 1. {D(−1), D(0), D(+1)} ← Init-Adjacency-Matrices(G) 2. M ← AGMY-Code-then-Sum(D(−1), D(0), D(+1)) 3. n ← V 4. for (cid:96) ← 2 to (cid:100)log n(cid:101) + 1 do 5. M ← M M // AGMY, find new 0 edges 6. Remove ±1 edges from M 7. M ← Normalize and Divide by 2(M ) 8. Z ← Get-Zero-Edges(M ) 9. M ← Z M Z // AGMY, extend ±1 and 0 edges Figure 5: A new matrix-based sign-closure algorithm for digraphs with initial edge costs representing {−1, +1}. This algorithm uses AGMY coded matrices. dividing the edge costs by 2 is from Alon, et al. [15]. Line 9 joins adjacent 0 cost edges and it extends ±1 cost edges with adjoining 0 cost edges. Line 9 cannot generate ±2 cost edges. Before line 9 in iteration (cid:96), these adjoining 0 cost edges have E1-length from 2 up to 3(cid:96)−2·2(cid:96)−1. So, at the end of line 9 in iteration (cid:96), up to three consecutive adjoining 0 cost edges may form a single E1-length 3(cid:96)−1 · 2(cid:96)−1 edge. 5'. M(cid:48) ← Markup minus one edges(M ) // AGMY, mark −1 edges 5". M ← M(cid:48) M // AGMY product, non-Dyck 0 edges are detectable Figure 6: Replacing line 5 of Algorithm 5 with these lines is the basis of a sign-closure algorithm for Dyck digraphs with initial edge costs {−1, +1}. Further updates are done in Normalize and Divide by 2(M ) so it deletes 0 edges marked here as created by non-Dyck paths. Figure 6 shows how to determine if a new 0 edge is made by a −1 edge fol- lowed by a +1 edge. A −1 edge followed by a +1 edge is not Dyck. The function Markup minus one edges adds to each negative edge in its AGMY input matrix M producing M(cid:48). Now, a −1 cost edge followed by a +1 cost edge has an AGMY product of (cid:16) 1 3(n+1) (cid:32)(cid:18) (cid:19)4 (cid:18) (cid:17)4 (cid:19)(cid:33) 1 3(n + 1) + 1 3(n + 1) 3(n + 1) = 15 (cid:18) (cid:19)3 1 3(n + 1) + 1 and such cubic terms are found by a Dyck modified Normalize and Divide by 2(M ) in the algorithm in Figure 5. This cubic term only occurs when an AGMY −1 value is multiplied by an AGMY +1 value, when this product represents a −1 edge going to a +1 edge. Of course, a −1 edge going to a +1 edge is not a Dyck path. Also these cubic terms cannot become −2 AGMY edges in one AGMY matrix multiplication, by Lemma 8. Finally, for the Dyck case, the function Normalize and Divide by 2(M ) in the algorithm in Figure 6 is updated to delete any 0 cost edge made from a −1 edge followed by a +1 edge. The next convention smooths the subsequent presentation. Convention 1 (Digraph-flat-exact-paths context) The algorithm Digraph-flat- exact-paths refers to Figure 5 for the semi-Dyck case in addition to Figure 6 for the Dyck case, depending on the context. 3.2 Flat Dyck and semi-Dyck grammars Flat grammars supply a foundation for the complete solution. Definition 6 (Flat Dyck and flat semi-Dyck grammars) The flat Dyck language is, F =⇒ T P T =⇒ T T P  P =⇒ a P a−1 . The flat semi-Dyck language replaces the last production with P =⇒ a P a−1 a−1 P a . Definition 7 (Sign-closure graph evolution) Consider an LDG G1 = (Σ, V, E1) and Digraph-flat-exact-paths. At the end of each iteration (cid:96) ≥ 2 this algorithm produces the LDG G(cid:96) = (Σ ∪ {0}, V, E(cid:96)). A path in G may become a single {−1, 0, +1} edge in E(cid:96). Such new edges are generated by Digraph-flat-exact-paths. The number of +1 and −1 edges from E1 contributing to new edges give important insights. Definition 8 (c+-length and c−-length) Consider an LDG G(cid:96) = (Σ, V, E(cid:96)) and an edge e ∈ E(cid:96), for (cid:96) ≥ 1. An edge e's c+(e)-length is e's number of +1 edges from E1 and c−(e)-length is e's number of −1 edges from E1. In iteration (cid:96) of Digraph-flat-exact-paths, edges with ±1 costs are made by joining ±1 edges from iteration (cid:96) − 1. Also, additional exact 0 cost paths may be included in the new edges. After iteration (cid:96) = 2, new ±1 edges are not ±1 exact paths. The next corollary is known in a number of contexts. 16 Corollary 2 Consider an LDG G1 = (Σ, V, E1) where Σ = 2, Σ is Dyck (semi-Dyck) and any 0 cost edge e in G(cid:96) with E1-length e, then e has e edges with −1 costs, all from E1. 2 e 2 edges with +1 costs and e Corollary 2 indicates c+(e) = c−(e) = for all 0 cost edges e. A c+-length (c−-length) may be any integer from 0 to n − 1. 2 The proof of the next lemma uses the idea that a new ±1 edge e may merge with an exact 0 cost edge producing a new ±1 edge e(cid:48) with a larger E1-length. However both edges e and e(cid:48) have the same c±-length. Lemma 9 Given an LDG G1 = (Σ, V, E1), where Σ is flat Dyck (flat semi-Dyck) and Σ = 2, then all exact 0 cost edges created by line 5 in iteration (cid:96) of Digraph-flat- exact-paths have E1-length at least 2(cid:96)−1, where (cid:100)log n(cid:101) + 1 ≥ (cid:96) ≥ 2. Proof: Without loss, this proof focuses on the algorithm in Figure 5. Line 9 extends ±1 and exact 0 cost edges using 0 edges of E1-length from 2 to 3(cid:96)−2 · 2(cid:96)−1. It extends adjoining pairs of exact 0 cost paths in flat grammars. Thus, line 9 is not in the next induction. The induction is on the iteration (cid:96) and includes {−1, 0, +1} edges of E1-length of at least 2(cid:96)−1. Basis In iteration (cid:96) = 2, line 5 computes exact 0 cost edges of E1-length at least 2(cid:96)−1 = 2. Likewise, line 5 generates all ±2 cost edges with E1-length of at least 2(cid:96)−1 = 2. These ±2 cost edges are converted to ±1 cost edges, by normalization in line 7. Their E1-lengths remain at least 2(cid:96)−1, but their c+-length or c−-length is 2(cid:96)−1. Inductive Hypothesis Assume for some λ, all iterations (cid:96) where λ ≥ (cid:96) ≥ 2 are such that line 5 computes {−1, 0, +1} cost edges of E1-length at least 2(cid:96)−1. Here the 0 cost edges are exact 0 cost paths. The new ±1 edges have c+-length and c−-length of 2(cid:96)−1, respectively. Inductive Step Consider iteration λ + 1 for some λ where λ ≥ (cid:96) ≥ 2. By the inductive hypothesis, in iteration λ = (cid:96), line 5 computes exact 0 cost edges of E1-length at least 2λ−1. In iteration λ = (cid:96), Normalize and Divide by 2 produces new ±1 edges only if they are ±2 edges just generated by line 5. These new ±1 edges have E1 length of at least 2λ−1 by the inductive Hypothesis. Also the inductive Hypothesis indicates these new ±1 edges have c+-length or c−-length of 2(cid:96)−1, respectively. In conclusion, during iteration λ + 1, line 5 combines adjoining +1 and −1 cost edges forming exact 0 cost edges with E1-length at least 2 · 2λ−1 = 2λ. Also, the new +1 edges have c+-length 2λ, and the new −1 edges have c−-length 2λ. This is because new ±2 edges are made by joining ±1 edges from the previous iteration. 17 The algorithm Digraph-flat-exact-paths uses O(log n) algebraic matrix multi- plications. The same is true for the Dyck extension given in Figure 6. Each matrix multiplication costs O(nω log n). This gives a total cost of O(nω log2 n) time for the flat Dyck (semi-Dyck) case. Theorem 1 Given an LDG G = (Σ, V, E1), where Σ is flat Dyck (flat semi-Dyck) and Σ = 2, then Figure 5's algorithm (updated by Figure 6) finds all exact 0 paths in (cid:101)O(nω) time. 4 Exact 0 cost paths and Dyck and semi-Dyck grid graphs Dyck and semi-Dyck languages are generalizations of the Flat Dyck and flat semi-Dyck languages. Grid paths enable the transition from flat grammars to the general case. Each acyclic path in an LDG has an equivalent path in a grid graph. See an example grid graph in Figure 7. Pyramids and valleys are distinct grid graphs. Pyramid paths are generated by the non-terminal P in Definition 6. Pyramids have Dyck labels ak a−k, for k ≥ 1. Two adjoint pyramids in a Dyck grid paths share a valley. This shared valley is not a Dyck path on its own. Indeed, pyramids are building blocks of Dyck paths in grid graphs. In semi-Dyck grid paths, the valleys are themselves semi-Dyck words. That is, pyramids and valleys are building blocks for semi-Dyck paths in grid graphs. Semi-Dyck path valleys are labeled a−k ak, for k ≥ 1. Definition 9 (Pyramids and Valleys) Consider an LDG G = (Σ, V, E1). A Dyck pyramid is a maximal path labeled by ak a−k, for k ≥ 1. A Dyck pyramid path p is maximal since its label is ak a−k and ak+1 a−k−1 does not label a valid Dyck path containing p. Semi-Dyck paths also includes maximal valleys labeled by a−k ak. A peak is labeled a a−1. In a grid graph, a pyramid starting from (i, j) and ending at (i + t, j) has base level j. Figure 9 shows base levels 0, 1 and 2. The y-axis of Figure 7 shows grid levels. In a grid graph, a semi-Dyck path starts from point (0, 0) and ends at some point (x, 0) for an integer x ≥ 0. A Dyck path in a grid graph never has a y coordinate below 0. In general, an LDG +1 edge is equivalent to a grid graph edge going from (x, y) to (x + 1, y + 1), for x ≥ 0. Likewise, an LDG −1 edge is equivalent to a grid graph edge going from (x, y) to (x + 1, y − 1). Let p be an exact 0 cost path in an LDG. In a grid graph p is, p = (x1, y1), (x2, y2), ··· , (xn, yn). so that (x1, y1) = (0, 0), (xn, yn) = (xn, 0), and y1 + ··· + yn = 0. In such a path, its maximal peak(s) are at level max{ y1, ··· , yn }. 18 Figure 7: An exact 0 cost Dyck path on a grid with maximum peak (9, 5) at level 5 Start with an exact 0 cost path p, then two exact 0 cost subpaths p1 and p2 are distinct iff E[p1] ∩ E[p2] = ∅. Suppose p does not form a cycle. Two exact 0 cost distinct subpaths p1 and p2 are adjoining when they share exactly one vertex and have the same base level. This common vertex joins the end of one of these paths to the start of the other. Definition 10 (Pairs) A pyramid pair is an adjoining pair of pyramids. A valley pair is an adjoining pair of valleys. Likewise, a mixed pair is an adjoining pyramid (valley) and valley (pyramid). Figure 8 shows three pyramid pairs in a flat Dyck path. The two left peaks in Figure 9 form a pyramid pair on level 2, but not level 1 or 0. Figure 8: Three pyramid pairs { (1, 2), (2, 3), (3, 4)} in a flat Dyck path Consider an exact 0 cost path forming a pyramid pair. Intuitively, each of these pyramids are independent since Digraph-flat-exact-paths finds their exact 0 paths independently. 4.1 The general case Consider a Dyck pyramid pair ak1 a−k1 ak2 a−k2 for integers k1 ≥ 1, k2 ≥ 1. The word as ak1 a−k1 ak2 a−k2 a−s, 19 has the exterior pair as and a−s, for an integer s ≥ 1, see for example [41]. Exterior pairs are always made of pairs of matching elements. Semi-Dyck words have exterior pairs as and a−s for any integer s (cid:54)= 0. Combining exterior pairs with flat grammars gives the general Dyck and semi-Dyck cases. An isolated pyramid (valley) has no adjoining pyramid (valley). Pyramids and If ak a−k is an isolated pyramid, then it is valleys are isolated by exterior pairs. enclosed by at least one exterior pair. The rightmost pyramid in Figure 9 is an isolated pyramid. This isolated pyramid has label a2 a−2. There is an isolated pyramid pair at base level 2. These two pyramids are on the left. Definition 11 (Isolated paths) In a grid graph, an m isolated path is any maximal sequence of m pyramids or valleys all adjoining at the same base level. A consequence of the definition of an m isolated path is it has no (m+1)st adjoining pyramid or valley. Isolated paths with m = 2 are isolated pairs. Isolated paths with m = 4 are isolated quads. with three peaks in the middle. These pyramids are contained by an exterior pair. The four boxes in Figure 10 are isolated paths. There are also two pyramid pairs An invocation of Digraph-flat-exact-paths runs (cid:100)log n(cid:101) iterations from line 4 in Figure 5. One invocation of Digraph-flat-exact-paths converts all of these isolated paths into exact 0 cost edges. Figure 9: Level 2 has one isolated pyramid pair on the left, level 1 has an isolated pyramid on the right Corollary 3 Given an LDG G1 = (Σ, V, E1), where Σ is Dyck (semi-Dyck) and Σ = 2, then one invocation of Digraph-flat-exact-paths finds an exact 0 cost path for an m isolated path, where m : n/2 ≥ m ≥ 2. Proof: Without loss, the focus is on an m isolated path of pyramids. Since the m ≤ n/2 pyramids form an adjoining isolated path, they all have the same base level. 20 Figure 10: A Dyck or semi-Dyck path with four isolated paths in the boxes This means the m pyramids form a flat Dyck path. So an invocation Digraph-flat- exact-paths computes the flat Dyck reachability of all adjoining pyramid pairs by Lemma 9. A Dyck inner segment is a Dyck word w between a set of exterior pairs as and a−s, for integers s ≥ 1. The word as w a−s labels a valid Dyck path p and s is maximal so as+1 w a−s−1 does not label a valid path containing p. The semi-Dyck case has maximal exterior pairs as and a−s, for integers s (cid:54)= 1. A semi-Dyck inner segment is a semi-Dyck word. Inner segments are contained by pyramid (valley) bases in the Dyck (semi-Dyck) case. If an inner segment is empty, then the exterior pairs as and a−s (a−s and as) form a pyramid (valley), for s ≥ 1. Corollary 4 Given an LDG G(cid:96) = (Σ, V, E(cid:96)), where Σ is Dyck (semi-Dyck) and Σ = 2 and (cid:96) ≥ 2, and suppose an 0 cost edge connects an inner segment of s exterior pairs. Then one invocation of Digraph-flat-exact-paths finds an exact 0 path through this inner segment and these exterior pairs. Proof: Suppose a set of s exterior pairs contains a 0 cost edge. It must be that, s < n/2, and by assumption Digraph-flat-exact-paths already found inner segment's exact 0 cost path by iteration (cid:96). Thus, Digraph-flat-exact-paths finds the exact 0 cost path including these exterior pairs by Lemma 9. Consider Digraph-flat-exact-paths. Finding exact 0 cost paths for isolated paths is not compatible with finding paths in their exterior pairs. This incompatibility is handled by careful iterations of Digraph-flat-exact-paths. See a single iteration in Figure 11. When needed, assume lines 3 and 4 are adapted for the Dyck case, see the discussion accompanying Figure 6. Convention 2 (Atomic invocations of Digraph-flat-exact-paths) For the worst case of Figure 11, the algorithm Digraph-flat-exact-paths is atomic. 21 1. M ← Digraph-flat-exact-paths(G) // Fig. 5 (semi-Dyck add Fig. 6) 2. M ← M + AdjMatrix(G) // original edges plus exact 0 paths 3. M ← M 2 // AGMY multiplication, extending ±1 edges with exact 0 paths 4. M ← Normalize and Divide by 2(M ) Figure 11: A single iteration for solving the general case, the general Dyck or semi- Dyck solution iterates these four steps (cid:100)log n(cid:101) times. One invocation of Digraph-flat-exact-paths, Figure 5, does not find the exact 0 path from start to end of the top path in Figure 12. Similarly, one invocation of semi-Dyck version of Digraph-flat-exact-paths does not find the exact 0 cost path from start to end for the bottom path. Figure 12: Cases where Digraph-flat-exact-paths alone does not work The next discussion illustrates the challenge of atomic invocations of Digraph- flat-exact-paths. Then we show how iterations of Figure 11 correct for these chal- lenges. Using label-costs and node names from 0 to 6, the top path in Figure 12 is, p = 0 +1−→ 1 +1−→ 2 −1−→ 3 +1−→ 4 −1−→ 5 −1−→ 6. The Dyck algorithm Digraph-flat-exact-paths fails to find the exact 0 path for p. To see this, let p1 be the subpath made of the middle two edges, from node 2 to 4. So, p1 is labeled with a−1 a and p1 is not Dyck. In its first iteration, the algorithm −2−→ 6. Also the ±2 edges are normalized to ±1 edges: finds ±2 edges 0 +2−→ 2 and 4 −1−→ 6. In the Dyck case, there are no exact 0 paths to extend these new 0 +1−→ 2 and 4 ±1 edges, so they are removed in the second iteration. This leaves no exact 0 path from 0 to 6. Consider the path p at the top of Figure 12. The semi-Dyck version of Digraph- flat-exact-paths finds the exact 0 cost path along p. This is because the middle two edges, from node 2 to 4, are labeled a−1 a. So in the first iteration, an exact 0 semi-Dyck path is found from 2 to 4. Also in this iteration, as in the Dyck case, a 22 new +1 is created from 0 to 2. Likewise, a −1 edge is created from 4 to 6. All told, in line 9 of the first iteration, the new +1 edge is extended from node 0 to 4 and the −1 edge is extended to go from 2 to 6. Thus, the second iteration finds the semi-Dyck path from 0 to 6. The flat semi-Dyck (Dyck) algorithm Digraph-flat-exact-paths does not find the exact 0 path for the bottom path of Figure 12. This is because in its first iteration it does not find an exact 0 cost path from the first pyramid peak to the fourth pyramid peak. It does find the exact 0 path joining the three exact 0 cost valleys using line 9. This same iteration extends the new ±1 edges after normalizing the ±2 edges at the start and end. The new +1 edge is extended to the second pyramid peak. The −1 edge is extended from the third pyramid peak. These extensions are all done by line 9. So they are computed in the same algebraic matrix multiplication that forms the exact 0 path joining the three valleys. Therefore, the extended ±1 edges cannot reach each other, so in the next iteration they cannot form an exact 0 cost path in line 5. An iterative solution. The general solution is based on iterating invocations of Digraph-flat-exact-paths. See Figure 11. After each run of the flat path algorithm, all original ±1 edges are extended by the new exact 0 paths. Any new ±2 edges are normalized to ±1 edges in preparation for the next iteration. The process is repeated for finding more exact 0 paths. After each invocation of Digraph-flat-exact-paths, all new exact 0 paths remain for subsequent iterations. Figure 13: A worst case Dyck path for t > 2, where the t = 1 case is the empty block attaching its input edge directly to its output edge, giving m = 2 pyramids In Figure 13(a), if the leftmost t − 1 block is empty, the rightmost t − 1 block continues recursively using the Figure 13(b), then the leftmost side is an isolated pyramid. In general, if the leftmost (rightmost) t − 1 block is an isolated path, then it will be replaced by an exact 0 cost path in one invocation of Digraph-flat-exact- paths by Corollary 3. Each time this algorithm find an exact 0 cost path, a new 0 cost edges is created. This is because, for Dyck paths, Corollary 3 shows m > 2 pairs of adjoining pyramids require a single invocation of Digraph-flat-exact-paths. Just the same, a single invocation of Digraph-flat-exact-paths also finds an exact 0 path for pyramid pairs. Indeed, reducing m > 2 adjoining pyramids to m = 2 pyramids, frees vertices to contribute to worst case subpaths. Similarly, Corollary 4 indicates exterior pairs as 23 Figure 14: A worst case semi-Dyck path for t > 2, where the t = 1 case is the empty block attaching its input edge directly to its output edge giving m = 4 pyramids and a−s, for s ≥ 1, may be reduced to exterior pairs a and a−1 where s = 1. Since if s > 1 and say an exact 0 path is known for an inner segment, then one invocation of Digraph-flat-exact-paths finds the exact 0 path through these exterior pairs. Likewise, a single invocation finds the exact 0 path through exterior pairs a and a−1 when the exact 0 path is known for the inner segment. So, a reduced worst case Dyck path has all exterior pairs with s = 1. Reduced semi-Dyck paths have exterior pairs as and a−s, for s ∈ {−1, +1}. Re- duced valleys are labeled a−1 a. Finally, any m > 4 pairs of adjoining pyramids and/or valleys are replaced with m = 4 quads. Worst case semi-Dyck paths are the exact 0 paths given in Figure 14. If there are only three pyramids in Figure 14(a), then they have two adjoining shared valleys. The first iteration of line 5 creates a +2 edge at the start. Likewise, the first iteration creates a −2 edge at the end. These edges are normalized to new ±1 edges in line 7. Finally, line 9 extends the new ±1 edges using the two exact 0 paths just made from the two valleys. This gives a +1 edge adjoining a −1 edge for the next iteration. The next iteration of Digraph-flat-exact-paths combines these edges producing an exact 0 path from the start to the end of this path. In summary, semi-Dyck isolated paths with m ≤ 3 pyramids and/or valleys become exact 0 paths in a single invocation of Digraph-flat-exact-paths. Figure 15: In the Dyck case, if the algorithm in Figure 11 converts the paths p1, p2, p3 and p4 into 0 cost edges, then these are two adjoining augmented pairs contained in an exterior pair Definition 12 (Augmented pairs or quads) A Dyck (semi-Dyck) augmented pair (quad) is a path of two (four) adjoining pyramid (and/or valley) bases whose inner segments 24 are 0 cost edges. All adjoining bases are the same base level and all adjoining bases are contained by an exterior pair. If two augmented pairs adjoin at the same base level, then these augmented pairs become a single augmented pair in one iteration of Figure 11. Another iteration replaces this single augmented pair with a 0 cost edge. In general, say G(cid:48) is a reduced Dyck grid graph with m augmented pairs all adjoining at the same base level. If all augmented pairs in G(cid:48) have the same maximum level peaks, then all augmented pairs become exact 0 cost paths in the same iteration of Figure 11. Figure 13 shows how augmented pairs may be constructed. In particular, each level of augmented pairs is contained by an exterior pair. A new augmented pair may only form if this augmented pair has an adjoint augmented pyramid and both together are contained by an exterior pair. The semi-Dyck augmented quads are similar, see Figure 14. Figure 16: Three reduced worst case Dyck paths Figure 16 gives reduced Dyck path examples with m ∈ { 2, 4, 8 } peaks. In general if t(m) is the number of nodes n in a reduced Dyck path with m peaks, then t(m) = 2 t(m/2)+1 with the base case t(1) = 3. This means t(2) = 7, t(4) = 15 and t(8) = 31. Or if m = 2k, then n = 2k+2 − 1. Lemma 10 Consider a reduced Dyck grid path with m = 2k pyramid peaks and n = 2k+2 − 1 nodes, for an integer k ≥ 1. Suppose one pyramid peak is replaced by a 0 cost edge, then Figure 11 requires fewer than log m iterations to find the exact 0 paths. In a grid graph let p be a reduced Dyck path with m − 1 pyramid peaks, for Proof: m = 2k where k ≥ 1. These peaks are all at maximum level m. Suppose, for the sake of a contradiction, determining that this path p is an exact 0 cost path requires log m iterations. Since there are m = 2k − 1 pyramid peaks at level m, there is at least one pyramid peak that is not in an isolated pair. This single isolated pyramid becomes an exact 0 cost path in the first iteration of Figure 11. So this exact 0 cost path cannot contribute to creating a new augmented pair by an invocation of Digraph-flat-exact-paths. Therefore, at the start of the second iteration of Figure 11, there is an augmented pair that does not have an equivalent neighboring pair to form a new augmented 25 pair. Hence, in the third iteration, there is a new augmented pair just created from two augmented pairs that will not have an equivalent neighboring pair to form a new augmented pair. In general, the after log m − 1 iterations of this process, there are at least log m−1(cid:88) i=1 m 1 2i pyramid peaks that started at the maximum level m but they could not form a new augmented pair. This sum is larger than 1 one peak gives a path with one peak which requires one invocation of the algorithm in Figure 11. In summary, this means the remaining peaks already formed an exact 0 cost path. Thus, giving a contradiction since log m − 1 iterations are sufficient to find this exact 0 cost path. 2 for m ≥ 4. For m = 2 peaks, dropping In general suppose ts(m) is the number of nodes n in a reduced semi-Dyck path with m = 4k peaks, for k ≥ 0. Therefore, ts(m) = 4ts(m/4) − 1 with the base case ts(1) = 3. This means ts(4) = 11 and ts(16) = 43. Or if m = 4k, then n = 22k+1+1 , see [42, A007583]. 3 A proof of the next lemma is similar to the proof of Lemma 10. Lemma 11 Consider a reduced semi-Dyck grid path with m = 4k pyramids or valleys nodes, for an integer k ≥ 1. Suppose one pyramid or valley is replaced and n = 22k+1+1 by an exact 0 path, then Figure 11 requires fewer than log4 m iterations. 3 Lemmas 10 and 11 show the worst case Dyck or semi-Dyck paths have maximum peaks at height O(log m). Moreover, these results indicate it is sufficient to consider m peaks when m is a power of 2 for the Dyck case and powers of 4 for the semi-Dyck case. Lemma 12 Given an LDG G = (Σ, V, E1), where Σ is Dyck (semi-Dyck) and Σ = 2, then a worst case path for iterations of Figure 11 is given by Figure 13 (Figure 14). Proof: Without loss, consider only reduced Dyck paths. All Dyck paths are built from pyramids. In reduced paths, all pyramids are in isolated pyramid pairs. The reduced pyramids are a a−1. Furthermore, all isolated pyramid pairs have an exterior pair as and a−s where s = 1. By Lemma 10, the reduced worst case must start with m = 2k pyramid peaks, for k ≥ 1, at maximum level m. The algorithm in Figure 11 finds the exact 0 path in such paths in (cid:100)log m(cid:101) ≤ (cid:100)log n(cid:101) iterations, since m ≤ n. A similar argument holds in the semi-Dyck case. The main difference is: semi- Dyck paths are built from pyramids and valleys. Moreover, adjoining isolated paths 26 may be reduced to m = 4 adjoining elements that are isolated together. Given these differences, all the Dyck arguments just presented remain the same. This completes the proof. In the next lemma, height of a grid graph is the y value of maximum peak (x, y). Lemma 13 Given an LDG G = (Σ, V, E1), where Σ is Dyck (semi-Dyck) and Σ = 2, then in the worst case finding all exact 0 paths takes (cid:100)log n(cid:101) iterations of Figure 11. Proof: Without loss, the focus is on Dyck paths. Let h(n) be the height of a worst- case Dyck path for iterations of the algorithm in Figure 11. By Lemma 12, the worst-case paths must double their number of isolated pairs at each level. This means after the first iteration, each subsequent iteration of the algorithm in Figure 11 halves the number of augmented pairs. Therefore, h(n) ≤ h((cid:100)n/2(cid:101)) + 1 which immediately means h(n) = O(log n). In particular, the additive term of 1 is for each invocation of Digraph-flat-exact-paths. This section culminates in the main theorem. Theorem 2 Given an LDG G = (Σ, V, E1), where Σ is Dyck (semi-Dyck) and Σ = 2, then Figure 11's algorithm solves Dyck (semi-Dyck) reachability in O(nω log3 n) time. 5 Determining ±1 reachability Determining ±1 path reachability in an LDG is based on 0 cost edges computed by the algorithm in Figure 11. After running this algorithm, each 0 cost edge represents an exact 0 cost reachability path. This reachability is either Dyck and semi-Dyck reachability. Definition 13 Let E∗ contain all 0 cost edges found by running the algorithm in Figure 11 (cid:100)log n(cid:101) times. cost edges E∗. The focus is on the E1 edges of G1 = (Σ, V, E1) in combination with the exact 0 In the case of ±1 reachability, consider the next paths from i to j. Both i −→ k1 0(cid:121) k2 is an exact 0 cost edge from E∗. So, all and k2 −→ j are edges in E1 and k1 cases for i u−→ k1 and k2 v−→ j so that u, v ∈ {−1, +1} are: 27 i +1−→ k1 i +1−→ k1 −1−→ k1 i −1−→ k1 i 0(cid:121) k2 0(cid:121) k2 0(cid:121) k2 0(cid:121) k2 +1−→ j, −1−→ j, +1−→ j, −1−→ j. If these are the only paths from i to j, then there is no exact ±1 path from i to j. Of course, all edges in E∗ are built from edges in E1. An edge is directly from E1 if it is not in an exact 0 cost edge under discussion. Lemma 14 Given an LDG G1 = (Σ, V, E1), its exact 0 cost paths are 0 edges in E∗ where Σ is Dyck (semi-Dyck) and Σ = 2, then all ±1 paths can be found by extending all ±1 edges in E1 with only 0 cost edges in E∗. Consider the edge e1 = i Proof: Without loss, the semi-Dyck case is the focus. Recall, semi-Dyck paths are paths with the same number of +1 and −1 edges from E1. u−→ j in E1, where u ∈ {−1, +1}, so that there is a 0 cost edge from k1 to k2 in E∗. Let k1 0(cid:121) k2 be this ±1−→ j, is a ±1 path 0 cost edge in E∗. Suppose, for the sake of a contradiction, that i that is not discovered by extending e1 with edges from E∗. Consider the next cases. ±1−→ k1 ∈ E1 and another edge e2 = k2 Case 1: If e1 and e2 have different signs. If e1 and e2 have different signs, then the entire path i 0−→ j is another 0 cost edge in E∗ found by the algorithm in Figure 11. This is a contradiction, since in this case joining e1 and e2 does not create a ±1 edge. Case 2: If e1 and e2 have the same sign. 0(cid:121) k2 from E∗ between the edges e1 to e2 gives a ±2 Given the exact 0 edge k1 Say the path p1,2 contributes to a ±1 edge in combination with another opposite 0(cid:121) ±1 e2. ±1 e1 path: p1,2 = sign edge e3. There are two subcases that both lead to contraditions. Subcase 2a: ±1 e1 0(cid:121) ±1 e2 0(cid:121) ∓1 e3. This subcase gives p2,3 = and edge in E∗. Therefore, the ±1 reachabilty of e3 which has exact cost 0. Thus, p2,3 must be e3 requires only 0(cid:121) ±1 e2 0(cid:121) ∓1 ±1 e1 ±1 e2 0(cid:121) ∓1 28 e1 = i ±1−→ k1 to be directly from E1. Subcase 2b: ∓1 e3 0(cid:121) ±1 e1 0(cid:121) ±1 e2. This subcase gives p3,1 = E∗. This means the ±1 reachabilty of to be directly from E1. ∓1 e3 0(cid:121) ±1 e1 which also has cost 0. Thus, p3,1 must be in ±1−→ j e2 requires only e2 = k2 0(cid:121) ∓1 ∓1 e3 0(cid:121) ±1 e1 Since Dyck languages are also semi-Dyck, the proof is complete. {−1, 1} is the same as determining all 0 reachability in G. Finding all exact 0 cost edges in an LDG G with all edges initially labeled from Consider the output E∗ from Figure 11. Lemma 14 indicates finding all exact ±1 cost paths may be computed as the AGMY matrix product, where M is the adjacency matrix of the given LDG G = (V, E1). This costs (cid:101)O(nω). E∗ M E∗ 6 Conclusion Combining Theorem 2 with Lemma 14 gives useful results for finding exact Dyck and semi-Dyck paths in digraphs. Starting with an LDG G = (Σ, V, E1), where Σ is Dyck with Σ = 2, then all {−1, 0, +1} cost edges can be found in in O(nω log3 n) time. A number of powerful techniques can reduce this cost by polylog factors giving (cid:101)O(nω), see [15, 38, 25, 18, 26]. In particular, Zwick [18] outlines such improvements nicely. Acknowledgments Thanks to Emily Proulx and Sarthak Behl for contributing example inputs and dis- cussing applications of these results. Thanks to Derek Morris for pointing out interesting applications as well as his encouragement. 29 References [1] P. G. Bradford, "Efficient exact paths for Dyck and semi-Dyck labeled path reach- ability," in IEEE 8th Annual Ubiquitous Computing, Electronics Mobile Commu- nication Conference (UEMCON). IEEE Press, 2017, pp. 247 -- 253. [2] M. Nykanen and E. Ukkonen, "The exact path length problem," J. Algorithms, vol. 42, no. 1, pp. 41 -- 53, Jan. 2002. [3] L. Lee, "Fast context-free grammar parsing requires fast Boolean matrix multi- plication," Journal of the ACM, vol. 49, no. 1, pp. 1 -- 15, 2002. [4] C. Barrett, R. Jacob, and M. Marathe, "Formal language constrained path prob- lems," SIAM Journal on Computing, vol. 30, no. 3, pp. 809 -- 837, 2001. [5] R. Greenlaw, H. J. Hoover, and W. L. Ruzzo, Limits to Parallel Computation: P-Completeness Theory. Oxford University Press, 1995. [6] F. Afrati and C. Papadimitriou, "The parallel complexity of simple chain queries," in Proc. of the 6th ACM Symposium on Principles of Database Systems (PODS '87). New York, NY, USA: ACM, 1987, pp. 210 -- 213. [7] T. Reps, "On the sequential nature of interprocedural program-analysis problems," Acta Inf., vol. 33, no. 5, pp. 739 -- 757, Aug. 1996. [Online]. Available: http://dx.doi.org/10.1007/BF03036473 [8] J. D. Ullman and A. Van Gelder, "Parallel complexity of logical query programs," in 27th Annual Symposium on Foundations of Computer Science, Oct 1986, pp. 438 -- 454. [9] M. Yannakakis, "Graph-theoretic methods in database theory," in PODS '90: Proceedings of the ninth ACM SIGACT-SIGMOD-SIGART symposium on Prin- ciples of database systems. New York, NY, USA: ACM Press, 1990, pp. 230 -- 242. [10] D. Coppersmith and S. Winograd, "Matrix multiplication via arithmetic progres- sions," Journal of Symbolic Computation, vol. 9, no. 3, pp. 251 -- 280, 1990. [11] A. J. Stothers, "On the complexity of matrix multiplication," Ph.D. dissertation, University of Edinburgh, School of Mathematics, 2010. [12] V. V. Williams, "Multiplying matrices faster than Coppersmith-Winograd," in Proceedings of the Forty-fourth Annual ACM Symposium on Theory of Comput- ing, ser. STOC '12. New York, NY, USA: ACM, 2012, pp. 887 -- 898. [13] F. Le Gall, "Powers of tensors and fast matrix multiplication," in Proceedings of the 39th International Symposium on Symbolic and Algebraic Computation, ser. ISSAC '14. New York, NY, USA: ACM, 2014, pp. 296 -- 303. 30 [14] D. Melski and T. Reps, "Interconvertibility of a class of set constraints and context-free-language reachability," Theor. Comput. Sci., vol. 248, no. 1-2, pp. 29 -- 98, Oct. 2000. [15] N. Alon, Z. Galil, and O. Margalit, "On the exponent of the all pairs shortest path problem," Journal of Computer and System Sciences, vol. 54, no. 2, pp. 255 -- 262, 1997. [16] T. Takaoka, "Subcubic cost algorithms for the all pairs shortest path problem," Algorithmica, vol. 20, no. 3, pp. 309 -- 318, 1998. [17] Z. Galil and O. Margalit, "All pairs shortest paths for graphs with small integer length edges," Journal of Computer and System Sciences, vol. 54, no. 2, pp. 243 -- 254, 1997. [18] U. Zwick, "All pairs shortest paths using bridging sets and rectangular matrix multiplication," J. ACM, vol. 49, no. 3, pp. 289 -- 317, May 2002. [19] P. G. Bradford and D. A. Thomas, "Labeled shortest paths in digraphs with negative and positive edge weights," RAIRO - Theoretical Informatics and Ap- plications, vol. 43, no. 3, pp. 567 -- 583, 2009. [20] P. G. Bradford, "Quickest path distances on context-free labeled graphs," in 6th WSEAS Int.Conf. on Info., Security and Privacy (ISP '07), 2007, pp. 22 -- 29. [21] P. G. Bradford and V. Choppella, "Fast point-to-point Dyck constrained shortest paths on a DAG (extended abstract)," in IEEE 7th Annual Ubiquitous Computing, Electronics Mobile Communication Conference (UEMCON). IEEE Press, 2016, pp. 1 -- 7. [22] E. Khamespanah, R. Khosravi, and M. Sirjani, "Efficient TCTL model checking algorithm for timed actors," in Proceedings of the 4th International Workshop on Programming Based on Actors Agents & Decentralized Control, ser. AGERE! '14. New York, NY, USA: ACM, 2014, pp. 55 -- 66. [23] C. B. Ward, N. M. Wiegand, and P. G. Bradford, "A distributed context-free language constrained shortest path algorithm," in 2008 37th International Con- ference on Parallel Processing, Sept 2008, pp. 373 -- 380. [24] C. B. Ward and N. M. Wiegand, "Complexity results on labeled shortest path problems from wireless routing metrics," Comput. Netw., vol. 54, no. 2, pp. 208 -- 217, Feb. 2010. [25] S. Chaudhuri, "Subcubic algorithms for recursive state machines," in Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Pro- gramming Languages, ser. POPL '08. New York, NY, USA: ACM, 2008, pp. 159 -- 169. 31 [26] W. Rytter, "Fast recognition of pushdown automaton and context-free lan- guages," Information and Control, vol. 67, no. 1, pp. 12 -- 22, 1985. [27] H. Yuan and P. Eugster, An Efficient Algorithm for Solving the Dyck-CFL Reach- ability Problem on Trees. Berlin, Heidelberg: Springer Berlin Heidelberg, 2009, pp. 175 -- 189. [28] Q. Zhang, M. R. Lyu, H. Yuan, for dyck-cfl-reachability with applications to alias analysis," SIGPLAN Not., vol. 48, no. 6, http: //doi.acm.org/10.1145/2499370.2462159 "Fast algorithms and Z. Su, pp. 435 -- 446, Jun. 2013. [Online]. Available: [29] Q. Zhang and Z. Su, "Context-sensitive data-dependence analysis via linear conjunctive language reachability," SIGPLAN Not., vol. 52, no. 1, pp. 344 -- 358, Jan. 2017. [Online]. Available: http://doi.acm.org/10.1145/3093333.3009848 [30] N. Hollingum and B. Scholz, Towards a Scalable Framework for Context-Free Language Reachability. Berlin, Heidelberg: Springer Berlin Heidelberg, 2015, pp. 193 -- 211. [31] A. Chakrabarti, G. Cormode, R. Kondapally, and A. McGregor, "Information cost tradeoffs for augmented index and streaming language recognition," SIAM J. Comput., vol. 42, no. 1, pp. 61 -- 83, 2013. [32] H. Tang, D. Wang, Y. Xiong, L. Zhang, X. Wang, and L. Zhang, "Conditional dyck-cfl reachability analysis for complete and efficient library summarization," in Programming Languages and Systems, H. Yang, Ed. Berlin, Heidelberg: Springer Berlin Heidelberg, 2017, pp. 880 -- 908. [33] G. Grahne, A. Thomo, and W. W. Wadge, "Preferential regular path queries," Fundam. Inform., vol. 89, no. 2-3, pp. 259 -- 288, 2008. [34] V. Choppella and C. T. Haynes, "Source-tracking unification." Inf. Comput., vol. 201, no. 2, pp. 121 -- 159, 2005. [35] G. Yuval, "An algorithm for finding all shortest paths using n2.81 infinite-precision multiplications," Inform. Process. Lett., vol. 4, no. 6, pp. 155 -- 156, 1976. [36] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algo- rithms (3rd edition). MIT Press, 2009. [37] P. W. Purdom, "A transitive closure algorithm," BIT Numerical Mathematics, vol. 10, no. 1, pp. 76 -- 94, 1970. [38] A. V. Aho, J. E. Hopcroft, and J. D. Ullman, The Design and Analysis of Com- puter Algorithms, 1st ed. Boston, MA, USA: Addison-Wesley Longman Publish- ing Co., Inc., 1974. 32 [39] A. Shoshan and U. Zwick, "All pairs shortest paths in undirected graphs with IEEE, integer weights," in IEEE Foundations of Computer Science Conference. 1999, pp. 605 -- 615. [40] F. Romani, "Shortest-path problem is not harder than matrix multiplication," Inform. Process. Lett., vol. 11, no. 3, pp. 134 -- 136, 1980. [41] A. Denise and R. Simion, "Two combinatorial statistics on dyck paths," Discrete Mathematics, vol. 137, no. 1, pp. 155 -- 176, 1995. [Online]. Available: http://www.sciencedirect.com/science/article/pii/0012365X93E0147V [42] N. J. A. Sloane (editor). The on-line encyclopedia of integer sequences. Accessed: 2018-02-11. [Online]. Available: https://oeis.org 33
1912.12409
1
1912
2019-12-28T06:22:28
Online Rainbow Coloring In Graphs
[ "cs.DS", "cs.DM" ]
Rainbow coloring is a special case of edge coloring, where there must be at least one path between every distinct pair of vertices that consists of different color edges. Here, we may use the same color for the adjacent edges of a graph representing two different paths from a single vertex. In online rainbow coloring, we have no priori knowledge about the vertices and edges of the graph, in fact the edges are available one by one. We have to color an edge as soon as it arrives and before the arrival of the next edge. We can not revoke the coloring decision once it is made. According to our knowledge, there is no study of online rainbow coloring for graphs. In this paper, we make a first attempt to propose an online algorithm named Least Recently Used Color(LRUC) for online rainbow coloring. We analyze the performance of LRUC through competitive analysis. We show that LRUC is optimal for line graph, tree and star graph. For 1-cyclic graph, LRUC is shown to be (2-2/n)-competitive, where n>3. We obtain the competitive ratios of (n-1)/3 and n-1 for wheel and complete graphs respectively, where n is the number of vertices.
cs.DS
cs
Online Rainbow Coloring In Graphs 1 Debasis Dwibedy, Rakesh Mohanty and Arun Khamari Department of Computer Science and Engineering Veer Surendra Sai University of Technology Burla, Odisha, India, 76018 Email: [email protected], [email protected], [email protected] Abstract Rainbow coloring is a special case of edge coloring, where there must be atleast one path between every distinct pair of vertices that consists of different color edges. Here, we may use the same color for the adjacent edges of a graph representing two different paths from a single vertex. In online rainbow coloring, we have no priori knowledge about the vertices and edges of the graph, infact the edges are available one by one. We have to color an edge as soon as it arrives and before the arrival of the next edge. We can not revoke the colorinng decision once it is made. According to our knowledge, there is no study of online rainbow coloring for graphs. In this paper, we make a first attempt to propose an online algorithm named Least Recently Used Color(LRUC) for online rainbow coloring. We analyze the performance of LRUC through competitive analysis. We show that LRUC is optimal for line graph, tree and star graph. For 1-cyclic graph, LRUC is shown to be (2 − 2 n )-competitive, where n ≥ 4. We obtain the competitive ratios of n−1 3 and n − 1 for wheel and complete graphs respectively, where n is the number of vertices. A. Online Algorithm and Competitive analysis I. INTRODUCTION A computational problem is online when the inputs of the problem are available one by one and an immediate action is desired after arrival of each new input. The algorithm designed for an online computational problem is called online algorithm(ONL) [1]. Here, the algorithm takes a sequence of decisions by considering present and past inputs without knowledge of future inputs. Formally, suppose we have an input sequence I=< i1, i2, .., in > of finite size n, where i1 is available at time t = 1 , i2 is available at t = 2 and so on. At any given t the input instances It are only known and the input instances It′ are unknown to the algorithm, where t′ > t. Optimal offline algorithm(OPTL) is the one that has prior knowledge about the entire inputs and incurs minimum cost among all offline algorithm. 2 The performance of ONL can be measured through competitive analysis [2]. Here, the cost of ONL is compared to the cost of the OPTL. Let ON L(I) and OP T L(I) be the cost obtained by ON L and OP T L respectively for processing of the input sequence I. ON L can be s-competitive if and only if ON L(I) ≤ s.OP T L(I) + b, where b is a positive constant. 1) Rainbow coloring: Rainbow coloring [3] of a non-trivial connected simple graph G(v, e) is a special case of edge coloring where all vertices pair in G(v, e) must have atleast 1 rainbow path. A rainbow path exists between a pair of vertices if and only if all edges in the path must have different colors. Formally, we define the rainbow coloring of the edges in G(v, e) as c : e(G) → {1, 2, ......k}, where k ≥ 1. Here, c is a rainbow k-coloring as k different colors are used. Our objective is to minimize k while making G(v, e) rainbow colored. The minimum value of k for G(v, e) is the rainbow connection number rc(G) of G(v, e). 2) Offline rainbow coloring: The rainbow coloring is offline when the algorithm has complete knowl- edge about all vertices and edges of the graph prior to make a coloring decision. All the components of the graph are processed and colored simultaneously. Formally, suppose we have a non-trivial connected graph G(v, e) with n vertices vi(i = 1, 2, .....n) and m edges ej(j = 1, 2, .....m). All vi and ej are given as inputs to the offline algorithm in advance. The algorithm processes the input graph as a whole and produces a rainbow coloring of the edges of the graph. We denote rc(G) obtains by OPTL as rcOP T L(G). For a simple illustration, we take a cyclic graph with 3 vertices(C3) in figure 1(a) and present an offline rainbow coloring of C3. 3) Online Rainbow Coloring: In online rainbow coloring, the inputs are a non-trivial un-directed connected simple graph G and a set of colors c. The output is a rainbow colored graph, where there must be atleast one rainbow path between every distinct pair of vertices. Our goal is to use minimum colors while making G rainbow colored. We have constraints such as the edges of G are unknown at the begining and are available one by one in an order. The edge needs to be colored as soon as it arrives and prior to the arrival of the next edge. The coloring decision is irrevocable. The assumption is that the partial graph formed after the addition of each new edge must be connected. For simple illustration, we take C3 in figure 1(b) and present an online rainbow coloring of C3. 4) Practical motivation: Rainbow coloring can be used as a mechanism for frequency distribution among different links of a cellular network [4, 5]. If it is required distinct communication channels between a pair of mobile stations to communicate, then rainbow coloring can be applied to minimize the number of unique channels in the whole network. 5) Research motivation: Computing rc(G) of a non-trivial connected graph G(v, e) has been proved to be NP-Hard [5]. It is non-trivial to decide whether a given coloring in an edge colored graph also holds the minimum colors to make the graph rainbow colored [5]. The problem becomes trivial when fixed number of colors are used. However, the problem is NP-Complete if the coloring is arbitrary [6]. 3 II. BACKGROUND AND PRELIMINARIES 1) Definitions and Notations : • A graph is Connected if it has atleast one path between each vertices pair [7]. • Non-trivial graph(G) is a simple connected graph with atleast two edges [7]. • Size of graph(m) denotes the total number of edges of the graph [7]. • Degree of a vertex(deg(v)) denotes the number of edges incident on v [7]. • We call a vertex vi as pendant, if deg(vi) = 1 [8]. • Diameter(diam(G)) of a graph is the largest distance between two vertices vi, vk, which is maximum over the distances between all pairs of vertices in a graph [7, 8]. • A graph G(v, e) is rainbow connected if there exists atleast one rainbow path between every pair of vertices [3]. • Online Rainbow Connection Number(rconline(G)) denotes the number of colors used through online rainbow coloring [3]. • A simple connected non-trivial graph is Complete (Kn) if all distinct pair of vertices are adjacent to each other [4, 7]. • Line graph(Ln) is a simple graph where the vertices are in one-one correspondence with the edges. Here, vi is adjacent to vi−1 and vi+1, for each i, 2 ≤ i ≤ n − 1, where, v1 and vn are adjacent to only v2 and vn−1 [4, 7]. • In a Regular graph(Rn) with n vertices, every vertex has equal degree. Suppose in Rn, every vertices have degree equals to r, then Rn is called r-regular [4, 7]. • A Cyclic graph(Cn) is basically a 2-regular graph where number of vertices is equal to number of edges [7, 8]. If there exists only 1 cycle in Cn, then we call Cn as 1-Cyclic. • Wheel graph(Wn) is a cyclic graph with an additional vertex which is connected to every other vertices of the cyclic graph Cn−1 [7]. 2) Overview of Related Work : Offline rainbow coloring has been studied for graphs with limitless variants since the seminal work of Chartrand and et.al. in [3]. To acquaint with the state of the art literature and recent advancements in offline rainbow coloring, see survey [7]. In our concern, there is no study in the literature for online rainbow coloring in graphs. However, for the competitive analysis of our proposed online algorithm LRUC, we must know about the optimal offline strategy for rainbow coloring in various graphs. Therefore, we present an overview of some important contributions and results in offline rainbow connections of graphs as follows. Chartrand and et.al. [3] introduced rainbow coloring in graphs. They showed that rc(Kn) = 1 and 4 rc(Tn) = m. They proved rc(Wn) = 3, for n ≥ 8 and rc(Cn) = ⌈ n 2 ⌉, where n ≥ 4. For the complete bipertite graph Kp,q, they obtained rc(Kp,q) = 2. Caro and et. al. [9] studied the rainbow connections in graph (G) with minimum degree of G. They obtained rc(G) < 5 minimum degree of G. They proved that rc(G) ≤ min{n ln(δ) 6 n for δ(G) ≥ 3, where δ(G) is the } for connected graph δ (1+oδ)(1), n 4ln(δ)+3 δ G with n vertices and minimum degree δ(G). The hardness of rainbow coloring in graphs was studied in [4,5]. In [4], authors proved that computing rc(G) for any G is NP-Hard. In [5], it was shown that obtaining rc(G) ≤ k for any given k is NP-Complete. Chartrand and et. al. [10] defined k-connectivity of G as rck(G). They obtained rck(Kn) = 2, for any integer k ≥ 2 if there exists an integer f (k), where f (k) ≤ n. In bipartite graph, they showed that for every k ≥ 2, there is an integer r such that rcK(Kr,r) = 3. Krivelevich and Yuster [11] defined rainbow vertex connection rvc(G) for any G. They proved that rvc(G) < 11n δ . Schiermeyer [12] addressed the conjecture of Caro and et. al. [9]. He proved 4 for δ ≥ 3. Chandran and et. al. [13] showed that diam(G) ≤ rc(G) ≤ diam(G) + 1, where G is an interval graph and δ ≥ 2. They proved rc(G) = diam(G) if G is an unit interval graph. that rc(G) < 3n For circular arc graph, they obtained the inequality diam(G) ≤ rc(G) ≤ diam(G) + 4. Chartrand and et. al. [14] defined k-rainbow coloring as an edge coloring of G such that for every set A ⊆ k vertices of G, there exists a rainbow tree Tn in G such that A ⊆ v(T ), where v(T ) is the number of vertices of Tn. They defined k-rainbow index rxk(G) as the minimum number of colors required to k-rainbow color G. They showed that rxk(G) = n − 2 if k = 3 and girth g ≥ 4. For uni cyclic graph of order n ≥ 3, they obtained rxk(G) = n − 1. Li and Sun [15] addressed the open question put by Chartrand et. al. in [10] to determine rck(Kr,r). They showed that rck(Kr,r) = 3, where r ≥ 2k⌈ k 2 ⌉ and k ≥ 2. In [16], Li and Sun studied for computing rc(G), where G is a line graph(Ln) that consists of triangles. They obtained two upper bounds on rc(G) for Ln in terms of number of edge disjoint triangles of Ln. Li and et. al. [17] obtained rc(G) ≤ 5 if G is a bridge less graph and diam(G) = 2. They showed that rc(G) ≤ k + 2 for any connected G with diam(G) = 2 and k bridges, where k ≥ 1. Li and et. al. [18] proved that rc(G) ≤ ⌈ n 2 ⌉ for n ≥ 3, where G is a 2-connected graph. Dudek and et. al. [19] studied rainbow connection of random r-regular graph G(n, r) of order n, where r ≥ 4. They proved that rc(G) = O(logn). III. OUR CONTRIBUTION AND RESULTS 1) Online Rainbow Coloring Algorithm: According to our knowledge their is no study of online algorithm for rainbow coloring in the literature. We make a first attempt to propose an online rainbow coloring algorithm named Least Recently Used Color(LRUC) for various types of graphs such as line, tree, star, cyclic, wheel, complete and bipartite. The pseudocode of LRUC algorithm is presented as 5 follows. Algorithm 1 LRUC 1: Initially, i=1, j=1, Set of Colors c : {c1} 2: Assign color c1 to the first edge e1. 3: j=j+1. 4: WHILE a new edge ej arrives 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: BEGIN IF ej is adjacent to only one already arrived edge. THEN i=i+1. Assign a new color ci to ej . Insert the new color ci to the set of colors c. END IF. ELSE IF ej is adjacent to atleast two already arrived edges. IF one of the vertex of ej has degree 1. THEN i=i+1. Assign a new color ci to ej . Insert ci to the set of colors c. END IF. ELSE IF both the vertices of ej has degree atleast 2. THEN Assign the least recently used color from the set of colors. END ELSE IF. END ELSE IF. j=j+1 END WHILE 23: Return Set of Colors c. 24: END Theorem. 1. LRUC is 1-competitive for class A, where A ∈ G and A = {Ln, Tn, Sn}. Proof: For the competitive analysis of LRUC, we have to first compute the cost of OPTL, then the cost of LRUC. The ratio between the cost of LRUC and cost of OPTL gives us the competitive ratio of LRUC for any G, which is the performance indicator for LRUC. So, first we verify for (Ln) as follows. Computation of OPTL: In Ln, all edges are adjacent to its previous and next edge. However, the first edge e1 is adjacent to only its next edge e2 and the last edge en−1 is adjacent to only its previous edge en−2. This structure of a line graph sets up only one path between the extreme vertices pair(v1, vn) through 6 the edges e1, e2....en−1. So, to satisfy the rainbow coloring property, OPTL uses distinct colors for all edges from e1 to en−1. Therefore, rcOP T L(Ln) ≤ n − 1. (1) Computation of LRUC: LRUC assigns a new color to each incoming edge ej of the line graph(Ln). Because each ej , where 1 ≤ j ≤ n − 1 has atleast one pendant vertex. Therefore, the minimum number of colors required for Ln is equal to n − 1. Formally suppose we have n vertices, then the geodesic from v1 to vn contain n − 1 edges where all edges must be colored different. Therefore, we have rcLRU C (Ln) ≤ n−1. From equations (1) and (2), we can have: rcLRU C(Ln) rcOP T L(Ln) = n−1 n−1 = 1. (2) Now, we verify for (Tn) as follows. Computation of OPTL: OPTL uses m colors to make a tree rainbow colored, where m is the size of the tree [3]. Therefore, we have rcOP T L(Tn) = m. (3) Computation of LRUC: We can use at most m colors to make any graph rainbow colored. Suppose we use k colors for rainbow coloring in tree, where k < m. The edges of the tree are available one by one, so, every newly arrive edge must have a pendant vertex. Hence, the new edge becomes the part of the unique path from the pendant vertex to every other known vertices of the tree. Therefore, we have to use different colors to each incoming edge. If we use any existing color, then there must be an altenate path from the pendant vertex to atleast one known vertex. This indicates the existance of a cycle in the tree, which is a contradiction. So, we must use the number of colors equal to the size of the tree not less than that. There- fore, we have rcLRU C (Tn) = m. From equations (3) and (4), we have rcLRU C(Tn) rcOP T L(Tn) = m m = 1. (4) Now, we verify for (Sn) as follows. Computation of OPTL: In Sn, all edges are adjacent to each other through a central vertex. Let the central vertex be v1. So, every distinct (vi, vk) pairs, where 2 ≤ (i, k) ≤ n have an unique path of length 2 and for each vi, where 2 ≤ i ≤ n, the path between (v1, vi) is of length 1. Therefore, Sn consists of n − 1 pendant vertices. OPTL initiates the rainbow coloring by choosing any of the pendant vertex (let, v2) and explore the paths to all other vi, where, 3 ≤ i ≤ n. So, OPTL uses 2 colors that satisfies the rainbow coloring property between v2 and every other vi. Subsequently, the next pendant vertex(let, v3) is chosen and the unknown paths to other vi, where, 4 ≤ i ≤ n are explored. Here, we use an additional color besides the 2 earlier used colors because if we use an existing color, then there would be no rainbow path either between v2 and atleast one of the other vi, where 3 ≤ i ≤ n or between v3 and atleast one of 7 the other vi, where 2 ≤ i ≤ n (as Sn is a simple graph, we can ignore edges from vi to vi). Similarly, by considering rest of the n − 3 pendant vertices one by one, we use an additional n − 3 colors. So, in total we use n − 1 colors, which is equal to the size of Sn i.e. m. Therefore, we have rcOP T L(Sn) = m. (5) Computation of LRUC: Online Rainbow coloring of Tn and Sn are identical. We refer to the computation of LRUC for Tn as a proof for online rainbow coloring of Sn. Therefore, we have rcLRU C (Sn) = m. From equations (5) and (6) we have rcLRU C(Sn) rcOP T L(Sn) = m m = 1. (6) Theorem. 2. LRUC is (2 − 2 n )-competitive for Cn, where Cn is 1-Cyclic and n ≥ 4. Proof: For the optimal offline rainbow coloring, we refer to the policy of Chartrand and et.al. [3]. OPTL uses ⌈ n 2 ⌉ colors for Cn, where n ≥ 4 [3]. Therefore, we have rcOP T L(Cn) = ⌈ n 2 ⌉ (7) Computation of LRUC: Suppose Cn contains 1 cycle of length n with vertices (v1, v2, ....vn−1, vn, v1). In worst case, edges(ej) arrive one by one in the order: e1(v1, v2), e2(v2, v3)....en−1(vn−1, vn). LRUC assigns a new color to each ej till the arrival of en−1. In any incoming ej , where 2 ≤ j ≤ n − 1, if we use an existing color, then there would not be a rainbow path between extreme pair of vertices v1 and vn+1 as both are pendant now. So, we bound to use n − 1 colors. The arrival of en(vn, v1) completes the cycle and can be colored with c1 as v1, vn are adjacent now. Therefore, we have rcLRU C (Cn) = n−1. From equations (7) and (8), we have: rcLRU C(Cn) rcOP T L(Cn) = n−1 2 ⌉ ≤ n−1 ( n ⌈ n 2 ) ≤ 2(n−1) n ≤ 2n−2 n ≤ 2 − 2 n . Theorem. 3. LRUC is ( n−1 3 )-competitive for Wn, where n ≥ 8. Proof : OPTL uses 3 colors for rainbow coloring in Wn, where n ≥ 8 [3]. Therefore, rcOP T L(Wn) = 3. (8) (9) Computation of LRUC: In Wn, let v1 be the central vertex connected to each vi, where i ≤ 2 ≤ n. In the worst case, first the internal n − 1 edges arrive one by one in any order. The internal n − 1 edges form Sn by connecting v1 to each vi, where i ≤ 2 ≤ n. So, LRUC uses n − 1 colors to the internal n − 1 edges due to equation (6). Irrespective of the order of arrival of the external n − 1 edges connecting distinct (vi, vk), where 2 ≤ (i, k) ≤ n, LRUC uses least recently used color to each ej, where n ≤ j ≤ 2n − 2. Therefore, rcLRU C(Wn) = n−1. From equations (9) and (10), we have rcLRU C(Wn) rcOP T L(Wn) = n−1 3 . Theorem. 4. LRUC is (n − 1)-competitive for Kn. 8 (10) Proof : In Kn, all distinct pair of vertices(vi, vk) are adjacent to each other, where 1 ≤ (i, k) ≤ n. So, OPTL assigns 1 color to each ej [3]. Therefore, rcOP T L(Kn) = 1 (11) Computation of LRUC: In the worst case, the first n − 1 edges of Kn arrive in the order of the line graph(Ln) i.e. e1(v1, v2), e2(v2, v3)...en−1(vn−1, vn). So, LRUC uses n − 1 different colors to the first n − 1 edges due to equation (2). For rest n2−3n+2 edges, LRUC uses least recently used color at each 2 time when ej arrives irrespective of its order of arrival because the vertices of each ej have degree atleast 2 as each ej must adjacent to atleast 2 already arrived edges, where n ≤ j ≤ n(n−1) . 2 Therefore, rcLRU C(Kn) = n − 1 From equations (11) and (12) we have rcLRU C(Kn) rcOP T L(Kn) = n−1 1 = n − 1. (12) IV. CONCLUSION We have studied rainbow coloring of graphs in an algorithmic perspective, where the components of the graph such as edges available one by one to the algorithm unlike the whole graph in traditional rainbow coloring problem of Chartrand and et. al. [3]. We have proposed the first online algorithm named LRUC for the online rainbow coloring problem. We have proved LRUC be the optimal online algorithm for special classes of graphs such as line, tree and star. LRUC has been shown to be (2- 2 n )- competitive for cyclic graph which contains only one cycle and atleast four vertices. We have obtained the competitive ratios of n−1 3 and n − 1 for wheel and complete graph respectively. We have observed that the performance of LRUC depends on the order of availability of the edges of any graph. Due to lack of knowledge about the whole graph, LRUC obtains greater rainbow connection number than the optimal offline algorithm(OPTL). Therefore, it will be interesting to investigate for a better online algorithm that perform near equal to OPTL. Further, LRUC can be studied for online rainbow coloring in other graphs. [1] A. Borodin, R.EI-Yaniv. Online computation and competitive analysis. Cambridge University Press, Cambridge, 1998. REFERENCES 9 [2] D.D. Sleator and R.E. Tarjan. Amortized efficiency of list update and paging rules. Communications of the ACM, 28 (2), pp. 202-208, 1985. [3] G. Chartrand, G.L. Johns, K.A. McKeon and P. Zhang. Rainbow connection in graphs. Mathematica Bohemica, 133(1), pp. 85-98, 2008. [4] X. Li, Y. Shi and Y. Sun. Rainbow connections of graphs: A survey. Graphs and Combinatorics, 29(1), pp. 1-38, 2013. [5] S. Chakraborty, E. Fischer, A. Matsliah and R. Yuster. Hardness and algorithms for rainbow connection. Journal of Combinatorial Optimization, 21(3), pp. 330-347, 2009. [6] P. Ananth, M. Nasre and K. K. Sarpatwar. Rainbow connectivity: Hardness and tractability. In FSTTCS, pp. 241-251, 2011. [7] J.A. Bondy and U.S.R. Murthy. Graph Theory. Graduate Texts in Mathematics, 244, Springer, 2008. [8] J. Bang-Jensen, G. Gutin. Diagrphs: Theory, Algorithms and Applications, 2nd, Springer-Verlag, London, 2009. [9] Y. Caro, A. Lev, Y. Roditty, Z. Tuza, and R. Yuster, On rainbow connection. Electronics Journal Combinatorics, 15(1), 2008. [10] G. Chartrand, G.L. Johns, K.A. McKeon and P. Zhang. The rainbow connectivity of a graph, pp.75-81, 2009. [11] M. Krivelevich and R. Yuster. The rainbow connection of a graph(at most) reciprocal to its minimum degree. Journal of Graph Theory, 63(3), pp. 185-191, 2010. [12] I. Schiermeyer. Rainbow connection in graphs with minimum degree three. In Journal of Combinatorial Algorithms, 5874, pp. 432-437, LNCS, Springer Berlin/Heidelberg, 2009. [13] L. Sunil Chandran, A. Das, D. Rajendraprasad and N. M. Varma. Rainbow connection number and connected dominating sets. Journal of Graph Theory, pp. 206-218, 2012. [14] G. Chartrand, F. Okamoto and P. Zhang. Rainbow trees in graphs and generalized connectivity. Networks, 55, pp. 360-367, 2010. [15] X. Li and Y. Sun. Note on the Rainbow k-connectivity of Regular Complete Bipartite Graphs. arXiv: 1004.2312v1[math.CO], 2010. [16] X. Li and Y. Sun. Upper bounds for the rainbow connection numbers of line graphs. Journal of Graphs and Combinatorics, 28, pp. 251-263, 2012. [17] H. Li, X. Li and S. Liu. Rainbow connections in Graphs with diameter 2. Arxiv preprint arXiv:1101.2765v1[math.CO], 2011. [18] X. Li, S. Liu, L.S. Chandran, R. Mathew and D. Rajendraprasad. Rainbow connection number and connectivity. Electronics Journal of Combinatorics, 19(1), P20, 2012. [19] A. Dudek, A. Frieze and C.E. Tsourakakis. Rainbow connections of random regular graphs. SIAM Journal of Discrete and Applied Mathematics, 29(4), pp. 2255-2266, 2015. This figure "figure_1.PNG" is available in "PNG"(cid:10) format from: http://arxiv.org/ps/1912.12409v1 This figure "offlineandonlinerainbowcoloring.PNG" is available in "PNG"(cid:10) format from: http://arxiv.org/ps/1912.12409v1
1602.08162
2
1602
2016-10-04T00:48:12
Streaming Verification of Graph Properties
[ "cs.DS" ]
Streaming interactive proofs (SIPs) are a framework for outsourced computation. A computationally limited streaming client (the verifier) hands over a large data set to an untrusted server (the prover) in the cloud and the two parties run a protocol to confirm the correctness of result with high probability. SIPs are particularly interesting for problems that are hard to solve (or even approximate) well in a streaming setting. The most notable of these problems is finding maximum matchings, which has received intense interest in recent years but has strong lower bounds even for constant factor approximations. In this paper, we present efficient streaming interactive proofs that can verify maximum matchings exactly. Our results cover all flavors of matchings (bipartite/non-bipartite and weighted). In addition, we also present streaming verifiers for approximate metric TSP. In particular, these are the first efficient results for weighted matchings and for metric TSP in any streaming verification model.
cs.DS
cs
Streaming Verification of Graph Properties∗ Amirali Abdullah† Samira Daruki‡ Chitradeep Dutta Roy§ Suresh Venkatasubramanian¶ Abstract Streaming interactive proofs (SIPs) are a framework for outsourced computation. A com- putationally limited streaming client (the verifier) hands over a large data set to an untrusted server (the prover) in the cloud and the two parties run a protocol to confirm the correctness of result with high probability. SIPs are particularly interesting for problems that are hard to solve (or even approximate) well in a streaming setting. The most notable of these problems is finding maximum matchings, which has received intense interest in recent years but has strong lower bounds even for constant factor approximations. In this paper, we present efficient streaming interactive proofs that can verify maximum matchings exactly. Our results cover all flavors of matchings (bipartite/non-bipartite and weighted). In addition, we also present streaming verifiers for approximate metric TSP. In particular, these are the first efficient results for weighted matchings and for metric TSP in any streaming verification model. 1 Introduction The shift from direct computation to outsourcing in the cloud has led to new ways of thinking about massive scale computation. In the verification setting, computational effort is split between a computationally weak client (the verifier) who owns the data and wants to solve a desired problem, and a more powerful server (the prover) which performs the computations. Here the client has only limited (streaming) access to the data, as well as a bounded ability to talk with the server (measured by the amount of communication), but wishes to verify the correctness of the prover's answers. This model can be viewed as a streaming modification of a classic interactive proof system (a streaming IP, or SIP), and has been the subject of a number of papers [25, 49, 22, 16, 21, 15, 38, 39] that have established sublinear (verifier) space and communication bounds for classic problems in streaming and data analysis. In this paper, we present streaming interactive proofs for graph problems that are traditionally hard for streaming, such as for the maximum matching problem (in bipartite and general graphs, both weighted and unweighted) as well for approximating the traveling salesperson problem. In particular, we present protocols that verify a matching exactly in a graph using polylogarithmic space and polylogarithmic communication apart from the matching itself. In all our results, we consider the input in the dynamic streaming model, where graph edges are presented in arbitrary order in a stream and we allow both deletion and insertion of edges. All our protocols use either ∗This research was supported in part by National Science Foundation under grants IIS-1251049, CNS-1302688 †Department of Mathematics, University of Michigan ‡School of Computing, University of Utah §School of Computing, University of Utah ¶School of Computing, University of Utah 1 INTRODUCTION 2 log n rounds of communication or (if the output size is sufficiently large or we are willing to tolerate superlogarithmic communication) constant rounds of communication. To prove the above results, we also need SIPs for sub-problems like connectivity, minimum spanning tree and triangle counting. While it is possible to derive similar (and in some cases better) results for these subroutines using known techniques [29], we require explicit protocols that return structures that can be used in the computation pipeline for the TSP. Furthermore, our protocols for these problems are much simpler than what can be obtained by techniques in [29], which require some effort to obtain precise bounds on the size and depth of the circuits corresponding to more complicated parallel algorithms. We summarize our results in Table 1. log n rounds γ = O(1) rounds Verifier Space Communication Verifier Space Problem Triangle Counting Matchings (all versions) Connectivity Minimum Spanning Tree Travelling Salesperson log2 n log2 n log2 n log2 n log2 n log2 n (ρ + log n) log n n log n n log2 n/ε n log2 n/ε log n log n log n log n log n Communication (ρ + n1/γ(cid:48) n1/γ log n ) log n (*) n log n n log2 n/ε n log2 n/ε Table 1: Our Results. All bounds expressed in bits, upto constant factors. For the matching results, ρ = min(n, C) where C is the cardinality of the optimal matching (weighted or unweighted). Note that for the MST, the verification is for a (1 + )-approximation. For the TSP, the verification is for a (3/2 + ε)-approximation. (*) γ(cid:48) is a linear function of γ and is strictly more than 1 as long as γ is a sufficiently large constant. Significance of our Results. While the streaming model of computation has been extremely effective for processing numeric and matrix data, its ability to handle large graphs is limited, even in the so-called semi-streaming model where the streaming algorithm is permitted to use space quasilinear in the number of vertices. Recent breakthroughs in graph sketching [43] have led to space-efficient approximations for many problems in the semi-streaming model but canonical graph problems like matchings have been shown to be provably hard. It is known [35] that no better than a 1 − 1/e approximation to the maximum cardinality matching is possible in the streaming model, even with space O(n). It was also known that even allowing limited communication (effectively a single message from the prover) required a space- communication product of Ω(n2) [15, 21]. Our results show that even allowing a few more rounds of communication dramatically improves the space-communication tradeoff for matching, as well as yielding exact verification. We note that streaming algorithms for matching vary greatly in performance and complexity depending in whether the graph is weighted or unweighted, bipartite or nonbipartite. In contrast, our results apply to all forms of matching. Interestingly, the special case of perfect matching, by virtue of being in RNC [37], admits an efficient SIP via results by Goldwasser, Kalai and Rothblum [29] and Cormode, Thaler and Yi [22]. Similarly for triangle counting, the best streaming algorithm [4] yields an additive εn3 error estimate in polylogarithmic space, and again in the annotation model (effectively a single round of communication) the best result yields a space-communication tradeoff of n2 log2 n, which is almost exponentially worse than the bound we obtain. We note that counting triangles is a classic problem in the sublinear algorithms literature, and identifying optimal space and communication bounds for this problem was posed as an open problem by Graham Cormode in the Bertinoro sublinear algorithms workshop [20]. Our bound for verifying a 3/2 +  approximation for the TSP in dynamic graphs is also interesting: a trivial 2 RELATED WORK 3 2-approximation in the semi-streaming model follows via the MST, but it is open to improve this bound (even on a grid) [47]. In general, our results can be viewed as providing further insight into the tradeoff between space and communication in sublinear algorithms. The annotation model of verification provides Ω(n2) lower bounds on the space-communication product for the problems we consider: in that light, the fact that we can obtain polynomially better bounds with only constant number of rounds demonstrates the power of just a few rounds of interaction. We note that as of this paper, virtually all of the canonical hard problems for streaming algorithms (Index [16], Disjointness [8, 9], Boolean Hidden Matching [27, 14, 40]) admit efficient SIPs. A SIP for Index was presented in [16] and we present SIPs for Disjointness and Boolean Hidden Matching here as well. Our model is also different from a standard multi-pass streaming framework, since communi- cation must remain sublinear in the input and in fact in all our protocols the verifier still reads the input exactly once. From a technical perspective, our work continues the sketching paradigm for designing efficient graph algorithms. All our results proceed by building linear sketches of the input graph. The key difference is that our sketches are not approximate but algebraic: based on random evaluation of polynomials over finite fields. Our sketches use higher dimensional linearization ("tensorization") of the input, which might itself be of interest. They also compose: indeed, our solutions are based on building a number of simple primitives that we combine in different ways. Figure 1 illustrates the interconnections between our tools and results. Figure 1: Summary of our results. Subroutines are in ovals and problems are in rectangles. Shaded boxes indicate prior work. An arrow from A to B indicates that B uses A as a subroutine 2 Related Work Outsourced computation. Work on outsourced computation comes in three other flavors in addition to SIPs: firstly, there is work on reducing the verifier and prover complexity without necessarily making the verifier a sublinear algorithm[29, 28, 34], in some cases using cryptographic assumptions to achieve their bounds. Another approach is the idea of rational proofs [7, 18, 31, 30], in which the verifier uses a payment function to give the prover incentive to be honest. Moving to sublinear verifiers, there has been research on designing SIPs where the verifier runs in sublinear time[32, 46]. Streaming Graph Verification. All prior work on streaming graph verification has been in the annotation model, which in practice resembles a 1-round SIP (a single message from prover to Sum checkMSEFinvSubsetVerify MatchingMatchings (all variants)ConnectivityMSTApprox TSPTriangles 3 PRELIMINARIES 4 verifier after the stream has been read). In recent work, Thaler [49] gives protocols for counting triangles, and computing maximum cardinality matching with both n log n space and communica- tion cost. For matching, Chakrabarti et al. [15] show that any annotation protocol with space cost O(n1−δ) requires communication cost Ω(n1+δ) for any δ > 0. They also show that any annotation protocol for graph connectivity with space cost O(n1−δ) requires communication cost Ω(n1+δ) for any δ > 0. It is also proved that every protocol for this problem in the annotation model requires Ω(n2) product of space and communication. This is optimal upto logarithmic factors. Furthermore, they conjecture that achieving smooth tradeoffs between space and communication cost is impossible, i.e. it is not known how to reduce the space usage to o(n log n) without blowing the communication cost up to Ω(n2) or vice versa [15, 49]. Note that in all our protocols, the product of space and communication is O(n poly log n). Streaming Graph Algorithms. In the general dynamic streaming model, poly log 1/ε-pass stream- ing algorithms [1, 2] give (1 + ε)-approximate answers and require O(n) space In one pass. The best results for matching are [19] (a parametrized algorithm for computing a maximal matching of size k using O(nk) space) and [6, 42] which give a streaming algorithm for recovering an n-approximate maximum matching by maintaining a linear sketch of size O(n2−3) bits. In the single-pass insert- only streaming model, Epstein et al. [26] give a constant (4.91) factor approximation for weighted graphs using O(n log n) space. Crouch and Stubbs [23] give a (4 + )-approximation algorithm which is the best known result for weighted matchings in this model. Triangle counting in streams has been studied extensively [10, 12, 13, 33, 44]. For dynamic graphs, the most space-efficient result is the one by [4] that provides the aforementioned additive εn3 bound in polylogarithmic space. The recent breakthrough in sketch-based graph streaming [3] has yielded O(n) semi-streaming algorithms for computing the connectivity, bipartiteness and minimum spanning trees of dynamic graphs. For more details, see [43]. 3 Preliminaries We will work in the streaming interactive proof (SIP) model first proposed by Cormode et al. [22]. In this model, there are two players, the prover P and the verifier V. The input consists of a stream τ of items from a universe U. Let f be a function mapping τ to any finite set S. A k-message SIP for f works as follows: 1. V and P read the input stream and perform some computation on it. 2. V and P then exchange k messages, after which V either outputs a value in S ∪ {⊥}, where ⊥ denotes that V is not convinced that the prover followed the prescribed protocol. V is randomized. There must exist a prover strategy that causes the verifier to output f (τ) with probability 1 − εc for some εc ≤ 1/3. Similarly, for all prover strategies, V must output a value in { f (τ),⊥} with probability 1 − εs for some εs ≤ 1/3. The values εc and εs are respectively referred to as the completeness and soundness errors of the protocol. The protocols we design here will have perfect completeness (εc = 0) 1 We note that the annotated stream model of Chakrabarti et al. [15] essentially corresponds to one-message SIPs.2 1The constant 1/3 appearing in the completeness and soundness requirements is chosen by convention [5]. The constant 1/3 can be replaced with any other constant in (0, 1) without affecting the theory in any way. 2Technically, the annotated data streaming model allows the annotation to be interleaved with the stream updates, while the SIP model does not allow the prover and verifier to communicate until after the stream has passed. However, 4 OVERVIEW OF OUR TECHNIQUES 5 Input Model. We will assume the input is presented as stream updates to a vector. In general, each element of this stream is a tuple (i, δ), where each i lies in a universe U of size u, and δ ∈ {+1,−1}. The data stream implicitly defines a frequency vector a = (a1, . . . , au), where ai is the sum of all δ values associated with i in the stream. The stream update (i, δ) is thus the implicit update a[i] ← a[i] + δ. In this paper, the stream consists of edges drawn from U = [n] × [n] along with weight information as needed. As is standard, we assume that edge weights are drawn from [nc] for some constant c. We allow edges to be inserted and deleted but the final edge multiplicity is 0 or 1, and also mandate that the length of the stream is polynomial in n. Finally, for weighted graphs, we further constrain that the edge weight updates be atomic, i.e., that an edge along with its full weight be inserted or deleted at each step. There are three parameters that control the complexity of our protocols: the vector length u, the length of stream s and the maximum size of a coordinate M = maxiai. In the protocols discussed in this paper M will always be upper bounded by some polynomial in u, i.e. log M = O(log u). All algorithms we present use linear sketches, and so the stream length s only affects verifier running time. In Lemma 6.2 we discuss how to reduce even this dependence, so that verifier update time becomes polylogarithmic on each step. Costs. A SIP has two costs: the verifier space, and the total communication, expressed as the number of bits exchanged between V and P. We will use the notation (A, B) to denote a SIP with verifier space O(A) and total communication O(B). We will also consider the number of rounds of communication between V and P. The basic versions of our protocols will require log n rounds, and we later show how to improve this to a constant number of rounds while maintaining the same space and similar communication cost otherwise. 4 Overview of our Techniques For all the problems that we discuss the input is a data stream of edges of a graph where for an edge e an element in the stream is of the form (i, j, ∆). Now all our protocols proceed as follows. We define a domain U of size u and a frequency vector a ∈ Zu whose entries are indexed by elements of U. A particular protocol might define a number of such vectors, each over a different domain. Each stream element will trigger a set of indices from U at which to update a. For example in case of matching, we derive this constraint universe from the LP certificate, whereas for counting triangles our universe is derived from all O(n3) possible three-tuples of the vertices. The key idea in all our protocols is that since we cannot maintain a explicitly due to limited space, we instead maintain a linear sketch of a that varies depending on the problem being solved. This sketch is computed as follows. We will design a polynomial that acts as a low-degree extension of f over an extension field F and can be written as p(x1, . . . , xd) = ∑u∈U a[u]gu(x1, x2, . . . , xd). The crucial property of this polynomial is that it is linear in the entries of a. This means that polynomial evaluation at any fixed point r = (r1, r2, . . . , rd) is easy in a stream: when we see an update a[u] ← a[u] + ∆, we merely need to add the expression ∆gu(r) to a running tally. Our sketch will always be a polynomial evaluation at a random point r. Once the stream has passed, V and the prover P will engage in a conversation that might involve further sketches as well as further updates to the current sketch. In our descriptions, we will use the imprecise but convenient almost all known annotated data streaming protocols do not utilize the ability to interleave the annotation with the stream, and hence are actually 1-message SIPs, but without any interaction from the verifier to prover side. 5 SOME USEFUL PROTOCOLS 6 shorthand "increment a[u]" to mean "update a linear sketch of some low-degree extension of a function of a". It should be clear in each context what the specific function is. As mentioned earlier, a single stream update of the form (i, j, ∆) might trigger updates in many entries of a, each of which will be indexed by a multidimensional vector. We will use the wild-card symbol '∗' to indicate that all values of that coordinate in the index should be considered. For example, suppose U ⊆ [n] × [n] × [n]. The instruction "update a[(i,∗, j)]" should be read as "update all entries a[t] where t ∈ {(i, s, j) s ∈ [n], (i, s, j) ∈ U}". We show later how to do these updates implicitly, so that verifier time remains suitably bounded. 5 Some Useful Protocols We will make use of two basic tools in our algorithms: Reed-Solomon fingerprints for testing vector equality, and the streaming SumCheck protocol of Cormode et al. [22]. We summarize the main properties of these protocols here: for more details, the reader is referred to the original papers. Multi-Set Equality (MSE). We are given streaming updates to the entries of two vectors a, a(cid:48) ∈ Zu and wish to check a = a(cid:48). Reed-Solomon fingerprinting is a standard technique to solve MSE using only logarithmic space. Theorem 5.1 (MSE, [21]). Suppose we are given stream updates to two vectors a, a(cid:48) ∈ Zu guaranteed to satisfy ai,a(cid:48) i ≤ M at the end of the data stream. Let t = max(M, u). There is a streaming algorithm using O(log t) space, satisfying the following properties: (i) If a = a(cid:48), then the streaming algorithm outputs 1 with probability 1. (ii) If a (cid:54)= a(cid:48), then the streaming algorithm outputs 0 with probability at least 1 − 1/t2. The SumCheck Protocol. We are given streaming updates to a vector a ∈ Zu and a univariate polynomial h : Z → Z. The Sum Check problem (SumCheck) is to verify a claim that ∑i h(ai) = K. Lemma 5.2 (SumCheck, [22]). There is a SIP to verify that ∑i∈[u] h(ai) = K for some claimed K. The total number of rounds is O(log u) and the cost of the protocol is (log(u) logF, deg(h) log(u) logF). Here are the two other protocols that act as building blocks for our graph verification protocols. Inverse Protocol (Finv). Let a ∈ Zu be a (frequency) vector. The inverse frequency function F−1 k (a) = {i ai = k}. Let for a fixed k is the number of elements of a that have frequency k: F−1 hk(i) = 1 for i = k and 0 otherwise. We can then define F−1 k (a) = ∑i hk(ai). Note that the domain of hk is [M] where M = maxi ai. We will refer to the problem of verifying a claimed value of F−1 as Finv. By using Lemma 5.2, there is a simple SIP for Finv. We restate the related results here [22]. Lemma 5.3 (Finv, [22]). Given stream updates to a vector a ∈ Zu such that maxi ai = M and a fixed integer k there is a SIP to verify the claim F−1 k (a) = K with cost (log2 u, M log2 u) in log u rounds. k k Remark 1 Note that the same result holds if instead of verifying an inverse query for a single S = {iai ∈ S}. S with costs frequency k, we wish to verify it for a set of frequencies. Let S ⊂ [M] and let F−1 Then using the same idea as above, there is a SIP for verifying a claimed value of F−1 given by Lemma 5.3. Remark 2 Note that in the protocols presented in this paper later, the input to the Finv is not the graph edges itself, but instead the Finv is applied to the derived stream updates triggered by each input stream elements. As stated before, a single stream update of the form (i, j, ∆) might trigger updates in many entries of vector a, which is defined based on the problem. 6 WARM-UP: COUNTING TRIANGLES 7 Subset Protocol. We now present a new protocol for a variant of the vector equality test described in Theorem 5.1. While this problem has been studied in the annotation model, it requires space- communication product of Ω(u2) communication in that setting. Lemma 5.4 (Subset). Let E ⊂ [u] be a set of elements, and let S ⊂ [u] be another set owned by P. There is a SIP to verify a claim that S ⊂ E with cost (log2 u, (S + log u) log u) in log u rounds. Proof. Consider a vector ¯a with length u, in which the verifier does the following updates: for each element in set E, increment the corresponding value in vector ¯a by +1 and for each element in set S, decrements the corresponding value in vector ¯a by −1. Let the vector a ∈ {0, 1}u be the characteristic vector of E, and let a(cid:48) be the characteristic vector of S. Thus, ¯a = a − a(cid:48). By applying F−1−1 protocol on ¯a, verifier can determine if S ⊂ E or not. Note that in vector ¯a, M = 1. Then the protocol cost follows by Lemma 5.3. 6 Warm-up: Counting Triangles The number of triangles in a graph is the number of induced subgraphs isomorphic to K3. Here we present a protocol to verify the number of triangles in a graph presented as a dynamic stream of edges. We will assume that at the end of the stream no edge has a net frequency greater than 1. 1. V processes the input data stream consisting of tuples (i, j, ∆) representing edges in the graph 3 with respect to a vector a indexed by entries from U = {(i, j, k) i, j, k ∈ [n], i < j < k}. for F−1 For each edge e = (i, j, ∆), i < j in the stream, V increments all entries a[(i,∗, j)], a[(∗, i, j)] and a[(i, j,∗)] by ∆. Note that the input to F−1 3 protocol is in fact these derived incremental updates from the original stream of edges in the input graph and not the tuples (i, j, ∆). 2. P sends the claimed value c∗ as the number of triangles in G. 3. V checks the the correctness of the answer by running the verification protocol for F−1 and checks if F−1 3 = c∗. Lemma 6.1. The above protocol correctly verifies (with a constant probability of error) the number of triangles in a graph with cost (log2 n, log2 n). Proof. Follows from Lemma 5.3 and observation that maximum frequency of any entry in a is 3. Verifier Update Time. Note that while this protocol and the other graph protocols which follows achieves very small space and communication costs, but the update time could be high (polynomial in n) since processing a single stream token may trigger updates in many entries of a. But by using a nice trick found in [16], the verifier time can be reduced to polylog n. Here we state the main results which can be applied to all the protocols in this paper to guarantee polylog n verifier update time. Lemma 6.2. Assume a data stream τ in which each element triggers updates on multiple entries of vector a, and each entry in this vector is indexed by a multidimensional vector with b coordinates and let U ⊆ [nc]b. In all the SIP protocols for graph problems in this paper, the updates in the form of a[(β1, β2,· · · , βq,∗,· · · ,∗)] (which is interpreted as: update all entries β where β ∈ {(β1,· · · , βq, s1,· · · , sb−q)si ∈ [nc], i ∈ [b − q], (β1,· · · , βq, s1,· · · , sb−q) ∈ U}) can be done in polylog n time. 7 SIP FOR MAX-MATCHING IN BIPARTITE GRAPHS 8 Here we present the proof for Lemma 6.2. The main ideas are extracted from [16], in which this trick is used for reducing verifier time in Nearest Neighbor verification problem. For more details, refer to Section 3.2 in [16]. Proof. Suppose the boolean function φ which takes two vectors β and x as inputs, in which β = (β1,· · · , βb) is a vector with b coordinates each βi ∈ [n]c and x = (x1,· · · , xq) is a vector with q < b coordinates each xi ∈ [n]c. Here we assume β is an index in the vector a defined over the input stream and x the update vector defined by the current stream element(i.e. specifies which indices in a must be updated). Define φ(β, x) = 1 ↔ βi = xi, 1 ≤ ∀i ≤ q with O(log n)-bits inputs (since we can assume b as a small constant). Let define the length of the shortest de Morgan formula for function φ as fsize(φ). Obviously, the function φ is essentially the equality check on O(logn)-bits input and we know that the addition and multiplication of s-bits inputs can be computed by Boolean circuits in depth log s, resulting Boolean formula of size poly(s). Thus, fsize(φ) = polylog n. Considering the boolean formula for φ, we associate a polynomial G with each gate G of this formula, with input variables W1,· · · , Wb log n and X1,· · · , Xq log n, as follows: G = βi ⇒ G = Wi G = xi ⇒ G = Xi G = ¬G1 ⇒ G = − G1 G = G1 ∧ G2 ⇒ G = G1 G2 G = G1 ∨ G2 ⇒ G = 1 − (1 − G1(1 − G2)) Let φ(W1,· · · , Wb log n, X1,· · · , Xq log n) to be the polynomial associated with the output gate, which is in fact the standard arithmetization of the formula. We consider φ as a polynomial defined over F[W1,· · · , Wb log n, X1,· · · , Xq log n] for a large enough finite field F. By construction, φ has total degree at most fsize(φ) and agree with φ on every Boolean input. Define the polynomial Ψ(W1,· · · , Wb log n) = Σi=1 φ((W1,· · · , Wb log n), x(i)), in which x(i) is the update vector defined by the element i in the stream. Now we can observe that the vector a defined by the stream updates, can be interpreted as follows: a[β] = Σi=1φ(β, x(i)) = Σi=1 φ(β, x(i)) = Ψ(β) It follows that Ψ is the extension of a to F with degree equal to fsize(φ) and can be defined implicitly by input stream. Also, the verifier can easily evaluate Ψ(r) for some random point r ∈ Fb log n, as similar to polynomial evaluation in SumCheck protocol. Considering that fsize(φ) = polylog n, the complexity result of update time follows. Note that this approach adds an extra space cost fsize(φ) =poly log n for the size of Boolean formula, but in general this does not affect the total space cost of the protocols discussed in this paper. 7 SIP for MAX-MATCHING in Bipartite Graphs We now present a SIP for maximum cardinality matching in bipartite graphs. The prover P needs to generate two certificates: an actual matching, and a proof that this is optimal. By König's theorem [41], a bipartite graph has a maximum matching of size k if and only if it has a minimum vertex cover of size k. Therefore, P's proof consists of two parts: a) Send the claimed optimal matching M ⊂ E of size k b) Send a vertex cover S ⊂ Vof size k. V has three tasks: i) Verify that M is a matching and that M ⊂ E. ii) Verify that S covers all edges in E. iii) Verify that M = S. We 8 SIP FOR MAX-WEIGHT-MATCHING IN BIPARTITE GRAPHS 9 describe protocols for first two tasks and the third task is trivially solvable by counting the length of the streams and can be done in log n space. V will run the three protocols in parallel. Verifying a Matching. Verifying that M ⊂ E can be done by running the Subset protocol from Lemma 5.4 on E and the claimed matching M. A set of edges M is a matching if each vertex has degree at most 1 on the subgraph defined by M. Interpreted another way, let τM be the stream of endpoints of edges in M. Then each item in τM must have frequency 1. This motivates the following protocol, based on Theorem 5.1. V treats τM as a sequence of updates to a frequency vector a ∈ ZV counting the number of occurrences of each vertex. V then asks P to send a stream of all the vertices incident on edges of M as updates to a different frequency vector a(cid:48). V then runs the MSE protocol to verify that these are the same. Verifying that S is a Vertex Cover. The difficulty with verifying a vertex cover is that V no longer has streaming access to E. However, we can once again reformulate the verification in terms of frequency vectors. S is a vertex cover if and only if each edge of E is incident to some vertex in S. Let a, a(cid:48) ∈ Z(n 2) be vectors indexed by U = {(i, j), i, j ∈ V, i < j}. On receiving the input stream edge e = (i, j, ∆), i < j, V increments a[(i, j)] by ∆. For each vertex i ∈ S that P sends, we increment all entries a(cid:48)[(i,∗)] and a(cid:48)[(∗, i)]. Now it is easy to see that S is a vertex cover if and only there are no entries in a − a(cid:48) with value 1 (because these entries correspond to edges that have not been covered by a vertex in S). This yields the following verification protocol. 1. V processes the input edge stream for the F−1 1 protocol, maintaining updates to a vector a. 2. P sends over a claimed vertex cover S of size c∗ one vertex at a time. For each vertex i ∈ S, V decrements all entries a[(i,∗)] and a[(∗, i)]. 3. V runs Finv to verify that F−1 The bounds for this protocol follow from Lemmas 5.3, 5.4 and Theorem 5.1: 1 (a) = 0. Theorem 7.1. Given an input bipartite graph with n vertices, there exists a streaming interactive protocol for verifying the maximum-matching with log n rounds of communication, and cost (log2 n, (c∗ + log n) log n), where c∗ is the size of the optimal matching. 8 SIP for MAX-WEIGHT-MATCHING in Bipartite Graphs Consider now a bipartite graph with edge weights, with the goal being to compute a matching of maximum weight (the weight of the matching being the sum of the weights of its edges). Our verification protocol will introduce another technique we call "flattening" that we will exploit subsequently for matching in general graphs. Recall that we assume a "dynamic update" model for the streaming edges: each edge is presented in the form (e, we, ∆) where ∆ ∈ {+1,−1}. Thus, edges are inserted and deleted in the graph, but their weight is not modified. We will also assume that all weights are bounded by some polynomial nc. As before, one part of the protocol is the presentation of a matching by P: the verification of this matching follows the same procedure as in Section 7 and we will not discuss it further. We now focus on the problem of certifying optimality of this matching. 8 SIP FOR MAX-WEIGHT-MATCHING IN BIPARTITE GRAPHS 10 For this goal, we proceed by the standard LP-duality for bipartite maximum weight matching. Let the graph be G = (V, E) and A is its incidence matrix (a matrix in {0, 1}V×E where aij = 1 iff edge j is incident to vertex i). Let δ(v) denote the edge neighborhood of a vertex v and Pmatch represent the convex combination of all matchings on G, and note that for a bipartite graph: Applying the LP duality theorem to the bipartite max-weight matching problem on G, and letting w be the weight vector on the edges, we see that: (1) x ∈ RE Pmatch = xe ≤ 1 + : ∀v ∈ V, ∑ e∈δ(v)  wTx : x ≥ 0 and ∀v ∈ V, ∑ (cid:111) (cid:110) (cid:110) (cid:111) wTx : x ≥ 0, Ax ≤ 1 (cid:110) 1Ty : ATy ≥ w, y ≥ 0 1Ty : y ≥ 0 and ∀ei,j ∈ E, yi + yj ≥ wi,j xe ≤ 1 e∈δ(v)  (cid:111) max{wTx : x ∈ Pmatch(G)} = max = max = min = min Considering this formulation, a certificate of optimality for a maximum weight matching of cost c∗ is an assignment of weights yi to vertices of V such that ∑ yi = c∗ and for each edge e = (i, j), yi + yj ≥ we. A protocol similar to the unweighted case would proceed as follows: P would send over a stream (i, yi) of vertices, and the verifier would treat these as decrements to a vector over edges. V would then verify that no element of the vector had a value greater than zero. However, by Lemma 5.3, this would incur a communication cost linear in the maximum weight (since that is the maximum value of an element of this vector), which is prohibitively expensive. The key is to observe that the communication cost of the protocol depends linearly on the maximum value of an element of the vector, but only logarithmically on the length of the vector itself. So if we can "flatten" the vector so that it becomes larger, but the maximum value of an element becomes smaller, we might obtain a cheaper protocol. Let a be indexed by elements of U = {((i, j), w, yi, yj) (i, j) ∈ E, w, yi, yj ∈ [nc], i < j, w ≤ yi + yj}. U = O(n3c+2). The protocol proceeds as follows. Intuitively, each entry of a corresponds to a valid dual constraint. When V reads the input stream of edges, it will increment counts for all entries of a that could be part of a valid dual constraint. Correspondingly, when P sends back the actual dual variables, V updates all compatible entries. 1. V processes the input edge stream for F−1 2. Upon seeing (e, we, ∆) in the stream, V accordingly updates all entries a[(e, w,∗,∗)] by ∆. 3. P sends a stream of (i, yi) in increasing order of i. 4. V verifies that all i ∈ [n] appear in the list. For each i, it increments all entries a[((i,∗),∗, yi,∗)] (with respect to a). 3 and a[(∗, i),∗,∗, yi)]. 5. V verifies that F−1 3 (a) = m and accepts. 9 SIP FOR MAXIMUM-WEIGHT-MATCHING IN GENERAL GRAPHS 11 Correctness. Suppose the prover provides a valid dual certificate satisfying the conditions for optimality. Consider any edge e = (i, j), the associated dual variables yi, yj and the entry r = (e, wij, yi, yj). When e is first encountered, V will increment a[r]. When P sends yi, r will satisfy the compatibility condition and a[r] will be incremented. A similar increment will happen for yj. Note that no other stream element will trigger an update of a[r]. Therefore, every satisfied constraint will yield an entry of a with value 3. Conversely, suppose the constraint is not satisfied, i.e yi + yj < wij. There is no corresponding entry of a to be updated in this case. This proves that the number of entries of a with value 3 is exactly the number of edges with satisfied dual constraints. The correctness of the protocol follows. Complexity. The maximum frequency in a is at most 3 and the domain size u = O(n3c+2). Note that this is in contrast with the representation first proposed that would have domain size n2 and maximum frequency O(nc). In effect, we have flattened the representation. Invoking Lemma 5.3, as well as the bound for verifying the matching from Section 7, we obtain the following result. Theorem 8.1. Given a bipartite graph with n vertices and edge weights drawn from [nc] for some constant c, there exists a streaming interactive protocol for verifying the maximum-weight matching with log n rounds of communication, space cost O(log2 n) and communication cost O(n log n). We can make a small improvement to Theorem 8.1. First note that the prover need only send the non-zero yi in ascending order along with label to the verifier, who can implicitly assign yj = 0 to all absent weights. This then reduces the communication to be linear in the cardinality and thereby also the cost of the maximum weight matching. Namely, we now have: Theorem 8.2. Given an input bipartite graph with n vertices and edge weights drawn from [nc] for some constant c, there exists a streaming interactive protocol for verifying the maximum-weight matching with log n rounds of communication, space cost O(log2 n) and communication cost O(c∗ log n), where c∗ is the cardinality of the optimal matching over the input. Note. We assume that V knows the number of edges in the graph. This assumption can be dropped easily by merely summing over all updates ∆. Since we assume that every edge will have a final count of 1 or 0, this will correctly compute the number of edges at the end of the stream. 9 SIP for Maximum-Weight-Matching in General Graphs We now turn to the most general setting: of maximum weight matching in general graphs. This of course subsumes the easier case of maximum cardinality matching in general graphs, and while there is a slightly simpler protocol for that problem based on the Tutte-Berge characterization of maximum cardinality matchings [50, 11], we will not discuss it here. We will use the odd-set based LP-duality characterization of maximum weight matchings due to Cunningham and Marsh. Let O(V) denote the set of all odd-cardinality subsets of V Let yi ∈ [nc] define non-negative integral weight on vertex vi, zU ∈ [nc] define a non-negative integral weight on an odd-cardinality subset U ∈ O(V), wij ∈ [nc] define the weight of an edge e = (i, j) and c∗ ∈ [nc+1] be the weight of a maximum weight matching on G. We define y and z to be dual feasible if yi + yj + ∑U∈O(V) i,j∈U zU ≥ wi,j,∀i, j A collection of sets is said to be laminar, if any two sets in the collection are either disjoint or nested (one is contained in the other). Note that such a family must have size linear in the size of the ground set. Standard LP-duality and the Cunningham-Marsh theorem state that: 9 SIP FOR MAXIMUM-WEIGHT-MATCHING IN GENERAL GRAPHS 12 Theorem 9.1 ([24]). For every integral set of edge weights W, and choices of dual feasible integral vectors y and z, c∗ ≤ ∑v∈V yv + ∑U∈O(V) zU . Furthermore, there exist vectors y and z that are dual feasible such that {U : zU > 0} is laminar and for which the above upper bound achieves equality. (cid:106) 1 2U(cid:107) We design a protocol that will verify that each dual edge constraint is satisfied by the dual variables. The laminar family {U : zU > 0} can be viewed as a collection of nested subsets (each of which we call a claw) that are disjoint from each other. Within each claw, a set U can be described by giving each vertex v in order of increasing level (cid:96)(v): the number of sets v is contained in (see Figure 2). The prover will describe a set U and its associated zU by the tuple (LI, (cid:96), rU, ∂U), Figure 2: A Laminar family where 1 ≤ LI ≤ n is the index of the claw U is contained in, (cid:96) = (cid:96)(U), rU = ∑U(cid:48)⊇U(cid:48) zU(cid:48) and ∂U = U \ ∪U(cid:48)(cid:48)⊂UU(cid:48)(cid:48). For an edge e = (i, j) let re = ∑i,j∈U,U∈O(V) zU represent the weight assigned to an edge by weight vector z on the laminar family. Any edge whose endpoints lie in different claws will have re = 0. For a vertex v, let rv = minv∈U rU. For an edge e = (v, w) whose endpoints lie in the same claw, it is easy to see that re = min(rv, rw), or equivalently that re = rarg min((cid:96)(v),(cid:96)(w)). For such an edge, let (cid:96)e,↓ = min((cid:96)(u), (cid:96)(v)) and (cid:96)e,↑ = max((cid:96)(u), (cid:96)(v)). We will use LI(e) ∈ [n] to denote the index of the claw that the endpoints of e belong to. The Protocol. V prepares to make updates to a vector a with entries indexed by U = U1 ∪ U2. U1 consists of all tuples of the form {(i, j, w, y, y(cid:48), LI, (cid:96), (cid:96)(cid:48), r)} and U2 consists of all tuples of the form {(i, j, w, y, y(cid:48), 0, 0, 0, 0)} where i < j, i, j, LI, (cid:96), (cid:96)(cid:48) ∈ [n], y, y(cid:48), r, w ∈ [nc] and tuples in U1 must satisfy 1) w ≤ y + y(cid:48) + r and 2) it is not simultaneously true that y + y(cid:48) ≥ w and r > 0. Note that a ∈ Zu where u = O(n4c+5) and all weights are bounded by nc. 1. V prepares to process the stream for an F−1 (e, we, ∆), it updates all entries a[(e, we,∗,∗,∗,∗,∗,∗)]. 5 query. When V sees an edge update of form 2. P sends a list of vertices (i, yi) in order of increasing i. For each (i, yi), V increments by 1 the count of all entries a[(i,∗,∗, yi,∗,∗,∗,∗,∗] and a[(∗, i,∗,∗, yi,∗,∗,∗,∗)] with indices drawn from U1. Note that P only sends vertices with nonzero weight, but since they are sent in increasing order, V can infer the missing entries and issue updates to a as above. V also maintains the sum of all yi. 3. P sends the description of the laminar family in the form of tuples (LI, (cid:96), rU, ∂U), sorted in lexicographic order by LI and then by (cid:96). V performs the following operations. (a) V increments all entries of the form (i,∗,∗, yi,∗, 0, 0, 0, 0) or (∗, i,∗,∗, yi, 0, 0, 0, 0) by 2 to account for edges which are satisfied by only vector y. (b) V maintains the sum ΣR of all rU seen thus far. If the tuple is deepest level for a given claw (easily verified by retaining a one-tuple lookahead) then V adds rU to another running sum Σmax. LI=1LI=2`=1`=2`=3`=2`=1 9 SIP FOR MAXIMUM-WEIGHT-MATCHING IN GENERAL GRAPHS 13 (c) V verifies that the entries appear in sorted order and that rU is monotone increasing. (d) V updates the fingerprint structure from Theorem 5.1 with each vertex in ∂U. (e) For each v ∈ ∂U, V increments (subject to our two constraints on the universe) all entries of a indexed by tuples of the form (e, we,∗,∗, LI,∗, (cid:96),∗) and all entries indexed by tuples of the form (e, we,∗,∗, LI, (cid:96),∗, rU), where e is any edge containing v as an endpoint. (f) V ensures all sets presented are odd by verifying that for each LI, all ∂U except the last one are even. 4. P sends V all vertices participating in the laminar family in ascending order of vertex label. V verifies that the fingerprint constructed from this stream matches the fingerprint constructed earlier, and hence that all the claws are disjoint. 5. V runs a verification protocol for F−1 Define cs as the certificate size, which is upper bounded by the matching cardinality. Then: 5 (a) = m, returning Σr and Σmax. 5 (a) and accepts if F−1 Theorem 9.2. Given dynamic updates to a weighted graph on n vertices with all weights bounded poly- nomially in n, there is a SIP with cost (log2 n, (cs + log n) log n), where cs is the cardinality of maximum matching, that runs in log n rounds and verifies the size of a maximum weight matching. Proof. In parallel, V and P run protocols to verify a claimed matching as well as its optimality. The correctness and resource bounds for verifying the matching follow from Section 7. We now turn to verifying the optimality of this matching. The verifier must establish the following facts: (i) P provides a valid laminar family of odd sets. (ii) The lower and upper bounds are equal. (iii) All dual constraints are satisfied. Since the verifier fingerprints the vertices in each claw and then asks P to replay all vertices that participate in the laminar structure, it can verify that no vertex is repeated and therefore that the family is indeed laminar. Each ∂U in a claw can be written as the difference of two odd sets, except the deepest one (for which ∂U = U). Therefore, the cardinality of each ∂U must be even, except for the deepest one. V verifies this claim, establishing that the laminar family comprises of odd sets. Consider the term ∑U zU(cid:98)U/2(cid:99) in the dual cost. Since each U is odd, this can be rewritten as (1/2)(∑u zuU − ∑U zU). Consider the odd sets U0 ⊃ U1 ⊃ . . . ⊃ Ul in a single claw. We have rUj = ∑i≤j zUi, and therefore ∑j rUj = ∑j ∑i≤j zUi. Reordering, this is equal to ∑i≤j ∑j zUi = ∑i zUiUi. Also, rUl = ∑i zUi. Summing over all claws, Σr = ∑U zUU and Σmax = ∑U zU. Therefore, ∑i yi + Σr − Σmax equals the cost of the dual solution provided by P. Finally we turn to validating the dual constraints. Consider an edge e = (i, j) whose dual constraints are satisfied: i.e. P provides yi, yj and zU such that yi + yj + rij ≥ we. Firstly, consider the case when rij > 0. In this case, the edge belongs to some claw LI. Let its lower and upper endpoints vertex levels be s, t, corresponding to odd sets US, Ut. Consider now the entry of a indexed by (e, yi, yj, LI, s, t, rij). This entry is updated when e is initially encountered and ends up with a net count of 1 at the end of input processing. It is incremented twice when P sends the (i, yi) and (j, yj). When P sends Us this entry is incremented because rij = rUs = min(rUS, rUt ) and when P sends Ut this entry is incremented because Ut has level t, returning a final count of 5. If rij = 0 (for example when the edge crosses a claw), then the entry indexed by (e, we, yi, yj, 0, 0, 0, 0) is incremented when e is read. It is not updated when P sends (i, yi) or (j, yj). When P sends the laminar family, V increments this entry by 2 twice (one for each of i and j) because we know that yi + yj ≥ we. In this case, the entry indexed by (i, j, we, yi, yj, 0, 0, 0, 0) will be exactly 5. Thus, for each satisfied edge there is exactly one entry of a that has a count of 5. 10 STREAMING INTERACTIVE PROOFS FOR APPROXIMATE MST 14 Conversely, suppose e is not satisfied by the dual constraints, for which a necessary condition is that yi + yj < we. Firstly, note that any entry indexed by (i, j, we,∗,∗, 0, 0, 0, 0) will receive only two increments: one from reading the edge, and another from one of yi and yj, but not both. Secondly, consider any entry with an index of the form (i, j, we,∗,∗, LI,∗,∗,∗) for LI > 0. Each such entry gets a single increment from reading e and two increments when P sends (i, yi) and (j, yj). However, it will not receive an increment from the second of the two updates in Step 3(e), because yi + yj + rij < we and so its final count will be at most 4. The complexity of the protocol follows from the complexity for Finv, Subset and the matching verification described in Section 7. 10 Streaming Interactive Proofs for Approximate MST For verifying the approximate weight of MST, we follow the reduction to the problem of counting the number of connected components in graphs, which was initially introduced in [17] and later was generalized to streaming setting [3]. Here is the main results which we use here: Lemma 10.1 ([3]). Let T be a minimum spanning tree on graph G with edge weights bounded by W =poly(n) and Gi be the subgraph of G consisting of all edges whose weights is at most wi = (1 + )i and let cc(H) denote the number of connected components of graph H. Set r = (cid:98)log1+ W(cid:99). Then, w(T) ≤ n − (1 + )r + λicc(Gi) ≤ (1 + )w(T) r∑ i=0 where λi = (1 + )i+1 − (1 + )i. Based on this result, we can design a SIP for verifying the approximate weight of minimum spanning tree using a verification protocol 10.2 for number of connected components in a graph. Theorem 10.2. Given a weighted graph with n vertices, there exists a SIP protocol for verifying the number of connected components Gi with (log n) rounds of communication, and (log2 n, n log n) cost. Corollary 10.2.1. Given a weighted graph with n vertices, there exists a SIP protocol for verifying MST within (1 + )-approximation with (log n) rounds of communication, and (log2 n, n log2 n/) cost. Proof. As the verifier processes the stream, each edge weight is snapped to the closest power of (1 + ). Note that given an a priori bound nc on edge weights, G can be partitioned into at most log n ε graphs Gi. We run this many copies of the connected components protocol in parallel to verify the values of cc(Gi),∀i. We now present the proof of theorem 10.2. For simplicity, consider V = (V1 ∪ · · · ∪ Vr) as the r connected components and T = (Ti ∪ · · · ∪ Tr) as r spanning trees on r corresponding connected components, provided by prover as the certificate. Now verifier needs to check if the certificate T is valid by considering the following conditions: 1. Disjointness: All the spanning trees are disjoint, i.e. Ti ∩ Tj = ∅ for all the pairs of trees in T. 2. Subset: Each spanning tree in T = (T1 ∪ · · · ∪ Tr) is a subgraph of the input graph G. This may be handled by Subset protocol described before in Lemma 5.4. 3. r-SpanningTree: Each component in T = (T1 ∪ · · · ∪ Tr) is in fact a spanning tree. 10 STREAMING INTERACTIVE PROOFS FOR APPROXIMATE MST 15 4. Maximality: Each component in T = (T1 ∪ · · · ∪ Tr) is in fact maximal, i.e. there is no edge between the components in original graph G. We assume that the certificate T is sent by the prover in streaming manner in the following format and both players agree on this at the start of the protocol: T : {T, r, (T1,· · · , Tr)} For the representation of spanning trees, we consider a topological ordering on each tree Ti, starting from root node rooti, and each directed edge (vout, vin) connects the parent node vout to the child node vin: Ti : {rooti,∪e(vout, vin)} Here we present the protocols for checking each of these conditions. The following Disjointness protocol will be called as a subroutine in our r-SpanningTree main protocol. Protocol: Disjointness 1. P sends over r components of Ti in T in streaming manner . 2. P "replays" all the edges T(cid:48) in the tuple form (ei,j, (cid:96)) for i, j ∈ [n] and (cid:96) ∈ [r] denotes the component ei,j is assigned to. The edges in T(cid:48) are presented according to a canonical total ordering on the edge set, and hence V can easily check that T(cid:48) has no repeated edge; i.e. the same edge presented in two distinct components. 3. Fingerprinting can then be used to confirm that T(cid:48) = ∪iTi with high probability, and hence that each edge occurs in at most one tree. 4. A similar procedure is run to ensure that no vertex is repeated in more than one Ti and that every vertex is seen at least once. To check if each component in the claimed certificate T sent by the prover is in fact spanning tree, the verifier needs to check that each Ti is cycle-free and also connected. For this goal we present the following protocol: Protocol: r-SpanningTree 1. P sends over the certificate T : {T, r, (T1,· · · , Tr)} in which each Ti is of the form {i,∪e(vout, vin)} and the root ui of Ti is presented first. 2. V runs the Disjointness protocol to ensure that in the certificate T : {T, r, (T1,· · · , Tr)} all Ti and Tj are edge and vertex disjoint for all i (cid:54)= j. 3. V has the prover again similarly replay ∪iTi ordered by the label of the in-vertex of each edge to ensure that each vertex except the root ui has exactly one incoming edge; i.e. that all Ti are cycle free and connected. We now need to check that there is no edge between sets Vi and Vj for i (cid:54)= j: 10 STREAMING INTERACTIVE PROOFS FOR APPROXIMATE MST 16 Protocol: Maximality 1. We define an extended universe U now of size n3, with elements (ei,j, k) where k ∈ [n] represents the label of the component. 2. V initiates the F−1−1 protocol on the input stream. Upon seeing any edge ei,j, V increments by 1 all tuples containing ei,j. 3. P sends the label of each vertex (vi, j) where j ∈ [n] represents the label of the component in the certificate. (Note that the verifier can ensure this input is consistent with the T = ∪iTi sent earlier by simply fingerprinting as described before). 4. V considers each vertex vi ∈ Vj as a decrement update by 2 on all n possible tuples compatible with vi and component label j. This step can be assumed as continuing the process for F−1−1 mentioned in the first step. 5. F−1−1 corresponds to exactly the set of edges observed in stream and crossing between two Vi and Vj for i (cid:54)= j. To see this, we enumerate the cases explicitly: (a) {−3,−4} are the possible values for an edge (ea,b, i) with both endpoints contained in a single Vi corresponding to whether ea,b was originally in the stream or not. (The edge is decremented twice by 2 in the derived stream.) (b) {−1,−2} are the possible values for any edge (ea,b, i) and (ea,b, j) with one endpoint in a Vi and the other in Vj for i (cid:54)= j, corresponding to whether ea,b was originally in the stream or not. (ea,b is decremented exactly once by 2 in each of the two copies corresponding to i and j respectively.) 6. V runs F−1 with P and accepts that there are no edges between the Vi if and only if F−1−1 = 0. Complexity Analysis of the Protocol We know the cost of F−1−1 protocol is (log2 n, log2 n) for frequency ranges bounded by a constant, whereas the costs of the remaining fingerprinting steps and sending the certificate are at most (log n, n log n). Hence the cost of our protocol is dominated by (log2 n, n log n) in the worst case. The verifier update cost on each step is bounded as O(n2). Testing Bipartiteness As a corollary of Theorem 10.2 it is also possible to test whether a graph is bipartite. This follows by applying the connectivity verification protocol described before on the both input graph G and the bipartite double cover of G, say G(cid:48). The bipartite double cover of a graph is formed by making two copies u1, u2 of every node u of G and adding edges {u1, v2} and {u2, v1} for every edge {u, v} of G. It can be easily shown that G is bipartite if and only if the number of connected components in the double cover G(cid:48) is exactly twice the number of connected components in G. Corollary 10.2.2. Given an input graph G with n vertices, there exists a SIP protocol for testing bipartiteness on G with (log n) rounds of communication, and (log2 n, n log n) cost. Remark We note here that while we could have used known parallel algorithms for connectivity and MST combined with the protocol of Goldwasser et al [29] and the technique of Cormode, Thaler and Yi [22] to obtain similar results, we need an explicit and simpler protocol with an output that we can fit into the overall TSP protocol described later in next section. 11 STREAMING INTERACTIVE PROOFS FOR APPROXIMATE METRIC TSP 17 11 Streaming Interactive Proofs for Approximate Metric TSP We can apply our protocols to another interesting graph streaming problem: that of computing an approximation to the min cost travelling salesman tour. The input here is a weighted complete graph of distances. 2 2 We briefly recall the Christofides heuristic: compute a MST T on the graph and add to T all edges of a min-weight perfect matching on the odd-degree vertices of T. The classical Christofides result shows that the sum of the costs of this MST and induced min-weight matching is a 3/2 approximation to the TSP cost. In the SIP setting, we have protocols for both of these problems. The difficulty however is in the dependency: the matching is built on the odd-degree vertices of the MST, and this would seem to require the verifier to maintain much more states as in the streaming setting. We show that this is not the case, and in fact we can obtain an efficient SIP for verifying a (3/2 + )-approximation to the TSP. Assume T is a (1 + ε) approximate MST provided by the prover in the verification protocol and let T∗ be the optimum MST on G. Also, let A be the optimum solution to TSP. Since graph G is connected, we have w(A) ≥ w(T∗) and because (1 + ) · w(T∗) ≥ w(T), thus (1 + ) · w(A) ≥ w(T). Further, let M be the min-cost-matching over the odd degree set O. By a simple reasoning, we can show that w(M) ≤ w(A) and from the triangle inequality it follows that the algorithm can verify the TSP cost within ( 3 , thus w(M) + w(T) ≤ (1 + ) · w(A) + w(A) 2 + )-approximation. We use first the protocol for verifying approximate MST described in Section10. What remains is how we verify a min-cost perfect matching on the odd-degree nodes of the spanning tree. We employ the procedure described in Section 9 for maximum weight matching along with a standard equivalence to min-cost perfect matching. In addition to validating all the LP constraints, we also have to make sure that they pertain solely to vertices in ODD. We do this as above by using the fingerprint for ODD to ensure that we only count satisfied constraints on edges in ODD. Here we describe the protocol for verifying approximate metric TSP in full details, which results in Theorem 11.1: 11.1 The TSP Verification Protocol. 1. P presents a spanning tree which is claimed to be MST and can be verified within (1 + )- approximation by V (as described in Section 10). V maintains a fingerprint on the vertices by using the MSE algorithm and updating the frequency of each vertex seen as an endpoint of an edge in the tree. This results in a fingerprint where each vertex has multiplicity equal to its degree in the MST. 2. P then lists all vertices of the spanning tree in lexicographic order annotated with their degree. V verifies that this fingerprint matches the one constructed in the previous step and builds a new fingerprint for the set ODD of all odd-degree vertices (disregarding their degree). 3. P presents a claimed min-weight perfect matching on the vertex set ODD 4. V verifies that this list of edges is indeed a matching using the protocol from Section 7. In addition, it verifies that the vertices touched by these edges comprise ODD by using MSE to validate the fingerprint from the previous step. 5. To verify the lower bound on min-weight perfect matching, we first reduce to max-weight matching. Let W = nc be the a priori upper bound on the weight of each edge. Replace 12 BOOLEAN HIDDEN HYPERMATCHING AND DISJOINTNESS 18 all weights w by W + 1 − w. Clearly now on a complete graph the max-weight matching corresponds to the min-weight perfect matching. 6. First, V needs to ensure that the entire certificate C is contained inside the ODD set. Recall that V has maintained a fingerprint of ODD, so we may use a variant of MSE. P replays C, along with any vertices which are in ODD but not in C and V checks the fingerprints match. 7. Then, V needs to check that all the constraints for the problem is satisfied by the certificate. This step is identical to what we described before for Maximum-Weight-Matching 9(counting the "good" tuples), but here the satisfied constraints must be counted only on ODD set. 8. For this goal, we amend the protocol of Section 9 so that P streams the subset V − ODD to the verifier and then V can simply decrement the frequency of all the tuples defined on V − ODD by 1. Now all tuples corresponding to edges not containing both endpoints in ODD may achieve frequency at most 4 and hence will not be counted by the F−1 5 query. 9. Again, the accuracy of the claimed V − ODD can be checked by using MSE. Let D be the claimed V − ODD. P streams D to V, who checks by MSE that the fingerprint of D ∪ ODD matches that of the entire vertex set. (Note that fingerprints are linear, so the fingerprint of D ∪ ODD is just the fingerprint of D plus the fingerprint of ODD.) 10. Now, V accepts the max-weight matching certificate if and only if the number of "good" tuples (which determines the count of satisfied edge constraints) is ( ) (i.e. the number of edges in complete graph induced by the ODD set). As discussed earlier, these correspond to the value of F−1 in our extended universe. ODD 2 5 Finally, the approximate TSP cost is the sum of the min-weight perfect matching on ODD and the MST cost on the graph. Theorem 11.1. Given a weighted complete graph with n vertices, in which the edge weights satisfy the triangle inequality, there exists a streaming interactive protocol for verifying optimal TSP cost within 2 + )-approximation with (log n) rounds of communication, and (log2 n, n log2 n/ε) cost. ( 3 12 Boolean Hidden Hypermatching and Disjointness Boolean Hidden Matching (BHHt n) is a two-party one-way communication problem in which Alice's input is a boolean vector x ∈ {0, 1}n where n = kt for some integer k and Bob's input is a (perfect) hypermatching M on the set of coordinates [n], where each edge Mr contains t vertices represented by indices as {Mr,1, ..., Mr,t}, and a boolean vector w of length n ((cid:76) 1≤i≤t xM1,i,· · · ,(cid:76) t . We identify the matching M with its edge incidence matrix. Let Mx denote the length n t boolean vector YES case: The vector w satisfies Mx(cid:76) w = 0 n t ,i ). It is promised in advance that there are only two separate cases: NO case: The vector w satisfies Mx(cid:76) w = 1 n 1≤i≤t xM n t . t . The goal for Bob is to differentiate these two cases. The following lower bound result for BHHt n is obtained in [51]: Lemma 12.1. ([51]) Any randomized one-way communication protocol for solving BHHt some integer k, with error probability at most 1 t ) communication. 4 requires Ω(n1− 1 n when n = kt for 13 REVISIT THE SUM-CHECK PROTOCOL WITH CONSTANT ROUNDS 19 Lemma 12.2. Consider the streaming version of BHHt n problem, in which the binary vector x comes in streaming, followed by edges in M along with the boolean vector w for weights. There exists a streaming interactive protocol with communication and space cost O(t · log n(log log n)) for BHHt Proof. Considering the promise that we have in YES and NO case of BHHt n communication problem, it is enough to query the weights of vertices on only one of the hyperedges on the matching and compare it to the corresponding weight in vector w. This way the BHHt n problem can be reduced to t instances of INDEX problem. Assume the vector x as the input stream and take one of the followed hyperedges, say Mr = {Mr,1, ..., Mr,t}, as the t query index. In this scenario the verifier (cid:76) wr = 1. According to [16], the verification (communication (cid:76) just need to apply the verification protocol INDEX in t locations {Mr,1, ..., Mr,t} on x and check if and space) cost for INDEX problem is O(log n(log log n)) and this results in O(t · log n(log log n)) cost for BHHt n. (cid:76) wr = 0 or(cid:76) n problem. 1≤i≤t xMr,i 1≤i≤t xMr,i We now show a similar result for Disjointness(DISJn). DISJn is a two-party one-way communi- cation problem in which Alice and Bob each have a boolean vector x and y ∈ {0, 1}n respectively, and they wish to determine if there is some index i such that ai = bi = 1. Razoborov [45] shows an Ω(n) lower bound on the communication complexity of this problem for one-way protocols. We show now however that DISJn is easy in the SIP model. Lemma 12.3. Consider the streaming version of DISJn problem, in which the binary vector x comes in streaming, followed by binary vector y. There exists a streaming interactive protocol with communication and space cost O(log2 n) for DISJn. Proof. The verifier maintains a universe U corresponding to [n]. When the verifier sees the ith bit of x, it increments the frequency of universe element i by xi. Now when the verifier streams yi, the verifier again increments the frequency of element i by yi. Clearly, x and y correspond to disjoint sets if and only if F−1 2 = 0. We can then simply run the Finv protocol, and the bound follows by Lemma 5.3 Lemma 12.2 and 12.3 shows that while BHHt n and DISJn are lower bound barriers to computa- tions in the streaming model, however they are easily tractable in the streaming verification setting. This gives a first suggestion that for problems such as MAX-CUT and MAX-MATCHING where most of the known lower bounds go through BHHt n or DISJn, streaming verification protocols may prove more effective, and was the initial motivation for our study. 13 Revisit the sum-check protocol with constant rounds As mentioned before, we have a (log u)-rounds (log u)-cost verification protocol for any frequency- based functions by applying the sum-check as the core of the protocol. In this section, we study on the possibility of reducing the round-complexity of these protocols to constant-rounds. For this goal, we revisit the sum-check protocol described in [22] and briefly explain the details of the protocol and the complexity analysis. The sum-check which we present here is for verifying F1(a) = ∑i∈[u] fa(i) = ∑ x1,··· ,xd∈[(cid:96)]d fa(x1, x2,· · · , xd), in which u = [(cid:96)]d. We can simply extend this protocol to any frequency-based function defined as F(a) = ∑i∈[u] h(ai) = ∑i∈[u] h ◦ f (i). We briefly describe the construction of this extension polynomial. Start from fa and rearrange the frequency vector a into a d-dimensional array in which u = (cid:96)d for a choosen parameter (cid:96). This 13 REVISIT THE SUM-CHECK PROTOCOL WITH CONSTANT ROUNDS 20 way we can write i ∈ [u] as a vector ((i)(cid:96) field size F > u and define the low-degree extension (LDE) of a as fa(x) = ∑ χv(x) = ∏d This indicator function can be defined by Lagrange basis polynomial as follows: d) ∈ [(cid:96)]d. Now we pick a large prime number for v∈[(cid:96)]d avχv(x), in which j=1 χvj (xj) and χk(xj) has this property that it is equal to 1 if xj = k and 0 otherwise. 1, ..., (i)(cid:96) (xj − 0)...(xj − (k − 1))(xj − (k + 1))...(xj − ((cid:96) − 1)) (k − 0)...(k − (k − 1))(k − (k + 1))...(k − ((cid:96) − 1)) (2) Observe that for any fixed value r ∈ [F]d, fa(r) is a linear function of a and can be evaluated by a streaming verifier as the updates arrive. This is the key to the implementation of the sum-check protocol. At the start of protocol, before observing the stream, V picks a random point, presented as r = (r1,· · · , rd) ∈ [F]d in the corresponding field. Then computes fa(r) incrementally as reads the stream updates on a. After observing the stream, the verification protocol proceeds in d rounds as follows: In the first round, P sends a polynomial g1(x1), claimed as : g1(X1) = ∑ x2,··· ,xd∈[(cid:96)]d−1 fa(X1, x2,· · · , xd) Note that in this stage, if polynomial g1 is the same as what is claimed here by P, then F1(a) = ∑x1∈[(cid:96)] g1(x1). claiming that: Followng this process, in round j > 1, V sends rj−1 to P. Then P sends a polynomial gj(xj), gj(Xj) = ∑ xj+1,··· ,xd∈[(cid:96)]d−j fa(r1,· · · , rj−1, Xj, xj+1,· · · , xd) In each round, V does consistency checks by comparing the two most recent polynomials as follows: gj−1(rj−1) = ∑ xj∈[(cid:96)] gj(xj) Finally, in the last round, P sends gd which is claimed to be: gd(Xd) = fa(r1,· · · , rd−1, Xd) Now, V can check if gd(rd) = fa(r). If this test (along with all the previous checks) passes, then V accepts and convinced that F1(a) = ∑x1∈[(cid:96)] g1(x1). Complexity Analysis. The protocol consists of d rounds, and in each of them a polynomial gj is sent by P, which can be communicated using O((cid:96)) words. This results in a total communication cost of O(d(cid:96)). V needs to maintain r, fa(r) which each requires (d + 1) words of space, as well as computing and maintaining the values for a constant number of polynomials in each round of sum-check. As described before, this is required for comparing the two most recent polynomials by checking gj−1(rj−1) = ∑ xj∈[(cid:96)] gj(xj) 13 REVISIT THE SUM-CHECK PROTOCOL WITH CONSTANT ROUNDS 21 Each of the gj communicated in round j is a univariate polynomial with degree ((cid:96) − 1) and can be described in ((cid:96) − 1) words. Let's represent each polynomial gj as follows: gj(xj) = ∑ i∈[(cid:96)−1] cijxi j In each round j the verifier requires to do the consistency checks over the recent polynomials as follows: gj(rj) = ∑ xj∈[(cid:96)] ∑ i∈[(cid:96)−1] cijxi j By reversing the ordering over the sum operation, we can rewrite this check as: gj−1(rj−1) = ∑ i∈[(cid:96)−1] ∑ xj∈[(cid:96)] cijxi j = ∑ i∈[(cid:96)−1] cij ∑ xj∈[(cid:96)] xi j Let yi = ∑xj∈[(cid:96)] xi j. Then, this will be equivalent to: gj−1(rj−1) = ∑ i∈[(cid:96)−1] cijyi Both sides in this test can be computed and maintained in O(1) words space as V reads the polynomials gj presented by P in streaming manner. Thus, the total space required by V is O(d) words. By selecting (cid:96) as a constant (say 2), we obtain both space and communication cost O(log u) words for sum-check protocol which runs in log u rounds and the probablity of error is (cid:96)dF. Now to obtain constant-rounds protocol, we can set (cid:96) = O(u 1 γ ) for some integer constant γ > 1, and considering u = [(cid:96)]d, we get d = γ = O(1) (note that d controls the the number of rounds), 1 result in a protocol with constant rounds and total communication O(u γ ) words, while maintaining the low space cost γ = O(1) words for V. The failure probability goes to O( u γF ), which by choosing F larger than ub it can be made less than 1 ub for any constant b without changing the asymptotic bounds. 1 Constant round for frequency-based functions Here for verifying any statistic F(a) = ∑i∈[u] h(ai) = ∑i∈[u] h ◦ f (i) on frequency vector a, we use the similiar ideas to basic sum-check protocol which we described for verifying F1, but the polynomials communicated by prover will be based on functions h ◦ fa: 1(X1), claimed as: h ◦ fa(X1, x2,· · · , xd) In the first round, P sends a polynomial g(cid:48) ∑ g(cid:48) 1(X1) = x2,··· ,xd∈[(cid:96)]d−1 If polynomial g(cid:48) In each round j > 1, V sends rj−1 to P. Then P sends a polynomial g(cid:48) 1 is the same as what is claimed here by P, then F(a) = ∑x1∈[(cid:96)] g(cid:48) 1(x1). j(Xj), claimed as: g(cid:48) j(Xj) = ∑ xj+1,··· ,xd∈[(cid:96)]d−j h ◦ fa(r1,· · · , rj−1, Xj, xj+1,· · · , xd) 13 REVISIT THE SUM-CHECK PROTOCOL WITH CONSTANT ROUNDS 22 Again, consistency checks in each round is done by V by comparing the two most recent polynomials: g(cid:48) j−1(rj−1) = ∑ xj∈[(cid:96)] g(cid:48) j(xj) And finally the verification process will be completed in the last round by sending polynomial g(cid:48) d(Xd) by P, claimed as: d(Xd) = h ◦ fa(r1,· · · , rd−1, Xd) g(cid:48) followed by checking if g(cid:48) d(rd) = h ◦ fa(r) by V. Complexity Analysis. Protocol consists of d rounds, and in each of them a polynomial g(cid:48) j with degree O(deg(h) · (cid:96)) is sent by P, which can be communicated using O(deg(h) · (cid:96)) words. This results in a total communication cost of O(deg(h) · d(cid:96)). V needs to maintain r, h ◦ fa(r) (each requires O(d) words space) as well as computing and maintaining the value for a constant number of polynomials in streaming manner in each round of protocol (requires O(1) words of space), which results in a total space of O(d) words of space. By selecting (cid:96) as a constant (say 2), then we obtain communication cost O(deg(h) · log u) and space cost O(log u) words for sum-check protocol which runs in log u rounds and the probability of error is deg(h)·(cid:96)d Note that the number of variables in input function to sum-check protocol determines the number of rounds and for any frequency-based function defined as F(a) = ∑i∈[u] h(ai) = ∑i∈[u] h ◦ f (i), in which h is a univariate function, the number of variables will not change and will be the same as fa. This implies that by applying the same trick as described above for reducing the number 1 of variables in fa (by setting (cid:96) = O(u γ ) for some integer constant γ > 1 and d = γ = O(1)), we can obtain a constant-round protocol for verifying any statistics F(a) defined by the frequency vector on the input stream, with space cost γ = O(1) words and communication cost O(deg(h) · u 1 γ ) words, while keeping the probability of error as low as O( deg(h) ) for some integer b > 1 (by choosing F > ub). Lemma 13.1 ([22]). There is a SIP to verify that ∑i∈[u] h(ai) = K for some claimed K, with constant-round (γ), space cost γ · log n = O(log n) bits and communication cost O(deg(h) · u γ · log n) bits, while keeping the probability of error as low as O( deg(h) F ub . 1 Corollary 13.1.1 ([22]). Let h be a univariate polynomial defined on the frequency vector a of a graph G under our model. There is a SIP for the function F(τ) = ∑i∈[u] h(ai). The total number of rounds is constant γ and the cost of the protocol is ) for some integer b > 1 (by choosing F > ub). (cid:16) γ log n, u 1 γ log n (cid:17) ub . Remark Note that in all the (log n)-rounds verification protocols which we presented before the space cost is log2 n bits and with changing the protocol to constant γ-rounds, we improve the space to O(log n) bits. On the other hand, in most of these protocols the communication cost is dominated by the size of certificate, which is generally bounded by O(n log n). Thus, while using constant- round sum-check as the core of verification protocols will increase the related communication cost 1 by a n γ factor, but that will not change the total communication cost of SIPs for matching and TSP, in which the communication cost is dominated by the certificate size. REFERENCES 23 14 Discussion and Future Directions Our matching protocol requires the prover to send back an actual matching and a certificate for it. Suppose we merely wanted to verify a claimed cost for the matching. Is there a way to verify this with less communication? Another interesting question is to consider designing SIPs for graph problems which are known to be NP-hard. For example, is there any efficient SIP for verifying Max Cut in streaming graphs? (motivated by the fact that in standard streaming setting, even approximating maxcut is known to be hard and space lower bounds exist [36]). In our SIPs for matching, we assume that the edge weight updates are atomic. Can we relax this constraint? Justin Thaler [48] observed that by using techniques from [21], we can design a SIP with log2 n space cost and O(W(log W + log n) log n) bits of communication, in which W is the upper bound on the edge weights (i.e. wij ≤ W). Both protocols will result in similar costs for any instance where the edge weights are at most O(n), with having the advantage of handling incrementally-specified edge weights in the second approach. However, in the general case where wij ∈ [nc], our solution still has lower communication cost (worst case n log n). References [1] Ahn, K. J., and Guha, S. Access to data and number of iterations: Dual primal algorithms for maximum matching under resource constraints. arXiv preprint arXiv:1307.4359 (2013). [2] Ahn, K. J., and Guha, S. Linear programming in the semi-streaming model with application to the maximum matching problem. Information and Computation 222 (2013), 59–79. [3] Ahn, K. J., Guha, S., and McGregor, A. Analyzing graph structure via linear measurements. In SODA (2012), SIAM, pp. 459–467. [4] Ahn, K. J., Guha, S., and McGregor, A. Graph sketches: sparsification, spanners, and subgraphs. In Proceedings of the 31st symposium on Principles of Database Systems (2012), ACM, pp. 5–14. [5] Arora, S., and Barak, B. Computational Complexity: A Modern Approach. Cambridge University Press, 2009. [6] Assadi, S., Khanna, S., Li, Y., and Yaroslavtsev, G. Tight bounds for linear sketches of approxi- mate matchings. arXiv preprint arXiv:1505.01467 (2015). [7] Azar, P. D., and Micali, S. Rational proofs. In STOC (2012), ACM, pp. 1017–1028. [8] Bahmani, B., Kumar, R., and Vassilvitskii, S. Densest subgraph in streaming and mapreduce. Proceedings of the VLDB Endowment 5, 5 (2012), 454–465. [9] Bar-Yossef, Z. The complexity of massive data set computations. PhD thesis, University of California at Berkeley, 2002. [10] Bar-Yossef, Z., Kumar, R., and Sivakumar, D. Reductions in streaming algorithms, with an application to counting triangles in graphs. In SODA (2002), Society for Industrial and Applied Mathematics, pp. 623–632. [11] Berge, C. Sur le couplage maximum d'un graphe. Comptes rendus hebdomadaires des séances de l'Académie des sciences 247 (1958), 258–259. REFERENCES 24 [12] Braverman, V., Ostrovsky, R., and Vilenchik, D. How hard is counting triangles in the streaming model? In Automata, Languages, and Programming. Springer, 2013, pp. 244–254. [13] Buriol, L. S., Frahling, G., Leonardi, S., Marchetti-Spaccamela, A., and Sohler, C. Counting triangles in data streams. In Proceedings of the twenty-fifth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems (2006), ACM, pp. 253–262. [14] Bury, M., and Schwiegelshohn, C. Sublinear estimation of weighted matchings in dynamic data streams. arXiv preprint arXiv:1505.02019 (2015). [15] Chakrabarti, A., Cormode, G., and McGregor, A. Annotations in data streams. In Automata, Languages and Programming. Springer, 2009, pp. 222–234. [16] Chakrabarti, A., Cormode, G., McGregor, A., Thaler, J., and Venkatasubramanian, S. Verifiable stream computation and arthur–merlin communication. In CCC (2015). [17] Chazelle, B., Rubinfeld, R., and Trevisan, L. Approximating the minimum spanning tree weight in sublinear time. SIAM Journal on computing 34, 6 (2005), 1370–1379. [18] Chen, J., McCauley, S., and Singh, S. Rational proofs with multiple provers. CoRR abs/1504.08361 (2015). [19] Chitnis, R., Cormode, G., Hajiaghayi, M., and Monemizadeh, M. Parameterized streaming: maximal matching and vertex cover. In SODA (2015), SIAM, pp. 1234–1251. [20] Cormode, G. Bertinoro workshop 2011, problem 47. http://sublinear.info/index.php? title=Open_Problems:47. [21] Cormode, G., Mitzenmacher, M., and Thaler, J. Streaming graph computations with a helpful advisor. Algorithmica 65, 2 (2013), 409–442. [22] Cormode, G., Thaler, J., and Yi, K. Verifying computations with streaming interactive proofs. Proceedings of the VLDB Endowment 5, 1 (2011), 25–36. [23] Crouch, M., and Stubbs, D. M. Improved streaming algorithms for weighted matching, via unweighted matching. APPROX/RANDOM 28 (2014), 96–104. [24] Cunningham, W., and Marsh, A. A primal algorithm for optimum matching. In Polyhedral Combinatorics. Springer, 1978, pp. 50–72. [25] Daruki, S., Thaler, J., and Venkatasubramanian, S. Streaming verification in data analysis. In Algorithms and Computation. Springer Berlin Heidelberg, 2015, pp. 715–726. [26] Epstein, L., Levin, A., Mestre, J., and Segev, D. Improved approximation guarantees for weighted matching in the semi-streaming model. SIAM Journal on Discrete Mathematics 25, 3 (2011), 1251–1265. [27] Esfandiari, H., Hajiaghayi, M. T., Liaghat, V., Monemizadeh, M., and Onak, K. Streaming algorithms for estimating the matching size in planar graphs and beyond. In SODA (2015), SIAM, pp. 1217–1233. [28] Fenner, S. A., Gurjar, R., and Thierauf, T. Bipartite perfect matching is in quasi-nc. Electronic Colloquium on Computational Complexity (ECCC) 22 (2015), 177. REFERENCES 25 [29] Goldwasser, S., Kalai, Y. T., and Rothblum, G. N. Delegating computation: Interactive proofs for muggles. In STOC '08 (New York, NY, USA, 2008), ACM, pp. 113–122. [30] Guo, S., Hubácek, P., Rosen, A., and Vald, M. Rational arguments: single round delegation with sublinear verification. In Proc. ITCS (2014), ACM, pp. 523–540. [31] Guo, S., Hubácek, P., Rosen, A., and Vald, M. Rational sumchecks. In Theory of Cryptography. Springer, 2016, pp. 319–351. [32] Gur, T., and Rothblum, R. D. Non-interactive proofs of proximity. T. Roughgarden, Ed., ACM, pp. 133–142. In Proc. ITCS (2015), [33] Jowhari, H., and Ghodsi, M. New streaming algorithms for counting triangles in graphs. In Computing and Combinatorics. Springer, 2005, pp. 710–716. [34] Kalai, Y. T., Raz, R., and Rothblum, R. D. How to delegate computations: The power of no-signaling proofs. Cryptology ePrint Archive, Report 2013/862, 2013. http://eprint.iacr. org/. [35] Kapralov, M. Better bounds for matchings in the streaming model. In SODA (2013), SIAM, pp. 1679–1697. [36] Kapralov, M., Khanna, S., and Sudan, M. Streaming lower bounds for approximating max-cut. In SODA (2015), SIAM, pp. 1263–1282. [37] Karp, R. M., Upfal, E., and Wigderson, A. Constructing a perfect matching is in random NC. Combinatorica 6, 1 (Jan. 1986), 35–48. [38] Klauck, H. On arthur merlin games in communication complexity. In Computational Complexity (CCC), 2011 IEEE 26th Annual Conference on (2011), IEEE, pp. 189–199. [39] Klauck, H., and Prakash, V. An improved interactive streaming algorithm for the distinct elements problem. In Automata, Languages, and Programming. Springer, 2014, pp. 919–930. [40] Kogan, D., and Krauthgamer, R. Sketching cuts in graphs and hypergraphs. In Proc. ITCS (2015), ACM, pp. 367–376. [41] König, D. Gráfok és alkalmazásuk a determinánsok és a halmazok elméletére. Matematikai és TermÃl'szettudományi Értesíto 34 (1916), 104–119. [42] Konrad, C. Maximum matching in turnstile streams. arXiv preprint arXiv:1505.01460 (2015). [43] McGregor, A. Graph stream algorithms: A survey. ACM SIGMOD Record 43, 1 (2014), 9–20. [44] Pavan, A., Tangwongsan, K., Tirthapura, S., and Wu, K.-L. Counting and sampling triangles from a graph stream. Proceedings of the VLDB Endowment 6, 14 (2013), 1870–1881. [45] Razborov, A. A. On the distributional complexity of disjointness. Theoretical Computer Science 106, 2 (1992), 385–390. [46] Reingold, O., Rothblum, G. N., and Rothblum, R. D. Constant-round interactive proofs for delegating computation. In Proc. STOC (2016). REFERENCES 26 [47] Sohler, C. Dortmund workshop on streaming algorithms, problem 52. http://sublinear. info/index.php?title=Open_Problems:52, 2012. [48] Thaler, J. Private communication, 2015. [49] Thaler, J. Semi-streaming algorithms for annotated graph streams. In Proc. ICALP (2016). [50] Tutte, W. T. The factorization of linear graphs. The Journal of the London Mathematical Society, Ser. 1 22, 2 (1947), 107–111. [51] Verbin, E., and Yu, W. The streaming complexity of cycle counting, sorting by reversals, and other problems. In SODA (2011), SIAM, pp. 11–25.
1803.01474
1
1803
2018-03-05T02:50:14
Optimizing Learned Bloom Filters by Sandwiching
[ "cs.DS" ]
We provide a simple method for improving the performance of the recently introduced learned Bloom filters, by showing that they perform better when the learned function is sandwiched between two Bloom filters.
cs.DS
cs
Optimizing Learned Bloom Filters by Sandwiching Michael Mitzenmacher1 8 1 0 2 r a M 5 ] S D . s c [ 1 v 4 7 4 1 0 . 3 0 8 1 : v i X r a Abstract- We provide a simple method for improving the performance of the recently introduced learned Bloom filters, by showing that they perform better when the learned function is sandwiched between two Bloom filters. I. INTRODUCTION Recent work has introduced the learned Bloom filter [2]. As formalized in [3], the learned Bloom filter, like a standard Bloom filter, provides a compressed representation of a set of keys K that allows membership queries. Given a key y, a learned Bloom filter will always return yes if y is in K, and will generally return no if y is not in K, but may return false positives. What makes a learned Bloom filter interesting is that it uses a function that can be obtained by "learning" the set K to help determine the appropriate answer. Specifically, we recall the following definition from [3]: Definition 1: A learned Bloom filter on a set of positive keys K and negative keys U is a function f : U → [0, 1] and threshold τ, where U is the universe possible query keys, and an associated standard Bloom filter B, referred to as a backup filter. The backup filter is set to hold the set of keys {z : z ∈ K, f (z) < τ}. For a query y, the learned Bloom filter returns that y ∈ K if f (y) ≥ τ, or if f (y) < τ and the backup filter returns that y ∈ K. The learned Bloom filter returns y /∈ K otherwise. In less mathematical terms, a learned Bloom filter consists of pre-filter before a Bloom filter, where the backup Bloom filter now acts to prevent false negatives. The pre-filter suggested in [2] comes from a neural network and estimates the probability an element is in the set, allowing the use of a backup Bloom filter that can be substantially smaller than a standard Bloom filter for the set of keys K. If the function f has a sufficiently small representation, then the learned Bloom filter can be correspondingly smaller than a standard Bloom filter for the same set. Given this formalization of the learned Bloom filter, and the additional analysis from [3] for determining the false positive rate of a learned Bloom filter, it seems natural to ask whether this structure can be improved. Here we show, perhaps surprisingly, that a better structure is to use a Bloom filter before using the function f, in order to remove most queries for keys not in K. We emphasize that this initial Bloom filter does not declare that an input y is in K, but passes on all matching elements the learned function f, and it returns y /∈ K when the Bloom filter shows the element is not in K. Then, as before, we use the function f to attempt 1School of Engineering and Applied Sciences, Harvard University. Sup- ported in part by NSF grants CCF-1563710, CCF-1535795, and CCF- 1320231. This work was done while visiting Microsoft Research. to remove false positives from the initial Bloom filter, and then use the backup filter to allow back in keys from K that were false negatives for f. Because we have two layers of Bloom filters surrounding the learned function f, we refer to this as a sandwiched learned Bloom filter. The sandwiched learned Bloom filter is represented pictorially in Figure 1. In hindsight, our result that sandwiching improves per- formance makes sense. The purpose of the backup Bloom filter is to remove the false negatives arising from the learned function. If we can arrange to remove more false positives up front, then the backup Bloom filter can be quite porous, allowing most everything that reaches it through, and therefore can be quite small. Indeed, our analysis shows that the backup filter can be remarkably small, so that as the budget of bits available for the Bloom filters increases, any additional bits should go to the initial Bloom filter. We present our analysis below. II. ANALYZING SANDWICHED LEARNED BLOOM FILTERS We model the sandwiched learned Bloom filter as follows. The middle of the learned Bloom filter we treat as an oracle for the keys K, where K = m. For keys not in K there is an associated false positive probability Fp, and there are Fnm false negatives for keys in K. (The value Fn is like a false negative probability, but given K this fraction is determined and known according to the oracle outcomes.) This oracle can represent the function f associated with Definition 1 for learned Bloom filters, but might also represent other sorts of filter structures as well. Also, as described in [3], we note that in the context of a learned Bloom filter, the false positive rate is necessarily tied to the query stream, and so in general may be an empirically determined quantity; see [3] for further details and discussion on this point. Here we show how to optimize over a single oracle, although in practice we may possibly choose from oracles with different values Fp and Fn, in which case we can optimize for each set of value and choose the best suited to the application. We assume a total budget of bm bits to be divided between an initial Bloom filter of b1m bits and a backup Bloom filter of b2m bits. To model the false positive rate of a Bloom filter that uses j bits per stored key, we assume the false positive rate falls as αj. This is the case for a standard Bloom filter (where α ≈ 0.6185 when using the optimal number of hash functions, as described in the survey [1]), as well as for a static Bloom filter built using a perfect hash function (where α = 1/2, again described in [1]). The analysis can be modified to handle other functions for false positives in terms of j in a straightforward manner. It is important to note that if K = m, the backup Bloom filter only needs to hold mFn keys, and hence we take the number of bits per stored key to be b2/Fn. Note that if we find the best value of b2 is b, then no initial Bloom filter is needed, but otherwise, an initial Bloom filter is helpful. The false positive rate of a sandwiched learned Bloom filter is then αb1 (Fp + (1 − Fp)αb2/Fn ). To see this, note that for y /∈ K, y first has to pass through the initial Bloom filter, which occurs with probability αb1. Then y either causes a false positive from the learned function f with probability Fp, or with remaining probability (1 − Fp) it yields a false positive on the backup Bloom filter, with probability αb2/Fn. As α, Fp, Fn and b are all constants for the purpose of this analysis, we may optimize for b1 in the equivalent expression Fpαb1 + (1 − Fp)αb/Fnαb1(1−1/Fn). The derivative with respect to b1 is Fp(ln α)αb1 + (1− Fp) 1 − 1 Fn (cid:18) (cid:19) αb/Fn(ln α)αb1(1−1/Fn). This equals 0 when Fp (1 − Fp) (cid:16) 1 Fn (cid:17) = α(b−b1)/Fn = αb2/Fn . − 1 This yields that the false positive rate is minimized when b2 = Fn logα (cid:16) 1 Fn (cid:17) . − 1 Fp (1 − Fp) This result may be somewhat surprising, as here we see that b2 is a constant, independent of b. That is, the number of bits used for the backup filter is not a constant fraction of the total budgeted number of bits bm, but a fixed number of bits; if the number of budgeted bits increases, one should simply increase the size of the initial Bloom filter as long as the backup filter is appropriately sized. In hindsight, returning to the expression for the false positive rate αb1 (Fp + (1 − Fp)αb2/Fn ), we can see the intuition for why this would be the case. If we think of sequentially distributing the bm bits among the two Bloom filters, the expression shows that bits assigned to the initial filter (the b1 bits) reduce false positives arising from the learned function (the Fp term) as well as false positives arising subsequent to the learned function (the (1 − Fp) term), while the backup filter only reduces false positives arising subsequent to the learned function. Initially we would provide bits to the backup filter to reduce the (1 − Fp) rate of false positives subsequent to the learned function. Indeed, bits in the backup filter drive down this (1−Fp) term rapidly, because the backup filter holds fewer keys from the original set, leading to the b2/Fn (instead of just a b2) in the exponent in the expression αb2/Fn. Once the false positives coming through the backup Bloom filter reaches an appropriate level, which, by plugging in the determined optimal value for b2, we find is (cid:18) 1 (cid:19) − 1 , Fp/ Fn then the tradeoff changes. At the gains from reducing the false positives from the backup Bloom filter are smaller than the gains obtained by using the initial Bloom filter. that point As an example, using numbers roughly corresponding to settings tested in [2], suppose we have a learned function f where Fn = 1/2 and Fp = 1/100. For convenience we consider α = 1/2 (that corresponds to perfect hash function based Bloom filters). Then b2 = (log2 99)/2 ≈ 3.315. Depending on our Bloom filter budget parameter b, we obtain different levels of performance improvement by using the initial Bloom filter. At b = 8 bits per key, the false positive rate drops from approximately 0.010015 to 0.000777, over an order of magnitude. Even at b = 6 bits per key, the false positive rate drops from approximately 0.010242 to 0.003109. If one wants to consider a fixed false positive rate and con- sider the space savings from using the sandwiched approach, that is somewhat more difficult. The primary determinant of the overall false positive rate is the oracle's false positive probability Fp. The sandwich optimization allows one to achieve better overall false positive with a larger Fp; that is, it can allow for weaker, and correspondingly smaller, oracles. A possible further advantage of the sandwich approach is that it makes learned Bloom filters more robust. As discussed in [3], if the queries given to a learned Bloom filter do not come from the same distribution as the queries from the test set used to estimate the learned Bloom filter's false positive probability, the actual false positive probability may be substantially larger than expected. The use of an initial Bloom filter mitigates this problem, as this issue affects the smaller number of keys that pass the initial Bloom filter. In any case, we suggest that given that the sandwich learned Bloom filter is a relatively simple modification if one chooses to use a learned Bloom filter, we believe that the sandwiching method will allow greater application of the learned Bloom filter methodology. REFERENCES [1] A. Broder and M. Mitzenmacher. Network applications of bloom filters: A survey. Internet Mathematics, 1(4):485-509, 2004. [2] T. Kraska, A. Beutel, E. H. Chi, J. Dean, and N. Polyzotis. The Case for Learned Index Structures. https://arxiv.org/abs/1712. 01208, 2017. [3] M. Mitzenmacher. A Model for Learned Bloom Filters and Related Structures. https://arxiv.org/abs/1802.00884, 2018. Fig. 1. The left side shows the original learned Bloom filter. The right side shows the sandwiched learned Bloom filter. Learned Oracle Backup Filter Input Posi6ves Nega6ves Posi6ves Nega6ves Learned Oracle Backup Filter Posi6ves Posi6ves Nega6ves Posi6ves Nega6ves Ini6al Filter Input Nega6ves
1912.06983
1
1912
2019-12-15T05:48:48
Bisect and Conquer: Hierarchical Clustering via Max-Uncut Bisection
[ "cs.DS" ]
Hierarchical Clustering is an unsupervised data analysis method which has been widely used for decades. Despite its popularity, it had an underdeveloped analytical foundation and to address this, Dasgupta recently introduced an optimization viewpoint of hierarchical clustering with pairwise similarity information that spurred a line of work shedding light on old algorithms (e.g., Average-Linkage), but also designing new algorithms. Here, for the maximization dual of Dasgupta's objective (introduced by Moseley-Wang), we present polynomial-time .4246 approximation algorithms that use Max-Uncut Bisection as a subroutine. The previous best worst-case approximation factor in polynomial time was .336, improving only slightly over Average-Linkage which achieves 1/3. Finally, we complement our positive results by providing APX-hardness (even for 0-1 similarities), under the Small Set Expansion hypothesis.
cs.DS
cs
Bisect and Conquer: Hierarchical Clustering via Max-Uncut Bisection Sara Ahmadian∗ Vaggos Chatziafratis† Alessandro Epasto∗ Euiwoong Lee‡ Mohammad Mahdian∗ Konstantin Makarychev§ Grigory Yaroslavtsev¶ Abstract Hierarchical Clustering is an unsupervised data analysis method which has been widely used for decades. Despite its popularity, it had an underdeveloped analytical foundation and to ad- dress this, Dasgupta recently introduced an optimization viewpoint of hierarchical clustering with pairwise similarity information that spurred a line of work shedding light on old algorithms (e.g., Average-Linkage), but also designing new algorithms. Here, for the maximization dual of Das- gupta's objective (introduced by Moseley-Wang), we present polynomial-time .4246 approxima- tion algorithms that use Max-Uncut Bisection as a subroutine. The previous best worst-case approximation factor in polynomial time was .336, improving only slightly over Average-Linkage which achieves 1/3. Finally, we complement our positive results by providing APX-hardness (even for 0-1 similarities), under the Small Set Expansion hypothesis. 1 Introduction Hierarchical Clustering (HC) is a popular unsupervised learning method which produces a recursive de- composition of a dataset into clusters of increasingly finer granularity. The output of HC is a hierarchical representation of the dataset in the form of a tree (a.k.a. dendrogram) whose leaves correspond to the data points. The internal nodes of the tree correspond to clusters organized in a hierarchical fashion. Since HC captures cluster structure at all levels of granularity simultaneously, it offers several advantages over a basic flat clustering (a partition of the data into a fixed number of clusters) and it has been used for several decades (see e.g., Ward's method [WJ63]). It is one of the most popular methods across a wide range of fields e.g., in phylogenetics [SS62, JS68], where many of the so-called linkage-based algorithms (like Average/Single/Complete-Linkage) originated, in gene expression data analysis [ESBB98], the analysis of social networks [LRU14, MMO08], bioinformatics [DBE+15], image and text classification [SKK+00], and even in financial markets [TLM10]. See classic texts [JMF99, MRS08, Jai10] for a standard introduction to HC and linkage-based methods. Due to the importance of HC, many variations (including linkage- based methods) are also currently implemented in standard scientific computing packages and in large-scale systems [BBD+17]. Despite the plethora of applications, until recently there wasn't a concrete objective associated with HC methods (except for the Single-Linkage clustering which enjoys a simple combinatorial structure due to the ∗Google Research NY, New York. †Stanford University, California. Supported by an Onassis Foundation Scholarship. ‡New York University, New York. §Northwestern University, Evanston, IL. ¶Indiana University, Bloomington. Supported by NSF grant 1657477. 1 connection to minimum spanning trees [GR69]). This is in stark contrast with flat clustering methods where k-means, k-median, k-center constitute some standard objectives. Recent breakthrough work [Das16] by Dasgupta addressed this gap by introducing the following objective function: Definition 1.1 (HC Objective [Das16]). Given a similarity matrix with entries wij ≥ 0 corresponding to similarities between data points i and j, let the hierarchical clustering objective for a tree T be defined as: (cid:88) F−(T ) = wijT (i, j), i<j where T (i, j) denotes the number of leaves under the least common ancestor of i and j. The goal of HC under Dasgupta's objective is to minimize the function F−(T ) among all possible trees. Intuitively, the objective encourages solutions that do not separate similar points (those with high wij) until the lower levels of the tree; this is because T (i, j) = n, if i, j are separated at the top split of the tree T , whereas T (i, j) = 2, if i, j are separated at the very last level. Dasgupta [Das16] further showed that many desirable properties hold for this objective with respect to recovering ground truth hierarchical clusterings. This was later strengthened both theoretically and experimentally [CAKMTM19,RP16]. Although, it is not hard to see that the optimum tree should be binary, it is not clear how one can optimize for it given the vast search space. Surprisingly, [Das16] established a connection with a standard graph partitioning primitive, Sparsest-Cut, which had been previously used to obtain HC in practice [MMO08]. Later work [CC17] further showed a black-box connection: an α- approximation for Sparsest-Cut or Balanced-Cut gives an O(α)-approximation for F−(T ). Hence an √ log n)-approximation can be computed in polynomial time by using the celebrated result of [ARV08]. O( A constant-factor hardness is also known under the Small Set Expansion hypothesis [CC17, RP16]. Building on Dasgupta's work, Moseley and Wang [MW17] gave the first approximation analysis of the Average-Linkage method. Specifically, for the complement of Dasgupta's objective (see Definition 2.1), they proved that Average-Linkage achieves a 1/3 approximation in the worst case. That factor was marginally improved to .3363 in [CCN19] via an ad-hoc semidefinite programming formulation of the problem. This was the state-of-the-art in terms of approximation prior to this work and was arguably complicated and impractical. Contributions: In this paper, we extend the recent line of research initiated by Dasgupta's work on objective-based hierarchical clustering for similarity data, by significantly beating the previous best-known approximation factor for the [MW17] objective and doing so with natural algorithms. Our algorithm is based on a combination of Max-Uncut Bisection and Average-Linkage and guarantees .4246 of the value of the optimum hierarchical clustering, whereas previous work based on semidefinite programming [CCN19] only achieved .3363. An advantage of our algorithm is that it uses the Max-Uncut Bisection primitive as a black-box and the approximation ratio gracefully degrades as a function of the quality of this primitive; this is in contrast with previous approaches [CCN19] which solve complicated convex relaxations tailored to the objective. Since both theoretical and practical solutions for Max-Uncut Bisection are readily available in [ABG16, SS13], this results in a family of algorithms which can be analyzed both rigorously and empirically. We also complement our algorithmic results with hardness of approximation (APX-hardness): assuming the Small Set Expansion hypothesis, we prove that even for 0-1 similarities, there exists ε > 0, such that it is NP-hard to approximate the [MW17] objective within a factor of (1 − ε). A summary of our results compared to the previous work is given in Table 1. Here we also point out that .3333 is a simple baseline achieved by a random binary tree [MW17] and hence our work gives the first major improvement over this baseline. Further Related Work: HC has also been studied in the "semi-supervised" or "interactive" case, where prior knowledge or expert advice is available, with or without the geometric information on the data points. Examples of these works include [EZK18] where they are interested in the number of (triplet) queries necessary to determine a ground truth HC, and [VD16, CNC18] who provide techniques for incor- porating triplet constraints (the analog of split/merge feedback [BB08, ABV17] or must-link/cannot-link 2 [MW17] [CCN19] Our paper Approx. Hardness NP-hard 1/3 .3363 - .4246 APX-hard under SSE Table 1: Our results for the [MW17] objective. constraints [WCR+01, WC00] in standard flat clustering) to get better hierarchical trees. Furthermore, as- suming the data points lie in a metric space (instead of wij being arbitrary similarities), there are previous works that measure the quality of a HC using standard flat-clustering objectives like k-means, k-median or k-center as proxies [CCFM04, Das02, Pla06, LNRW10] in order to get approximation guarantees. Finally, in high dimensions when even running simple algorithms like single-linkage becomes impractical due to the exponential dependence on the dimension [YV17], one can still efficiently achieve good approximations if the similarities are generated with the fairly common Gaussian Kernel and other smooth similarity measures, as is shown in [CCNY18]. Organization: We start by providing the necessary background in Section 2. Then, we give our .4246 approximation algorithm for HC based on Max-Uncut Bisection in Section 3 and our hardness of ap- proximation result in Section 4. Our conclusion is given in Section 5. 2 Preliminaries We begin by setting the notation used throughout the paper. The input to the HC problem is given by an (explicit or implicit) n × n matrix of pairwise similarities with non-negative entries wij ≥ 0 corresponding to the similarity between the i-th and j-th data point. Sometimes we also refer to the underlying weighted graph as G(V, E, w). We denote by T a rooted tree whose leaves correspond to the n vertices. For two leaves i, j, T (i, j) denotes the subtree rooted in the least common ancestor of i and j in T and T (i, j) the number of leaves contained in T (i, j). (i<j)∈S×S wij denotes the total weight of pairwise similarities inside S. For a i∈S,j∈T wij denotes the total weight of pairwise similarities between S and T . Definition 2.1 (HC Objective [MW17]). For a tree T consider the hierarchical clustering objective: For a set S ⊆ V , w(S) :=(cid:80) pair of disjoint sets (S, T ) ∈ V × V , w(S, T ) :=(cid:80) (cid:88) F +(T ) = If we denote the total weight of the graph by W :=(cid:80) 1≤i<j≤n the value of this objective is (n − 2)W . wij(n − T (i, j)) (*) i<j wij, then note that a trivial upper bound on Average-Linkage: One of the main algorithms used in practice for HC, it starts by merging clusters of data points that have the highest average similarity. It is known that it achieves 1/3 approximation for the Moseley-Wang objective and this is tight in the worst case∗ [CCN19]. For a formal description, please refer to Algorithm 1. (S, ¯S), such that the weight of uncut edges (cid:80) Max-Uncut Bisection: This is the complement problem to Min-Cut Bisection (which is perhaps more standard in the literature), and the goal here is to split the vertices of a weighted graph into two sets i∈S,j∈ ¯S wij is maximized. It is known that one ij∈E wij −(cid:80) can achieve at least .8776 of the optimum value in polynomial time [ABG16, WDX15]. ∗As is common in worst-case analysis of algorithms, the 1/3 tightness for Average-Linkage is based on a rather brittle pathological counterexample, even though its performance is much better in practice (see for example [CCNY18]). 3 Algorithm 1 Average-Linkage 1: input: Similarity matrix w ∈ Rn×n≥0 . 2: Initialize clusters C ← ∪v∈V {v}. 3: while C ≥ 2 do Pick A, B ∈ C to maximize: Set C ← C ∪ {A ∪ B} \ {A, B} w(A, B) := 1AB (cid:80) 4: 5: 6: 7: end while a∈A,b∈B wab Algorithm 2 HC via Max-Uncut Bisection 1: input: Similarity matrix w ∈ Rn×n≥0 . 2: Partition the underlying graph on n vertices with edges weighted by w into two parts S and ¯S using Max-Uncut Bisection as a black box. This creates the top split in the hierarchical clustering tree. 3: Run Average-Linkage on S and on ¯S to get trees TS and T ¯S . 4: Construct the resulting HC tree by first splitting into (S, ¯S), then building trees TS and T ¯S on the respective sets. 3 0.4246 approximation for HC Our algorithm, based on Max-Uncut Bisection and Average-Linkage, is simple to state and is given It starts by finding an approximate solution to Max-Uncut Bisection, followed by in Algorithm 2. Average-Linkage agglomerative hierarchical clustering in each of the two pieces†. Our main result is that this approach produces a binary tree which achieves .4246 of the optimum: 4ρ Theorem 3.1. Given an instance of hierarchical clustering, our Algorithm 2 outputs a tree achieving 3(2ρ+1) − o(1) ≥ .4246 (for ρ = 0.8776) of the optimum according to the objective (*), if a ρ-approximation for the Max-Uncut Bisection problem is used as a black-box. Remark: The current best approximation factor achievable for Max-Uncut Bisection in polynomial time is ρ = 0.8776. This makes our analysis almost tight, since one can't get better than .444 even by using an exact Max-Uncut Bisection algorithm (with ρ = 1). 3.1 Overview of the proof Before delving into the technical details of the main proof, we present our high-level strategy through a series of 4 main steps: Step 1: Consider a binary‡ tree T ∗ corresponding to the optimal solution for the hierarchical clustering problem and let OPT = F +(T ∗) be the value of the objective function for this tree. Note that there exists a subtree (cid:99)T ∗ in this tree which contains more than n/2 leaves while its two children contain at most n/2 leaves each (see Figure 1). Given this decomposition of the optimum tree into three size restricted sets A, B, C, we provide an upper bound for OPT as a function of the weight inside and across these sets (see Proposition 3.2). We then need to do a case analysis based on whether the weight across or inside these sets is larger. Step 2: from the Average-Linkage part of our algorithm alone yields a 4 Proposition 3.4 based on the Fact 3.3. In the former case, things are easy as one can show that OPT is small and that even the contribution 9 -approximation. This is carried out in †With no change in approximation one can also run Max-Uncut Bisection recursively, however running Average-Linkage ‡W.l.o.g. the optimal tree can be made binary. is typically substantially more efficient. 4 Figure 1: Splitting T ∗ to size restricted sets A, B, C. Step 3: In the latter case, we show that there exists a split of the graph into two exactly equal pieces, so that the weight of the uncut edges is relatively large. This is crucial in the analysis as having a good solution to the Max-Uncut Bisection directly translates into a high value returned by the ρ-approximate black box algorithm (see Lemma 3.5, Proposition 3.6 and Proposition 3.7). Step 4: Finally, from the previous step we know that the returned value of the black box is large, hence taking into account the form of the HC objective, we can derive a lower bound for the value our Algorithm 2. The proof of the main theorem is then completed by Proposition 3.8 and Lemma 3.9. 3.2 Proof of Theorem 3.1 For ease of presentation, we assume n is even, to avoid the floor/ceiling notation and we omit the o(1) terms. Proposition 3.2. Let A be the set of leaves in the left subtree of (cid:99)T ∗, let B the set of leaves in the right subtree of (cid:99)T ∗ and C = V \ (A ∪ B) be the set of leaves outside of (cid:99)T ∗. Then§: OPT ≤ (w(A) + w(B) + w(C)) · (n − 2)+ + (w(A, B) + w(B, C) + w(A, C)) · C Proof. For an edge (i, j) whose endpoints lie in the same cluster (i.e., A, B or C), its contribution to the objective is at most wij(n − 2), using the trivial upper bound of (n − 2). Consider any pair of leaves (i, j) ∈ A × B in T ∗. The least common ancestor for this pair is the root of (cid:99)T ∗ and hence the contribution of this pair to the objective is equal to wij(n−(cid:99)T ∗) = wijC. Similarly, for any pair of leaves (i, j) ∈ A× C (or in B × C), their least common ancestor is a predecessor of the root of (cid:99)T ∗ and hence the contribution of this pair to the objective is at most wij(n − (cid:99)T ∗) = wijC. The desired bound now follows by summing up all the contributions of all distinct pairs of leaves. §By definition, A, B contain at most n 2 leaves, while C contains strictly fewer than n 2 leaves. 5 3 W (n − 2) = 1 3 (α + β)(n − 2). From now on, let α := w(A) + w(B) + w(C) and let β := w(A, B) + w(B, C) + w(A, C) denote the total weights of similarities inside the three sets and crossing a pair of these sets respectively. Note the total weight of all similarities is W = α + β. Fact 3.3 (Average-Linkage [MW17]). The Average-Linkage algorithm gives a solution whose F + objective is at least 1 Proposition 3.4. If α ≤ β, our Algorithm 2 outputs a solution of value at least 4/9OPT ≥ 0.44OPT, where OPT denotes the HC value of any optimum solution. Proof. Recall that by definition of C it holds that C < n have OPT ≤ α(n− 2) +C· β ≤ α(n− 2) + n−2 3 (α+β)(n−2). We have 1 solution whose expected value is 1 Hence, the Average-Linkage part of the algorithm alone gives a 4 Lemma 3.5. Suppose α ≥ β. Then, there exists a balanced cut (L, R) of the nodes in G, such that the weight of the uncut edges is at least α − (α − β)δmax(c), where c = C/n and δmax(c) = c(1−2c) (1−3c2) . 2 . Hence by Proposition 3.2 we 2 β. On the other hand, by Fact 3.3, Average-Linkage outputs a 9 (α(n−2)+ n−2 9 (β−α) ≥ 0. 2 ≤ n 2 − 1 ≤ n−2 3 (α+β)(n−2)− 4 9 -approximation in this case. 2 β) = 1 Proof. For the partition (A, B, C) we will refer to edges whose both endpoints are inside one of the three sets as red edges (i.e., (i, j) ∈ (A × A) ∪ (B × B) ∪ (C × C)). We refer to the edges whose two endpoints are contained in two different sets as blue edges (i.e., (i, j) ∈ (A × B) ∪ (A × C) ∪ (B × C)). Our goal here is to give a randomized partitioning scheme that produces the bisection (L, R) with high value of uncut weight lying inside L, R. For simplicity, recall that n is even. The case of odd n is handled similarly. Denote a = A/n and b = B/n. Let(cid:101)a = 1/2 − a,(cid:101)b = 1/2 − b, and(cid:101)c = 1/2 − c. Note that(cid:101)a,(cid:101)b are non-negative, and(cid:101)c is strictly positive due to the size restrictions. Define: qA = and 2(cid:101)b(cid:101)c ((cid:101)b +(cid:101)c)2 , qB = 2(cid:101)a(cid:101)c ((cid:101)a +(cid:101)c)2 , qC = 2(cid:101)a(cid:101)b ((cid:101)a +(cid:101)b)2 , pA = pB = pC = qBqC qAqB + qBqC + qAqC qAqC qAqB + qBqC + qAqC qAqB qAqB + qBqC + qAqC , , . We also denote the following expression by δ: δ = qA qB qC qAqB + qBqC + qAqC . 1). Consider the following partitioning procedure: • Pick one of the sets A, B, or C with probability pA, pB, and pC, respectively (note that pA + pB + pC = and output the cut L = B ∪ SB, R = C ∪ SC. • If the chosen set is A, partition it into two random sets SB and SC of size(cid:101)bA/((cid:101)b +(cid:101)c) and(cid:101)cA/((cid:101)b +(cid:101)c) • Similarly, if the chosen set is B, we partition it into two random sets SA and SC of size(cid:101)aB/((cid:101)a +(cid:101)c) and(cid:101)cB/((cid:101)a +(cid:101)c) and output the cut L = C ∪ SC, R = A ∪ SA. • If the chosen set is C, we partition it into two random sets SA and SB of size(cid:101)aC/((cid:101)a+(cid:101)b) and(cid:101)bC/((cid:101)a+(cid:101)b) and output the cut L = A ∪ SA, R = B ∪ SB. 6 We first observe that each of the output sets L and R has n/2 vertices, i.e., (L, R) is a bisection of the graph. If for instance, the algorithm picks set A at the first step, then the set L contains B +(cid:101)bA/((cid:101)b +(cid:101)c) vertices. We have L = B + (cid:101)b(cid:101)b +(cid:101)c = bn + 1/2 − b 1 − b − c · an = A = bn + 1/2 − b · an = n 2 . a The set R is the complement to L, thus, it also contains n/2 vertices. The cases when the algorithm picks the set B or C are identical. We now compute the expected weight of red edges in the bisection (L, R). Proposition 3.6. The expected weight of uncut red edges is (1 − δ)α. Proof. Again, assume that the algorithm picks the set A at the first step. Then, the sets B and C are contained in the sets L and R, respectively. Consequently, no edges in B and C are in the cut between L and R. Every edge in A is cut with probability 2(cid:101)b(cid:101)c/((cid:101)b +(cid:101)c)2. Thus, the weight of red edges in the cut between L and R (denoted as Ered(L, R)) given that the algorithm picks set A equals E(cid:2)Ered(L, R) algorithm picks A at first step(cid:3) = 2(cid:101)b(cid:101)c ((cid:101)b +(cid:101)c)2 = w(A) = qAw(A). Similarly, if the algorithm picks the set B or C, the expected sizes of the cuts equal qBw(B) and qCw(C), respectively. Hence, the expected weight of the red edges between L and R (when we do not condition on the first step of the algorithm) equals E(cid:2)Ered(L, R)(cid:3) = pAqAw(A) + pBqBw(B) + pC qCw(C) Observe that pAqA = pBqB = pCqC = qA qB qC = δ. Then, the expected weight of red edges between L and R equals: qAqB + qBqC + qAqC E(cid:2)Ered(L, R)(cid:3) = δ(w(A) + w(B) + w(C)) = δα. Here, we used that w(A) + w(B) + w(C) = α. The expected weight of uncut red edges equals (1 − δ)α. We now lower bound the weight of uncut blue edges. Proposition 3.7. The expected weight of uncut blue edges is at least δβ. Proof. We separately consider edges between sets A and B, B and C, A and C. Consider an edge (u, v) ∈ A× B. This edge is not in the cut (L, R) if both endpoints u and v belong to L or both endpoints belong to R. The former event -- {u, v ∈ L} -- occurs if the set B is chosen in the first step of the algorithm and the set SA contains vertex v; the latter event -- {u, v ∈ R} -- occurs if A is chosen in the first step of the algorithm and the set SB contains vertex u. The probability of the union of these events is¶ + pA · (cid:101)b(cid:101)b +(cid:101)c (cid:101)a(cid:101)a +(cid:101)c + pAqA · ((cid:101)b +(cid:101)c) 2(cid:101)c ¶Note that(cid:101)c = 0 cannot happen by definition of the sets A, B, C. = pBqB · ((cid:101)a +(cid:101)c) 2(cid:101)c Pr[(u, v) /∈ (L, R)] = pB · . = 7 Since pAqA = pBqB = δ, we have Pr[(u, v) /∈ (L, R)] = δ ·(cid:101)a +(cid:101)b + 2(cid:101)c 2(cid:101)c = δ · 1/2 +(cid:101)c 2(cid:101)c ≥ δ. The last inequality holds because (1/2 +(cid:101)c)/(cid:101)c ≥ 2 for all (cid:101)c ∈ (0, 1/2]. The same bound holds for edges between sets B and C and sets A and C. Therefore, the expected weight of uncut blue edges is at least δβ. By the above two propositions (Proposition 3.6 and Proposition 3.7) the expected total weight of uncut edges is at least: E [w(L) + w(R)] ≥ (1 − δ)α + δβ = α − (α − β)δ. Note that we are in the case with α − β ≥ 0. Thus to establish a lower bound on the expectation, we need to show an upper bound on δ. Write δ = qA qB qC qAqB + qBqC + qAqC = 1 + 1 qB 1 qA . + 1 qC After plugging in the values of qA, qB, and qC, we obtain the following expression for δ. Observe that a + b + c = 1 and(cid:101)a +(cid:101)b +(cid:101)c = 1/2. Thus,(cid:101)b +(cid:101)c = 1/2 −(cid:101)a,(cid:101)a +(cid:101)c = 1/2 −(cid:101)b, and(cid:101)a +(cid:101)b = 1/2 −(cid:101)c. 3 + 1 2 = δ = 1 1 Hence, ((cid:101)b+(cid:101)c)2 2(cid:101)a(cid:101)c + ((cid:101)a+(cid:101)b)2 + ((cid:101)a+(cid:101)c)2 2(cid:101)b(cid:101)c 2(cid:101)a(cid:101)b (cid:1) (cid:0)(cid:101)b+(cid:101)c(cid:101)a + (cid:101)a+(cid:101)c(cid:101)b + (cid:101)a+(cid:101)b(cid:101)c (cid:0) 1/2−(cid:101)a(cid:101)a + 1/2−(cid:101)b(cid:101)b + 1/2−(cid:101)c(cid:101)c (cid:1) . (cid:0) 1(cid:101)a + 1(cid:101)b + 1(cid:101)c Note that since the function t (cid:55)→ 1/t is convex for t > 0, we have (cid:17) ≥ 2(cid:101)a +(cid:101)b 1/2 −(cid:101)c (cid:16) 1(cid:101)a 2 + 1 3 + 1 2 = 3 1 1 1(cid:101)b 2 = 1 2 + δ = 4 = (cid:1) = = 2 c Therefore, δ ≤ 1 4(cid:101)c c + 1 2 + 1 3 c(1 − 2c) 1 − 3c2 . = We conclude that the expected weight of uncut edges is at least α − (α − β)δmax(c), where δmax(c) = c(1 − 2c)/(1 − 3c2). Proposition 3.8. Let ρ = 0.8776 be the approximation factor of the Max-Uncut Bisection algo- 3 (n − rithm [ABG16, WDX15]. Then if β ≤ α, our Algorithm 2 outputs a solution of value at least 2ρ 1)((1 − δmax(c))α + δmax(c)β). Proof. Let (L, R) be the bisection produced by the ρ-approximate Max-Uncut Bisection algorithm. This partition satisfies: w(L) + w(R) ≥ ρOPTMax-Uncut Bisection 8 Our Algorithm 2 produces a tree where at the top level the left subtree is L, the right subtree is R and both of these subtrees are then generated by Average-Linkage. Hence each edge (i, j) ∈ L × L (and similarly for edges in R × R) contributes: (cid:0) n 2 − 2)(cid:1) = 2 3 wij(n − 1) wij 2 + 1 3 ( n to the objective. Thus the overall value of our solution is at least: 2 3 (n − 1)(w(L) + w(R)) ≥ (n − 1) · OPTMax-Uncut Bisection ≥ 2ρ 3 If β ≤ α then by Lemma 3.5 we have that OPTMax-Uncut Bisection ≥ α − (α − β)δmax(c) and the proof follows by rearranging the terms. Lemma 3.9. The approximation factor ξ of our Algorithm 2 is at least Proof. First, note that if β ≥ α then by Proposition 3.4 the approximation is at least 0.44. Hence it suffices to only consider the case when β ≤ α. Recall that by Fact 3.3, Average-Linkage outputs a 3 (α + β)(n − 2) and by Proposition 3.2, we have OPT ≤ α(n − 2) + Cβ. Hence if solution of value 1 3 (α + β)(n − 2) ≥ ξ (α(n − 2) + Cβ) then the desired approximation holds. 1 3(2ρ+1) ≥ 0.42469. 4ρ Thus we only need to consider the case when 1 (α + β) ≤ ξ (cid:16) 3 (α + β)(n − 2) ≤ ξ (α(n − 2) + Cβ) or equivalently: (cid:17) ⇐⇒ 1 3 α + C n−2 β ⇐⇒ β ≤ 3ξ − 1 C n−2 ξ 1 − 3 α. 3 (1 − δmax(c)) and c2 = 2ρ Let c1 = 2ρ 3 δmax(c). In this case by Proposition 3.8, our Algorithm 2 gives value at least c1(n− 1)α + c2(n− 1)β. Hence it suffices to show that c1(n− 2)α + c2(n− 2)β ≥ ξ(α(n− 2) +Cβ). Or equivalently that: C n−2 ξ − c2) ≤ α(c1 − ξ) β( Using the bound on β above it suffices to show that: C n−2 ξ − c2) ≤ c1 − ξ. ( 3ξ − 1 C n−2 ξ 1 − 3 After simplifying this expression the above bound holds for: c1 − c2 n−2 c1 − cn Hence it suffices to find the minimum of the RHS over c ∈ [0, 1 c2 after simplification the RHS is equal to: 1 + 3 cn ξ ≤ n−2 − 3c2 2 − 1 . ρ(1 − c) 2c2ρ + (1 − 3c2) 2 3 n ]. Plugging in the expressions for c1 and Differentiating over c one can show that the minimum of this expression is attained for c = 1 2 − 1 n . √ Indeed, the numerator of the derivative is quadratic function with negative leading coefficient whose roots for t = 2ρ − 3. The left root is approximately 0.545 and hence the derivative is negative on are 1 ± 2 − 1 [0, 1 n ]. The value at the minimum c = 1 2 − 1 t(t+1) t n is thus equal(cid:107) to (ρ = 0.8776): 4ρ ≥ 0.42469 3(2ρ + 1) (cid:107)Observe that our analysis based on Max-Uncut Bisection is almost tight since even if we were given exact access to the optimum (i.e., ρ = 1), the approximation ratio for HC would only slightly increase to 4 9 = .444. 9 4 Hardness of Approximation In this section, we prove that maximizing the Moseley-Wang HC objective (*) is APX-hard: Theorem 4.1. Under the Small Set Expansion ( SSE) hypothesis, there exists ε > 0, such that it is NP-hard to approximate the Moseley-Wang HC objective function (*) within a factor (1 − ε). Initially introduced by Raghavendra and Steurer [RS10], SSE has been used to prove improved hard- ness results for optimization problems including Balanced Separator and Minimum Linear Arrange- ment [RST12]. Given a d-regular, unweighted graph G = (V, E) and S ⊆ V , let µ(S) := S/V and Φ(S) := E(S, V \ S)/dS. Raghavendra et al. [RST12] prove the following strong hardness result. (While it is not explicitly stated that the result holds for regular graphs, it can be checked that their reduction produces a regular graph [Tul19].) Theorem 4.2 (Theorem 3.6 of [RST12]). Assuming the SSE, for any q ∈ N and ε, γ > 0, given a regular graph G = (V, E), it is NP-hard to distinguish the following two cases. • YES: There exist q disjoint sets S1, . . . , Sq ⊆ V such that for all (cid:96) ∈ [q], Φ(S(cid:96)) ≤ ε + o(ε). µ(S(cid:96)) = 1/q and • NO: For all sets S ⊆ V , Φ(S) ≥ φ1−ε/2(µ(S)) − γ/µ(S) where φ1−ε/2(µ(S)) is the expansion of the sets of volume µ(S) in the infinite Gaussian graph with correlation 1 − ε/2. Proof of Theorem 4.1. Let us consider the instance of Hierarchical Clustering defined by the same graph where each pair has weight 1 if there is an edge, and 0 otherwise. Then W = E is the total weight. • YES: The fraction of edges crossing between different Si's is at most ε + o(ε), and all edges inside some Si are multiplied by at least n(1 − 1/q) in the objective function. So the objective function for Hierarchical clustering is at least (1 − ε − o(ε))W · (1 − 1 q )n ≥ nW (1 − 1 q − ε − o(ε)). • NO: Consider an arbitrary binary tree T that maximizes the Moseley-Wang objective function (*). For a tree node a ∈ T , let Ta be the subtree of T rooted at a, and Va ⊆ V be the set of graph vertices corresponding the leaves of Ta. Let b ∈ T be a highest node such that n/3 ≤ Vb ≤ 2n/3 (such a node always exists in a binary tree). By Theorem 4.2, we have Φ(Vb) ≥ φ1−ε/2(µ(Vb)) − γ/µ(Vb) ≥ C √ ε for some absolute constant C. Here we use the fact that φ1−ε/2(µ(Vb)) ≥ Ω( ε) for µ(Vb) ∈ [1/3, 2/3] √ and take γ small enough depending on ε. So the total fraction of edges in E(Vb, V \ Vb) is at least µ(Vb) · Φ(Vb) ≥ C √ ε 3 . Note that edges in E(Tb, V \ Tb) will multiplied by at most n/3 in the objective function. (Let a be the parent of b. Then Va > 2n/3 by the choice of b and for any edge crossing Vb, the the least common ancestors of the two endpoints will be a or one if its ancestors.) Therefore, the objective function is at most √ nW − C √ 3 W · 2n ε 3 = nW (1 − 2C 9 ε ). 10 Therefore, the value is at least nW (1 − 1/q − ε − o(ε)) in the YES case and nW (1 − (2C ε/9)) in the NO case. By taking ε > 0 sufficiently small and q arbitrarily large, there is a constant gap between the YES case value and the NO case value. √ 5 Conclusion In this paper, we presented a .4246 approximation algorithm for the hierarchical clustering problem with pairwise similarities under the Moseley-Wang objective (*), which is the complement to Dasgupta's objective. Our algorithm uses Max-Uncut Bisection as a black box and improves upon previous state-of-the-art approximation algorithms that were more complicated and only guaranteed .3363 of the optimum value. In terms of hardness of approximation, under the Small Set Expansion hypothesis, we prove that even for unweighted graphs, there exists ε > 0, such that it is NP-hard to approximate the objective function (*) within a factor of (1 − ε). References [ABG16] [ABV17] [ARV08] [BB08] [BBD+17] Per Austrin, Siavosh Benabbas, and Konstantinos Georgiou. Better balance by being bi- ased: A 0.8776-approximation for max bisection. ACM Transactions on Algorithms (TALG), 13(1):2, 2016. Pranjal Awasthi, Maria Florina Balcan, and Konstantin Voevodski. Local algorithms for interactive clustering. The Journal of Machine Learning Research, 18(1):75 -- 109, 2017. Sanjeev Arora, Satish Rao, and Umesh V. Vazirani. Geometry, flows, and graph-partitioning algorithms. Commun. ACM, 51(10):96 -- 105, 2008. Maria-Florina Balcan and Avrim Blum. Clustering with interactive feedback. In International Conference on Algorithmic Learning Theory, pages 316 -- 328. Springer, 2008. Mohammadhossein Bateni, Soheil Behnezhad, Mahsa Derakhshan, MohammadTaghi Haji- aghayi, Raimondas Kiveris, Silvio Lattanzi, and Vahab Mirrokni. Affinity clustering: Hier- archical clustering at scale. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Sys- tems 30, pages 6864 -- 6874. Curran Associates, Inc., 2017. [CAKMTM19] Vincent Cohen-Addad, Varun Kanade, Frederik Mallmann-Trenn, and Claire Mathieu. Hi- erarchical clustering: Objective functions and algorithms. Journal of the ACM (JACM), 66(4):26, 2019. [CC17] [CCFM04] [CCN19] Moses Charikar and Vaggos Chatziafratis. Approximate hierarchical clustering via sparsest cut and spreading metrics. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Sympo- sium on Discrete Algorithms, pages 841 -- 854. Society for Industrial and Applied Mathematics, 2017. Moses Charikar, Chandra Chekuri, Tom´as Feder, and Rajeev Motwani. Incremental clus- tering and dynamic information retrieval. SIAM Journal on Computing, 33(6):1417 -- 1440, 2004. Moses Charikar, Vaggos Chatziafratis, and Rad Niazadeh. Hierarchical clustering better than average-linkage. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 2291 -- 2304. SIAM, 2019. [CCNY18] Moses Charikar, Vaggos Chatziafratis, Rad Niazadeh, and Grigory Yaroslavtsev. Hierarchical clustering for euclidean data. arXiv preprint arXiv:1812.10582, 2018. 11 [CNC18] [Das02] [Das16] [DBE+15] [ESBB98] [EZK18] [GR69] [Jai10] [JMF99] [JS68] Vaggos Chatziafratis, Rad Niazadeh, and Moses Charikar. Hierarchical clustering with struc- tural constraints. In International Conference on Machine Learning, pages 773 -- 782, 2018. Sanjoy Dasgupta. Performance guarantees for hierarchical clustering. In International Con- ference on Computational Learning Theory, pages 351 -- 363. Springer, 2002. Sanjoy Dasgupta. A cost function for similarity-based hierarchical clustering. In Proceedings of the forty-eighth annual ACM symposium on Theory of Computing, pages 118 -- 127. ACM, 2016. Ibai Diez, Paolo Bonifazi, Inaki Escudero, Beatriz Mateos, Miguel A Munoz, Sebastiano Stramaglia, and Jesus M Cortes. A novel brain partition highlights the modular skeleton shared by structure and function. Scientific reports, 5:10532, 2015. Michael B Eisen, Paul T Spellman, Patrick O Brown, and David Botstein. Cluster analysis and display of genome-wide expression patterns. Proceedings of the National Academy of Sciences, 95(25):14863 -- 14868, 1998. Ehsan Emamjomeh-Zadeh and David Kempe. Adaptive hierarchical clustering using ordinal queries. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 415 -- 429. Society for Industrial and Applied Mathematics, 2018. John C Gower and Gavin JS Ross. Minimum spanning trees and single linkage cluster analysis. Journal of the Royal Statistical Society: Series C (Applied Statistics), 18(1):54 -- 64, 1969. Anil K. Jain. Data clustering: 50 years beyond k-means. Pattern Recognition Letters, 31(8):651 -- 666, 2010. Anil K. Jain, M. Narasimha Murty, and Patrick J. Flynn. Data clustering: A review. ACM Comput. Surv., 31(3):264 -- 323, 1999. N Jardine and R Sibson. A model for taxonomy. Mathematical Biosciences, 2(3-4):465 -- 482, 1968. [LNRW10] Guolong Lin, Chandrashekhar Nagarajan, Rajmohan Rajaraman, and David P Williamson. A general approach for incremental approximation and hierarchical clustering. SIAM Journal on Computing, 39(8):3633 -- 3669, 2010. [LRU14] [MMO08] [MRS08] [MW17] [Pla06] [RP16] Jure Leskovec, Anand Rajaraman, and Jeffrey David Ullman. Mining of massive datasets. Cambridge university press, 2014. Charles F Mann, David W Matula, and Eli V Olinick. The use of sparsest cuts to reveal the hierarchical community structure of social networks. Social Networks, 30(3):223 -- 234, 2008. Christopher D. Manning, Prabhakar Raghavan, and Hinrich Schutze. Introduction to infor- mation retrieval. Cambridge University Press, 2008. Benjamin Moseley and Joshua Wang. Approximation bounds for hierarchical clustering: Average linkage, bisecting k-means, and local search. In Advances in Neural Information Processing Systems, pages 3097 -- 3106, 2017. C Greg Plaxton. Approximation algorithms for hierarchical location problems. Journal of Computer and System Sciences, 72(3):425 -- 443, 2006. Aurko Roy and Sebastian Pokutta. Hierarchical clustering via spreading metrics. In Advances in Neural Information Processing Systems, pages 2316 -- 2324, 2016. 12 [RS10] [RST12] [SKK+00] [SS62] [SS13] [TLM10] [Tul19] [VD16] [WC00] [WCR+01] [WDX15] [WJ63] [YV17] Prasad Raghavendra and David Steurer. Graph expansion and the unique games conjecture. In Proceedings of the forty-second ACM symposium on Theory of computing, pages 755 -- 764. ACM, 2010. Prasad Raghavendra, David Steurer, and Madhur Tulsiani. Reductions between expansion problems. In 2012 IEEE 27th Conference on Computational Complexity, pages 64 -- 73. IEEE, 2012. Michael Steinbach, George Karypis, Vipin Kumar, et al. A comparison of document clustering techniques. In KDD workshop on text mining, volume 400, pages 525 -- 526. Boston, 2000. Peter HA Sneath and Robert R Sokal. Numerical taxonomy. Nature, 193(4818):855 -- 860, 1962. Peter Sanders and Christian Schulz. Kahip v0.53 - karlsruhe high quality partitioning - user guide. CoRR, abs/1311.1714, 2013. Michele Tumminello, Fabrizio Lillo, and Rosario N Mantegna. Correlation, hierarchies, and networks in financial markets. Journal of Economic Behavior & Organization, 75(1):40 -- 58, 2010. Madhur Tulsiani, 2019. Personal Communication. Sharad Vikram and Sanjoy Dasgupta. Interactive bayesian hierarchical clustering. In Inter- national Conference on Machine Learning, pages 2081 -- 2090, 2016. Kiri Wagstaff and Claire Cardie. Clustering with instance-level constraints. AAAI/IAAI, 1097:577 -- 584, 2000. Kiri Wagstaff, Claire Cardie, Seth Rogers, Stefan Schrodl, et al. Constrained k-means clus- tering with background knowledge. In ICML, volume 1, pages 577 -- 584, 2001. Chenchen Wu, Donglei Du, and Dachuan Xu. An improved semidefinite programming hier- archies rounding approximation algorithm for maximum graph bisection problems. Journal of Combinatorial Optimization, 29(1):53 -- 66, 2015. Joe H Ward Jr. Hierarchical grouping to optimize an objective function. Journal of the American statistical association, 58(301):236 -- 244, 1963. Grigory Yaroslavtsev and Adithya Vadapalli. Massively parallel algorithms and hardness for single-linkage clustering under ell p-distances. arXiv preprint arXiv:1710.01431, 2017. 13
1410.3438
2
1410
2015-06-29T13:25:45
Efficient and Compact Representations of Prefix Codes
[ "cs.DS" ]
Most of the attention in statistical compression is given to the space used by the compressed sequence, a problem completely solved with optimal prefix codes. However, in many applications, the storage space used to represent the prefix code itself can be an issue. In this paper we introduce and compare several techniques to store prefix codes. Let $N$ be the sequence length and $n$ be the alphabet size. Then a naive storage of an optimal prefix code uses $O(n\log n)$ bits. Our first technique shows how to use $O(n\log\log(N/n))$ bits to store the optimal prefix code. Then we introduce an approximate technique that, for any $0<\epsilon<1/2$, takes $O(n \log \log (1 / \epsilon))$ bits to store a prefix code with average codeword length within an additive $\epsilon$ of the minimum. Finally, a second approximation takes, for any constant $c > 1$, $O(n^{1 / c} \log n)$ bits to store a prefix code with average codeword length at most $c$ times the minimum. In all cases, our data structures allow encoding and decoding of any symbol in $O(1)$ time. We experimentally compare our new techniques with the state of the art, showing that we achieve 6--8-fold space reductions, at the price of a slower encoding (2.5--8 times slower) and decoding (12--24 times slower). The approximations further reduce this space and improve the time significantly, up to recovering the speed of classical implementations, for a moderate penalty in the average code length. As a byproduct, we compare various heuristic, approximate, and optimal algorithms to generate length-restricted codes, showing that the optimal ones are clearly superior and practical enough to be implemented.
cs.DS
cs
Efficient and Compact Representations of Prefix Codes ∗ † ‡ Travis Gagie(cid:63) Gonzalo Navarro† Yakov Nekrich‡ Alberto Ord´onez+ (cid:63) Department of Computer Science, University of Helsinki, Finland † Department of Computer Science, University of Chile, Chile ‡ David R. Cheriton School of Computer Science, University of Waterloo, Canada + Database Laboratory, Universidade da Coruna, Spain Abstract Most of the attention in statistical compression is given to the space used by the compressed sequence, a problem completely solved with optimal prefix codes. However, in many applica- tions, the storage space used to represent the prefix code itself can be an issue. In this paper we introduce and compare several techniques to store prefix codes. Let N be the sequence length and n be the alphabet size. Then a naive storage of an optimal prefix code uses O(n log n) bits. Our first technique shows how to use O(n log log(N/n)) bits to store the optimal prefix code. Then we introduce an approximate technique that, for any 0 <  < 1/2, takes O(n log log(1/)) bits to store a prefix code with average codeword length within an additive  of the minimum. Finally, a second approximation takes, for any constant c > 1, O(cid:0)n1/c log n(cid:1) bits to store a prefix code with average codeword length at most c times the minimum. In all cases, our data structures allow encoding and decoding of any symbol in O(1) time. We experimentally compare our new techniques with the state of the art, showing that we achieve 6 -- 8-fold space reductions, at the price of a slower encoding (2.5 -- 8 times slower) and decoding (12 -- 24 times slower). The approximations further reduce this space and improve the time significantly, up to recovering the speed of classical implementations, for a moderate penalty in the average code length. As a byproduct, we compare various heuristic, approximate, and optimal algorithms to generate length-restricted codes, showing that the optimal ones are clearly superior and practical enough to be implemented. 1 Introduction (where(cid:80)n i=1 pi = 1), the binary empirical entropy of the text is H(P ) =(cid:80)n Statistical compression is a well-established branch of Information Theory. Given a text T of length N , over an alphabet of n symbols Σ = {a1, . . . , an} with relative frequencies P = (cid:104)p1, . . . , pn(cid:105) in T i=1 pi lg(1/pi), where lg denotes the logarithm in base 2. An instantaneous code assigns a binary code ci to each symbol ai so that the symbol can be decoded as soon as the last bit of ci is read from the compressed stream. ∗Funded in part by Millennium Nucleus Information and Coordination in Networks ICM/FIC RC130003 for Gonzalo Navarro, and by MINECO (PGE and FEDER) [TIN2013-46238-C4-3-R, TIN2013-47090-C3-3-P]; CDTI, AGI, MINECO [CDTI-00064563/ITC-20133062]; ICT COST Action IC1302; Xunta de Galicia (co-founded with FEDER) [GRC2013/053], and AP2010-6038 (FPU Program) for Alberto Ord´onez. †Early partial versions of this work appeared in Proc. SOFSEM 2010 [22] and Proc. DCC 2013 [44]. ‡Corresponding author: Alberto Ord´onez, email: [email protected]. 1 [28] finds a prefix-free set of codes ci of length (cid:96)i, such that its average length L(P ) =(cid:80)n An optimal (or minimum-redundancy) instantaneous code (also called a prefix code) like Huffman's i=1 pi(cid:96)i is minimal and satisfies H(P ) ≤ L(P ) < H(P ) + 1. This guarantees that the encoded text uses less than N (H(P ) + 1) bits. Arithmetic codes achieve less space, NH(P ) + 2 bits, however they are not instantaneous, which complicates and slows down both encoding and decoding. In this paper we are interested in instantaneous codes. In terms of the redundancy of the code, L(P ) − H(P ), Huffman codes are optimal and the topic can be considered closed. How to store the prefix code itself, however, is much less studied. It is not hard to store it using O(n log n) bits, and this is sufficient when n is much smaller than N . There are several scenarios, however, where the storage of the code itself is problematic. One example is word-based compression, which is a standard to compress natural language text [6, 37]. Word-based Huffman compression not only performs very competitively, offering compression ratios around 25%, but also benefits direct access [52], text searching [39], and indexing [8]. In this case the alphabet size n is the number of distinct words in the text, which can reach many millions. Other scenarios where large alphabets arise are the compression of East Asian languages and general numeric sequences. Yet another case arises when the text is short, for example when it is cut into several pieces that are statistically compressed independently, for example for compression boosting [15, 29] or for interactive communications or adaptive compression [9]. The more effectively the codes are stored, the finer-grained can the text be cut. During encoding and decoding, the code must be maintained in main memory to achieve reason- able efficiency, whereas the plain or the compressed text can be easily read or written in streaming mode. Therefore, the size of the code, and not that of the text, is what poses the main memory requirements for efficient compression and decompression. This is particularly stringent on mobile devices, for example, where the supply of main memory is comparatively short. With the modern trend of embedding small devices and sensors in all kinds of objects (e.g., the "Internet of Things"1), those low-memory scenarios may become common. In this paper we obtain various relevant results of theoretical and practical nature about how to store a code space-efficiently, while also considering the time efficiency of compression and decompression. Our specific contributions are the following. 1. In Section 3 we show that it is possible to store an optimal prefix code within O(n log (cid:96)max) bits, where (cid:96)max = O(min(n, log N )) is the maximum length of a code (Theorem 1). Then we refine the space to O(n log log(N/n)) bits (Corollary 1). Within this space, encoding and decoding are carried out in constant time on a RAM machine with word size w = Ω(log N ). The result is obtained by using canonical Huffman codes [47], fast predecessor data structures [18, 46] to find code lengths, and multiary wavelet trees [25, 16, 5] to represent the mapping between codewords and symbols. 2. In Section 4 we show that, for any 0 <  < 1/2, it takes O(n log log(1/)) bits to store a prefix code with average codeword length at most L(P ) + . Encoding and decoding can be carried out in constant time on a RAM machine with word size w = Ω(log n). Thus, if we can tolerate a small constant additive increase in the average codeword length, we can store a prefix code using only O(n) bits. We obtain this result by building on the above scheme, where we use length-limited optimal prefix codes [35] with a carefully chosen (cid:96)max value. 1http://en.wikipedia.org/wiki/Internet of Things 2 3. In Section 5 we show that, for any constant c > 1, it takes O(cid:0)n1/c log n(cid:1) bits to store a prefix code with average codeword length at most cL(P ). Encoding and decoding can be carried out in constant time on a RAM machine with word size w = Ω(log n). Thus, if we can tolerate a small constant multiplicative increase, we can store a prefix code in o(n) bits. To achieve this result, we only store the codes that are shorter than about (cid:96)max/c, and use a simple code of length (cid:96)max + 1 for the others. Then all but the shortest codewords need to be explicitly represented. 4. In Section 6 we engineer and implement all the schemes above and compare them with careful implementations of state-of-the-art optimal and suboptimal codes. Our model representations are shown to use 6 -- 8 times less space than classical ones, at the price of being several times slower for compression (2.5 -- 8 times) and decompression (12 -- 24 times). The additive ap- proximations reduce these spaces up to a half and the times by 20% -- 30%, at the expense of a small increase (5%) in the redundancy. The multiplicative approximations can obtain models of the same size of the additive ones, yet increasing the redundancy to around 10%. In exchange, they are about as fast as the classical compression methods. If we allow them increase the redundancy to 15% -- 20%, the multiplicative approximations obtain model sizes that are orders of magnitude smaller than classical representations. 5. As a byproduct, Section 6 also compares varios heuristic, approximation, and exact algorithms to generate length-restricted prefix codes. The experiments show that the optimal algorithm is practical to implement and runs fast, while obtaining significantly better average code lengths than the heuristics and the approximations. A very simple-to-program approximation reaches the same optimal average code length in our experiments, yet it runs significantly slower. Compared to early partial versions of this work [22, 44], this article includes more detailed expla- nations, better implementations of our exact scheme, the first implementations of the approximate schemes, the experimental study of the performance of algorithms that generate length-limited codes, and stronger baselines to compare with. 2 Related Work A simple pointer-based implementation of a Huffman tree takes O(n log n) bits, and it is not difficult to show this is an optimal upper bound for storing a prefix code with minimum average codeword length. For example, suppose we are given a permutation π over n symbols. Let P be the probability distribution that assigns probability pπ(i) = 1/2i for 1 ≤ i < n, and probability pπ(n) = 1/2n−1. Since P is dyadic, every optimal prefix code assigns codewords of length (cid:96)π(i) = i, for 1 ≤ i < n, and (cid:96)π(n) = n − 1. Therefore, given any optimal prefix code and a bit indicating whether π(n − 1) < π(n), we can reconstruct π. Since there are n! choices for π, in the worst case it takes Ω(log n!) = Ω(n log n) bits to store an optimal prefix code. Considering the argument above, it is natural to ask whether the same lower bound holds for probability distributions that are not so skewed, and the answer is no. A prefix code is canonical [47, 38] if a shorter codeword is always lexicographically smaller than a longer codeword. Given any prefix code, we can always generate a canonical code with the same code lengths. Moreover, we can reassign the codewords such that, if a symbol is lexicographically the jth with a codeword of length (cid:96), then it is assigned the jth consecutive codeword of length (cid:96). It is clear that it is sufficient 3 √ to store the codeword length of each symbol to be able to reconstruct such a code, and thus the code can be represented in O(n log (cid:96)max) bits. There are more interesting upper bounds than (cid:96)max ≤ n. Katona and Nemetz [31] (see also Buro [11]) showed that, if a symbol has relative frequency p, then any Huffman code assigns it a codeword of length at most (cid:98)logφ(1/p)(cid:99), where φ = (1 + 5)/2 ≈ 1.618 is the golden ratio, and thus (cid:96)max is at most (cid:98)logφ(1/pmin)(cid:99), where pmin is the smallest relative frequency in P . Note also that, since pmin ≥ 1/N , it must hold (cid:96)max ≤ logφ N , therefore the canonical code can be stored in O(n log log N ) bits. Alternatively, one can enforce a value for (cid:96)max (which must be at least (cid:100)lg n(cid:101)) and pay a price in terms of average codeword length. The same bound above [31] hints at a way to achieve any desired (cid:96)max value: artificially increase the frequency of the least frequent symbols until the new pmin value is over φ−(cid:96)max, and then an optimal prefix code built on the new frequencies will hold the given maximum code length. Another simple technique (see, e.g., [3], where it was used for Hu-Tucker codes) is to start with an optimal prefix code, and then spot all the highest nodes in the code tree with depth (cid:96)max − d and more than 2d leaves, for any d. Then the subtrees of the parents of those nodes are made perfectly balanced. A more sophisticated technique, by Milidi´u and Laber [35], yields a performance guarantee. It first builds a Huffman tree T1, then removes all the subtrees rooted at depth greater than (cid:96)max, builds a complete binary tree T2 of height h whose leaves are those removed from T1, finds the node v ∈ T1 at depth (cid:96)max − h − 1 whose subtree T3's leaves correspond to the symbols with minimum total probability, and finally replaces v by a new node whose subtrees are T2 and T3. They show that the resulting average code length is at most L(P ) + 1/φ(cid:96)max−(cid:100)lg(n+(cid:100)lg n(cid:101)−(cid:96)max)(cid:101)−1. All these approximations require O(n) time plus the time to build the Huffman tree. A technique to obtain the optimal length-restricted prefix code, by Larmore and Hirshberg [33], performs in O(n (cid:96)max) time by reducing the construction to a binary version of the coin-collector's problem. The above is an example of how an additive increase in the average codeword length may yield less space to represent the code itself. Another well-known additive approximation follows from Gilbert and Moore's proof [24] that we can build an alphabetic prefix code with average codeword length less than H(P ) + 2, and indeed no more than L(P ) + 1 [41, 48]. In an alphabetic prefix code, the lexicographic order of the codewords is the same as that of the source symbols, so we need to store only the code tree and not the assignment of codewords to symbols. Any code tree, of n − 1 internal nodes, can be encoded in 4n + o(n) bits so that it can be navigated in constant time per operation [14], and thus encoding and decoding of any symbol takes time proportional to its codeword length. Multiplicative approximations have the potential of yielding codes that can be represented within o(n) bits. Adler and Maggs [1] showed it generally takes more than (9/40)n1/(20c) lg n bits to store a prefix code with average codeword length at most cH(P ). Gagie [19, 20, 21] showed that, for any constant c ≥ 1, it takes O(cid:0)n1/c log n(cid:1) bits to store a prefix code with average codeword cH(P ) + o(log n) in O(cid:0)n1/c−(cid:1) bits. Note that our result does not have the additive term "+2" in length at most cH(P ) + 2. He also showed his upper bound is nearly optimal because, for any positive constant , we cannot always store a prefix code with average codeword length at most addition to the multiplicative term, which is very relevant on low-entropy texts. 4 (a) (b) Figure 1: An arbitrary canonical prefix code (a) and the result of sorting the source symbols at each level (b). 3 Representing Optimal Codes Figure 1(a) illustrates a canonical Huffman code. For encoding in constant time, we can simply use an array like Codes, which stores at position i the code ci of source symbol ai, using (cid:96)max = O(log N ) bits for each. For decoding, the source symbols are written in an array Symb, in left-to-right order of the leaves. This array requires n lg n bits. The access to this array is done via two smaller arrays, which have one entry per level: sR[(cid:96)] points to the first position of level (cid:96) in Symb, whereas first[(cid:96)] stores the first code in level (cid:96). The space for these two arrays is O(cid:0)(cid:96)2 (cid:1) bits. max Then, if we have to decode the first symbol encoded in a bitstream, we first have to determine its length (cid:96). In our example, if the bitstream starts with 0, then (cid:96) = 2; if it starts with 10, then (cid:96) = 3, and otherwise (cid:96) = 4. Once the level (cid:96) is found, we read the next (cid:96) bits of the stream in ci, and decode the symbol as ai = Symb[sR[(cid:96)] + ci − first[(cid:96)]]. The problem of finding the appropriate entry in first can be recast into a predecessor search problem [23, 30]. We extend all the values first[(cid:96)] by appending (cid:96)max − (cid:96) bits at the end. In our example, the values become 0000 = 0, 1000 = 8, and 1100 = 12. Now, we find the length (cid:96) of the next symbol by reading the first (cid:96)max bits from the stream, interpreting it as a binary number, and finding its predecessor value in the set. Since we have only (cid:96)max = O(log N ) numbers in the set, and each has (cid:96)max = O(log N ) bits, the predecessor search can be carried out in constant time using fusion trees [18] (see also Patrascu and Thorup [46]), within O(cid:0)(cid:96)2 (cid:1) bits of space. max Although the resulting structure allows constant-time encoding and decoding, its space usage is still O(n (cid:96)max) bits. In order to reduce it to O(n log (cid:96)max), we will use a multiary wavelet tree data structure [25, 16]. In particular, we use the version that does not need universal tables [5, Thm. 7]. This structure represents a sequence L[1, n] over alphabet [1, (cid:96)max] using n lg (cid:96)max + o(n lg (cid:96)max) bits, and carries out the operations in time O(log (cid:96)max/ log w). In our case, where (cid:96)max = O(w), 5 726841530000001011111111010111111100111010000101Codes 72684153SymbsR001001100firstCanonical Huffman Tree representationCanonical Huffman Tree276813450000001011111127681345001001100firstsRCanonical Huffman Tree with symbols sorted at each levelSymb42444323L the space is n lg (cid:96)max + o(n) bits and the time is O(1). The operations supported by wavelet trees are the following: (1) Given i, retrieve L[i]; (2) given i and (cid:96) ∈ [1, (cid:96)max], compute rank(cid:96)(L, i), the number of occurrences of (cid:96) in L[1, i]; (3) given j and (cid:96) ∈ [1, (cid:96)max], compute select(cid:96)(S, j), the position in L of the j-th occurrence of (cid:96). Assume that the symbols of the canonical Huffman tree are in increasing order within each depth, as in Figure 1(b).2 Now, the key property is that Codes[i] = first[(cid:96)] + rank(cid:96)(L, i) − 1, where (cid:96) = L[i], which finds the code ci = Codes[i] of ai in constant time. The inverse property is useful for decoding code ci of length (cid:96): the symbol is ai = Symb[sR[(cid:96)]+ci−first[(cid:96)]] = select(cid:96)(L, ci−first[(cid:96)]+1). Therefore, arrays Codes, Symb, and sR are not required; we can encode and decode in constant time using just the wavelet tree of L and first, plus its predecessor structure. This completes the result. word size w = Ω((cid:96)max), we can store an optimal prefix code using n lg (cid:96)max + o(n) + O(cid:0)(cid:96)2 Theorem 1 Let P be the frequency distribution over n symbols for a text of length N , so that an optimal prefix code has maximum codeword length (cid:96)max. Then, under the RAM model with computer note that (cid:96)max ≤ logφ N . Within this space, encoding and decoding any symbol takes O(1) time. (cid:1) bits, max Therefore, under mild assumptions, we can store an optimal code in O(n log log N ) bits, with constant-time encoding and decoding operations. In the next section we refine this result further. On the other hand, note that Theorem 1 is also valid for nonoptimal prefix codes, as long as they are canonical and their (cid:96)max is O(w). We must warn the practice-oriented reader that Theorem 1 (as well as those to come) must be understood as a theoretical result. As we will explain in Section 6, other structures with worse theoretical guarantees perform better in practice than those chosen to obtain the best theoretical results. Our engineered implementation of Theorem 1 reaches O(log log N ), and even O(log N ), decoding time. It does, indeed, use much less space than previous model representations, but it is also much slower. 4 Additive Approximation In this section we exchange a small additive penalty over the optimal prefix code for an even more space-efficient representation of the code, while retaining constant-time encoding and decoding. It follows from Milidi´u and Laber's bound [35] that, for any  with 0 <  < 1/2, there is always a prefix code with maximum codeword length (cid:96)max = (cid:100)lg n(cid:101) +(cid:100)logφ(1/)(cid:101) + 1 and average codeword length within an additive 1 φ(cid:96)max−(cid:100)lg(n+(cid:100)lg n(cid:101)−(cid:96)max)(cid:101)−1 ≤ 1 φ(cid:96)max−(cid:100)lg n(cid:101)−1 ≤ 1 φlogφ(1/) =  n lg (cid:96)max + O(cid:0)n + (cid:96)2 (cid:1) bits, with constant-time encoding and decoding. In order to reduce the of the minimum L(P ). The techniques described in Section 3 give a way to store such a code in space, we note that our wavelet tree representation [5, Thm. 7] in fact uses nH0(L) + o(n) bits when (cid:96)max = O(w). Here H0(L) denotes the empirical zero-order entropy of L. Then we obtain the following result. max 2In fact, most previous descriptions of canonical Huffman codes assume this increasing order, but we want to emphasize that this is essential for our construction. 6 Theorem 2 Let L(P ) be the optimal average codeword length for a distribution P over n symbols. Then, for any 0 <  < 1/2, under the RAM model with computer word size w = Ω(log n), we can store a prefix code over P with average codeword length at most L(P ) + , using n lg lg(1/) +O(n) bits, such that encoding and decoding any symbol takes O(1) time. Proof. Our structure uses nH0(L) + o(n) + O(cid:0)(cid:96)2 (cid:1) bits, which is nH0(L) + o(n) because (cid:96)max = O(log n). To complete the proof it is sufficient to show that H0(S) ≤ lg lg(1/) + O(1). To see this, consider L as two interleaved subsequences, L1 and L2, of length n1 and n2, with L1 containing those lengths ≤ (cid:100)lg n(cid:101) and L2 containing those greater. Thus nH0(L) ≤ n1H0(L1) + n2H0(L2) + n (from an obvious encoding of L using L1, L2, and a bitmap). max occurrences of symbol (cid:96). This completion cannot decrease n1H0(L1) =(cid:80)(cid:100)lg n(cid:101) Let us call occ((cid:96), L1) the number of occurrences of symbol (cid:96) in L1. Since there are at most 2(cid:96) codewords of length (cid:96), assume we complete L1 with spurious symbols so that it has exactly 2(cid:96) occ((cid:96),L1) , as increasing some occ((cid:96), L1) to occ((cid:96), L1) + 1 produces a difference of f (n1) − f (occ((cid:96), L1)) ≥ 0, where f (x) = (x + 1) lg(x + 1) − x lg x is increasing. Hence we can assume L1 contains exactly 2(cid:96) occurrences of symbol 1 ≤ (cid:96) ≤ (cid:100)lg n(cid:101); straightforward calculation then shows n1H0(L1) = O(n1). On the other hand, L2 contains at most (cid:96)max − (cid:100)lg n(cid:101) distinct values, so H0(L2) ≤ lg((cid:96)max − (cid:100)lg n(cid:101)), unless (cid:96)max = (cid:100)lg n(cid:101), in which case L2 is empty and n2H0(L2) = 0. Thus n2H0(L2) ≤ n2 lg((cid:100)logφ(1/)(cid:101) + 1) = n2 lg lg(1/) +O(n2). Combining both bounds, we get H0(L) ≤ lg lg(1/) + O(1) and the theorem holds. (cid:3) (cid:96)=1 occ((cid:96), L1) lg n1 In other words, under mild assumptions, we can store a code using O(n log log(1/)) bits at the price of increasing the average codeword length by , and in addition have constant-time encoding and decoding. For constant , this means that the code uses just O(n) bits at the price of an arbitrarily small constant additive penalty over the shortest possible prefix code. Figure 2 shows an example. Note that the same reasoning of this proof, applied over the encoding of Theorem 1, yields a refined upper bound. Corollary 1 Let P be the frequency distribution of n symbols for a text of length N . Then, under the RAM model with computer word size w = Ω(log N ), we can store an optimal prefix code for P using n lg lg(N/n) + O(cid:0)n + log2 N(cid:1) bits, while encoding and decoding any symbol in O(1) time. Proof. Proceed as in the proof of Theorem 2, using that (cid:96)max ≤ logφ N and putting inside L1 the lengths up to (cid:100)logφ n(cid:101). Then n1H(L1) = O(n1) and n2H(L2) ≤ lg lg(N/n) + O(n2). (cid:3) 5 Multiplicative Approximation In this section we obtain a multiplicative rather than an additive approximation to the optimal prefix code, in order to achieve a sublinear-sized representation of the code. We will divide the alphabet into frequent and infrequent symbols, and store information about only the frequent ones. Given a constant c > 1, we use Milidi´u and Laber's algorithm [35] to build a prefix code with maximum codeword length (cid:96)max = (cid:100)lg n(cid:101) + (cid:100)1/(c − 1)(cid:101) + 1 (our final codes will have length up to (cid:96)max + 1). We call a symbol's codeword short if it has length at most (cid:96)max/c + 2, and long otherwise. Notice there are S ≤ 2(cid:96)max/c+2 = O(cid:0)n1/c(cid:1) symbols with short codewords. Also, although applying Milidi´u and Laber's algorithm may cause some exceptions, symbols with short codewords 7 (a) (b) (c) Figure 2: An example of Milidi´u and Laber's algorithm [35]. In (a), a canonical Huffman tree. We set lmax = 5 and remove all the symbols below that level (marked with the dotted line), which yields three empty nodes (marked as black circles in the top tree). In (b), those black circles are replaced by the deepest symbols below level lmax: 1, 8, and 10. The other symbols below (cid:96)max, 9, 13, 12 and 5, form a balanced binary tree that is hung from a new node created as the left child of the root (in black in the middle tree). The former left child of the root becomes the left child of this new node. Finally, in (c), we transform the middle tree into its cannonical form, but sorting those symbols belonging to the same level in increasing order. 8 810112591371541432611810711541432611913125101578141461123591213 are usually more frequent than symbols with long ones. We will hereafter call frequent/infrequent symbols those encoded with short/long codewords. Note that, if we build a canonical code, all the short codewords will precede the long ones. We first describe how to handle the frequent symbols. A perfect hash data structure [17] hash will map the frequent symbols in [1, n] to the interval [1, S] in constant time. The reverse mapping is done via a plain array ihash[1, S] that stores the original symbol that corresponds to each mapped symbol. We use this mapping also to reorder the frequent symbols so that the corresponding prefix in array Symb (recall Section 3) reads 1, 2, . . . , S. Thanks to this, we can encode and decode any frequent symbol using just first, sR, predecessor structures on both of them, and the tables hash and ihash. To encode a frequent symbol ai, we find it in hash, obtain the mapped symbol a(cid:48) ∈ [1, S], find the predecessor sR[(cid:96)] of a(cid:48) and then the code is the (cid:96)-bit integer ci = first[(cid:96)] + a(cid:48) − sR[(cid:96)]. To decode a short code ci, we first find its corresponding length (cid:96) using the predecessor structure on first, then obtain its mapped code a(cid:48) = sR[(cid:96)] + ci − first[(cid:96)], and finally the original symbol is i = ihash[a(cid:48)]. Structures hash and ihash require O(cid:0)n1/c log n(cid:1) bits, whereas sR and first, together with their predecessor structures, require less, O(cid:0)log2 n(cid:1) bits. The long codewords will be replaced by new codewords, all of length (cid:96)max + 1. Let clong be the first long codeword and let (cid:96) be its length. Then we form the new codeword c(cid:48) long by appending (cid:96)max + 1 − (cid:96) zeros at the end of clong. The new codewords will be the ((cid:96)max+1)-bit integers long + i − 1 long, c(cid:48) c(cid:48) (frequent symbols ai will leave unused symbols c(cid:48) long + n − 1. An infrequent symbol ai will be mapped to code c(cid:48) long + 1, . . . , c(cid:48) long + i − 1). Figure 3 shows an example. Since c > 1, we have n1/c < n/2 for sufficiently large n, so we can assume without loss of generality that there are fewer than n/2 short codewords,3 and thus there are at least n/2 long codewords. Since every long codeword is replaced by at least two new codewords, the total number long+n−1. of new codewords is at least n. Thus there are sufficient slots to assign codewords c(cid:48) To encode an infrequent symbol ai, we first fail to find it in table hash. Then, we assign it the long + i − 1. To decode a long codeword, we first read (cid:96)max + 1 bits ((cid:96)max+1)-bits long codeword c(cid:48) into ci. If ci ≥ c(cid:48) long, then the codeword is long, and corresponds to the source symbol aci−c(cid:48) long+1. Note that we use no space to store the infrequent symbols. This leads to proving our result. Theorem 3 Let L(P ) be the optimal average codeword length for a distribution P over n symbols. Then, for any constant c > 1, under the RAM model with computer word size w = Ω(log n), we can such that encoding and decoding any symbol takes O(1) time. store a prefix code over P with average codeword length at most cL(P ), using O(cid:0)n1/c log n(cid:1) bits, long to c(cid:48) Proof. Only the claimed average codeword length remains to be proved. By analysis of the algorithm by Milidi´u and Laber [35] we can see that the codeword length of a symbol in their length-restricted code exceeds the codeword length of the same symbol in an optimal code by at most 1, and only when the codeword length in the optimal code is at least (cid:96)max−(cid:100)log n(cid:101)−1 = (cid:100)1/(c−1)(cid:101). Hence, the codeword length of a frequent symbol exceeds the codeword length of the same symbol in an optimal (cid:100)1/(c−1)(cid:101)+1 (cid:100)1/(c−1)(cid:101) ≤ c. Every infrequent symbol is encoded with a codeword of code by a factor of at most length (cid:96)max + 1. Since the codeword length of an infrequent symbol in the length-restricted code is more than (cid:96)max/c + 2, its length in an optimal code is more than (cid:96)max/c + 1. Hence, the codeword length of an infrequent symbol in our code is at most (cid:96)max+1 (cid:96)max/c+1 < c times greater than the codeword 3If this is not the case, then n = O(1), so we can use any optimal encoding: there will be no redundancy over L(P ) and the asymptotic space formula for storing the code will still be valid. 9 (a) (b) (c) Figure 3: An example of the multiplicative approximation, with n = 16 and c = 3. The tree shown in (a) is the result of applying the algorithm of Milidi´u and Laber to a given set of codes. Now, we set (cid:96)max = 6 according to our formula, and declare short those codewords of lengths up to (cid:98)(cid:96)max/c(cid:99) + 2 = 4. Short codewords (above the dashed line on top) are stored unaltered but with all symbols at each level sorted in increasing order (b). Long codewords (below the dashed line) are extended up to length (cid:96)max + 1 = 7 and reassigned a code according to their values in the contiguous slots of length 7 (those in gray in the middle). Thus, given a long codeword x, its code is directly obtained as c(cid:48) long = 11000002 is the first code of length (cid:96)max + 1. In (c), a representation of the hash and inverse hash to code/decode short codewords. We set the hash size to m = 13 and h(x) = (5x + 7) mod m. We store the code associated with each cell. long + x − 1, where c(cid:48) 10 1379164611518103215141261115810122347913141516110000081210151112345678910111206010101010111000100101100hash1261115810iHash000101000sRfirst length of the same symbol in an optimal code. Hence, the average codeword length for our code is (cid:3) less than c times the optimal one. c times the optimum, in O(cid:0)n1/c log n(cid:1) bits and allowing constant-time encoding and decoding. Again, under mild assumptions, this means that we can store a code with average length within 6 Experimental Results We engineer and implement the optimal and approximate code representations described above, obtaining complexities that are close to the theoretical ones. We compare these with the best known alternatives to represent prefix codes we are aware of. Our comparisons will measure the size of the code representation, the encoding and decoding time and, in the case of the approximations, the redundancy on top of H(P ). 6.1 Implementations Our constant-time results build on two data structures. One is the multiary wavelet tree [16, 5]. A practical study [7] shows that multiary wavelet trees can be faster than binary ones, but require significantly more space (even with the better variants they design). To prioritize space, we will use binary wavelet trees, which perform the operations in time O(log (cid:96)max) = O(log log N ). The second constant-time data structure is the fusion tree [18], of which there are no practical implementations as far as we know. Even implementable loglogarithmic predecessor search data structures, like van Emde Boas trees [51], are worse than binary search for small universes like our range [1, (cid:96)max] = [1,O(log N )]. With a simple binary search on first we obtain a total encoding and decoding time of O(log log N ), which is sufficiently good for practical purposes. Even more, preliminary experiments showed that sequential search on first is about as good as binary search in our test collections (this is also the case with classical representations [34]). Although sequential search costs O(log N ) time, the higher success of instruction prefetching makes it much faster than binary search. Thus, our experimental results use sequential search. To achieve space close to nH0(L) in the wavelet tree, we use a Huffman-shaped wavelet tree [43]. The bitmaps of the wavelet tree are represented in plain form and using a space overhead of 37.5% to support rank/select operations [42]. The total space of the wavelet tree is thus close to 1.375 · nH0(L) bits in practice. Besides, we enhance these bitmaps with a small additional index to speed up select operations [45], which increases the constant 1.375 to at least 1.4, or more if we want more speed. An earlier version of our work [44] recasts this wavelet tree into a compressed permutation representation [4] of vector Symb, which leads to a similar implementation. For the additive approximation of Section 4, we use the same implementation as for the exact version, after modifying the code tree as described in that section. The lower number of levels will automatically make sequence L more compressible and the wavelet tree faster. For the multiplicative approximation of Section 5, we implement table hash with double hashing. The hash function is of the form h(x, i) = (h1(x) + (i − 1) · h2(x)) mod m for the ith trial, where h1(x) = x mod m, h2(x) = 1 + (x mod (m − 1)), where m is a prime number. Predecessor searches over sR and first are done via binary search since, as discussed above, theoretically better predecessor data structures are not advantageous on this small domain. 11 Classical Huffman codes. As a baseline to compare with our encoding, we use the representa- tion of Figure 1(a), using n (cid:96)max bits for Codes, n lg n bits for Symb, (cid:96)2 max bits for first, and (cid:96)max lg n bits for sR. For compression, the obvious constant-time solution using Codes is the fastest one. We also implemented the fastest decompression strategies we are aware of, which are more sophisti- cated. The naive approach, dubbed TABLE in our experiments, consists of iteratively probing the next (cid:96) bits from the compressed sequence, where (cid:96) is the next available tree depth. If the relative numeric code resulting from reading (cid:96) bits exceeds the number of nodes at this level, we probe the next level, and so on until finding the right length [47]. Much research has focused on impoving upon this naive approach [38, 36, 12, 49, 26, 34]. For instance, one could use an additional table that takes a prefix of b bits of the compressed sequence and tells which is the minimum code length compatible with that prefix. This speeds up decompression by reducing the number of iterations needed to find a valid code. This technique was proposed by Moffat and Turpin [38] and we call it TABLES in our experiments. Alternatively, one could use a table that stores, for all the b-bit prefixes, the symbols that can be directly decoded from them (if any) and how many bits those symbols use. Note this technique can be combined with TABLES: if no symbol can be decoded, we use TABLES. In our experiments, we call TABLEE the combination of these two techniques. Note that, when measuring compression/decompression times, we will only consider the space needed for compression/decompression (whereas our structure is a single one for both operations). Hu-Tucker codes. As a representative of a suboptimal code that requires little storage space [10], we also implement alphabetic codes, using the Hu-Tucker algorithm [27, 32]. This algorithm takes O(n log n) time and yields the optimal alphabetic code, which guarantees an average code length below H(P ) + 2. As the code is alphabetic, no permutation of symbols needs to be stored; the ith leaf of the code tree corresponds to the ith source symbol. On the other hand, the tree shape is arbitrary. We implement the code tree using succinct tree representations, more precisely the so-called FF [2], which efficiently supports the required navigation operations. This representation requires 2.37 bits per tree node, that is, 4.74n bits for our tree (which has n leaves and n − 1 internal nodes). FF represents general trees, so we convert the binary code tree into a general tree using the well-known mapping [40]: we identify the left child of the code tree with the first child in the general tree, and the right child of the code tree with the next sibling in the general tree. The general tree has an extra root node whose children are the nodes in the rightmost path of the code tree. With this representation, compression of symbol c is carried out by starting from the root and descending towards the cth leaf. We use the number of leaves on the left subtree to decide whether to go left or right. The left/right decisions made in the path correspond to the code. In the general tree, we compute the number of nodes k in the subtree of the first child, and then the number of leaves in the code tree is k/2. For decompression, we start from the root and descend left or right depending on the bits of the code. Each time we go right, we accumulate the number of leaves on the left, so that when we arrive at a leaf the decoded symbol is the final accumulated value plus 1. 6.2 Experimental Setup We used an isolated AMD Phenom(tm) II X4 955 running at 800MHz with 8GB of RAM memory and a ST3250318AS SATA hard disk. The operating system is GNU/Linux, Ubuntu 10.04, with kernel 3.2.0-31-generic. All our implementations use a single thread and are coded in C++. The 12 Collection EsWiki EsInv Indo Length Alphabet Entropy Depth Level entr. (H0(L)) 2.24 2.60 2.51 (H(P )) 11.12 5.88 16.29 1,634,145 1,005,702 3,715,187 ((cid:96)max) 28 28 27 (N ) (n) 200,000,000 300,000,000 120,000,000 Table 1: Main statistics of the texts used. Collection EsWiki EsInv Indo Naive (nw) 6.23 MB 3.83 MB 14.17 MB Engineered Canonical (n lg n) 4.02 MB 2.39 MB 9.67 MB (n (cid:96)max) 5.45 MB 3.35 MB 11.96 MB Ours (nH0(L)) 0.44 MB 0.31 MB 1.11 MB Compressed [50] 0.45 MB 0.33 MB 1.18 MB Table 2: Rough minimum size of various model representations. compiler is gcc version 4.6.3, with -O9 optimization. Time results refer to cpu user time. The stream to be compressed and decompressed is read from and written to disk, using the buffering mechanism of the operating system. We use three datasets4 in our experiments. EsWiki is a sequence of word identifiers ob- tained by stemming the Spanish Wikipedia with the Snowball algorithm. Compressing natural language using word-based models is a strong trend in text databases [37]. EsInv is the con- catenation of differentially encoded inverted lists of a random sample of the Spanish Wikipedia. These have large alphabet sizes but also many repetitions, so they are highly compressible. Fi- nally, Indo is the concatenation of the adjacency lists of Web graph Indochina-2004 available at http://law.di.unimi.it/datasets.php. Compressing adjacency lists to zero-order entropy is a simple and useful tool for graphs with power-law degree distributions, although it is usually com- bined with other techniques [13]. We use a prefix of each of the sequences to speed up experiments. Table 1 gives various statistics on the collections. Apart from N and n, we give the empirical entropy of the sequence (H(P ), in bits per symbol or bps), the maximum length of a Huffman code ((cid:96)max), and the zero-order entropy of the sequence of levels (H0(L), in bps). It can be seen that H0(L) is significantly smaller than lg (cid:96)max, thus our compressed representation of L can indeed be up to an order of magnitude smaller than the worst-case upper bound of n lg (cid:96)max bits. Before we compare the exact sizes of different representations, which depend on the extra data structures used to speed up encoding and decoding, Table 2 gives the size of the basic data that must be stored in each case. The first column shows nw, the size of a naive model representation using computer words of w = 32 bits. The second shows n (cid:96)max, which corresponds to a more engineered representation where we use only the number of bits required to describe a codeword. In these two, more structures are needed for decoding but we ignore them. The third column gives n lg n, which is the main space cost of a canonical Huffman tree representation: basically the permutation of symbols (different ones for encoding and decoding). The fourth column shows nH0(L), which is a lower bound on the size of our model representation (the exact value will depend on the desired encoding/decoding speed). These raw numbers explain why our technique will be 4Made available in http://lbd.udc.es/research/ECRPC 13 much more effective to represent the model than the typical data structures, and that we can expect up to 7 -- 9-fold space reductions (these will decrease to 6 -- 8-fold on the actual structures). Indeed, this entropy space is close to that of a sophisticated model representation [50] that can be used only for transmitting the model in compressed form; this is shown in the last column. 6.3 Representing Optimal Codes Figure 4 compares compression and decompression times, as a function of the space used by the code representations, of our new data structure (COMPR) versus the table based represen- tations described in Section 6.1 (TABLE, TABLES, and TABLEE). We used sampling periods of {16, 32, 64, 128} for the auxiliary data structures added to the wavelet tree bitmaps to speed up select operations [45], and parameter b = 14 for table based approaches (this gave us the best time performance). It can be seen that our compressed representations takes just around 12% of the space of the table implementation for compression (an 8-fold reduction), while being 2.5 -- 8 times slower. Note that compression is performed by carrying out rank operations on the wavelet tree bitmaps. Therefore, we do not consider the space overhead incurred to speed up select operations, and we only plot a single point for technique COMPR at compression charts. Also, we only show the simple (and most compact) TABLE variant, as the improvements of the others apply only to decompression. For decompression, our solution (COMPR) takes 17% to 45% of the space of the TABLE∗ variants (thus reaching almost a 6-fold space reduction), but it is also 12 -- 24 times slower. This is because our solution uses operation select for decompression, and this is slower than rank even with the structures for speeding it up. Overall, our compact representation is able to compress at a rate around 2.5 -- 5 MB/sec and decompress at 1 MB/sec, while using much less space than a classical Huffman implementation (which compresses/decompresses at around 14 -- 25 MB/sec). Finally, note that we only need a single data structure to both compress and decompress, while the naive approach uses different tables for each operation. In the cases where both functionalities are simultaneously necessary (as in compressed sequence representations [43]), our structure uses as little as 7% of the space needed by a classical representation. 6.4 Length-Limited Codes In the theoretical description, we refer to an optimal technique for limiting the length of the code trees to a given value (cid:96)max ≥ (cid:100)lg n(cid:101) [33], as well as several heuristics and approximations: • Milidi´u: the approximate technique proposed by Milidi´u and Laber [35] that nevertheless guarantees the upper bound we have used in the paper. It takes O(n) time. • Increase: inspired in the bounds of Katona and Nemetz [31], we start with f = 2 and set to f the frequency of each symbol whose frequency is < f . Then we build the Huffman tree, and if its height is ≤ (cid:96)max, we are done. Otherwise, we increase f by 1 and repeat the process. Since the Huffman construction algorithm is linear-time once the symbols are sorted by frequency O(n log n) time if we use exponential search to find the correct f value. A close predecessor of this method appears in Chapter 9 of Managing Gigabytes [52]. They use a multiplicative and the process does not need to reorder them, this method takes O(cid:0)n log(nφ−(cid:96)max)(cid:1) = 14 Figure 4: Code representation size versus compression/decompression time for table based repre- sentations (TABLE, TABLES, and TABLEE) and ours (COMPR). Time (in logscale) is measured in nanoseconds per symbol. 15 10 100 1000 0 5 10 15 20 25 30ηs/symbolSpace (bits/alphabet symbol)Collection EsWikiCompression 10 100 1000 0 5 10 15 20 25 30ηs/symbolSpace (bits/alphabet symbol)Collection EsWikiDecompressionCOMPRTABLETABLESTABLEE 10 100 1000 0 5 10 15 20 25 30ηs/symbolSpace (bits/alphabet symbol)Collection EsInvCompression 10 100 1000 0 5 10 15 20 25 30ηs/symbolSpace (bits/alphabet symbol)Collection EsInvDecompression 10 100 1000 0 5 10 15 20 25 30ηs/symbolSpace (bits/alphabet symbol)Collection IndoCompression 10 100 1000 0 5 10 15 20 25 30ηs/symbolSpace (bits/alphabet symbol)Collection IndoDecompression instead of an additive approximation, so as to find an appropriate f faster. Thus they may find a value of f that is larger than the optimal. • Increase-A: analogous to Increase, but instead adds f to the frequency of each symbol. • Balance: the technique (e.g., see [3]), that balances the parents of the maximal subtrees that, even if balanced, exceed the maximum allowed height. It also takes O(n) time. In the case of a canonical Huffman tree, this is even simpler, since only one node along the rightmost path of the tree needs to be balanced. • Optimal: the package-merge algorithm of Larmore and Hirshberg [33]. Its time complexity is O(n (cid:96)max). Figure 5 compares the techniques for all the meaningful (cid:96)max values, showing the additive re- dundancy they produce over H(P ). It can be seen that the average code lengths obtained by Milidi´u, although they have theoretical guarantees, are not so good in practice. They are com- parable with those of Balance, a simpler and still linear-time heuristic, which however does not provide any guarantee and sometimes can only return a completely balanced tree. On the other hand, technique Increase performs better than or equal to Increase-A, and actually matches the average code length of Optimal systematically in the three collections. Techniques Milidi´u, Balance, and Optimal are all equally fast in practice, taking about 2 sec- onds to find their length-restricted code in our collections. The time for Increase and Increase-A depends on the value of (cid:96)max. For large values of (cid:96)max, they also take around 2 seconds, but this raises up to 20 seconds when (cid:96)max is closer to (cid:100)lg n(cid:101) (and thus the value f to add is larger, up to 100 -- 300 in our sequences). In practice, technique Increase can be recommended for its extreme simplicity to implement and very good approximation results. If the construction time is an issue, then Optimal should be used. It performs fast in practice and it is not so hard to implement5. For the following experiments, we will use the results of Optimal/Increase. As a final note, observe that by restricting the code length to, say, (cid:96)max = 22 on EsWiki and EsInv and (cid:96)max = 23 on Indo, the additive redundancy obtained is below  = 0.6, and the redundancy is below 5% of H(P ). 6.5 Approximations Now we evaluate the additive and multiplicative approximations, in terms of average code length L, compression and decompression performance. We compare them with two optimal model rep- resentations, OPT-T and OPT-C, which correspond to TABLE and COMPR of Section 6.3. The additive approximations (Section 4) included, ADD+T and ADD+C, are obtained by restricting the maximum code lengths to (cid:96)max and storing the resulting codes using TABLE or COMPR, re- spectively. We show one point per (cid:96)max = 22 . . . 27 on EsWiki and EsInv, and (cid:96)max = 22 . . . 26 on Indo. For the multiplicative approximation (Section 5), we test the variants MULT-(cid:96)max, which limit (cid:96)max to 25 and 26, and use c values 1.5, 1.75, 2, and 3. For all the solutions that use a wavelet tree, we have fixed a select sampling rate to 32. of the code, measured as L(P )/H(P ). Figure 6 shows the results in terms of bps for storing the model versus the resulting redundancy 5There are even some public implementations, for example https://gist.github.com/imaya/3985581 16 Figure 5: Comparison of the length-restricted approaches measured as their additive redundancy (in logscale) over the zero-order empirical entropy, H(P ), for each value of (cid:96)max. We also include Hu-Tucker and Huffman as reference points. 17 0.01 0.1 1 102122232425262728293031L(P)-H(P)lmaxCollection EsWiki 0.01 0.1 1 10 22 23 24 25 26 27 28 29 30L(P)-H(P)lmaxCollection EsInv 0.01 0.1 1 10 22 23 24 25 26 27 28 29 30L(P)-H(P)lmaxCollection IndoMilidiúBalanceIncreaseIncrease-AOptimalHu-TuckerHuffman Figure 6: Relation between the size of the model and the average code length. The x-axes are in logscale for values smaller than 1 and in two linear scales for 1 -- 5 and 5 -- 35. The horizontal line shows the limit (cid:100)lg n(cid:101)/H(P ), where no compression is obtained compared with a fixed-length code. 18 11.11.53.001 .01 .1 1L(P)/H(P) 12345Model size (bps)Collection EsWiki5101520253035 11.11.53.001 .01 .1 1L(P)/H(P) 12345Model size (bps)Collection EsInv5101520253035 11.11.53.001 .01 .1 1L(P)/H(P) 12345Model size (bps)Collection indo5101520253035 OPT-TOPT-CADD+CADD+TMULT-26MULT-25 The additive approximations have a mild impact when implemented in classical form. However, the compact representation, ADD+C, reaches half the space of our exact compact representation, OPT-C. This is obtained at the price of a modest redundancy, below 5% in all cases, if one uses reasonable values for (cid:96)max. With the larger c values, the multiplicative approach is extremely efficient for storing the model, reaching reductions up to 2 and 3 orders of magnitude with respect to the classic representations. However, this comes at the price of a redundancy that can reach 50%. The redundancy may go beyond (cid:100)lg n(cid:101)/H(P ), at which point it is better to use a plain code of (cid:100)lg n(cid:101) bits. Instead, with value c = 1.75, the model size is still 20 times smaller than a classical representation, and 2 -- 3 times smaller than the most compact representation of additive approximations, with a redundancy only slightly over 10%. Figure 7 compares these representations in terms of compression and decompression perfor- mance. The numbers near each point show the redundancy (as a percentage over the entropy) of the model representing that point. We use ADD+C with values (cid:96)max = 22 on EsWiki and EsInv and (cid:96)max = 23 on Indo. For ADD+T, the decompression times are the same for all the tested (cid:96)max values. In this figure we set the select samplings of the wavelet trees to (32, 64, 128). We also include in the comparison the variant MULT-26 with c = 1.75 and 1.5. It can be seen that the multiplicative approach is very fast, comparable to the table-based approaches ADD+T and OPT-T: 10% -- 50% slower at compression and at most 20% slower at decompression. Within this speed, if we use c = 1.75, the representation is 6 -- 11 times smaller than the classical one for compression and 5 -- 9 times for decompression, at the price of about 10% of redundancy. If we choose c = 1.5, the redundancy increases to about 20% but the model becomes an order of magnitude smaller. The compressed additive approach (ADD+C) achieves a smaller model than the multiplicative one with c = 1.75 (it is 14 times smaller than the classical representation for compression and 11 times for decompression). This is achieved with significantly less redundancy than the multiplicative model, just 3% -- 5%. However, although ADD+C is about 20% -- 30% faster than the exact code OPT-C, it is still significantly slower than the table-based representations (2 -- 5.5 times slower for compression and 9 -- 17 for decompression). Finally, we can see that our compact implementation of Hu-Tucker codes achieves competitive space, but it is an order of magnitude slower than our additive approximations, which can always use simultaneously less space and time. With respect to the redundancy, Figure 5 shows that Hu-Tucker codes are equivalent to our additive approximations with (cid:96)max = 23 on EsWiki, (cid:96)max = 22 on EsInv, and (cid:96)max = 24 on Indo. This shows that the use of alphabetic codes as a suboptimal code to reduce the model representation size is inferior, in all aspects, to our additive approximations. Figure 7 shows that Hu-Tucker is also inferior, in the three aspects, to our compact optimal codes, OPT-C. We remark that alphabetic codes are interesting by themselves for other reasons, in contexts where preserving the order of the source symbols is important. 7 Conclusions We have explored the problem of providing compact representations of Huffman models. The model size is relevant in several applications, particularly because it must reside in main memory for efficient compression and decompression. We have proposed new representations achieving constant compression and decompression time 19 Figure 7: Space/time performance of the approximate and exact approaches. Times are in nanosec- onds per symbol and in logscale. The numbers around the points are their redundancy as a per- centage of the entropy. 20 10 100 1000 10000 0 5 10 15 20 25 30ηs/symbolModel size (bps)Collection EsWikiCompression0.30.350.5121372 10 100 1000 10000 0 5 10 15 20 25ηs/symbolModel size (bps)Collection EsWikiDecompression0.30.350.51372 10 100 1000 10000 0 5 10 15 20 25 30ηs/symbolModel size (bps)Collection EsInvCompression0.30.330.511.517123 10 100 1000 10000 0 5 10 15 20 25ηs/symbolModel size (bps)Collection EsInvDecompression0.30.330.517123 10 100 1000 10000 0 5 10 15 20 25 30ηs/symbolModel size (bps)Collection IndoCompression0.10.130.5131581 10 100 1000 10000 0 5 10 15 20 25ηs/symbolModel size (bps)Collection IndoDecompression0.10.130.51581OPT-TOPT-CADD+C+22ADD+C+23ADD+T+23,24,25MULT-26 Hu-Tucker per symbol while using O(n log log(N/n)) bits per symbol, where n is the alphabet size and N the sequence length. This is in contrast to the (at least) O(n log n) bits used by previous representations. In our practical implementation, the time complexities are O(log log N ) and even O(log N ), but we do achieve 8-fold space reductions for compression and up to 6-fold for decompression. This comes, however, at the price of increased compression and decompression time (2.5 -- 8 times slower at compression and 12 -- 24 at decompression), compared to current representations. In low-memory scenarios, the space reduction can make the difference between fitting the model in main memory or not, and thus the increased times are the price to pay. We also showed that, by tolerating a small additive overhead of  on the average code length, the model can be stored in O(n log log(1/)) bits, while maintaining constant compression and decompression time. In practice, these additive approximations can halve our compressed model size (becoming 11 -- 14 times smaller than a classical representation), while incurring a very small increase (5%) in the average code length. They are also faster, but still 2 -- 5.5 times slower for compression and 5 -- 9 for decompression. Finally, we showed that a multiplicative penalty in the average code length allows storing the model in o(n) bits. In practice, the reduction in model size is sharp, while the compression and decompression times are only 10% -- 50% and 0% -- 20% slower, respectively, than classical implemen- tations. Redundancies are higher, however. With 10% of redundancy, the model size is close to that of the additive approach, and with 20% the size decreases by another order of magnitude. Some challenges for future work are: • Adapt these representations to dynamic scenarios, where the model undergoes changes as compression/decompression progresses. While our compact representations can be adapted to support updates, the main problem is how to efficiently maintain a dynamic canonical Huffman code. We are not aware of such a technique. • Find more efficient representations of alphabetic codes. Our baseline achieves reasonably good space, but the navigation on the compact tree representations slows it down considerably. It is possible that faster representations supporting left/right child and subtree size can be found. • Find constant-time encoding and decoding methods that are fast and compact in practice. Multiary wavelet trees [7] are faster than binary wavelet trees, but generally use much more space. Giving them the shape of a (multiary) Huffman tree and using plain representations for the sequences in the nodes could reduce the space gap with our binary Huffman-shaped wavelet trees used to represent L. As for the fusion trees, looking for a practical implemen- tation of trees with arity w, which outperforms a plain binary search, is interesting not only for this problem, but in general for predecessor searches on small universes. Acknowledgements. We thank the reviewers, whose comments helped improve the paper sig- nificantly. References [1] M. Adler and B. M. Maggs. Protocols for asymmetric communication channels. Journal of Computer and System Sciences, 63(4):573 -- 596, 2001. 21 [2] D. Arroyuelo, R. C´anovas, G. Navarro, and K. Sadakane. Succinct trees in practice. In Proc. 11th Workshop on Algorithm Engineering and Experiments (ALENEX), pages 84 -- 97, 2010. [3] J. Barbay and G. Navarro. Compressed representations of permutations, and applications. In Proc. 26th International Symposium on Theoretical Aspects of Computer Science (STACS), pages 111 -- 122, 2009. [4] J. Barbay and G. Navarro. On compressing permutations and adaptive sorting. Theoretical Computer Science, 513:109 -- 123, 2013. [5] D. Belazzougui and G. Navarro. New lower and upper bounds for representing sequences. In Proc. 20th Annual European Symposium on Algorithms (ESA), LNCS 7501, pages 181 -- 192, 2012. [6] J. L. Bentley, D. D. Sleator, R. E. Tarjan, and V. K. Wei. A locally adaptive data compression scheme. Communications of the ACM, 29(4), 1986. [7] A. Bowe. Multiary Wavelet Trees in Practice. Honours thesis, RMIT University, Australia, 2010. [8] N. Brisaboa, A. Farina, S. Ladra, and G. Navarro. Implicit indexing of natural language text by reorganizing bytecodes. Information Retrieval, 15(6):527 -- 557, 2012. [9] N. Brisaboa, A. Farina, G. Navarro, and J. Param´a. Lightweight natural language text com- pression. Information Retrieval, 10:1 -- 33, 2007. [10] N. Brisaboa, G. Navarro, and A. Ord´onez. Smaller self-indexes for natural language. In Proc. 19th International Symposium on String Processing and Information Retrieval (SPIRE), LNCS 7608, pages 372 -- 378, 2012. [11] M. Buro. On the maximum length of Huffman codes. Information Processing Letters, 45(5):219 -- 223, 1993. [12] Y. Choueka, S. T. Klein, and Y. Perl. Efficient variants of Huffman codes in high level languages. In Proc. 8th Annual International ACM Conference on Research and development in Information Retrieval (SIGIR), pages 122 -- 130. ACM, 1985. [13] F. Claude and G. Navarro. Fast and compact Web graph representations. ACM Transactions on the Web, 4(4):article 16, 2010. [14] P. Davoodi, R. Raman, and S. Rao Satti. Succinct representations of binary trees for range minimum queries. In Proc. 18th Annual International Conference on Computing and Combi- natorics (COCOON), LNCS 7434, pages 396 -- 407, 2012. [15] P. Ferragina, R. Giancarlo, G. Manzini, and M. Sciortino. Boosting textual compression in optimal linear time. Journal of the ACM, 52(4):688 -- 713, 2005. [16] P. Ferragina, G. Manzini, V. Makinen, and G. Navarro. Compressed representations of se- quences and full-text indexes. ACM Transactions on Algorithms, 3(2):article 20, 2007. 22 [17] M. L. Fredman, J. Koml´os, and E. Szemer´edi. Storing a sparse table with O(1) worst case access time. Journal of the ACM, 31(3):538 -- 544, 1984. [18] M. L. Fredman and D. E. Willard. Surpassing the information theoretic bound with fusion trees. Journal of Computer and System Sciences, 47(3):424 -- 436, 1993. [19] T. Gagie. Compressing probability distributions. Information Processing Letters, 97(4):133 -- 137, 2006. [20] T. Gagie. Large alphabets and incompressibility. Information Processing Letters, 99(6):246 -- 251, 2006. [21] T. Gagie. Dynamic asymmetric communication. Information Processing Letters, 108(6):352 -- 355, 2008. [22] T. Gagie, G. Navarro, and Y. Nekrich. Fast and compact prefix codes. In Proc. 36th Interna- tional Conference on Current Trends in Theory and Practice of Computer Science (SOFSEM), LNCS 5901, pages 419 -- 427, 2010. [23] T. Gagie and Y. Nekrich. Worst-case optimal adaptive prefix coding. In Proc. 9th Symposium on Algorithms and Data Structures (WADS), pages 315 -- 326, 2009. [24] E. N. Gilbert and E. F. Moore. Variable-length binary encodings. Bell System Technical Journal, 38:933 -- 967, 1959. [25] R. Grossi, A. Gupta, and J. Vitter. High-order entropy-compressed text indexes. In Proc. 14th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 841 -- 850, 2003. [26] R. Hashemian. Memory efficient and high-speed search Huffman coding. Communications, IEEE Transactions on, 43(10):2576 -- 2581, 1995. [27] T. C. Hu and A. C. Tucker. Optimal computer search trees and variable-length alphabetical codes. SIAM Journal of Applied Mathematics, 21(4):514 -- 532, 1971. [28] D. Huffman. A method for the construction of minimum-redundancy codes. Proceedings of the I.R.E., 40(9):1090 -- 1101, 1952. [29] J. Karkkainen and S. J. Puglisi. Fixed block compression boosting in FM-indexes. In Proc. 18th International Symposium on String Processing and Information Retrieval (SPIRE), pages 174 -- 184, 2011. [30] M. Karpinski and Y. Nekrich. A fast algorithm for adaptive prefix coding. Algorithmica, 55(1):29 -- 41, 2009. [31] G. O. H. Katona and T. O. H. Nemetz. Huffman codes and self-information. IEEE Transactions on Information Theory, 22(3):337 -- 340, 1976. [32] D. E. Knuth. The Art of Computer Programming. Vol. 3: Sorting and Searching. Addison- Wesley, 1973. [33] L. L. Larmore and D. S. Hirschberg. A fast algorithm for optimal length-limited Huffman codes. Journal of the ACM, 37(3):464 -- 473, 1990. 23 [34] M. Liddell and A. Moffat. Decoding prefix codes. Software: Practice and Experience, 36(15):1687 -- 1710, 2006. [35] R. L. Milidi´u and E. S. Laber. Bounding the inefficiency of length-restricted prefix codes. Algorithmica, 31(4):513 -- 529, 2001. [36] R. L. Milidi´u, E. S. Laber, L. O. Moreno, and J. C Duarte. A fast decoding method for prefix codes. In Proc. 13th Data Compression Conference (DCC), page 438, 2003. [37] A. Moffat. Word-based text compression. Software Practice and Experience, 19(2):185 -- 198, 1989. [38] A. Moffat and A. Turpin. On the implementation of minimum-redundancy prefix codes. IEEE Transactions on Communications, 45(10):1200 -- 1207, 1997. [39] E. Moura, G. Navarro, N. Ziviani, and R. Baeza-Yates. Fast and flexible word searching on compressed text. ACM Transactions on Information Systems, 18(2):113 -- 139, 2000. [40] J. I. Munro and V. Raman. Succinct representation of balanced parentheses and static trees. SIAM Journal on Computing, 31(3):762 -- 776, 2001. [41] N. Nakatsu. Bounds on the redundancy of binary alphabetical codes. IEEE Transactions on Information Theory, 37(4):1225 -- 1229, 1991. [42] G. Navarro. Implementing the LZ-index: Theory versus practice. ACM Journal of Experi- mental Algorithmics (JEA), 13:article 2, 2009. [43] G. Navarro. Wavelet trees for all. Journal of Discrete Algorithms, 25:2 -- 20, 2014. [44] G. Navarro and A. Ord´onez. Compressing Huffman models on large alphabets. In Proc. 23rd Data Compression Conference (DCC), pages 381 -- 390, 2013. [45] G. Navarro and E. Providel. Fast, small, simple rank/select on bitmaps. In Proc. 11th Inter- national Symposium on Experimental Algorithms (SEA), LNCS 7276, pages 295 -- 306, 2012. [46] M. Patrascu and M. Thorup. Time-space trade-offs for predecessor search. CoRR, cs/0603043v1, 2008. http://arxiv.org/pdf/cs/0603043v1. [47] E. S. Schwarz and B. Kallick. Generating a canonical prefix encoding. Communications of the ACM, 7(3):166 -- 169, 1964. [48] D. Sheinwald. On binary alphabetic codes. In Proc. 2nd Data Compression Conference (DCC), pages 112 -- 121, 1992. [49] A. Siemi´nski. Fast decoding of the Huffman codes. Information Processing Letters, 26(5):237 -- 241, 1988. [50] A. Turpin and A. Moffat. Housekeeping for prefix coding. IEEE Transactions on Communi- cations, 48(4):622 -- 628, 2000. [51] P. van Emde Boas, R. Kaas, and E. Zijlstra. Design and implementation of an efficient priority queue. Mathematical Systems Theory, 10:99 -- 127, 1977. 24 [52] I. H. Witten, A. Moffat, and T. C. Bell. Managing Gigabytes: Compressing and Indexing Documents and Images. Morgan Kaufmann, 2nd edition, 1999. 25
1210.0461
2
1210
2012-11-19T15:28:54
On Parallelizing Matrix Multiplication by the Column-Row Method
[ "cs.DS" ]
We consider the problem of sparse matrix multiplication by the column row method in a distributed setting where the matrix product is not necessarily sparse. We present a surprisingly simple method for "consistent" parallel processing of sparse outer products (column-row vector products) over several processors, in a communication-avoiding setting where each processor has a copy of the input. The method is consistent in the sense that a given output entry is always assigned to the same processor independently of the specific structure of the outer product. We show guarantees on the work done by each processor, and achieve linear speedup down to the point where the cost is dominated by reading the input. Our method gives a way of distributing (or parallelizing) matrix product computations in settings where the main bottlenecks are storing the result matrix, and inter-processor communication. Motivated by observations on real data that often the absolute values of the entries in the product adhere to a power law, we combine our approach with frequent items mining algorithms and show how to obtain a tight approximation of the weight of the heaviest entries in the product matrix. As a case study we present the application of our approach to frequent pair mining in transactional data streams, a problem that can be phrased in terms of sparse ${0,1}$-integer matrix multiplication by the column-row method. Experimental evaluation of the proposed method on real-life data supports the theoretical findings.
cs.DS
cs
On Parallelizing Matrix Multiplication by the Column-Row Method∗ Andrea Campagna† Konstantin Kutzkov‡ Rasmus Pagh§ Abstract We consider the problem of sparse matrix multiplication by the column row method in a distributed setting where the matrix product is not necessarily sparse. We present a sur- prisingly simple method for “consistent” parallel process- ing of sparse outer products (column-row vector products) over several processors, in a communication-avoiding setting where each processor has a copy of the input. The method is consistent in the sense that a given output entry is al- ways assigned to the same processor independently of the specific structure of the outer product. We show guaran- tees on the work done by each processor, and achieve linear speedup down to the point where the cost is dominated by reading the input. Our method gives a way of distributing (or parallelizing) matrix product computations in settings where the main bottlenecks are storing the result matrix, and inter-processor communication. Motivated by observa- tions on real data that often the absolute values of the entries in the product adhere to a power law, we combine our ap- proach with frequent items mining algorithms and show how to obtain a tight approximation of the weight of the heaviest entries in the product matrix. As a case study we present the application of our approach to frequent pair mining in transactional data streams, a prob- lem that can be phrased in terms of sparse {0, 1}-integer matrix multiplication by the column-row method. Experi- mental evaluation of the proposed method on real-life data supports the theoretical findings. Introduction 1 Column row vector products (aka. outer products) are ubiquitous in scientific computing. Often one needs to compute an aggregate function over several products. Most notably, the product of two matrices can be writ- ten as a sum of outer products. Observe that a prod- uct of two sparse matrices can be dense in the worst case, and will typically be much less sparse than the in- put matrices. This is a practical problem in algorithms that multiply very high-dimensional, sparse matrices, under the Sapere Aude program. ∗Work supported by the Danish National Research Council †[email protected], IT University of Copenhagen, Denmark. ‡[email protected], IT University of Copenhagen, Denmark. §[email protected], IT University of Copenhagen, Denmark. such as the Markov Cluster Algorithm [21] popular in bio-informatics. There are approaches to approximat- ing matrix products that can use less space [9, 19] but they do not address how to balance the work in a par- allel or distributed setting. State-of-the-art clusters for bio-informatics can easily have a combined main mem- ory capacity of 1 TB or more. Thus there is potential for computing huge result matrices if computation and storage can be used efficiently. Based on the observation that handling the output data, rather than the input data, can be the main bot- tleneck we present a method for parallelizing the com- putation of sparse outer products in a setting where the input is assumed to be broadcast. No other communica- tion is allowed — that is, algorithms need to be com- munication avoiding. To our best knowledge there is no previous work on (sparse) matrix multiplication in such a setting. The standard approach is to assume that this input is distributed among processors, which then com- municate as needed. As noted by Demmel et al. [11] communication is often a bottleneck in parallel sparse matrix computations. We believe that in some settings (such as an ethernet-connected cluster) where broad- cast is cheap, but the total capacity for point-to-point communication is a bottleneck, an approach that trades broadcasting the input for reduced inter-processor com- munication can improve performance, assuming that the total work remains the same and that the computation is load-balanced well. Because there can be no communication after the broadcast of the input we do not need to consider a par- ticular parallel or distributed memory model. However, for concreteness we will from now on speak of paral- lelization across multiple processors. For practical rea- sons we also restrict our experiments to the setting of a multi-core architecture. Our algorithm avoids commu- nication by distributing the matrix output entries in a consistent way, i.e., each processor will process either all nonzero terms contributing to a given output entry, or none of them. As a case study we consider 0-1 ma- trix products arising in data mining applications, where the task is to approximate the largest entries in the re- sult matrix well. This is done by combining our method for parallelizing outer products with known heavy hitter algorithms. Our algorithm works in a data stream setting, where the vectors are given one at a time, and space for sav- ing past vectors is not available. In contrast, traditional work on parallel matrix multiplication requires that the whole input can be stored in the memory of the sys- tem. However, our main point is not the space saved on not storing the input, but rather that the (possi- bly non-dense) output is distributed evenly among the processors. We believe that there are many interest- ing opportunities ahead in parallel processing of data streams, especially for computations that require more than (quasi-) linear time in the input size. 2 Background Parallel matrix multiplication. A major algo- rithmic problem that can be approached using our method is sparse matrix multiplication. The product of matrices A, B ∈ Rn×n can be computed by summing over n outer products of columns of A and rows of B. Assuming all outer products are dense a simple algo- rithm distributes the computation among several pro- cessors such that the work load is equal and there is no need for communication between the processors or shared data structures: each one of p processors will sum p × n√ over a submatrix of the outer products of size n√ p , and only the column and row vectors have to be read by each processor. This approach, first described by Can- non [7], is known to achieve very good scalability with a growing number of processors. However, for the situation where the outer products are expected to be sparse, this simple algorithm is not guaranteed to achieve good scalability. The reason is that we do not know in advance the specific structure of the output matrix and it might happen that certain p × n√ n√ p -submatrices are dense while many others are sparse, which implies that the workload is not balanced among processors. An approach to avoid this problem is to initially permute the rows (resp. columns) of the left (resp. right) input matrix. This corresponds to permuting both rows and columns of the output matrix. However, this approach is vulnerable to the situation in which the nonzero output entries are not well distributed among rows or columns. For example, if half of the work in computing the output relates to a single output row or column, this work will only be distributed among p out of p processors. √ Also, it is often the case that we don’t know in advance the exact dimensions of the sparse matrices as they are generated in a streaming fashion. Matrix multiplication in the streaming setting has recently received some attention [12, 19, 20]. Randomized algorithms have been designed approximating the values of individual entries in the matrix product running in subcubic time and subquadratic space in one or two passes over the input matrices and requiring access only to certain columns and rows. We refer to [4] for an overview on state-of-the-art results on parallel matrix multiplication relying on inter- processor communication. 3 Overview of contributions. Parallel sparse matrix multiplication. Hash- ing has long been used for load balancing tasks, mapping a given task x to a random bucket h(x). A good hash function will distribute the tasks almost evenly among the buckets, such that different processors will handle given buckets and get a similar load. When comput- ing a matrix product we can think of each entry of the output matrix as a task. However, if we decide to sim- ply hash all entries in a product (in parallel), a lot of inter-processor communication will be needed to iden- tify the entries in each bucket that are nonzero in a given outer product. Our approach turns this around, and uses a carefully chosen hash function that allows a processor to efficiently identify the output entries hash- ing to a given bucket. In particular each processor can, without communication or shared data structures, pro- cess exactly the terms that belong to its bucket, with an additional overhead that is linear in the size of the in- put vectors. We show that our approach is particularly well suited for matrix multiplication by the column-row method when individual outer products are sparse but not the resulting matrix product. Approximate matrix multiplication. As al- ready mentioned, randomized algorithms running in subcubic time, using a small amount of memory and performing only a limited number of scans of the input matrix are gaining more and more popularity [12, 19, 20]. Instead of computing exactly the matrix product, the algorithms return an approximation of individual entries. For matrix products where the entries adhere to a skewed distribution, the approximation of the heaviest entries is known to be of very high quality. The reader is referred to [19] for a more detailed discussion and a list of applications of approximate matrix multiplication. Inspired by the above and observations on real data, we compose our parallel matrix multiplication method with two known algorithms for finding frequent items in data streams: Space-Saving [18] and Count- Sketch [8]. The former gives deterministic upper and lower bounds on the true value and the latter – an unbiased estimator. Both algorithms are capable of handling weighted updates but Space-Saving is restricted only to positive updates. More concretely, our main contributions can be summa- rized as follows: • A new algorithm for the parallelization of the multiplication of sparse matrices by the column row method. • The combination of the above with approximate matrix multiplication. • We theoretically analyze the expected time com- plexity, the load balancing among cores and the ap- proximation guarantee of our algorithm under the assumption of Zipfian distribution of the entries’ weights (a common situation in many real-life ap- In particular, while Count-Sketch plications). was always based on an initial hashing/splitting step, we believe that this work is the first to in- vestigate the composition of hashing and Space- Saving for approximate matrix multiplication. • Extensive experimental evaluation of our approach in the context of frequent pair mining in transac- tional data streams. 4 Preliminaries Notation For vectors u, v ∈ Rn the outer product of u and v is denoted as uv ∈ Rn×n. For matrices A, B ∈ Rn×n we denote by ai the ith column of A and by bj the jth row of B for i, j ∈ [n] where [n] := {0, . . . , n − 1}. The ith element in a vector u is written as u(i). The weight of the entry (i, j) in the product AB is the inner product of the ith row of A and jth column of B, for i, j ∈ [n]. Alternatively, in the column-row notation it can be also written as k=0 ak(i)bk(j), i.e., the sum over the (i, j)th entry in all outer products. When clear from the context we refer to entries with larger absolute weight as heavy entries. The number of non-zero entries in u ∈ Rn is written as u. (cid:80)n−1 A family H of functions from E to [k] is k-wise independent if for a function h : E → [k] chosen uniformly at random from H it holds Pr[h(e1) = c1 ∧ h(e2) = c2 ∧ ··· ∧ h(et) = ct] = k−t for distinct elements ei ∈ E, 1 ≤ i ≤ t, and ci ∈ [k]. We will refer to a function chosen uniformly at random from a k-wise independent family H as a k-wise independent function. The elements in E adhere to Zipfian distribution with parameters C and z if wi = C/iz for the absolute weight wi of the ith most heavy element in E. Frequent items mining algorithms. We will use two well-known frequent item mining algorithms Count-Sketch [8] and Space-Saving [18] as subrou- tines. We give a brief overview of how they work. In Count-Sketch every item i is hashed by a hash function h : [n] → [k] to a position in an array CS consisting of k estimators, each of them being a real number. Upon updating the weight of an item i, we add 1 or −1 to the corresponding estimator by using a uniform sign hash function s(i) evaluating i to either 1 or −1. After processing the stream the frequency of a given item i can be estimated as CS[h(i)]· s(i). The intuition is that for a heavy item the contribution from other items will cancel out and will not significantly affect the estimate. Both h and s are pairwise independent and this is sufficient to show that for an appropriate number of estimators and a skewed distribution of item weights the heavy items will be assigned to only one estimator with high probability. The probability for correct estimates can be amplified by working with t > 1 hash functions and returning the median of the t estimates upon a query for the frequency of a given item. The Space-Saving algorithm offers upper and lower frequency bounds, rather than an unbiased esti- mator. It keeps a summary of the stream consisting of (cid:96) triples (itemj, countj, overestimationj), 1 ≤ j ≤ (cid:96). The (cid:96) triples are sorted according to their count value. Upon the arrival of a new item i the algorithm distinguishes between the following cases: • If not all (cid:96) slots are already full, we insert a new triple as (i, 1, 0). • If i is already recorded, we increase the correspond- ing counter by 1 and update the order in the sum- mary. • Otherwise, we replace the last (item(cid:96), count(cid:96), overestimation(cid:96)) triple (i, count(cid:96) + 1, count(cid:96)). with a triple new After processing the stream we return as an estimate for an item weight either its counter in the summary or, if not recorded, the overestimation in the last counter in the list. For a stream of length m, the overestimation in a given counter is bounded by m/(cid:96) and it is guaranteed that an item occurring more than m/(cid:96) times will be in the summary. This comes from the fact that each increase in the overestimation of an item not recorded in the summary is witnessed by (cid:96) different items in the summary and this cannot happen more than m/(cid:96) times. However, the algorithm is known to perform extremely well in practice and report almost the exact weights for the heaviest entries, see e.g. [10]. A natural generalization of both algorithms works with weighted positive updates. This is straightforward for Count-Sketch, and for Space-Saving the only issue to consider is how to efficiently update the sum- mary. A solution achieving amortized constant time per update is presented in [5]. 5 Our approach The algorithm. Assume we are given matrices A, B ∈ Rn×n such that A is stored as column-major ordered triples and B as row-major ordered triples. (For an overview of efficient implementations of the model we refer to Chapter 2 of [4].) The skeleton of our algorithm is the following: • Define s Count-Sketch estimators (or alterna- tively Space-Saving summaries with (cid:96) triples, for a small constant (cid:96)). • For the kth column and row vectors ak ∈ A, bk ∈ B, k ∈ [n], hash each entry in ab to one of the estimators. • After all outer products have been processed return an estimate for all entries. In the parallel version, each processor keeps track of a subset of the estimators, and the total space remains fixed. Thus, we are in a shared nothing model with no need for a shared memory – the only requirement is that each processor sees the column and row vectors for each outer product. Pseudocode of the algorithm is given in Figure 1. We refer to it as the CRoP algorithm, which refers to the fact that each processor crops the output matrix to produce a small fraction of it, and is also an acronym for “Column-Row Parallel”. A crucial property in our analysis and experimental evaluations is that the heaviest entries do not often collide, and thus we obtain high quality estimates on their weight. We combine two different ways for estimating the weight of the heaviest entries based on the Count-Sketch and Space-Saving algorithms. In particular, we use a distribution hash function h : [n] × [n] → [κ] to split the set of entries into κ parts, and use a Space-Saving sketch and a Count-Sketch estimator on each part. The size κ of the hash table and the size of the Space-Saving sketch determines the accuracy of the estimates. Parallel processing of entries. Naıvely we could just iterate through all entries of each outer product, but we would like an algorithm that runs in time linear in the number of nonzero elements in the input vectors and the entries hashing to a given interval of the hash table. In other words, given sufficient parallelism we can handle a given data rate even if there is a huge number of entries in a given outer product. Lemma 1. Let ha, hb : E → [κ] be pairwise independent hash functions. Given input vectors a and b with O(t) nonzero entries each and an interval L = [q, q+1, . . . , r) for 0 ≤ q ≤ r ≤ κ we can construct E abL , the set of entries occurring in the outer product ab hashing to a value in L, in expected time O(E abL + t). Proof. We exploit the special structure of our hash functions: h(i, j) = (ha(i) + hb(j)) mod κ for a 2- wise independent hash function ha, hb : N → [κ] and i, j ∈ [n]. It is easy to show that this construction implies that h : E → [κ] is also pairwise independent. To find the entries with a nonzero value in ab that hash to [q, r) we first sort the indices with a nonzero value in each a and b according to the hash value in arrays Ha and Hb for a and b, respectively. Entries with a hash value in the right range correspond to elements in Ha and Hb with sum in [q, r) ∪ [κ + q, κ + r). Since the hash values are pairwise independent we can sort by bucket sort in expected linear time. One way to find the entries in the right range would be to iterate over elements of Ha, and for each do two binary searches in Hb to find the values in the right ranges. However, this can be further improved by processing Ha in sorted order, and exploiting that the entries with hash value in the right range correspond to intervals of Hb that will be moving monotonically left. Thus, for a fixed index i we find the entries (i, j), j ∈ [n] with a hash value in [q, r)∪ [κ + q, κ + r) in time linear in the number of such entries. This brings down the time to O(E abL + t). Parameters. We will assume that data is not lightly skewed and z > 1/2. We will distinguish between the cases when 1/2 < z < 1 and z > 1. In order to keep the presentation concise the particular case z = 1 will not be analyzed. In our analysis we will also use as a parameter the total number of nonzero entries d occurring in the matrix product. The value of d is not known in advance. One can either be conservative and assume d = O(n2), or in the case of positive input matrices use efficient methods for estimating the number of nonzero entries [2] if two passes over the input are allowed. 6 Analysis Load balancing. First we show that pairwise in- dependent hashing of entries guarantees good load bal- ance among processors. We show that for outer prod- ucts for which the number of non-zero entries is con- siderably bigger than the number of processors, CRoP achieves good scalability with high probability. function CRoP Input: matrices A, B ∈ R+n×n, Interval [q, r), a list κ Space- Saving summaries SS each for (cid:96) entries, array for κ real numbers CS, pairwise independent hash functions ha, hb : N → [κ], s : E → {−1, 1} 1: for i ∈ [n] do 2: 3: 4: 5: 6: a := ith column of A, b := ith row of B E := Hash(ha, hb, a, b, [q, r)) for e ∈ E do Update Space-Saving summary SS[h(e)] with the entry e. CS[h(e)] = CS[h(e)] + e · s(e). function Hash Input: pairwise independent hash functions ha, hb : N → [κ], vectors a ∈ Rn, b ∈ Rn, Interval [q, r) while Ha[i] + Hb[k] > q do if k > 0: k = k − 1 1: sort the nonzero entries in a and b according to ha and hb in arrays Ha and Hb, respectively 2: k = Hb.length, E = ∅ 3: for i = 1 to Ha.length − 1 do 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: return the set E j = j + 1 if j >= Hb.length: break for-loop E = E ∪ (i, j) if j < Hb.length: j = j + 1 else: break for-loop j = k while Ha[i] + Hb[j] < q do while Ha[i] + Hb[j] < r do Figure 1: [CRoP algorithm] A high-level description for a single run of our algorithm. The description of the hash functions h : E → [κ] and s : E → {−1, 1} is sent to all processors before the computation starts. For a detailed pseudocode description of Space-Saving and Count-Sketch the reader is referred to the original works [8, 18]. After processing the input matrices one can obtain an estimate for individual entries from the corresponding Space-Saving summary or Count-Sketch estimator. Theorem 1. Suppose we run K instances of CRoP with disjoint intervals of the same size, on an input of ab column and row vectors a, b ∈ Rn. Let W = K . Then for W ≥ a+b the probability that the number of entries processed by a given instance will deviate by more than λW from its expected value is bounded by (a+b) for any λ > 0. λ2 1 Proof. We distribute the nonzero entries in ab to K processors. We consider one of the K processors, say P1. Let Ye be an indicator random variable denoting whether the entry e is hashed to the range of P1. e∈ab Ye. Thus, we have E[X] = W . Since the hash function is pairwise independent for the variance of X we have V [X] = 1 K = Clearly, E[Ye] = 1/K. Let X = (cid:80) (cid:80) e∈ab V [Ye] = (cid:80) e ] − E[Ye]2) ≤ (cid:80) e∈ab(E[Y 2 e∈ab ab K = E[X] = W . Using Chebyshev’s inequality and W ≥ a+b λ2 we estimate the probability that this number deviates by more than λ to: Pr[X − E[X] ≥ λW ] ≤ V [X] λ2W 2 = V [X]K 2 (λab)2 = K λ2ab ≤ 1 (a + b) The above theorem essentially says that when we expect a sufficient number of entries per core in a given outer product, the probability that the work load will deviate by more than a small constant factor from its expectation, namely W/K, is very small. Thus, we expect that the computation of only a small fraction of the outer products will not be well balanced among processors and this will not considerably affect the total performance. In the following we present results for the estimates based on Space-Saving (giving guarantees on the upper/lower bounds), as well as the unbiased Count- Sketch estimator returned by our algorithm. Quality of estimates. Theorem 2. Let A, B be n × n nonnegative matrices such that there are d nonzero entries in AB adhering to a Zipfian distribution with parameters C and z. After processing all outer products aibi, 1 ≤ i ≤ n, by CRoP with k buckets and a Space-Saving data structure with (cid:96) entries • if z > 1, an entry with weight at least Ω( C ((cid:96)k)z ) is recorded in one of the Space-Saving summaries with probability more than 1/2. By running O(log (cid:96)k δ ) instances of CRoP in parallel, we report all entries with weight Ω( C ((cid:96)k)z ) or more with probability at least 1 − δ. (cid:96)k ((cid:96)k)z , Cd1−z • if z < 1, an entry with weight at )) is recorded in one of least Ω(max( C the Space-Saving summaries with probability more than δ ) instances of CRoP 1/2. By running O(log K in parallel, for K = max((cid:96)k, d (cid:96)k ), we report all ((cid:96)k)z , Cd1−z entries with weight Ω(max( C )) or more with probability at least 1 − δ. (cid:96)k Proof. Let the minimum absolute weight for heavy entries be αm, α > 0. (At the end of the proof we will obtain bounds on αm depending on k.) We will estimate the probability that a heavy entry e is not reported. From the Zipfian distribution we obtain that x := ( C z entries will have weight above αm. Let B be the bucket e hashes to. We first consider the αm ) 1 reported. Let w :=(cid:80)d case that at most (cid:96)/2 entries with weight above αm are hashed to B. The expected number of heavy entries hashed to B is x/k. For k ≥ 12x (cid:96) we get by Markov’s inequality that the probability p1 that more than (cid:96)/2 heavy entries will land in B is at most 1/6. As already discussed in Section 4, if the total weight of non-heavy entries hashed to B is less than (cid:96)αm/2 and no other heavy entries hash to B, then all heavy entries will be i=x+1 C/iz be the total weight of non-heavy entries. In the following we will use the fact that w = O(C(d1−z)) for z < 1 and w = O(C(x1−z)) for z > 1, where d is the number of distinct entries in the matrix product. This follows by integration of the corresponding continuous function. Then we expect non-heavy entries of total weight w/k to land in B. Let Yj be an indicator random variable denoting whether the jth non-heavy entry is hashed to B and j=1 Yj. Clearly, E[X] = w/k. Applying Markov’s inequality we obtain p2 := Pr[X ≥ 3w/k] ≤ 1/3. We want 3w/k ≤ (cid:96)αm/2. For z < 1 we have w = O(C(d1−z) thus together with the bound on the number of heavy entries in the bucket we set k = max(O( 1 (cid:96)αm) ). Similarly, for z > 1 we have w = O(C(x1−z), hence the bound k = O( 1 z ). Thus, for z < 1, we will consider entries heavy if their weight is αm = Ω(max( C )) and for z > 1 if αm = Ω( C ((cid:96)k)z ). By the union bound the probability that an entry with weight at least αm is not reported is at most p1 + p2 < 1/2. X = (cid:80)d−x z ), O( C(d1−z) (cid:96) ( C αm ) 1 (cid:96) ( C αm ) 1 ((cid:96)k)z , Cd1−z (cid:96)k By running t copies of the algorithm in parallel and reporting only entries that are reported in some summary in at least t/2 cases, we can amplify the probability for a correct estimate to exp(O(t)). The analysis follows a standard application of Chernoff’s inequality. Thus, for the given values of t and K for each heavy entry we bound the probability of not being reported to δ K for z > 1 and z < 1, respectively. Since the number of heavy entries in each case is bounded by (cid:96)k or K, by the union bound we bound the error to δ that any heavy entry will not be reported. (cid:96)k and δ Count-Sketch was analyzed for Zipfian data in the original publication [8]. [8] Let A, B ∈ Rn×n such that the entries Theorem 3. in AB adhere to a Zipfian distribution with parameters C and z > 1/2. After processing all outer products akbk by CRoP with k Count-Sketch estimators, each entry is approximated with additive error of at most Ω( C kz ) with probability more than 1/2. By running of O( n δ ) instances in parallel the additive error of at most kz ) for any entry holds with probability at least 1− δ. Ω( C A lower bound. We present a lower bound for the space needed to report the heaviest entry in a matrix product by the column-row method. Of course, this applies also to any harder problem, such as reporting a larger set of heavy entries, with estimates. Theorem 4. Any algorithm that always outputs the heaviest entry in a matrix product AB, or even just the weight of the heaviest entry, in only one pass over the outer products aibi, i ∈ [n], must encode in its state all entry weights, in the sense that if two prefixes of the outer products differ in the weight of some entry, the algorithm must be in different states after seeing the prefixes. Proof. Since we are allowed only one pass over the column and row vectors of the input matrices, we will consider the outer products as a stream of updates for the output entries. For a prefix of the stream consider the count vector that for each entry records its weight in the prefix. Let A be any algorithm that computes the heaviest entry in a data stream. Consider two distinct weight vectors x and y, corresponding to different stream prefixes. We argue that A must be in two different states after seeing these prefixes. Suppose that the latter claim is not true, so that for x (cid:54)= y the algorithm is in the same state. Since x and y differ, there must be at least one entry (i, j) having distinct weights in the two weight vectors. But this implies that we can extend the streams with a sequence that makes the entry (i, j) the heaviest one in one of the weight vectors, say w.l.o.g. x, (i, j) becomes the heaviest entry, while this does not happen in y. Still, the algorithm would be in the same state in both cases, returning the same result and weight. This contradicts the assumption that A always returns the correct answer, so the assumption that x and y resulted in the same state must be false. Intuitively, the only generally applicable ways of storing the weights of all entries is to either store each weight explicitly, or store all column and row vectors seen so far. 7 Frequent pair mining in transactional data streams: a case study Our original motivation was to parallelize the mining of frequent pairs from a high speed transaction stream. As already explained, the problem can be seen as an instance of sparse matrix multiplication AAT by the column row method. We use the following notation for transactional data streams. Let I be a set of items. A transaction T ⊂ I is a set of items. We call a subset p = {i, j} ⊂ I a pair. For a stream of transactions S, the support of a pair p is the number of transactions containing p: sup(p) = {T : p ⊆ T}, T ∈ S. We can consider each transaction T as a {0, 1}-valued sparse n-dimensional vector vT and the set of pairs occurring in the given transaction as the nonzero entries above the diagonal in the outer product of vT and its transpose. 7.1 Frequent Pattern Mining. Considerable work has been done on parallel and distributed implementa- tions of frequent itemset methods. We refer to Zaki’s 1999 survey [23] for an overview of some main tech- niques that have been investigated. Subsequent work has focused on either multi-core computing, aiming to minimize the overhead of access to shared data struc- tures [13, 14], or more recently GPU computing, focus- ing on representations of data that allow efficient GPU implementations (see e.g. [16, 15] for recent results). To our best knowledge, all known methods for par- allelising frequent itemset mining use either a shared data structure, or a “vertical”, column-by-column lay- out of the data (for each item, a sorted list of the trans- actions where it occurs). In the former case the shared data structure will become a bottleneck when scaling to many cores. In the latter case one can no longer have a space-efficient streaming algorithm, because comput- ing the vertical representation requires storing all trans- actions. It is also well-known that for sparse matri- ces this representation, which supports fast computa- tion of inner products, leads to higher time complexity than methods based on outer products. See [3] for an overview of theoretical results on (serial) sparse matrix products. 7.2 Related work on stream mining. Though we view the new load balancing technique as the main contribution of our work, its application to stream mining is interesting in its own right. In the following we briefly review related work in this area. Manku and Motwani [17] first recognized the neces- sity for efficient algorithms targeted at frequent item- sets in transaction streams and presented a heuristic ap- proach generalizing their StickySampling algorithm. A straightforward approach to mining of frequent pairs is to reduce the problem to that of mining frequent items by generating all item pairs in a given transaction. Yu et al. [22] and Campagna and Pagh [6] present randomized algorithms for transaction stream mining. The theoret- ical bounds on the quality of their estimates however heavily depend on the assumption that transactions are either generated independently at random by some pro- cess or arrive in a random order. It is already clear from the experiments of [6] that such optimistic assumptions do not hold for many data sets. For both schemes [22, 6] Dataset Mushroom Pumsb Pumsb star Kosarak Retail Accidents Webdocs Nytimes Pubmed Wikipedia 22.4 · 105 1360 · 105 638 · 105 3130 · 105 80.7 · 105 187 · 105 2.0 · 1011 1.0 · 1010 1.6 · 1010 5.17 · 1011 # of pairs (F2) # of distinct pairs 3.65 · 103 536 · 103 485 · 103 33100 · 103 3600 · 103 47.3 · 103 > 7 · 1010 > 5 · 108 > 6 · 108 > 5.8 · 109 Table 1: Information on data sets for our experiments. Nytimes and Pubmed are taken from the UCI Machine Learning Repos- itory (Bag of Words data set). The wikipedia dataset has been crafted according to what is described in [1, Page 14]. The other data sets are from the Frequent Itemset Mining Implementations (FIMI) Repository. For the last three data sets the number of distinct pairs was estimated using a hashing technique from [2]. In the context of sparse matrix multiplication the number of pairs is the total number of nonzero entries in all outer products and the number of distinct pairs is the number nonzero entries in the output matrix. it is easy to find an ordering of essentially any trans- action stream that breaks the randomness assumption, and makes it perform much worse than the theoretical bounds. We therefore believe that a more conservative model is needed to derive a rigorous theoretical analysis, while exploiting observed properties of real data sets. 7.3 Experimental evaluation. We worked with a cache-optimized Java implementation working only with primitive data types and used the built-in random number generator to store hash values in a table. Unless otherwise reported we ran experiments on as Mac Pro desktop equipped with Quad-Core Intel 2.8GHz and 16 GB main memory. In this architecture there are 8 cores and a total of 24 MB cache available but 2 cores share 6 MB of cache. Datasets. We evaluated the performance of our al- gorithm on the following datasets: Mushroom, Pumsb, Pumsb star and Kosarak, taken from the Frequent Itemset Mining Implementations (FIMI) Repository, Wikipedia – crafted according to what is described in [1, Page 14], and Nytimes and Pubmed taken from the UCI Machine Learning Repository. Table 1 summarizes the data sets used in experi- ments. In all cases, we use the order in which the trans- actions are given as the stream order. Accuracy of results. Our first set of experiments shows results on the precision of the counts obtained by CRoP using a Space-Saving data structure of size 2,i.e., we record only two pairs. The accuracy depends on the amount of space used and the number of pairs we are interested in reporting. Assume the pairs are sorted in decreasing order according to their frequency, we say that ith pair has rank i. We made one experiment fixing the space usage, and looking at results for pairs of decreasing rank (computed exactly), and one that varies the space usage and considers the top-100 pairs. In practice, it may be hard to foresee how much space will be needed for a particular stream, so probably one will tend to use as much space as feasible with respect to running time (ensure in-cache hash table), or what amount of memory can be made available on the system. A consequence of this will be even more precise results. The results of our experiments on the Nytimes data set can be seen in Figure 2(a). Varying space usage We now investigate what happens to the quality of results when the space usage of CRoP is pushed to, and beyond, its limits. For this, we chose to work with 3 representative data sets, namely Mushroom, Retail and Accidents, for decreasing space usage, plotting the ratio between the upper and lower bounds for the top-100 pairs returned by our algorithm. This is shown in Figure 2(b) and we can see how the transition between very poor and very good quality is fairly fast. Larger Space-Saving data structures. We es- timated the number of pairs with ratio at least 90% between lower and upper bound by varying the number of pairs in each bucket but keeping the total number of pairs of our sketch constant. We counted the num- ber of pairs until the 100-th bad estimate, i.e. until 100 pairs have a lower bound less than 90% of its up- per bound. Since our algorithm is randomized we chose 100 as cut-off in order not to be sensitive to outliers in the estimates. We fixed the total number of pairs for the Kosarak dataset to 240000 and for the Accidents dataset to 6000. We then varied the pairs per bucket from 2 to 24. The effect was much better estimates with the same space usage, see Figure 3(a). Count-Sketch Estimates The result of the un- biased COUNT-SKETCH estimator for the Kosarak dataset with 50000 buckets and 2 pairs per bucket is pre- sented in Figure 3(b). We ran the algorithm 11 times and for each pair reported at least 6 times we return the median of its estimates. The plot shows the ra- tio of our estimates and the exact count of the 3000 pairs with highest support computed by Apriori. Not reported pairs have ratio 0. In general we observe that the estimates given by Space-Saving are tighter. Scalability. In order to assess the scalability of our approach, we performed the following experiment: We ran the algorithm with a Space-Saving data structure on the Kosarak dataset with a sketch of size 10000i on i cores. For each run we computed the recall for the top Figure 2: (a) The plot on the left side shows upper and lower bounds for Nytimes computed by CRoP using 106 buckets. Values are normalized by dividing by true support. Upper bounds shadow lower bounds, exact bounds are visible only as a red dot with no blue dot below. As can be seen, upper bounds are generally tighter than lower bounds. (b) On the right-hand side we plot the average ratio of lower and upper bound for top-100 pairs, for three representative data sets, as function of number of buckets. As can be seen, there is a quick transition from poor to excellent precision. 10000 pairs in the dataset, see Table 2. The idea is that each core can handle a sketch of size 10000 using only its local cache. The running time is the time needed for all processes to complete. Given that each core needs about 8 sec to read all input transactions, sort it according to the hash values of the items and then decide which pairs it is responsible for, a very good scalability is observed. The results indicate that using parallelism our approach is both more efficient and achieves more accurate results. Load balance. We have run experiments evaluat- ing the distribution of pairs among the buckets. When running these experiments, we kept track of the num- ber of pairs processed by each core. The results of these experiments are reported in Table 3. The numbers in the table confirm that the pairs spread evenly amongst 110100100010000Actual rank0.00010.0010.010.11Upper and lower bounds, relative to true value10210310410500.10.20.30.40.50.60.70.80.91number of bucketsEstimate quality for top 100 pairs RetailAccidentsMushroom Cores Time(sec) Recall 1 22.13 0.1119 2 14.87 0.1988 4 11.73 0.3156 8 9.96 0.4812 Table 2: Recall for Kosarak. Dataset Cores Average Retail Kosarak Webdocs Nytimes Wikipedia 8 4 2 8 4 2 8 4 2 8 4 2 8 895542 1791084 3582168 3203546 6407091 1.2814 · 107 8.928 · 108 1.7856 · 109 3.5712 · 109 1.2497 · 109 2.4995 · 109 4.9989 · 109 6.4582 · 1010 Maximum 934040 1808784 3585869 3219769 6427398 1.2827 · 107 8.9394 · 108 1.7871 · 109 3.573 · 109 1.251 · 109 2.5005 · 109 4.9995 · 109 6.4651 · 1010 Table 3: The table shows the average and maximum number of pair occurrences handled by each core. As can be seen, the maximum is quite close to the average. cores to run at close to maximum speed, while needing to cache only a small number of transactions. Somewhat surprisingly and inconsistent with the above results, we observed however that our experi- ments on a multicore CPU for various architectures do not always suggest very good scalability with in- creased number of cores. For example, the Webdocs dataset consists of long transactions only, thus the time for reading the input should not dominate. However, we observed that even if the processing time becomes better with more cores the advantages of having more cores become less and less pronounced. In particular, the running time between processing the data set with eight cores instead of four cores decreases by a factor of only 1.25 while the ratio of the running time between one core and two cores is about 1.85. The reason is that each core has a small amount of dedicated L2 cache which is not sufficient to keep the whole interval of the hash table assigned to it and this leads to memory con- tention among processes. This means the potential of our method can be fully exploited when distributing the work to several processors or when we work with rather small sketches of the data stream. More precisely, experiments have been carried out in order to verify how the algorithm scales, in terms of time, when parallel computations are used. We ran the algorithm on various datasets using different number of cores in order to highlight the parallel nature of the algorithm. Table 4 reports some of the results we Figure 3: On the left side is the number of estimates with ratio of at least 90% until 100 bad estimates have been seen for a given number of pairs in each Space-Saving summary. As we see a sharp improvement in the quality of the estimates can be observed by increasing the number of pairs in each summary. On the right- hand side the plot represents the ratio of estimates and true count for the top 3000 pairs of Kosarak. All top 1400 pairs are reported by our algorithm and for most of the pairs the estimates are within of factor 2. However, the estimates are worse than those given by Space-Saving with the same total space usage. the buckets meaning that parallelism greatly improves the running time of the algorithm, since there will be no core that has to sustain a much larger burden than the others; such a negative situation would bring the performances of the algorithm close to a sequential one. Progress of processing. We ran four processes, and let the operating system allocate one to each core. We tracked the progress of each process over time. The result for the Kosarak dataset are shown in Figure 4(b) and for Nytimes dataset in Figure 4(a). As can be seen, the cores make almost identical progress when running at full speed. In a data streaming setting this means that we can expect to manage streams that require all 051015202515002000250030003500400045005000550060006500PairsNumber of Estimates within 10% of exact value kosarakaccidents05001000150020002500300000.511.522.5Rank of pairsRatio of estimate and exact count Dataset # of cores ms on # cores ms 1 core Retail Kosarak Webdocs Nytimes Wikipedia 8 4 2 8 4 2 8 4 2 8 4 2 8 4 2 1321 1193 1512 1551 1586 1997 299153 357679 482111 443119 524553 689058 27526403 35397110 53795313 2001 2881 891565 1313698 93477243 Table 4: Experiments ran on an Intel Xeon E5570 2.93 GHz equipped with 23 GB of RAM; the OS is GNU/Linux, kernel version 2.6.18. The number of processes used is 8 for all four datasets. Times are given in milliseconds (ms). The number of buckets for the largest datasets is of the order 220. We can observe that in any case, millions of pairs per second were manipulated by the algorithm. Figure 4: On the left side we see the progress of the current transaction number of each core running CRoP on the Nytimes data set, over a period of about 400 seconds and on the right-hand side the total time recorded for every 100th transaction when running CRoP with 4 cores on the Kosarak data set. obtained. As one can see the exact running times for the eval- uation of the scalability of our algorithm appear some- what cumbersome since the improvement in running times does not suggest very good scalability. This is not due to a flaw in our implementation but a consequence of the specific Xeon E5570 architecture. Each core has a small amount of dedicated cache, namely 256 KB. In order to obtain correct estimates we need a large num- ber of buckets which do not fit in cache and this leads to memory contention. For considerably smaller size of our sketch we achieve almost perfect scalability. We ran another set of experiments on a Mac Pro desktop equipped with Quad-Core Intel 2.8GHz. In this archi- tecture there are 8 cores and a total of 24 MB cache available but 2 cores share 6 MB of cache. The running time for 4 parallel processes was about two times better than the running time for 2 parallel processes but the improvement for 8 processes was not as good, clearly in- dicating cache contention among 8 cores and an optimal use for 4 processes. For a large dataset with a high number of pairs such as Nytimes our simple Java implementation nevertheless processed almost 100 million pairs per second on an 8-core Mac Pro, the total running time was about 110 seconds. The sketch contained 400000 buckets which was enough to find the exact counts of the top few hundred pairs. The throughput of a competing hash table solution can be upper bounded by the number of updates of random memory locations possible (disregarding time for hash function computation, and other overheads). On the Mac Pro the number of such updates per second was estimated to around 50 millon per second, when updating a 1 GB table using 8 cores. This means that we are at least a factor of 2 faster than any implementation based on a large, shared data structure. References [1] E. Abusland and M. Markovics. Implementing and evaluating a sampling-based approach to association mining on mapreduce. Master’s thesis, IT University of Copenhagen, 2011. 050100150200Time / 2s050000100000150000200000250000300000Transaction number0200040006000800010000Transaction number / 100050001000015000Time / ms [2] R. R. Amossen, A. Campagna, and R. Pagh. Bet- In ter size estimation for sparse matrix products. APPROX-RANDOM, pages 406–419, 2010. [20] T. Sarl´os. Improved approximation algorithms for large matrices via random projections. In FOCS, pages 143–152, 2006. [21] S. van Dongen. Graph Clustering by Flow Simulation. PhD thesis, University of Utrecht, May 2000. [22] J. Xu Yu, Z. Chong, H. Lu, Z. Zhang, and A. Zhou. A false negative approach to mining frequent itemsets from high speed transactional data streams. Inf. Sci., 176(14):1986–2015, 2006. [23] M. J. Zaki. Parallel and distributed association mining: A survey. IEEE Concurrency, 7(4):14–25, 1999. [3] R. R. Amossen and R. Pagh. Faster join-projects and In ICDT, pages 121– sparse matrix multiplications. 126, 2009. [4] A. Bulu¸c. Linear Algebraic Primitives for Parallel Computing on Large Graphs. PhD thesis, University of California, Santa Barbara, CA, March 2010. [5] A. Campagna and R. Pagh. Finding associations and In computing similarity via biased pair sampling. ICDM, pages 61–70, 2009. [6] A. Campagna and R. Pagh. On finding similar items in a stream of transactions. In ICDM Workshops, pages 121–128, 2010. [7] L. E. Cannon. A cellular computer to implement the In Technical report, Ph.D. kalman filter algorithm. Thesis, Montana State University, 1969. [8] M. Charikar, K. Chen, and M. Farach-Colton. Finding frequent items in data streams. Theor. Comput. Sci., 312(1):3–15, 2004. [9] E. Cohen and D. D. Lewis. Approximating matrix multiplication for pattern recognition tasks. In SODA, pages 682–691, 1997. [10] G. Cormode and M. Hadjieleftheriou. Finding the frequent items in streams of data. Commun. ACM, 52(10):97–105, 2009. [11] J. Demmel, M. Hoemmen, M. Mohiyuddin, and K. Yelick. Avoiding communication in sparse matrix computations. In IPDPS 2008., pages 1 –12, april 2008. [12] P. Drineas, R. Kannan, and M. W. Mahoney. Fast monte carlo algorithms for matrices i: Approximating matrix multiplication. SIAM J. Comput., 36(1):132– 157, 2006. [13] A. Ghoting, G. Buehrer, S. Parthasarathy, D. Kim, A. Nguyen, Y.-K. Chen, and P. Dubey. Cache- conscious frequent pattern mining on a modern pro- cessor. In VLDB, 2005. [14] E. Li and L. Liu. Optimization of frequent itemset In VLDB, pages mining on multiple-core processor. 1275–1285, 2007. [15] H. Li. A gpu-based closed frequent itemsets mining algorithm over stream. In IEEE International Confer- ence on Intelligent Computing and Intelligent Systems, pages 6–10, 2010. [16] H. Li and N. Zhang. Mining maximal frequent itemsets In FSKD, pages 1461–1464, on graphics processors. 2010. [17] G. S. Manku and R. Motwani. Approximate frequency counts over data streams. In Philip A. Bernstein et al., editors, VLDB ’02, pages 346–357, 2002. [18] A. Metwally, D. Agrawal, and A. El Abbadi. An integrated efficient solution for computing frequent and top-k elements in data streams. ACM Trans. Database Syst., 31(3):1095–1133, 2006. [19] R. Pagh. Compressed matrix multiplication. In ITCS, 2012.
1304.7403
1
1304
2013-04-27T19:56:34
Improved Approximation Algorithms for the Min-Max Selecting Items Problem
[ "cs.DS" ]
We give a simple deterministic $O(\log K / \log\log K)$ approximation algorithm for the Min-Max Selecting Items problem, where $K$ is the number of scenarios. While our main goal is simplicity, this result also improves over the previous best approximation ratio of $O(\log K)$ due to Kasperski, Kurpisz, and Zieli\'nski (Information Processing Letters (2013)). Despite using the method of pessimistic estimators, the algorithm has a polynomial runtime also in the RAM model of computation. We also show that the LP formulation for this problem by Kasperski and Zieli\'nski (Annals of Operations Research (2009)), which is the basis for the previous work and ours, has an integrality gap of at least $\Omega(\log K / \log\log K)$.
cs.DS
cs
Improved Approximation Algorithms for the Min-Max Selecting Items Problem Benjamin Doerr Max Planck Institute for Computer Science, Campus E1 4 66123 Saarbrucken, Germany July 19, 2018 Abstract We give a simple deterministic O(log K/ log log K) approximation algo- rithm for the Min-Max Selecting Items problem, where K is the number of scenarios. While our main goal is simplicity, this result also improves over the previous best approximation ratio of O(log K) due to Kasperski, Kurpisz, and Zieli´nski (Information Processing Letters (2013)). Despite us- ing the method of pessimistic estimators, the algorithm has a polynomial runtime also in the RAM model of computation. We also show that the LP formulation for this problem by Kasperski and Zieli´nski (Annals of Opera- tions Research (2009)), which is the basis for the previous work and ours, has an integrality gap of at least Ω(log K/ log log K). Key words: Approximation algorithm; randomized rounding; derandom- ization; robust optimization. 1 A Simple Approximation Algorithm In this short note, we first give a simple approximation algorithm for the Min-Max Selecting Items problem. In this problem, we are given n items numbered from 1 to n and a set S of K scenarios. A scenario S ∈ S is an assignment of nonnegative integral costs cS,i to each item i ∈ [n] := {1, . . . , n}. The goal is to select a set P of exactly p items such that the maximum cost c(P, S) := Pi∈P cS,i of the selected items in any scenario is minimal. This problem belongs to the class of problems where solutions are sought which are robust to an event determined only after the optimization process. See [KY97] for more on robust optimization. 1 For the above defined Min-Max Selecting Items problem, a randomized O(log K) approximation algorithm was given in [KZ09]. A deterministic algorithm of same approximation ratio was given in [KKZ13]. We shall now give an algorithm considerably simpler than the two previous ones that achieves an approximation ratio of O(log K/ log log K). Like both previous works, we regard the following class of linear programs. For any C ≥ 0, let IC := {i ∈ [n] ∀S ∈ S : cS,i ≤ C} denote the set of items having cost at most C in all scenarios. Consider the linear program LPC : X xi = p i∈IC X i∈IC cS,ixi ≤ C, S ∈ S xi ∈ [0, 1], i ∈ IC. Via binary search over the reasonable values for C and solving LPC, we find the smallest C such that LPC has a solution. Naturally, this C is a lower bound for the optimum of the Min-Max Selecting Items problem. Our aim in the following is to transform the fractional solution (xi)i∈IC into a so- lution for the selecting items problem that has cost c(P, S) = O(C log K/ log log K) for all S ∈ S. The solution we will construct shall only take items from IC, hence for conve- nience, we may simply assume IC = [n]. By scaling the costs, we may assume that C = 1, and consequently (since IC = [n]), that all costs are rational numbers not exceeding 1. We now use dependent randomized rounding and its derandomization to find the desired solution. In Raghavan's [Rag88] classic randomized rounding, we would round each xi independently to some 0,1 valued yi such that Pr(yi = 1) = xi. Chernoff bounds would immediately give that with reasonable probability, we have Pi∈[n] cS,iyi ≤ O(log K/ log log K) for all S ∈ S. The problem with this approach is that the cardinality constraint Pi∈[n] yi = p is unlikely to be satisfied. Our feeling is that overcoming this difficulty is the major reason why the previous solutions to the Min-Max Selecting Items problem are slightly technical. Fortunately, there is an easy solution. As first shown in 2001 by Srini- vasan [Sri01], one can do randomized rounding both satisfying cardinality con- straints and satisfying the same Chernoff bounds that are known for independent randomized rounding. This idea has found numerous applications in the last ten years. On the technical side, an alternative solution for this rounding problem that led to the first derandomization of such roundings was developed in [Doe05]. That Srinivasan's approach can be derandomized, in fact by simply reusing Raghavan's 2 pessimistic estimators, was shown in [DW09, Theorem 3.1]. We state a slightly different formulation of this result here, which has an identical proof. Theorem 1. Let A ∈ [0, 1]m×n and x ∈ [0, 1]n. Assume that Pi∈[n] xi ∈ Z. Then in time O(mn), a y ∈ {0, 1}n can be computed such that Pi∈[n] yi = Pi∈[n] xi and such that the rounding errors (Ay)r − (Ax)r in each row r satisfy the same bounds as in Raghavan's derandomization of independent randomized rounding. This result assumes that one can compute rational powers of integers with perfect precision in constant time. In the RAM model of computation, the result only holds for A ∈ {0, 1}m×n. We apply this result to our solution x of LPC and the matrix A := (CS,i). By adding dummy variables, we may assume that sr := (Ax)r = 1 for all rows r. Then the theorem above together with Theorem 3 and equation (1.14) in [Rag88] gives a y ∈ {0, 1}n with the rounding errors in all rows bounded by, in Raghavan's notation, ∆(1, 1/(2K)) ≤ e ln(2K) ln(e ln(2K)) . Consequently, P = {i ∈ [n] yi = 1} is a solution to the Min-Max Selecting Items problem with maximum cost at most 1 + e ln(2K) ln(e ln(2K)) = O(log K/ log log K). 2 Making the Algorithm Work in the RAM Model of Computation One known restriction of Raghavan's derandomization (described in detail in Sec- tion 2.2 of the original paper [Rag88]) is that it can be implemented in the RAM model of computation only if the coefficients of the constraint matrix (this is the matrix A in Theorem 1) are in {0, 1}. In all other cases, rational powers of integers have to be computed, so the derandomization can only be executed in the Real RAM model. Since having to assume the Real RAM model of computation for a purely combinatorial problem is undesirable (see also [SS96]), there has been some interest to make the method of pessimistic estimators also work in the RAM model. The first successful derandomization for the RAM model was given by Srivastav and Stangier [SS96]. As the 30-page paper indicates, their approach is technically quite involved. A second price to pay is an increased runtime of O(mn2 log(mn)) as opposed to the usual O(mn) runtime for Raghavan's derandomization. An alternative approach was presented in [Doe06], which solves many deran- domization problems in time O(mn log n) by a reduction to Raghavan's solution for {0, 1} matrices. Since the derandomization result as formulated in [Doe06] does not give O(log K/ log log K) approximations (in our notation), we quickly prove an alternative formulation that serves our needs. 3 Theorem 2. Let A ∈ ([0, 1] ∩ Q)m×n and x ∈ ([0, 1] ∩ Q)n. Assume that Pi∈[n] xi ∈ Z. Then in time O(mn log n), a y ∈ {0, 1}n can be com- puted such that (i) Pi∈[n] yi = Pi∈[n] xi and (ii) for all r ∈ [m], (Ay)r = O(max{1, (Ax)r} log m/ log log m). Proof. Let ℓ = ⌈log2 n⌉. In time O(mn log n), compute binary matrices A(1), . . . , A(ℓ) ∈ {0, 1}m×n such that A := Pj∈[ℓ] 2−jA(j) and A differ in each en- try by at most 2−ℓ ≤ 1/n. By the triangle inequality, kAx − Axk∞ ≤ 1 for all x ∈ [0, 1]n. Applying Theorem 1 to x and the (mℓ) × n matrix obtained from all rows of A(1), . . . , A(ℓ), in time O(mℓn) in the RAM model we obtain a y ∈ {0, 1}n such that (i) Pi∈[n] yi = Pi∈[n] xi and (ii') for all r ∈ [m] and j ∈ [ℓ], we have that (A(j)y)r − (A(j)x)r satisfies the upper bound for rounding error ob- tained by Raghavan's derandomization for an (mℓ) × n matrix. Note that by (1.13), (1.14) and Theorem 3 in [Rag88], each of these rounding errors is O(max{1, (A(j)x)r} log(mℓ)/ log log(mℓ)). Consequently, 2−j((A(j)y)r − (A(j)x)r)(cid:12)(cid:12)(cid:12)(cid:12) ( Ay)r − ( Ax)r = (cid:12)(cid:12)(cid:12)(cid:12) ≤ X 2−j(A(j)y)r − ((A(j)x)r ≤ O(log(mℓ)/ log log(mℓ)) X ≤ O(log(mℓ)/ log log(mℓ)) X ≤ O(log(mℓ)/ log log(mℓ))(1 + ( Ax)r), 2−j max{1, (A(j)x)r} 2−j(1 + (A(j)x)r) X j∈[ℓ] j∈[ℓ] j∈[ℓ] j∈[ℓ] (Ay)r ≤ 1 + ( Ay)r ≤ 1 + ( Ax)r + ( Ay)r − ( Ax)r = and thus O(max{1, ( Ax)r} log(mℓ)/ log log(mℓ)) = O(max{1, (Ax)r} log(mℓ)/ log log(mℓ)). This shows the theorem for, e.g., m ≥ √log n. If m < √log n, we may use elementary linear algebra as follows to transform x into a vector x′ ∈ ([0, 1] ∩ Q)n such that Ax = Ax′, the cardinality constraint Pi∈[n] x′ i = Pi∈[n] xi is satisfied, and at most m + 1 entries of x′ are not 0 or 1: Let J ⊆ [n], J = m+2 such that xj /∈ {0, 1} for all j ∈ J. Then by essentially solving an m×(m+2) system of linear equalities (in time O(m3)), we obtain an ε ∈ Rn\{0} such that ε[n]\J = 0, Aε = 0 and Pi∈[n] εi = 0. Hence adding a suitable multiple of ε to x yields a [0, 1] -- vector x′ having fewer non-integral entries than x and still satisfying Ax = Ax′ and the cardinality constraint. Repeating this O(n) times, we end up with the desired x′. Computing it took O(nm3) ≤ O(nm log n) time. 4 We can now ignore the entries of x′ that are already 0 or 1 and the corresponding columns of A. We solve the resulting derandomization problem consisting of an m× (m + 1) matrix A, a cardinality constraint, and an (m + 1) -- dimensional vector x by simply checking all at most 2m+1 = O(n) possible roundings and computing their rounding errors each in time of order m2 = O(m log n). Again, the total time for this is O(mn log n). This procedure finds a y as desired, since we know its existence from Theorem 1 already. 3 The Integrality Gap We now show that the linear relaxation LPC has an integrality gap of at least log K/ log log K, that is, there is an instance of the Min-Max Selecting Items prob- lem such that LP1 is feasible, but any integral solution to this Min-Max Selecting Items problem has cost at least Ω(log K/ log log K). This indicates that LP-based approaches using this LP formulation will not easily give approximation ratios asymptotically better than Θ(log K/ log log K). Let k be an arbitrary integer. Let p ≥ k and n ≥ k2 + (p − k). For each T ∈ (cid:0)[k2] k (cid:1) := {T ⊆ [k2] T = k}, define a scenario ST by cST ,i = 1, if i ∈ T , cST ,i = 0, if i ∈ [k2 + (p− k)]\ T , and cST ,i = 2 otherwise. Let x ∈ [0, 1]n be defined by xi = 1/k for i ∈ [k2], xi = 1 for i ∈ [k2 + 1..k2 + (p − k)], and xi = 0 otherwise. Then Pi∈[n] xi = p and Pi∈[n] cST ,ixi = 1 for all T ∈ (cid:0)[k2] k (cid:1). Hence LP1 is feasible. Now let P be an optimal (integral) solution to this problem instance. Since items in [k2+(p−k)+1..n] have cost 2 in all scenarios, whereas those in [k2+(p−k)] have cost at most 1 in all scenarios (and these are at least p = P items), the optimality of P implies P ⊆ [k2 + (p − k)]. Since P = p, we have P ∩ [k2] ≥ k. Hence there is a T ∈ (cid:0)[k2] k (cid:1) such that T ⊆ P . Consequently, c(P, ST ) ≥ P ∩T = k. This shows that the integrality gap of this instance is at least k. k (cid:1) of k (cid:1)) = Θ(k log k). It remains to show that k = Ω(log K/ log log K) for the number K = (cid:0)[k2] scenarios. By Stirling's formula, we compute log(K) = Θ(log (cid:0)k2 Consequently, log K/ log log K = Θ(k log k/ log(k log k)) = Θ(k). References [Doe05] B. Doerr. Roundings respecting hard constraints. In V. Diekert and B. Durand, editors, Proc. 22nd Ann. Symp. on Theoretical Aspects of Computer Science (STACS 2005), volume 3404 of Lecture Notes in Com- put. Sci., pages 617 -- 628. Springer-Verlag, 2005. 5 [Doe06] B. Doerr. Generating randomized roundings with cardinality constraints In B. Durand and W. Thomas, editors, Proc. and derandomizations. 23rd Ann. Symp. on Theoretical Aspects of Computer Science (STACS 2006), volume 3884 of Lecture Notes in Comput. Sci., pages 571 -- 583. Springer, 2006. [DW09] B. Doerr and M. Wahlstrom. Randomized rounding in the presence of a cardinality constraint. In Proc. Workshop on Algorithm Engineering and Experiments (ALENEX 2009), pages 162 -- 174. SIAM, 2009. [KKZ13] A. Kasperski, A. Kurpisz, and P. Zieli´nski. Approximating the min-max (regret) selecting items problem. Inf. Process. Lett., 113:23 -- 29, 2013. [KY97] P. Kouvelis and G. Yu. Robust Discrete Optimization and Its Applica- tions. Springer, 1997. [KZ09] A. Kasperski and P. Zieli´nski. A randomized algorithm for the min-max selecting items problem with uncertain weights. Annals OR, 172:221 -- 230, 2009. [Rag88] P. Raghavan. Probabilistic construction of deterministic algorithms: Ap- proximating packing integer programs. J. Comput. Syst. Sci., 37:130 -- 143, 1988. [Sri01] A. Srinivasan. Distributions on level-sets with applications to approxi- mations algorithms. In Proc. 42nd Ann. IEEE Symp. on Foundations of Computer Science (FOCS), pages 588 -- 597, 2001. [SS96] A. Srivastav and P. Stangier. Algorithmic Chernoff -- Hoeffding inequal- ities in integer programming. Random Structures Algorithms, 8:27 -- 58, 1996. 6
1907.08579
1
1907
2019-07-19T17:17:44
On Approximate Range Mode and Range Selection
[ "cs.DS" ]
For any $\epsilon \in (0,1)$, a $(1+\epsilon)$-approximate range mode query asks for the position of an element whose frequency in the query range is at most a factor $(1+\epsilon)$ smaller than the true mode. For this problem, we design an $O(n/\epsilon)$ bit data structure supporting queries in $O(\lg(1/\epsilon))$ time. This is an encoding data structure which does not require access to the input sequence; we prove the space cost is asymptotically optimal for constant $\epsilon$. Our solution improves the previous best result of Greve et al. (Cell Probe Lower Bounds and Approximations for Range Mode, ICALP'10) by reducing the space cost by a factor of $\lg n$ while achieving the same query time. We also design an $O(n)$-word dynamic data structure that answers queries in $O(\lg n /\lg\lg n)$ time and supports insertions and deletions in $O(\lg n)$ time, for any constant $\epsilon \in (0,1)$. This is the first result on dynamic approximate range mode; it can also be used to obtain the first static data structure for approximate 3-sided range mode queries in two dimensions. We also consider approximate range selection. For any $\alpha \in (0,1/2)$, an $\alpha$-approximate range selection query asks for the position of an element whose rank in the query range is in $[k - \alpha s, k + \alpha s]$, where $k$ is a rank given by the query and $s$ is the size of the query range. When $\alpha$ is a constant, we design an $O(n)$-bit encoding data structure that can answer queries in constant time and prove this space cost is asymptotically optimal. The previous best result by Krizanc et al. (Range Mode and Range Median Queries on Lists and Trees, Nordic Journal of Computing, 2005) uses $O(n\lg n)$ bits, or $O(n)$ words, to achieve constant approximation for range median only. Thus we not only improve the space cost, but also provide support for any arbitrary $k$ given at query time.
cs.DS
cs
On Approximate Range Mode and Range Selection Hicham El-Zein Cheriton School of Computer Science, University of Waterloo, Canada [email protected] Meng He Faculty of Computer Science, Dalhousie University, Canada [email protected] J. Ian Munro Cheriton School of Computer Science, University of Waterloo, Canada [email protected] Yakov Nekrich Cheriton School of Computer Science, University of Waterloo, Canada [email protected] Bryce Sandlund Cheriton School of Computer Science, University of Waterloo, Canada [email protected] Abstract data structure which does not require access to the input sequence; we prove the space cost is asymptotically optimal for constant . Our solution improves the previous best result of Greve et al. (Cell Probe Lower Bounds and Approximations for Range Mode, ICALP'10) by reducing the space For any ∈(0, 1), a(1+ )-approximate range mode query asks for the position of an element whose frequency in the query range is at most a factor(1+ ) smaller than the true mode. For this problem, we design an O(n~) bit data structure supporting queries in O(lg(1~)) time. This is an encoding cost by a factor of lg n while achieving the same query time. We also design an O(n)-word dynamic data structure that answers queries in O(lg n~ lg lg n) time and supports insertions and deletions in O(lg n) time, for any constant ∈(0, 1). This is the first result on dynamic approximate range We also consider approximate range selection. For any α∈(0, 1~2), an α-approximate range selection query asks for the position of an element whose rank in the query range is in[k− αs, k+ αs], we design an O(n)-bit encoding data structure that can answer queries in constant time and prove and Range Median Queries on Lists and Trees, Nordic Journal of Computing, 2005) uses O(n lg n) bits, or O(n) words, to achieve constant approximation for range median only. Thus we not only 2012 ACM Subject Classification Theory of computation→ Data structures design and analysis mode; it can also be used to obtain the first static data structure for approximate 3-sided range mode queries in two dimensions. where k is a rank given by the query and s is the size of the query range. When α is a constant, this space cost is asymptotically optimal. The previous best result by Krizanc et al. (Range Mode improve the space cost, but also provide support for any arbitrary k given at query time. Keywords and phrases data structures, approximate range query, range mode, range median Digital Object Identifier 10.4230/LIPIcs... 1 Introduction The mode and median of a data set are important statistics, widely used across many disciplines. Thus, they are frequently computed in applications for data mining, information retrieval and data analytics. The range mode and median problems further aim at speeding up the computation of the mode and median in an arbitrary subrange of the given sequence of © Hicham El-Zein, Meng He, J. Ian Munro, Yakov Nekrich, Bryce Sandlund; 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 l u J 9 1 ] S D . s c [ 1 v 9 7 5 8 0 . 7 0 9 1 : v i X r a XX:2 On Approximate Range Mode and Range Selection Larsen [16] under the cell probe model. He et al. [15] showed how to support range selection Due to the massive amounts of electronic data available, linear space data structures are often preferred by modern applications. The following are the best solutions to these query elements, and thus have been studied extensively [17, 1, 19, 20, 12, 13, 16, 2, 15, 4, 11, 5, 14, 7]. In these problems, we preprocess a sequence of elements c1, c2, . . . , cn to answer queries. Given also gave strong evidence that, if linear space is required, this query time cannot be improved significantly using purely combinatorial methods with current knowledge. When updates to elements are allowed, El-Zein et al. [7] showed how to support both range mode queries frequent element in ca..b (ca..b denotes ca, . . . , cb), while a range median query asks for the position of the median element in ca..b. A generalization of range median is the range selection query, which asks for the position of the kth smallest element in ca..b for any given k. Thus a two indices a and b with 1≤ a≤ b≤ n, a range mode query asks for a position of the most range selection query becomes range median if k=ऄ(b− a+ 1)~2अ. problems that use O(n) words of space. In static settings, Chan et al. [4] showed how to answer a range mode query in O( n~ lg n) time. By proving a conditional lower bound, they and updates in O(n2~3) time. For range selection, the solution of Chan and Wilkinson [5] answers queries in O(lg k~ lg lg n+ 1) time, matching the lower bound of Jørgensen and in O((lg n~ lg lg n)2) worst-case time and updates in O((lg n~ lg lg n)2) amortized time. range mode [13]. To define this query, let Fx(ca..b) denote the frequency of an element x in ca..b and F(ca..b) denote the frequency of the mode of ca..b (F(ca..b)= maxxFx(ca..b)). Then a(1+ε)-approximate range mode query asks for the position of an element x in ca..b such that (1+ ε)⋅ Fx(ca..b)≥ F(ca..b) for some positive ε. This element is called a(1+ ε)-approximate uses O(n~ε) words of space to support queries in O(lg(1~ε)) time, for any ε∈(0, 1). in the query range ca..b has rank i. Then, for an approximation ratio α ∈ (0, 1~2), an is betweenऄs~2अ− αs andऄs~2अ+ αs, where s= b− a+ 1. Bose et al. [1] studied this problem, for which they proposed a data structure occupying O(n~α) words of space that answers for any given k, asks for the position of an element x whose rank in ca..b is between k− αs and k+ αs. However, this problem has not been formally studied previously. The query times for range mode in both linear space data structure solutions and conditional lower bounds are much larger than that for many other query problems, including range median. To provide faster support for queries, researchers have studied approximate mode of ca..b. Previously, the best result on this problem is that of Greve et al. [13], which Approximate range median can be defined similarly. We say that the ith smallest element α-approximate range median query asks for the position of an element x whose rank in ca..b queries in constant time. An α-approximate range selection query can also be defined, which, To further improve the space efficiency of data structures, researchers have recently studied various query problems in the encoding model [8, 14]. Under this model, a data structure is not allowed to store or assume access to the original data set. Instead, it should occupy as little space as possible, while providing support for queries. For example, in this model, Fischer and Heun [8] studied the range minimum query problem, which asks for the position of the smallest element in ca..b. They proposed a data structure occupying only 2n+ o(n) bits with constant query time. The range selection problem has also been O(n lg κ) bits for any fixed positive integer κ, using which a range selection query can be answered in O(lg k~ lg lg n+ 1) time for any k given in the query with 1≤ k≤ κ. considered in this model: Grossi et al. [14] proposed an encoding data structure occupying Naturally, encoding data structures are only relevant when their space occupancy is asymptotically less than the input data, at least for certain choices of parameters. The space costs of previous results on approximate range mode or median, however, match the size of the H. El-Zein, M. He, I. Munro, Y.Nekrich, and B. Sandlund XX:3 Query Type Exact Query Time Space in Bits Update Time - - - O(n2−2δ lg n) O(nδ log n) O(n2 log log n~ lg n) O(1) O( O(n lg n) n~ log n) O(n lg n) O(n3~4 log n~ log log n) O(n3~4 log log n) O(n2~3 log n~ log log n) O(n2~3 log n~ log log n) O(n4~3 lg n) O(n2~3) O(n lg n) O(n lg n~ε) O(lg lg n+ lg(1~ε)) (1+ ε)− O(lg(1~ε)) O(n lg n~ε) Approximation O(lg(1~ε)) O(n~ε) O(m lg m) O(lg m~ lg lg m) in(0, 1~2) and m= min(n lg n~ε, n~ε2). is in o(1). Thus, we study the problem of designing encoding data structures of approximate input sequence asymptotically when ε or α is a constant and become superlinear when ε or α Table 1 Static and Dynamic Range Mode Query History. In this table, δ is an arbitrary constant Source [17] [20] [4] [4] [4] [7] [1] [13] new new O(n2~3) O(lg n~ε2) - - - range mode, median and selection queries, to improve the space efficiency of previous solutions. Furthermore, previously no research has been done on dynamic approximate range mode, while the dynamic exact data structures for range mode require polynomial query and update times. Therefore, we also study approximate range mode queries under dynamic settings, to provide substantially faster support for queries and updates. which is asymptotically less than the space needed to encode the original sequence itself. means that our space cost is asymptotically optimal for constant ε. When ε is not necessarily improvement upon previous best result of Greve et al. [13], since we match their query time while saving the space cost by a factor of lg n; we assume a word RAM model in which Our Results. For(1+ ε)-approximate range mode, where 0< ε< 1, we design an encoding data structure using O(n~ε) bits that can answer a query in O(lg(1~ε)) time. This is an each word has Θ(lg n) bits. We also prove a lower bound to show that any data structure supporting(1+ε)-approximate range mode must use Ω(n~(1+ε)) bits for any positive ε. This a constant, as long as ε= o(1~ lg n), our data structure uses o(n lg n) bits, i.e., o(n) words, For α-approximate range selection, where 0< α< 1~2, we design encoding data structures k=ऄs~2अ for range median), we have a solution occupying O(n~α2) bits that can answer a with each query, we have another encoding structure in O(n~α3) bits with constant query use at least Ω(n) bits, our data structures are asymptotically optimal for constant α. In dynamic settings, for any ε∈(0, 1), we present an O(m lg m)-bit structure where m= min(n lg n~ε, n~ε2). It supports(1+ ε)-approximate range mode in O(lg m~ lg lg m) time and insertions/deletions in O(lg n~ε2) time. When ε is an arbitrary constant in(0, 1), this data structure uses O(n) words, answers queries in O(lg n~ lg lg n) time, and supports updates in O(lg n) time. As the best result on dynamic exact range mode [7] requires O(n2~3) time time. Our query time matches that of the previous best data structure of Bose et al. [1] which supports range median only, while we decrease the space cost by a factor of lg n when α is a constant. As we also show that any approximate range selection data structure must for two variants of this problem. If k is fixed and given in advance, either as a constant or as a function of the size, s, of the query range satisfying certain reasonable constraints (e.g., query in constant time. If k is not known beforehand and different values of k could be given XX:4 On Approximate Range Mode and Range Selection Query Type Exact α− Approximation α− Approximation (with fixed k) - - - Query Time Space in Bits Update Time O(1) O((n lg lg n)2~ lg n) O(n log n) O(lg n~ lg lg n) O(lg k~ lg lg n+ 1) O(n lg n) O(lg2 n) O(n lg2 n) O((lg n~ lg lg n)2) O((lg n~ lg lg n)2) O(n lg2 n~ lg lg n) O((lg n~ lg lg n)2) O((lg n~ lg lg n)2) O(n lg n) O(n lg n~α) O(1) O(1) O(n~α2) O(n~α3) O(1) O(lg2 n) - - - Source [20] [2] [5] [12] [2] [15] [1] new new Table 2 Static and Dynamic Range Median and Selection Query History. for both queries and updates, this approximate solution is much faster for constant ε. It is also the first result on dynamic approximate range mode. Finally, we apply the technique to solve static(1+ ε)-approximate three-sided range mode in two dimensions, achieving O(lg m) time query and occupying O(m lg m) words of space, where again m= min(n lg n~ε, n~ε2). This is another new approximate query problem. Tables 1 and 2 compare our results to previous work to be surveyed in Section 2. 2 Previous Work mode query. On the other end of the spectrum, there has been work [19, 20] on improving the Range Mode. Krizanc et al. [17] first studied the static range mode problem and showed conditional lower bound to show that, with current knowledge, either the query time must be polynomial, or the construction time must be polynomially larger than n. Later, Greve et al. [13] gave an (unconditional) lower bound in the cell probe model, showing that any that, for any δ ∈ (0, 1~2), there is an O(n2−2δ)-word solution that answers queries in O(nδ log n) time. Setting δ = 1~2 yields an O(n)-word data structure supporting range mode in O(√ n log n) time. They also presented a data structure using O(n2 log log n~ log n) words, or O(n2 log log n) bits, to support queries in constant time. Chan et al. [4] further provided a better linear word solution with O( n~ log n) query time. They also proved a log(Sw~n)) time to answer a range structure using S memory cells of w-bit words requires Ω( n) constant-time query structure of Krizanc et al., and the best solution uses O(n2 lg lg n~ lg2 words, or O(n2 lg lg n~ lg n) bits [20]. range mode can be supported in O(n3~4 log n~ log log n) worst-case time while updates can be performed in O(n3~4 log log n) amortized expected time. Alternatively, they can use O(n4~3) words to improve the query and update efficiency to O(n2~3 log n~ log log n) worst-case time Very recently, El-Zein et al. [7] further improved these solutions by designing an O(n)-word structure supporting both queries and updates in O(n2~3) time. mode using data structures occupying O(n), O(n lg lg n) and O(n lg n) words, respectively. and amortized expected time, respectively. They also proved a conditional lower bound to show that, with current knowledge, either queries or updates must require polynomial time. In dynamic settings, Chan et al. [4] provided a tradeoff among space cost, query time and update time. This tradeoff implies two important results: using linear space in words, Bose et al. [1] were the first to study approximate range mode. They showed how to provide constant-time support for 4-approximate mode, 3-approximate mode and 2-approximate log n H. El-Zein, M. He, I. Munro, Y.Nekrich, and B. Sandlund For(1+ ε)-approximation, they designed an O(n~ε)-word solution that can answer a query in O(lg lg1+ε n)= O(lg lg n+ lg(1~ε)) time. Greve et al. [13] further improved these results by using O(n~ε) words of space to support queries in O(lg(1~ε)) time. XX:5 optimal query time for range selection. More recently, Grossi et al. [14] proposed an encoding Range Median and Selection. The study of range median also has a rich history. It was also Krizanc et al. [17] who initially proposed this problem. There have been several solutions with near-quadratic space and constant query time [17, 19, 20], the best of which uses O((n lg lg n~ lg n)2) words [20]. For linear-space solutions, following a series of earlier work [17, 10, 12, 3], Brodal et al. [2] first achieved an O(n)-word solution that answers range median and selection queries in O(lg n~ lg lg n) time. Jørgensen and Larsen [16] further improved the query time of range selection to O(lg lg n+ lg k~ lg lg n), where k is the specified query rank. They also proved that, under the cell probe model, Ω(lg k~ lg lg n+ 1) time is necessary for any range selection data structure using O(n lgO(1) n) space. Chan and Wilkinson [5] were then the first who designed a linear word solution with O(lg k~ lg lg n+ 1) data structure occupying O(n lg κ) bits for any fixed positive integer κ, using which a range selection query can be answered in O(lg k~ lg lg n+ 1) time for any k given in the query with 1≤ k≤ κ. Gawrychowski and Nicholson [11] presented a space-optimal encoding of range selection which uses even less space, and proved its space cost is optimal within an o(n) In the dynamic case, Gfeller and Sanders [12] proposed a data structure that uses O(n lg n) words of space to support range median in O(lg2 n) time and insertions and deletions in n) amortized time. The structure of Brodal et al. [2] occupies O(n lg n~ lg lg n) words O(lg2 of space, answers queries in O((lg n~ lg lg n)2) worst-case time and supports insertions and deletions in O((lg n~ lg lg n)2) amortized time. Later He et al. [15] improved the space cost to O(n) words while providing the same support for queries and updates. The work of Bose structure occupying O(n~α) words of space that answers queries in constant time. additive term in bits, though no support for queries is provided. All of the above results for range selection assume the selection rank k is specified at query time. et al. [1] is the only work on α-approximate range median, for which they proposed a data 3 Approximate Range Mode Before we proceed, we give a few preliminaries. We will at times refer to elements (of c1..n or otherwise) as colors. This is because their data type has no significance in frequency applications and thus the term color standardizes the data type. Furthermore, at times we create indexing such as a value ri for when the mode in some range csi..ri exceeds a given threshold. It is possible the mode never exceeds such a threshold. To avoid dealing with such corner cases in the rest of this exposition, we make the assumption that our list of elements c1..n is padded at the beginning and end with a sufficient number of one arbitrary color. We allow non-constant ε. However, in our upper bounds, we make the restriction ≤ 1, (cid:73) Theorem 1. Any one-dimensional(1+ ε)-approximate range mode data structure requires Ω(n~(1+ ε)) bits. ca..b with F(ca..b)≤ऄ1~εअ, and is exact. The second part answers high frequency queries ca..b with F(ca..b)>ऄ1~εअ, and makes use of the approximation factor. We delay the proof of Theorem 1 to Appendix A. We proceed with our new upper bound. Our data structure consists of two parts. The first part answers low frequency queries to allow simplification in the runtime and space analyses. XX:6 On Approximate Range Mode and Range Selection find in constant time, for any query range ca..b, one of the following that holds: Low Frequencies: O(n~ε)-Bits O(lg(1~ε)) Query Time. Similar to the data structure of Greve et al. [13], for k= 0, . . . ,ऄ1~εअ let Qk be an increasing sequence of size n such that Qk[i] is the largest integer j≥ i satisfying F(ci..j)= k. Since Qk is an increasing sequence whose largest element is n, we store it in 2n+ O(n~ lg2 n) bits [18] while still accessing its ith element in constant time1. The total space used is O(n~ε) bits. Given a query range ca..b, F(ca..b)> k iff b> Qk[a]. Thus, using binary search, we can determine if F(ca..b)< 1~ε and K= F(ca..b) in that case. If F(ca..b)< 1~ε we return index Q(K−1)[a]+ 1; otherwise we query the high frequency structure. The total time is O(lg(1~ε)). High Frequencies: O(n~ε)-Bits O(lg lg n+ lg(1~ε)) Query Time. We first present an O(n~ε)-bit structure that answers high frequency(1+ ε)-approximate range mode queries in O(lg lg n+ lg(1~ε)) time. We start by developing a tool to binary search the frequency of the mode, with the goal of locating a(1+ ε)-approximate mode. (cid:73) Lemma 2. There exists a data structure using O(k⋅ ε⋅ n~(1+ ε)k+ n~ lg2 n) bits that can 1. F(ca..b)<(1+ ε)k~ε, 2. F(ca..b)>(1+ ε)k~ε, or 3. ((1+ ε)k−1~2)~ε< F(ca..b)<((1+ ε)k+1~2)~ε. In case 2, we find an element with frequency greater than(1+ ε)k~ε in range ca..b. In case 3, we find an element with frequency greater than((1+ ε)k−1~2)~ε in range ca..b. When this structure is present for all k in range 0, . . . ,aelg1+ε εnae, the above trichotomy is sufficient to binary search for an approximate mode of frequency at least 1~ε. If we ever land (1+ ε)k~ε< F(ca..b)<(1+ ε)k+1~ε, which represents case 2 for value k and case 1 for value k+ 1. Since case 2 provides an element with frequency greater than(1+ ε)k~ε, this element Proof. Let 1+ ∆=√ 1+ ε and fj =(∆~ε)⋅(1+ ∆)j. For each integer i in [0, n~ऄf2k−1अ] let si= i⋅ऄf2k−1अ+ 1 and denote by ri the smallest value such that F(csi..ri )≥(1+ ∆)2k~ε. Notice that cri is the unique mode of csi..ri. Similarly, for each integer i in[0, n~ऄf2kअ], let i the smallest value such that F(cs′ = i⋅ऄf2kअ+ 1 and denote by r )≥(1+ ∆)2k+1~ε. ′ ′ i..r′ 1. If b< ri, then F(ca..b)≤ F(csi..ri−1)<((1+ ∆)2k~ε)=((1+ ε)k~ε). (cs′ )−f2k, since there are at mostऄf2kअ−1< f2k elements (ca..b)> Fr′ 2. If b≥ r proceed as follows. ′ j ..r′ j, then Fr′ ′ (cs′ )− f2k≥((1+ ∆)2k+1~ε)−(∆~ε)⋅(1+ ∆)2k=(1+ ∆)2k~ε (ca..b)> Fr′ j and a. Then: between s =(1+ ε)k~ε. j ..r′ Fr′ 3. Suppose b≥ ri and b< r j. Since there are at mostऄf2k−1अ− 1< f2k−1 elements between si ′ and a and since b≥ ri, we have that )− f2k−1≥((1+ ∆)2k~ε)−(∆~ε)⋅(1+ ∆)2k−1=((1+ ∆)2k−1)~ε (csi..ri =((1+ ε)k−1~2)~ε. 1 We store Qk[1] and(Qk[i]− Qk[i− 1]) in unary with a 0 separator between each two consecutive values in a 2n-bit vector ψ with rank and select structures. To access Qk[i] we count the number of 1s in case 3, the encoding gives an approximate mode, and otherwise, we find the k satisfying ′ j preceding or equal to a. We i Given a query range ca..b, we find the biggest indices si, s (ca..b)> Fri is an approximate mode. j j j j j j s i Fri before the ith 0 in ψ. H. El-Zein, M. He, I. Munro, Y.Nekrich, and B. Sandlund XX:7 ′ i εn = Θ( 1 ε (1) (cid:74) term. We have = n Rationalizing the denominator, we can show 1 ∆ and so 1 ∆ ε j, then F(ca..b)≤ F(cs′ ′ j ..r′ j n)= O(k⋅ ε⋅ n~(1+ ε)k+ n~ lg2 n). (k⋅ ε⋅ n~(1+ ε)k)= On⋅ ε∑∞ there are n 0s. For each ri, we insert a 1 bit after the rith 0 bit in the bit vector. Thus ri is equal to the number of 0s before the ith 1 bit in the bit vector. A second bit vector of length ′ vectors in the succinct data structure of Patrascu [18]. This data structure provides constant j, and thus determine whether case 1, time rank and select, which allow us to locate ri and r 2, or 3 applies, in constant time. −1)<((1+ ∆)2k+1)~ε=((1+ ε)k+1~2)~ε. Finally, since b< r To store the values{ri}, we construct a bit vector of length O(n) as follows. In the bit vector, O(n) is used to encode the values{r } in a similar way. We then represent these two bit For a bit vector of size n with m ones, the space cost can be made O(m lg(n~m)+n~ lg2 n) bits [18]. For vector r, m lg(n~m)= O((n~f2k−1) lg f2k−1), and for vector r ′, m lg(n~m)= O((n~f2k) lg f2k). The cost is dominated by vector r. Let us first consider the O(m lg(n~m)) n~f2k−1 lg f2k−1= ∆(1+ ∆)2k−1 lg((∆~ε)⋅(1+ ∆)2k−1). ) and = 1+√ 1+ε 1√ 1+ε−1 ∆~ε= O(1). Thus, with ≤ 1, we can bound (1) with O (k−1~2)n (1+ε)k−1~2 lg(1+ ε). Finally, since we restrict ε≤ 1, we can do a Taylor series expansion to give lg(1+ ε)= O(ε). Thus our final space bound is O((n~f2k−1) lg f2k−1+ n~ lg2 To make the above lemma useful, we must apply it to all k in range 0, . . . ,aelg1+ε εnae. We first analyze the total space cost of all the O(k⋅ ε⋅ n~(1+ ε)k) terms. Summing up these terms, k=1(k~(1+ ε)k)= O(n~ε) bits. The other we have O∑aelg1+ε nae k=1 term comes out to O(lg1+ε lg n lg(1+ε) bits. Again applying Taylor series for 1~ lg(1+ ε)= O(1~ε) gives O(n~(ε lg n)) bits. Thus the total space cost is O(n~ε) bits. number of values of k in the entire range is O(lg1+ε n), so the complexity of the binary search )= O(lg lg n+ lg(1~ε)). is O(lg(lg1+ε n))= O(lg lg n (cid:73) Lemma 3. There exists an O(n~ε)-bit data structure that supports one-dimensional (1+ ε)-approximate range mode queries in O(lg lg n+ lg(1~ε)) time. High Frequencies: O(n~ε)-Bits O(lg(1~ε)) Query Time. The bottleneck of the approach additional data structure that uses O(n) bits but returns a 4-approximate range mode. (cid:73) Lemma 4. There exists an O(n)-bit data structure that supports one-dimensional approx- top level, we store two fusion treesF n~2,l andFn~2,r. The treeFn~2,l contains the values e1, . . . , elg n, where ej is the largest index satisfying F(cej ..n~2)= 2j. Fn~2,r contains the values e1, . . . , elg n, where ej is the smallest index satisfying F(cn~2..ej )= 2j. If a query crosses the middle index n~2, we queryFn~2,l to get p1, the smallest value greater than or equal to a, and we queryFk,r to get p2, the largest value less than or equal to b. We return p1 if F(cp1..n~2)> F(cn~2..p2 ) and p2 otherwise. Clearly, p1 is a 2-approximate mode for ca..n~2 and p2 is a 2-approximate mode for cn~2..b. The true mode has at least half its occurrences in one of these regions, so the value we return is a 4-approximate mode for ca..b. imate range mode queries in constant time with approximation factor 4. Proof. We assume n is a power of 2. We construct a network of fusion trees [9]. At the n)⊆ O (ε⋅ n)⋅ n~ lg2 lg(1+ε))= O(lg lg n ε described in the previous section is the binary search on k. To speed up queries, we store an The time complexity of the binary search is different from a typical binary search. The XX:8 On Approximate Range Mode and Range Selection If the query does not cross the middle, it falls entirely in one of the two sides. We may therefore repeat our fusion tree scheme in a divide and conquer fashion, recursing on the two halves. Eventually, there will be a level of the recursion that intersects the query. To analyze the total space used, we use the recurrence S(n)= 2S(n~2)+ O(lg2 n), which solves to S(n)= O(n) bits. To analyze the time complexity of the query, observe that the fusion trees on O(lg n) elements with word size O(lg n) support the necessary predecessor/ successor queries in constant time. However, we must know which fusion trees to query. This involves finding the level of recursion in which the query range intersects the midpoint. This is equivalent to the highest set bit in the XOR of a and b, which can be determined in constant time in the word RAM model. With this information, we can do the necessary arithmetic to find the (cid:74) appropriate fusion trees to query, and thus query takes constant time. We now return to the(1+ ε)-approximation. To answer a query ca..b, we first query the know x≤ F(ca, . . . , cb)≤ 4x. We have thus shrunk the number of values of k from Lemma 2 that need be tested for the(1+ ε)-approximation fromऄlg1+ε nअ toऄlg1+ε (4x~x)अ=ऄlg1+ε 4अ. Thus our binary search now takes time O(lg lg(1+ε))= O(lg(1~ε)). (cid:73) Theorem 5. There exists an O(n~ε)-bit data structure that supports one-dimensional approximate range mode queries in O(lg(1~ε)) time with approximation factor 1+ ε. 4-approximation structure of Lemma 4, which returns a corresponding frequency x. We now 2 However, unlike the sets of intervals maintained in Section 3, our construction in this section satisfies the property that a single update affects only a small number of intervals in 4 Dynamic Approximate Range Mode In this section we consider the dynamic variant of the approximate range mode problem. We maintain our sequence ca..b under insertions and deletions, so that for an arbitrary query range ca..b an approximate range mode can be found efficiently. The high-level approach is as follows. Similar to Section 3, for each j≤ lg1+ε n, our goal is to maintain a set of intervalsIj such that the mode of a query range ca..b occurs more than(1+ ε)j times if and only if ca..b contains an interval inIj. Then, for all j and each interval cl..r inIj we maintain the points(l, r, j) in a data structureD that supports the following range queries: given a query point(a, b), return the highest j such that a≤ l and r≤ b for at least one point(l, r, j) inD. the setsIj for all j. We now proceed with the technical argument. by Sx[i] the position of the ith occurrence of element x. Let Ix(l, r) denote the interval Let Sx denote the set of positions of the element x in the sequence c1..n. We will denote ′=(1+ ε)1~3 and fix x. There are f= Fx(c1..n) occurrences of element Now let δ= 1+ ε cSx[l]..Sx[r].  possible intervals Ix(l, r) in x in the full range c1..n. We will maintain a subset of thef setsIj,x, 1≤ j≤ऄlgδ nअ. We will not have need for nested intervals inIj,x; therefore, we can number each interval ofIj,x from left to right with sk the start of interval k and ek the end of interval k, satisfying sk≤ sk+1, ek≤ ek+1. We maintain the following two invariants on the intervals ofIj,x: (1) δj≤ ek− sk≤ δj+1, and (2)(ε ′~2)δj≤ sk+1− sk≤ ε ′ of positions of Sx not covered by an interval ofIj,x at either end is at most(ε ′~2)δj (so s1≤(ε ′~2)δj). From our invariants we get the following proposition. δj)+ O(1~ε (cid:73) Proposition 6. An interval Ix(l, r) intersects at most 2(r− l+1)~(ε ′) intervals ′ ofIj,x. ′~2)δj and f− rIj,x≤(ε δj, and the number 2 H. El-Zein, M. He, I. Munro, Y.Nekrich, and B. Sandlund XX:9 ′) lg n) time overall. be updated during rebuilds. it originated. ′) lg n)= O((lg n)~ε positions of x that fall in each interval. Furthermore, we space them so that Invariant (2) ′~2)δj and ε ′ δj elements between δj). ′ (cid:74) satisfying invariants (1) and (2) with a constant number of queries on Sx per interval, thus intervals at each level. However, the affect on pot is the same for each interval, and when we rebuild, we rebuild a superset of the intervals affected on update. It follows that the total elements of Sx (and thus positions in the original sequence c1..n) that fall between sk and ek. When we insert or delete an element x, by Proposition 6, we must update the pot values of To build these intervals, we must be able to efficiently search for elements by rank in Sx. As this will not dominate the update cost, we can use a typical order statistic Proof. By Invariant (2), we have a gap size of between(ε consecutive starting points of intervals ofIj,x. Since each interval has size at most δj+1, the total number of intervals intersecting Ix(l, r) is at most 2(r− l+ 1+ 2δj+1)~(ε For each interval Ix(sk, ek) ofIj,x, let pot(Ix(sk, ek))= ek− sk+ 1 denote the number of O(1~ε ′) lgδ n) intervals are affected. ′) intervals ofIj,x. Across all j, 1≤ j≤ऄlogδ nअ, O((1~ε During the updates, each affected pot(Ix(sk, ek)) value is incremented or decremented by one. If, for an interval Ix(sk, ek) inIj,x, Invariant (1) is violated by the update, then we rearrange the intervals in the neighborhood of Ix(sk, ek) as follows. Consider all intervals ofIj,x that intersect with Ix(sk, ek+1). By Proposition 6, there are O(1~ε ′) such intervals. ′~2)δjअ We remove said intervals and create new intervals in their place with exactlyऄ(1+ ε holds when the new intervals are inserted intoIj,x. tree, with O(lg f)= O(lg n) query and update time. We may construct the new intervals in O((1~ε ′) We can analyze the total cost of rebuilds as follows. On each update, we affect O(1~ε ′2) per update. amortized cost of rebuilds is∑ऄlogδ nअ j=1 O(lg n) and O((1~ε ′) lgδ n)= O(lg n~ε ′2) per update, but we have yet to describe the data structure that holds eachIj,x, which will also need to Consider each interval Ix(sk, ek) ofIj,x as a point(sk, ek, j). We store each interval of Ij,x, across all 1≤ j≤ऄlgδ nअ and all x, in a data structureD that supports the following range queries: given a query point(a, b), return the highest j such that a≤ l and r≤ b for at least one point(l, r, j) inD. Associated with each point, we keep the element x from which We first must consider the number of intervals (and thus points) stored inD. As before, δjअ). Across all we assume element x occurs f= Fx(c1..n) times in c1..n. ThenIj,x= O(f~ऄε ′ ′) or O(f~ε levels, we can bound the total number of intervals at O(f lgδ n)= O(f lg n~ε ′2). Accounting for all x, the number of intervals inD will be O(m)= O(min(n lg n~ε ′2)). , n~ε ′ (cid:73) Lemma 7. Data structureD can be stored in O(n lg n) bits, where n is the number of elements inD. Queries and updates can be supported in O(lg n~ lg lg n) time. interval fromIj,x for some x is contained in ca..b. Using data structureD from Lemma 7, we can compute the index j in O(lg n~ lg lg n) time. We return the element x associated with j. (cid:73) Lemma 8. The element x returned is a(1+ ε)-approximate mode of query range ca..b. Proof. If ca..b contains an interval fromIj,x, then x occurs at least δj times in ca..b. On the other hand, we can show that if some y occurs δj+3 times in ca..b, then ca..b contains an interval fromIj+1,y. Recall δj+3=(1+ ε ′)δj+2. Each interval ofIj+1,y has size at most (1~δj)⋅ O((1~ε ′2), respectively. So far we pay O(lg n~ε Now suppose we are given a query range ca..b. We find the largest j such that some Further, in each update we must update Sx and update the pot values. These take time We delay the proof of Lemma 7 to Appendix A. XX:10 On Approximate Range Mode and Range Selection ′ (cid:74) This gives us the main theorem for the section. δj elements of y between the start of every interval in δj+2 and there is a gap of at most ε ′ ′)δj+2, it must be that an interval ofIj+1,y falls in Ij+1,y. Then since ε δj+1+ δj+2<(1+ ε the query range ca..b. We therefore know δj≤ F(ca..b)< δj+3=(1+ )δj. It follows that x is a(1+ ε)-approximate mode of query range ca..b. (cid:73) Theorem 9. There exists an O(m lg m)-bit data structure, where m= min(n lg n~ε, n~ε2) that answers(1+ ε)-approximate range mode queries in O(lg m~ lg lg m) time. Insertions and deletions are supported in O(lg n~ε2) time. Proof. We have(1+ ε ′)3=(1+ ε) and(1+ ε)3= ε3+ 3ε2+ 3ε+ 1. The smallest exponent dominates O(1~ε ′= O(1~ε). As previously ′) since ε≤ 1 and thus ε stated, the number of intervals inD is O(m), where m= min(n lg n~ε, n~ε2). The space bound forD is thus O(m lg m)= Ω(n lg n) bits, which dominates the total space cost. The query time is O(lg m~ lg lg m). The update cost has four components: UpdatingD, updating Sα, and updating pot O(lg n~ε ′2)= O(lg n~ε2). Via Lemma 7, the cost of updatingD is O(lg m~ lg lg m). Since m is no more than n~ε2, lg m~ lg lg m is dominated by O(lg n~ε2). In total, the cost of updates is O(lg n~ε2). values for all affected intervals. As previously mentioned, the latter three are dominated by ′< ε≤ 1. Thus we have 1~ε (cid:74) We can use our dynamic data structure to obtain a result for approximate range mode queries on two-dimensional points. Our data structure can find approximate mode in the case when the query range is bounded on three sides (see Appendix A for the proof). (cid:73) Corollary 10. There exists a data structure that supports three-sided two-dimensional approximate range mode queries in O(log m) time and uses O(m log m) words of log n bits, where m= min(n lg n~ε, n~ε2). Approximate Range Median and Range Selection 5 In this section we present solutions to approximate range selection queries. As discussed previously, a range selection query takes two indices a, b of a sequence c1, . . . , cn and must We study two variants. In the first variant, the rank k is supplied prior to construction of the data structure. In the second variant, we allow k to be specified at query time. Here rank is defined so the ith smallest element in the range has rank i. We also support a specific return the index of an element x whose rank in ca..b is between k−α(b−a+1) and k+α(b−a+1). k depending on the size of the range, i.e. f(b− a+ 1)=ऄ(b− a+ 1)~2अ, which is the range median problem. We make the restrictions f(x)≤ f(x+ 1)≤ f(x)+ 1 and 1≤ f(x)≤ x. Ω(n) bits. Fixed Rank f(b− a+ 1)= k Selection. We first address the range selection variant with a fixed rank f(b− a+ 1)= k. We use a similar approach to the one in Lemma 4. We again assume n is a power of 2. At the top level, we store values mn~2,i,j (1≤ i, j≤ऄlg1+α nअ). Let ri= n~2−(1+ α)i and sj= n~2+1+(1+ α)j. Then mn~2,i,j is the element of rank f(sj− ri+1) in the range caeriae..ऄsjअ. We then build the structure recursively on the left and right halves of (cid:73) Theorem 11. Any one-dimensional approximate range median data structure requires We delay the proof of Theorem 11 to Appendix A. the full range. that mt,i,j is an α-approximate rank k element for range sa, . . . , sb. As for Theorem 4, to find the level to query, we find the highest set bit of a XOR b, then find the appropriate index mt,i,j via arithmetic. In total, the query takes constant time. (cid:73) Lemma 12. The above data structure returns an α-approximate fixed-rank k element of any query range ca..b. Given a query range ca..b, we find the appropriate element mt,i,j where a≤ t, t+ 1≤ b, and i and j are largest possible satisfying a≤ ri and sj≤ b. We return mt,i,j. Proof. Let x= ri− a and y= b− sj. Consider the size of x. If we let z=(1+ α)i, then x+ z<(1+ α)z. It follows x< αz. Since z≤(t− a+ 1), and applying similarly for y, we can show x< α(t− a+ 1) and y< α(b− t). The elements in the ranges represented by x and y shift the true rank k element of ca..b at most x+ y< α(b− a+ 1) ranks from mt,i,j. It follows We now analyze the space required. At the top level, we use O(lg2 (n)⋅lg n) bits, which n~α2) bits. Therefore our recurrence is S(n)= 2S(n~2)+ is equal to O( lg3 1+α O(lg3 n~α2). The recursion tree is leaf-heavy, with total space amounting to O(n~α2) bits. (cid:73) Theorem 13. There exists an O(n~α2)-bit data structure that supports one-dimensional α-approximate fixed-rank f(b− a+ 1)= k selection queries in constant time. Let δ= 1+ α~2. At the top level we now store values mn~2,i,j,l (1≤ i, j,≤ऄlgδ nअ, 0≤ l≤ae1~αae). Again, we let ri= n~2− δi and sj= n~2+ 1+ δj. However, this time, mn~2,i,j,l represents the element of rank ql= lα⋅(sj− ri+ 1)+ 1 in cri..sj. As ql may be fractional, for simplicity we just store both rankaeqlae andऄqlअ elements. We build this structure recursively on both Given a query sa..b, we again find the appropriate element mt,i,j,l where a≤ t, t+ 1≤ b, i and j are largest possible satisfying a≤ ri and sj≤ b, and l is chosen so ql is as close to k as Online Rank k Selection. Our data structure from the previous section can be adapted to support queries that specify the rank k at query time. We again assume n is a power of 2. lg2(1+α))= O(lg3 n halves of the full range. (cid:74) H. El-Zein, M. He, I. Munro, Y.Nekrich, and B. Sandlund XX:11 possible. We return mt,i,j,l. (cid:73) Lemma 14. The above data structure returns an α-approximate rank k element of any query range ca..b and specified rank k. Proof. Again let x= ri− a and y= b− sj. For the same reasons as in the proof of Lemma 12, we have x+ y< α(b− a+ 1)~2. There are no more than α⋅(sj− ri+ 1)≤ α⋅(b− a+ 1) ranks between each consecutive ql and ql+1. Thus our chosen ql satisfiesql− k<aeα(b− a+ 1)~2ae. It follows that mt,i,j,l is no more than α⋅(b− a+ 1) ranks away from the true rank k element in range ca..b. n~α3), from the additional space usage. Our recurrence is now T(n)= 2T(n~2)+ O(lg3 additional 1~α factor in the space cost at each level. This totals to O(n~α3) bits. (cid:73) Theorem 15. There exists an O(n~α3)-bit data structure that supports one dimensional The query time follows as in the previous section. However, we must account for the (cid:74) α-approximate online rank k selection queries in constant time. 1 References P. Bose, E. Kranakis, P. Morin, and Y. Tang. Approximate range mode and range median queries. In Proceedings of the 22nd Annual Symposium on Theoretical Aspects of Computer Science. XX:12 On Approximate Range Mode and Range Selection 2 G. S. Brodal, B. Gfeller, A. G. Jørgensen, and P. Sanders. Towards optimal range medians. Theoretical Computeer Science, 412(24):2588 -- 2601, 2011. 6 5 4 3 G. S. Brodal and A. G. Jørgensen. Data structures for range median queries. In Proceedings of the 20th International Symposium on Algorithms and Computation, pages 822 -- 831, 2009. T. M. Chan, S. Durocher, K. G. Larsen, J. Morrison, and B. T. Wilkinson. Linear-space data structures for range mode query in arrays. Theory of Computing Systems, 55(4):719 -- 741, 2014. T. M. Chan and B. T. Wilkinson. Adaptive and approximate orthogonal range counting. ACM Trans. Algorithms, 12(4):45:1 -- 45:15, 2016. P. F. Dietz. Fully persistent arrays (extended array). In Proceedings of Workshop on Algorithms and Data Structures (WADS), pages 67 -- 74, 1989. 7 H. El-Zein, M. He, J. I. Munro, and B. Sandlund. Improved time and space bounds for dynamic range mode. In Proceedings of the 26th Annual European Symposium on Algorithms, pages 25:1 -- 25:13, 2018. J. Fischer and V. Heun. Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM Journal on Computing, 40(2):465 -- 492, 2011. 9 M. L. Fredman and D. E. Willard. Blasting through the information theoretic barrier with fusion trees. In Proceedings of the Twenty-second Annual ACM Symposium on Theory of Computing, STOC '90, pages 1 -- 7, 1990. T. Gagie, S. J. Puglisi, and A. Turpin. Range quantile queries: Another virtue of wavelet trees. In Proceedings of the 16th International Symposium on String Processing and Information Retrieval, pages 1 -- 6, 2009. P. Gawrychowski and P. K. Nicholson. Optimal encodings for range top- k k , selection, and min-max. In Proceedings of the 42nd International Colloquium on Automata, Languages, and Programming, pages 593 -- 604, 2015. 8 10 11 12 B. Gfeller and P. Sanders. Towards optimal range medians. In Proceedings of the 36th International Colloquium on Automata, Languages and Programming, pages 475 -- 486, 2009. 13 M. Greve, A. G. Jørgensen, K. D. Larsen, and J. Truelsen. Cell probe lower bounds and In Proceedings of the 37th International Colloquium on approximations for range mode. Automata, Languages and Programming, pages 605 -- 616, 2010. 14 R. Grossi, J. Iacono, G. Navarro, R. Raman, and S. S. Rao. Asymptotically optimal encodings of range data structures for selection and top-k queries. ACM Transactions on Algorithms, 13(2):28:1 -- 28:31, 2017. 15 M. He, J. I. Munro, and P. K. Nicholson. Dynamic range selection in linear space. In Proceedings of the 22nd International Symposium, pages 160 -- 169, 2011. 16 A. G. Jørgensen and K. G. Larsen. Range selection and median: Tight cell probe lower bounds and adaptive data structures. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms, pages 805 -- 813, 2011. 17 D. Krizanc, P. Morin, and M. H. M. Smid. Range mode and range median queries on lists and trees. Nord. J. Comput., 12(1):1 -- 17, 2005. 18 M. Patrascu. Succincter. In 2008 49th Annual IEEE Symposium on Foundations of Computer Science, pages 305 -- 313, 2008. 19 H. Petersen. Improved bounds for range mode and range median queries. In Proceedings of the 34th Conference on Current Trends in Theory and Practice of Computer Science, pages 418 -- 423, 2008. 20 H. Petersen and S. Grabowski. Range mode and range median queries in constant time and sub-quadratic space. Information Processing Letters, 109(4):225 -- 228, 2009. H. El-Zein, M. He, I. Munro, Y.Nekrich, and B. Sandlund XX:13 A Omitted Proofs any data structure that answers one-dimensional approximate range mode queries. Here we allow arbitrary . Proof of Theorem 1. Using a simple proof we show that Ω(n~(1+ ε)) bits are required for Given an approximation factor 1+ ε, divide the sequence S of size n intoaen~(2k)ae full blocks each of size 2k, where k=ऄ1+ εअ+1, and, if n is not a multiple of 2k, a non-full block of size n mod 2k. Denote by t1, . . . , tk+1 k+ 1 arbitrary, distinct colors. We say that S satisfies property (∗) if for each full block b in S one of the following two conditions hold: either b consists of t1 repeated k times followed by t2, . . . , tk+1, Clearly, the number of sequences that satisfy (∗) is at least 2aen~(2k)ae, since there exist or b consists of t2, . . . , tk+1 followed by t1 repeated k times. aen~(2k)ae full blocks in a sequence of size n and each of them can have one of two different values. Moreover, for any two distinct sequences S1 and S2 satisfying (∗) differing at full Proof of Lemma 7. Let P denote the set of points to be stored in our data structure. block b, there exists at least one approximate range mode query, namely the query that asks for an approximate mode of b, that will return different values (either a value from the first k position in the block or from the last k positions of the block). Thus, the information theoretic lower bound for storing an approximate range mode data structure is (cid:74) Ω(lg 2aen~(2k)ae)= Ω(aen~(2k)ae)= Ω(n) bits. Here we use ε > 0 independently of the rest of the section. We start by considering the special case when the second coordinate is bounded by lgε n, i.e., r ≤ lgε n for all (l, r, j)∈ P. In this case it is sufficient to store lg n points for every possible value of b: let maxr,j denote the biggest first coordinate of a point(l ′= r, j ′= j (maxr,j= max{ l ′= j}. The answer to a query(a, b) is the largest j that satisfies a≤ maxr,j for some r≤ b. We keep all values maxr,j such that P contains at least one point(l, r, j) for some l, and store them in increasing order. We group them in blocks of size Θ(lg1−ε n) and we keep a global lookup table of size o(n) bits that allows Also, in a local lookup table of size O(lg3ε n) bits we store for each block and every answering queries within any possible block. ′) in P with r ′)∈ P and r ′= r, j ′(l possible value of r the index of the block preceding it which maximizes the value of j given r. We also store a fusion tree on the values maxr,j so that we can compute the rank of a within these values in constant time. Given a query, we compute in constant time the block which the predecessor of a belongs to and use table lookup on that block and one other block preceding it to get the answer. Updates also take constant time since the size of individual blocks and the local lookup table fit in a single word. A general query can be reduced to the above described special case by using a range tree with node degree lgε n that splits the points on the value of their second coordinate. Although every point is stored in O(lg n~ lg lg n) nodes, our data structure uses linear space. Let P(u) denote the set of points stored in a node u. We replace the second coordinate of each point p∈ P(u) with the index i of the child node ui such that p∈ P(ui). We keep the above described special case data structure in every node P(u), but we do not store the set P(u) itself. A query interval can be fully covered by O(lg n~ lg lg n) tree nodes. We query the data structure in each one of them and return the maximum value j in O(lg n~ lg lg n) time. Similarly, an update affects the special case data structure in O(lg n~ lg lg n) nodes and requires O(lg n~ lg lg n) time. The total space usage is O(n log n) bits because we spend O(min(log2+ε n,P(u) lg n) bits in each node u of the range tree. To prove this bound, we classify nodes into low and ′ ′ , r , j ′ ′ , r , j XX:14 On Approximate Range Mode and Range Selection two conditions hold: a sequence of size n and each block can have one of two different values. Moreover for Proof of Corollary 10. Using the technique introduced by Dietz in [6], we can transform (cid:74) high nodes. Low nodes are the nodes in the lowest(1+ 2~ε) levels of the tree and the rest of the nodes are high nodes. We also store the set of points P(u) in every low node u. Thus we spend O(P(u) lg n) bits in every low node, so the total space consumed by all low nodes is O((1~ε)n lg n) bits. We spend O(lg2+ε n)= O(P(u)) bits in every high node because P(u)≥ lg2+ε n. Since the total number of points in all P(u) is O(n(lg n~ lg lg n)), the total space consumed by high nodes is O(n(lg n~ lg lg n)) bits. a data structure that supports updates in u(n) time and queries in q(n) time into an offline partially persistent data structure that answers queries in O(q(n)⋅ log log n) time and uses O(n⋅ u(n)) words of space. Using sweep line technique, we can transform an offline Proof of Theorem 11. Assume n is even. Divide the sequence S of size n to n~2 blocks each of size 2. We say that S satisfies property (∗) if for each block b in S one of the following either b consists of{1, 2}, or b consists of{2, 1}. Clearly, the number of sequences that satisfy (∗) is 2(n~2) since there exists n~2 blocks in any two distinct sequences S1 and S2 satisfying(∗) differing at block b, the approximate structure is Ω(lg 2(n~2))= Ω(n~2)= Ω(n) bits. range selection query must be exact on block b, and therefore must return different values. Thus, the information theoretic lower bound for storing an approximate range median data (cid:74) partially persistent data structure for one-dimensional queries into a static data structure for (cid:74) three-sided queries with the same time and space bounds.
1507.02384
1
1507
2015-07-09T05:58:47
Maximum matching width: new characterizations and a fast algorithm for dominating set
[ "cs.DS", "cs.DM", "math.CO" ]
We give alternative definitions for maximum matching width, e.g. a graph $G$ has $\operatorname{mmw}(G) \leq k$ if and only if it is a subgraph of a chordal graph $H$ and for every maximal clique $X$ of $H$ there exists $A,B,C \subseteq X$ with $A \cup B \cup C=X$ and $|A|,|B|,|C| \leq k$ such that any subset of $X$ that is a minimal separator of $H$ is a subset of either $A, B$ or $C$. Treewidth and branchwidth have alternative definitions through intersections of subtrees, where treewidth focuses on nodes and branchwidth focuses on edges. We show that mm-width combines both aspects, focusing on nodes and on edges. Based on this we prove that given a graph $G$ and a branch decomposition of mm-width $k$ we can solve Dominating Set in time $O^*({8^k})$, thereby beating $O^*(3^{\operatorname{tw}(G)})$ whenever $\operatorname{tw}(G) > \log_3{8} \times k \approx 1.893 k$. Note that $\operatorname{mmw}(G) \leq \operatorname{tw}(G)+1 \leq 3 \operatorname{mmw}(G)$ and these inequalities are tight. Given only the graph $G$ and using the best known algorithms to find decompositions, maximum matching width will be better for solving Dominating Set whenever $\operatorname{tw}(G) > 1.549 \times \operatorname{mmw}(G)$.
cs.DS
cs
MAXIMUM MATCHING WIDTH: NEW CHARACTERIZATIONS AND A FAST ALGORITHM FOR DOMINATING SET JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE Abstract. We give alternative definitions for maximum matching width, e.g. a graph G has mmw(G) ≤ k if and only if it is a subgraph of a chordal graph H and for every maximal clique X of H there exists A, B, C ⊆ X with A ∪ B ∪ C = X and A,B,C ≤ k such that any subset of X that is a minimal separator of H is a subset of either A, B or C. Treewidth and branchwidth have alternative definitions through intersections of subtrees, where treewidth focuses on nodes and branchwidth focuses on edges. We show that mm-width combines both aspects, focusing on nodes and on edges. Based on this we prove that given a graph G and a branch decomposition of mm-width k we can solve Dominating Set in time O∗(8k), thereby beating O∗(3tw(G)) whenever tw(G) > log3 8 × k ≈ 1.893k. Note that mmw(G) ≤ tw(G) + 1 ≤ 3 mmw(G) and these inequalities are tight. Given only the graph G and using the best known algorithms to find decompositions, maximum matching width will be better for solving Dominating Set whenever tw(G) > 1.549 × mmw(G). 1. Introduction The treewidth tw(G) and branchwidth bw(G) of a graph G are connectivity parameters of importance in algorithm design. By dynamic programming along the associated tree decomposition or branch decomposition one can solve many graph optimization problems in time linear in the graph size and exponential in the parameter. For any graph G, its treewidth and branchwidth is related by bw(G) ≤ tw(G) + 1 ≤ 3 2 bw(G) [15]. The two parameters are thus equivalent with respect to fixed parameter tractability (FPT), with a problem being FPT parameterized by treewidth if and only if it is FPT parameterized by branchwidth. For some of these problems the best known FPT algorithms are optimal, up to some complexity theoretic assumption. For example, Minimum Dominating Set Problem can be solved in time O∗(3tw(G)) when given a decomposition of treewidth tw(G) [17] but Date: August 26, 2018. Key words and phrases. FPT algorithms, treewidth, dominating set. The first author is supported by Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Science, ICT & Future Planning (2011-0011653). 1 2 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE not in time O∗((3 − )tw(G)) for any  > 0 unless the Strong Exponential Time Hypothesis (SETH) fails [12]. Recently, a graph parameter equivalent to treewidth and branchwidth was introduced, the maximum matching width (or mm-width) mmw(G), defined by a branch decomposition over the vertex set of the graph G, using the symmetric submodular cut function obtained by taking the size of a maximum matching of the bipartite graph crossing the cut (by Konig's Theorem equivalent to minimum vertex cover) [18]. For any graph G we have mmw(G) ≤ bw(G) ≤ tw(G) + 1 ≤ 3 mmw(G) and these inequalities are tight, for example any balanced decomposition tree will show that mmw(Kn) = (cid:100) n 3(cid:101). In this paper we show that given a branch decomposition over the vertex set of mm-width k we can solve Dominating Set in time O∗(8k). This runtime beats the O∗(3tw(G)) algorithm for treewidth [17] whenever tw(G) > log3 8 × k ≈ 1.893k. If we assume only G as input, then since mm-width has a submodular cut function [16] we can approximate mm-width to within a factor 3 mmw(G) + 1 in O∗(23 mmw(G)) time using the generic algorithm of [13], giving a total runtime for solving dominating set of O∗(29 mmw(G)). For treewidth we can in O∗(23.7 tw(G)) time [1] get an approximation to within a factor (3 + 2/3) tw(G) giving a total runtime for solving dominating set of O∗(33.666 tw(G))1. This implies that on input G, using maximum matching width gives better exponential factors whenever tw(G) > 1.549 mmw(G). Our results are based on a new characterization of graphs of mm-width at most k, as intersection graphs of subtrees of a tree. It can be formulated as follows, encompassing analogous formulations for all three parameters mm-width (respectively treewidth, respectively branchwidth): For any k ≥ 2 a graph G on vertices v1, v2, ..., vn has mmw(G) ≤ k (resp. tw(G) ≤ k−1, resp. bw(G) ≤ k) if and only if there is a tree T of max degree at most 3 with nontrivial subtrees T1, T2, ..., Tn such that if vivj ∈ E(G) then subtrees Ti and Tj have at least one node (resp. node, resp. edge) of T in common and for each edge (resp. node, resp. edge) of T there are at most k subtrees using it. Thus, while treewidth has a focus on nodes and branchwidth a focus on edges, mm-width combines the aspects of both. We also arrive at the following alternative characterization: a graph G has mmw(G) ≤ k if and only if it is a subgraph of a chordal graph H and for every maximal clique X of H there exists A, B, C ⊆ X with A∪ B ∪ C = X and A,B,C ≤ k such that any subset of X that is a minimal separator of H is a subset of either A, B or C. In fact, using techniques introduced by Bodlaender and Kloks in [4] these new characterizations will also allow us to compute a branch decomposition of optimal mm-width in FPT time [9]. In section 2 we give 1Note that there is also a O∗(ctw(G)) time 3-approximation of treewidth [3], but the c is so large that the approximation alone has a bigger exponential part than the entire Dominating Set algorithm when using the 3.666-approximation. MAXIMUM MATCHING WIDTH 3 definitions. In section 3 we define unique minimum vertex covers for any bipartite graph, show some monotonicity properties of these, and use this to give the new characterizations of mm-width. In section 4 we give the dynamic programming algorithm for dominating set. We end in section 5 with some discussions. 2. Definitions For a simple and loopless graph G = (V, E) and its vertex v, let N (v) be the set of all vertices adjacent to v in G, and N [v] = N (v) ∪ {v}. For a subset S of V (G), let N (S) be the set of all vertices that are not in S but are adjacent to some vertex of S in G, and N [S] = N (S) ∪ S. A tree decomposition of a graph G is a pair (T,{Xt}t∈V (T )) consisting of a tree T and a family {Xt}t∈V (T ) of vertex sets Xt ⊆ V (G), called bags, satisfying the following three conditions: (1) each vertex of G is in at least one bag, (2) for each edge uv of G, there exists a bag that contains both u and v, (3) for vertices t1, t2, t3 of T , if t2 is on the path from t1 to t3, then and Xt1 ∩ Xt3 ⊆ Xt2. The width of a tree decomposition (T,{Xt}t∈V (T )) is maxt∈V (T )Xt− 1. The treewidth of G, denoted by tw(G), is the minimum width over all possible tree decompositions of G. A branch decomposition over X, for some set of elements X, is a pair (T, δ), where T is a tree over vertices of degree at most 3, and δ is a bijection from the leaves of T to the elements in X. Any edge ab disconnects T into two subtrees Ta and Tb. Likewise, any edge ab partitions the elements of X into two parts A and B, namely the elements mapped by δ from the leaves of Ta, and of Tb, respectively. An edge ab ∈ E(T ) is said to induce the partition (A, B). A rooted branch decomposition is a branch decomposition (T, δ) where we subdivide an edge of T and make the new vertex the root r. In a rooted branch decomposition, for an internal vertex v ∈ V (T ), we denote by δ(v) the union of δ(l) for all leaves of l having v as its ancestor. Given a symmetric (f (A) = f (A)) function f : 2X → R, using branch decompositions over X, we get a nice way of defining width parameters: For a branch decomposition (T, δ) and edge e ∈ T , we define the f -value of the edge e to be the value f (A) = f (B) where A and B are the two parts of the partition induced by e in (T, δ), denoted f (e). We define the f -width of branch decomposition (T, δ) to be the maximum f -value over all edges of T , denoted f (T, δ): maxe∈T{f -value of e}. For set X of elements, we define the f -width of X to be the minimum f -width over all branch decompositions over X. If X ≤ 1, then X admits no branch decomposition and we define its f -width to be f (∅). 4 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE For a graph G and a subset S ⊆ E(G), the branchwidth bw(G) of G is the f -width of E(G) where f : 2E(G) → R is a function such that f (S) is the number of vertices that are incident with an edge in S as well as an edge in E(G) \ S. The Maximum Matching-width of a graph G, mm-width in short, is a width parameter defined through branch decompositions over V (G) and the cardinality of matchings. For a subset S ⊆ V (G), the Maximum Matching- value is defined to be the size of a maximum matching in G[S, V (G) \ S], denoted mm(S). The mm-width of a graph G, denoted mmw(G), is the f -width of V (G) for f = mm. 3. Subtrees of a tree representation for mm-width 3.1. Konig covers. In this subsection, we will define canonical minimum vertex covers for any bipartite graph. Our starting point is a well-known result in graph theory. Theorem 3.1 (Konig's Theorem [10]). Given a bipartite graph G, for any maximum matching M and minimum vertex cover C of G, the number of edges in M is the same as the number of vertices in C; M = C. Let (A, B) be the vertex partition of G. This statement can be proved in multiple ways. The harder direction, that a maximum matching is never smaller than a minimum vertex cover, does not hold for general graphs, and is usually proven by taking a maximum matching M and constructing a vertex cover C having size exactly M, as follows: For each edge ab ∈ M (where a ∈ A, and b ∈ B), if ab is part of an alternating path starting in an unsaturated vertex of A, then put b into C, otherwise put a into C. For a proof that C indeed is a minimum vertex cover of G, see e.g. [7]. We will call the vertex cover C constructed by the above procedure the A-Konig cover of G. A B-Konig cover of G is constructed similarly by changing the roles of A and B (see Figure 1). Lemma 3.2 below shows that the A B A B Figure 1. A-Konig cover and B-Konig cover. A-Konig cover will, on the A-side consist of the A-vertices in the union over all minimum vertex covers, and on the B-side will consist of the B-vertices in the intersection over all minimum vertex covers. MAXIMUM MATCHING WIDTH 5 Lemma 3.2. For a bipartite graph G = (A ∪ B, E) and minimum vertex cover C of G, the set C is the A-Konig cover of G if and only if for any minimum vertex cover C(cid:48) of G we have A∩ C(cid:48) ⊆ A∩ C, and B ∩ C(cid:48) ⊇ B ∩ C. Proof. Let M be a maximum matching of G, and C∗ the A-Konig cover of G constructed from M . Since both C∗ and C are minimum vertex covers, by showing that for any minimum vertex cover C(cid:48) of G we have A∩ C(cid:48) ⊆ A∩ C∗, and B ∩ C(cid:48) ⊇ B ∩ C∗, as a consequence will also show that C(cid:48) = C∗ if and only if for all minimum vertex covers C(cid:48) of G we have A ∩ C(cid:48) ⊆ A ∩ C and B ∩ C(cid:48) ⊇ B ∩ C. So this is precisely what we will do. Let C(cid:48) be any minimum vertex cover, and b any vertex in C∗ ∩ B. We will show that b ∈ C(cid:48), and from that conclude B ∩ C(cid:48) ⊇ B ∩ C∗. As b ∈ C∗ there must be some alternating path from b to an unsaturated vertex u ∈ A. The vertices b and u are on different sides of the bipartite graph, so the alternating path P between u and b must be of some odd length 2k + 1. From Theorem 3.1, we deduce that one and only one endpoint of each edge in M must be in C(cid:48). As each vertex in V (P ) is incident with at most two edges of P , and all edges of P must be covered by C(cid:48), we need at least (cid:100)(2k + 1)/2(cid:101) = k + 1 of the vertices in V (P ) to be in C(cid:48). However, the vertices of V (P ) − b are incident with only k edges of M . Therefore at most k of the vertices V (P ) − b can be in C(cid:48). In order to have at least k + 1 vertices from V (P ) in C(cid:48) we thus must have b ∈ C(cid:48). We now show that C(cid:48) ∩ A ⊆ C∗ by showing that a ∈ C∗ if a ∈ A∩ C(cid:48). Let E∗ and E(cid:48) be the edges of G not covered by C∗ ∩ B and C(cid:48) ∩ B, respectively. Since C∗ ∩ B ⊆ C(cid:48) ∩ B, the set E∗ must contain all the edges of E(cid:48). As C(cid:48) is a minimum vertex cover, and all edges other than E(cid:48) are covered by C(cid:48) ∩ B, a vertex a of A is in C(cid:48) only if it covers an edge e ∈ E(cid:48). As E(cid:48) ⊆ E∗, we have e ∈ E∗, and hence C∗ must also cover e by a vertex in A. As G is bipartite, the only vertex from A that covers e is a, and we can conclude that a ∈ C∗. (cid:3) The following lemma establishes an important monotonicity property for A-Konig covers. Lemma 3.3. Given a graph G and tripartition (A, B, X) of the vertices V (G), the following two properties holds for the A-Konig cover CA of G[A, B∪ X] and any minimum vertex cover C of G[A ∪ X, B]. (1) A ∩ C ⊆ A ∩ CA (2) B ∩ C ⊇ B ∩ CA. Proof. To prove this, we will show that it holds for X = {x}, and then by transitivity of the subset relation and that a Konig cover is also a minimum vertex cover, it must hold also when X is any subset of V (G). Let A(cid:48) = A + x and B(cid:48) = B + x, and let C(cid:48) be the A-Konig cover of the graph G[A, B] (be aware that this graph has one less vertex than G). We will break the proof into four parts, namely A ∩ C ⊆ A ∩ C(cid:48), A ∩ C(cid:48) ⊆ A ∩ CA, B ∩ CA ⊆ B ∩ C(cid:48), and B ∩ C(cid:48) ⊆ B ∩ C. Again, by transitivity of the subset 6 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE relation, this will be sufficient for our proof. We now look at each part separately. A ∩ C ⊆ A ∩ C(cid:48): Two cases: C = C(cid:48) and C > C(cid:48). We do the latter first. This means that C(cid:48) ∪ {x} must be a minimum vertex cover of G[A(cid:48), B]. Therefore the A(cid:48)-Konig cover C∗ of G[A(cid:48), B(cid:48)] must contain (C(cid:48) ∪ {x}) ∩ A(cid:48). This means that C∗ is a minimum vertex cover of G[A, B], and by C(cid:48) being the A-Konig cover of G[A, B], we have from Lemma 3.2 that C(cid:48)∩ A ⊇ C∗∩ A. And since C∗ is a A(cid:48)-Konig cover of G[A(cid:48), B] we have C(cid:48) ∩ A(cid:48) ⊇ C ∩ A(cid:48) and can conclude that C(cid:48) ∩ A ⊇ A ∩ C. Now assume that the two vertex covers are of equal size. Clearly x (cid:54)∈ C, as then C − x is a smaller vertex cover of G[A, B] than C(cid:48), so x is not in C. This means that C is a minimum vertex cover of G[A, B], so all vertices in A ∩ C must be in C(cid:48) by Lemma 3.2. A ∩ C(cid:48) ⊆ A ∩ CA: Suppose C(cid:48) is smaller than CA. This means C(cid:48) + x is a minimum vertex cover of G[A, B(cid:48)], and hence (C(cid:48) + x) ∩ A ⊆ CA ∩ A by Lemma 3.2. On the other hand, if C(cid:48) is of the same size as CA. Then CA is a minimum vertex cover of G[A, B], and so x (cid:54)∈ CA. This means CA ∩ N (x) ∩ A ⊆ CA ∩ A. And as CA is a minimum vertex cover of G[A, B], we know from Lemma 3.2 that CA∩ N (x)∩ A ⊆ C(cid:48). In particular, this means C(cid:48) covers all the edges of G[A, B(cid:48)] not in G[A, B], which means that C(cid:48) is also a minimum vertex cover of G[A, B(cid:48)]. This latter observation means that C(cid:48) ∩ A ⊆ CA ∩ A from Lemma 3.2. B ∩ CA ⊆ B ∩ C(cid:48): Suppose C(cid:48) is smaller than CA. This means C(cid:48) + x is a minimum vertex cover of G[A, B(cid:48)], and thus B(cid:48) ∩ (C(cid:48) + x) ⊇ B(cid:48) ∩ CA. Which implies that B ∩ C(cid:48) ⊇ B ∩ CA. Now assume that C(cid:48) is of the same size as CA. This means CA is a minimum vertex cover of G[A, B] and x (cid:54)∈ CA. Furthermore, this means N (x) ∩ A ⊆ CA ∩ A ⊆ C(cid:48) ∩ A by Lemma 3.2 and we conclude that C(cid:48) is a minimum vertex cover of G[A, B(cid:48)]. By Lemma 3.2, this means B(cid:48) ∩ CA ⊆ B(cid:48) ∩ C(cid:48) and in particular B ∩ CA ⊆ B ∩ C(cid:48). B ∩ C(cid:48) ⊇ B ∩ C: Suppose C(cid:48) is smaller than C. This means C(cid:48) + x is a minimum vertex cover of G[A, B(cid:48)], and hence by Lemma 3.2 we have B(cid:48) ∩ (C(cid:48) + x) ⊆ B(cid:48) ∩ C2, which implies B ∩ C(cid:48) ⊆ B ∩ C2. Now suppose C(cid:48) is of the same size as C. This means that C is a minimum vertex cover of G[A, B], and hence we immediately get C ∩ B ⊇ C(cid:48) ∩ B by Lemma 3.2. that CA ∩ B ⊆ C ∩ B, and C ∩ A ⊆ CA ∩ A. This completes the proof, as we by transitivity of the subset relation have (cid:3) We are now ready to prove an important connectedness property of Konig covers that arise from cuts of a given branch decomposition. Lemma 3.4. Given a connected graph G and rooted branch decomposition (T, δ) over V (G), for any node v in T , where C are the descendants of v and Cu means the δ(u)-Konig cover of G[δ(u), δ(u)], we have that  (cid:91) Cx x∈V (T )\C (cid:33)  ∩ (cid:32)(cid:91) x∈C Cx ⊆ Cv . MAXIMUM MATCHING WIDTH 7 Proof. First notice for all x ∈ C, since Cx is a δ(x)-Konig cover and Cv a minimum vertex cover, from Lemma 3.3 we have that Cx ∩ δ(x) ⊆ Cv ∩ δ(x). In particular, since δ(x) ⊆ δ(v), we have that Cx \ δ(v) ⊆ Cv \ δ(v) ⊆ Cv. Since each vertex of V (G) is either in δ(v) or not in δ(v), by showing that also for all x ∈ (V (T ) \ C) we have Cx ∩ δ(v) ⊆ Cv we can conclude that the lemma holds: For all x ∈ V (T ) \ C either δ(v) ⊆ δ(x) (when x is an ancestor of v) or δ(v) ⊆ δ(x) (when x is neither a descendant of v nor an ancestor of v), in either case, we can apply the δ(v)-Konig cover Cv of G[δ(v), δ(v)] and the minimum vertex cover Cx of G[δ(x), δ(x)] to Lemma 3.3 and see that Cx ∩ δ(v) ⊆ Cv ∩ δ(v) ⊆ Cv. (cid:3) 3.2. The new characterization of mmw. We say a graph is nontrivial if it has an edge. Theorem 3.5. A nontrivial graph G = (V, E) has mmw(G) ≤ k if and only if there is a tree T of max degree at most 3 and for each vertex u ∈ V a nontrivial subtree Tu of T such that i) if uv ∈ E then the subtrees Tu and Tv have at least one vertex of T in common, and ii) for every edge of T there are at most k subtrees using this edge. Proof. Forward direction: Let (T, δ) be a rooted branch decomposition over V having mm-width at most k, and assume G has no isolated vertices. For each edge e = uv of T , with u a child of v, assign the δ(u)-Konig cover Cu of G[δ(u), V \ δ(u)] to the edge uv. For each vertex x of G, define the set of edges of T whose Konig cover contains x and let Tx be the sub-forest of T induced by these edges. Using Lemma 3.4 we first show that Tx is a connected forest and thus a subtree of T . Consider edge e = uv of T . Let p be the lowest common ancestor of u and v. For every vertex w on the path from p to u and on the path from p to v, except p, we know that exactly one of u, v is a descendant of w. By Lemma 3.4, (Cu ∩ Cv) ⊆ Cw. It means that if a vertex x of G is in both Cu and Cv then it is also in Cw, which implies that Tx is connected. Now, since the branch decomposition has mm-width at most k part i) in the statement of the Theorem holds. For an arbitrary edge ab of G, consider any edge e of T on the path from δ−1(a) to δ−1(b) and the partition (A, B) induced by e where a ∈ A, b ∈ B. Then the Konig cover of e must contain one of a and b, and thus, ii) holds as well. Finally, Tx is nontrivial because the edge of T incident with a leaf δ−1(x) assigns the Konig cover {x}. If G has isolated isolated vertices, Tx is not nontrivial for isolated vertex x. We fix this by setting Tx to consist exactly of the edge incident with δ−1(x), for any isolated vertex x of G. Backward direction: For each given subtree {Tu}u∈V of T , choose an edge in Tu (it is also in T ) and append in the tree T a leaf (cid:96)u, and extend Tu to contain (cid:96)u and set δ((cid:96)u) = u. Exhaustively remove leaves (from both T and the subtrees) that are not mapped by δ. Call the resulting tree T (cid:48) and u}u∈V and T (cid:48) still satisfy i) and ii). subtrees {T (cid:48) u}u∈V . Note that subtrees {T (cid:48) 8 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE We claim that (T (cid:48), δ) is a branch decomposition of mm-width at most k. It is clearly a branch decomposition over V , and for any edge e of T (cid:48), if we choose S ⊆ V to be those u with Tu using this edge e, then this will be a vertex cover of the bipartite graph H given by this edge e, and of size at most k because for an edge xy in H, one of Tx and Ty must contain e. (cid:3) In the introduction we mentioned analogous characterizations of treewidth and branchwidth, for these see e.g. [14]. Another alternative characterization is the following. Corollary 3.6. A graph G has mmw(G) ≤ k if and only if it is a subgraph of a chordal graph H and for every maximal clique X of H there exists A, B, C ⊆ X with A ∪ B ∪ C = X and A,B,C ≤ k such that any subset of X that is a minimal separator of H is a subset of either A, B or C. We only sketch the proof, which is similar to an alternative characterization of branchwidth given in [14]. We say a tree is ternary if it has maximum degree at most 3. Note that a graph is chordal if and only if it is an intersection graph of subtrees of a tree [8]. In the forward direction, take the chordal graph resulting from the subtrees of ternary tree representation. In the backward direction, take a clique tree of H and make a ternary tree decomposition (which is easily made into a subtrees of ternary tree representation) by for each maximal clique X of degree larger than three making a bag X with three neighboring bags A, B, C. If minimal separators S1, ..., Sq subset of X are contained in A make a path extending from bag A of q new bags also containing A, with a single bag containing Si, 1 ≤ i ≤ q attached to each of them. These ternary subtrees, one for each maximal clique, is then connected together in a tree by the structure of the clique tree, adding an edge between bags of identical minimal separators. 4. Fast DP for Dominating Set parameterized by mm-width For graph G = (V, E) a subset of vertices S ⊆ V is said to dominate the vertices in N [S], and it is a dominating set if N [S] = V . Given a rooted branch decomposition (T, δ) of G of mm-width k, we will in this section give an O∗(8k) algorithm for computing the size of a Minimum Dominating Set of G. This by an algorithm doing dynamic programming along a rooted tree decomposition (T (cid:48),{Xt}t∈V (T (cid:48))) of G that we compute from (T, δ) as follows. Given a rooted branch decomposition (T, δ) of G having mm-width k the proof of Theorem 3.5 yields a polynomial-time algorithm (using an algorithm for maximum matching in bipartite graphs) finding a family {Tu}u∈V (G) of nontrivial subtrees of T (note we can assume T is a rooted tree with root of degree two and all other internal vertices of degree three) such that i) if uv ∈ E(G) then the subtrees Tu and Tv have at least one vertex of T (cid:48) in common, and ii) for every edge of T (cid:48) there are at most k subtrees using this edge. From this it is easy to construct a rooted tree decomposition (T (cid:48),{Xt}t∈V (T (cid:48))) of G, having the properties described in Figure 2. Let T (cid:48) MAXIMUM MATCHING WIDTH 9 be a tree with vertex set A ∪ B ∪ {r} where A is the set of edges of T , B is the set of non-root vertices (all of degree-3) of T , and r is the root of T and also the root of T (cid:48). Two vertices e, v of T (cid:48) are adjacent if and only if e ∈ A and v ∈ B ∪ {r} are incident in T . For a vertex e ∈ A, let Xe be the set of vertices in G such that if a subtree Tw uses edge e of T , then w ∈ Xe. For a vertex v ∈ B, let Xv be the set of vertices in G such that for the three incident edges e1, e2, e3 of v in T , Xv = Xe1 ∪ Xe2 ∪ Xe3. Let Xr = Xe1 ∪ Xe2 if e1 and e2 are incident with r in T . Then (T (cid:48),{Xt}t∈V (T (cid:48))) is a tree decomposition of G with a root r, having the properties described in Figure 2, which we will use in the dynamic programming. Let us now define the relevant subproblems for the dynamic programming over this tree decomposition. For node t of the tree we denote by Gt the graph induced by the union of Xu where u is a descendant of t. A coloring of a bag Xt is a mapping f : Xt → {1, 0,∗} with the meaning that: all vertices with color 1 are contained in the dominating set of this partial solution in Gt, all vertices with color 0 are dominated, while vertices with color * might be dominated, not dominated, or in the dominating set. Thus the only restriction is that a vertex with color 1 must be a dominator, and a vertex with color 0 must be dominated. Thus, for any S ⊆ V (G) there is a set c(S) of 3S2N (S) colorings f : V (G) → {1, 0,∗} compatible with taking S as set of dominators, with vertices of S colored 1, 0 or ∗, vertices of N (S) colored 0 or ∗, and the remaining vertices colored ∗. For a coloring f of bag Xt we denote by T [t, f ] (and view this as a 'Table' of values) the minimum S over all S ⊆ V (Gt) such that there exists f(cid:48) ∈ c(S) with f(cid:48)Xt = f and f(cid:48)V (Gt)\Xt having everywhere the value 0. In other words, the minimum size of a set S of vertices of Gt that dominate all vertices in V (Gt) \ Xt, with a coloring f(cid:48) compatible with taking S as set of dominators, such that f(cid:48) restricted to Xt gives f . If no such set S exists, then T [t, f ] = ∞. Note that the size of the minimum dominating set of G is the minimum value over all T [r, f ] where f−1(∗) = ∅ at the root r. We initialize the table at a leaf (cid:96), with X(cid:96) = {v} as follows. Denote by fi the coloring from {v} to {1, 0,∗} with fi(v) = i for i ∈ {1, 0,∗}. Then for a leaf bag X(cid:96), set T [(cid:96), f1] := 1, T [(cid:96), f0] := ∞, T [(cid:96), f∗] := 0. For internal nodes of the tree, instead of separate 'Join, Introduce and Forget' operations we will give a single update rule with several stages. We will be using an Extend-Table subroutine which takes a partially filled table T [t,·] and extends it to table T (cid:48)[t,·] so the result will adhere to the above definition, ensuring the monotonicity property that T (cid:48)[t, f ] ≤ T (cid:48)[t, f(cid:48)] for any f we can get from f(cid:48) by changing the color of a vertex from 1 to 0 or ∗, or from 0 to ∗. Extend-Table is implemented as follows: (a) Initialize. For all f , if T [t, f ] is defined then T (cid:48)[t, f ] := T [t, f ], else T (cid:48)[t, f ] := ∞. (b) Change from 1 to 0. For q = Xt down to 1: for any f in T (cid:48)[t, f ] where {v : f (v) = 1} = q, for any choice of a single vertex u ∈ {v : f (v) = 1} 10 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE (c) Change from 0 to ∗. Similarly as in step (b). set fu(u) = 0 and set fu(x) = f (x) for x (cid:54)= u, and update T (cid:48)[t, fu] := min{T (cid:48)[t, fu], T (cid:48)[t, f ]}. Note the transition from color 1 to ∗ will happen by transitivity. The time for Extend-Table is proportional to the number of entries in the tables times Xt. Figure 2. Part of ternary tree used in the subtree representa- tion of G on the left, with node x having three incident edges a, b, c, with subtrees of vertices contained in A, B, C ⊆ V (G) using these edges respectively, giving rise to the four bags in the tree decomposition shown in the middle, with constraint A,B,C ≤ k. Assume we have the situation in Figure 2, corresponding to the bags surrounding any degree-three node x of the tree decomposition. This arises from the branch decomposition (and the subtrees of tree representation) having a node incident to three edges, creating three bags a, b, c containing subsets of vertices A, B, C, respectively, each of size at most k, and giving rise to the four bags a, b, c, x in the figure, with the latter containing subsets of vertices X = A ∪ B ∪ C. Let L = (A ∩ B) ∪ (A ∩ C) ∪ (B ∩ C). Assume we have already computed T [b, f ] and T [c, f ] for all 3B and 3C choices of f , respectively. We want to compute T [a, f ] for all 3A choices of f , in time O∗(max{3A, 3B, 3C, 3L2X\L}). Note that we will not compute the table T [x,·], as it would have 3X entries, which is more than the allowed time bound. Instead, we compute a series of tables: c [x,·]) of size 3B, by for each entry T [b, f ] extending the b [x,·] (and T 1 (1) T 1 coloring f of B to a unique coloring f(cid:48) of X based on the neighborhood of the dominators in f , c [x,·]) of size at most min(3B, 3B∩L2X\(B∩L)), by chang- b [x,·] (and T 2 ing each coloring f of X to a coloring f(cid:48) of X where vertices in B \ L having color 1 instead are given color 0 (note these vertices have no neighbors in V (G) \ V (Gx)), (2) T 2 AaACBLLLLCBbcxacbX=AUBUCx MAXIMUM MATCHING WIDTH 11 (3) T 3 c [x,·]) of size exactly 3B∩L2X\(B∩L), with f−1(1) ⊆ B∩L, b [x,·] and b [x,·] (and T 3 by running Extend-Table on T 2 sc[x,·] of size 3L2X\L by subset convolution over parts of T 3 (4) T 1 c [x,·], T 3 sc[x,·] of size 3L2X\L by running Extend-Table on T 1 sc[x,·], (5) T 2 (6) T [a,·] of size 3A by going over all 3A colorings of A and minimizing b [x,·], over appropriate entries of T 2 sc[x,·]. Note that in Step (4) we use the following: Theorem 4.1 (Fast Subset Convolution [2]). For two functions g, h : 2V → {−M, . . . , M}, given all the 2V values of g and h in the input, all 2V values of the subset convolution of g and h over the integer min-sum semiring, i.e. (g ∗ h)(Y ) = minQ∪R=Y and Q∩R=∅ g(Q) + h(R), can be computed in time 2V V O(1) · O(M log M log log M ). (1) Compute T 1 Let us now give the details of the first three steps: compute f(cid:48) : B ∪ A ∪ C → {1, 0,∗} by b [x,·]. In any order, go through all f : B → {1, 0,∗} and  f (x) 0 ∗ f(cid:48)(v) = if v ∈ B if v (cid:54)∈ B and ∃u ∈ B : f (u) = 1 ∧ uv ∈ E(G) otherwise b [x, f(cid:48)] := T [b, f ]. (2) Compute T 2 and set T 1 b [x,·]. First, initialize T 2 C → {1, 0,∗} where f−1(1) ⊆ B ∩ L. f : B ∪ A ∪ C → {1, 0,∗} such that T 1 step, and compute f(cid:48) : B ∪ A ∪ C → {1, 0,∗} by b [x, f ] = ∞ for all f : B ∪ A ∪ In any order, go through all b [x, f ] was defined in the previous f(cid:48)(v) = f(cid:48)(v) = f (v) otherwise if v ∈ B \ L and f (v) = 1 (cid:26) 0 and set T 2 entries in T 2 (3) Compute T 3 b [x, f(cid:48)] := min{T 2 b [x, f(cid:48)], T 1 b [x,·]. b [x,·] by Extend-Table on T 2 b [x, f ]}. There will be no other b [x,·]. The total time for the above three steps is bounded by O∗(max{3B, 3B∩L2X\(B∩L)}). b [x, f ] is defined for all f where vertices in B ∩ L take on values Note that T 3 {1, 0,∗} and vertices in X \ (B ∩ L) take on values {0,∗}. The value of b [x, f ] will be the minimum S over all S ⊆ V (Gb) such that there exists T 3 f(cid:48) ∈ c(S) with f(cid:48)X = f and f(cid:48)V (Gb)\X having everywhere the value 0. Note the slight difference from the standard definition, namely that even though the coloring f is defined on X, the dominators only come from V (Gb), and c [x,·] is computed in a similar way, with the not from V (Gx). The table T 3 colorings again defined on X but with the dominators now coming from V (Gc). When computing a Join of these two tables, we want dominators to come from V (Gb) ∪ V (Gc). Because of the monotonicity property that holds for 12 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE these two tables, we can compute their Join T 1 sc[x, f ] for any f where vertices in L take on values {1, 0,∗} and vertices in X \ L take on values {0,∗}, by combining colorings as follows: T 1 sc[x, f ] = min fb,fc (T 3 b [x, fb] + T 3 c [x, fc]) − f−1(1) ∩ B ∩ C where fb, fc satisfy: b [x, f ] and T 3 • f (v) = 0 if and only if (fb(v), fc(v)) ∈ {(0,∗), (∗, 0)} • f (v) = ∗ if and only if fb(v) = fc(v) = ∗ • f (v) = 1 if and only if v ∈ B ∩ C and fb(v) = fc(v) = 1, or v ∈ B \ C and (fb(v), fc(v)) = (1,∗), or v ∈ C \ B and (fb(v), fc(v)) = (∗, 1). This means that we can apply subset convolution to compute a table sc[x, f ] on 3L2X\L entries based on T 3 T 1 c [x, f ]. Note that (B ∩ L) ∪ (C ∩ L) = L. For this step we follow the description in [6, Section 11.1.2]. Fix a set D ⊆ L to be the dominating vertices. Let FD denote the set of 2X\D functions f : X → {1, 0,∗} such that f−1(1) = D, i.e. with vertices in X \ D mapping in all possible ways to {0,∗}. For each D ⊆ L we will by subset convolution compute the values of T 1 We represent every f ∈ FD by the set S = f−1(0) and define bS : X → {1, 0,∗} such that bS(x) = 1 if x ∈ D ∩ B, bS(x) = 0 if x ∈ S, bS(x) = ∗ otherwise. Similarly, define cS : X → {1, 0,∗} such that cS(x) = 1 if x ∈ D ∩ C, cS(x) = 0 if x ∈ S, cS(x) = ∗ otherwise. Then, as explained previously, for every f ∈ FD we want to compute c [x, cR]) − f−1(1) ∩ B ∩ C. b [x, bQ] + T 3 T 1 sc[x, f ] = Define functions Tb : 2X\D → N such that for every S ⊆ X \ D we have b [x, bS]. Likewise, define functions Tc : 2X\D → N such that for Tb(S) = T 3 every S ⊆ X \ D we have Tc(S) = T 3 c [x, cS]. Also, define aS : X → {1, 0,∗} such that aS(x) = 1 if x ∈ D, aS(x) = 0 if x ∈ S, aS(x) = ∗ otherwise. We then compute for every S ⊆ X \ D, sc[x, f ] for all f ∈ FD. Q∪R=f−1(0) and Q∩R=∅ (T 3 min sc[x, aS] := (Tb ∗ Tc)(S) − f−1(1) ∩ B ∩ C T 1 where the subset convolution is over the mini-sum semiring. (4) In Step (4), by Fast Subset Convolution, Theorem 4.1, we compute sc[x, aS], for all aS defined by all f ∈ FD, in O∗(2X\D) time each. For all T 1 such subsets D ⊆ L we get the time 2L\D = 2X\L3L. (cid:88) D⊆L 2X\D = (cid:88) D⊆L 2X\L2L\D = 2X\L (cid:88) D⊆L sc[x,·] to get the table (5) In Step (5), we need to run Extend-Table on T 1 sc[x,·]. This since the subset convolution was computed for each fixed set T 2 of dominators so the monotonicity property of the table may not hold. Note sc[x, f ] will be the minimum S over all S ⊆ V (Gb)∪V (Gc) that the value of T 2 {1, 0,∗} by f(cid:48)(v) =  1 if v ∈ A ∩ L and f (v) = 1 0 if v ∈ A and f (v) = 0 and N (v) ∩ f−1(1) = ∅ 0 if v (cid:54)∈ A and N (v) ∩ f−1(1) = ∅ ∗ otherwise sc[x, f(cid:48)] + f−1(1) ∩ (A \ L). MAXIMUM MATCHING WIDTH 13 such that there exists f(cid:48) ∈ c(S) with f(cid:48)X = f and f(cid:48)(V (Gb)∪V (Gc))\X having everywhere the value 0. (6) In Step (6), we will for each f : A → {1, 0,∗} compute f(cid:48) : B∪A∪C → and set T [a, f ] := T 2 Note that when we iterate over all choices of f : A → {1, 0,∗}, the vertices colored 0 (in addition to all vertices of X \ A) must either be dominated by the vertices in f−1(1) or by vertices in X \ Va. As we know precisely what vertices of f−1(0) are dominated by f−1(1), we know the rest must be dominated from vertices of X \ Va, and therefore we look in Tsc[x, f(cid:48)] at an index f(cid:48) which colors the rest of f−1(0) by 0. We can also observe that it is not important for us whether or not f−1(0) contains all neighbours of f−1(1), since we are iterating over all choices of f - also those where f−1(0) contains all neighbours of f−1(1). The total runtime becomes O∗(max{3A, 3B, 3C, 3L2(A∪B∪C)\L}), with L = (A ∩ B) ∪ (A ∩ C) ∪ (B ∩ C) and with constraints A,B,C ≤ k. This runtime is maximum when L = ∅, giving a runtime of O∗(23k). We thus have the following theorem. Theorem 4.2. Given a graph G and branch decomposition over its vertex set of mm-width k we can solve Dominating Set in time O∗(8k). 5. Discussion We have shown that the graph parameter mm-width will for some graphs be better than treewidth for solving Minimum Dominating Set. The improve- ment holds whenever tw(G) > 1.549 × mmw(G), if given only the graph as input. In Figure 3 we list some examples of small graphs having treewidth at least twice as big as mm-width. It could be interesting to explore the relation between treewidth and mm-width for various well-known classes of graphs. The given algorithmic technique, using fast subset convolution, should extend to any graph problem expressible as a maximization or minimization over (σ, ρ)-sets, using the techniques introduced for treewidth in [17]. We may also compare with branchwidth. Let ω be the exponent of matrix multiplication, which is less than 2.3728639 [11]. In 2010, Bodlaender, van Leeuwen, van Rooij, and Vatshelle [5] gave an O∗(3 2 k) time algorithm solving Minimum Dominating Set if an input graph is given with its branch decomposition of width k. This means that given decompositions of bw(G) and mmw(G) our algorithm based on mm-width is faster than the algorithm in [5] whenever bw(G) > log3 8 · 2 1.6 mmw(G). ω · mmw(G) > 2 log3 8 2.3728639 · mmw(G) > ω 14 JISU JEONG, SIGVE HORTEMO SAETHER, AND JAN ARNE TELLE Figure 3. Three graphs of mm-width 2. Left and middle have treewidth 4, and right has treewidth 5. Taking the subtrees of tree representation for treewidth, branchwidth and maximum matching width mentioned in the Introduction as input, our algorithm for dominating set can be seen as a generic one that works for any of treewidth, branchwidth or maximum matching width of the given representation, and in case of both treewidth and mm-width it will give the best runtime known. We gave an alternative definition of mm-width using subtrees of a tree, similar to alternative definitions of treewidth and branchwidth. We saw that in the subtrees of a tree representation treewidth focuses on nodes, branchwidth focuses on edges, and mm-width combines them both. There is also a fourth way of defining a parameter through these intersections of subtrees representation; where subtrees Tu and Tv must share an edge if uv ∈ E(G) (similar to branchwidth) and the width is defined by the maximum number of subtrees sharing a single vertex (similar to treewidth). This parameter will be an upper bound on all the other three parameters, but might it be that the structure this parameter highlights can be used to improve the runtime of Dominating Set beyond O∗(3tw(G)) for even more cases than those shown using mm-width and branchwidth? References [1] E. Amir. Approximation algorithms for treewidth. Algorithmica, 56(4):448 -- 479, 2010. [2] A. Bjorklund, T. Husfeldt, P. Kaski, and M. Koivisto. Fourier meets Mobius: fast subset convolution. In STOC'07 -- Proceedings of the 39th Annual ACM Symposium on Theory of Computing, pages 67 -- 74. ACM, New York, 2007. [3] H. L. Bodlaender, P. G. Drange, M. S. Dregi, F. V. Fomin, D. Lokshtanov, and M. Pilipczuk. An o(ckn) 5-approximation algorithm for treewidth. In Foundations of Computer Science (FOCS), 2013 IEEE 54th Annual Symposium on, pages 499 -- 508. IEEE, 2013. [4] H. L. Bodlaender and T. Kloks. Efficient and constructive algorithms for the pathwidth and treewidth of graphs. J. Algorithms, 21(2):358 -- 402, 1996. [5] H. L. Bodlaender, E. J. van Leeuwen, J. M. M. van Rooij, and M. Vatshelle. Faster algorithms on branch and clique decompositions. In Mathematical foundations of computer science 2010, volume 6281 of Lecture Notes in Comput. Sci., pages 174 -- 185. Springer, Berlin, 2010. MAXIMUM MATCHING WIDTH 15 [6] M. Cygan, F. V. Fomin, (cid:32)L. Kowalik, D. Lokshtanov, D. Marx, M. Pilipczuk, M. Pilipczuk, and S. Saurabh. Parameterized Algorithms. Springer International Publishing, New York, 2016. [7] R. Diestel. Graph theory, volume 173 of Graduate Texts in Mathematics. Springer, Heidelberg, fourth edition, 2010. [8] F. Gavril. The intersection graphs of subtrees in trees are exactly the chordal graphs. J. Combinatorial Theory Ser. B, 16:47 -- 56, 1974. [9] J. Jeong, S. H. Saether, and J. A. Telle. An FPT algorithm computing a decomposition of optimal mm-width. in preparation, 2015. [10] D. Konig. Gr´afok ´es m´atrixok. Matematikai ´es Fizikai Lapok, 38:116 -- 119, 1931. [11] F. Le Gall. Powers of tensors and fast matrix multiplication. In ISSAC 2014 -- Proceedings of the 39th International Symposium on Symbolic and Algebraic Compu- tation, pages 296 -- 303. ACM, New York, 2014. [12] D. Lokshtanov, D. Marx, and S. Saurabh. Known algorithms on graphs of bounded treewidth are probably optimal. In Proceedings of the Twenty-Second Annual ACM- SIAM Symposium on Discrete Algorithms, pages 777 -- 789. SIAM, Philadelphia, PA, 2011. [13] S. Oum and P. Seymour. Approximating clique-width and branch-width. J. Combin. Theory Ser. B, 96(4):514 -- 528, 2006. [14] C. Paul and J. A. Telle. Edge-maximal graphs of branchwidth k: the k-branches. Discrete Math., 309(6):1467 -- 1475, 2009. [15] N. Robertson and P. D. Seymour. Graph minors. X. Obstructions to tree-decomposition. J. Combin. Theory Ser. B, 52(2):153 -- 190, 1991. [16] S. H. Saether and J. A. Telle. Between treewidth and clique-width. In Graph-theoretic concepts in computer science, volume 8747 of Lecture Notes in Comput. Sci., pages 396 -- 407. Springer, Cham, 2014. [17] J. M. M. van Rooij, H. L. Bodlaender, and P. Rossmanith. Dynamic programming on tree decompositions using generalised fast subset convolution. In Algorithms -- ESA 2009, volume 5757 of Lecture Notes in Comput. Sci., pages 566 -- 577. Springer, Berlin, 2009. [18] M. Vatshelle. New Width Parameters of Graphs. PhD thesis, The University of Bergen, 2012. (Jeong) Department of Mathematical Sciences, KAIST, South Korea (Saether, Telle) Department of Informatics, University of Bergen, Norway E-mail address: [email protected] E-mail address: [email protected] E-mail address: [email protected]
1101.5753
1
1101
2011-01-30T09:35:13
Fault-Tolerant Spanners: Better and Simpler
[ "cs.DS", "math.CO" ]
A natural requirement of many distributed structures is fault-tolerance: after some failures, whatever remains from the structure should still be effective for whatever remains from the network. In this paper we examine spanners of general graphs that are tolerant to vertex failures, and significantly improve their dependence on the number of faults $r$, for all stretch bounds. For stretch $k \geq 3$ we design a simple transformation that converts every $k$-spanner construction with at most $f(n)$ edges into an $r$-fault-tolerant $k$-spanner construction with at most $O(r^3 \log n) \cdot f(2n/r)$ edges. Applying this to standard greedy spanner constructions gives $r$-fault tolerant $k$-spanners with $\tilde O(r^{2} n^{1+\frac{2}{k+1}})$ edges. The previous construction by Chechik, Langberg, Peleg, and Roddity [STOC 2009] depends similarly on $n$ but exponentially on $r$ (approximately like $k^r$). For the case $k=2$ and unit-length edges, an $O(r \log n)$-approximation algorithm is known from recent work of Dinitz and Krauthgamer [arXiv 2010], where several spanner results are obtained using a common approach of rounding a natural flow-based linear programming relaxation. Here we use a different (stronger) LP relaxation and improve the approximation ratio to $O(\log n)$, which is, notably, independent of the number of faults $r$. We further strengthen this bound in terms of the maximum degree by using the \Lovasz Local Lemma. Finally, we show that most of our constructions are inherently local by designing equivalent distributed algorithms in the LOCAL model of distributed computation.
cs.DS
cs
Fault-Tolerant Spanners: Better and Simpler Michael Dinitz∗ Robert Krauthgamer† Weizmann Institute of Science December 9, 2013 Abstract A natural requirement of many distributed structures is fault-tolerance : after some failures, whatever remains from the structure should still be effective for whatever remains from the network. In this paper we examine spanners of general graphs that are tolerant to vertex failures, and significantly improve their dependence on the number of faults r, for all stretch bounds. For stretch k ≥ 3 we design a simple transformation that converts every k -spanner con- struction with at most f (n) edges into an r-fault-tolerant k -spanner construction with at most O(r3 log n) · f (2n/r) edges. Applying this to standard greedy spanner constructions gives r-fault tolerant k -spanners with O(r2n1+ 2 k+1 ) edges. The previous construction by Chechik, Langberg, Peleg, and Roddity [STOC 2009] depends similarly on n but exponential ly on r (approximately like kr ). For the case k = 2 and unit-length edges, an O(r log n)-approximation algorithm is known from recent work of Dinitz and Krauthgamer [arXiv 2010], where several spanner results are obtained using a common approach of rounding a natural flow-based linear programming relax- ation. Here we use a different (stronger) LP relaxation and improve the approximation ratio to O(log n), which is, notably, independent of the number of faults r. We further strengthen this bound in terms of the maximum degree by using the Lov´asz Local Lemma. Finally, we show that most of our constructions are inherently local by designing equivalent distributed algorithms in the LOCAL model of distributed computation. 1 1 0 2 n a J 0 3 ] S D . s c [ 1 v 3 5 7 5 . 1 0 1 1 : v i X r a ∗Email: [email protected] † Supported in part by The Israel Science Foundation (grant #452/08), and by a Minerva grant. Email: [email protected] 1 Introduction Let G = (V , E ) be a graph, possibly with edge-lengths ℓ : E → R≥0 . A k-spanner of G, for k ≥ 1, is a subgraph G′ = (V , E ′ ) that preserves all pairwise distances within factor k , i.e. for all u, v ∈ V , dG′ (u, v) ≤ k · dG (u, v). (1) Here and throughout, dH denotes the shortest-path distance in a graph H , and n = V . The distance preservation factor k is called the stretch of the spanner. It is easy to see that requiring (1) only for edges (u, v) ∈ E suffices. This definition also extends naturally to directed graphs. Obviously G is a 1-spanner of itself, so usually the goal is to compute a “small” spanner. Two traditional notions of “small” are the number of edges in G′ (called the size of G′ ), and the weight of G′ (where the weight of a graph is the sum of the lengths of the edges in the graph). If every edge has unit length then these two notions are the same, but for more general edge lengths they can be quite different. This notion of graph spanners, first introduced by Peleg and Schaffer [PS89] and Peleg and Ullman [PU89], has been studied extensively, with applications ranging from routing in networks (e.g. [AP95, TZ05]) to solving linear systems (e.g. [ST04, EEST08]). Many of these applications, especially in distributed computing, arise by modeling computer networks or distributed systems as graphs. But one aspect of distributed systems that is not captured by the above spanner definition is the possibility of failure. We would like our spanner to be robust to failures, so that even if some nodes fail we still have a spanner of what remains. More formally, G′ is an r-fault tolerant k-spanner of G if for every set F ⊆ V with F ≤ r , the spanner condition holds for G \ F , i.e. for all u, v ∈ V \ F we have dG′ \F (u, v) ≤ k · dG\F (u, v). This notion of fault-tolerant spanners was first introduced by Levcopoulos, Narasimhan, and Smid [LNS98] in the context of geometric spanners (the special case when the vertices are in Euclidean space and the distance between two points is the Euclidean distance). They provided both size and weight bounds for (1 + ǫ)-spanners, which were later improved by Lukovski [Luk99] and Czuma j and Zhao [CZ03]. The first result on fault-tolerant spanners for general graphs, by Chechik, Langberg, Peleg, and Roditty [CLPR09], constructs r-fault tolerant (2k − 1)-spanners with size O(r2kr+1 · n1+1/k log1−1/k n), for any integer k ≥ 1. Since it has long been known how to construct (2k − 1)-spanners with size O(n1+1/k ) (see e.g [ADD+ 93]), this means that the extra cost of r-fault tolerance is O(r2kr+1 ). While this is independent of n, it grows rapidly as the number of faults r gets large. We address an important question they left open of improving this dependence on r from exponential to polynomial. Nontrivial absolute bounds on the size of a k-spanner are possible only when the stretch k ≥ 3. For k = 2, there are graphs with Ω(n2 ) edges for which every edge must be included in the span- ner (e.g., a complete bipartite graph). So the common approach is to provide relative bounds, namely, design approximation algorithms for the problem of computing a minimum size/weight r-fault tolerant 2-spanner. In this context one assumes that all edges have unit length, so the size equals the weight. Without fault tolerance, the problem is reasonably well understood: there are algorithms that provide an O(log n)-approximation [KP94, EP01] (or, with some extra ef- fort, an O(log(E /V ))-approximation), and the problem is NP-hard to approximate better than Ω(log n) [Kor01]. For the r-fault tolerant 2-spanner problem, Dinitz and Krauthgamer [DK10] recently gave an O(r log n)-approximation. However, they did not provide evidence that this loss of r was necessary, an issue that we address in this paper. 1 1.1 Results and Techniques Stretch bounds k ≥ 3. Here, our main result is a new r-fault tolerant k-spanner with size that depends only polynomially on r , thereby improving over the exponential dependence by Chechik et al. [CLPR09]. Theorem 1.1. For every graph G = (V , E ) with positive edge-lengths and odd k ≥ 3, there is an k+1 n1+ 2 r-fault tolerant k-spanner with size O(r2− 2 k+1 log n). In fact, we prove something slightly stronger: a general conversion theorem that turns any algorithm for constructing k-spanners with size f (n) into an algorithm for constructing r-fault tolerant k-spanners with size O(r3 log n · f (2n/r). Applying this conversion to the well-known greedy spanner algorithm (see e.g. [ADD+ 93]) immediately yields Theorem 1.1. At a high level, Chechik et al. [CLPR09] apply the spanner construction of Thorup and Zwick [TZ05] to every possible fault set, eventually taking the union of all of these spanners. They show, through a rather involved analysis that relies on specific properties of the Thorup-Zwick construction, that taking a union over as many as O(nr ) spanners increases the size bound only by an O(r2kr ) factor. Our conversion technique, on the other hand, is extremely general. Inspired by the color-coding technique of Alon, Yuster, and Zwick [AYZ95] and its recent incarnation in designing data structures and oracles [WY10], we randomly sample nodes to act as a fault set, and then apply a generic spanner algorithm on what remains. Our sampling dramatically oversamples nodes — instead of fault sets of size r , we end up with sampled fault sets of size approximately (1 − 1 r )n. This allows us to satisfy many fault sets of size r with a single iteration of the generic algorithm. The size bound follows almost immediately. Stretch k = 2 (and assuming unit-length edges). Here, our main result is an approximation algorithm with ratio that is independent of r . Our algorithm actually works in an even more general setting, where the graph is directed and edges have costs ce : E → R≥0 . The goal is to find an r-fault tolerant 2-spanner of minimum total cost. We refer to this problem as Minimum Cost r-Fault Tolerant 2-Spanner. Theorem 1.2. For every r ≤ n, there is a (randomized) O(log n)-approximation algorithm for Minimum Cost r-Fault Tolerant 2-Spanner. This improves over the previously known O(r log n)-approximation [DK10]. Similarly to [DK10], we design a flow-based linear programming (LP) relaxation of the problem and then apply a round- ing scheme that uses randomization at the vertices, rather than naively at the edges. However, the relaxation used by [DK10] is not strong enough to achieve approximation factor independent of r ; even simple graphs (such as the complete graph with unit costs) have integrality gaps of Ω(r). We thus design a different relaxation, and add to it a large family of constraints that are essentially the knapsack-cover inequalities of Carr, Fleischer, Leung, and Phillips [CFLP00], adapted to our context. With these additional constraints, we are able to show that the simple rounding scheme devised in [DK10] now achieves an O(log n)-approximation. We further show that the integrality gap is at most O(log ∆), where ∆ is the maximum degree of the graph, in the special case where all edge costs are 1. Note that this bound is at least as good as the O(log n) bound (and possibly better). We prove this by a more careful analysis of essentially the same randomized rounding scheme using the Lov´asz Local Lemma. This makes the result non-algorithmic – it only shows that the rounding scheme succeeds with a positive probability. 2 Distributed versions of our algorithms. Finally, one feature that is shared by both the k = 2 and the k ≥ 3 case is that the algorithms are local (assuming that the generic algorithm used by the conversion theorem is itself local). To show this formally, we provide distributed versions of the algorithm in the LOCAL model of distributed computation. The LOCAL model is a standard message-passing model in which in each round, every node is allowed to send an unbounded-size message to each of its neighbors [Pel00 ]. While the unbounded message-size assumption may not be realistic, this model captures locality in the sense that in t rounds, each node has knowledge of, and is influenced by, only the nodes that are within (hop-)distance t of it. Assuming that the underlying generic spanner algorithm is distributed in this sense, our general conversion theorem trivially provides a distributed algorithm since the failure sampling is done independently by every edge. Designing a distributed version of the r-fault tolerant 2-spanner algorithm is not quite as simple, since our centralized algorithm uses the Ellipsoid method to solve a linear program that has an exponential number of constraints. While there is a significant amount of literature on solving linear programs in a distributed manner, much of the time strong assumptions are made about the structure of the linear program. In particular, it is common to assume that the LP is a positive (i.e. a packing/covering) LP. Unfortunately the LP relaxation that we use is not positive, even for r = 0, so we cannot simply use an off-the-shelf distributed LP solver. Instead, we leverage the fact that the LP itself is “mostly” local — we partition the graph into clusters, solve the LP separately on each cluster, and then repeat this process several times, eventually taking the average values. This technique is quite similar to the work of Kuhn, Moscibroda, and Wattenhofer [KMW06], who showed how to approximately solve positive LPs using the graph decompositions of Linial and Saks [LS93]. We construct padded decompositions using a variant of the methods developd by Bartal [Bar96] and by Linial and Saks [LS93]. Combining this distributed methodology for solving the LP relaxation together with the obvious distributed implementation of the aforementioned rounding scheme, we obtain the following distributed O(log n)-approximation. Theorem 1.3. There is a randomized algorithm that takes O(log2 n) rounds and gives an O(log n)- approximation for Minimum Cost r-Fault Tolerant 2-Spanner in the LOCAL model of dis- tributed computation. 2 General k In this section we give our construction of r-vertex-tolerant k-spanners (with arbitrary edge- lengths). For each F ⊆ V with F ≤ r , we let EF denote the edges of G \ F , i.e. EF = {{u, v} ∈ E : u, v 6∈ F }. We first give a general conversion theorem that turns any k-spanner construction into an r-fault tolerant k-spanner construction at an extra cost of at most poly(r) · log n. This conversion actually works fine even when the underlying spanner construction is randomized, but since good deterministic constructions exist we will assume for simplicity that the underlying construction is deterministic. We say that an event happens with high probability if it happens with probability at least 1 − 1 nC for constant C that can be made arbitrarily large (at the cost of increasing the constants hidden by O(·) notation). Theorem 2.1. If there is an algorithm that on every graph builds a k-spanner of size f (n), then there is an algorithm that on any graph builds with high probability an r-fault tolerant k-spanner of size O(r3 log n · f ( 2n r )). 3 Proof. Our algorithm is simple: in each iteration, we independently add each vertex to a set J with probability p = 1 − 1/r , and then use the given algorithm to build a k-spanner on the remaining graph G \ J . If r = 1 then we can set p = 1/2, which will just affect the constants in the O(·). We do this for α = Θ(r3 log n) iterations, each independent of the others. Let H be the graph obtained by taking the union of the iterations. We first bound the size of H . Without loss of generality we can assume that r ≤ n2/3 , since when r > n2/3 the claimed size bound is larger than n2 and thus trivially true. In each iteration, the expected number of vertices in G \ J is n/r . By a simple Chernoff bound, the probability that a given iteration has more than 2n/r vertices in G \ J is at most e−(1/3)n/r ≤ e−(1/3)n1/3 . Since there are only α = O(r3 log n) ≤ O(e3 ln n log n) iterations, we can take a union bound over the iterations and get that with high probability the number of vertices in G \ J is at most 2n/r in every iteration. Thus the total size of H is at most O(α · f ( 2n r )). Now we just need to prove that this algorithm results in a valid r-fault tolerant k-spanner for α = O(r3 log n). For each F ⊆ V with F ≤ r , let E ′ F be the edges in EF for which the shortest path in G \ F between the endpoints is just the edge. More formally, EF = {{u, v} ∈ EF : dG\F (u, v) = ℓ({u, v})}. It is easy to see that it is sufficient for there to be a path of length at most k · dG\F (u, v) between u and v in G \ F for every F ⊆ V with F ≤ r and {u, v} ∈ E ′ F . This is because for a given failure set F , if we distort the distances of all remaining edges that are actually part of shortest paths by at most k , then we distort the distances of all pairs by at most k (since each edge on the shortest path is distorted by at most k). So we consider a particular such F and {u, v} and upper bound the probability that there is no stretch-k path between u and v in G \ F . Suppose that in some iteration neither u nor v is in J , but all of F is in J . Then since {u, v} ∈ E ′ F , the spanner that we build on G \ J contains a path between u and v of length at most k · dG\J (u, v) = k · ℓ({u, e}) = k · dG\F (u, v). Obviously this path also exists in G \ F , since F ⊆ J . So if this happens then H is valid for {u, v} and F . The probability that this happens in a particular iteration is clearly (1 − p)2 · pr , which is at least 1/(4r2 ) as long as r ≥ 2 (if r = 1 then this probability it 1/8, which does not significantly affect the results). Thus the probability that 4r2 )α ≤ e−α/4r2 this never happens in any iteration is at most (1 − 1 , so if we set α = Θ(r3 log n) this becomes less than 1/nC (r+2) for arbitrarily large constant C . Now taking a union bound over all {u, v} and F gives the theorem. Corollary 2.2. For every graph G = (V , E ) with nonnegative edge lengths ℓ : E → R≥0 and every odd k ≥ 1, there is a polynomial time algorithm that with high probability constructs a r-vertex- k+1 n1+ 2 tolerant k-spanner with at most O(r2− 2 k+1 log n) edges. Proof. Althofer et al. [ADD+ 93] showed that the simple greedy spanner construction has size at most O(n1+ 2 k+1 ). Applying Theorem 2.1 to this construction completes the proof. Since Theorem 2.1 applies to any k-spanner construction, we can apply it to distributed spanner constructions. We assume that every node knows r , the desired amount of fault tolerance. Theorem 2.3. If there is a distributed algorithm A that on every graph builds a k-spanner of size f (n) in t(n) rounds, then there is a distributed algorithm that on any graph builds with high probability an r-fault tolerant k-spanner of size O(r3 log n · f (2n/r)) in O(r3 log n · t(n)) rounds. Proof. The algorithm is simple: O(r3 log n) times, each edge independently decides whether or not to join J with probability 1 − 1/r , and then A is run on the remainder. This obviously takes at most O(r3 log n · t(n)) rounds, and the analysis of Theorem 2.1 proves the desired size bound. 4 Corollary 2.4. There is a distributed algorithm in the LOCAL model that in O(kr3 log n) rounds k+1 n1+ 2 constructs with high probability an r-fault tolerant k-spanner with at most O(kr2− 2 k+1 log n) edges. Proof. Apply Theorem 2.3 to the distributed deterministic spanner construction of Derbel, Gavoille, Peleg, and Viennot [DGPV08], which has size O(kn1+ 2 k+1 ) and runs in O(k) rounds. 3 Unit-Length r-Fault Tolerant 2-Spanner We now move from general k to the specific case of k = 2. It is easy to see (and has long been known) that no non-trivial absolute bounds on the size a 2-spanner are possible, so following previous work, we instead consider the approximation version. In this section we will mostly work in the directed setting in which every edge e has an arbitrary cost ce ≥ 0. This is obviously more general than the undirected, unit-cost setting considered in Section 2; we can work in this setting because of our additional assumptions that k = 2 and edge lengths are unit. Recent work of Dinitz and Krauthgamer [DK10] achieves approximation ratio O(r log n) for the unit-length r-fault tolerant 2-spanner problem, and an O(r log ∆) upper bound on the integrality gap (where ∆ is the maximum degree). Here we improve these results to O(log n) and O(log ∆) (for all r) via a different LP relaxation, and also provide a distributed implementation. 3.1 The Previous LP Relaxation The relaxation in [DK10] uses, at a high level, a characterization of r-fault tolerant 2-spanners based on flows where “for every set of r faults, it is possible to send one unit of (integral) flow from u to v along paths of length at most 2 for any edge (u, v) still present in the graph once the faults have been removed”. More formally, for each (u, v) ∈ E let Pu,v denote the paths of length exactly two from u to v , so Pu,v ∪ {(u, v)} is the set of all paths of length at most 2. As in Section 2, for any possible fault set F ⊆ V with F ≤ r let EF be the set of edges in E with neither endpoint in F . Let P F u,v be the subset of Pu,v ∪ {(u, v)} that still survives in EF . The integer program (IP) used by Dinitz and Krauthgamer [DK10] is presented below as IP (2). cexe min X e∈E s.t. X P ∈P F u,v : e∈P X f F P ≥ 1 P ∈P F u,v xe ∈ {0, 1} f F P ∈ {0, 1} f F P ≤ xe ∀F ⊆ V : F ≤ r, ∀(u, v) ∈ EF , ∀e ∈ EF ∀F ⊆ V : F ≤ r, ∀(u, v) ∈ EF ∀e ∈ E ∀F ⊆ V : F ≤ r, ∀(u, v) ∈ EF , ∀P ∈ P F u,v (2) This formulation has capacity variables xe for every edge e, flow variables f F P for every possible fault set F and every path P ∈ P F u,v ∪ (u, v) (for every (u, v) ∈ E ), and constraints that require flows to obey the capacities and still send one unit of flow for every possible fault set. Even though there are an exponential number of both constraints and variables, it is solvable in polynomial time [DK10]. 5 While IP (2) is the obvious integer programming formulation of the r-fault tolerant k-spanner problem, its straightforward relaxation to a linear program is not strong enough to give an approx- imation that is independent of r (despite having an exponential number of both constraints and variables). An easy way to see this is by considering the complete graph. On the complete graph, every vertex obviously needs at least r incoming and outgoing edges, or else it could be isolated with less than r faults. So on Kn the optimum spanner has size at least rn. On the other hand, when we relax the integrality constraints we can set the capacity of every edge to 1/(n − r − 2) and still have enough capacity to send one unit of flow from any vertex to any other even after r of them have failed. So the linear program has cost of only n2/(n − r − 2), which is O(n) as long as r < cn for some constant c < 1. Thus the integrality gap of the relaxation is Ω(r) for an extremely wide range of r . 3.2 A New LP Relaxation To get around this problem, we will use a different relaxation based on weighted flow. Before we give our formulation, we first prove a simple and useful characterization of r-fault-tolerant 2-spanners: Lemma 3.1. For any (directed) graph G = (V , E ), a subgraph H = (V , E ′ ) is an r-fault tolerant 2-spanner if and only if for every (u, v) in E either (u, v) ∈ E ′ or there are at least r + 1 paths of length 2 from u to v in E ′ Proof. Let H be an r-fault tolerant 2-spanner of G, and for the sake of contradiction assume that there is some (u, v) ∈ E that is not in E ′ and for which there are at most r paths of length 2 from u to v . Let W ⊆ V be the vertices that are the midpoints of these paths. Then if we let our fault set F be W , in the remaining graph H \ W there is no u − v path, while in G \ W the edge (u, v) still exists. Thus H is not an r-fault tolerant 2-spanner, giving the contradiction. For the other direction, suppose that for every (u, v) ∈ E either (u, v) ∈ E ′ or there are at least r + 1 paths of lengths 2 from u to v . Let F ⊆ V with F ≤ r be some fault set. We need to show that H is a valid 2-spanner for G \ F , so let (u, v) ∈ E with u, v 6∈ F be an arbitrary edge in G \ F . If (u, v) ∈ E ′ then obviously H preserves its distance exactly, and if (u, v) 6∈ E ′ then by assumption there are at least r + 1 paths from u to v of length 2 in E ′ . At most r of the intermediate vertices on those paths can be in F , so in G \ F there is at least one such path remaining. With this lemma in hand, it is easy to see that the following integer program is an exact formulation of the r-fault tolerant 2-spanner problem. cexe fP ≤ xe min X e∈E s.t. X P ∈Pu,v :e∈P (r + 1)x(u,v) + X P ∈Pu,v xe ∈ {0, 1} fP ≥ 0 ∀(u, v) ∈ E , ∀e ∈ E fP ≥ r + 1 ∀(u, v) ∈ E ∀e ∈ E ∀(u, v) ∈ E , ∀P ∈ Pu,v (3) So now we have a different IP formulation than the one that was used in [DK10] to get an O(r log n)-approximation. Unfortunately, it is still not strong enough to yield an approximation 6 ratio independent of r ; there are still simple examples that give an integrality gap of Ω(r). For example, consider a graph with nodes u and v and an edge of cost M from u to v (for some arbitrarily large M ), together with r nodes w1 , . . . , wr and an edge of cost 1 from u to wi and from wi to v for all i ∈ [r ]. The set of all wi nodes is a valid fault set, so the optimum spanner needs to include the (u, v) edge in order to still be valid. So the optimum spanner has cost at least M . On the other hand, the LP can set xe to 1 for all edges e incident on some wi , and set x(u,v) = 1/(r + 1). This has cost of only M /(r + 1) + 2r . By setting M large enough, we get a gap of Ω(r). We will strengthen the relaxation by adding a set of valid inequalities that are essentially the knapsack-cover inequalities of Carr et al. [CFLP00] applied to this IP. Let (u, v) ∈ E , and consider some arbitrary subset W ⊆ Pu,v with W ≤ r . If x(u,v) = 0, then the covering inequality for (u, v) implies that PP ∈Pu,v fP ≥ r + 1, and thus PP ∈Pu,v \W fP ≥ r + 1 − W . On the other hand, if x(u,v) = 1 then clearly (r + 1 − W )x(u,v) ≥ r + 1 − W . So for all (u, v) ∈ E and all W ⊆ Pu,v with W ≤ r , we can add the constraint that (r + 1 − W )x(u,v) + PP ∈Pu,v \W fP ≥ r + 1 − W . These are the knapsack-cover inequalities, and when we add them to our IP formulation and relax the integrality constraints we get the following LP relaxation: cexe fP ≤ xe min X e∈E s.t. X P ∈Pu,v :e∈P (r + 1 − W )x(u,v) + X P ∈Pu,v \W 0 ≤ xe ≤ 1 fP ≥ 0 ∀(u, v) ∈ E , ∀e ∈ E fP ≥ r + 1 − W ∀(u, v) ∈ E , ∀W ⊆ Pu,v : W ≤ r ∀e ∈ E ∀(u, v) ∈ E , ∀P ∈ Pu,v (4) We refer to the first type of constraints as capacity constraints, the second type as knapsack- cover constraints (or inequalities), and the third as multiplicity constraints. This relaxation has a polynomial number of variables but a possibly exponential number of constraints, so we first need to show that we can solve it. To do this we construct a separation oracle, which allows us to solve it in polynomial time by using the Ellipsoid algorithm. Lemma 3.2. There is a polynomial time algorithm that solves LP (4). Proof. We want to construct a separation oracle. Note that there are only a polynomial number of capacity constraints and multiplicity constraints, so we can check them all in polynomial time. To find a violated knapsack-cover inequality, note that if there is some (u, v) ∈ E and some W ⊆ Pu,v that violates the inequality, then the set W ′ which consists of the W paths in Pu,v with the largest fP value also violates the inequality. So for every (u, v) ∈ E , for every k ∈ [0, r ], it suffices to check the constraint for (u, v) and the k paths in Pu,v with largest flow. Since r ≤ n, this takes only polynomial time. 3.3 O(log n)-approximation We now give the main result of this section. 7 Theorem 3.3. There is a randomized O(log n)-approximation for Minimum Cost r-Fault Tol- erant 2-Spanner (for al l r). Proof. The first step of the algorithm is to solve LP (4) using Lemma 3.2. We then round the solution using Algorithm 1 below. (This rounding algorithm was designed in [DK10], but for a different relaxation, hence they were forced to set α = Θ(r log n) and the analysis therein is not applicable here.) Algorithm 1: Rounding algorithm for r-fault tolerant 2-spanner. 1 Set α = C ln n (for a large enough constant C ). 2 For every v ∈ V choose independently a random threshold Tv ∈ [0, 1]. 3 Output E ′ = {(u, v) ∈ E : min{Tu , Tv } ≤ α · xu,v }. We first show that the cost of the solution is likely to be at most 6α times the LP value. The probability than some edge e is selected to be in E ′ is at most 2αxe , so the expected cost of the solution E ′ is Pe∈E ce · 2αxe = 2α Pe cexe . By Markov’s inequality, the cost of the solution E ′ exceeds 6α Pe ce xe with probability at most 1/3. We now argue that this algorithm returns a valid r-fault tolerant 2-spanner with high probability. We say that E ′ satisfies an edge (u, v) if either (u, v) ∈ E ′ or E ′ contains at least r + 1 length 2 paths from u to v . By Lemma 3.1, if E ′ satisfies all edges then it is a valid r-fault tolerant 2-spanner. Consider some edge (u, v) ∈ E . Order the paths in Pu,v in nonincreasing order by their flow values in the LP solution, so Pi is the path with the ith largest flow. Let Wi = {P1 , P2 , . . . , Pi }, and let i∗ = max{i : fPi ≥ 1/α}. If i∗ > r then r + 1 paths have flow value at least 1/α, so both of the edges in each path have x value at least 1/α, so they are included in E ′ with probability 1. Thus (u, v) is satisfied with probability 1. On the other hand, suppose that i∗ ≤ r . Let us denote r ′ = r+ 1− i∗ ≥ 1. By the knapsack-cover constraint for (u, v) and Wi∗ , we know that r ′x(u,v) + X P ∈Pu,v \Wi∗ fP ≥ r ′ If r ′x(u,v) ≥ r ′/2 then x(u,v) ≥ 1/2 and thus (u, v) is included in E ′ with probability 1, satisfying (u, v). Otherwise it must be the case that PP ∈Pu,v \Wi∗ fP ≥ r ′/2. For P ∈ Pu,v , let IP be an indicator for the event that the T value of the middle vertex is at most α times the flow value fP (formally, if P = (u, z , v) then IP = 1Tz ≤αfP ), and observe that this event implies that both edges of P are included in E ′ (because then we have Tz ≤ min{x(u,z ) , x(z ,v) }). Note that for P ∈ Wi∗ , we have IP = 1 with probability 1. For P ∈ Pu,v \ Wi∗ , we have IP = 1 with probability at least αfP ∈ [0, 1]. The number of paths from Pu,v \ Wi∗ included in E ′ is clearly at least PP ∈Pu,v \Wi∗ IP , and we can bound that last quantity (which is a sum of independent indicators) by a Chernoff bound (see e.g. [MR95, DP09]). Its expectation is E h X P ∈Pu,v \Wi∗ IP i ≥ X P ∈Pu,v \Wi∗ αfP ≥ αr ′/2, so by our choice of α = C log n for a large enough C , Pr h X P ∈Pu,v \Wi∗ IP ≤ αr ′/4i ≤ e−Ω(αr ′ ) ≤ 1/nΩ(C ) ≤ 1/n3 . (5) 8 Thus, with high probability the total number of length 2 paths between u and v included in E ′ is at least i∗ + αr ′/4 ≥ r + 1, and thus (u, v) is satisfied. The theorem follows by taking a union bound over these events for all edges (u, v), and the aforementioned event that the solution’s cost exceeds 6α times the LP value. 3.4 Bounded-Degree Graphs When the maximum degree of the graph is bounded by ∆ and the edge costs ce are all 1, we can improve Theorem 3.3 slightly and give an O(log ∆)-approximation. We simply change the inflation parameter α in Algorithm 1 to be O(log ∆) instead of O(log n). We then need a more careful analysis, using an algorithmic version of the Lov´asz Local Lemma. Theorem 3.4. There is a (randomized) O(log ∆)-approximation for the (directed) r-fault tolerant 2-spanner problem on graphs in which ce = 1 for al l e ∈ E and the maximum (in and out) degree is at most ∆ ≥ 2. We shall use the following constructive version of the symmetric Lov´asz Local Lemma, which is an immediate corollary of the nonsymmetric version proved by Moser and Tardos [MT10]. Lemma 3.5 (Moser and Tardos [MT10]). Let P be a finite set of mutual ly independent random variables in a probability space. Let A be a finite set of events determined by the variables in P . Suppose that each A ∈ A is mutual ly independent of al l but at most d other events in A, and suppose that Pr[A] ≤ p for al l A ∈ A. If ep(d + 1) ≤ 1 then there exists an assignment of values to the variables P such that no event A ∈ A occurs. Moreover, there is a randomized algorithm that finds such an assignment in expected time O(P + A · P /d). Proof of Theorem 3.4. Consider a directed graph G with unit edges costs ce = 1 and vertex degrees bounded by ∆. Consider a solution to the LP relaxation (4), and apply Algorithm 1 to it but with inflation factor α = C log ∆ instead of C log n. For an edge (u, v) ∈ E , let Au,v be the event that E ′ does not satisfy this edge, i.e. (u, v) 6∈ E ′ and the graph G′ = (V , E ′ ) has less than r + 1 paths of length 2 from u to v . The analysis of Theorem 3.3 shows (after modifying (5) with our new value of α), that Pr[Au,v ] ≤ e−Ω(α) ≤ 1/∆Ω(C ) . Furthermore, note that Au,v depends only on the random variables Tz for z ∈ (N + (u)∩N − (v))∪{u}. Here and throughout, N + (u) and N − (u) denote the out-neighbors and in-neighbors of u ∈ V , respectively. Observe that Au,v is independent of all but ∆3 other events Au′ ,v′ , simply because there are at most ∆ choices for each of z , u′ , and v ′ . We could now apply Lemma 3.5 to these events. The underlying mutually independent random variables P would be the Tu variables, and the “bad events” A would be the events Au,v . This would give us an algorithm that in polynomial time returned a valid r-fault tolerant k-spanner, but we also need a bound on the cost of this spanner. The analysis via Markov’s inequality in Theorem 3.3 is too weak now, because when we apply the algorithm of Lemma 3.5 we change the overall distribution in a way that might destroy the cost bound. We need to integrate the cost analysis into the events that Lemma 3.5 is applied to, so at a high level we employ a more local approach where the cost of E ′ is split among the vertices and events bounding the cost are added to the Au,v events. More specifically, we shall create many events, each of which controls how the 9 cost of E ′ compares local ly with the cost of the LP, and then apply the Local Lemma to the new events together with the {Au,v } events. A formal argument follows. For each vertex u ∈ V , let the random variable Z + u be the number of outgoing edges (u, v) for which Tv ≤ α · xu,v , and let Z − u be the number of incoming edges (v , u) for which Tv ≤ α · xu,v . Informally, Z + u + Z − u is the number of edges incident to u whose inclusion in E ′ can be charged to their other endpoint. The algorithm’s cost is E ′ ≤ Pu∈V (Z + u + Z − u ), since every edge (u, v) included in E ′ adds 1 to either Z + u or Z − v (or both). For each vertex v ∈ V , let Bu be the event that Z + u + Z − u > 4α(P(u,v)∈E xu,v + P(v,u)∈E xv,u ). We would like to show that this event happens only with small probability. Note that E[Z + u ] = P(u,v)∈E min{αxu,v , 1} ≤ α P(u,v)∈E xu,v , so by a Chernoff bound (see e.g. [MR95, DP09]) we get xu,v i ≤ e−(1/3)(C ln ∆) P(u,v)∈E xu,v ≤ ∆−C/3 , Pr hZ + u > 2α X (u,v)∈E where in the final inequality we assume there is at least one outgoing edge from u and thus P(u,v)∈E xu,v ≥ 1 (since otherwise Z + u = 0 with probability 1). Using a similar argument to bound Z − u , we get Pr[Bu ] ≤ Pr hZ + u > 2α X (u,v)∈E xu,v i + Pr hZ − u > 2α X (v,u)∈E xv,ui ≤ 2∆−C/3 . We now apply Lemma 3.5 to the events and Au,v and Bu . Note that Bu depends only on the random variables Tz for z ∈ N + (u) ∪ N − (u), and recall that Au,v depends only on Tz for z ∈ N + (u) ∩ N − (v). Thus each event is mutually independent of all but O(∆3 ) other events — for an event Au,v we exclude at most ∆3 events Au′ ,v′ and at most 2∆2 events Bu′ ; for an event Bu we exclude at most 4∆2 events Bu′ and at most 2∆3 events Au′ ,v′ . We can thus apply the Lemma 3.5 with dependency parameter d = O(∆3 ), because by setting sufficiently large C , the probability of each event is at most a suitable p = ∆−Ω(C ) < 1/e(d + 1). Since the number of events is at most O(n2 ) and the number of underlying variables is only n, we conclude that there is a polynomial time algorithm to find the underlying variables Tu so that none of the events Au,v and Bu occur. This implies that G′ = (V , E ′ ) is an r-fault tolerant 2-spanner of G of cost E ′ ≤ X u∈V u (cid:1) ≤ 8α X u + Z − (cid:0)Z + (u,v)∈E cu,v xu,v ≤ O(log ∆) · LP, which proves Theorem 3.4. 3.5 Distributed Construction We now show how to adapt and use the O(log n)-approximation that we designed in Section 3.3 to give a distributed O(log n)-approximation. We will assume that communication along an edge is bidirectional, even if the graph is directed. The main problem that we run into when trying to design a distributed algorithm based on Algorithm 1 is solving the linear program. If we had a solution, and every vertex knew the xe value of its incident edges, then we would be done; the rounding scheme in Algorithm 1 is entirely local, so every vertex v ∈ V would just locally pick its threshold Tv and include the appropriate edges. If we want both endpoints of an edge to know that 10 it has been included in the spanner, we can then just have every vertex tell all of its neighbors (in a single round) which edges it bought based on its threshold. In order to (approximately) solve the LP we partition the graph into clusters, solve the LP separately on each cluster, and then repeat this process several times, eventually taking the average. This technique is quite similar to the work of Kuhn, Moscibroda, and Wattenhofer [KMW06], who showed how to approximately solve positive LPs using the graph decompositions of Linial and Saks [LS93]. The fundamental tool that we will use is the ability to quickly compute a good padded de- composition, which is a basic tool in metric embeddings, but has found numerous applications in approximation and online algorithms (e.g. for network design problems). This notion is essentially a version of low-diameter decompositions, such as a sparse covers [AP90]. This specific version was (probably) introduced by Rao [Rao99], who observed it is can be derived from an earlier con- struction of Klein, Plotkin and Rao [KPR93]. An explicit formulation of padded decompositions appeared only later, in [KL03, GKL03], and used a construction of Bartal [Bar96]. The definition given below is actually a special case of the usual notion, where the so-called padding requirement is a unit radius around each vertex, i.e. just the vertex’s neighborhood. Let T = T (V ) denote the set of all partitions of V (irrespective of the graph structure). For a partition P ∈ T , we call each set C ∈ P a cluster. Let G′ be the undirected graph corresponding to G, and define the diameter of C to be diam(C ) = maxu,v∈V dG′ (u, v) (this is usually called weak diameter, because it corresponds to the shortest u − v path in G′ , possibly going out of C along the way). Finally, for x ∈ V and a partition P ∈ T , we let P (x) denote the cluster of P that contains x. Definition 3.6. A padded decomposition of G is a probability measure µ on T that satisfies the following two conditions: 1. For every P ∈ supp(µ) and every C ∈ P we have diam(C ) ≤ O(log n). 2. For every x ∈ V we have PrP ∼µ [N (x) ⊆ P (x)] ≥ 1/2. It is known that every metric space admits such a padded decomposition, and there are polynomial-time randomized algorithms to sample from such a decomposition [Bar96, FRT04]. It is convenient to assign to each cluster a vertex, called the cluster center. One could always choose an arbitrary vertex in the cluster (e.g. one whose identifier is the smallest). The next lemma is a straightforward adaptation of the construction of Bartal [Bar96] to the distributed context; it can also be viewed as a slight modification to the graph decompositions of Linial and Saks [LS93]. Lemma 3.7. There is an algorithm in the LOCAL model that runs in O(log n) rounds and with high probability samples from a padded decomposition, so that every vertex knows the cluster containing it, meaning al l other vertices in the same cluster. Every cluster C also has a cluster center v ∈ V (which is not necessarily in the cluster) with the property that diam(C ∪ {v}) ≤ O(log n). Proof. The construction of Bartal [Bar96] is simple, and is usually described iteratively. (As men- tioned above, the padding property is not formally proved there, but it can be derived from the analysis therein, see also [KL03, GKL03]). Working in the metric completion of G (so removing vertices does not change distances), repeat the following procedure until every vertex has been assigned to some cluster: Pick an arbitrary vertex u from those that have not yet been assigned a cluster. Randomly pick a radius ru from the geometric distribution with some constant parameter 11 p > 0. Create a new cluster consisting of u and all unclustered vertices that are within distance ru of u. While this procedure is phrased iteratively, it quite obviously can be made distributed with only minor changes. First, every vertex u ∈ V locally chooses a value ru from the geometric distribution with parameter p. Then every node u simultaneously sends a message containing the ID of u to all nodes within distance min{ru , O(log n)} of u. Note that this take only O(log n) rounds, and with high probability maxu{ru } ≤ O(log n) (in fact we could truncate the exponential distribution so that ru is always less than O(log n), since the analysis of [KL03] shows that this does not significantly affect the padding probability). Now every node chooses as a cluster center the sender with the smallest ID (i.e. the sender that comes earliest in the lexicographic ordering) of the vertices whose messages it received. The only difference between the output of this algorithm and Bartal’s algorithm is that in Bartal only unclustered nodes can be the center of a new cluster, while in our variation every vertex (in lexicographic order) gets the chance to create a cluster (which it might not be a member of itself ). It is well known (see e.g. [KL03, GKL03]) that this change does not affect anything in the analysis. We remark that the construction above has a natural choice of cluster centers. Under this choice, a cluster C might not contain its center v ∈ V , but diam(C ∪ {v}) ≤ O(log n), which is sufficient for our purposes. Now that we can construct padded decompositions, we want to use them to decompose LP (4) into “local” parts. Let P be a partition sampled from µ. For each cluster C ∈ P , let N (C ) denote the set of vertices in V \ C that are adjacent to at least one vertex in C , let δ(C ) ⊆ E be all edges with one endpoint in C and one endpoint not in C , and let E (C ) ⊆ E be the set of edges with both endpoints in C . Let G(C ) be the subgraph of G induced by C ∪ N (C ). We define LP(C ) to be LP (4) for G(C ), but where edges in δ(C ) are modified to have cost 0. Let LP∗ be the value of an optimal solution to LP (4), and let LP∗ (C ) be the value of an optimal solution to LP(C ). Lemma 3.8. PC ∈P LP∗ (C ) ≤ LP∗ for every partition P ∈ T . Proof. Let hx, f i be an optimal fractional solution to LP (4). We want to use this solution to build fractional solutions to LP(C ) for all C ∈ P whose total cost is at most LP∗ . For each cluster C ∈ P , define a solution hxC , f C i for LP(C ) as follows: Let xC e = xe if e ∈ E (C ) and let xC e = 1 if e ∈ δ(C ). Note that this already satisfies all of the knapsack-cover constraints for edges in δ(C ). For edges (u, v) ∈ E (C ), note that every path in Pu,v appears in G(C ), so we can set f C P = fP for these paths. Since these flows satisfy the knapsack-cover constraints in LP (4), we now satisfy also the knapsack-cover constraints in LP(C ). All other flows f C P (e.g. between vertices in N (C )) are set to 0, and obviously the capacity constraints are satisfied, hence hxC , f C i is a feasible solution to LP(C ). Since in LP(C ) the edges in δ(C ) have cost 0, and every edge of E is in E (C ) for at most one cluster C , X C ∈P LP∗ (C ) = X C ∈P X e∈E (C ) e ≤ X ce xC e∈E ce xe = LP∗ , which proves the lemma. 12 We can now give our distributed algorithm for Minimum Cost r-Fault Tolerant 2-Spanner: 2 Algorithm 2: Distributed algorithm for r-fault tolerant 2-spanner. 1 for i ← 1 to t = O(log n) do Sample a partition Pi from µ using Lemma 3.7 ; cluster C ∈ Pi knows G(C ) The center of each cluster C ∈ Pi solves LP(C ) using Lemma 3.2, and sends the solution hxC,i , f C,i i to all vertices in C ; // we assume the center of each 3 // these are the iterations 4 For each edge (u, v) ∈ E , let I(u,v) = {i : Pi (u) = Pi (v)} ; in which both endpoints are in same cluster t Pi∈Ie xPi (e),i 5 xe ← min{1, 4 e endpoints of e 6 Round xe using Algorithm 1 ; } ; // Pi (e) is the cluster of Pi containing both // each edge is rounded by its endpoints Theorem 3.9. Algorithm 2 terminates in O(log2 n) rounds and computes (in expectation) an O(log n)-approximation to Minimum Cost r-Fault Tolerant 2-Spanner. Proof. We first prove the time bound. Lemma 3.7 implies that sampling from µ takes only O(log n) rounds, and since the diameter of every cluster is at most O(log n) the other two steps of the loop also take only O(log n) rounds. Since we execute the loop O(log n) times, the number of rounds needed to complete the loop is at most O(log2 n). After the loop, each vertex can compute xe for all incident edges e without any extra communication (since each endpoint of an edge e knows Ie and the LP values for that iteration). Finally, as already pointed out, the rounding of Algorithm 1 can be done locally, with one extra round used to make sure that both endpoints of an edge know if the edge was included by the rounding. Thus the total number of rounds is O(log2 n), as claimed. To prove that this algorithm returns an O(log n)-approximation, we will show that with high probability the xe values it computes form a feasible solution to LP (4) (when appropriate flow values fP are chosen) of cost at most O(LP∗ ). Once we have this, the analysis of Theorem 3.3 implies that the rounding step outputs (in expectation) a spanner G′ = (V , E ′ ) whose cost is O(log n) Pe ce xe ≤ O(log n) LP∗ , which is clearly an O(log n)-approximation as asserted in the the- orem. To bound the cost, note that the xe/4 values are just the averages of the LP(C ) values for all t Pt LP∗ (C ) ≤ rounds in which the edge e does not have cost 0. In other words, Pe ce xe ≤ 4 i=1 PC ∈Pi 4 LP∗ , where the final inequality is from Lemma 3.8. So it just remains to show that the xe ’s form a feasible solution to LP (4). To prove this, consider an edge e = (u, v), and let I ′ e ⊆ Ie be the set of iterations i in which N (u) ∪ {u} is all in the same cluster of Pi (where we fix u as one of the endpoints of e in an arbitrary manner). By the second property of padded decompositions, the probability that N (u)∪{u} is all in the same cluster is at least 1/2. The iterations are independent, so a straightforward Chernoff bound f Pi (u,v),i e ≥ t/4] ≥ 1 − 1/n3 . For a path P ∈ Pu,v , set fP = 1 implies that Pr[I ′ (u,v) Pi∈I ′ . I ′ P (u,v) In other words, the flow along a path from u to v is equal to the average flow along it in the LP solutions that were computed in iterations when N (u) ∪ {u} were all in the same cluster. The capacity constraints are obviously satisfied, since each iteration satisfies the capacity con- straints, and the edge capacities are scaled by 4/t while flows are scaled by a factor that can be only smaller. Note that here we depend on the fact that al l of N (u) is in the same cluster as u; if 13 some vertex z ∈ N (u) were in a different cluster, then in the LP solution for the cluster containing u and v there could be flow sent from u to v through z . This flow would not have the corresponding capacity added to the xe variables, which would be a problem. Similarly, consider the knapsack-cover constraint for some (u, v) ∈ E and some W ⊆ Pu,v with W ≤ r . Then since we could send enough flow in each iteration in I ′ (u,v) , when we take the average we can still send enough flow, i.e. (r + 1 − W ) xu,v + X P ∈Pu,v \W (cid:16) 4 u,v + X t (r + 1 − W )xi P ∈Pu,v \W (cid:16)(r + 1 − W )xi u,v + X P ∈Pu,v \W fP ≥ X i∈I ′ (u,v) 1 (u,v) X I ′ i∈I ′ (u,v) = r + 1 − W , ≥ (u,v) f Pi (u,v),i 1 I ′ P (cid:17) f Pi (u,v),i P (cid:17) where the last inequality is by the knapsack-cover constraint for the cluster Pi (u, v). Thus we have a valid LP solution, completing the proof. Remark: While for our purposes it was enough to solve the LP to within a constant factor (since we lose an O(log n) factor in the rounding anyway), it is easy to see that we could in fact solve the LP to within a (1 + ǫ) factor. First, we could change the padded decomposition to have the padding property (u and N (u) are all in the same cluster) to hold with probability at least 1 − ǫ, which would require increasing the diameter of the clusters, and thus the number of rounds it takes to solve the LP, by an O(1/ǫ) factor. Second, when we apply the Chernoff bound, instead of asking the number of times the padding event occurs to be at least t/4, we could ask that it is at least (1 − ǫ)2 t. By increasing t by an O(1/ǫ2 ) factor, we still get the right probabilities. Overall, the number of rounds would now be O(ε−3 log n). 4 Conclusions and Future Work This paper considers the problem of constructing r-fault tolerant spanners and gives two basic constructions. For general stretch bounds k ≥ 3, we show how to construct r-fault tolerant k- spanners whose size is at most polynomially (in r) larger than spanners without fault tolerance, improving over the previous exponential dependency (on r) of [CLPR09]. Our main technique is oversampling failure sets, in order to handle many of them in one iteration. An interesting open question is to provide lower bounds on the size of the best r-fault tolerant k-spanner; to the best of our knowledge, no such bounds are known other than those that apply even when r = 0. For k = 2 and unit edge lengths we design an O(log n)-approximation algorithm (for all r), improving over the previous O(r log n) factor of [DK10] and showing that the approximation ratio could be independent of the desired amount of fault tolerance r . Our main technique here is to design a new linear programming relaxation that includes the exponentially many knapsack-cover inequalities of [CFLP00]. We also provided a distributed version of the algorithm, and showed that when all edge costs are 1 the approximation can be improved to O(log ∆). An interesting open question is to improve this ratio to O(log E /V ), which would match the approximation known for the non-fault tolerant version. 14 References [ADD+ 93] I. Althofer, G. Das, D. Dobkin, D. Joseph, and J. Soares. On sparse spanners of weighted graphs. Discrete Comput. Geom., 9(1):81–100, 1993. [AP90] [AP95] B. Awerbuch and D. Peleg. Sparse partitions. In 31st Annual IEEE Symposium on Foundations of Computer Science, pages 503–513, 1990. B. Awerbuch and D. Peleg. Online tracking of mobile users. J. ACM, 42(5):1021–1058, 1995. [AYZ95] N. Alon, R. Yuster, and U. Zwick. Color-coding. J. ACM, 42(4):844–856, 1995. [Bar96] Y. Bartal. Probabilistic approximation of metric spaces and its algorithmic applications. In 37th Annual Symposium on Foundations of Computer Science, pages 184–193. IEEE, 1996. [CFLP00] R. D. Carr, L. K. Fleischer, V. J. Leung, and C. A. Phillips. Strengthening integrality gaps for capacitated network design and covering problems. In 11th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 106–115. SIAM, 2000. [CLPR09] S. Chechik, M. Langberg, D. Peleg, and L. Roditty. Fault-tolerant spanners for general graphs. In 41st Annual ACM Symposium on Theory of Computing, pages 435–444. ACM, 2009. [CZ03] A. Czuma j and H. Zhao. Fault-tolerant geometric spanners. In Proceedings of the 19th Annual Symposium on Computational Geometry, pages 1–10. ACM, 2003. [DGPV08] B. Derbel, C. Gavoille, D. Peleg, and L. Viennot. On the locality of distributed sparse spanner construction. In 27th Annual ACM Symposium on Principles of Distributed Computing, pages 273–282. ACM, 2008. [DK10] [DP09] M. Dinitz and R. Krauthgamer. Directed spanners via flow-based linear programs. CoRR, abs/1011.3701, 2010. D. Dubhashi and A. Panconesi. Concentration of Measure for the Analysis of Random- ized Algorithms. Cambridge University Press, New York, NY, USA, 2009. [EEST08] M. Elkin, Y. Emek, D. A. Spielman, and S.-H. Teng. Lower-stretch spanning trees. SIAM J. Comput., 38(2):608–628, 2008. [EP01] M. Elkin and D. Peleg. The client-server 2-spanner problem with applications to network design. In 8th International Col loquium on Structural Information and Communication Complexity (SIROCCO), pages 117–132. Carleton Scientific, 2001. [FRT04] J. Fakcharoenphol, S. Rao, and K. Talwar. A tight bound on approximating arbitrary metrics by tree metrics. J. Comput. Syst. Sci., 69(3):485–497, 2004. [GKL03] A. Gupta, R. Krauthgamer, and J. R. Lee. Bounded geometries, fractals, and low- distortion embeddings. In 44th Annual IEEE Symposium on Foundations of Computer Science, pages 534–543, October 2003. 15 [KL03] R. Krauthgamer and J. R. Lee. The intrinsic dimensionality of graphs. In Proceedings of the 35th ACM Symposium on Theory of Computing, pages 438–447, June 2003. [KMW06] F. Kuhn, T. Moscibroda, and R. Wattenhofer. The price of being near-sighted. In 27th Annual ACM-SIAM symposium on Discrete Algorithm, pages 980–989. ACM, 2006. [Kor01] [KP94] G. Kortsarz. On the hardness of approximating spanners. Algorithmica, 30(3):432–450, 2001. G. Kortsarz and D. Peleg. Generating sparse 2-spanners. J. Algorithms, 17(2):222–236, 1994. [KPR93] P. Klein, S. A. Plotkin, and S. Rao. Excluded minors, network decomposition, and multicommodity flow. In 25th Annual ACM Symposium on Theory of Computing, pages 682–690, May 1993. [LNS98] C. Levcopoulos, G. Narasimhan, and M. Smid. Efficient algorithms for constructing fault-tolerant geometric spanners. In 30th ACM Symposium on Theory of Computing, pages 186–195. ACM, 1998. [LS93] [Luk99] [MR95] [MT10] N. Linial and M. Saks. Low diameter graph decompositions. Combinatorica, 13(4):441– 454, 1993. T. Lukovszki. New results on fault tolerant geometric spanners. In Proceedings of the 6th International Workshop on Algorithms and Data Structures, WADS ’99, pages 193–204, London, UK, 1999. Springer-Verlag. R. Motwani and P. Raghavan. Randomized Algorithms. Cambridge University Press, 1995. R. A. Moser and G. Tardos. A constructive proof of the general Lov´asz Local Lemma. J. ACM, 57:11:1–11:15, February 2010. [Pel00] D. Peleg. Distributed computing: a locality-sensitive approach. SIAM, 2000. [PS89] D. Peleg and A. A. Schaffer. Graph spanners. J. Graph Theory, 13(1):99–116, 1989. [PU89] [Rao99] [ST04] D. Peleg and J. D. Ullman. An optimal synchronizer for the hypercube. SIAM J. Comput., 18:740–747, August 1989. S. Rao. Small distortion and volume preserving embeddings for planar and Euclidean metrics. In Proceedings of the 15th Annual Symposium on Computational Geometry, pages 300–306. ACM, 1999. D. A. Spielman and S.-H. Teng. Nearly-linear time algorithms for graph partitioning, graph sparsification, and solving linear systems. In 36th Annual ACM Symposium on Theory of Computing, pages 81–90. ACM, 2004. [TZ05] M. Thorup and U. Zwick. Approximate distance oracles. J. ACM, 52(1):1–24, 2005. [WY10] O. Weimann and R. Yuster. Replacement paths via fast matrix multiplication. In 51st Annual IEEE Symposium on Foundations of Computer Science, pages 655 –662, 2010. 16
1711.05135
3
1711
2018-04-07T23:37:42
Similarity-Aware Spectral Sparsification by Edge Filtering
[ "cs.DS", "math.NA", "cs.SI" ]
In recent years, spectral graph sparsification techniques that can compute ultra-sparse graph proxies have been extensively studied for accelerating various numerical and graph-related applications. Prior nearly-linear-time spectral sparsification methods first extract low-stretch spanning tree from the original graph to form the backbone of the sparsifier, and then recover small portions of spectrally-critical off-tree edges to the spanning tree to significantly improve the approximation quality. However, it is not clear how many off-tree edges should be recovered for achieving a desired spectral similarity level within the sparsifier. Motivated by recent graph signal processing techniques, this paper proposes a similarity-aware spectral graph sparsification framework that leverages efficient spectral off-tree edge embedding and filtering schemes to construct spectral sparsifiers with guaranteed spectral similarity (relative condition number) level. An iterative graph densification scheme is introduced to facilitate efficient and effective filtering of off-tree edges for highly ill-conditioned problems. The proposed method has been validated using various kinds of graphs obtained from public domain sparse matrix collections relevant to VLSI CAD, finite element analysis, as well as social and data networks frequently studied in many machine learning and data mining applications.
cs.DS
cs
Similarity-Aware Spectral Sparsification by Edge Filtering Department of Electrical and Computer Engineering Michigan Technological University Zhuo Feng Houghton, MI, 49931 [email protected] 8 1 0 2 r p A 7 ] S D . s c [ 3 v 5 3 1 5 0 . 1 1 7 1 : v i X r a ABSTRACT In recent years, spectral graph sparsification techniques that can compute ultra-sparse graph proxies have been exten- sively studied for accelerating various numerical and graph- related applications. Prior nearly-linear-time spectral spar- sification methods first extract low-stretch spanning tree from the original graph to form the backbone of the spar- sifier, and then recover small portions of spectrally-critical off-tree edges to the spanning tree to significantly improve the approximation quality. However, it is not clear how many off-tree edges should be recovered for achieving a de- sired spectral similarity level within the sparsifier. Moti- vated by recent graph signal processing techniques, this pa- per proposes a similarity-aware spectral graph sparsification framework that leverages efficient spectral off-tree edge em- bedding and filtering schemes to construct spectral sparsi- fiers with guaranteed spectral similarity (relative condition number) level. An iterative graph densification scheme is introduced to facilitate efficient and effective filtering of off- tree edges for highly ill-conditioned problems. The proposed method has been validated using various kinds of graphs ob- tained from public domain sparse matrix collections relevant to VLSI CAD, finite element analysis, as well as social and data networks frequently studied in many machine learning and data mining applications. Categories and Subject Descriptors B.7.2 [Design Aids]: simulation-Integrated Circuits General Terms Performance, Algorithms, Verification Keywords Spectral graph theory, graph partitioning, iterative methods 1. INTRODUCTION Spectral methods are playing increasingly important roles in many graph and numerical applications [22], such as scien- tific computing [20], numerical optimization [3], data mining [14], graph analytics [10], machine learning [7], graph signal Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. DAC'18, June 24–29, 2018, San Francisco, CA, USA Copyright 2018 ACM 978-1-4503-5700-5/18/06 ...$15.00 https://doi.org/10.1145/3195970.3196114. processing [16], and VLSI computer-aided design [9,23]. For example, classical spectral graph partitioning (data cluster- ing) algorithms embed original graphs into low-dimensional space using the first few nontrivial eigenvectors of graph Laplacians and subsequently perform graph partitioning (data clustering) on the low-dimensional graphs to obtain high- quality solution [14]. Recent spectral graph sparsification research [2, 4, 12, 14, 17,19] allows computing nearly-linear-sized subgraphs (spar- sifiers) that can robustly preserve the spectrum (i.e., eigen- values and eigenvectors) of the original graph's Laplacian, which immediately leads to a series of theoretically nearly- linear-time numerical and graph algorithms for solving sparse matrices, graph-based semi-supervised learning (SSL), spec- tral graph partitioning (data clustering), and max-flow prob- lems [3, 11, 19, 20]. For example, sparsified circuit networks allow for developing more scalable computer-aided (CAD) design algorithms for designing large VLSI systems [9, 23]; sparsified social (data) networks enable to more efficiently understand and analyze large social (data) networks [22]; sparsified matrices can be immediately leveraged to accel- erate the solution computation of large linear system of equations [24]. To this end, a spectral sparsification algo- rithm leveraging an edge sampling scheme that sets sam- pling probabilities proportional to edge effective resistances (of the original graph) has been proposed in [17]. A practically-efficient, nearly-linear complexity spectral graph sparsification algorithm has been recently introduced in [9], which first extracts a "spectrally critical" spanning tree subgraph as a backbone of the sparsifier, and subse- quently recovers a small portion of dissimilar "spectrally critical" off-tree edges to the spanning tree. However, in many scientific computing and graph-related applications, it is important to compute spectral graph sparsifiers of de- sired spectral similarity level: introducing too few edges may lead to poor approximation of the original graph, whereas too many edges can result in high computational complexity. For example, when using a preconditioned conjugate gradi- ent (PCG) solver to solve a symmetric diagonally dominant (SDD) matrix for multiple right-hand-side (RHS) vectors, it is hoped the PCG solver would converge to a good solution as quickly as possible, which usually requires the sparsifier (preconditioner) to be highly spectrally-similar to the origi- nal problem; on the other hand, in many graph partitioning tasks, only the Fielder vector (the first nontrivial eigenvec- tor) of graph Laplacian is needed [18], so even a sparsifier with much lower spectral similarity will suffice. This paper introduces a similarity-aware spectral graph sparsification framework that leverages efficient spectral off- tree edge embedding and filtering schemes to construct spec- tral sparsifiers with guaranteed spectral similarity. The con- tribution of this work has been summarized as follows: 1. We present a similarity-aware spectral graph sparsifi- cation framework by leveraging spectral off-tree edge embedding and filtering schemes that have been moti- vated by recent graph signal processing techniques [16]. 2. An iterative graph densification procedure is proposed to incrementally improve the approximation of the spar- sifier, which enables to flexibly trade off the complexity and spectral similarity of the sparsified graph. 3. Extensive experiments have been conducted to vali- date the proposed method in various numerical and graph-related applications, such as solving sparse SDD matrices, and spectral graph partitioning, as well as simplification of large social and data networks. 2. SPECTRAL GRAPH SPARSIFICATION Consider a graph G = (V, E, w) with V denoting the ver- tex (data point) set of the graph, E denoting the edge set of the graph, and w denoting a weight (similarity) function that assigns positive weights to all edges. The graph Lapla- cian LG of G is an SDD matrix defined as follows: if (p, q) ∈ E if (p = q) −w(p, q) (cid:80) w(p, t) LG(p, q) = (1)  (p,t)∈E 0 otherwise . Spectral graph sparsification [19] aims to preserve the original graph spectrum within ultra-sparse subgraphs (graph sparsifiers), which allows preserving not only cuts in the graph but also eigenvalues and eigenvectors of the original graph Laplacian, distances (e.g. effective resistances) be- tween vertices, low-dimensional graph embedding, etc. Two graphs G and P are said to be σ−spectrally similar if for all real vectors x ∈ RV their quadratic forms satisfy: xT LPx σ ≤ xT LGx ≤ σxT LPx. (2) Define the relative condition number to be κ(LG, LP) = λmax/λmin, where λmax and λmin denote the largest and smallest generalized eigenvalues satisfying: LGu = λLPu, (3) with u denoting the generalized eigenvector of λ. It can be further shown that κ(LG, LP) ≤ σ2, which indicates that a smaller relative condition number or σ2 corresponds to a higher spectral similarity. Obviously, we can simply use σ2 to denote the upper bound of the relative condition number. 3. SIMILARITY-AWARE SPECTRAL SPAR- SIFICATION BY EDGE FILTERING 3.1 Overview of Our Approach The overview of the proposed method for similarity-aware spectral sparsification of undirected graphs has been summa- rized as follows. For a given input graph, the following key procedures are involved in the proposed algorithm flow: (a) low-stretch spanning tree [1, 8] extraction based on its orig- inal graph Laplacian; (b) spectral (generalized eigenvalue) embedding and filtering of off-tree edges by leveraging the recent spectral perturbation analysis framework [9]; (c) in- cremental sparsifier improvement (graph densification) by gradually adding small portions of dissimilar off-tree edges to the spanning tree. Fig. 1 shows the spectral drawings [10] of an airfoil graph [6] as well as its spectrally-similar sub- graph computed by the proposed similarity-aware spectral sparsification algorithm. Figure 1: Two spectrally-similar airfoil graphs. In the rest of this paper, we assume that G = (V, E, w) is a weighted, undirected and connected graph, whereas P = (V, Es, ws) is its sparsifier. To simplify the our analysis, we assume the edge weights in the sparsifier remain the same as the original ones, though edge re-scaling schemes [19] can be applied to further improve the approximation. The de- PLG are denoted by λmax = λ1 ≥ scending eigenvalues of L+ λ2 ≥ ··· ≥ λn ≥ 1, where L+ P denotes the Moore-Penrose pseudoinverse of LP. 3.2 Spectral Embedding of Off-Tree Edges It has been shown that there are not too many large gen- eralized eigenvalues for spanning-tree sparsifiers [21]: L+ PLG has at most k generalized eigenvalues greater than stP (G) , where stP (G) denotes the total stretch of the spanning-tree subgraph P with respect the original graph G. Recent re- search results show that every undirected graph has a low- stretch spanning tree (LSST) such that [1, 8]: k O(m log n log log n) ≥ stP (G) = Trace(L+ PLG) = λi, i=1 (4) where m = E and n = V . As a result, it is possible to construct an ultra-sparse yet spectrally similar sparsifier by recovering only a small portion of important off-tree edges to the spanning tree: for example, σ-similar spectral sparsi- fiers with O( m log n log log n ) off-tree edges can be computed efficiently using perturbation-based method [9]. σ2 To identify important off-tree edges the following gener- alized eigenvalue perturbation analysis is considered [9]: LG (ui + δui) = (λi + δλi) (LP + δLP) (ui + δui) , (5) n(cid:88) where a perturbation matrix δLP is applied for the inclusion of extra off-tree edges into LP and results in perturbed gen- eralized eigenvalues and eigenvectors λi+δλi and ui+δui for i = 1, ..., n, respectively. The key to effective spectral sparsi- fication is to identify the key off-tree edges that will result in the greatest reduction in dominant generalized eigenvalues. To this end, the following scheme for embedding generalized eigenvalues into each off-tree edge is adopted in this work [9]: Step 1: Start with an initial random vector h0 = αiui, n(cid:80) i=1 where ui are the LP-orthogonal generalized eigenvectors of i LPuj = 1 for i = j, and 0 for i (cid:54)= j; L+ Step 2: Perform t-step generalized power iterations with PLG that satisfy uT h0 to obtain ht = (cid:0)L+ (cid:1)t h0 = αiλt iui; ht will be a PLG n(cid:80) i=1 good approximation of dominant eigenvectors; Step 3: Compute the Laplacian quadratic form for δLP,max = -0.02-0.02-0.03-0.0100-0.020.010.020.030.04(cid:131)0.040.020 LG − LP with ht: = (cid:80) (p,q)∈E\Es n(cid:80) i=1 (cid:1)2(λi − 1) n(cid:80) (cid:1)2 i=1 (cid:0)αiλt = (cid:80) i (p,q)∈E\Es (cid:0)ui QδLP,max (ht) = ht TδLP,maxht = wp,q α2 i λ2t i T ep,q heat(p,q), (6) where δLP,max denotes the perturbation of LP including all off-tree edges, ep,q ∈ Rn denotes the vector that has the p-th element being 1, the q-th element being −1 and oth- ers being 0, and heat(p,q) denotes the edge Joule heat of the off-tree edge (p, q). The amplitude of QδLP,max (ht) re- flects the spectral similarity between graphs P and G: larger QδLP,max (ht) indicates greater σ2 and thus lower spectral similarity. More importantly, (6) allows embedding general- ized eigenvalues into the Laplacian quadratic form of each off-tree edge and ranking each off-tree edge according to its edge Joule heat (spectral criticality): recovering the off-tree edges with largest heat(p,q) will most significantly decrease the largest generalized eigenvalues. In practice, using a small number (e.g. t = 2) of generalized power iterations will suf- fice for spectral edge embedding purpose. 3.3 "Spectrally-Unique" Off-Tree Edges To simplify the following analysis, we define a "spectrally unique" off-tree edge ei to be the one that connects to ver- tices pi and qi, and only impacts a single large generalized eigenvalue λi. Then the truncated version of (6) including the top k dominant "spectrally-unique" off-tree edges for fix- ing the top k largest eigenvalues of L+ PLG can be expressed as follows for λi (cid:29) 1: QδLP,max (ht) ≈ k(cid:80) i=1 (cid:0)ui (cid:1)2 ≈ k(cid:80) i=1 wpi,qi α2 i λ2t i T epi,qi α2 i λ2t+1 i . (7) Since each off-tree edge only impacts one generalized eigen- value, we can express epi,qi = γiLPui according to (6), which leads to: (cid:26) γi, i = j, 0, i (cid:54)= j. uT j epi,qi = (8) (9) Then the effective resistance of edge ei in P becomes: Reff ei = eT pi,qi L+ Pepi,qi = γ2 i uT i LPui = γ2 i , which immediately leads to: QδLP,max (ht) ≈ k(cid:88) ei ≈ k(cid:88) α2 i λ2t i wpi,qi Reff α2 i λ2t+1 i . (10) i=1 i=1 Since the stretch of off-tree edge ei is computed by stP (ei) = ei , (10) also indicates that stP (ei) ≈ λi holds for wpi,qi Reff "spectrally-unique" off-tree edges. Consequently, the key off-tree edges identified by (6) or (10) will have the largest stretch values and therefore most significantly impact the largest eigenvalues of L+ PLG. (10) also can be considered as a randomized version of Trace(L+ PLG) that is further scaled up by a factor of λ2t i . 3.4 Spectral Sparsification as A Graph Filter Although (6) and (10) provide a spectral ranking for each off-tree edge, it is not clear how many off-tree edges should be recovered to the spanning tree for achieving a desired spectral similarity level. To this end, we introduce a sim- ple yet effective spectral off-tree edge filtering scheme mo- tivated by recent graph signal processing techniques [16]. To more efficiently analyze signals on general undirected graphs, graph signal processing techniques have been exten- sively studied recently [16]. There is a clear analogy between traditional signal processing based on classical Fourier anal- ysis and graph signal processing: 1) the signals at different time points in classical Fourier analysis correspond to the signals at different nodes in an undirected graph; 2) the more slowly oscillating functions in time domain correspond to the graph Laplacian eigenvectors associated with lower eigenval- ues and more slowly varying (smoother) components across the graph. A comprehensive review of fundamental signal processing operations, such as filtering, translation, modu- lation, dilation, and down-sampling to the graph setting has been provided in [16]. Spectral sparsification aims to maintain a simplest sub- graph sufficient for preserving the slowly-varying or "low- frequency" signals on graphs, which therefore can be re- garded as a "low-pass" graph filter. In other words, such spectrally sparsified graphs will be able to preserve the eigen- vectors associated with low eigenvalues more accurately than high eigenvalues, and thus will retain "low-frequency" graph signals sufficiently well, but not so well for highly-oscillating (signal) components due to the missing edges. In practice, preserving the spectral (structural) proper- ties of the original graph within the spectral sparsifier is key to design of many fast numerical and graph-related al- gorithms [3, 11, 17, 20]. For example, when using spectral sparsifier as a preconditioner in preconditioned conjugate gradient (PCG) iterations, the convergence rate only de- pends on the spectral similarity (or relative condition num- ber) for achieving a desired accuracy level, while in spec- tral graph partitioning and data clustering tasks only the first few eigenvectors associated with the smallest nontrivial eigenvalues of graph Laplacian are needed [14, 18]. 3.5 Off-Tree Edge Filtering with Joule Heat To only recover the off-tree edges that are most critical for achieving the desired spectral similarity level, we propose the following scheme for truncating "spectrally-unique" off-tree edges based on each edge's Joule heat. For a spanning-tree preconditioner, since there will be at most k generalized eigenvalues that are greater than stP (G)/k, the following simple yet nearly worst-case generalized eigenvalue distri- bution can be assumed: λi = 2λmax i + 1 = stP (G) i + 1 , i ≥ 1. (11) To most economically select the top-k "spectrally-unique" off-tree edges that will dominantly impact the top-k largest generalized eigenvalues, the following sum of quadratic forms (Joule heat levels) can be computed based on (10) by per- forming t-step generalized power iterations with r multiple random vectors ht,1, ..., ht,r: QδLP,max (ht,1, ..., ht,r) ≈ r(cid:88) k(cid:88) (αi,j)2 j=1 i=1 (cid:18) 2λmax (cid:19)2t+1 . i + 1 (12) The goal is to select top k "spectrally-unique" off-tree edges for fixing the top k largest generalized eigenvalues such that the resulting upper bound of the relative condition number will become σ2 = λmax , where λmax and λmin denote the λmin largest and smallest eigenvalues of L+ PLG after adding top-k "spectrally-unique" off-tree edges. Then we have: k = 2λmax/λmax − 1. (13) When using multiple random vectors for computing (12), it α2 j=1 r(cid:80)  r(cid:80) r(cid:80) j=1 j=1 α2 k,j ≈ r(cid:80) (cid:18) λmax λmax α2 k,j α2 1,j j=1 θk = heatλk heatλ1 = is expected that 1,j, which allows us to define the normalized edge Joule heat θk for the k-th "spectrally- unique" off-tree edge through the following simplifications: (cid:19)2t+1 ≈ (cid:18) σ2λmin (cid:19)2t+1 λmax and sparsified Laplacians, λmin can be subsequently com- puted. By restricting the values in x to be only 1 or 0, which can be considered as assigning one of the two colors to each node in graphs G and P , the following simplifications can be made: . λmin ≈ minx(cid:54)=0 x(i)∈{0,1} xTLGx xTLPx = minx(cid:54)=0 x(i)∈{0,1} x(p)(cid:54)=x(q),(p,q)∈E x(p)(cid:54)=x(q),(p,q)∈Es wpq , wpq (cid:80) (cid:80) (14) The key idea of the proposed similarity-aware spectral spar- sification is to leverage the normalized Joule heat (14) as a threshold for filtering off-tree edges: only the off-tree edges with normalized Joule heat values greater than θk will be se- lected for inclusion into the spanning tree for achieving the desired spectral similarity (σ) level. Although the above scheme is derived for filtering "spectrally-unique" off-tree edges, general off-tree edges also can be filtered using similar strategies. Since adding the off-tree edges with largest Joule heat to the subgraph will mainly impact the largest gener- alized eigenvalues but not the smallest ones, we will assume λmin ≈ λmin, and use the following edge truncation scheme for filtering general off-tree edges: the off-tree edge (p, q) will be included into the sparsifier if its normalized Joule heat value is greater than the threshold determined by: (cid:18) σ2λmin (cid:19)2t+1 heat(p,q) heatmax ≥ θσ ≈ , λmax θ(p,q) = (15) where θσ denotes the threshold for achieving the σ−spectral similarity in the sparsifier, and heatmax denotes the maxi- mum Joule heat of all off-tree edges computed by (6) with multiple initial random vectors. 3.6 Estimation of Extreme Eigenvalues To achieve the above spectral off-tree edge filtering scheme, we need to compute θσ in (15) that further requires to es- timate the extreme eigenvalues λmax and λmin of L+ PLG. In this work, we propose the following efficient methods for computing these extreme generalized eigenvalues. 3.6.1 Estimating λmax via Power Iterations Since generalized power iterations converge at a geometric rate determined by the separation of the two largest gen- eralized eigenvalues λmax = λ1 > λ2 , the error of the estimated eigenvalue will decrease quickly when λ2/λ1 is It has been shown that the largest eigenvalues of small. L+ PLG are well separated from each other [21], which thus leads to very fast convergence of generalized power itera- tions for estimating λ1. To achieve scalable performance of power iterations, we can adopt recent graph-theoretic alge- braic multigrid (AMG) methods for solving the sparsified Laplacian matrix LP [13, 24]. 3.6.2 Estimating λmin via Node Coloring Since the smallest eigenvalues of L+ PLG are crowded to- gether [21], using (shifted) inverse power iterations may not be efficient due to the extremely slow convergence rate. To the extent of our knowledge, none of existing eigenvalue de- composition methods can efficiently compute λmin. This work exploits the following Courant-Fischer theorem for generalized eigenvalue problems: λmin = minx(cid:54)=0 xTLGx xTLPx , (16) where x is also required to be orthogonal to the all-one vec- tor. (16) indicates that if we can find a vector x that mini- mizes the ratio between the quadratic forms of the original (17) which will always allow estimating an upper bound for λmin. To this end, we first initialize all nodes with 0 value and subsequently try to find a node p such that the ratio between quadratic forms can be minimized: λmin ≈ min p∈V LG(p, p) LP (p, p) . (18) The above procedure for estimating λmin only requires find- ing the node with the smallest node degree ratio and thus can be easily implemented and efficiently performed for even very graph problems. Our results for real-world graphs show that the proposed method is highly efficient and can rea- sonably estimate the smallest generalized eigenvalues when compared with existing generalized eigenvalue methods [15]. 3.7 Iterative Graph Densification To achieve more effective edge filtering for similarity-aware spectral graph sparsification, we propose to iteratively re- cover off-tree edges to the sparsifier through an incremental graph densification procedure. Each densification iteration adds a small portion of "filtered" off-tree edges to the latest spectral sparsifier, while the spectral similarity is estimated to determine if more off-tree edges are needed. The i-th graph densification iteration includes the following steps: 1. Update the subgraph Laplacian matrix LP as well as its solver by leveraging recent graph-theoretic alge- braic multigrid methods [13, 24]; 2. Estimate the spectral similarity by computing λmax and λmin using the methods described in Section 3.6; 3. If the spectral similarity is not satisfactory, continue with the following steps; otherwise, terminate the sub- graph densification procedure. 4. Perform t-step generalized power iterations with O(log V ) random vectors to compute the sum of Laplacian quadratic forms (12); 5. Rank and filter each off-tree edge according to its nor- malized Joule heat value using the threshold θσ in (15); 6. Check the similarity of each selected off-tree edge and only add dissimilar edges to the latest sparsifier. 4. EXPERIMENTAL RESULTS The proposed spectral sparsification algorithm has been implemented in C++ 1. The test cases used in this paper have been selected from a great variety of matrices that have been used in circuit simulation, finite element analysis, ma- chine learning and data mining applications. If the original matrix is not a graph Laplacian, it will be converted into a graph Laplacian by setting each edge weight using the ab- solute value of each nonzero entry in the lower triangular matrix; if edge weights are not available in the original ma- trix file, a unit edge weight will be assigned to all edges. 1https://sites.google.com/mtu.edu/zhuofeng-graphspar Table 1: Results of extreme eigenvalue estimations. Test Cases λmin λmin λmin λmax λmax λmax 3.5% fe rotor 6.1% 3.8% 2.5% 2.0% 4.4% 120.9 116.7 10.5% 120.6 113.2 92.4 7.6% 96.0 90.3 4.3% 92.6 10.5% 84.4 82.7 pdb1HYS bcsstk36 brack2 raefsky3 1.34 1.71 1.18 1.15 1.13 1.40 1.89 1.27 1.20 1.25 Table 2: Results of iterative SDD matrix solver. Graphs E V 1.6E6 3.0E6 1.2E6 3.7E6 1.0E6 2.0E6 0.7E6 2.2E6 paraboli fem 0.5E6 1.6E6 G3 circuit thermal2 ecology2 tmt sym E50 V N50 T50 20s 1.11 23s 1.14 16s 1.14 16s 1.21 1.22 16s 21 20 20 19 18 E200 V 1.05 1.06 1.06 1.14 1.09 N200 T200 37 36 40 38 38 8s 9s 5s 4s 3s Table 3: Results of spectral graph partitioning. Test Cases V G3 circuit thermal2 ecology2 tmt sym 1.6E6 1.2E6 1.0E6 0.7E6 paraboli fem 0.5E6 1.0E6 4.5E6 9.0E6 mesh 1M mesh 4M mesh 9M V+ V− 1.35 1.00 1.03 0.99 0.98 1.01 0.99 0.99 TD (MD ) 52.3s (2.3G) 13.0s (0.9G) 12.1s (0.7G) 10.2s (0.6G) 8.8s (0.4G) 10.2s (0.7G) 49.6s (3.0G) 138.5s (6.9G) TI (MI ) Rel.Err. 7.6s (0.3G) 3.0s (0.2G) 3.4s (0.2G) 1.9s (0.1G) 2.4s (0.1G) 1.7s (0.2G) 8.2s (0.7G) 13.3s (1.5G) 2.2E-2 6.8E-4 8.9E-3 2.1E-2 3.9E-2 3.3E-3 7.5E-3 7.8E-4 Figure 2: Spectral edge ranking and filtering by nor- malized Joule heat of off-tree edges for G2 circuit (left) and T hermal1 (right) test cases [6] with top off-tree edges highlighted in red rectangles. All of our experiments have been conducted using a single CPU core of a computing platform running 64-bit RHEW 7.2 with a 2.67GHz 12-core CPU and 50 GB memory. 4.1 Estimation of Extreme Eigenvalues In Table 1, the extreme generalized eigenvalues (λmin and λmax) estimated by the proposed methods (Section 3.6) are compared with the ones (λmin and λmax) computed by the "eigs" function in Matlab for sparse matrices in [6], while the relative errors (λmin and λmax ) are also shown. λmax is estimated using less than ten generalized power iterations. We also illustrate the results of spectral edge ranking and filtering according to Joule heat levels computed by one-step generalized power iteration using (6) in Fig. 2 for two sparse matrices in [6]. The thresholds of normalized edge Joule heat values required for spectral edge filtering are labeled using red dash lines. It is observed in Fig. 2 there is a sharp change of the top normalized edge Joule heat values, which indicates that there are not many large eigenvalues of L+ PLG in both cases and agrees well with the prior theoretical analysis [21]. 4.2 A Scalable Sparse SDD Matrix Solver The spectral sparsifier obtained by the proposed similarity- aware algorithm is also leveraged as a preconditioner in a PCG solver. The RHS input vector b is generated ran- domly and the solver is set to converge to an accuracy level Ax − b < 10−3b for all test cases. "V " and "E" de- note the numbers of nodes and edges in the original graph, whereas "Eσ2", "Nσ2 " and "Tσ2 " denote the number of edges in the sparsifier, the number of PCG iterations required for converging to the desired accuracy level, and the total time of graph sparsification for achieving the spectral similarity of σ2, respectively. As observed in all test cases, there are very clear trade-offs between the graph density, computation time, and spectral similarity for all spectral sparsifiers ex- tracted using the proposed method: sparsifiers with higher spectral similarities (smaller σ2) allow converging to the re- quired solution accuracy level in much fewer PCG iterations, but need to retain more edges in the subgraphs and thus re- quire longer time to compute (sparsify). 4.3 A Scalable Spectral Graph Partitioner It has been shown that by applying only a few inverse power iterations, the approximate Fiedler vector (uf ) that corresponds to the smallest nonzero eigenvalue of the (nor- malized) graph Laplacian matrix can be obtained for ob- taining high-quality graph partitioning solution [20]. There- fore, using the spectral sparsifiers computed by the proposed spectral sparsification algorithm can immediately accelerate the PCG solver for inverse power iterations, leading to scal- able performance for graph partitioning problems [20]. In fact, if the spectral sparsifier is already a good approxima- tion of the original graph, its Fiedler vector can be directly used for partitioning the original graph. We implement the accelerated spectral graph partitioning algorithm, and test it with sparse matrices in [6] and sev- eral 2D mesh graphs synthesized with random edge weights. As shown in Table 3, the graphs associated with sparse ma- trices have been partitioned into two pieces using sign cut method [18] according to the approximate Fiedler vectors computed by a few steps of inverse power iterations. The direct solver [5] and the preconditioned iterative solver are invoked within each inverse power iteration for updating the V+ V− " approximate Fiedler vectors uf and uf , respectively. " denotes the ratio of nodes assigned with positive and nega- tive signs according to the approximate Fiedler vector, and "Rel.Err." denotes the relative error of the proposed solver compared to the direct solver computed by , where Vdif denotes the number of nodes with different signs in uf and uf . " TD" (" TI ") and "MD" (" MI ") denote the total solution time (excluding sparsification time) and memory cost of the direct (iterative) method. We extract sparsifiers with σ2 ≤ 200 for all test cases. 4.4 Sparsification of Other Complex networks As shown in Table 4, a few finite element, protein, data and social networks have been spectrally sparsified to achieve σ2 ≈ 100 using the proposed similarity-aware method. "Ttot" Vdif V Table 4: Results of complex network sparsification. Test Cases fe tooth appu coAuthorsDBLP auto RCV-80NN V 7.8E4 1.4E4 3.0E5 4.5E5 1.9E5 E 4.5E5 9.2E5 1.0E6 3.3E6 1.2E7 Ttot 3.0s 5.4s 7.2s 29.0s 46.5s E Es 5× 25× 3× 5× 36× λ1 λ1 eig (T s T o eig ) 8, 050× 14.5s (2.7s) 13, 624× 2,400s (15s) 1, 364× 2,047s (36s) 48, 190× N/A (54s) 28, 410× N/A (170s) (cid:131)G2_matrixThermal1Not too many large generalized eigenvalues!2500(cid:86)(cid:124)2100(cid:86)(cid:124)2500(cid:86)(cid:124)2100(cid:86)(cid:124) eig(T s is the total time for extracting the sparsifier, " λ1 " denotes λ1 the ratio of the largest generalized eigenvalues before and after adding off-tree edges into the spanning tree sparsifier, and T o eig) denotes the time for computing the first ten eigenvectors of the original (sparsified) graph Laplacians us- ing the "eigs" function in Matlab. Since spectral sparsifiers can well approximate the spectral (structural) properties of the original graph, the sparsified graphs can be leveraged for accelerating many numerical and graph-related tasks. For example, spectral clustering (partitioning) using the orig- inal "RCV-80NN" (80-nearest-neighbor) graph can not be performed on our server with 50GB memory, while it only takes a few minutes using the sparsified one. 5. CONCLUSIONS For the first time, this paper introduces a similarity-aware spectral graph sparsification framework that can be immedi- ately leveraged to develop fast numerical and graph-related algorithms. Motivated by recent graph signal processing concepts, an iterative graph densification procedure based on spectral embedding and filtering of off-tree edges has been proposed for extracting ultra-sparse yet spectrally-similar graph sparsifiers, which enables to flexibly trade off the com- plexity and spectral similarity of the sparsified graph in nu- merical and graph-related applications. Extensive experi- ment results have confirmed the effectiveness and scalability of an iterative matrix solver and a spectral graph partition- ing algorithm for a variety of large-scale, real-world graph problems, such as VLSI and finite element analysis prob- lems, as well as data and social networks. 6. ACKNOWLEDGMENTS This work is supported in part by the National Science Foundation under Grants CCF-1350206 and CCF-1618364. 7. REFERENCES [1] I. Abraham and O. Neiman. Using petal-decompositions to build a low stretch spanning tree. In Proceedings of the forty-fourth annual ACM symposium on Theory of computing (STOC), pages 395–406. ACM, 2012. [2] J. Batson, D. Spielman, and N. Srivastava. Twice-Ramanujan Sparsifiers. SIAM Journal on Computing, 41(6):1704–1721, 2012. [3] P. Christiano, J. Kelner, A. Madry, D. Spielman, and S. Teng. Electrical flows, laplacian systems, and faster approximation of maximum flow in undirected graphs. In Proc. ACM STOC, pages 273–282, 2011. [4] M. B. Cohen, J. Kelner, J. Peebles, R. Peng, A. B. Rao, A. Sidford, and A. Vladu. Almost-linear-time algorithms for markov chains and new spectral primitives for directed graphs. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, pages 410–419. ACM, 2017. [5] T. Davis. CHOLMOD: sparse supernodal Cholesky factorization and update/downdate. [Online]. Available: http://www.cise.ufl.edu/research/sparse/cholmod/, 2008. [6] T. Davis and Y. Hu. The university of florida sparse matrix collection. ACM Trans. on Math. Soft. (TOMS), 38(1):1, 2011. [7] M. Defferrard, X. Bresson, and P. Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems, pages 3844–3852, 2016. [8] M. Elkin, Y. Emek, D. Spielman, and S. Teng. Lower-stretch spanning trees. SIAM Journal on Computing, 38(2):608–628, 2008. [9] Z. Feng. Spectral graph sparsification in nearly-linear time leveraging efficient spectral perturbation analysis. In Design Automation Conference (DAC), 2016 53nd ACM/EDAC/IEEE, pages 1–6. IEEE, 2016. [10] Y. Koren. On spectral graph drawing. In International Computing and Combinatorics Conference, pages 496–508. Springer, 2003. [11] I. Koutis, G. Miller, and R. Peng. Approaching Optimality for Solving SDD Linear Systems. In Proc. IEEE FOCS, pages 235–244, 2010. [12] Y. T. Lee and H. Sun. An SDP-based Algorithm for Linear-sized Spectral Sparsification. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2017, pages 678–687, New York, NY, USA, 2017. ACM. [13] O. Livne and A. Brandt. Lean algebraic multigrid (LAMG): Fast graph Laplacian linear solver. SIAM Journal on Scientific Computing, 34(4):B499–B522, 2012. [14] R. Peng, H. Sun, and L. Zanetti. Partitioning well-clustered graphs: Spectral clustering works. In Proceedings of The 28th Conference on Learning Theory (COLT), pages 1423–1455, 2015. [15] Y. Saad. Numerical Methods for Large Eigenvalue Problems: Revised Edition, volume 66. Siam, 2011. [16] D. I. Shuman, S. K. Narang, P. Frossard, A. Ortega, and P. Vandergheynst. The emerging field of signal processing on graphs: Extending high-dimensional data analysis to networks and other irregular domains. IEEE Signal Processing Magazine, 30(3):83–98, 2013. [17] D. Spielman and N. Srivastava. Graph sparsification by effective resistances. SIAM Journal on Computing, 40(6):1913–1926, 2011. [18] D. Spielman and S. Teng. Spectral partitioning works: Planar graphs and finite element meshes. In Foundations of Computer Science (FOCS), 1996. Proceedings., 37th Annual Symposium on, pages 96–105. IEEE, 1996. [19] D. Spielman and S. Teng. Spectral sparsification of graphs. SIAM Journal on Computing, 40(4):981–1025, 2011. [20] D. Spielman and S. Teng. Nearly linear time algorithms for preconditioning and solving symmetric, diagonally dominant linear systems. SIAM Journal on Matrix Analysis and Applications, 35(3):835–885, 2014. [21] D. Spielman and J. Woo. A note on preconditioning by low-stretch spanning trees. arXiv preprint arXiv:0903.2816, 2009. [22] S.-H. Teng. Scalable algorithms for data and network analysis. Foundations and Trends® in Theoretical Computer Science, 12(1–2):1–274, 2016. [23] Z. Zhao and Z. Feng. A spectral graph sparsification approach to scalable vectorless power grid integrity verification. In Proceedings of the 54th Annual Design Automation Conference 2017, page 68. ACM, 2017. [24] Z. Zhao, Y. Wang, and Z. Feng. SAMG: Sparsified Graph Theoretic Algebraic Multigrid for Solving Large Symmetric Diagonally Dominant (SDD) Matrices. In Proceedings of the 36th International Conference on Computer-Aided Design (ICCAD). ACM, 2017.
1911.02356
1
1911
2019-11-06T13:10:54
In Search of Dense Subgraphs: How Good is Greedy Peeling?
[ "cs.DS" ]
The problem of finding the densest subgraph in a given graph has several applications in graph mining, particularly in areas like social network analysis, protein and gene analyses etc. Depending on the application, finding dense subgraphs can be used to determine regions of high importance, similar characteristics or enhanced interaction. The densest subgraph extraction problem is a fundamentally a non-linear optimization problem. Nevertheless, it can be solved in polynomial time by an exact algorithm based on the iterative solution of a series of maximum flow sub-problems. Despite its polynomial time complexity, the computing time required by the exact algorithms on very large graphs could be prohibitive. Thus, to approach graphs with millions of vertices and edges, one has to resort to heuristic algorithms. We provide an efficient implementation of a greedy heuristic from the literature that is extremely fast and has some nice theoretical properties. We also introduce a new heurisitic algorithm that is built on top of the greedy and the exact methods. An extensive computational study is presented to evaluate the performance of various solution methods on a benchmark composed of 86 instances taken from the literature. This analysis shows that the proposed heuristic algorithm proved very effective on a large number of test instances, often providing either the optimal solution or near-optimal solution within short computing times.
cs.DS
cs
In Search of Dense Subgraphs: How Good is Greedy Peeling? Naga V. C. Gudapati, Enrico Malaguti, Michele Monaci DEI, University of Bologna, Viale Risorgimento 2, I-40136 Bologna, Italy. {chaitanya.gudapati, enrico.malaguti, michele.monaci}@unibo.it Abstract The problem of finding the densest subgraph in a given graph has several applications in graph mining, particularly in areas like social network analysis, protein and gene analyses etc. Depending on the application, finding dense subgraphs can be used to determine regions of high importance, similar characteristics or enhanced interaction. The densest subgraph extraction problem is a fundamentally a non-linear optimization problem. Nevertheless, it can be solved in polynomial time by an exact algorithm based on the iterative solution of a series of maximum flow sub-problems. Despite its polynomial time complexity, the computing time required by the exact algorithms on very large graphs could be prohibitive. Thus, to approach graphs with millions of vertices and edges, one has to resort to heuristic algorithms. We provide an efficient implementation of a greedy heuristic from the literature that is extremely fast and has some nice theoretical properties. We also introduce a new heurisitic algorithm that is built on top of the greedy and the exact methods. An extensive computational study is presented to evaluate the performance of various solution methods on a benchmark composed of 86 instances taken from the literature. This analysis shows that the proposed heuristic algorithm proved very effective on a large number of test instances, often providing either the optimal solution or near-optimal solution within short computing times. Keywords. dense graphs, approximation, heuristic algorithms, computational experiments. 1. Introduction A graph is a mathematical structure containing vertices and edges that is often used to represent different real-life scenarios. Besides very traditional applications in transportation, mapping, logis- tics, etc., graphs may also be used to describe many social, biological, financial, and technological systems. In these cases, vertices represent individuals, cells, proteins, components, etc., and edges represent some kind of interaction between the vertices. As a result, Graph Theory is one of the most extensively researched areas in computer science. Graph networks that arise in real-life applications have edges which are either weighted or un- weighted. While unweighted edges simply represent some connection between two vertices, weighted edges are used to indicate the importance of a connection in the graph, or the time required for travelling on a given edge, or probability of an edge to occur in the network. The edges could be further directed or undirected: the former models one-way relationships, like the "follow" network in Twitter, while the latter are used for two-ways connections, for instance, Facebook friendships. One of the most interesting problems in social networks is the identification of dense areas. Intuitively, dense areas in a graph can be considered to be a subset of highly-connected vertices that correspond to regions where there is more interaction among the vertices. For instance, consider a network describing the interactions between various Internet service providers, exchange points, customers, and other related parties: identifying dense subgraphs in this network allows us to detect critical points of failure, which could further help in planning for contingencies to mitigate unplanned service outages. Similarly, for social networks, dense subgraphs identify areas 1 of common interests and communities. Many other examples, where finding dense subgraphs is a key problem are detailed in [17] and in [9]. 2. Definition of the Problem In this section we give a formal definition of the problem. Let G = (V, E) be an unweighted, undirected graph with vertex set V and edge set E. Through out the text, we will assume that G is a simple graph, i.e., there are no multiple edges connecting the same pair of vertices. The density of G, sometimes referred to as average degree, is defined as f (G) = E V , (1) and corresponds to the ratio between the number of edges and the number of vertices in the graph. For a given subset of vertices S ⊆ V , we define E(S) as the induced set of edges, i.e., E(S) = {e = (u, v) ∈ E : u ∈ S, v ∈ S}, and G(S) = (S, E(S)) as the subgraph induced by S. When no confusion arises, we will write that set S has a density f (S) = f (G(S)) = E(S) S (2) Given an unweighted graph G = (V, E), the Densest Subgraph Extraction (DSE) problem re- quires to determine a subset S ⊆ V of vertices that induces a subgraph of maximum density. As already mentioned, in many applications each edge e ∈ E has a positive weight we, which could, for instance, be used to represent the importance of a relationship between two vertices in the network. Weighted graphs can also be used to model a unique scenario where the actual edge set is unknown and each potential edge has associated a non-negative probability. In this probabilistic setting, one is interested in finding a subgraph that has a large probability to be the one with maximum density. This leads to a natural extension of the density definition (1) to the weighted case density of a weighted graph as f w(G) = we X e∈E V . (3) Similarly, we can define the weighted density for a given set S ⊆ V of vertices. The aforementioned density definitions are valid for undirected graphs only. For directed graphs, different definitions are typically used and we refer the interested reader to [6, 16]. The DSE problem has been studied since the early 1980s. Though this problem is fundamen- tally an unconstrained non-linear optimization problem, it can still be solved efficiently. Indeed, a flow-based algorithm to get an optimal solution of the problem for unweighted graphs was intro- duced in [18] and it requires utmost V max-flow (min-cut) operations on a network of V + 2 vertices i.e., it runs in polynomial time. Later, an alternative flow-based algorithm with better computational complexity was introduced in [12]. This algorithm determines the densest subgraph in only O(log(V )) max-flow operations and can be easily extended to weighted graphs. Finally, a parametric max-flow algorithm which can solve the DSE with a single max-flow computation was given in [10]. This parametric max-flow algorithm improves upon the complexity of the previous method described in [12] by a factor of log(V ) but that improvement in computational complexity can not be extended to weighted graphs. 2 Though solvable in polynomial time, computing densest subgraphs using flow-based algorithms could be very time consuming for very large graphs. Thus, when real-world applications that involve millions of vertices and edges are considered, one has to resort to heuristics. One of the most important heuristic algorithms for the DSE problem is the Greedy Peeling introduced in [3]. Besides being very fast in practice, this algorithm has nice theoretical properties. It has been proved in [6] that this algorithm has a worst-case 2-approximation, i.e., the density of the subgraph found by Greedy Peeling will be at least half of the density of the optimal subgraph. Finally, we mention a variant of the Greedy Peeling algorithm, introduced in [4], that can be implemented in a distributed way to reduce the memory requirement for storing all the data. The resulting algorithm produces a solution with a worst-case approximation of (2 + 2ǫ) for any ǫ > 0. In some applications, additional constraints are imposed to limit (either from below or from above) the size of set S; in this case, the resulting problem becomes an N P-hard problem. An extensive discussion on finding dense subgraphs with size bounds can be found in [2]. Many alternative definitions of density have been proposed in the literature. Indeed, the average degree may produce subgraphs that have a large number of vertices, and not extensively connected. For instance, a clique, which is intuitively a dense area in a graph, might not be the densest subgraph according to the average degree definition, as another larger and loosely connected subgraph could produce a bigger ratio according to (1). Additional considerations about the downsides of using definition (1) as a metric to find the dense subgraphs are given in [15]. A different density metric, called quasi-clique, was introduced in [20]; according to this definition, the density of graph G = (V, E) is given by f (G) = E(S) − α(cid:0)S 2 (cid:1), where α is a tuning parameter. This function tends to produce subgraphs that are relatively compact and well connected. The discounted average degree, proposed in [15], is defined as f (S) = E(S) Sβ , where β is a parameter that can be chosen to affect the size of the desired subgraph. The authors showed that this metric favours subgraphs that have certain desirable properties, like increased connectivity between vertices, and more compact subgraph. Other than these two definitions, depending on the type of graph, there have been many other definitions of density, see, e.g., [1, 5, 7]. While each of these metrics might give a more compact subgraph with respect to the average degree, there is no general consensus on the use of alternative metrics for finding dense subgraphs, and average degree remains the most common and accepted. Besides the average degree metric, other metrics based on density have been considered, like edge ratio, triangle density, and triangle ratio (see [19] for details). The rest of the paper is organized as follows. In Section 3 we will review the main exact and heuristic approaches from the literature for solving the DSE problem. Section 4 introduces a new Hybrid Algorithm that is built on top of Greedy Peeling and Exact Algorithms. All algorithms are computationally tested in Section 5 on a large set of graph instances taken from the literature including both unweighted and weighted graphs. Finally, in Section 6 we draw some conclusions. This paper has three main contributions. From a practical viewpoint, we introduce a simple heuristic algorithm that is built on top of the greedy heuristic and any exact method. Our proposed algorithm is typically very fast, produces solutions that improve over the greedy solution, and gives us near optimal solutions. From a theoretical point of view, we present a simple graph instance where the Greedy Peeling algorithm approaches its worst-case performance. To the best of our knowledge, there is only one contribution in the literature showing a similar behaviour of the Greedy Peeling algorithm (see [11]) but the example we present is simpler than the previous one. Finally, from a computational study perspective, we present a through computational study that is by far the most extensive reported in the literature for this class of problems. While most of the previous works in the literature have dealt with small or medium-sized instances, in this 3 paper we make a considerable step forward concerning the problem size by considering graphs with tens of millions of vertices and hundreds of millions of edges. Our computational study shows that the practical performance of the Greedy Peeling algorithm is much better than its theoretical guarantee, and that a further improvement can be achieved with limited computational effort. 3. Algorithms In this section we discuss solution approaches for the DSE problem proposed in the literature. The next section describes two exact algorithmic approaches, while Section 3.2 presents a greedy heuristic and analyzes its theoretical performance. 3.1 Exact algorithms The first exact algorithm we consider is the Goldberg's Algorithm which has been introduced in [12] and is a relatively fast exact algorithm to compute the densest subgraph in a given graph G. The algorithm primarily works by iteratively solving a series of max-flow problems on an augmented graph G′ which is constructed from the original G. At each iteration, the algorithm "guesses" the density value say g, defines an augmented graph G′ according to the current g value, and computes the maximum flow on G′. As the maximum density value will lie in the interval [0, E(S)], a binary search approach is used to determine the optimal g value. It is proved in [12] that, as the optimal g value can only take a finite set of values, the number of iterations of the algorithm is bounded by O(log(V )). There are many efficient algorithms for solving max-flow problem (see, e.g., [14]). Using the Push-Relabel algorithm (see [13]), the maximum flow problem can be solved in O(V 3) time, producing an overall O(log(V ) V 3) time complexity. A completely different exact solution method has been proposed in [6]. This approach describes the DSE problem by means of a Linear Programming (LP) model, that can be solved using any general-purpose LP solver. The LP model can also be easily extended to the weighted case with minor modifications. The model has V + E variables and two constraints per edge, i.e., its size is polynomial in the size of the input graph. Despite this, the constraint matrix of the formulation can be massive and the memory requirements to solve the model can be prohibitive for large graph instances. Typically this produces computational performances that are worse than those of the flow-based algorithm Goldberg's Algorithm discussed above. However, the LP model provides a good foundation for finding the densest subgraphs in directed graphs and its related proofs as discussed in [6]. 3.2 Greedy Peeling Algorithm For very large graph instances, the application of the exact algorithms described in the previous section may require large memory and long computational times. This is where heuristic approaches can be used for getting reasonably good solutions quickly. The heuristic algorithm described in this section produces subgraph whose density is usually close to the optimal one. As the objective of DSE is to find a subgraph with best average degree, the algorithm consists of starting with the initial graph and removing, one at a time, the vertex with smallest degree in the current graph. The resulting algorithm, called Greedy Peeling, is described in Figure 1 and can be naively implemented to run in O(n2) on a graph G = (V, E) with n = V vertices and m = E edges. To prove the time complexity it is enough to observe that there are n iterations; each iteration requires O(n) time to find the vertex u with minimum degree with respect to the current subgraph (breaking ties arbitrarily), and another O(n) time to update the subgraph once 4 u has been removed. A more efficient implementation can be obtained using a "degree-lists" data structure, in which a list is defined for each possible value of the degree of a vertex. All vertices with same degree are placed in the same list and lists are ordered by increasing degree. Using this data structure, the determination of the next vertex u to be removed can be done in constant time, taking an arbitrary vertex in the first non-empty list. Since removing vertex u decreases the degree of its neighbours by one unit, updating the graph (essentially data-lists) can be done by moving each neighbour of u from its current list to the previous one (i.e., to the list with degree one less than current degree). Since the number of vertex movements among the lists is equal to the number of edges of G, the time complexity of the algorithm is O(n + m). The results in this paper (see Section 5) correspond to this implementation of the algorithm. Algorithm Greedy Peeling(V, E) initialize: n := V , Sn := V ; for i = n to 1 do let u be the smallest degree vertex in G(Si); Si−1 := Si \ {u}; endfor SH := arg maxi=1,...,n f (Si); return SH Figure 1: Algorithm Greedy Peeling. The Greedy Peeling algorithm can be easily extended to the weighted case by selecting, at each iteration, vertex u as the one having the minimum weighted sum of all the incident edges with respect to the current subgraph. However, the linear time complexity of the algorithm is not preserved because the degree-lists data structure cannot be used for graphs with general weights. Using Fibonacci heaps to determine, at each iteration, the minimum weighted degree vertex, the algorithm runs in O(m + n log(n)), see [6]. The degree-lists implementation could however be used to determine the weighted dense subgraphs, similar to the unweighted case, if weights are either integer numbers or are all scaled to integers. In both cases, there is a considerable worsening in the performances of the algorithm as the number of lists to be considered is bounded by the maximum weight degree of all vertices, i.e., it is pseudo-polynomial in the size of the input (and is strongly dependent on the number of significative digits in the weight values, if these are not integer). In this paper, we use binary heaps to implement the Greedy Peeling algorithm for the weighted cases and report results for this implementation, which works for both rational and integer weights, and is very fast in practice even for large graphs. 3.2.1 Worst-case Analysis The theoretical performance of the Greedy Peeling algorithm was analyzed in [6] (and in [3] for a constrained version of the DSE problem), where the worst-case performance ratio of the algorithm was proved to be equal to 2. To the best of our knowledge, the only example for which the approximation is asymptotically tight has been given in [20]. As the given instance is somehow complicated and for the sake of completeness, we report a simpler instance where the worst-case approximation is approached. The bad instance, shown in Figure 2, is a graph Gwc which has an hub-and-spoke central structure with a single vertex acting as hub and a single vertex at the end of each of t spokes. In addition to the hub-and-spoke arrangement of the central vertices, we have 2p vertices which are 5 • • • •5 •6 •7 t + i t + i + 1 • • • • ••• • 4 • 3 • 2 • • 0 • 8 • 9 • • • • • • 1 • t • t + 4 • t + 3 • t + 2 • t + 1 • t + 2p • t + 2p − 1 Figure 2: Bad instance for the Greepy Peeling. The graph has 1 + t + 2p vertices and t + p edges. divided into p pairs, each pair of vertices being connected by a single edge. It is trivial to see that the central hub-and-spoke structure, with t edges and t + 1 vertices is the densest subgraph in Gwc t+1 , where S∗ denotes the set of vertices in the densest and the optimal density is given by f (S∗) = t subgraph. Consider now the Greedy Peeling algorithm, and assume that ties are broken by selecting the vertex with minimum index among those with smallest degree. Observe that each vertex in Gwc, except for the central one, has a degree of 1. Thus, the first selected vertex is 1, then vertex 2 follows, and so on. At iteration k the algorithm removes vertex k, and defines a subgraph with 1 + t + 2p − k vertices and t + p − k edges, i.e., the density of the graph keeps decreasing. Thus, the solution SG returned by the Greedy Peeling corresponds to the entire set of vertices and has a density f (SG) = t+p 1+t+2p . The ratio between the densities of the optimal solution and of the Greedy Peeling solution is is given by f (S∗) f (SG) = t t+1 t+p 1+t+2p = t(1 + t + 2p) (t + p)(t + 1) For sufficiently large values of p and t with p >> t, the above ratio converges to 2. Algorithm Hybrid(V, E) Peeling phase S1 := Greedy Peeling(V, E); Expansion phase S2 := {v ∈ V : (u, v) ∈ E for some v ∈ S1}; E2 := {e = (u, v) ∈ E : u ∈ S2, v ∈ S2}; Exact phase SH := Exact(S2, E2); return SH Figure 3: Hybrid Algorithm. 6 4. Hybrid algorithm In this section we present a Hybrid Algorithm that combines both Greedy Peeling and Exact Algo- rithm to improve the greedy solution value. The algorithm is given in Figure 3 and consists of three phases, namely Peeling phase, Expansion phase, and Exact phase. The first phase corresponds to the execution of the Greedy Peeling algorithm discussed in Section 3.2 and is intended to quickly produce an initial solution. Using the greedy solution, the Expansion phase obtains a "core" sub- graph, which is likely to contain either all or most of the vertices in an optimal solution. Finally, the Exact phase solves the DSE problem on the core using an exact algorithm, for instance, the flow-based Goldberg's Algorithm or the LP approach described in Section 3.1. The Expansion phase takes in input a subset of vertices S1, possibly identified by the Greedy Peeling, expands the vertex set by adding all those vertices that are neighbors of one vertex in S1, and defines the induced edge set E2. An implementation of this phase is described in Figure 4. Set S2 is a list of all vertices that are currently included in the expanded graph. Before the expansion phase, S2 = ∅. In the expansion phase we considers all vertices in S1, one at a time. For each u ∈ S1, we consider all its neighbors; if the current neighbor v is both is in S1 ∩ S2, we add the edge (u, v) to E2. If v /∈ S2, we add vertex v to S2 and edge (u, v) to E2, and scan all neighbors of v; for each neighbor k that is currently in set S2 we also add an edge (v, k) to E2. Procedure Expansion(S1, V, E) S2 := ∅, E2 := ∅; //consider each vertex u in the input solution for each u ∈ S1 do S2 := S2 ∪ {u}; add all neighbors of u for each v ∈ V : (u, v) ∈ E do if v ∈ S1 then if v ∈ S2 then E2 := E2 ∪ {(u, v)}; else S2 := S2 ∪ {v}, E2 := E2 ∪ {(u, v)}; add edges between vertices that both are in S 2 \ S 1 for each k ∈ S2 \ S1 : (v, k) ∈ E do E2 := E2 ∪ {(v, k)}; endif endfor endfor return (S2, E2) Figure 4: Expansion phase. Figure 5 gives an example of the expansion phase. The original graph has 12 vertices and S1 = {5, 6, 7, 8}. At first, S2 = ∅. We can start at vertex u = 5 which makes S2 = {5} and consider the first of its neighbors, i.e., vertex v = 2. From the algorithm, we can add vertex 2 to S2 and the edge (2, 5) to E2. Now, we scan the neighbors of 2 and we can add an edge to E2 if any of the neighboring vertices of 2 are present in S2. Since no new neighboring vertices of 2 (essential vertex 1) are present in S2, we do not add any new edges to E2. So we have S2 = {5, 2} and E2 = {(2, 5)}. Then, we examine the other neighboring vertices of 5 namely 6, 7 and 8. As all these vertices belong to S1 and none of them are in S2, no action is taken. Then, we move on the next member in S1, i.e. u = 6. We add 6 to S2 and examine the neighbors of 6. We have vertex v = 3 that can be 7 added to S2 and the edge (3, 6) can be added to E2. Now, S2 = {5, 2, 6, 3} and S2 \ S1 = {2, 3}, implying that edge (3, 2) has to be added to E2. Since no other edge can be added, we then move on to the next neighbor of 6, namely 5. When considering this vertex, edge (6, 5) can be added to E2 as 5 is in both S1 and S2. As all the neighbors of 6 have been considered, we move onto the next vertex in S1, i.e. 7. We continue doing the above process for all the members in S1 until we get the expanded subgraph, shown in Figure 5(b) 2 6 1 3 7 4 5 9 8 10 12 11 (a) expansion 8 10 2 6 1 3 7 4 5 9 12 11 (b) Figure 5: an example of Expansion In the third phase, an exact algorithm is applied to the graph obtained by expansion. Typically this graph is much smaller than the original one, allowing a fast execution of the exact algorithm. In addition, if the flow-based algorithm is used, the greedy solution value, combined with the 2- approximation guarantee of the method, produces good initial lower and upper bounds for the value of the density, which can be used to speed up the binary search. The biggest caveat is that there are instances for which the Greedy Peeling produces very large subgraphs. In this situation, the expansion procedure may require a very long computing time, and often returns the complete graph, making the approach impractical. 5. Computational experiments 5.1 Setup and Programming All the algorithms described in this paper were implemented in C++ using standard containers, like, e.g., std::vector, std::queue etc. We used the GCC compiler with a high level of optimiza- tion enabled (-O3). All our experiments were executed on a computer equipped with an Intel(R) Xeon(R) CPU E3-1220 V2 @ 3.10GHz CPU and 16 GB of RAM; all computing times given below are expressed in milliseconds. In the following we report the results obtained using the three algorithms, namely: • The Greedy Peeling discussed in Section 3.2. • The Hybrid Algorithm of Section 4. 8 • The flow-based exact algorithm (Goldberg's Algorithm) of Section 3.1. This algorithm embeds a push-relabel algorithm to compute the max-flow (min-cut) with O(V 3) time complexity. It should be noted that this algorithm requires to construct an augmented network which has twice the number of edges than the original graph network. As a result, the augmented network could occupy very large space in memory, and hence the algorithm may fail for memory requirement on very large instances. We analyzed both weighted and unweighted instances (see below). For weighted problems, the Greedy Peeling was implemented using binary heaps as this solution turned out to be much more efficient than using the degree-list implementation. As to the exact algorithm, it required very minor modifications for handling the weighted case as well. The Hybrid Algorithm uses the Greedy Peeling and the Goldberg's Algorithm as modular components to create and solve the expanded subgraph respectively, while the expansion procedure clearly is not affected by the presence of weights on the edges. 5.2 Testbed All the instances, both unweighted and weighted, were taken from Suite Sparse Collection [8]. To select the instances, we considered all graphs that: (i) are classified as undirected graph or undirected weighted graph or undirected graph with com- munities or undirected random graph; (ii) have at least 20,000 vertices; (iii) have at most 65,000,000 vertices and 150,000,000 edges; (iv) have only positive weights (for weighted instances). This produced a testbed with 170 instances. The benchmark includes 50 census-based weighted graphs (like xx2010 in Table 5) that have very similar characteristics. To avoid presenting very similar results, we decided to consider only the ten largest among these instances. In addition, we have also considered three large directed graphs (called Wikipedia instances), that were present in the computational analysis in [11]; for these instances, minor modifications were required, e.g., converting directed arcs to undirected edges and removing duplicated edges. Finally, we do not present the results on some graphs where the greedy algorithms fails. We explain the reason later in this section for this specific exclusion. Most of the available graphs are unweighted and hence we have partitioned them into different buckets, depending on their size. The Medium bucket contains those instances which have less than 1,000,000 vertices. The Large bucket contains instances having more than 1,000,000 vertices but less than 10 million vertices and less than 50,000,000 edges. Finally, the Xtra-Large bucket includes all the remaining instances. 5.3 Analysis In this section we report the outcome of our computational experiments. The results are given using a table for each set of instances. The bold numbers in the tables below indicate the best density found and which algorithm finds it for the first time. The tables report, for each instance, the following information: • The name of the problem and the main characteristics of the graph. 9 • For the Greedy Peeling algorithm: the required computing time TG and the associated density value fG. • For the Hybrid Algorithm: the computing time for the expansion phase and for the exact phase (T2 and T3, respectively), the overall computing time TH of the algorithm and the density value fH of the best solution found. • For the Exact algorithm: the required computing time TE and the density value f ∗. If an algorithm runs out of memory during its execution, we report the failure by ' -- '. T2 Hybrid T3 Exact TE 30114.8 259526.0 289694.5 7.4559 280444.9 73151.8 TH fH 5066.7 11.4 35843.3 737.0 89415.8 310410.2 400007.2 Greedy Peeling Graph Properties V Problem 2.7 2.9995 TG 53.7 37.6 coAuthorsCiteseer 227,320 coAuthorsDBLP 299,067 com-Amazon 334,863 ca-CondMat 23,133 caidaRouterLevel 192,244 598a 110,971 as-22july06 22,963 fG 7.4416 6.8043 3.2 19.9423 7.4495 181.3 12.5000 4.3 25.5167 50.2 96.3 12.0019 60.5 43.0000 57.0000 78.1 104.4 3.8327 56.5000 94.5 296.3 422.0000 358.4 168.0000 1.9493 62.8 37.0000 2.9991 E 144 144,649 1,074,393 741,934 48,436 auto 448,695 3,314,611 93,439 609,066 citationCiteseer 268,495 1,156,647 814,134 977,676 925,872 com-DBLP 317,080 1,049,866 coPapersCiteseer 434,102 16,036,720 coPapersDBLP 540,486 15,245,729 43,858 cs4 22,499 807,700 dblp-2010 326,186 delaunay n15 32,768 98,274 196,575 delaunay n16 65,536 delaunay n17 131,072 393,176 delaunay n18 262,144 786,396 delaunay n19 524,288 1,572,823 89,038 dictionary28 52,652 fe body 45,087 163,734 fe ocean 143,437 409,593 fe rotor 99,617 662,431 452,591 fe tooth 78,136 214,078 loc-Brightkite 58,228 950,327 loc-Gowalla 196,591 luxembourg osm 114,599 119,666 m14b 214,765 1,679,018 mycielskian15 24,575 5,555,555 mycielskian16 49,151 16,691,240 mycielskian17 98,303 50,122,871 1092.1 845.8977 rgg n 2 15 s0 32,768 160,240 7.5500 rgg n 2 16 s0 65,536 7.6471 342,127 rgg n 2 17 s0 131,072 8.0000 728,753 10.0769 rgg n 2 18 s0 262,144 1,547,283 rgg n 2 19 s0 524,288 3,269,766 8.9474 89,440 1.4905 165,435 1.5789 1.5714 161,950 121,544 1.9596 5.8 12.5000 3.9043 7.1 2.8734 22.7 27.5 6.6571 5.9171 20.1 40.5571 11.0 43.8000 62.1 1.1548 10.1 79.9 7.8266 t60k 60,005 usroads 129,164 usroads-48 126,146 wing 62,032 6.9 16.8 39.9 87.0 190.4 5.9 19.1 18.6 9.5 4.7 10.4 23.0 47.6 96.6 9008.9 f ∗ 7.4559 6.8792 40947.6 6.8792 1317.4 19.9423 751.5 19.9423 622512.7 7.5213 7.5211 2336.1 13.3667 13.3 13.3667 23785.8 25.7750 282.7 25.7750 59115.4 12.1808 6570.3 12.1808 25229.9 43.0000 123.7 43.0000 35584.6 57.0690 158.0 57.0690 53902.4 4.8041 10942.2 4.8041 38550.6 56.5652 178.0 56.5652 205527.8 422.0000 3842.4 422.0000 233183.4 168.0000 2752.8 168.0000 1.9526 8309.2 1.9526 26000.4 37.0000 82.4 37.0000 2.9991 14375.0 2.9991 2.9995 49406.5 2.9995 2.9997 145617.5 2.9997 2.9999 2.9999 427411.9 2.9999 1768799.0 2.9999 2634.8 12.5000 5421.1 4.0490 80359.5 2.8966 6.6920 58032.8 5.9801 6124.8 40.5591 32753.3 43.8018 4338.7 1.5238 7.8694 107600.5 333.5567 344396.4 530.8705 -- 1165647.2 845.8977 3336.3 7.8947 9.0000 7824.2 20552.0 8.9200 45015.0 10.4242 197.6 10.1667 125960.6 10.1667 83854.0 1.4914 11992.8 1.7528 14238.7 1.7528 53894.6 1.9627 -- 8.7 19.6 42.8 8.2083 93.0 10.4242 92632.6 1.4914 1.6250 1.6250 48225.5 1.9627 5.9778 515.5 40.5591 12139.6 43.8018 1.2667 11.0 12.5000 3.9213 2.8964 168.5 55561.3 7.6522 9.000 21.6 22.2 27885.8 15.2 0.5 9.1 205.8 4.5 5.5 2163.0 6.0 229.9 67.8 247.4 4.0 710.2 2835.5 8.6 223.3 6268.2 58.7 74.5 8674.8 77.5 3316.2 2324.6 8059.1 15.7 12997.1 50002.7 1.2 2.4 6533.3 4.1 159.0 49005.3 2319.0 12.0 174.7 2.5 25546.7 492.6 11902.8 2.6 -- 0.4 0.8 1.6 3.1 5.6 1036.3 1.7 2.6 1897.6 -- 1.4 2.1 1.4 2.9 1.5 91590.4 0.9 1.0 46318.4 13712.0 52848.5 2.9997 11103.4 147668.5 158794.9 2.9999 44140.1 394457.4 438645.1 2.9999 176182.4 1740164.0 1916442.9 12459.8 146689.0 159176.4 6.6920 159632.2 71078.1 185721.1 256879.2 7.8694 238330.9 101.4 333.5567 30001.7 97961.5 128064.6 333.5567 322.3 530.8705 175641.3 305244.9 481208.5 530.8705 Table 1: Results on Medium size instances. The results in Table 1 show that the exact algorithm can handle quite efficiently instances of 10 medium size: the required computing time is equal to 137 seconds on average and no failure was experienced due to memory reasons. The Greedy Peeling algorithm, though having a worst-case performance ratio equal to 2, gives a very tight approximation on the optimal density in practice. The average gap with respect to the optimal density is below 3% and the average CPU time is around 0.07 seconds. Nevertheless, the Hybrid Algorithm improves over the greedy solution in 27 cases (out of 41) and produces an average gap to the optimum of about 1%. However, there are a number of instances for which the Hybrid Algorithm performs poorly in terms of computing time. We can also see that for the instance mycielskian17, the Hybrid Algorithm runs out of memory. In Table 2 we report all the instances where the ratio of TH > 0.75 and where the Hybrid Algorithm TE runs out of memory. For each such instance, the table gives: • The name of the problem. • The number of vertices VG in the subgraph produced by Greedy Peeling and the ratio between VG and the total number of vertices V . • The number of vertices and edges (V2 and E2, respectively) in the expanded subgraph and the ratio between V2 and the total number of vertices V . Graph Properties Problem 144 cs4 delaunay n15 delaunay n16 delaunay n17 delaunay n18 delaunay n19 fe ocean fe rotor m14b mycielskian15 mycielskian16 mycielskian17 t60k wing Greedy Peeling Hybrid VG 144,649 22,499 32,768 65,536 131,072 262,144 524,288 143,437 99,617 214,765 M6 3,501,776 24,575 49,151 98,303 60,005 62,032 V2 138,830 22,499 32,768 65,536 131,072 262,144 524,288 109,860 98,971 210,693 E2 VG/V 1,032,694 0.9509 43,858 1.0000 98,274 1.0000 196,575 1.0000 393,176 1.0000 786,396 1.0000 1,572,823 1.0000 315,384 0.7212 658,472 0.9859 0.9634 1,647,651 0.9739 3,412,415 10,233,983 24,575 0.3694 5,555,555 0.3344 49,151 16,691,240 98,303 50,122,871 0.2899 89,313 59,935 0.9977 0.9971 61,994 121,461 V2/V 0.9598 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 0.7659 0.9935 0.9810 0.9745 1.0000 1.0000 1.0000 0.9988 0.9994 Table 2: Instances for which the Hybrid Algorithm can take a very long time. Table 2 shows that the pitfalls of Hybrid Algorithm occur in those instances where the solution produced by Greedy Peeling has almost the same number of vertices as the whole graph. And sometimes, even when Greedy Peeling produces a smaller and more compact solution, the expan- sion phase produces either the original graph or almost the original graph. In these cases, the expansion phase may be time consuming, and the application of the exact algorithm requires the same computing time as solving the initial problem to optimality. Thus, the Hybrid Algorithm may overall be even slower than the direct application of the exact algorithm on the initial graph. The average computing time taken by the Hybrid Algorithm for the Medium instances is around 115 seconds; if we exclude the pathological cases listed in Table 2, the hybrid time falls to around 21 seconds. In Table 3 we present the results of our experiments on Large instances. Based on the out- come of the results in Table 2, we do not run the Hybrid algorithm for those instances where the 11 TG Graph Properties Problem V E as-Skitter 1,696,415 11,095,298 asia osm 11,950,757 12,711,603 1342.2 185.2 belgium osm 1,441,295 1,549,970 Greedy Peeling fG 822.6 89.1810 1.7778 1.6000 com-LiveJournal 3,997,962 34,681,189 3129.7 190.9845 com-Youtube 1,134,890 2,987,624 341.3 45.5778 1.6250 germany osm 11,548,845 12,369,181 1734.4 great-britain osm 7,733,822 8,156,517 1039.0 1.8710 italy osm 6,686,493 7,013,978 1.6250 743.4 netherlands osm 2,216,688 2,441,238 1.6667 298.8 640.9 8.5361 packing-500x100x100-b050 2,145,852 17,488,243 rgg n 2 20 s0 1,048,576 6,891,620 415.2 11.1212 rgg n 2 21 s0 2,097,152 14,487,995 930.6 9.3934 rgg n 2 22 s0 4,194,304 30,359,198 1937.8 10.5503 2021.1 3485.8 1.6002 597.3 1.6743 205.8 1.6441 1.7656 241.3 2.0014 1001420.7 111528.39 1113531.6 road central 14,081,816 16,933,413 3285.6 roadNet-CA 1,971,281 2,766,607 315.0 roadNet-PA 1,090,920 1,541,898 177.7 roadNet-TX 1,393,383 1,921,660 216.8 672.9 venturiLevel3 4,026,819 8,054,237 Hybrid T3 37273.4 0.4 0.1 695.2 60642.4 0.6 1.3 0.4 0.3 1868.9 1134.0 824.0 328.5 8.7361 147977.6 612576.4 761195.0 433.7 11.6250 960.8 11.9048 12.550 1.6667 1.7143 T2 2303.8 135.4 15.4 82.8 1608.5 133.9 93.7 80.2 29.4 TH 1478.1 200.6 fH 40399.8 89.4009 1.7778 1.6000 3907.7 193.5136 62592.3 45.5988 1.6667 1.9583 14.1 22.3 58.4 179.3 48.7 14.0 17.1 4.4 7.9 25.0 20.9 233.5 14.2 7.3 1.7750 1.9677 1.8571 2.0769 Exact TE f ∗ 388513.9 89.4009 703145.0 1.8513 77872.7 1.6750 1226155.5 193.5136 157970.6 45.5988 784833.6 1.7500 465254.6 1.9583 365157.8 1.7778 1.7143 190545.5 2931714.4 8.8078 276226.5 11.6346 667290.4 11.9048 1806177.7 12.5500 6231763.4 1.9029 313535.2 1.9677 234657.2 1.8783 2.0769 2.0613 872899.2 127.0162 1919124.9 140.5966 2063044.9 141.6711 82250.8 2.0613 351929.5074 wikipedia-20051105 1,634,989 18,540,603 1561.8 126.5925 wikipedia-20060925 2,983,494 35,048,116 3643.1 138.7406 wikipedia-20061104 3,148,440 37,043,458 3862.4 140.5598 14248.1 418588.5 434379.8 127.0162 43194.7 967617.4 1014476.4 140.5966 47102.8 1031432.3 1082416.4 141.6711 Table 3: Results on Large instances. greedy solution (or the expanded subgraph) is almost as large as the complete original graph. In particular, we removed the graphs for which V2 V > 0.85, namely the instances in the series de- launay series, hugebubbles, hugetrace, and hugetric, as well as instances 333SP, adaptive, AS365, channel-500x100x100-b050, NACA0015, and NLR. Note that V2 can be computed in negligible time before performing the expansion, simply scanning all the edges that are incident to vertices in the greedy solution. Results in Table 3 show that, like medium instances, Hybrid Algorithm consistently improves upon the density value produced by Greedy Peeling, and often times finds the optimal solution. The Hybrid Algorithm was able to find the optimal solution in 13 cases out of 21 instances, and in 12 cases it was faster than the Goldberg's Algorithm. As for the remaining 8 instances that are not solved to optimality, the associated average gap is around 4%. The average gap over all the 21 instances is around 1%, much smaller than that of the Greedy Peeling, which is around 7%. As for the computing time, Greedy Peeling just takes around 1.4 seconds on average, while the Hybrid Algorithm takes 215 seconds on average. The Goldberg's Algorithm takes almost 1100 seconds on average for solving these problems to optimality. In Table 4, we present the results of the three algorithms for the eight Xtra-Large instances in our benchmark. These graph instances were derived from real-life applications like gene networks (kmer series), road networks, social networks etc. It can be immediately seen that the exact algorithm fails for all the instances due to memory limitation. For these instances, Greedy Peeling finds a dense subgraph within 10 seconds on average, despite running on some graphs having tens of millions of vertices and hundreds of millions of edges. The Hybrid Algorithm consistently improves upon the greedy solution for almost all these istances as well, the only exception being problem soc- orkut, for which the algorithm runs out of memory. Ignoring this instance, the average computing time taken by the Hybrid Algorithm is around 40 seconds, and the average improvement produced by this algorithm over the Greedy Peeling is by 9%. Finally, Table 5 presents the results of the three algorithms on the weighted instances. 12 Graph Properties Greedy Peeling Problem E europe osm 50,912,018 54,054,660 hollywood-2009 1,139,905 56,375,711 V fG 1.7047 TG 6869.1 1895.3 1104.0000 14712.7 199468.9 216076.9 1104.0000 4.0455 TH 7535.4 T2 640.2 2.0000 Hybrid T3 26.1 Exact fH TE f ∗ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- kmer U1a 67,716,231 69,389,281 26907.0 kmer V2a 55,042,369 58,608,800 20570.0 4072.6 8571.6 4545.7 9111.0 rgg n 2 23 s0 8,388,608 63,501,393 rgg n 2 24 s0 16,777,216 132,557,200 road usa 23,947,347 28,854,312 soc-orkut 4,847,571 106,349,209 4.0000 6.9000 11.0476 12.1220 1.5974 206.9307 862.0 691.0 112.6 237.8 301.5 509.7 7.0909 2.0 27771.0 10.8 21271.8 25.6 15.5 2.7 -- 4210.8 13.4000 8824.9 13.7143 4849.9 1.8462 -- Table 4: Results on Xtra-Large instances. The Greedy Peeling performs very well, and determines an optimal solution in 9 out of 16 cases; for instance mawi 201512020000 it produces the same density value as the Hybrid, but optimality of the solution cannot be confirmed as the exact method failed. The Hybrid improves over the greedy solution in 5 of the 6 remaining instances, in all these cases finding an optimal solution. On average, the Greedy Peeling takes 2 seconds, while the Hybrid Algorithm takes 3 seconds. On the other hand, the exact algorithm requires almost 98 seconds to find the optimal solution. By removing the two mawi instances, we see that the average error of the Greedy Peeling is around 1.7%, reduced to less than 0.02% by the Hybrid Algorithm. Graph Properties Greedy Peeling TG V 31,163 40,421 fG 836.1 6234021.00 17.60 Problem ca2010 cond-mat-2003 cond-mat-2005 fl2010 ga2010 human gene1 il2010 mi2010 mo2010 E 710,145 1,744,683 120,029 175,693 484,481 1,173,147 291,086 709,028 22,283 12,323,680 13.2 451,554 1,082,232 789,045 329,885 10.0 343,565 828,284 10.6 mawi 201512012345 18,571,154 19,020,160 557.3 mawi 201512020000 35,991,342 37,242,710 16670.7 1770103.00 1073.8856 26.3 21.6 482.8 3753682.46 285.2 3929610.00 277.7 62.67 519.4 5508363.60 275.4 6993878.84 342.9 1666117.50 798116.43 T2 21.1 0.8 1.1 14.7 8.6 8500.7 23.00 mouse gene ny2010 oh2010 pa2010 tx2010 45,101 14,461,095 854,772 350,169 365,344 884,120 421,545 1,029,231 914,231 2,228,136 27.75 423.5 316.5 2986674.11 340.1 3826971.80 429.7 3202713.00 6563105.33 1181.9 Exact Hybrid T3 0.5 0.2 0.0 19.9 3.9 TE 3929610.00 17.60 23.00 TH fH 889.9 17.3 24.5 f ∗ 6234021.00 102852.4 6234021.00 2993.6 17.60 4823.1 23.00 544.5 3992056.53 59491.5 3992056.53 32925.6 278.9 3929610.00 62.67 275029.7 26151.3 142179.7 168647.0 62.67 488.6 56272.4 5508363.60 39722.7 7390000.23 316.4 1666117.50 41242.4 342.3 -- -- -- -- 28.47 28.47 504904.1 3289936.62 349.7 3289936.62 42967.6 3826971.80 43120.3 370.5 3202713.00 429.4 52429.2 1225.0 6630141.80 119992.3 6630141.80 0.6 2.8 0.5 119.7 183.5 19113.4 34124.6 217645.7 252196.7 5508363.60 7370921.58 1666117.50 9817.0 927951.00 1770103.00 3826971.80 3202713.00 10.9 10.9 12.1 26.7 2.4 3.6 0.4 2.2 Table 5: Results on Weighted instances. 6. Conclusions In this paper, we have studied a non-linear graph optimization problem that requires to determine the densest subgraph in a given graph. We introduced a new heuristic algorithm that combines a fast and effective greedy algorithm and an exact method from the literature. We have provided a simple instance for which the greedy algorithm shows its worst case performance. We have presented an efficient implementation of the algorithms to solve both unweighted and weighted problems, with the aim of attacking instances of very large size, like those arising, e.g., in social network applications. To the best of our knowledge, this is the most comprehensive computational 13 study on Densest Subgraph Extraction problem involving instances with tens of millions of vertices and hundreds of millions of edges. Acknowledgments This research was supported by "Mixed-Integer Non Linear Optimisation: Algorithms and Appli- cation" consortium, which has received funding from the European Unions EU Framework Pro- gramme for Research and Innovation Horizon 2020 under the Marie Sk lodowska-Curie Actions Grant Agreement No 764759. References [1] J. Abello, M.G.C. Resende, and S. Sudarsky. Massive quasi-clique detection. In Sergio Rajs- baum, editor, LATIN 2002: Theoretical Informatics, pages 598 -- 612, Berlin, Heidelberg, 2002. Springer. [2] R. Andersen and K. Chellapilla. Finding dense subgraphs with size bounds. In K. Avrachenkov, D. Donato, and N. Litvak, editors, Algorithms and Models for the Web-Graph, pages 27 -- 37, Berlin, Heidelberg, 2009. Springer. [3] Y. Asahiro, K. Iwama, H. Tamaki, and T. Tokuyama. Greedily finding a dense subgraph. Journal of Algorithms, 34(2):203 -- 221, 2000. [4] B. Bahmani, R. Kumar, and S. Vassilvitskii. Densest subgraph in streaming and mapreduce. Proc. VLDB Endow., 5(5):454 -- 465, January 2012. [5] B. Balasundaram, S. Butenko, and I.V. Hicks. Clique relaxations in social network analysis: The maximum k-plex problem. Operations Research, 59(1):133 -- 142, 2011. [6] M. Charikar. Greedy approximation algorithms for finding dense components in a graph. In K. Jansen and S. Khuller, editors, Approximation Algorithms for Combinatorial Optimization, pages 84 -- 95, Berlin, Heidelberg, 2000. Springer. [7] J. Chen and Y. Saad. Dense subgraph extraction with application to community detection. IEEE Transactions on Knowledge and Data Engineering, 24(7):1216 -- 1230, 2012. [8] T. A. Davis and Y. Hu. The university of florida sparse matrix collection. ACM Trans. Math. Softw., 38(1):1:1 -- 1:25, December 2011. [9] S. Fortunato. Community detection in graphs. Physics Reports, 486(3 -- 5):75 -- 174, 2010. [10] G. Gallo, M. Grigoriadis, and R. Tarjan. A fast parametric maximum flow algorithm and applications. SIAM Journal on Computing, 18(1):30 -- 55, 1989. [11] A. Gionis and C. discovery http://people.seas.harvard.edu/~babis/dsd.pdf, 2015. Accessed: 2019-10-16. Tsourakakis. subgraph Dense (dsd). [12] A. V. Goldberg. Finding a maximum density subgraph. Technical report, University of Cali- fornia at Berkeley, Berkeley, CA, USA, 1984. [13] A.V. Goldberg and R.E. Tarjan. A new approach to the maximum-flow problem. Journal of the ACM, 35(4):921 -- 940, 1988. 14 [14] M. Henzinger, A. Noe, C. Schulz, and D. Strash. Practical minimum cut algorithms. Journal of Experimental Algorithmics, 23:1.8:1 -- 1.8:22, 2018. [15] Y. Hiroki and H. Satoshi. Discounted average degree density metric and new algorithms for the densest subgraph problem. Networks, 71(1):3 -- 15, 2018. [16] S. Khuller and B. Saha. On finding dense subgraphs. In S. Albers, A. Marchetti-Spaccamela, Y. Matias, S. Nikoletseas, and W. Thomas, editors, International Colloquium on Automata, Languages, and Programming, pages 597 -- 608, Berlin, Heidelberg, 2009. Springer. [17] V. E. Lee, N. Ruan, R. Jin, and C. Aggarwal. A Survey of Algorithms for Dense Subgraph Discovery, pages 303 -- 336. Springer, Boston, MA, 2010. [18] J.-C. Picard and M. Queyranne. A network flow solution to some nonlinear 0-1 programming problems, with applications to graph theory. Networks, 12(2):141 -- 159, 1982. [19] C. Tsourakakis. A novel approach to finding nearcliques: The triangle-densest subgraph prob- lem. Technical report, ICERM, Brown University, 2014. [20] C. Tsourakakis, F. Bonchi, A. Gionis, F. Gullo, and M. Tsiarli. Denser than the densest subgraph: Extracting optimal quasi-cliques with quality guarantees. In R. Ghani, T.E. Senator, P. Bradley, R. Parekh, and J. He, editors, Proceedings of the 19th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 104 -- 112. ACM, 2013. 15
1503.08019
2
1503
2016-03-24T04:37:16
Optimality of Fast Matching Algorithms for Random Networks with Applications to Structural Controllability
[ "cs.DS", "eess.SY" ]
Network control refers to a very large and diverse set of problems including controllability of linear time-invariant dynamical systems, where the objective is to select an appropriate input to steer the network to a desired state. There are many notions of controllability, one of them being structural controllability, which is intimately connected to finding maximum matchings on the underlying network topology. In this work, we study fast, scalable algorithms for finding maximum matchings for a large class of random networks. First, we illustrate that degree distribution random networks are realistic models for real networks in terms of structural controllability. Subsequently, we analyze a popular, fast and practical heuristic due to Karp and Sipser as well as a simplification of it. For both heuristics, we establish asymptotic optimality and provide results concerning the asymptotic size of maximum matchings for an extensive class of random networks.
cs.DS
cs
Optimality of Fast Matching Algorithms for 1 Random Networks with Applications to Structural Controllability Mohamad Kazem Shirani Faradonbeh, Ambuj Tewari, and George Michailidis Abstract Network control refers to a very large and diverse set of problems including controllability of linear time-invariant dynamical systems, where the objective is to select an appropriate input to steer the network to a desired state. There are many notions of controllability, one of them being structural controllability, which is intimately connected to finding maximum matchings on the underlying network topology. In this work, we study fast, scalable algorithms for finding maximum matchings for a large class of random networks. First, we illustrate that degree distribution random networks are realistic models for real networks in terms of structural controllability. Subsequently, we analyze a popular, fast and practical heuristic due to Karp and Sipser as well as a simplification of it. For both heuristics, we establish asymptotic optimality and provide results concerning the asymptotic size of maximum matchings for an extensive class of random networks. Maximum Matching, Karp-Sipser, Structural Controllability, Network Control, Random Networks. Index Terms N ETWORKS are capable of capturing relationships between a set of entities (vertices) and have found applications in diverse scientific fields including biology, engineering, economics and the social sciences [1], [2], [3]. Network control I. INTRODUCTION refers to a very large and diverse set of problems that involve control actions over a network (see for example, [4], [5], [6], [7], [8], [9], [10], [11], [12], [13] and references therein). A class of control problems involves dynamical systems evolving over time that have inputs and outputs and many results exist for systems that exhibit linear and time-invariant dynamics [11]. One particular notion of control is that of structural controllability [1], [14], which was recently explored by Liu et al. [12]. Under this notion, the structural controllability problem reduces to find maximum matchings on appropriate matrices as reviewed in Section I-A. The problem of obtaining maximum matchings has been extensively studied in the computer science literature both for deterministic [15] as well as random networks [16]. However, the focus in the literature has been on special classes of undirected random networks [17], [18]. For example, using the results of Tao and Vu [19], one can infer that for dense Erdos-Renyi random networks, a single controller is sufficient to ensure controllability. Little is known about the performance of matching algorithms in other interesting classes of random networks [20], with an exception of the recent work of Balister and Gerke [21]. We focus on degree distribution random 2 network models, and establish results on the minimum number of controllers needed to guarantee structural controllability. We also show that these models are realistic representations for real world applications. A popular, fast and practical algorithm for matchings on undirected random networks is due to Karp and Sipser [22], which represents the cornerstone of our theoretical investigations and through it we provide generalizations of previous work in the literature to broader classes of undirected random networks. Further, we also extend the results for directed variants of the same classes of random networks. A. Structural Controllability and Maximum Matchings Next, we review some key concepts in structural controllability for linear dynamical systems. Consider a system described by a n-dimensional state vector x(t) = (x1(t), ..., xn(t))T ∈ Rn, whose dynamical evolution is described by dx dt = Ax(t) + Bu(t), where A ∈ Rn×n is the system transition matrix, u(t) = (u1(t), ..., uk(t))T ∈ Rk captures control actions and B ∈ Rn×k is the input matrix. Assuming that the n-dimensional system can be represented by vertices on a network G = (V, E) with V = {1, 2, ..., n} denoting the set of vertices and E ⊂ V × V the set of edges, it can be seen that the non-zero entries in the transition matrix A correspond to the directed edges in E. Indeed, for i, j ∈ V the edge i → j exists if and only if vertex i influences vertex j, i.e. Aji (cid:54)= 0. Such a system is called controllable if for any initial state x(0) = x0 and any desired state xd for some T < ∞ one can find an input matrix B and control vectors {u(t)}0≤t≤T so that the system reaches state xd i.e. x(T ) = xd. The minimum k for which system can be controllable is called the minimum number of controllers. The magnitude of the entries in the transition matrix A captures the interaction strength between the vertices in the network; for example, the traffic on individual communication links in a communications network or the strength of a regulatory interaction in a biological network. The time invariant matrix B indicates which vertices are controlled by an outside controller. Hence, the set of vertices that when applying controllers to them makes the system controllable needs to be identified. Note that we don't assume any constraint on the number of nonzero elements in the columns of input matrix B, i.e. one controller ui(t) can influence multiple vertices. The case where every controller can be applied to only one vertex in the network (which in turn implies that the goal is to find the minimum number of vertices the controllers can be applied to) is studied by Olshevsky [23]. He shows that finding the exact solution to the problem is NP hard. The algebraic criterion to check controllability of a time invariant linear dynamical system is Kalman's controllability rank condition, that states that controllability can be achieved, if and only if the matrix C = [B, AB, ..., An−1B] is full rank; i.e. rank(C) = n. Note that C ∈ Rn×nk. This algebraic criterion is computationally hard to check, especially for large systems. Further, in many applications, obtaining exact values of A may not be feasible and hence a tractable alternative is needed. Thus, we say that a time invariant linear dynamical system is structurally controllable, if it is possible to select the non-zero values of A, B, so that Kalman's rank condition is satisfied [1]. A structurally controllable system is controllable for almost all A, B; i.e. the pathological cases for which a structurally controllable network is not controllable has zero Lebesgue measure. The relation between the minimum number of controllers needed to structurally control a network and the size of its maximum 3 matching has been presented in several forms (see [24]). The version used in the current work is the one appearing in Liu et al. [12] "minimum inputs theorem" (stated below). Moreover, similar equivalence between structural controllability and maximum matching when every controller can be applied to only one vertex, is studied by Assadi et al. [25]. Furthermore, Commault and Dion [26] study the problem of using only a single controller applied to as few vertices as possible. More general results regarding the control configuration selection can be found in the work of Pequito et al. [27] which discusses relations to maximum matching problem as well. Other considerations must be taken into account for deciding which approach is most suitable for the practical application under consideration. Finally, we have no assumption regarding self-loops in the network. Cowan et al. [28] study networks, where every vertex influences itself. Algorithms to find a maximum matching are well studied in the literature and exhibit polynomial time complexity (with respect to the size of the network). A popular one developed by Micali and Vazirani [29] has running time O(cid:0)V 0.5E(cid:1). Next, for completeness we provide a definition of maximum matching and also state the minimum inputs theorem. Definition 1. For a directed network G = (V, E), a subset of edges M is a matching, if no two edges in M share a common starting or a common ending vertex. A maximum matching corresponds to a matching of maximum size. Definition 2. Given a matching M for directed network G = (V, E), a vertex is matched, if it is an ending vertex of an edge in the matching M. Otherwise, it is unmatched. Minimum Inputs Theorem [12]: Let M∗ be a maximum matching of the network G = (V, E). The minimum number of controllers needed for structural controllability of the network is max{1, n − M∗}. Moreover, for any matching M, the network is struturally controllable using max{1, n − M} controllers. The upshot of this result is that in order to find the minimum number of required controllers for structural controllability we can equivalently find the size of a maximum matching. Furthermore, one can explicitly find the structure of the input matrix B according to the proof of minimum inputs theorem. In fact, one can see that a matching is formed of a set of directed loops and a set of directed paths. The first vertex of each path is unmatched, while all other vertices are matched. According to Lin's work [1], one controller is used to actuate every unmatched vertex. Amongst matched vertices, some might need to be actuated by a controller, but no new controller is needed, as it suffices to apply any of the previously used controllers to one arbitrary vertex of each loop. So the number of nonzero components in B ∈ Rn×k, or equivalently the total number of the connections between the inputs and vertices in the network, is at most n. More details are provided by Liu et al. (Supplementary Information of [12]). As the problem of finding the minimum number of controllers needed for structural controllability of a network reduces to maximum matching type of problems, henceforth we use the (minimum) number of unmatched vertices and the (minimum) number of controllers interchangeably. In this work, we provide results about the size of matchings obtained by different fast algorithms for classes of random networks. In fact, Karp and Sipser [22] proved that, for the classical undirected Erdos-Renyi random network, the KS algorithm is optimal. We generalize their results to a larger class of random networks. The remainder of the paper is organized as follows. In Section II we introduce different classes of random networks subsequently studied in this work. Furthermore, some probabilistic results needed for technical developments are summarized. The main algorithms 4 studied are introduced in Section III and connections to real networks using some numerical examples are provided in Section IV. The key results of the paper are presented in Sections V (analysis and optimality of the algorithms). Notations: For set S, let S be the number of elements in S.(cid:0) (cid:1) = n! n1!...nr!. For vertices u, v ∈ V in the network G = (V, E), {u, v} ((u, v) or (v, u) in directed or bipartite networks) denotes an edge, so N = M ∪ {{u, v}} means adding the edge {u, v} to M gives N. G−{u, v} means removing vertices u, v (and so all edges connected to them) from network G. Further, degG(v) denotes the degree of v in G i.e. the number of edges in G connected to v. When there is no subscript, the xi. network G is identifiable from the context. Finally, for x ∈ Rn, n ∈ {0, 1, 2, ...}∪{∞}, (cid:107)x(cid:107)1 is (cid:96)1 norm of x: (cid:107)x(cid:107)1 = n(cid:80) n1,...,nr n II. RANDOM NETWORKS i=1 In this section, we introduce different classes of random network models and then present some general results about convergence and concentration of real-valued functions on networks. In order to have a general framework which includes both directed and undirected networks, we note that every undirected network G = (V, E) can be considered as a directed network in which, for all vertices i, j, both edges i → j and j → i exist, if and only if the edge i ↔ j exists in the original undirected network. All statements presented are true for both directed and undirected networks unless explicitly mentioned. For a comprehensive discussion on constructions and properties of (undirected) random networks, see chapter 3 in Durrett [30]. The first model for random networks we consider is the Erdos-Renyi (ER) model. A directed network G = (V, E), V = {1, 2, ..., n} is (drawn from) ER if every edge i → j for i, j = 1, 2, ..., n is present in the network independently with probability p(n). Analogously, an undirected network G = (V, E), V = {1, 2, ..., n} is ER if every edge i ↔ j for i, j = 1, 2, ..., n, i ≤ j is present in the network independently with probability p(n). Henceforth, for λ ∈ [0,∞], ER(λ) is a Erdos-Renyi random network, for which np(n) → λ as n → ∞. In ER(λ) random networks, the parameter λ corresponds to the average degree. The next model we consider is the Uniform Fixed-Size (U F S) model. A directed network G = (V, E), V = {1, 2, ..., n} is U F S when the cardinality of the edge set E = kn for some fixed kn, and the kn directed edges are drawn uniformly among all n2 possible edges. The construction for the undirected network is similar, but the kn edges are chosen uniformly among n → λ for possible edges. For λ ∈ [0,∞], we denote by U F S(λ) a random network of the UFS class, for which kn all n(n+1) 2 directed and kn n → λ 2 for the undirected case, as n → ∞. Once again, the λ parameter corresponds to the average degree. Finally, we introduce the class of Degree Distribution (DD) random networks. There are a couple of reasons for considering this class. First, it lets us consider networks with degree distributions commonly found in real networks that simpler models such as ER (where the degree distribution is Poisson) cannot model. For example, as shown in Fig. 1, the degree distribution of real world networks can be any arbitrary non-parametric distribution. Histograms demonstrating input and output degree distributions of some other real world networks can be found in Fig. 2. Second, as empirically shown in Section IV, the number of controllers for structural controllability of a network is, to a large extent, determined by its degree distribution. More details can be found in Section IV as well as the work of Liu et al. [12]. 5 Figure 1: Degree distribution histogram of the social network between prison inmates. For more information see Table I. (blue: input degree, red: output degree). As shown here, it is difficult to model degree distributions of real networks using standard parameteric distributions. Figure 2: Degree distribution histogram of some networks. For more information see Table I. (blue: input degree, red: output degree). An undirected random network is a member of the DD class, if for a given degree distribution the attachment of edges is random. Specifically, let p be a probability distribution with support on the set {0, 1, 2, . . .} of nonnegative integers. We then construct an undirected network DD(p) = (V, E) as follows. Let V = {1, 2, ..., n} and for i ∈ V , let vertex i have Di 6 n(cid:80) n(cid:80) i=1 undirected half-edge(s) (one-half of an edge is connected to vertex i). Note that D1, . . . , Dn are the corresponding degrees which are assumed to be independent and identically distributed (iid) with distribution p; P(Di = k) = p(k). To complete the construction, we then pair all half-edges randomly; i.e. all(cid:0) n(cid:80) (cid:1) possible attachments of half-edges have equal probability. Di i=1 2,...,2 When the number of half-edges Di is an even number, the construction is straightforward and the number of edges will i=1 be 1 2 Di. When it is an odd number, we pair the half-edges randomly to obtain the network and omit the last single half-edge Di − 1). Note that the omission or presence of multiple edges will lead to a difference between D1, . . . , Dn and the actual observed degrees for which no pairing was established at the end of the construction, so that the number of edges will be 1 2 ( i=1 n(cid:80) deg(1), . . . , deg(n) once the network construction is completed. However, as Lemma 1 below establishes, the asymptotic empirical degree distribution will be the original degree distribution from which the network was constructed, as long as the expected value of Di, EDi is finite. Viewing an undirected network DD(p) as a directed one, both input and output degrees of vertex i are deg(i). To construct a directed DD random network, denoted by DD(pin, pout), with distinct input (degin) and output (degout) degrees, we do the following: once we have iid draws D(in) from the input and output degree probability distributions pin and pout and D(out) i i respectively: P(D(in) i = k) = pin(k), P(D(out) i = k) = pout(k), directed half-edges pointing into vertex i and D(out) let vertex i ∈ V have D(in) i. Next, we pair directed half-edges randomly to have min{ n(cid:80) max(cid:8) n(cid:80) The random pairing of half-edges implies that all (cid:18) i likely. Note that D(in) i , D(out) i i=0 do not need to be independent. n(cid:80) D(in) i i=0 D(in) i , i D(out) i (cid:9)(cid:19) i=0 D(out) i , n(cid:80) i=0 directed half-edges pointing out from vertex } edges and omit the remaining half-edges. ! possible pairings of half-edges are equally Furthermore, in general, the degrees do not need to be iid. In fact, as shown later in the paper, the key asymptotic results we establish are based on the empirical degree distributions which are, by the following lemma, same as the original degree distributions when vertex degrees are iid. However, as long as for all k = 0, 1, . . ., {i∈V :Di=k} n lim n→∞ (equivalently ) are deterministic, our results hold using the resulting asymptotic empirical degree {i∈V :D(in) i =k} lim n→∞ n distributions. {i∈V :D(out) i n =k} , lim n→∞ Lemma 1. For an undirected network G = (V, E), define the asymptotic empirical degree distribution as {i ∈ V : deg(i) = k} n . p(k) = lim n→∞ ∞(cid:80) If G = DD(p) is a random network and µ = kp(k) < ∞, then the limit above exists and we have p(k) = p(k) for all k = 1, 2, . . .. In general for a network G = (V, E), define the asymptotic empirical input and output degree distributions as k=0 pin(k) = lim n→∞ pout(k) = lim n→∞ {i ∈ V : degin(i) = k} n {i ∈ V : degout(i) = k} n . If G = DD(pin, pout) is a random network and µ = ∞(cid:80) kpin(k) = above exist and we have pin(k) = pin(k), pout(k) = pout(k). k=0 kpout(k) < ∞, then for all k = 1, 2, . . . the limits 7 ∞(cid:80) k=0 Henceforth, for all networks by pin, pout we mean asymptotic empirical degree distributions pin, pout respectively. Next, we define the Lipschitz property for real valued functions defined over networks. Definition 3. Let f be a real-valued function on the set of directed networks. We say f has the Lipschitz property, if f (G1) − f (G2) ≤ 1 whenever G1 = (V, E1), G2 = (V, E2), E2 = E1 ∪ {e}; i.e. the value of f will change at most by 1 if one new edge is added to the network. Remark 1. Properly defining the norm (cid:107) · (cid:107) on the networks, one can see the Lipschitz property is the same as the classic notion f (G1) − f (G2) ≤ (cid:107)G1 − G2(cid:107). Indeed, for every network G = (V, E), letting A(G) be the adjacency matrix of G (A(G) ∈ RV ×V , for i, j ∈ V if i → j, A(G)ji = 1 and A(G)ji = 0 otherwise), define (cid:107)G(cid:107) = (cid:107)A(G)(cid:107)1 = A(G)ij. Then G1, G2 differ by only one edge if and only if (cid:107)A(G1)−A(G2)(cid:107)1 = 1. So f has the Lipschitz property if f (G1)−f (G2) = f (A(G1)) − f (A(G2)) ≤ (cid:107)A(G1) − A(G2)(cid:107)1. V (cid:80) i,j=1 Next, we present convergence and concentration inequalities for functions of random networks which have the Lipschitz property. Specifically, the number of unmatched vertices (or equivalently the number of controllers) obtained by a matching algorithm, has the Lipschitz property as shown in Section V. The consequence of the Lipschitz property for a function defined on a "not too dense" random network, is that it concentrates around its expected value. Further, if the average degree of the network is finite, then the concentration occurs exponentially fast. These results are summarized in the following theorem. Theorem 1 (Convergence of real-valued functions for random networks). Let G = (V, E) belong to the ER, U F S, DD(pin, pout) or DD(p) class. For a real-valued function f which has the Lipschitz property, if then f (G)−E(f (G)) n →P 0 as n → ∞. If in addition, E (E) n2 = 0, lim sup n→∞ then f (G)−E(f (G)) such that for every 0 <  < 1 : n E(E) n < ∞ the rate of convergence is exponential; i.e. there is C > 0 lim sup n→∞ → 0 a.s. as n → ∞. When sup n≥1 E (E) log n n2 = 0, P( f (G) − E(f (G)) n > ) ≤ 2 exp(−nC2). III. MATCHING ALGORITHMS Before studying the algorithms, we provide a description of networks which will be useful later. As mentioned before, every undirected network can be considered as a directed one. Now to have a better understanding of how the algorithms work we view every directed network as a bipartite network G = (L, R, E) where L = R = V , E ⊂ L × R, L and R are respectively the left and the right side of the bipartite network, and for l ∈ L, r ∈ R there is an edge (l, r) ∈ E if and only if in the original directed network there is an edge from l to r: l → r. Henceforth we will only deal with bipartite networks. 8 Matching algorithms take a network as input and produce a matching as output. Maximum matching algorithms will give a matching of maximum size. Algorithm 1 is the well known Greedy Algorithm that produces a suboptimal matching MG in general. For an arbitrarily chosen vertex v on the right side, Greedy tries to find an arbitrary vertex u on the left side which is connected to v and has not been used before by any other vertex on the right side. Note that as mentioned above, networks can be assumed to be bipartite. Moreover, clearly the time complexity of Greedy is O(n). Algorithm 1 : Greedy Input: G = (L, R, E) Output: matching MG(G) MG ← ∅ while E (cid:54)= ∅ do let v ∈ R if deg(v) = 0 then G ← G − {v} else if for u ∈ L, (u, v) ∈ E then G ← G − {u, v} MG ← MG ∪ {(u, v)} end if end while return MG Note that Greedy picks an arbitrary vertex v ∈ R in every iteration. Because the goal is to find a matching of largest possible size, this strategy for picking a vertex can be improved. First note that for every vertex v ∈ R of degree one, there is a matching of maximum size in which v is matched. The logic is as follows. Let u ∈ L be the vertex on the left side connected to v, (u, v) ∈ E. There must exist a vertex on the right side, w ∈ R, such that (u, w) ∈ E, such that w is matched to u by a matching M of maximum size; since, if not, adding (u, w) to it leads to a matching of larger size. Now defining a new matching M(cid:48) which is exactly M with (u, w) removed and (u, v) added, i.e. M(cid:48) = M ∪ {(u, v)} − {(u, w)}, we have M = M(cid:48) i.e. M(cid:48) is a maximum matching as well. Hence as long as we can find a vertex of degree one, we can find a matching of exactly maximum size. In other words: no mistake occurs as long as a degree one vertex is picked in every iteration of Greedy (a mistake occurs if in an iteration, the algorithm adds an edge to the matching which is not optimal, i.e. leads to a deviation from maximum matching). Algorithm 2 : Karp-Sipser Input: G = (L, R, E) Output: matching MKS(G) MKS ← ∅ while E (cid:54)= ∅ do deg(w) let v = arg min w∈L∪R if deg(v) = 0 then G ← G − {v} else if for u ∈ L ∪ R, {u, v} ∈ E then G ← G − {u, v} MKS ← MKS ∪ {{u, v}} end if end while return MKS 9 This fact is the idea behind Algorithm 2, called the Karp-Sipser Algorithm (KS) [22], which produces a matching MKS. In every iteration of KS, among all vertices a vertex of minimum degree is picked. Regarding time complexity of the KS algorithm, note the following connection with the Greedy one: in every iteration, KS picks a vertex of minimum degree and by using a "Heap" data structure, finding a vertex of minimum degree has complexity O(1) [31]; therefore, the running time of KS is linear. Further, since for real networks, the average degree is finite, for each iteration of the KS algorithm (i.e. excluding up to o(n) iterations) there are O(n) many vertices of degree one, which implies that determining a degree one vertex takes on average in O(1) steps. We can simplify the KS algorithm and search for a minimum degree vertex among vertices on only one side to derive Algorithm 3 that we call the One-sided Karp-Sipser (OKS) Algorithm and whose output we denote by MOKS. As we will see later in the analysis of real networks, the size of the matching given by OKS is usually less than or equal to the size of the matching given by KS. The intuition behind this is as follows. It is possible to make a mistake in OKS because of lack of degree one vertices on the right side, but if degree one vertices exist on the left side, KS can still work optimally. Yet, later we will prove (asymptotic) optimality of both algorithms. Algorithm 3 : One-Sided Karp-Sipser Input: G = (L, R, E) Output: matching MOKS(G) MOKS ← ∅ while E (cid:54)= ∅ do deg(w) let v = argmin w∈R if deg(v) = 0 then G ← G − {v} else if for u ∈ L, (u, v) ∈ E then G ← G − {u, v} MOKS ← MOKS ∪ {(u, v)} end if end while return MOKS IV. NUMERICAL EXAMPLES In this section, we present the results of selected numerical analyses on real world networks. We study the number of controllers, or equivalently the number of unmatched vertices for 10 different networks. This provides support to studying DD random networks as a realistic model for control applications. In other words, using Fig. 4, to find the number of controllers needed to structurally control a network, one can assume real networks are in fact DD random networks. The full description of these networks can be found in Table I. Table II contains the results for 10 networks, including social, internet, web, electronic, neuronal, power grid and tran- scriptional regulatory networks, enumerated by the first row of the table. The second (third and fourth respectively) row is the number of controllers needed for structural controllability of the corresponding network if OKS (KS and Maximum Matching respectively) algorithm will be used. 10 number 1 2 3 4 5 6 7 8 9 10 network leader2inter-st-college- student [32] celegansneural [33] p2p-Gnutella06 [34] polblogs [35] prisoninter-st-prison- inmates [32] s208-st [36] s420-st [36] s838-st [36] USpowergrid-n4941 [33] yeastinter-st [36] type Social Neuronal Internet WWW Social Electronic Circuits Electronic Circuits Electronic Circuits Power Grid Transcriptional Regulatory V 32 297 8717 1490 67 122 252 512 4941 688 Table I: Real networks used in this paper E 96 2345 31525 19025 182 189 399 819 13188 1079 description directed directed directed directed directed directed directed directed undirected directed Algorithms V − MOKS V − MKS V − M∗ average of V −MOKS for random network V = n 1 6 6 6 2 51 49 49 3 5033 5033 5033 4 703 702 702 Networks 5 10 9 9 6 29 29 29 7 59 59 59 8 119 119 119 5.6 29.8 5006.8 616.5 10.1 24.7 32 297 8717 1490 67 122 48.6 252 100.5 512 9 610 577 575 454.9 4941 10 565 565 565 557.7 688 Table II: The number of controllers given by different algorithms for different networks as well as the average number of controllers for equivalent degree distribution random network and the size of the networks. The fifth row shows the average number of controllers for a random network generated by degree distribution model for random networks, i.e. input and output degrees of all vertices are the same as the original real-world network but the attachment of half-edges is random. This random attachment is based on a simple fact that every random permutation is superposition of large enough number of random swaps. Finally, the last row of the table shows the size of the networks. As seen in the table, OKS and KS perform very close to Maximum Matching for all networks. Moreover, network 9 is the only one for which the performance of OKS is significantly different than KS. We suspect that this is because network 9 is the only undirected network. The numerical results in Table II can be understood better by the following figures. Fig. 3 shows the performance of OKS and KS versus Maximum Matching, i.e. rows 2,3 of the Table II versus row 4. The similarity in performance between OKS, KS and maximum matching algorithms is better depicted in Fig. 3. The number of controllers for equivalent degree distribution random network versus the original network, i.e. row 5 of the Table II versus row 4 is shown in Fig. 4. According to this plot, degree distribution random networks are sufficiently realistic models for real-world networks in terms of the number of controllers needed for structural controllability. V. MATCHING ALGORITHMS IN RANDOM NETWORKS In this section, we present results about the asymptotic size of matchings produced by the algorithms presented above. We first consider the general case where the asymptotic degree distribution of the random network is any arbitrary degree distribution with finite mean. Then, more detailed results regarding the special case for a Poisson asymptotic empirical degree 11 Figure 3: The number of controllers given by OKS ( ◦ ) and KS ( × ) versus the number of controllers given by Maximum Matching for 10 different real networks. Figure 4: The number of controllers for randomly rewired networks versus the number of controllers for the original networks. distribution will be provided. Even though as seen before, the latter case is not common among real networks, because of classical interests on ER and U F S random networks and the KS algorithm, as well as comprehensiveness, we also study it. Before proceeding with the analysis of matching algorithms in an extensive class of random networks, we must ensure that the size of the matchings provided by either Greedy, KS, OKS algorithms or any maximum matching algorithm has the Lipschitz property in order to have convergence of MG(G) for random network G where M∗(G) is a maximum matching of network G. The following lemma establishes the desired Lipschitz property. The size of the matching provided by any of the above algorithms has the Lipschitz property due to the recursive nature of the algorithms. and M∗(G) n MKS (G) MOKS (G) , n , n n The Lipschitz property for the size of maximum matchings comes from their maximality regardless of the algorithm used to obtain the maximum matching (this follows easily from the definition of maximum matching). Lemma 2. The real-valued functions MG,MKS, MOKS and M∗ which are the size of matchings provided by Greedy, KS, OKS and maximum matching algorithms, respectively, have the Lipschitz property. A. Arbitrary Degree Distribution We establish the optimality of OKS algorithm which immediately yields optimality of KS as well, for reasons explained before. For this purpose, we follow in the footsteps of Karp and Sipser [22] and embed the dynamics of both input and output degree sequences as the algorithm proceeds in continuous time. This embedding provides differential equations governing the degree sequence vectors. However, in the general degree distribution case, unlike the classic Erdos-Renyi case, the differential 12 equations are defined in arbitrarily high dimensions. So there is little hope of working in fixed small dimension as Karp and Sipser [22] did (their differential equations were 3 dimensional) and new ideas are needed. The key idea in our proof is to use the differential equations to show that the number of iterations when there is no degree one vertex (and so the algorithm can possibly make a mistake) is sublinear (in n) which means the fraction of unmatched vertices (or equivalently the relative size of the number of controllers) given by OKS is asymptotically the same as that of maximum matching. Finally, a set of equations for the relative size of maximum matching according to asymptotic empirical input and output degree distributions is provided. Theorem 2 (Asymptotic optimality of OKS algorithm). For network G = (L, R, E),R = L = n let MOKS(G) and M∗(G) be the size of matching given by OKS algorithm and the size of maximum matching respectively. Let G be either ipout(i) < ∞ (where pin, pout ER, U F S or DD random network with finite average degree, i.e. ipin(i) = ∞(cid:80) ∞(cid:80) E n = lim n→∞ i=0 i=0 are asymptotic empirical degree distributions). Then MOKS(G) n lim n→∞ M∗(G) n . = lim n→∞ Remark 2. Under the assumptions of Theorem 2, one can show the asymptotic optimality of KS as well: lim n→∞ MKS (G) n = M∗(G) n lim n→∞ . We omit the proof here as it is very similar to the proof of Theorem 2. √ Note that in Theorem 1 letting  = n−r for every r > 1 2 the convergence holds. So the difference between MOKS and n). Now the following questions arise: (i) what is the size of maximum matching? (ii) how can we compute the M∗ is O( answer (asymptotically) without running the algorithm? The following theorem gives the size of maximum matching in terms of input and output degree distributions. For u ∈ [0, 1) define moment generating functions: ∞(cid:88) Φin(u) = pin(i)ui, Φout(u) = pout(i)ui, ∞(cid:88) ∞(cid:88) ∞(cid:88) i=1 i=1 i=0 ipin(i) µ ui−1, ipout(i) µ ui−1, i=0 φin(u) = Φ(cid:48) in(u) = 1 µ φout(u) = Φ(cid:48) out(u) = 1 µ ipout(i) is the average degree. ∞(cid:80) i=0 ipin(i) = ∞(cid:80) i=0 where µ = Theorem 3 (Size of Maximum Matching). For (either ER, U F S or DD) random network G = (L, R, E),R = L = n if µ < ∞ let U∗ be (cid:104) 1 2 U∗ = Φin(1 − w1) + Φin(w2) + Φout(1 − w3) − 2 + Φout(w4) + µ (w3(1 − w2) + w1(1 − w4)) (cid:105) (1) where (w1, w2, w3, w4) ∈ [0, 1)4 is the smallest solution of φout(1 − w3) = 1 − w2 , φin(w2) = w3, φin(1 − w1) = 1 − w4 , φout(w4) = w1, then the asymptotic fraction of unmatched vertices is U∗: 13 n→∞ 1 − M∗(G) lim n = U∗. Note that the formula (1) first appeared in Liu et al.'s work [12] and was supported by numerical experiments. The result above formally proves its validity. B. Poisson Degree Distribution We first present selected asymptotic and non-asymptotic results about the fraction of matched vertices for the matching given by Greedy. Subsequently we generalize the results provided by Karp and Sipser [22] on the performance of KS. Studying a simple algorithm (Greedy) on a simple random network G (drawn from directed ER where every edge i → j exists with probability p) allows us to obtain explicitly the non-asymptotic probability mass function for MG(G). The following theorem also provides the asymptotic behavior of MG(G) for directed ER. Theorem 4 (Greedy for directed ER). Let the network G be directed ER of size n. Then: P(MG(G) = n − k) = αn(q)2 αk(q)2αn−k(q) qk2 , (1 − qj). For ER(λ) (i.e. np → λ) if λ = 0 then lim n→∞ MG(G) n = 0. If λ = ∞ then where q = 1 − p and αi(q) = i(cid:81) MG(G) n lim n→∞ j=1 = 1. For λ ∈ (0,∞), MG(G) is asymptotically normal: λ − log(2 − e−λ) (cid:18) N n λ (cid:19) . 1 4λ , n Some of the results in Theorem 4 remain valid for a larger class of random networks including directed and undirected networks. Theorem 5 (Greedy for asymptotically Poisson degree distributions). Assume G is one of ER(λ), U F S(λ), DD(p) and DD(p, p) where probability distribution p is Poisson(λ). If λ = 0 (respectively λ = ∞) then lim n→∞ 1). For λ ∈ (0,∞), = 1 − log(2−e−λ) = 0 (respespectively MG(G) . MG(G) n lim n→∞ n λ Similar results hold for KS. In fact, Karp and Sipser [22] proved that, for the classical undirected Erdos-Renyi random network (denoted by undirected ER(λ), λ ∈ (0,∞) here), KS is optimal. They split the running of the algorithm into two phases. Phase 1 begins when the algorithms starts and finishes the first time there is no vertex of degree one in the network, when phase 2 starts and proceeds until the algorithm removes all edges from the network. For network G let U (G), U1(G) and U2(G) be the number of vertices left unmatched (became of degree zero before being removed from the network) when 14 running maximum matching, phase 1 and phase 2 respectively, H = (V (cid:48), E(cid:48)) be the remaining network at the beginning of phase 2. Hence M∗(G) = n − U (G),MKS(G) = n − U1(G) − U2(G),MKS(H) = V (cid:48) − U2(G). Since there is no deviation from maximum matching as long as vertices of degree one exists, we have U1(G) ≤ U (G) ≤ U1(G) + U2(G). Karp and Sipser show U2(G) . Further, they show n → k(λ) and V (cid:48) where γ∗ is the smallest root of γ = λ exp(−λe−γ) and γ∗ = λe−γ∗. For λ ≤ e we have h(λ) = 0 because of γ∗ = γ∗. In the following theorem, we generalize these results to a larger class of random networks. n → 0 as n → ∞ so the algorithm is optimal, i.e. lim n→∞ n → h(λ) and find functions k, h as k(λ) = γ∗+γ∗+γ∗γ∗ − 1, h(λ) = (1−γ∗)(γ∗−γ∗) = lim n→∞ MKS (G) M∗(G) U1(G) n n λ λ Theorem 6 (KS for asymptotically Poisson degree distributions). Assume G is one of ER(λ), U F S(λ), DD(p) and DD(p, p) = 0. If λ = ∞ then where probability distribution p is Poisson(λ). If λ = 0 then lim n→∞ = lim n→∞ MKS (G) M∗(G) n n MKS (G) n lim n→∞ = lim n→∞ M∗(G) n = 1. For λ ∈ (0,∞), we have MKS(G) n lim n→∞ M∗(G) n = lim n→∞ = 1 − k(λ). Furthermore, U2(G) n → 0 , U1(G) n → k(λ) and V (cid:48) n → h(λ) as n → ∞. Remark 3. Note that the results in Theorem 6 are consistent with Theorem 3 as follows. Letting pin, pout be Poisson(λ), calculations show U∗ = k(λ) because of µ = λ, Φin(u) = Φout(u) = φin(u) = φout(u) = exp (λ(u − 1)). Results presented in Theorems 5 and 6 are based on the fact that in all mentioned random networks, the asymptotic empirical degree distribution is Poisson. VI. CONCLUSION We proved that the OKS algorithm is (asymptotically) optimal for determining a set of vertices where controllers should be applied to. Indeed, first benefiting from the connection between structural controllability of networks and maximum matching problems (minimum inputs theorem) we introduced simple fast matching algorithms OKS and KS. Further, using topologies extracted from real networks, we empirically showed that the minimum number of controllers for structural controllability heavily depends on the degree distribution of the network, which in turn implies that the assumption of a random network with specified degree distribution is reasonable for many real world networks. Finally, new proof techniques introduced in this study enable the rigorous analysis of the the performance of a class of fast matching algorithms for random networks. Ruths and Ruths [37] showed that existing random network models, while capturing the key features for predicting the minimum number of controllers, are not predicting more detailed control profiles of real networks. This calls for the development of new random network models that match control profiles, and associated fast control algorithms. APPENDIX A For an arbitrary  > 0, let N be large enough such that 2. Further, for random network G = (V, E),V = n, remove some edges from G in order to have no vertex of degree larger than N to get network G(cid:48) = (V, E(cid:48)). Now for every vertex i ∈ V there are possibly two reasons for the difference between Di and degG(cid:48)(i): kp(k) <  k=N +1 PROOF OF LEMMA 1 ∞(cid:80) • the set of edges we removed from G to get G(cid:48) • multiple edges in the network G(cid:48) 15 so, (cid:12)(cid:12)(cid:12){i ∈ V : Di = k} − {i ∈ V : degG(cid:48)(i) = k}(cid:12)(cid:12)(cid:12) ≤ E − E(cid:48) + n(cid:88) where Mi is the number of multiple edges in G(cid:48) connected to vertex i. There are at most(cid:0)N i=1 1Mi(cid:54)=0 (cid:1) pairs of half-edges connected (2) 2 to vertex i and for every two of them the probability of the outcome Aj that they both are connected to vertex j is at most (N 2 ) (D 2 ) where D = 2E(cid:48). So, (cid:18)N (cid:19) n(cid:88) 2 j=1 1Aj Mi ≤ , P(AjD) ≤ 2 (cid:1)(cid:0)D (cid:0)N (cid:1) . P(Mi ≥ 1(cid:12)(cid:12)D) ≤ 1 2 nδ By Markov's inequality for any δ > 0 we have: (cid:33) (cid:12)(cid:12)(cid:12)D P(Mi (cid:54)= 0(cid:12)(cid:12)D) = n(cid:88) i=1 n(cid:88) i=1 1 nδ ≤ 1 nδ (cid:32) P 1 n n(cid:88) 1Mi(cid:54)=0 > δ i=1 E n = µ and But lim n→∞ ∞(cid:80) k=N +1 (since kp(k) <  2 ) imply lim n→∞ E − E(cid:48) n <  2 1Mi(cid:54)=0 →P 0 lim n→∞ n > µ −  i.e. D−1 n(cid:88) 1 n i=1 On the other hand, for all k = 1, 2, . . . by the Law of Large Numbers: {i ∈ V : Di = k} lim n→∞ n = p(k) n(cid:88) i=1 E(Mi (cid:12)(cid:12)D) ≤ 2n(cid:0)N 2 (cid:1)2 δ(D − 1)2 . (3) (4) (5) Finally, because the only reason for the difference between degG(i) and degG(cid:48)(i) is the set of edges we removed from G to get G(cid:48) we have: (cid:12)(cid:12)(cid:12){i ∈ V : degG(i) = k} − {i ∈ V : degG(cid:48)(i) = k}(cid:12)(cid:12)(cid:12) ≤ E − E(cid:48) (6) Putting (2), (3), (4), (5), (6) all together: P lim n→∞ (cid:18)(cid:12)(cid:12)(cid:12){i ∈ V : degG(i) = k} n (cid:19) (cid:12)(cid:12)(cid:12) >  − p(k) = 0 Since the function f (G) = {i ∈ V : degG(i) = k} has the Lipschitz property by Theorem 1, a.s. convergence holds as well i.e. p(k) = p(k) 16 For DD(pin, pout), the changes in the asymptotic empirical degree distributions due to omission of max{ n(cid:88) n n(cid:80) n(cid:88) i − n(cid:80) D(in) i=0 i=0 D(in) , i i=0 i=0 } − min{ n(cid:88) D(out) i n(cid:88) D(in) i , D(out) i } i=0 i=0 → 0 because by the Law of Large Numbers lim n→∞ 1 n D(out) i n(cid:80) i=0 D(in) i = = µ as n → ∞. The contribution of multiple edges is asymptotically zero similarly. additional half-edges is at most 1 n(cid:80) i=0 lim n→∞ 1 n D(out) i APPENDIX B PROOF OF THEOREM 1 To prove convergence and concentration inequalities for real-valued functions for random networks we use some classical notions of probability such as martingale difference sequences. Rhee [38, Theorem 1] presents a concentration inequality for martingale difference sequences. Here we use a slightly more general version of it. The proof presented by Rhee [38] is valid by following the same line of reasoning. Theorem 7. Let Xi, i = 1, 2, . . . , k be a martingale difference sequence. If max 1≤i≤k a2 < ∞ then for all t ≥ 0 P( k(cid:88) Xi > t) ≤ 2 exp(− a2 M 2 ρ( M t a2 )) where ρ(x) = (1 + x) log(1 + x) − x for x ≥ 0. i=1 We prove the following stronger theorems: (cid:107)Xi(cid:107)∞ ≤ M < ∞ and k(cid:80) i=1 E(X 2 i Fi−1) ≤ Theorem 8. Assume f has the Lipschitz property and G = (V, E) is a random network in which V = {1, 2, . . . , n} and for i, j ∈ V , the edge i → j exists independently with probability p(n) ij . If lim sup n→∞ 1 n2 then f (G)−E(f (G)) n →P 0 as n → ∞. Furthermore, if n(cid:88) i,j=1 ij (1 − p(n) p(n) ij ) = 0 n(cid:88) i,j=1 ij (1 − p(n) p(n) ij ) = 0 lim sup n→∞ log n n2 (7) (8) then f (G)−E(f (G)) is exponential. In general given n → 0 a.s. as n → ∞. When the average degree is finite (e.g. ER(λ) for λ < ∞) the rate of convergence n(cid:88) i,j=1 1 n sup n≥1 ij (1 − p(n) p(n) ij ) ≤ C < ∞ (9) we have: P( f (G) − E(f (G)) n > ) ≤ 2 exp(−nCρ(  C )) Proof: To have more convenient notation we enumerate all possible edges i → j from 1 to k where k = n2 for for undirected ER. Indeed, Zi, i = 1, 2, . . . , k are independent Bernoulli random variables directed ER and k = n(n+1) 2 showing the existence of edges, i.e. if Zi = 1 the corresponding edge exists and if Zi = 0 the corresponding edge does not exist. Let pi, i = 1, 2, . . . be edge existence probabilities, P(Zi = 1), F0 be the trivial sigma-field and for i = 1, . . . , k let Fi = σ(Z1, . . . , Zi). Now define a martingale difference sequence as Xi = E(f (G)Fi) − E(f (G)Fi−1), i = 1, . . . , k so E(f (G)Fk) = f (G), E(f (G)F0) = E(f (G)). Define: 17 Ui = E(f (G)Z1, . . . , Zi−1, Zi = 1) Vi = E(f (G)Z1, . . . , Zi−1, Zi = 0) Thus, E(f (G)Z1, . . . , Zi−1) = piUi + (1 − pi)Vi  (1 − pi)(Ui − Vi) −pi(Ui − Vi) Xi = Zi = 0 i Fi−1) = pi(1 − pi)(Ui − Vi)2 E(X 2 Zi = 1 Since f has the Lipschitz property, Ui − Vi ≤ M (M = 1 for directed ER and M = 2 for undirected ER): max 1≤i≤k k(cid:88) (cid:107)Xi(cid:107)∞ ≤ max 1≤i≤k i Fi−1) ≤ k(cid:88) max{pi, 1 − pi} ≤ 1 pi(1 − pi) ≤ a2 < ∞ E(X 2 By Theorem 7 for all  > 0 we have: i=1 i=1 P( f (G) − E(f (G)) n > ) ≤ 2 exp(−a2ρ( n a2 )) (10) lim x→0 ρ(x) x2 = 1 2 implies: P( f (G) − E(f (G)) n > ) ≤ 2 exp(−2 n2 2a2 ) now if (7) holds then f (G)−E(f (G)) ) < ∞ so by the Borel-Cantelli lemma f (G)−E(f (G)) n n → 0 a.s. as n → ∞. →P 0 as n → ∞. To show the a.s. convergence, note that (8) gives ∞(cid:80) n=1 P( f (G)−E(f (G)) n > Finally using (9) we can let a2 = nC in (10) to obtain: f (G) − E(f (G)) P( n > ) ≤ 2 exp(−nCρ(  C )) Theorem 8 provides convergence and concentration inequality for ER random networks. A corollary of Theorem 8 is that the obtained results are valid for undirected random networks of Chung-Lu type (see page 82 of Durrett [30]). In a Chung-Lu random network the edge between i and j exists with probability wiwj wk for the set of weights w1, . . . , wn. Conditions (7), n(cid:80) k=1 18 (8), (9) for a Chung-Lu random network will be lim sup n→∞ n = 0, lim sup wn n→∞ wn log n n = 0 and sup n≥1 wn < ∞ respectively, where n(cid:80) wn is the average weight wn = 1 n Theorem 9. Assume f has the Lipschitz properrty and G = (V, E),E = kn is U F S. If wk. k=1 then f (G)−E(f (G)) n →P 0 as n → ∞. If furthermore, lim sup n→∞ kn n2 = 0 lim sup n→∞ kn log n n2 = 0 (11) (12) then f (G)−E(f (G)) for λ < ∞). Namely sup n≥1 n → 0 a.s. as n → ∞. The rate of convergence is exponential when the average degree is finite (e.g. U F S(λ) kn n ≤ C < ∞ implies: P( f (G) − E(f (G)) n > ) ≤ 2 exp(−n 2 C ) (13) Proof: Rhee [38, Theorem 4] shows If (11) holds then letting t = n we have exp(− t2 Borel-Cantelli Lemma f (G)−E(f (G)) kn n P(f (G) − E(f (G)) > t) ≤ 2 exp(− t2 kn ) → 0. If (12) holds then ) ∞(cid:80) P( n=1 → 0 a.s. as n → ∞. To show (13) it suffices to let t = n. f (G)−E(f (G)) n > ) < ∞ so by the Theorem 10. Let G = (V, E) be DD(pin, pout) or DD(p) (in the recent case pin = pout = p). Assuming real-valued function f has the Lipschitz property if E n2 = 0 lim sup n→∞ then f (G)−E(f (G)) n →P 0 as n → ∞. If in addition E log n n2 = 0 lim sup n→∞ then f (G)−E(f (G)) n → 0 a.s.. as n → ∞. When the average degree is finite i.e. E n sup n≥1 ≤ C < ∞ the rate of convergence is exponential: P( f (G) − E(f (G)) n > ) ≤ 2 exp(−nCρ(  4C )) (14) (15) (16) Proof: To form an inequality like (10) let k be the number of half-edges before being paired (so k is the number of directed edges - every undirected edge is two directed edges). Enumerate half-edges and for i = 1, 2, . . . , k let Zi be the random variable indicating the vertex whose half-edge the half-edge i is paired to i.e. Zi = j, j ∈ {1, . . . , n} if half-edge i is paired to a half-edge of vertex j. Let F0 be trivial sigma-field and for i = 1, . . . , k let Fi = σ(Z1, . . . , Zi). Now define a martingale difference sequence as Xi = E(f (G)Fi) − E(f (G)Fi−1), i = 1, . . . , k and Uij, Pij as : 19 Hence Ui = E(f (G)Z1, . . . , Zi−1) = n(cid:80) j=1 Uij = E(f (G)Z1, . . . , Zi−1, Zi = j) Pij = P(Zi = jZ1, . . . , Zi−1) PijUij and Xi = Uij − Ui whenever Zi = j. On the other hand, E(X 2 i Fi−1) = Pij(Uij − Ui)2 Lipschitz property of f implies Uij − Uil ≤ M (M ≤ 4 for undirected case and M ≤ 2 for directed case). Hence for all i = 1, . . . , k: n(cid:88) j=1 n(cid:88) PijM 2 ≤ k(cid:88) l=1 (cid:107)Xi(cid:107)∞ ≤ max 1≤j≤n (cid:107)Uij − Ui(cid:107)∞ ≤ max 1≤j≤n Pil(cid:107)Uij − Uil(cid:107)∞ ≤ M < ∞ k(cid:88) i Fi−1) ≤ k(cid:88) n(cid:88) E(X 2 M 2 ≤ kM 2 ≤ a2 < ∞ By Theorem 7 we have: i=1 i=1 j=1 i=1 ∀ ≥ 0 P( f (G) − E(f (G)) n > ) ≤ 2 exp(− a2 M 2 ρ( M n a2 )) Now (14), (15), (16) give lim sup n→∞ a2 n2 = 0, lim sup n→∞ a2 log n n2 = 0 and sup n≥1 a2 n ≤ 16C < ∞ respectively. APPENDIX C PROOF OF THEOREM 4 Letting M (n) = n − MG(G) be the number of unmatched vertices M (n) = n(cid:80) i=1 Mi where  1 0 Mi = the vertex picked in i-th iteration is unmatched the vertex picked in i-th iteration is matched P(Mi = 1M1, . . . , Mi−1) = q i−1(cid:80) Mj n−i+1+ j=1 Now note that according to the algorithm For example P(M (n) = 0) = P(M1 = 0, . . . , Mn = 0) = (1 − qn−i+1) = αn(q). We have P(M (n) = k) = i=1 P(Mi = 1{i∈I},∀ i = 1, . . . , n). n(cid:81) (cid:88) I=k If I = {i1, . . . , ik} then P(cid:0)Mi = 1{i∈I},∀i = 1, . . . , n(cid:1) = (1 − qn) . . . (1 − qn−i1+1)qn−i1+1(1 − qn−i1 ) . . . (1 − qn−ik+1)qn−ik+1 . . . (1 − qk+1) = αn(q) αk(q) qn−ij +1 P(M (n) = k) = αn(q) αk(q) q 2 k(k−1) (cid:88) 1 1≤i1<...<ik≤n k(cid:80) j=1 q ij i2−1(cid:88) i1=1 qi1 qik−1 . . . 1 − qi2−1 1 − q ) qik ik=k ik−1=k−1 qik . . . qi2(q (cid:88) 1≤i1<...<ik≤n k(cid:80) j=1 q ij = = = = = i2=2 ik−1(cid:88) i3−1(cid:88) i3−1(cid:88) i4−1(cid:88) i4−1(cid:88) i3=3 i2=2 qik . . . qik . . . qik . . . k(cid:89) j=1 ik=k n(cid:88) n(cid:88) n(cid:88) n(cid:88) n(cid:88) ik=k ik=k αi2−1(q) αi2−2(q) qi2 q1 α1(q) qi3 q1+2 α2(q) (cid:104) (1 + q)(1 − qi3−2) − q(1 − q2i3−5) (cid:105) qi3 q1+2 α2(q) αi3−1(q) αi3−3(q) ik=k = . . . = i3=3 αn(q) 1 2 k(k+1) q αk(q)αn−k(q) n = log(2−e−λ) λ 20 Thus: But: which establishes the result. Now to show lim n→∞ 1 − qn−k (1 − qk+1)2 q2k+1 = P(M (n) = k + 1) P(M (n) = k) = M (n) for ER(λ), for large n let (1− λ 1 − exp(cid:0)− λ (cid:2)1 − exp(cid:0)− λ n (n − k)(cid:1) n (k + 1)(cid:1)(cid:3)2 exp (cid:18) − λ n (2k + 1) . n )j = exp(− λ (cid:19) n j) to have: Denote βk = exp(− λ n k) to obtain: P(M (n) = k + 1) P(M (n) = k) = k(1 − e−λβ−1 β2 k ) n − 2βk + e− λ e λ n β2 k . P(M (n)=k+1) P(M (n)=k) > 1 if and only if (e− λ Therefore and as n → ∞, P(M (n) = k + 1) > P(M (n) = k) if and only if β−1 letting k∗ = arg max 0≤k≤n Theorem 8, a.s. convergence holds as well. To prove the asymptotic normality we will show P(M (n) = k) we get P(M (n) − k∗ > n) → 0 for all  > 0 as n → ∞ i.e. M (n) k < 2 − e−λ which is equivalent to k < log(2−e−λ) log(2−e−λ) n < 0 i.e. the probability mass function is unimodal n →P k + (e−λ − 2)βk + e λ n − 1)β2 λ λ lim n→∞ log P(M (n) = k(t)) P(M (n) = k(0)) = − t2 2σ2 where t = lim n→∞ k(t)−nµ√ n , k(0) = k∗ ≈ nµ, µ = log(2−e−λ) log P(M (n) = k(t)) = , σ2 = 1 4λ. We have: fj( t√ n ) − λnµ2 − λt2 − 2λ √ nµt λ n−k(t)(cid:88) j=1 n so . By (17) where the functions fj : R → R, j = 1, 2, . . . are fj(x) = 2 log(1 − e−λ(µ+j/n)−λx) − log(1 − e−λj/n). Note that But for aj = e−λ(µ+j/n) < 1 and some B < ∞ e−λµ = (2 − e−λ)−1. 21 (18) fj(0) = 2 log(1 − e−λ(µ+j/n)) − log(1 − e−λj/n) f(cid:48) j(0) = 2λaj 1 − aj −2λ2aj (1 − aj)2 f(cid:48)(cid:48) j (0) = f(cid:48)(cid:48)(cid:48) j (x) < B. j(0) t√ n ) = fj(0)+f(cid:48) n +f(cid:48)(cid:48) Now writing fj( t√ 1 − µ definition of Riemann integral implies: n−k(t)(cid:88) n−k(t)(cid:88) n−k(t)(cid:88) 1 n 1 n j=1 j=1 √ 1 n n j=1 j (0) t2 2n +f(cid:48)(cid:48)(cid:48) j ( t∗√ n ) j(0) → 2λ f(cid:48) 6n n for some t∗ ∈ [0, t] and using (18), because 1 √ t3 1−µ(cid:90) 1−µ(cid:90) eλµ+λx − 1 dx = 2λµ 1 e−λ(µ+x) 0 dx = −2λ (1 − e−λ(µ+x))2 j (0) → −2λ2 f(cid:48)(cid:48) t∗√ n ) < 0 → 0. B√ n f(cid:48)(cid:48)(cid:48) j ( n (n−k(t)) → n−k(t)(cid:80) j=1 j(0)− f(cid:48) n−k(t)(cid:80) j=1 Note that 1 n √ 2λµ j(0)−2λµ ≤ (1−µ)2 f(cid:48) n sup µ≤x≤1 ∂ ∂x 1 eλx−1 and sup µ≤x≤1 ∂ ∂x 1 eλx−1 = sup µ≤x≤1 n → 0. Now plugging all in (17) we get the desired result since log P(X = k(0)) = λeλx (eλx−1)2 < ∞ imply 1√ n−k(0)(cid:80) fj(0) − λnµ2. n j=1 APPENDIX D PROOF OF LEMMA 2 To prove the Lipschitz property for maximum matching let G = (L, R, E), G(cid:48) = (L, R, E(cid:48)), E(cid:48) = E ∪ {e},L = R = n and let M ⊂ E(cid:48) be a maximum matching in G(cid:48). If e /∈ M then M is a maximum matching in G. If e ∈ M then M − {e} is a matching in G so the size of maximum matching is at least M − {e}. Thus M∗(G(cid:48)) − 1 ≤ M∗(G) ≤ M∗(G(cid:48)). For the Greedy algorithm, if n = 1 then clearly MG(G(cid:48)),MG(G) are both either 0 or 1 so Assume function MG has the Lipschitz property for all networks of vertex size n − 1 and define networks H, H(cid:48) as the networks G, G(cid:48) after the first iteration: H = G − {u, v}, H(cid:48) = G(cid:48) − {u(cid:48), v(cid:48)}; u, u(cid:48) ∈ L; v, v(cid:48) ∈ R so both H, H(cid:48) have n − 1 vertices. If u = u(cid:48) and v = v(cid:48) then networks H, H(cid:48) are exactly the same except potentially the new edge e which can be added to H in order to get H(cid:48). Since H, H(cid:48) both have n − 1 vertices, by the assumption MG(H(cid:48)) − MG(H) ≤ 1. On the other hand, MG(G) = MG(H) ∪ {(u, v)}, MG(G(cid:48)) = MG(H(cid:48)) ∪ {(u, v)} imply MG(G) = MG(H) + 1,MG(G(cid:48)) = MG(H(cid:48)) + 1 i.e. MG(G(cid:48)) − MG(G) ≤ 1. (cid:12)(cid:12)(cid:12)MG(G(cid:48)) − MG(G)(cid:12)(cid:12)(cid:12) ≤ 1. 22 If v (cid:54)= v(cid:48) then the new edge e is connected to v(cid:48) ∈ R, u(cid:48) ∈ L and degG(v(cid:48)) = 0, degG(cid:48)(v(cid:48)) = 1. Now there are two possible cases: 1) vertex u(cid:48) ∈ L is not used in MG(G) i.e. there is not any vertex w ∈ R in MG(G) such that u(cid:48) is matched to w by Greedy algorithm applied to G. Therefore iterations of the Greedy algorithm after the first iteration will not change once the new edge e is added. In this case MG(G) = MG(H(cid:48)) and MG(G(cid:48)) = MG(H(cid:48)) ∪ {(u(cid:48), v(cid:48))}. 2) vertex u(cid:48) ∈ L is used in MG(G) i.e. there is a vertex w ∈ R such that u(cid:48) is matched to w by Greedy algorithm applied to G: (u(cid:48), w) ∈ MG(G) . Therefore the only iteration of the Greedy algorithm which will change once the new edge e is added is the one that vertex w ∈ R is picked. In this case MG(G) = MG(H(cid:48))∪{(u(cid:48), w)} and MG(G(cid:48)) = MG(H(cid:48))∪{(u(cid:48), v(cid:48))}. (cid:12)(cid:12)(cid:12)MG(G(cid:48)) − MG(G)(cid:12)(cid:12)(cid:12) ≤ 1. So MG has the Lipschitz property. Note that there is no assumption In both cases we have about the vertices v, v(cid:48) picked in the first iteration of the Greedy algorithm. So this proof is valid assuming vertices v, v(cid:48) are of minimum degree, i.e. the proof works for MKS and MOKS as well. APPENDIX E PROOF OF THEOREM 2 We prove the theorem in two steps. In Step 1, first we embed the dynamics of input and output degree sequences during the algorithm in a continuous time Markov process for a random network with bounded degrees. Then, we find explicit expressions for differential equations governing the dynamics of degree sequences for infinitely large networks. Then, we show that for a finite random network, the dynamics of degree sequences can be approximated by the solution of the presented initial value problem. Finally, we show that this solution spends zero time in the cases where there is no vertex of degree one so the number of iterations of the algorithm there is no vertex of degree one on the right side of the random network is sublinear w.r.t. the size of the network. In Step 2, we generalize the proof to the unbounded, but finite mean, degree sequences. Step 1: Embedding in a continuous time Markov process. Assume in addition that the asymptotic empirical degree distributions are bounded: pin(i) = pout(i) = 0 for i > N i.e. for every vertex v ∈ L ∪ R we have deg(v) ≤ N. First, we embed the dynamics of the algorithm in a continuous time Markov process. To go to continuous time, define Gn(t) as the n-vertex network at time t ∈ R where state changes Gn = Gn −{u, v} occur at Exp(n) interarrival times. More precisely, let τ1, τ2, . . . be i.i.d Exp(n) random variables, i.e. the probability density function is ne−nt for t ≥ 0 so E(τi) = 1 n. The first state change Gn = Gn − {u, v} occurs at time t = τ1, the second one occurs at t = τ1 + τ2 and so forth. Now we construct a Markov process on R2N which describes the performance of the algorithm. The transition kernel of the Markov process will be described later. Define X (n)(t), Y (n)(t) ∈ RN as: (cid:12)(cid:12){v ∈ R : deg(v) = k in Gn(t)}(cid:12)(cid:12), (cid:12)(cid:12){v ∈ L : deg(v) = k in Gn(t)}(cid:12)(cid:12), X (n) k (t) = Y (n) k (t) = 1 n 1 n for k = 1, 2, . . . , N. In addition let m = m(X (n)(t)) be the minimum degree of vertices in R(t): m(X (n)(t)) = min{k : k (t) (cid:54)= 0} so letting v1 = v, u1 = u whenever a state change occurs we have deg(v1) = m. Let (ui, v) ∈ E for X (n) i = 1, . . . , m, K = deg(u1) and (u, vj) ∈ E for j = 1, . . . , K. So for a network of size n we have the following conditional degree distributions for vertices u1, . . . , um, v2, . . . , vK: 23 k N(cid:80) k=1 Pn (deg(ui) = kAi−1(t)) = Pn (deg(vi) = kBi−1(t)) = nkY (n) (t) − k 1deg(uj )=k n kY (n) k deg(uj) nkX (n) k (t) − k N(cid:80) kX (n) n k=1 1deg(vj )=k deg(vj) j=1 i−1(cid:80) (t) − i−1(cid:80) i−1(cid:80) k (t) − i−1(cid:80) j=1 j=1 j=1 , , where Ai(t) = (deg(u1), . . . , deg(ui), Y (n)(t)),Bi(t) = (deg(v1), . . . , deg(vi), X (n)(t)). Note that since interarrival times are i.i.d exponential random variables, X (n)(t), Y (n)(t) are continuous time Markov processes. Letting X (n), Y (n) ∈ RN be the corresponding vectors after one state change for x, y ∈ RN define functions Fn, Gn : R2N → RN as: Fn(x, y) = nEn( X (n) − X (n)X (n) = x, Y (n) = y), Gn(x, y) = nEn( Y (n) − Y (n)X (n) = x, Y (n) = y), where En is expected value w.r.t Pn. Since the process is Markov, probability distribution of X (n), Y (n) depends only on X (n), Y (n). Asymptotic initial value problem: Define P(deg(ui) = k) = kY (n) k kY (n) (t) (t) , P(deg(vi) = k) = kX (n) k (t) kX (n) can be defined for every x, y ∈ RN with non-negative components. Now, for arbitrary x, y, some algebra gives: k=1 k=1 k (t) . Note that Pn, P N(cid:80) k N(cid:80) Pn(deg(ui) = kAi−1(t)) − P(deg(ui) = k) ≤ C1 n , Pn(deg(vi) = kBi−1(t)) − P(deg(vi) = k) ≤ C2 n . N(cid:80) For C1 = 2N 2 kyk N(cid:80) , C2 = 2N 2 kxk k=1 k=1 . Define: F(x, y) = nE( X (n) − X (n)X (n) = x, Y (n) = y), G(x, y) = nE( Y (n) − Y (n)X (n) = x, Y (n) = y), where E is expected value w.r.t P. Since n X (n) k = nX (n) k + n Y (n) k = nY (n) k + K(cid:88) [1deg(vj )=k+1 − 1deg(vj )=k] − 1k=m, m(cid:88) [1deg(uj )=k+1 − 1deg(uj )=k] − 1k=K, j=2 j=2 (19) (20) (21) (22) 24 inequalities (19), (20) yield N(cid:80) (cid:107)Fn(x, y) − F(x, y)(cid:107)1 ≤ 4N 4 kxk 1 n , k=1 N(cid:80) (cid:107)Gn(x, y) − G(x, y)(cid:107)1 ≤ 4N 4 kyk 1 n , k=1 (23) (24) and, F(x, y) = ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1) 1 (SAx − Ax) − 1m(x), (cid:107)Ax(cid:107)1 m(x) − 1 (cid:107)Ay(cid:107)1 + G(x, y) = − Ay (cid:107)Ay(cid:107)1 (SAy − Ay), where A and S are moment matrix and shift matrix respectively, i.e., A, S ∈ RN×N , Aij is i for i = j and 0 otherwise, and Sij is 1 for i = j − 1 and 0 otherwise, m(x) = min{k : xk (cid:54)= 0} and 1m ∈ RN is the vector in which m-th component is 1 and all others are 0. Note that (cid:107)AX (n)(t)(cid:107)1 = (cid:107)AY (n)(t)(cid:107)1 because for finite n always E(t) = n (t). Besides, transition kernel of the Markov process can be formulated by Pn according to (21), (22). k (t) = n N(cid:80) N(cid:80) kX (n) kY (n) k=1 k=1 k Approximating the dynamics of the degree sequences by the solution of asymptotic initial value problem: Now we can use Kurtz's Theorem [39]. Given functions F, G : R2N → RN and positive constant T , define x(t), y(t) : [0, T ] → RN as the solution of the initial value problems x = F(x, y), xk(0) = pin(k), k = 1, . . . , N , y = G(x, y), yk(0) = pout(k), k = 1, . . . , N , N(cid:80) and let E = {z ∈ RN such that:  < kzk ≤ N}. Suppose the following statements hold: k=1 (cid:107)Fn(z1, z2) − F(z1, z2)(cid:107)1 = 0. (cid:107)Gn(z1, z2) − G(z1, z2)(cid:107)1 = 0. 1) 2) lim n→∞ sup z1,z2∈E n→∞ sup lim z1,z2∈E 3) for all k = 1, . . . , N, k (0) = pin(k). 4) for all k = 1, . . . , N, 5) functions F, G are Lipschitz (in the classic sense). (0) = pout(k). n→∞ X (n) lim n→∞ Y (n) lim k (25) (26) (27) Then (cid:16)∃t ∈ [0, T ] : m(X (n)(t)) (cid:54)= m(x(t)) N(cid:80) (cid:17) = 0. Pn lim n→∞ N(cid:80) kyk(t) > } for some arbitrary  > 0, the first two conditions are satisfied by Letting T = T () = sup{t : (0) = pout(k). (23), (24). By the definition of asymptotic empirical degree distributions lim On the other hand, the initial value problems (25), (26) have unique solutions since defining metric d on RN as d(x, y) = k (0) = pin(k) and lim n→∞ X (n) n→∞ Y (n) kxk(t) > , k=1 k=1 k (cid:107)x − y(cid:107)1 + 1m(x)(cid:54)=m(y), F, G are Lipschitz with respect to this metric i.e. there is a B < ∞ such that for all x, x(cid:48), y, y(cid:48) ∈ RN 25 d(F(x, y), F(x(cid:48), y(cid:48))) < B(d(x, x(cid:48)) + d(y, y(cid:48))), d(G(x, y), G(x(cid:48), y(cid:48))) < B(d(x, x(cid:48)) + d(y, y(cid:48))). Note that stopping time at T (), i.e. when n edges are remaining in the network to be removed by the algorithm, will not cause any problem since continuing the algorithm from that point on cannot add more than  edges to the matching on a scale relative to the number n of vertices. Properties of the asymptotic initial value problems: The useful fact about the solutions of (25), (26) is that Lebesgue measure of the set {0 < t < T : m(x(t)) > 1} is zero. Suppose it is not. So there are 0 < t1 < t2 such that x1(t) = 0 for all t ∈ [t1, t2] so dx1(t) dt = 0 for all t ∈ (t1, t2). But dx1(t) dt = F1(x, y) = ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1) 1 (cid:107)Ax(cid:107)1 (2x2(t) − x1(t)) implies x2(t) = 0 for all t ∈ (t1, t2) which means m(x(t)) > 2 for all t ∈ (t1, t2). Repeating this argument for x2 now we will get m(x(t)) > 3 and so on. Therefore, m(x(t)) > N which is impossible. Thus, the set {0 < t < T : m(x(t)) > 1} has zero Lebesgue measure. Sublinearity of the number of iterations of the algorithm with no degree one vertex: Let J (n) ⊂ {1, 2, . . . , n} be the set of indices i of iterations of OKS such that after the i-th iteration the minimum degree on the right side of the network is larger than one. Since the set {0 < t < T : m(x(t)) > 1} has zero Lebesgue measure by (27) Lebesgue measure of the set {0 < t < T : m(X (n)(t)) > 1} goes to 0 as n grows. Because the Lebesgue measure of the set {0 < t < T : m(X (n)(t)) > 1} nτi+1 = E(nτ1) = 1. Therefore τi+1 = 0 but by the Law of Large Numbers lim n→∞ is (cid:80) (cid:80) (cid:80) 1J (n) i∈J (n) n = lim n→∞ i∈J (n) lim n→∞ there is no vertex of degree one on the right side of the network is sublinear w.r.t. the size of the network. J (n) nτi+1 = lim n→∞ 1J (n) i∈J (n) i∈J (n) i∈J (n) Sublinearity of difference between the output of OKS and maximum matching: Using lim n→∞ n = 0 we prove that the size of the matching provided by the OKS algorithm is away from maximum matching size by a sublinear factor. Starting τi+1 we have lim n→∞ J (n) J (n) n (cid:80) (cid:80) τi+1 = 0 i.e. the number of iterations of OKS algorithm for which the algorithm, as long as the minimum degree on the right side of the network is one, OKS makes no mistake, i.e. the size of the matching by OKS is the same as the size of maximum matching. When the minimum degree is m = m(X (n)(t)) > 1 it is possible that OKS picks a vertex on the left side which is not the optimal choice. We make it optimal by manipulating the network: if v ∈ R, u ∈ L, deg(v) = m are the chosen vertices in the iteration of the algorithm to be removed from the network, MOKS = MOKS ∪ {(u, v)}, manipulate the network by removing all other m − 1 edges connected to v. Since M∗ has the Lipschitz property, removing these m− 1 edges will change the size of the maximum matching by at most m− 1. Since m is the minimum degree and the average degree is bounded, m− 1 is bounded as well. On the other hand, the number of iterations that OKS will face such cases is sublinear w.r.t. the size of the network, so the whole number of possible errors, or in other words, the whole deviation from maximum matching made by OKS is sublinear, i.e. MOKS (G) n lim n→∞ = lim n→∞ M∗(G) n . Step 2: Generalization to unbounded degree. Now to generalize the proof to cases where the asymptotic empirical degree 26 ∞(cid:80) ∞(cid:80) distributions are not bounded, we use the classical technique of truncation. For arbitrary  > 0, let N be large enough such that kpin(k) <  2 , kpout(k) <  2. In random network G remove some edges in order to have no vertex of degree k=N +1 i=N +1 larger than N to get random network H which has bounded asymptotic empirical degree distributions. By Step 1, MOKS(H) n M∗(H) n . = lim n→∞ lim n→∞ (28) Because by Lemma 2 both functions M∗,MOKS have the Lipschitz property and asymptotically the number of edges removed from G to get H is less than n: (cid:12)(cid:12)M∗(H) − M∗(G)(cid:12)(cid:12) (cid:12)(cid:12)MOKS(H) − MOKS(G)(cid:12)(cid:12) n < , lim n→∞ lim n→∞ n < . (29) (30) Now (28), (29), (30) imply the desired result. Further, when  → 0, N → ∞, so formally we can take N = ∞ and write the functions F, G : R∞ → R∞ as F(x, y) = ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 G(x, y) = − Ay (cid:107)Ay(cid:107)1 − 1) 1 (cid:107)Ax(cid:107)1 m(x) − 1 (cid:107)Ay(cid:107)1 + (SAx − Ax) − 1m(x), (SAy − Ay), ∞(cid:80) ∞(cid:80) for matrices A, S ∈ R∞×∞ provided (cid:107)A2x(0)(cid:107)1 = k2pin(k) < ∞ or (cid:107)A2y(0)(cid:107)1 = k2pout(k) < ∞. k=1 k=1 APPENDIX F PROOF OF THEOREMS 5,6 As we saw in the proof of Theorem 2, The asymptotic performance of Greedy, OKS and KS algorithms can be described by asymptotic empirical degree distributions which are solutions of some initial value problems. If we find functions F, G : R∞ → R∞ for Greedy and KS we will have F(x, y) = ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 G(x, y) = − Ay (cid:107)Ay(cid:107)1 − 1) + + 1 (SAx − Ax) − x (cid:107)x(cid:107)1 (cid:107)Ax(cid:107)1 (cid:107)Ax(cid:107)1 − 1 (cid:107)x(cid:107)1 (cid:107)Ay(cid:107)1 (SAy − Ay) , for Greedy and for KS F(x, y) = xm xm + ym G(x, y) = ym xm + ym (cid:20) (cid:20) ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1) 1 (cid:107)Ax(cid:107)1 (SAx − Ax) − 1m (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 − 1) 1 (cid:107)Ay(cid:107)1 ( (SAy − Ay) − 1m (cid:21) (cid:21) (cid:20) (cid:20) − Ax (cid:107)Ax(cid:107)1 − Ay (cid:107)Ay(cid:107)1 m − 1 (cid:107)Ax(cid:107)1 + m − 1 (cid:107)Ay(cid:107)1 + + + ym xm + ym xm xm + ym (cid:21) (cid:21) (SAx − Ax) (SAy − Ay) where m = min{m(x(t)), m(y(t))} is the minimum degree. Since for KS we have G(x, y) = F(y, x), when x(0) = y(0) (i.e. pin = pout) x(t) = y(t) and 27 x = F(x) = ( (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 + m − 2) SAx − Ax 2(cid:107)Ax(cid:107)1 − Ax 2(cid:107)Ax(cid:107)1 − 1m 2 Thus for any degree distribution p the dynamics of KS is the same for both DD(p) and DD(p, p). Further, regarding the results provided in Theorems 5, 6 the relative size of the output of the algorithm as well as the dynamics of the algorithm is the same for all random networks ER(λ), U F S(λ), DD(p) and DD(p, p) where probability distribution p is Poisson(λ) because they all are sharing the asymptotic empirical degree distributions. So Theorem 4 implies lim n→∞ MG(G) n = 1 − log(2−e−λ) λ . For KS, all mentioned statements are proved for undirected ER(λ) by Karp and Sipser [22] so are valid for the desired class of random networks. APPENDIX G PROOF OF THEOREM 3 ∞(cid:80) Here we assume in addition that (cid:107)A2x(0)(cid:107)1 = k2pout(k) < ∞. Generalization to the case where above quantities are not bounded is straightforward similar to Step 2 in the proof of Theorem 2 and is omitted. k2pin(k) < ∞ and (cid:107)A2y(0)(cid:107)1 = k=1 k=1 Because lim n→∞ M∗(G) n = lim n→∞ MKS (G) n it suffices to show U∗ = lim n→∞ 1− MKS (G) n . To show the latter claim, we run KS algorithm and find the number of vertices left unmatched by the algorithm. Similar to what we did in the proof of Theorem ∞(cid:80) T(cid:90) (cid:20) 2 the asymptotic fraction of vertices left unmatched by KS is 1 − lim n→∞ MKS(G) n = pin(0) + xm xm + ym (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 ( − 1) + (m − 1)ym xm + ym where 0 T = sup{t : ∞(cid:88) k=1 kxk(t) > 0, ∞(cid:88) k=1 kyk(t) > 0} (cid:21) x1(t) (cid:107)Ax(cid:107)1 dt x = F(x, y), x(0) = pin y = F(y, x), y(0) = pout (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1) 1 (cid:107)Ax(cid:107)1 (SAx − Ax) − 1m + ym xm + ym (cid:21) (cid:20) − Ax (cid:107)Ax(cid:107)1 (cid:21) m − 1 (cid:107)Ax(cid:107)1 + (SAx − Ax) (cid:20) ( F(x, y) = xm xm + ym and m = min{m(x(t)), m(y(t))} is the minimum degree. Since as we saw in the proof of Theorem 2 the set {t : m(x(t)) > 1, m(y(t)) > 1} is of zero Lebesgue measure without loss of generality in all integrations we can assume m = 1, especially 1 − lim n→∞ MKS(G) n = pin(0) + x1 x1 + y1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 ( − 1) x1(t) (cid:107)Ax(cid:107)1 dt Now define: x0(t) = pin(0) + t(cid:90) 0 x1 x1 + y1 (cid:107)A2y(s)(cid:107)1 (cid:107)Ay(s)(cid:107)1 ( − 1) x1(s) (cid:107)Ax(cid:107)1 ds, T(cid:90) 0 28 U (t) = 1 2 y0(t) = pout(0) + t(cid:90) 0 x1 + y1 y1 ∞(cid:88) ∞(cid:88) (cid:107)A2x(s)(cid:107)1 (cid:107)Ax(s)(cid:107)1 ( − 1) y1(s) (cid:107)Ay(cid:107)1 ds, µ(t) = ixi(t) = iyi(t) = (cid:107)Ax(cid:107)1 = (cid:107)Ay(cid:107)1, i=0 i=0 Φin(t, u) = xi(t)ui, ∞(cid:88) ∞(cid:88) i=0 Φout(t, u) = yi(t)ui, ∞(cid:88) ∞(cid:88) i=1 i=1 i=0 ixi(t) (cid:107)Ax(t)(cid:107)1 ui−1, iyi(t) (cid:107)Ay(t)(cid:107)1 ui−1, φin(t, u) = φout(t, u) = φin(t, w2(t)) = w3(t), φin(t, 1 − w1(t)) = 1 − w4(t), φout(t, w4(t)) = w1(t), φout(t, 1 − w3(t)) = 1 − w2(t), V (t) = xi(t) = (cid:107)x(t)(cid:107)1, ∞(cid:88) i=1 (cid:104) + µ(t)(cid:2)w3(t)(1 − w2(t)) + w1(t)(1 − w4(t))(cid:3)(cid:105) Φin(t, w2(t)) + Φin(t, 1 − w1(t)) + Φout(t, w4(t)) + Φout(t, 1 − w3(t)) − 2 Since x1(T ) = x2(T ) = . . . = 0, y1(T ) = y2(T ) = . . . = 0 we have V (T ) = 0, µ(T ) = 0. But V (0) = 1 − pin(0) and for m = 1 V (t) = d(cid:107)x(cid:107)1 dt (cid:20) x1 = x1 + y1 = − x1 ( x1 + y1 = − x0(t) − 1 (cid:107)A2y(cid:107)1 −( (cid:107)Ay(cid:107)1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1) − 1 x1(cid:107)Ax(cid:107)1 − 1 x1(cid:107)Ax(cid:107)1 − 1) (cid:21) − y1 x1 + y1 i.e. −1 + pin(0) = V (T ) − V (0) = x0(0) − x0(T ) − T = pin(0) − x0(T ) − T . Therefore Φin(T, u) = x0(T ), Φout(T, u) = y0(T ), U (T ) = 1 − 2T and 1 − lim n→∞ MKS(G) n = x0(T ) = y0(T ) = 1 − T (31) On the other hand, as long as m = 1: µ(t) = dµ dt = y1 (cid:21) (cid:20) −(cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 x1 + y1 − y1 = − x1 = − x1(cid:107)A2y(cid:107)1 + y1(cid:107)A2x(cid:107)1 x1 + y1 (x1 + y1)(cid:107)Ax(cid:107)1 , x1 + y1 + x1 x1 + y1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (cid:20) ( (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 29 − 1) −x1 − (cid:107)Ax(cid:107)1 + x1 (cid:107)Ax(cid:107)1 (cid:21) − 1 d dt Φin(t, w2(t)) = + = + x1 x1 + y1 y1 x1 + y1 x1 x1 + y1 y1 x1 + y1 ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1)φin(t, w2(t))(1 − w2(t)) − w2(t) (cid:104) (cid:105) (cid:2) − w2(t)φin(t, w2(t))(cid:3) + (cid:107)Ax(cid:107)1 w2(t)φin(t, w2(t)) (cid:20) (cid:21) (cid:2) − w2(t)w3(t)(cid:3) + (cid:107)Ax(cid:107)1 w2(t)φin(t, w2(t)), − 1)w3(t)(1 − w2(t)) − w2(t) (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 ( Φin(t, 1 − w1(t)) = d dt + = + x1 x1 + y1 y1 x1 + y1 x1 x1 + y1 y1 x1 + y1 ( (cid:105) (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 − 1)φin(t, 1 − w1(t))w1(t) − 1 + w1(t) (cid:104) (cid:2) − 1 + w1(t)φin(t, 1 − w1(t))(cid:3) − (cid:107)Ax(cid:107)1 w1(t)φin(t, 1 − w1(t)) (cid:20) (cid:2) − (1 − w1(t))(1 − w4(t))(cid:3) − (cid:107)Ax(cid:107)1 w1(t)φin(t, 1 − w1(t)), − 1)w1(t)(1 − w4(t)) − 1 + w1(t) (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (cid:21) ( [µ(t)w3(t)(1 − w2(t))] = µ(t)w3(t)(1 − w2(t)) + µ(t) w3(t)(1 − w2(t)) − µ(t)w3(t) w2(t) d dt − x1(cid:107)A2y(cid:107)1 + y1(cid:107)A2x(cid:107)1 (x1 + y1)(cid:107)Ax(cid:107)1 w3(t)(1 − w2(t)) + (cid:107)Ax(cid:107)1 (cid:2) w3(t)(1 − w2(t)) − w3(t) w2(t)(cid:3). (cid:18) (cid:19) (cid:21) (cid:21) (cid:21) (cid:21) y1 x1 + y1 x1 x1 + y1 = The above equations imply: = (cid:20) (cid:20) (cid:20) (cid:20) ( ( ( ( 2 dU (t) dt x1 x1 + y1 x1 x1 + y1 y1 x1 + y1 y1 x1 + y1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 + + + − 1)w3(t)(1 − w2(t)) − w2(t) + [−w2(t)w3(t)] + (cid:107)Ax(cid:107)1 w2(t)φin(t, w2(t)) − 1)w1(t)(1 − w4(t)) − 1 + w1(t) + y1 x1 + y1 [−(1 − w1(t))(1 − w4(t))] − (cid:107)Ax(cid:107)1 w1(t)φin(t, 1 − w1(t)) − 1)w1(t)(1 − w4(t)) − w4(t) + [−w4(t)w1(t)] + (cid:107)Ay(cid:107)1 w4(t)φin(t, w4(t)) − 1)w3(t)(1 − w2(t)) − 1 + w3(t) + x1 x1 + y1 [−(1 − w3(t))(1 − w2(t))] − (cid:107)Ay(cid:107)1 w3(t)φin(t, 1 − w3(t)) + (− x1(cid:107)A2y(cid:107)1 + y1(cid:107)A2x(cid:107)1 + (− x1(cid:107)A2y(cid:107)1 + y1(cid:107)A2x(cid:107)1 (x1 + y1)(cid:107)Ax(cid:107)1 (x1 + y1)(cid:107)Ax(cid:107)1 )w3(t)(1 − w2(t)) + (cid:107)Ax(cid:107)1 [ w3(t)(1 − w2(t)) − w3(t) w2(t)] )w1(t)(1 − w4(t)) + (cid:107)Ax(cid:107)1 [ w1(t)(1 − w4(t)) − w1(t) w4(t)] 30 i.e. 2 d dt U (t) = + (w3(t)(1 − w2(t)) +w1(t)(1 − w4(t))) + ( (cid:20) −(cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (cid:20) − 1)w1(t)(1 − w4(t)) − 1 + w1(t) −w4(t)w1(t) − (1 − w3(t))(1 − w2(t)) −(cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 − 1)w1(t)(1 − w4(t)) − w4(t) +( − 1)w3(t)(1 − w2(t)) − 1 + w3(t) (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (w3(t)(1 − w2(t)) +w1(t)(1 − w4(t))) −w2(t)w3(t) − (1 − w1(t))(1 − w4(t)) − 1)w3(t)(1 − w2(t)) − w2(t) (cid:21) (cid:21) (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 x1 x1 + y1 + ( (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 y1 x1 + y1 (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 +( + (cid:107)Ax(cid:107)1 [ w2(t)w3(t) − w1(t)(1 − w4(t)) + w4(t)w1(t) − w3(t)(1 − w2(t)) + w3(t)(1 − w2(t)) − w3(t) w2(t) + w1(t)(1 − w4(t)) − w1(t) w4(t)] . (w3(t)(1 − w2(t)) + w1(t)(1 − w4(t))) + (cid:20) −(cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 (cid:107)A2y(cid:107)1 (cid:20) (cid:107)Ay(cid:107)1 −(cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 w1(t)(1 − w4(t)) − w1(t)(1 − w4(t)) − w4(t) + x1 + y1 −w2(t) + x1 y1 x1 + y1 (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 + (cid:107)A2x(cid:107)1 (cid:107)Ax(cid:107)1 (cid:107)A2y(cid:107)1 (cid:107)Ay(cid:107)1 w3(t)(1 − w2(t)) − w3(t)(1 − w2(t)) (cid:21) w1(t)(1 − w4(t)) − w1(t)(1 − w4(t)) − 1 +w1(t) − w4(t)w1(t) − (1 − w3(t))(1 − w2(t)) (w3(t)(1 − w2(t)) +w1(t)(1 − w4(t))) − w2(t)w3(t) − (1 − w1(t))(1 − w4(t)) w3(t)(1 − w2(t)) − w3(t)(1 − w2(t)) − 1 + w3(t) (cid:21) Simplifying 2 d dt U (t) = + yields 2 d dt U (t) = x1 x1 + y1 [−2] + y1 x1 + y1 [−2] = −2 Again, since the set {t : m > 0} is of zero Lebesgue measure integrating both sides of d dt U (t) = −1 we have: 1 − 2T = U (T ) = U (0) − T. So U∗ = U (0) = 1 − T which is the desired result by (31). REFERENCES [1] C.-T. Lin, "Structural controllability," Automatic Control, IEEE Transactions on, vol. 19, no. 3, pp. 201–208, 1974. [2] I. Rajapakse, M. Groudine, and M. Mesbahi, "What can systems theory of networks offer to biology?" PLoS computational biology, vol. 8, no. 6, p. e1002543, 2012. [3] R. Srikant, The mathematics of Internet congestion control. Springer Science & Business Media, 2004. [4] E. Dinits, "Algorithm of solution to problem of maximum flow in network with power estimates," Doklady Akademii Nauk SSSR, vol. 194, no. 4, p. 754, 1970. [5] L. R. Ford and D. R. Fulkerson, "Maximal flow through a network," Canadian journal of Mathematics, vol. 8, no. 3, pp. 399–404, 1956. [6] A. V. Goldberg and R. E. Tarjan, "A new approach to the maximum-flow problem," Journal of the ACM (JACM), vol. 35, no. 4, pp. 921–940, 1988. [7] T. B. Crabill, D. Gross, and M. J. Magazine, "A classified bibliography of research on optimal design and control of queues," Operations Research, vol. 25, no. 2, pp. 219–232, 1977. [8] L. Tadj and G. Choudhury, "Optimal design and control of queues," Top, vol. 13, no. 2, pp. 359–412, 2005. 31 [9] C. H. Papadimitriou and J. N. Tsitsiklis, "The complexity of optimal queuing network control," Mathematics of Operations Research, vol. 24, no. 2, pp. 293–305, 1999. [10] J. Nino-Mora, "Dynamic allocation indices for restless projects and queueing admission control: a polyhedral approach," Mathematical programming, vol. 93, no. 3, pp. 361–413, 2002. [11] D. G. Luenberger, Introduction to dynamic systems. John Wiley & Sons New York, 1979. [12] Y.-Y. Liu, J.-J. Slotine, and A.-L. Barab´asi, "Controllability of complex networks," Nature, vol. 473, no. 7346, pp. 167–173, 2011. [13] I. Rajapakse, D. Scalzo, and M. Groudine, "Losing control: Cancer's catastrophic transition," Nucleus, vol. 2, no. 4, pp. 249–252, 2011. [14] J.-M. Dion, C. Commault, and J. Van Der Woude, "Generic properties and control of linear structured systems: a survey," Automatica, vol. 39, no. 7, pp. 1125–1144, 2003. [15] A. Gibbons, Algorithmic graph theory. Cambridge University Press, 1985. [16] B. Bollob´as, "Random graphs, volume 73 of cambridge studies in advanced mathematics," 2001. [17] A. Frieze and P. Melsted, "Maximum matchings in random bipartite graphs and the space utilization of cuckoo hash tables," Random Structures & Algorithms, vol. 41, no. 3, pp. 334–364, 2012. [18] J. Aronson, A. Frieze, and B. G. Pittel, "Maximum matchings in sparse random graphs: Karp-Sipser revisited," Random Structures and Algorithms, vol. 12, no. 2, pp. 111–177, 1998. [19] T. Tao and V. Vu, "Random matrices have simple spectrum," arXiv preprint arXiv:1412.1438, 2014. [20] T. Bohman and A. Frieze, "Karp-Sipser on random graphs with a fixed degree sequence," Combinatorics, Probability and Computing, vol. 20, no. 05, pp. 721–741, 2011. [21] P. Balister and S. Gerke, "Controllability and matchings in random bipartite graphs," Surveys in Combinatorics 2015, vol. 424, p. 119, 2015. [22] R. M. Karp and M. Sipser, "Maximum matching in sparse random graphs," in 2013 IEEE 54th Annual Symposium on Foundations of Computer Science. IEEE, 1981, pp. 364–375. [23] A. Olshevsky, "Minimal controllability problems," Control of Network Systems, IEEE Transactions on, vol. 1, no. 3, pp. 249–258, 2014. [24] C. Commault, J.-M. Dion, and J. W. van der Woude, "Characterization of generic properties of linear structured systems for efficient computations," Kybernetika, vol. 38, no. 5, pp. 503–520, 2002. [25] S. Assadi, S. Khanna, Y. Li, and V. M. Preciado, "Complexity of the minimum input selection problem for structural controllability," IFAC-PapersOnLine, vol. 48, no. 22, pp. 70–75, 2015. [26] C. Commault and J.-M. Dion, "The single-input minimal controllability problem for structured systems," Systems & Control Letters, vol. 80, pp. 50–55, 2015. [27] S. Pequito, S. Kar et al., "A framework for structural input/output and control configuration selection in large-scale systems," 2013. [28] N. J. Cowan, E. J. Chastain, D. A. Vilhena, J. S. Freudenberg, and C. T. Bergstrom, "Nodal dynamics, not degree distributions, determine the structural controllability of complex networks," PloS one, vol. 7, no. 6, p. e38398, 2012. [29] S. Micali and V. V. Vazirani, "An O(V 0.5E) algoithm for finding maximum matching in general graphs," in Foundations of Computer Science, 1980., 21st Annual Symposium on. IEEE, 1980, pp. 17–27. [30] R. Durrett, Random graph dynamics. Cambridge university press Cambridge, 2007, vol. 200, no. 7. [31] T. H. Cormen and C. Charles, "C. e, leiserson, and rl rivest, introduction to algorithms," 1990. [32] M. A. Van Duijn, E. P. Zeggelink, M. Huisman, F. N. Stokman, and F. W. Wasseur, "Evolution of sociology freshmen into a friendship network," Journal of Mathematical Sociology, vol. 27, no. 2-3, pp. 153–191, 2003. [33] D. J. Watts and S. H. Strogatz, "Collective dynamics of small-worldnetworks," nature, vol. 393, no. 6684, pp. 440–442, 1998. [34] J. Leskovec, J. Kleinberg, and C. Faloutsos, "Graph evolution: Densification and shrinking diameters," ACM Transactions on Knowledge Discovery from Data (TKDD), vol. 1, no. 1, p. 2, 2007. [35] L. A. Adamic and N. Glance, "The political blogosphere and the 2004 us election: divided they blog," in Proceedings of the 3rd international workshop on Link discovery. ACM, 2005, pp. 36–43. [36] R. Milo, S. Shen-Orr, S. Itzkovitz, N. Kashtan, D. Chklovskii, and U. Alon, "Network motifs: simple building blocks of complex networks," Science, vol. 298, no. 5594, pp. 824–827, 2002. [37] J. Ruths and D. Ruths, "Control profiles of complex networks," Science, vol. 343, no. 6177, pp. 1373–1376, 2014. [38] W. T.Rhee, "A concentration inequality for maximum matching size in random graphs," Optimization, vol. 21, no. 5, pp. 797–803, 1990. 32 [39] T. G. Kurtz, "Solutions of ordinary differential equations as limits of pure jump Markov processes," Journal of applied Probability, vol. 7, no. 1, pp. 49–58, 1970.
1702.05678
1
1702
2017-02-19T00:03:09
An Adaptivity Hierarchy Theorem for Property Testing
[ "cs.DS", "cs.LG" ]
Adaptivity is known to play a crucial role in property testing. In particular, there exist properties for which there is an exponential gap between the power of \emph{adaptive} testing algorithms, wherein each query may be determined by the answers received to prior queries, and their \emph{non-adaptive} counterparts, in which all queries are independent of answers obtained from previous queries. In this work, we investigate the role of adaptivity in property testing at a finer level. We first quantify the degree of adaptivity of a testing algorithm by considering the number of "rounds of adaptivity" it uses. More accurately, we say that a tester is $k$-(round) adaptive if it makes queries in $k+1$ rounds, where the queries in the $i$'th round may depend on the answers obtained in the previous $i-1$ rounds. Then, we ask the following question: Does the power of testing algorithms smoothly grow with the number of rounds of adaptivity? We provide a positive answer to the foregoing question by proving an adaptivity hierarchy theorem for property testing. Specifically, our main result shows that for every $n\in \mathbb{N}$ and $0 \le k \le n^{0.99}$ there exists a property $\mathcal{P}_{n,k}$ of functions for which (1) there exists a $k$-adaptive tester for $\mathcal{P}_{n,k}$ with query complexity $\tilde{O}(k)$, yet (2) any $(k-1)$-adaptive tester for $\mathcal{P}_{n,k}$ must make $\Omega(n)$ queries. In addition, we show that such a qualitative adaptivity hierarchy can be witnessed for testing natural properties of graphs.
cs.DS
cs
An Adaptivity Hierarchy Theorem for Property Testing∗ Clément L. Canonne† Tom Gur‡ September 22, 2018 Abstract Adaptivity is known to play a crucial role in property testing. In particular, there exist properties for which there is an exponential gap between the power of adaptive testing algo- rithms, wherein each query may be determined by the answers received to prior queries, and their non-adaptive counterparts, in which all queries are independent of answers obtained from previous queries. In this work, we investigate the role of adaptivity in property testing at a finer level. We first quantify the degree of adaptivity of a testing algorithm by considering the number of "rounds of adaptivity" it uses. More accurately, we say that a tester is k-(round) adaptive if it makes queries in k + 1 rounds, where the queries in the i'th round may depend on the answers obtained in the previous i − 1 rounds. Then, we ask the following question: Does the power of testing algorithms smoothly grow with the number of rounds of adaptivity? We provide a positive answer to the foregoing question by proving an adaptivity hierarchy theorem for property testing. Specifically, our main result shows that for every n ∈ N and 0 ≤ k ≤ n0.99 there exists a property Pn,k of functions for which (1) there exists a k-adaptive tester for Pn,k with query complexity O(k), yet (2) any (k − 1)-adaptive tester for Pn,k must make Ω(n) queries. In addition, we show that such a qualitative adaptivity hierarchy can be witnessed for testing natural properties of graphs. 7 1 0 2 b e F 9 1 ] S D . s c [ 1 v 8 7 6 5 0 . 2 0 7 1 : v i X r a ∗This work previously appeared as "Fifty Shades of Adaptivity (in Property Testing)." †Columbia University. Email: [email protected]. Research supported by NSF grants CCF-1115703 and NSF CCF-1319788. ‡Weizmann Institute. Email: [email protected]. Research partially supported by ISF grant 671/13. Contents 1 Introduction 1.1 Our Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Preliminaries 3 The Definition of Testers with Bounded Adaptivity 1 2 3 4 4 4 A Strong Adaptivity Hierarchy 5 6 4.1 High-Level Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.2 Decision Tree Zoo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Decision Tree Hierarchy: Some Things Only Adaptivity Can Address . . . . . . . . . 8 4.4 Adaptivity Bounded Testers and Decision Trees: There and Back Again . . . . . . . 10 . . . . . . . . . . . . . 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.4.1 Preliminaries: Locally Testable and Decodable Codes 4.4.2 Transference Lemmas 5 An Adaptivity Hierarchy with respect to a Natural Property 13 . . . . . . . . . . . . . . . . . . 14 5.1 Cycle Freeness in the Bounded Degree Graph Model 5.2 Lower Bounds for Round-Adaptive Testers . . . . . . . . . . . . . . . . . . . . . . . . 15 6 Some Miscellaneous Remarks 18 6.1 On Simulating k Rounds With Fewer . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.2 On the Connection with Communication Complexity . . . . . . . . . . . . . . . . . . 19 6.3 On the Relative Power of Round- and Tail-Adaptive Testers . . . . . . . . . . . . . . 21 1 Introduction The study of property testing, initiated by Rubinfeld and Sudan [RS96] and Goldreich, Goldwasser and Ron [GGR98], has attracted significant attention in the last two decades (see, e.g., recent books [Gol10, Gol17, BY17] and surveys [Ron08, Ron09, Can15]). Loosely speaking, property testers are highly efficient randomized algorithms (typically running in sublinear time) that solve approximate decision problems, while only inspecting a tiny fraction of their inputs. More accu- rately, an ε-tester T for property P is a randomized algorithm that, given query access to an input x, decides whether x ∈ P or x is ε-far (say, in Hamming distance) from P. The query complexity of T is then the number of queries it makes to x. In general, a testing algorithm may select its queries adaptively such that the i'th query is deter- mined by the answers to the previous i− 1 queries, in which case it is said to be an adaptive tester. However, in many natural cases, testers may actually determine their queries solely based on their randomness (and input length), without any dependency on answers to previous queries; a tester that satisfies this condition is called a non-adaptive tester. A natural question, which commonly arises in query-based models, is whether the ability to make adaptive queries can significantly affect the query complexity. Adaptive queries can be easily emulated at the cost of a large blowup in query complexity (exponential in the number of queries). More accurately, any q-query adaptive tester for a property of objects represented by functions f : D → R can be emulated by an Rq-query non-adaptive tester (see e.g., [Gol17, Section 1.5]). While for certain types of properties and models -- e.g., linear properties [BHR05] and properties in the dense graph model [GT03] -- one has better emulations which come with little or no overhead, such efficient emulations cannot exist for all properties. As was shown by Raskhodnikova and Smith [RS06], in the bounded-degree graph model [GR00] there is a large chasm between the adaptive and non-adaptive query complexities of testing many natural graph properties. In particular, any property over bounded-degree graphs with n vertices, which is not determined by the vertex degree distribution,1 requires Ω(√n) queries to test non-adaptively, whereas many such properties (e.g., triangle-freeness and connectivity) have ε-testers with query complexity poly(1/ε). In this work, we investigate the role of adaptivity in property testing at a finer level. Rather than considering the extreme cases of fully adaptive testers versus completely non-adaptive testers, we consider testers with various levels of restricted adaptivity and ask the following question: Can the power of testers gradually grow with the "amount" of adaptivity they are allowed to use? Besides the sheer theoretical interest of understanding the role of adaptivity in property testing, a motivation for this question comes from the constraints that come with adaptive algorithms, which may counterbalance the apparent gain in efficiency. Indeed, non-adaptive algorithms (or at least those which only use a small number of adaptive "stages") may be preferred in practice to their adaptive counterparts, in spite of the larger number of queries they make. The reason for this preference is the significant gains obtained by being able to make many queries in parallel: when each query is an experiment which, while relatively cheap by itself, may take several hours, assessing the trade-off between rounds of adaptivity and total number of queries becomes crucial. 1Loosely speaking, a property P of bounded-degree graphs is not determined by the vertex degree distribution if there exist two graphs, G1 ∈ P and G2 that is "far" from P, such that the vertices of G1 and G2 have the same degrees. 1 An archetypal example where such considerations prevail is the (different) setting of group testing (see e.g. [DH00, Section 1.2]). To answer the foregoing question, we shall first need to give a precise definition for the "amount" of adaptivity that a tester uses. To this end, it is natural to consider the number of "rounds of adaptivity" used by a tester.2 More precisely, we say that a tester is k-round-adaptive if it generates and makes queries in k + 1 rounds, where in the i'th round the tester queries a set of locations Qi that may depend on the answers to queries in Q0, . . . , Qi−1, obtained in previous rounds. We will quantify the "amount" of adaptivity that a tester uses by the number of rounds of adaptivity that it uses. Equipped with the notion of round adaptivity, we can proceed to present our results. 1.1 Our Results Our main result provides a positive answer to the foregoing question by showing an adaptivity hierarchy theorem for property testing; that is, we show a family of properties {Pk}k such that for every k, the property Pk is "easy" for k-adaptive testers and "hard" for (k − 1)-adaptive testers. Theorem 1.1 (Informally stated (see Theorem 4.1)). For every n ∈ N and 0 ≤ k ≤ n0.99 there is a property Pn,k of strings over Fn such that: 1. there exists a k-round-adaptive tester for Pn,k with query complexity O(k), yet 2. any (k − 1)-round-adaptive tester for Pn,k must make Ω(n) queries. The above theorem relies on an arguably contrived family of property, which was specifically tailored towards maximizing the separations; hence, one may wonder whether such strong separa- tions also hold for more natural properties. As we show below, this is indeed the case: namely, we establish another adaptivity hierarchy theorem that, albeit weaker than Theorem 1.1, applies to the well-studied natural problem of testing k-cycle freeness in the bounded-degree graph model (see Section 5.1 for definitions). Theorem 1.2. Let k ∈ N be a constant. Then, (i) there exists a k-round-adaptive tester with query complexity O(1/ε) for (2k + 1)-cycle freeness in the bounded-degree graph model; yet (ii) any (k−1)-round-adaptive tester for (2k +1)-cycle freeness in the bounded-degree graph model must make Ω(√n) queries, where n is the number of vertices in the graph. We conclude this section by posing two open problems that naturally arise from our work. Open Problem 1 (One property to rule them all). Does there exist an adaptivity hierarchy with respect to a single property? That is, for any m and all sufficiently large n, is there a property P of elements of size n, and q1 > . . . > qm (m "levels" of hierarchy) such that for every k ∈ [m] there exists a k-adaptive tester for P with query complexity qk, yet every (k − 1)-adaptive tester must make ω(qk) queries to test P? Open Problem 2 (Au naturel is just as good). Does there exist a family of natural properties which exhibits an adaptivity hierarchy with separations as strong as in Theorem 1.1? 2We also consider an alternative notion of tail adaptivity, which roughly speaking refers to testers that first make a large number of non-adaptive queries and subsequently make a bounded number of adaptive queries. See Section 3 for details regarding how these two notions relate. 2 1.2 Previous Work As previously mentioned, the role of adaptivity in property testing has been the focus of several works before. It is well known that for any property of Boolean functions, there exists at most an exponential gap between adaptive and non-adaptive testers: any (adaptive) q-query testing algorithm for a property P of n-variate Boolean functions can be simulated by a non-adaptive tester with query complexity 2q − 1. Further, such gaps are known to exist for some natural properties, such as read-once width-2 OBDDs [RT12, BMW11] and signed majorities [MORS09, RS13] (importantly, there also exist cases where adaptivity is known not to help [BLR93, BHR05]). Another prominent example of a class of Boolean functions where adaptivity is known to help is that of k-juntas [Bla09, Bla08, STW15, CST+17], which can be tested adaptively with O(k) queries, Of course, the Boolean function setting is not the only one: in the dense graph model, it is known that while adaptivity can help [GR11], it will be at most by a quadratic factor [AFKS00, GT03]: yet for which the non-adaptive query complexity is Θ(cid:16)k3/2(cid:17). that is, every graph property testable (adaptively) with q queries has an O(cid:0)q2(cid:1)-query non-adaptive tester. This is no longer the case in the bounded-degree model, however; where Raskhodnikova and Smith showed that there exist many properties which can be tested adaptively with a constant number of queries, but for which any non-adaptive tester must have query complexity Ω(√n) [RS06]. However, all these results, even when they establish cases where adaptivity does help, leave open the question of how much adaptivity is needed for this to happen. In particular, for the case of properties of Boolean functions, many known adaptive testers which outperforms their non-adaptive counterpart do so, at some level, by conducting a binary search of some sort (see, e.g., [Bla09, RT12, RS13]) and thus comes inherently with a logarithmic numbers of "adaptive rounds." Our proof of Theorem 1.1 relies on a connection between the property testing and linear decision tree models. Although many of the ingredients we use are new, the connection itself is not and was first observed in [Tel14] (see also [BCK14] for a slightly different connection between property testing and parity decision trees). Adaptivity in other settings. We remark that the notion of round complexity in communica- tion complexity and interactive proof systems is somewhat analogous to that of round adaptivity, since in those models each round of communication or interaction allows the parties to adapt their strategies. Moreover, a round complexity hierarchy is known for communication complex- ity [NW93] and interactive proofs of proximity [GR17]. Finally, we also mention that the role of the number of adaptive measurements used by sparse recovery algorithms was shown to be very significant [IPW11]. Organization In Section 2 we provide the preliminaries required for the technical sections. In Section 3 we provide a precise definition for testers with bounded adaptivity. In Section 4 we prove our main result, which is a strong adaptivity hierarchy theorem for a property of functions. In Section 5 we prove an adaptivity hierarchy theorem with respect to a natural property of graphs. Finally, in Section 6 we discuss adaptivity round reductions, as well as a connection to communication complexity, and the relation between round and tail adaptivity. 3 2 Preliminaries We begin with standard notations: • We denote the relative Hamming distance, over alphabet Σ, between two vectors x ∈ Σn and y ∈ Σn by dist(x, y) := {xi 6= yi : i ∈ [n]} /n. If dist(x, y) ≤ ε, we say that x is ε-close to y, and otherwise we say that x is ε-far from y. Similarly, we denote the relative distance of x from a non-empty set S ⊆ Σn by dist(x, S) := miny∈S dist(x, y). If dist(x, S) ≤ ε, we say that x is ε-close to S, and otherwise we say that x is ε-far from S. • We denote by Ax(y) the output of algorithm A given direct access to input y and oracle access to string x. Given two interactive machines A and B, we denote by (Ax, B(y))(z) the output of A when interacting with B, where A (respectively, B) is given oracle access to x (respectively, direct access to y) and both parties have direct access to z. Throughout this work, probabilistic expressions that involve a randomized algorithm A are taken over the inner randomness of A (e.g., when we write Pr[Ax(y) = z], the probability is taken over the coin tosses of A). • We use the notations O(f ), Ω(f ) to hide polylogarithmic dependencies on the argument, i.e. for expressions of the form O(f logc f ) and Ω(f logc f ) (for some absolute constant c). Finally, all our logarithms are in base 2. Integrality. For simplicity of notation, we hereafter use the convention that all (relevant) integer parameters that are stated as real numbers are implicitly rounded to the closest integer. Uniformity. To facilitate notation, throughout this work we define all algorithms non-uniformly; that is, we fix an integer n ∈ N and restrict the algorithms to inputs of length n. Despite fixing n, we view it as a generic parameter and allow ourselves to write asymptotic expressions such as O(n). We remark that while our results are proved in terms of non-uniform algorithms, they can be extended to the uniform setting in a straightforward manner. 3 The Definition of Testers with Bounded Adaptivity In this section, we provide a formal abstraction that captures the notion of bounded adaptivity within the framework of property testing. We define two notions of bounded adaptivity: (1) round- adaptivity, which refers to algorithms that are allowed to make a bounded number of "batches" of queries, where the queries in each batch may depend on the answers to previous batches; (2) tail- adaptivity, which refers to algorithms that first make a large number of non-adaptive queries and subsequently make a bounded number of adaptive queries. We remark that while tail-adaptivity can be easily emulated via round-adaptivity, the converse Indeed, in Section 6.3 we show that round-adaptive testers can be much more does not hold. powerful than tail-adaptive testers. Nonetheless, our lower bounds hold for the stronger round- adaptivity notion, whereas out upper bounds hold for the more restrictive tail-adaptivity. Definition 3.1 (Round-Adaptive Testing Algorithms). Let Ω be a domain of cardinality n, and let k, q ≤ n. A randomized algorithm is said to be a (k, q)-round-adaptive tester for a property P ⊆ 2Ω, if, on proximity parameter ε ∈ (0, 1] and granted query access to a function f : Ω → {0, 1}, the following holds. 4 (i) Query Generation: The algorithm proceeds in k + 1 rounds, such that at round ℓ ≥ 0, it produces a set of queries Qℓ := {x(ℓ),1, . . . , x(ℓ),Qℓ} ⊆ Ω (possibly empty), based on its own internal randomness and the answers to the previous sets of queries Q0, . . . , Qℓ−1, and receives f (Qℓ) = {f (x(ℓ),1), . . . , f (x(ℓ),Qℓ)}; (ii) Completeness: If f ∈ P, then the algorithm outputs accept with probability at least 2/3; (iii) Soundness: If dist(f,P) > ε, then the algorithm outputs reject with probability at least 2/3. The query complexity q of the tester is the total number of queries made to f , i.e., q = Pk ℓ=0 Qℓ. If the algorithm returns accept with probability one whenever f ∈ P, it is said to have one-sided error (otherwise, it has two-sided error). We will sometimes refer to a tester with respect to proximity parameter ε as an ε-tester. Remark 3.2 (On amplification). We note that, as usual in property testing, the probability of success can be amplified by repetition to any 1 − δ, at the price of an O(log(1/δ)) factor in the query complexity. Crucially, this can be done with no increase in the number of adaptive rounds: while repetition would naïvely multiply both q and k by this factor, one can avoid the latter by running the O(log(1/δ)) independent copies of the algorithm in parallel, instead of sequentially. Definition 3.3 (Tail-Adaptive Testing Algorithms). Let Ω be a domain of cardinality n, and let k, q ≤ n. A randomized algorithm is said to be a (k, q)-tail-adaptive tester for a property P ⊆ 2Ω, if, on proximity parameter ε ∈ (0, 1], error parameter δ ∈ (0, 1], and granted query access to a function f : Ω → {0, 1}, the following holds. (i) Query Generation: The algorithm proceeds in k + 1 rounds, such that in the first round, it produces a set of queries Q := {x(0),1, . . . , x(0),Q} ⊆ Ω (possibly empty), based on its own internal randomness; and receives f (Q) = {f (x(0),1), . . . , f (x(0),Q)}; then it makes, over the next k rounds, k adaptive queries to f , denoted x(1), . . . , x(k); (ii) Completeness: If f ∈ P, then the algorithm outputs accept with probability at least 1 − δ; (iii) Soundness: If dist(f,P) > ε, then the algorithm outputs reject with probability at least 1− δ. The query complexity q of the tester is the total number of queries made to f , i.e., q = Q + k. If the algorithm returns accept with probability one whenever f ∈ P, it is said to be one-sided (otherwise, it is two-sided). Remark 3.4 (On (lack of) amplification). Unlike the round-adaptive algorithms, tail-adaptive test- ing algorithms do not enjoy a simple success amplification procedure which would leave unchanged the adaptivity parameter, only affecting the query complexity. This is the reason why the success probability δ is explicitly mentioned in Definition 3.3. 4 A Strong Adaptivity Hierarchy In this section we prove the adaptivity hierarchy theorem, which shows that, loosely speaking, up to a nearly linear threshold, each additional round of adaptivity can significantly augment the power of testing algorithms. Theorem 4.1 (Adaptivity Hierarchy Theorem). Fix any α ∈ (0, 1). There exists a constant β ∈ (0, 1) such that, for every n ∈ N, the following holds. For every integer 0 ≤ k ≤ nβ, there exists a property Pk ⊆ Fn1+α such that, for any constant ε ∈ (0, 1], n 5 (i) there exists a (k, O(k))-round-adaptive (one-sided) tester for Pk; yet (ii) any (k − 1, q)-round-adaptive (two-sided) tester for Pk must satisfy q = Ω(n). We remark that, in fact, the algorithm shown in the first item of Theorem 4.1 also gives an upper bound for the more restricted model of tail adaptivity. Specifically, for every k there also exists an (O(k), O(k))-tail-adaptive (one-sided) tester for Pk. Since a (k − 1, q)-round-adaptive lower bound implies a (k−1, q)-tail-adaptive lower bound (see discussion in Section 3), this implies an adaptivity hierarchy (albeit slightly weaker than in Theorem 4.1) with respect to tail-adaptive testers. Hereafter we assume, without loss of generality,3 that n is a prime number, and consider Fn, the field of order n. We will consider the following sequence of "k-iterated address" functions (fk)k≥0 from Fn n to {0, 1}, which will in turn lead to the definition of the properties (Pk)k≥0 that we use to show the hierarchy theorem. Loosely speaking, fk receives a vector x of n pointers (indices in [n]) and indicates whether when jumping from pointer to pointer k times, starting from an arbitrarily predetermined pointer, we reach a location in which x takes an even value. To formally define the foregoing functions, first consider g : Fn xa+1; that is, g returns the coordinate of x ∈ Fn we define the iterated versions of g, g0, . . . , gn, . . . : Fn n × Fn → Fn given by g(x, a) = n "pointed to" by a ∈ {0, . . . , n− 1}. Based on this, n → Fn, as g0(x) = g(x, 0) gk(x) = g(x, gk−1(x)). (k ≥ 1) Finally, we define the k-iterated address function fk : Fn n → Fn by fk(x) = 1{gk(x) even} =(1 0 if gk(x) even otherwise. (For instance, f0(x) = 1 if and only if x1 is even; and f1(x) = 1 if and only if the coordinate of x pointed to by x1, that is xx1+1, is even.) We proceed to describe the outline of the proof of Theorem 4.1. 4.1 High-Level Overview Broadly speaking, our roadmap for proving Theorem 4.1 consists of two main steps: 1. We first consider the adaptivity hierarchy question in the setting of randomized decision tree (DT) complexity (see Section 4.2). We can view a randomized DT for computing a function f as a probabilisitic algorithm that is given query access to an input x and is required to output f (x) with high probability. Adapting the definition of round adaptivity (Definition 3.1) in the natural way to decision trees, we will prove the randomized DT analogue of our adaptivity hierarchy theorem, using the foregoing family of address functions (fk)k≥0. Namely, we prove that for any k ≥ 0 with k = o(n), it holds that (i) fk can be computed by an algorithm making k + 1 queries, in k adaptive rounds; but (ii) any algorithm using only k − 1 rounds of adaptivity must make Ω(n) queries. 2. We then show a bidirectional connection between adaptivity-bounded randomized DT and property testers, which extends the connection observed by Tell [Tel14]. This allows us to "lift" the DT adaptivity hierarchy theorem to property testing. Specifically, we provide two 3If n is not prime, we choose a prime p such that n ≤ p ≤ 2p, and use standard padding techniques. 6 blackbox reductions between the DT problem of computing function f and property testing for a related property Pf , which preserve both the number of adaptive rounds and (roughly) the number of queries. We remark these reductions strongly rely on high-rate codes that exhibit both strong local testability and relaxed local decodability. The caveat with the above is that to "lift" DT lower bounds to testing algorithms via our methodology, we actually need to show lower bounds on a stronger model of DT (this stems from the reductions of the second item, in which we will encode the input via linear codes, requiring the DT algorithm to compute coordinates of this encoding). Hence, we will actually work in the linear decision tree (LDT) model, wherein the algorithm is allowed to query any linear combination (over Fn) of the coordinates, instead of only querying individual coordinates. (We note that in the case of F2, this corresponds to the parity decision tree model.) That is, we will proceed as follows: 1. (L)DT hierarchy: show that for any k ≥ 0, the function fk (i) can be computed by an efficient (k, O(k))-round-adaptive (deterministic) DT algorithm, but (ii) does not admit any (k − 1, o(n))-round-adaptive (randomized, two-sided) LDT algorithm; 2. Transference lemmas: Show that for any function f : Fn n → Fn, there exists a property Cf ⊆ F m(n) n such that, for any k ≥ 0, (a) a (k, q)-round-adaptive testing algorithm for Cf implies a (k, q)-round-adaptive LDT (b) a (k, q)-round-adaptive DT algorithm for f implies a (k, O(q))-round-adaptive testing algorithm for f (Lemma 4.10). algorithm for Cf (Lemma 4.11). Combining the items above will directly imply our hierarchy theorem for property testing (Theorem 4.1): Proof of Theorem 4.1. The upper bound (i) follows immediately from Claim 4.3 and Lemma 4.11, while combining Lemma 4.4 and Lemma 4.10 establishes the lower bound (ii). In Section 4.2, we define the decision tree models Organization for the rest of the section. and complexities that we shall need. Then, in Section 4.3, we prove the adaptivity hierarchy theorem for randomized (linear) decision trees. Finally, in Section 4.4 we prove the transference lemmas that allow us to lift the foregoing hierarchy theorem to the property testing framework. 4.2 Decision Tree Zoo We shall need to extend the definitions of several different types of decision tree algorithms (see [BdW02] for an extensive survey of decision tree complexity) to the setting of bounded adaptivity. Recall that a deterministic decision tree is a model of computation for computing a function f : Ωn → Ω. The decision tree is a rooted ordered Ω-ary tree. Each internal vertex of the tree is labeled with a value i ∈ {1, . . . , n} and the leaves of the tree are labeled with the elements in Ω. Given an input x ∈ Ωn, the decision tree is recursively evaluated by choosing to recurse on the i'th subtree in the j'th level if and only if xj = i. Once a leaf is reached, we output the label of that leaf and halt. Equivalently, we can view deterministic decision trees as algorithms that get oracle access to an input x ∈ Ωn, then adaptively make queries to x, to the end of computing f (x). (Note that the j'th query corresponds to the j'th layer of the corresponding decision tree, and that the different 7 vertices in the j'th layer represent the choices of the next queries, with respect to the answers obtained for previous queries). We define the deterministic decision tree complexity of a function f to be the minimal number of queries a deterministic decision tree algorithm needs to make to compute f in the worst case.4 Taking the algorithmic perspective, we define k-round-adaptive deterministic decision tree al- gorithms as algorithms that generate their queries in k rounds, where queries in each round may depend on queries from previous rounds. The extension of the foregoing definition to randomized decision tree algorithms is done in the natural way, by allowing the algorithm to toss random coins and succeed with high probability (say, 2/3) in computing f (x). Finally, we shall also extend the definition to linear decision trees, which are decision trees algorithms wherein each query is a linear combination of the elements of the domain. We remark that linear decision trees can be thought of as generalizing both parity decision trees and algebraic query complexity algorithms [AW08]. More accurately, the aforementioned notions are defined below. We provide the definition of the most general model and derive the more restricted models as special cases. Definition 4.2 (Round-Adaptive Decision Tree Algorithms). Let F be a finite field of cardinality n, and let k, q ≤ n. A (randomized) algorithm D is said to be a (k, q)-round-adaptive (linear) decision tree algorithm for computing a function f : Fn → F if, granted query access to a string x ∈ Fn, the following holds. (i) Query Generation: The algorithm proceeds in k + 1 rounds, such that at round ℓ ≥ 0, it produces a set of (linear) queries Qℓ := {Lℓ,1, . . . , Lℓ,Qℓ}, where Lℓ,j ∈ Fn specifies a linear combination, based on its internal randomness and the answers to the previous sets of queries Q0, . . . , Qℓ−1, and receives the answers hLℓ,1, xi, . . . ,hLℓ,Qℓ, xi. in all k rounds; that is, Pr[Dx = f (x)] ≥ 2/3. (ii) Computation: The algorithm computes f (x) with high probability using the answers it received The query complexity q of the tester is the total number of (linear) queries made to f , i.e., q = Pk ℓ=0 Qℓ. The randomized (k, q)-round-adaptive linear decision tree complexity of a function f , denoted R⊕k (f ), is the minimal query complexity for a (k, q)-round-adaptive randomized linear decision tree algorithm that computes f . If for all ℓ ∈ [k + 1] and j ∈ [Qℓ] the linear combination Lℓ,j only includes a single element (i.e., Lℓ,j only has a single non-zero entry), we say that D is a randomized (k, q)-round-adaptive decision tree algorithm complexity, and denote its corresponding complexity by Rk(f ). If, in addition, the algorithm does not toss any random coins and succeeds with probability 1, we say that D is a deterministic (k, q)-round-adaptive decision tree algorithm complexity, and denote its corresponding complexity by Dk(f ). 4.3 Decision Tree Hierarchy: Some Things Only Adaptivity Can Address We first establish the upper bound part of our adaptivity hierarchy theorem for DT, which follows immediately from the construction. Claim 4.3. For every k ≥ 0, there exists a (k, k + 1)-round-adaptive (deterministic) DT algorithm which computes fk; that is, Dk(fk) ≤ k + 1. 4We remark that this definition corresponds to the depth the of decision tree, and not to the number of vertices or edges in the tree. 8 Proof. The algorithm is straightforward: on input x ∈ Fn n, it sequentially queries x1 = g0(x), xg0(x)+1 = g1(x), . . . , xgk−1(x)+1 = gk(x); and returns 1 if gk(x) is even, and 0 otherwise. By definition of fk, this always correctly computes the function, is deterministic, and clearly satisfies the definition of a (k, k + 1)-round-adaptive DT algorithm. We proceed to show the lower bound part of our adaptivity hierarchy theorem for DT, which is proven via a reduction from communication complexity. Lemma 4.4. There exists an absolute constant c > 0 such that the following holds. For every , there is no (k, o(n/(k2 log n)))-round-adaptive (randomized) LDT algorithm log n(cid:17)1/3 0 ≤ k ≤ c(cid:16) n which computes fk+1; that is, R⊕k (fk+1) = Ω(cid:0)n/(k2 log n)(cid:1). Proof. We will reduce the computation of fk+1 (in k rounds of adaptivity) to a related k-round two- party randomized communication complexity problem, the "pointer-following" problem introduced by Papadimitriou and Sipser [PS82], and conclude by invoking the lower bound of Nisan and Wigderson [NW93] on this problem. This communication complexity problem between two computationally unbounded players, Al- ice and Bob, is defined as follows. Let VA and VB be two disjoint sets of cardinality n/2, and let v0 ∈ VA be a fixed element known to both players. The input is a pair of functions (χA, χB), where χA : VA → VB and χB : VB → VA. Alice and Bob are given χA and χB respectively, as well as a common random string, and their goal is to compute πk(χA, χB) := χ(k)(v0) with high probability, where χ(ℓ) is the ℓ-iterate of the function χ: χ : VA ∪ VB → VA ∪ VB v 7→ (χA(v) χB(v) v ∈ VA v ∈ VB. (In other terms, one can see the communication problem as Alice and Bob sharing the edges of a bipartite directed graph where each node has out-degree exactly one, and the goal is to find at which vertex the path of length k starting at a prespecified vertex v0, on Alice's side, ends.) We will rely on the following lower bound on the k-round, randomized (public-coin) version of this problem. Theorem 4.5 ([NW93], rephrased). Any k-round randomized communication protocol for the "pointer-following" problem, in which Bob sends the first message, must have total communica- tion complexity Ω(cid:16) n least 2/3. k2 − k log n(cid:17), even to only compute a single bit of πk(χA, χB) with probability at k2(cid:17). We remark that the fact that , this lower bound is Ω(cid:16) n log n(cid:17)1/3 Note that as long as k ≪ (cid:16) n the lower bound still holds even when only a single bit of the answer is to be computed will be crucial for us, as our goal is to reduce the communication complexity problem of "pointer-following" to computing the Boolean function fk+1 in the randomized decision tree model. Let A be any (k, q)-round-adaptive (randomized) LDT algorithm computing fk+1. Writing 2 −1}, fix a bijection between V := VA∪ VB (of size n) and VA = {v0, . . . , v n Fn mapping v0 to 1, so that we identify V with Fn. On input (χA, χB), Alice and Bob implicitly define the element x ∈ Fn 2 +1 = χB(u0), n by x1 = χA(v0), x2 = χA(v1), . . . , x n 2 −1} and VB = {u0, . . . , u n 2 −1) and x n = χA(v n 2 9 2 −1). From this, we get that πk+2(χA, χB) = gk+1(x), recalling 2 +2 = χA(u1), . . . , xn = χA(u n x n that gk(x) = g(x, gk−1(x)) is recursively defined for k ≥ 1, and g0(x) = x1. Hence deciding whether πk+2(χA, χB) is even is exactly equivalent to computing fk+1(x). Alice and Bob can then simulate the execution of A as follows. Without loss of generality, assume it is Alice's turn to speak. To answer a query of the form φS(x) = Pi∈S xi, she computes Pi∈S∩VA xi and sends it to Bob; on his side, Bob computes Pi∈S∩VB xi, and receiving Alice's message can then recover the value φS(x) and feed it to the algorithm. (In the next round, when sending his side of the (new) queries to Alice, Bob will also send this value φS(x), to make sure that both sides know the answers to all queries so far.) Since all queries of a given adaptive round of A can be prepared and sent in parallel (costing O(log n) bits of communication per query), this simulation can be performed in k + 1 rounds (as many as A takes) with communication complexity O(q log). At the end, whichever of Alice and Bob received the latest message holds the answer (to "is πk+1(χA, χB) an even node?"), which by assumption on A is correct with probability at least 2/3. Alice and Bob then use an extra round of communication to broadcast the answer to the other party, bringing the total number of rounds to k + 2. But by Theorem 4.5, computing this bit of πk+2(χA, χB) with only k + 2 rounds of com- munication (Bob speaking first) requires Ω(cid:16) n q = Ω(cid:16) k2 log n(cid:17). n k2(cid:17) bits of communication, and so we must have 4.4 Adaptivity Bounded Testers and Decision Trees: There and Back Again In this section we show how to reduce problems in the adaptivity bounded property testing model to problems in the adaptivity bounded (linear) decision tree model, and vice versa. We begin in Section 4.4.1, by presenting the required preliminaries regarding error-correction codes. Then, in Section 4.4.2, we prove the "transference lemmas" between these models. 4.4.1 Preliminaries: Locally Testable and Decodable Codes Let k, n ∈ N. A code over alphabet Σ with distance d is a function C : Σk → Σn that maps messages to codewords such that the distance between any two codewords is at least d = d(n). If d = Ω(n), C is said to have linear distance. If Σ = {0, 1}, we say that C is a binary code. If C is a linear map, we say that it is a linear code. The relative distance of C, denoted by δ(C), is d/n, and its rate is k/n. When it is clear from the context, we shall sometime abuse notation and refer to the code C as the set of all codewords {C(x)}x∈Σk . Following the discussion in the introduction, we define locally testable codes and locally decodable codes as follows. Definition 4.6 (Locally Testable Codes). A code C : Σk → Σn is a locally testable code (LTC) if there exists a probabilistic algorithm (tester) T that makes O(1) queries to a purported codeword w ∈ Σn and satisfies: 1. Completeness: For any codeword w of C it holds that PrT [T w = 1] ≥ 2/3. 2. Strong Soundness: For all w ∈ Σn, Pr T [T w = 0] ≥ poly(cid:0) dist(w, C)(cid:1). Definition 4.7 (Locally Decodable Codes). A code C : Σk → Σn is a locally decodable code (LDC) if there exists a constant δradius ∈ (0, δ(C)/2) and a probabilistic algorithm (decoder) D that, given 10 oracle access to w ∈ Σn and direct access to index i ∈ [k], satisfies the following condition: For any i ∈ [k] and w ∈ Σn that is δradius-close to a codeword C(x) it holds that Pr[Dw(i) = xi] ≥ 2/3. The query complexity of a LDC is the number of queries made by its decoder. We shall also need the notion of relaxed-LDCs (introduced in [BGH+06]). Similarly to LDCs, these codes have decoders that make few queries to an input in attempt to decode a given location in the message. However, unlike LDCs, the relaxed decoders are allowed to output a special symbol that indicates that the decoder detected a corruption in the codeword and is unable to decode this location. Note that the decoder must still avoid errors (with high probability).5 Definition 4.8 (Relaxed-LDC). A code C : Σk → Σn is a relaxed-LDC if there exists a constant δradius ∈ (0, δ(C)/2) such that the following holds. 1. (Perfect) Completeness: For any i ∈ [k] and x ∈ Σk it holds that DC(x)(i) = xi. 2. Relaxed Soundness: For any i ∈ [k] and any w ∈ Σn that is δradius-close to a (unique) codeword C(x), it holds that Pr[Dw(i) ∈ {xi,⊥}] ≥ 2/3. There are a couple of efficient constructions of codes that are both relaxed-LDCs and LTCs (see [BGH+06, GGK15]). We shall need the construction in [GGK15], which has the best parameters for our set- ting.6 Theorem 4.9 (e.g., [GGK15, Theorem 1.1]). For every k ∈ N, α > 0, and finite field F there exists an F-linear code C : Fk → Fk1+α with linear distance, which is both a relaxed-LDC and a (one-sided error) LTC with query complexity poly(1/ε); furthermore, both testing and (relaxed) decoding procedures are non-adaptive. 4.4.2 Transference Lemmas Fix any α > 0. Let C : Fn following properties: n → Fm n be a code with constant relative distance δ(C) > 0, with the • linearity: for all i ∈ [m], there exists a set Si ⊆ [n] such that C(x)i = Pj∈Si xi for all x ∈ Fn • rate: m ≤ n1+α; • testability: C is a strong-LTC with one-sided error and non-adaptive tester; • decodability: C is a relaxed-LDC. n; We will rely on Theorem 4.9 for the existence of such codes. Before delving into the details, we briefly explain the reason for each of the points above. The linearity will be crucial to reduce to and from the LDT model: indeed, any coordinate of a codeword corresponds to a fixed linear combination of the coordinates of the message, which corresponds to a single LDT query on that particular linear combination. The rate bound is required since our lower bounds are in terms of 5The full definition of relaxed-LDCs, as defined in [BGH+06] includes an additional condition on the success rate of the decoder. Namely, for every w ∈ {0, 1}n that is δradius-close to a codeword C(x), and for at least a ρ fraction of the indices i ∈ [k], with probability at least 2/3 the decoder D outputs the i'th bit of x. That is, there exists a set Iw ⊆ [k] of size at least ρk such that for every i ∈ Iw it holds that Pr [Dw(i) = xi] ≥ 2/3. We omit this condition since it is irrelevant to our application, and remark that every relaxed-LDC that satisfies the first two conditions can also be modified to satisfy the third conditions (see [BGH+06, Lemmas 4.9 and 4.10]). 6Specifically, the codes in [GGK15] are meaningful for every value of the proximity parameter, whereas the codes in [BGH+06] require ε > 1/ polylog(k). 11 the dimension n and upper bounds in terms of the block-lengh m. Ideally, we would like m = O(n), to have a direct correspondence between the LDT and the property testing query complexities; however, this nearly-linear rate is the best known achievable for constant-query LTCs and relaxed- LDCs [GGK15]. The LTC property will be useful to us in the reduction from property testing to DT query complexity (where we will need to first check that our input is close to a codeword, in view of decoding the closest message during the reduction), where the strong testability (i.e., rejection with probability proportional to the distance from a valid codeword) will allow us do deal with arbitrarily small values of the proximity parameter. Similarly, we will rely on the (relaxed) LDC property in that same reduction, in order to obtain individual coordinates of the message, given query access to an input close to a codeword. We proceed to show the framework for reducing property testing to decision tree complexity and vice-versa. For a fixed function f : Fn n; and define the sets of codewords C := C(Fn of Cf . Specifically, we prove the following. Lemma 4.10 (LDT PT Reduction Lemma). Fix any f : Fn round-adaptive tester for Cf , then there is an (k, q)-round-adaptive LDT algorithm for f . Proof. Suppose there exists a (k, q)-round-adaptive tester T for Cf . On input x ∈ Fn n, we emulate the invocation of T , with respect to proximity parameter ε = δ(C), on the encoded input y := C(x) ∈ Fm n and output 1 if and only if T returns accept. To see why this is correct, observe that by definition, if f (x) = 1 then y ∈ Cf . However, if f (x) = 0, then for any y′ ∈ Cf such that y′ = C(x) we must have dist(y, y′) > ε, by the distance of our code. It remains to show that this simulation can be achieved efficiently, as claimed. To do so, we will rely on the fact that C is a linear code: whenever T queries yi, we can compute the set Si ⊆ [n] (which only depends on C, and not on x), and perform the LDT query Pj∈Si xj. The simulation clearly preserves the number of adaptive rounds as well, concluding the proof. Consider now testing the property Cf : we will reduce the LDT computation of f to the testing n → {0, 1}. If there exists an (k, q)- n) ⊆ Fm n → {0, 1}, consider the subset f−1(1) ⊆ Fn n , Cf := C(f−1(1)) = { C(x) : x ∈ Fn n, f (x) = 1 } ⊆ C. In our next lemma, we give a partial converse relating property testing and decision tree com- plexity, with some logarithmic overhead in the resulting query complexity. Lemma 4.11 (PT DT Reduction Lemma). Fix any f : Fn n → {0, 1}. If there exists an (k, q)- round-adaptive (randomized) DT algorithm for f , then there is a (k, O(q log q) + poly(1/ε))-round- adaptive tester for Cf . (Moreover, if the DT algorithm is always correct, then this tester is one- sided.) Proof. Fix k ≥ 0, and suppose there exists such a (k, q)-round-adaptive DT algorithm A for f . On input y ∈ Fm n and proximity parameter ε ∈ (0, 1], we would like to decode y to a message x ∈ Fn n and invoke the algorithm on x to determine if f (x) = 1; more precisely, we wish to invoke the DT algorithm while simulating each query to x by locally decoding y using O(1) queries. The issue, however, is that the success of the local decodable is only guaranteed for inputs that are sufficiently close to a valid codeword, and we have no such guarantee on y a priori. However, recalling that C is a strong-LTC, we can handle this as follows. Letting δradius > 0 be the decodability radius of the relaxed-LDC C, we set δ∗ := min(δradius, ε). (1) Run independently O(poly(1/δ∗)) times the local tester for the strong-LTC C on y, and output reject if any of these rejected. Since every invocation of the local tester makes O(1) 12 queries to y, this has query complexity O(poly(1/δ∗)) = O(poly(1/ε)); and if dist(y,C) > δ∗ then this step outputs reject with probability at least 9/10. (2) Invoke A on the message x := argmin{ dist(C(x), y) : x ∈ Fn n }, answering each query xi by calling the local decoder for the relaxed-LDC C. This is done so that the decoder is correct with probability at least 1/(10q), by standard repetition (taking the plurality value); with the subtlety that we output reject immediately whenever the decoder returns ⊥. Since each query can be simulated by O(log(q)) queries (repeating the O(1) queries of the decoder O(log(1/q)) times), this step has query complexity O(q log q); and at the end, we output accept if, and only if, A returns the value 1 for f (x). Importantly, Step (1) can be run in parallel to Step (2), and in particular can be executed during the first "batch" of queries A makes. This guarantees that the whole simulation above uses the same number of adaptive rounds as A, as claimed. It remains to argue correctness. Completeness. Assume y ∈ Cf . In particular, y is a codeword of C, and the (one-sided) local tester returns accept with probability one in (1). Then, since by definition there is a unique x ∈ Fn n such that C(x) = y, the local decoder of Step (2) will correctly output the correct answer for each query with probability 1, and therefore A will correctly output f (x) with probability 2/3 -- so that the tester returns accept with probability at least 2/3 overall. (Moreover, if the DT algorithm A always correctly compute f , then the tester returns accept with probability one.) Soundness. Assume dist(y,Cf ) > ε. If dist(y,C) > δ∗, then the local tester returns reject with probability at least 9/10 in Step (1). Therefore, we can continue assuming that dist(y,C) ≤ δ∗, which satisfies the precondition of the relaxed-LDC decoder in Step (2). By a union bound over all q queries, with probability at least 9/10 we have that the decodings performed in Step (2) are all cor- rect; in which case we answer the queries of the algorithm according to x := argmin{ dist(C(x), y) : x ∈ Fn n } (or possibly answered by ⊥, in which case the tester immediately outputs reject and we are done). Since dist(y, C(x)) ≤ δ∗ ≤ ε, we must have C(x) 6∈ Cf , which implies that A correctly returns f (x) = 0 with probability at least 2/3, in which case the tester outputs reject. Overall, this happens with probability at least 9/10 · 9/10 · 2/3 = 27/50. Thus, in both cases the tester is correct with probability at least 27/50; repeating a constant number of times (as explained in Remark 3.2) and taking the majority vote allows us to amplify the probability of success to 2/3. 5 An Adaptivity Hierarchy with respect to a Natural Property In this section we show a natural property of graphs for which, broadly speaking, more adaptivity implies more power. More specifically, we prove the following adaptivity hierarchy theorem with respect to the property of k-cycle freeness in the bounded-degree graph model (see definitions in Section 5.1). Theorem 5.1. Let k ∈ N be a constant. Then, (i) there exists a (k, O(1/ε))-round-adaptive (one-sided) tester for (2k + 1)-cycle freeness in the bounded-degree graph model; yet (ii) any (k−1, q)-round-adaptive (two-sided) tester for (2k+1)-cycle freeness in the bounded-degree 13 graph model must satisfy q = Ω(√n). We stress that although Theorem 4.1 establishes an adaptivity hierarchy with stronger separa- tions, the merit of Theorem 5.1 is in showing that an adaptivity hierarchy also holds for a natural well-studied property. We further observe that the choice of the bounded-degree graph model is not insignificant: one cannot hope to establish such a striking gap in other settings such as the dense graph model or in the Boolean function testing setting. Indeed, as discussed in Section 1.2 it is well- known that in these two models, any adaptive tester can be made (fully) non-adaptive at the price of only a quadratic and exponential blowup in the query complexity, respectively(see [AFKS00, GT03] for the former; the latter is folklore). We remark that in Section 6.1 we discuss emulating testers with k rounds of adaptivity by testers with k′ < k rounds. 5.1 Cycle Freeness in the Bounded Degree Graph Model In the subsection we provide the necessary definitions and establish a basic upper bound on the complexity of k-adaptive testing of cycle freeness in the bounded degree graph model. We begin with a definition of the model. Let G = (V, E) be a graph with constant degree bound d < V , represented by its adjacency list; that is, represented by a function g : V × d → V such that g(v, i) = u ∈ V if u is the ith neighbor of v and g(v, i) = 0 if v has less than i neighbors. A bounded degree graph property P is a subset of graphs (represented by their adjacency list) that is closed under isomorphism; that is, for every permutation π it holds that G ∈ P if and only if G ∈ π(G). The distance of graph G from property P is the minimal fraction of entries in g one has to change to reach an element of P. We extend the definition of functional round-adaptive testing algorithms to the bounded degree graph model in the natural way. Definition 5.2 (Round-Adaptive Testing in the Bounded Degree Graph Model). Let G = (V, E) be a graph with constant degree bound d < V , represented by its adjacency list g : V × d → V , and let k, q ≤ n. A randomized algorithm is said to be a (k, q)-round-adaptive tester for a (bounded degree) graph property P, if, on proximity parameter ε ∈ (0, 1] and granted query access to g, the following holds. (i) Query Generation: The algorithm proceeds in k + 1 rounds, such that at round ℓ ≥ 0, it produces a set of queries Qℓ := {x(ℓ),1, . . . , x(ℓ),Qℓ} ⊆ Ω (possibly empty), based on its own internal randomness and the answers to the previous sets of queries Q0, . . . , Qℓ−1, and receives f (Qℓ) = {g(x(ℓ),1), . . . , g(x(ℓ),Qℓ)}; (ii) Completeness: If G ∈ P, then the algorithm outputs accept with probability at least 2/3; (iii) Soundness: If dist(G,P) > ε, then the algorithm outputs reject with probability at least 2/3. The query complexity q of the tester is the total number of queries made to f , i.e., q = Pk ℓ=0 Qℓ. If the algorithm returns accept with probability one whenever f ∈ P, it is said to have one-sided error (otherwise, it has two-sided error). As before, we will sometimes refer to a tester with respect to proximity parameter ε as an ε-tester. Next, we define the (bounded degree) graph property of k-cycle freeness. Definition 5.3 (Cycle Freeness). Let k ∈ N. A graph G = (V, E) is said to be k-cycle free if it does not contain any cycle of length less or equal to k; that is, if for every t ≤ k and v1, . . . , vt ∈ V either (vt, v1) 6∈ E or there exists i ∈ [t − 1] such that (vi, vi+1) 6∈ E. 14 Finally, we make the following observation, which roughly speaking implies that when surpassing a certain threshold of round adaptivity, testing cycle freeness in the bounded degree graph model becomes "easy."7 Observation 5.4. For every k ∈ N there exists a (k, q)-round-adaptive testing algorithm for (2k + 1)-cycle freeness and (2k + 2)-cycle freeness in the bounded-degree graph model with query complexity q = O(dk+1/ε). Proof. The algorithm explores the graph in the most natural way: starting from O(1/ε) "source vertices" selected uniformly at random, it adaptively explore their neighborhoods by querying at each round the neighbors of the previously reached vertices, in a breadth-first-search fashion. If any (2k + 1)-cycle (resp. (2k + 2)-cycle) is detected, the algorithm rejects, and accepts otherwise. (Clearly, this tester is one-sided.) It is easy to see that if any of the source vertices belongs to a (2k + 1)- or (2k + 2)-cycle, then this bounded-depth BFS will detect it; thus, we only need to argue that if the graph is ε-far from cycle freeness, with constant probability, one of the source vertices will participate in such a cycle. But this is the case, as any such graph must have at least εn vertices participating in a cycle (indeed, otherwise one could "correct" the graph by removing less than εdn vertices, contradicting the distance). Finally, for each source vertex, after k rounds of adaptivity the number of nodes visited is at most O(dk+1), hence the claimed query complexity. 5.2 Lower Bounds for Round-Adaptive Testers In this subsection, we prove the following lemma, which roughly speaking shows that testing (2k+3)- cycle freeness is hard for k-round-adaptive testing algorithms. Lemma 5.5. Let k ∈ N be constant. Then, any (k, q)-round-adaptive testing algorithm for (2k+3)- cycle freeness in the bounded-degree graph model must satisfy q = Ω(√n). In stark contrast, recall that Observation 5.4 shows that testing (2k + 2)-cycle freeness is easy for k-round-adaptive testing algorithms. Indeed, the proof of Theorem 5.1 follows by combining Observation 5.4 and Lemma 5.5 together. Proof of Lemma 5.5. We will show a distribution of (2k + 3)-cycle free graphs, denoted Y, and a distribution of graphs that are "far" from being (2k + 3)-cycle free, denoted N , and prove that no (k, q)-round-adaptive testing algorithm can distinguish, with high probability, between Y and N . Loosely speaking, Y consists of all graphs whose vertices are covered via disjoint (2k + 4)-cycles, and N consists of all graphs whose vertices are covered via disjoint (2k + 3)-cycles. More accurately, denote by Pt,n,d the subset of n-node graphs with maximum degree at most d that are t-cycle-free. Let Σt,s be the 2-regular graph on st vertices made of s disjoint t-cycles, namely (v1, . . . , vt), (vt+1, . . . , v2t), (v(s−1)t+1, . . . , vst). Denote also by Isr the independent set on r vertices. For two graphs G, G′ on respectively m and m′ vertices and with e and e′ edges, we write G ⊔ G′ for the graph on m + m′ vertices and with e + e′ edges obtained by concatenating disjoint copies of G, G′. (2k+3)k, and define the two distributions over n-node (2k+4)k, ℓ′ := j For k = O(1), we let ℓ := j graphs Y and N as follows. n n 7This is a specific case of a more general algorithm for testing subgraph freeness; see e.g. [Gol17, Section 9.2.1]. 15 • Y is the uniform distribution over all isomorphic copies of Gyes • N is the uniform distribution over all isomorphic copies of Gno k := Σ(2k+4),ℓ ⊔ Isn−(2k+4)ℓ; k := Σ(2k+3),ℓ′ ⊔ Isn−(2k+3)ℓ′. The next claim establishes that indeed Y consists of yes-instances, whereas N consists of no- instances. Claim 5.6. Y is supported on P(2k+3),n,d, while every graph in the support of N is Ω(1)-far from P(2k+3),n,d. Proof. The first part is obvious, as the only cycles in Gyes immediately follows from observing that Gno k are (2k + 4)-cycles. As for the second, it k contains ℓ′ disjoint (2k + 3)-cycles, and thus at least dn/2 = ℓ′ edges have to be removed to make it (2k + 3)-cycle free. Thus, dist(cid:16)Gno dk(cid:17) = Ωd(1). Ω(cid:16) 1 Let T be a deterministic testing algorithm with k rounds of adaptivity and query complexity q′ = o(√n). The following lemma concludes the proof of Lemma 5.5 by showing that T cannot distinguish, with high probability, between graphs in Y and graphs in N . Denote T 's (disjoint) query sets, per round, by Q0, . . . , Qk ⊆ V , where a query is a vertex v. Denote the corresponding sets of answers by A0, . . . , Ak, where the answer to a query v consists of the labels of all neighbors of v (i.e., either two or zero vertices). Since k = O(1), without loss of generality, we can assume (by k+1 = Θ(q′) for every i ∈ {0, . . . , k}. padding) that all query sets have the same size q := Qi = q′ Moreover, we can also assume that no vertex is queried twice, i.e. that all Qi's are disjoint. PrG∼Y hT G acceptsi − PrG∼N h T G acceptsi(cid:12)(cid:12)(cid:12) ≤ 1 Lemma 5.7. (cid:12)(cid:12)(cid:12) Proof. For j ∈ {0, . . . , k}, define by Yj and Nj the distribution of (A0, . . . , Aj) when G ∼ Y and when G ∼ N , respectively. We shall prove that dTV(Yk, Nk) ≤ 1 10 , which by the data processing inequality will imply the claim of Lemma 5.7. k ,P(2k+3),n,d(cid:17) ≥ ℓ′ 10 . The high-level idea is that in each round, the tester can either query "fresh" vertices, of which it has no prior information, or query the boundaries (i.e., the direct neighbors) of previously queried vertices. Then, loosely speaking we can argue that, on the one hand, if the total number of queries is o(√n), then both for graphs in Y and N all queries of "fresh" vertices (obtained during all rounds) with high probability would only fall into previously unattained disjoint cycles, in which case the answer would be a uniform sequence of "fresh" labels. On the other hand, the local view obtained by querying the boundary, using at most k rounds of adaptive queries, of each vertex previously obtained via a "fresh" query (which by the above lies in a cycle wherein the tester has no information of the labels of the other vertices participating in this cycle) is isomorphic to the tail graph over fresh labels, both for instances taken from Y and N (that is, we do not have enough adaptive queries to observe a full cycle). The foregoing intuition is formalized below. For i ∈ {0, . . . , k}, define i := Qi \ ∪i−1 Sf i := Qi ∩ ∪i−1 Sb j=0Aj j=0Aj to be, respectively, the set of "entirely fresh" nodes queried at round i (that is, nodes that are not neighbors of any previously queried node), and the set of "boundary nodes" (which are the not-yet-queried nodes neighbors of a previously queried node). 16 First, we bound the probability that any of the q′ queries made "hits" the set of disconnected nodes: Claim 5.8. Let E1(G) denote the event that T queries an isolated vertex of G, that is E1(G) := {∃i, v s.t. v ∈ Qi, deg(v) = 0}. Then PrG∼Y [ E1(G) ] , PrG∼N [ E1(G) ] = o(1). Proof. This follows by induction: at step i, conditioned on no isolated node having been queried yet, the algorithm has degree information about(cid:12)(cid:12)(cid:12)∪i−1 j=0 Aj ≤ 3q·i nodes, so there remain at least n− 3kq nodes on which the algorithm has no degree information at all. Among these, there are n − (2k + 4)ℓ ≤ (2k + 4) (or n − (2k + 3)ℓ′ ≤ (2k + 3), in the no-case) isolated nodes. By symmetry, this means that in the new batch of q queries, the algorithm will query n (cid:17)q = 1 −(cid:16)1 − O(1) one of these isolated nodes with probability at most 1 −(cid:16)1 − = O(cid:0) q n(cid:1) = o(1). Therefore, overall there will be an isolated node queried with probability at most k · o(1) = o(1). j=0Aj(cid:12)(cid:12)(cid:12) ≤ Pi−1 n−3kq−(2k+4)(cid:17)q j=0 Qj+Pi−1 j=0QjS∪i−1 (2k+4) Next, we argue that at each step, with overwhelming probability all the "fresh nodes" queried fall in distinct cycles, which have not been attained yet. Claim 5.9. Let E2(G) denote the event that at some round i, one of the queries in Sf i belongs to the same cycle (either a (2k + 4)- or a (2k + 3)-cycle, depending on whether the graph is drawn from j=0 Qj. Then PrG∼Y [ E2(G) ] , PrG∼N [ E2(G) ] = o(1). Y or N ) as one of the previous queries Si−1 Proof. We will show that PrG∼Y [ E2(G) ] = o(1); the no-case is similar. For i ∈ {1, . . . , k}, let E(i) 2 (G) denote the event that at some round i, one of the queries in Sf i belongs to the same cycle as a previous query, so that E2(G) = Sk Note that since Si−1 reached is at most Si−1 j=0 Qj = iq, we have Si−1 j=0 Aj ≤ 2iq (and the number of distinct cycles j=0 Qj). Therefore, at round i each of the at most q distinct queries in Sf falls independently in a previously visited cycle with probability upper bounded by i=1 E(i) 2 (G). i iq · (2k + 4) n − 3iq ≤ kq · (2k + 4) n − 3kq ≤ 2k2q n recalling that q = o(n) and k = O(1). A union bound over all at most q queries of Sf over the k rounds then shows that PrG∼Y [ E2(G) ] ≤ 2k3q2 n = o(1) (since q = o(√n)). i , and then To conclude the proof, note that by the above, with probability 1 − o(1) neither E1 nor E2 occurs; that is, none of the isolated vertices was queried, and all the "fresh" queries (during all rounds ) fell in previously unattained distinct cycles. In this case, at each round of adaptivity the algorithm can at most discover two new nodes out of every cycle it reached before (by including the one or two end nodes of the current "discovered portion" into Sb i ). Therefore, on any cycle ever reached, the (k, q)-round-adaptive testing algorithm can observe at most 2k + 2 nodes (which then form a consecutive path). We show that this implies that the algorithm cannot distinguish between a no-instance and a yes-instance, as loosely speaking, in both cases its local view is of a tail graph over uniformly distributed fresh labels, and so it is unable to determine whether it belongs to a cycle of length 2k + 3 or 2k + 4. To make the argument more precise, we will actually show a stronger statement; namely, we show that, conditioning on neither E1 nor E2 occuring, a simulator with no access to the graph 17 can answer the queries of the testing algorithm in a way that is indistinguishable from the tuple of answers obtained from querying a graph distributed according to either Y or N . This simulator operates as follows: at round i, 1. Order (arbitrarily) all the nodes of Qi: v1, . . . , vq, and initialize the set of available-to-sample 2. Do sequentially the following, for s = 1 . . . q: nodes U ← V \(cid:16)Qi ∪Si−1 • if vs ∈ Sf j=0 Qj ∪Si−1 j=0 Aj(cid:17). i (fresh node: no previous neighbors known), pick uniformly at random two distinct nodes u, u′ in Us and return them as answers (i.e., declare them as neighbors of vs); uniformly at random one other node u′ in Us, and return (u, u′) as answers; i (boundary node: exactly one already known neighbor, call it u): pick • otherwise, vs ∈ Sb • update U by removing u, u′: U ← U \ {u, u′} It is straightforward to verify that, since we conditioned on E1 and E2, this simulates exactly the same distribution over nodes (over the choice of G); since this is the same both for Y and N , we get that dTV(cid:16)(Yk E1 ∪ E2)), (Nk E1 ∪ E2))(cid:17) = 0, which combined with Claim 5.8 and Claim 5.9 finishes the proof. This concludes the proof of Lemma 5.5. 6 Some Miscellaneous Remarks 6.1 On Simulating k Rounds With Fewer As mentioned in the beginning of Section 5, in the Boolean setting any adaptive property testing algorithm can be simulated non-adaptively with only an exponential blowup in the query com- plexity. Phrased differently, this implies that any property of Boolean functions which admits a (k, q)-round-adaptive tester also has a (0, 2q − 1)-round-adaptive tester. This begs the following more general question: let P = Sn Pn be a property of Boolean func- tions, such that there exists a (k, q)-round-adaptive tester for P. For ℓ < k, what upper bound can we obtain on the query complexity q′ of the best (ℓ, q′)-round-adaptive tester for P? Denoting by qℓ this query complexity, the above discussion immediately implies: Fact 6.1. For any 0 ≤ ℓ ≤ k, one has qk ≤ qℓ ≤ 2qk − 1. In what follows, we provide a example of a more fine-grained version of this fact, in the case when ℓ = k − 1 (that is, one wishes to reduce the number of rounds of adaptivity by one). Proposition 6.2. For any 0 < k, one has qk ≤ qk−1 ≤ qk(1 + 2 Proof. Let Tk be a (k, q)-round-adaptive tester for P, which can be viewed as a distribution over deterministic algorithms. Thus, it is sufficient to explain how to simulate any deterministic al- gorithm with k rounds of adaptivity by one with ℓ rounds. Fix such a (k, q)-round deterministic algorithm: this can be seen equivalently as a depth-(k + 1) binary tree, where each internal node v is labeled by the set of queries Qv made at that stage, and the leaves are either accept or reject. By j=0(cid:12)(cid:12)(cid:12) Qvj(cid:12)(cid:12)(cid:12) ≤ q; assumption, we have that on each path (v0, v1, . . . , vk, v∗) from the root to a leaf, Pk moreover, one can assume without loss of generality that this is an equality. qk k ). 18 The idea is then to contract, on any path, two consecutive nodes as follows: instead of querying Qvj , receiving the answers, and then querying the (adaptively chosen) set Qvj+1, one can idea query simultaneously Qvj and the union of all possible sets Qvj+1: since the latter depends only on the previous queries, and the only unknown answers are those to the queries in Qvj , there are at most 2Qvj possibilities for Qvj+1. As clearly no matter what Qvj+1 would be, its size is at + q2Qvj. Thus, by Q queried has size at most (cid:12)(cid:12)(cid:12) Qvj(cid:12)(cid:12)(cid:12) most q, the set Q′i = Qvj ∪SQ : possible Qvj+1 contradicting the two rounds i and i + 1, one incurs an additional number of queries upper bounded by q2Qvj −(cid:12)(cid:12)(cid:12) j=0(cid:12)(cid:12)(cid:12) Qvj(cid:12)(cid:12)(cid:12) By an averaging argument, since on every such path we have Pk an index j∗ such that (cid:12)(cid:12)(cid:12) j=0(cid:12)(cid:12)(cid:12) single round, we additionally want to ensure j∗ < k. But similarly, as Pk−1 i∗ such that (cid:12)(cid:12)Qvi∗(cid:12)(cid:12) ≤ q algorithm is executed it will reach an index i∗ < k where it should make(cid:12)(cid:12)Qvi∗(cid:12)(cid:12) ≤ q k . We then get an index i∗ < k (which depends on the path taken down the tree) to which we can apply the above transformation. That is, whenever the deterministic k queries. At that point, it makes instead these queries, along with all queries this should have triggered at the next round, and thus is able to skip round i∗ + 1 at the price of an additional (at most) q2 = q, there must exist k+1. Since we would like to "contract" rounds j∗ and j∗ + 1 into a Qvj+1(cid:12)(cid:12)(cid:12) ≤ q2Qvj Qvj∗(cid:12)(cid:12)(cid:12) ≤ q Qvj(cid:12)(cid:12)(cid:12) ≤ q there exists q k queries. Remark 6.3. Note that in the above proof, while one can assume without loss of generality that the algorithm always makes exactly q queries, one cannot however assume that for any two such paths for all 0 ≤ j ≤ k. That is, the number of queries made in round j may not be the same depending on the path followed down by the algorithm, but instead depend adaptively on the previous queries made. (v0, v1, . . . , vk, v∗) and (u0, u1, . . . , uk, u∗), (cid:12)(cid:12)(cid:12) = (cid:12)(cid:12)(cid:12) Quj(cid:12)(cid:12)(cid:12) Qvj(cid:12)(cid:12)(cid:12) The above remark shows the difficulty in extending the proof of Proposition 6.2 further than a single round. If one is willing to assume that the number of queries at each round is non-adaptive, it becomes possible to obtain a more general statement for 0 ≤ ℓ < k; however, it is unclear how to proceed without this extra assumption, leading to the following question: Open Problem 3. Can one obtain a general round-reduction upper bound for 0 ≤ ℓ < k of the form qℓ ≤ φ(qk, ℓ, k), improving on Fact 6.1 for ℓ > 0? 6.2 On the Connection with Communication Complexity As exemplified in the proof of Lemma 4.4, there exists a striking parallel between the notion of k-round-adaptive testing algorithms, and that of k-round protocols in communication complexity. In this section, we make this parallel rigorous, and give a blackbox reduction between the two that one can leverage to establish lower bounds on k-round-adaptive testing. In more detail, we build on the communication complexity methodology for proving property testing lower bounds due to [BBM12] (more precisely, to the general formulation of this methodology as laid out in [Gol13]). Although the results stated there hold for non-adaptive lower bounds (in the case of one-way communication or simultaneous message passing) or fully adaptive lower bounds in property testing (in the case of two-way communication), it is easy to obtain their counterpart for k-round-adaptive, given in Theorem 6.4 below. But first, we need to recall some notations. In what follows, for a property P, integer k, and parameters ε, δ ∈ [0, 1], we write Q(k) δ (ε,P) for the minimum query complexity of any k-round-adaptive tester for P with error probability 19 δ and distance parameter ε. Given a communication complexity predicate F , we let CC(k) δ (F ), −→CCδ(F ), and ←−CCδ(F ) denote respectively the minimum communication complexity of a public-coin protocol for F with error δ in (i) k-rounds, (ii) one-way from Alice to Bob, and (iii) one-way from Bob to Alice, respectively (note that the case δ = 0 then corresponds to protocols with perfect completeness). Theorem 6.4. Let Ψ = (P, S) be a promise problem such that P, S ⊆ {0, 1}2n, P ⊆ {0, 1}ℓ be a property, and ε, δ > 0. Suppose the mapping F : {0, 1}2n → {0, 1}ℓ satisfies the following two conditions: 1 δ (Fi),←−CC δ n n 2δ (Ψ). B+1 CC(k+2) δ (ε,P) ≥ 1 (Fi)) (and Fi(x, y) δ (ε,P) ≥ (i) for every (x, y) ∈ P ∩ S, it holds that F (x, y) ∈ P; (ii) for every (x, y) ∈ P \ S, it holds that F (x, y) is ε-far from P. (Ψ), where B := maxi∈[ℓ] max(−→CC δ Then Q(k) is the i'th bit of F (x, y)). Moreover, if B′ := maxi∈[ℓ] max(−→CC0(Fi),←−CC0(Fi)), then Q(k) B′+1 CC(k+2) Proof. The proof will be identical to that of [Gol13, Theorem 3.1], where we only need to check that Alice and Bob can each simulate the execution of the property testing algorithm (using their public random coins), answering the queries made to F (x, y) while preserving the number of rounds. Running the testing algorithm, Alice first sends the bits allowing Bob to compute the answers to the first q0 queries, using her input x and the one-way protocols for the relevant Fi's. Bob then answers with the q0 bits corresponding to the answers he computed, as well as the bits allowing Alice to compute the answers to the next q1 queries made by the tester, using now his input y and the one-way protocols for the relevant Fi's. They do so for k + 1 rounds of communication in total, until the last player to receive a message gets from the other player both the answers to the queries in Qk−1 as well as the bits needed to compute (given their own input) the answers to the last qk queries. At that point, it only remains to use a last round of communication (the (k + 2)'nd) to communicate to the other player the answers to these last qk queries, so that both Alice and Bob can finish running their copy of the testing algorithm and know the answer. Note that the number of bits communicated at round 1 ≤ i ≤ k + 2 is by definition of B (resp. B′) at most B · qi−1 + qi−2 (resp. B′ · qi−1 + qi−2), so that at most (B + 1)q (resp. (B′ + 1)q) bits are communicated in total. This concludes the proof. To illustrate the above methodology, we show how it can be leveraged to prove a hierarchy of lower bounds on the power of k-adaptive testers for testing a very fundamental class of Boolean functions, that of m-linear functions.8 s ⊆ 22n √n 2 . Then, for any 0 ≤ k ≤ log∗ m − 2, any (k, q)-round-adaptive tester for PARn denote the class of parities of size s (over n variables), and 2m must Proposition 6.5. Let PARn fix m := satisfy q = Ω(cid:16)m log(k+2) m(cid:17). Proof. We will rely on a result of Sağlam and Tardos [ST13], which implies the following (tight) lower bound on the communication complexity of sparse set-disjointness (DISJn m, where both inputs x, y ∈ {0, 1}n are promised to have Hamming weight m): 8We observe that establishing the upper bound counterpart to this result would provide an answer 20 It then suffices to provide a reduction from DISJ4m2 m to testing PAR4m2 Theorem (Corollary of [ST13, Theorem 4]). For any 1 ≤ k ≤ log∗ m, any k-round probabilistic m with error probability at most 1/3 must have communication Ω(cid:16)m log(k) m(cid:17). protocol for DISJ4m2 2m . We follow the known reduction, as can be found in [BBM12, BGMdW13]. Namely, on input x ∈ {0, 1}n (resp. y ∈ {0, 1}n), Alice (resp. Bob) forms the parity function χx (resp. χy). As x ⊕ y = x+y−2x ∩ y = 2m− 2x ∩ y, the function χx⊕y is a 2(m−x ∩ y)-parity. Moreover, as for any z ∈ {0, 1}n we have χx⊕y(z) = χx(z)⊕χy(z), each query can be answered (with zero error) by one bit of communication in either direction. u = m }2 2m ⊆ 2ℓ; and F : {0, 1}2n → {0, 1}ℓ 2 , we can (Ψ) = and S = { (x, y) ∈ P : maps (x, y) to the truth table of χx⊕y. Since any two distinct parities are at distance 1 take any ε ≤ 1 Ω(cid:16)m log(k+2) m(cid:17) for any 0 ≤ k ≤ log∗ m − 2. Invoking Theorem 6.4 concludes the proof. Put in the language of our reduction theorem, Ψ = (P, S) with P = { u ∈ {0, 1}n : 2 . We then have B′ = 1, and by the theorem above we know that CC(k+2) 1/3 x ∩ y 6= 0 }; while ℓ = 2n, P = PARn 6.3 On the Relative Power of Round- and Tail-Adaptive Testers In this section, we show that the two notions of round- and tail-adaptive testers we introduced are not equivalent. As mentioned in Section 3, while round-adaptive testers are at least as powerful as tail-adaptive ones, there exist properties for which the separation is strict: Theorem 6.6. Fix any α ∈ (0, 1). There exists a constant β ∈ (0, 1) such that, for every n ∈ N, the following holds. For every integer 0 ≤ k ≤ nβ, there exists a property Pk ⊆ Fn1+α such that, for any constant ε ∈ (0, 1], (i) there exists a (k, O(k))-round-adaptive (one-sided) tester for Pk; yet (ii) any (k, q)-tail-adaptive (two-sided) tester for Pk must satisfy q = Ω(n). Proof sketch. The argument is very similar to that of Theorem 4.1, and follows the same overall structure. Namely, we slightly modify the k-iterated function fk of Section 4 (which was computable by a (k, k + 1)-tail-adaptive algorithm) to rule out tail-adaptive algorithms but not round-adaptive ones: that is, we define the function f′k : Fn n n → Fn by if xx,gk−1(x) = xx,gk−1(x)+1 mod n otherwise. f′k(x) = (1 0 (Perhaps more clearly, f′k is computed by iterating the pointer function k times, and then checking if the value xi at the final coordinate i ∈ [n] reached, and the value xi+1 at the adjacent coordinate i + 1, are equal.) It is not hard to see that the counterparts of Claim 4.3 and Lemma 4.4 still hold for f′k: first, the function is still easy to compute by (k, k + 2)-round-adaptive algorithms. However, because the very last round requires 2 queries and not one (to query xi and xi+1, once the value of i = gk−1(x) has been obtained), tail-round-adaptive algorithms are no longer able to leverage this, and analogously to Lemma 4.4 we can conclude that there is no (k, o(n/(k2 log n)))-round-adaptive (randomized) LDT algorithm which computes f′k. It then only remains to lift this DT separation to Open Problem 1, although one rather weak quantitatively. It also, as a special case, would separate adaptive and non-adaptive testing of m-linearity for m = o(n), a longstanding open question [BK12, BCK14]. 21 to property testing: we can do this as before (noting, in the case of lifting the lower bound, that the reduction of Lemma 4.10 preserves the number of queries per round, and thus the "tailness" of the algorithm). Acknowledgments We are grateful to Oded Goldreich for suggesting cycle freeness as a candidate natural property for proving an adaptivity hierarchy theorem, as well as for enlightening conversations that significantly contributed to this work; and wish to thank Rocco Servedio for helpful comments on an earlier version of this paper. 22 References [AFKS00] Noga Alon, Eldar Fischer, Michael Krivelevich, and Mario Szegedy. Efficient testing of large graphs. Combinatorica, 20(4):451 -- 476, 2000. 1.2, 5 [AW08] [BBM12] [BCK14] [BdW02] [BGH+06] Scott Aaronson and Avi Wigderson. Algebrization: a new barrier in complexity theory. In Proceedings of STOC, pages 731 -- 740, 2008. 4.2 Eric Blais, Joshua Brody, and Kevin Matulef. Property testing lower bounds via communication complexity. Computational Complexity, 21(2):311 -- 358, 2012. 6.2, 6.2 Abhishek Bhrushundi, Sourav Chakraborty, and Raghav Kulkarni. Property testing bounds for linear and quadratic functions via parity decision trees. In CSR, volume 8476 of Lecture Notes in Computer Science, pages 97 -- 110. Springer, 2014. 1.2, 8 Harry Buhrman and Ronald de Wolf. Complexity measures and decision tree com- plexity: a survey. Theor. Comput. Sci., 288(1):21 -- 43, 2002. 4.2 Eli Ben-Sasson, Oded Goldreich, Prahladh Harsha, Madhu Sudan, and Salil P. Vad- han. Robust PCPs of Proximity, Shorter PCPs, and Applications to Coding. SIAM Journal on Computing, 36(4):889 -- 974, 2006. 4.4.1, 4.4.1, 5, 6 [BGMdW13] Harry Buhrman, David García-Soriano, Arie Matsliah, and Ronald de Wolf. The non-adaptive query complexity of testing k-parities. Chicago J. Theor. Comput. Sci., 2013, 2013. 6.2 [BHR05] [BK12] [Bla08] [Bla09] [BLR93] [BMW11] Eli Ben-Sasson, Prahladh Harsha, and Sofya Raskhodnikova. Some 3CNF properties are hard to test. SIAM J. Comput., 35(1):1 -- 21, 2005. 1, 1.2 Eric Blais and Daniel M. Kane. Tight bounds for testing k-linearity. In Proceedings of APPROX-RANDOM, volume 7408 of Lecture Notes in Computer Science, pages 435 -- 446. Springer, 2012. 8 Eric Blais. Improved bounds for testing juntas. In Approximation, Randomization and Combinatorial Optimization. Algorithms and Techniques, pages 317 -- 330. Springer, 2008. 1.2 Eric Blais. Testing juntas nearly optimally. In Proceedings of STOC, pages 151 -- 158. ACM, 2009. 1.2 Manuel Blum, Michael Luby, and Ronitt Rubinfeld. Self-testing/correcting with ap- plications to numerical problems. J. Comput. Syst. Sci., 47(3):549 -- 595, 1993. 1.2 Joshua Brody, Kevin Matulef, and Chenggang Wu. Lower bounds for testing com- putability by small width OBDDs. In TAMC, volume 6648 of Lecture Notes in Com- puter Science, pages 320 -- 331. Springer, 2011. 1.2 [BY17] Arnab Bhattacharyya and Yuichi Yoshida. Property Testing. Forthcoming, 2017. 1 [Can15] 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, April 2015. 1 23 [CST+17] [DH00] [GGK15] Xi Chen, Rocco A. Servedio, Li-Yang Tan, Erik Waingarten, and Jinyu Xie. Settling the query complexity of non-adaptive junta testing. Private communication, 2017. 1.2 Dingzhu Du and Frank K. Hwang. Combinatorial Group Testing and Its Applications. Applied Mathematics. World Scientific, 2000. 1 Oded Goldreich, Tom Gur, and Ilan Komargodski. Strong locally testable codes with relaxed local decoders. In Conference on Computational Complexity, volume 33 of LIPIcs, pages 1 -- 41. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2015. 4.4.1, 4.9, 6, 4.4.2 [GGR98] Oded Goldreich, Shafi Goldwasser, and Dana Ron. Property testing and its connec- tion to learning and approximation. Journal of the ACM, 45(4):653 -- 750, July 1998. 1 [Gol10] [Gol13] Oded Goldreich, editor. Property Testing - Current Research and Surveys [outgrow of a workshop at the Institute for Computer Science (ITCS) at Tsinghua University, January 2010], volume 6390 of Lecture Notes in Computer Science. Springer, 2010. 1 Oded Goldreich. On the communication complexity methodology for proving lower bounds on the query complexity of property testing. Electronic Colloquium on Com- putational Complexity (ECCC), 20:73, 2013. 6.2, 6.2 [Gol17] Oded Goldreich. Introduction to Property Testing. Forthcoming, 2017. 1, 7 [GR00] [GR11] [GR17] [GT03] [IPW11] Oded Goldreich and Dana Ron. On testing expansion in bounded-degree graphs. Electronic Colloquium on Computational Complexity (ECCC), 7:20, 2000. 1 Oded Goldreich and Dana Ron. Algorithmic aspects of property testing in the dense graphs model. SIAM J. Comput., 40(2):376 -- 445, 2011. 1.2 Tom Gur and Ron D. Rothblum. A hierarchy theorem for interactive proofs of proximity. 2017. The 8th Innovations in Theoretical Computer Science (ITCS 2017) conference (to appear). 1.2 Oded Goldreich and Luca Trevisan. Three theorems regarding testing graph proper- ties. Random Struct. Algorithms, 23(1):23 -- 57, 2003. 1, 1.2, 5 Piotr Indyk, Eric Price, and David P. Woodruff. On the power of adaptivity in sparse recovery. In Proceedings of FOCS, pages 285 -- 294, 2011. 1.2 [MORS09] Kevin Matulef, Ryan O'Donnell, Ronitt Rubinfeld, and Rocco A. Servedio. Testing ±1-weight halfspace. In Proceedings of APPROX-RANDOM, volume 5687 of Lecture Notes in Computer Science, pages 646 -- 657. Springer, 2009. 1.2 [NW93] Noam Nisan and Avi Wigderson. Rounds in communication complexity revisited. SIAM Journal on Computing, 22(1):211 -- 219, February 1993. 1.2, 4.3, 4.5 [PS82] Christos H. Papadimitriou and Michael Sipser. Communication complexity. In Pro- 24 [Ron08] [Ron09] [RS96] [RS06] [RS13] [RT12] [ST13] [STW15] [Tel14] ceedings of STOC, Proceedings of STOC, pages 196 -- 200, New York, NY, USA, 1982. ACM. 4.3 Dana Ron. Property testing: A learning theory perspective. Foundations and Trends in Machine Learning, 1(3):307 -- 402, 2008. 1 Dana Ron. Algorithmic and analysis techniques in property testing. Foundations and Trends in Theoretical Computer Science, 5(2):73 -- 205, 2009. 1 Ronitt Rubinfeld and Madhu Sudan. Robust characterization of polynomials with applications to program testing. SIAM Journal on Computing, 25(2):252 -- 271, 1996. 1 Sofya Raskhodnikova and Adam D. Smith. A note on adaptivity in testing proper- ties of bounded degree graphs. Electronic Colloquium on Computational Complexity (ECCC), 13(089), 2006. 1, 1.2 Dana Ron and Rocco A. Servedio. Exponentially improved algorithms and lower bounds for testing signed majorities. In Proceedings of SODA, pages 1319 -- 1336. SIAM, 2013. 1.2 Dana Ron and Gilad Tsur. Testing computability by width-two OBDDs. Theor. Comput. Sci., 420:64 -- 79, 2012. 1.2 Mert Sağlam and Gábor Tardos. On the communication complexity of sparse set disjointness and exists-equal problems. In Proceedings of FOCS, pages 678 -- 687. IEEE Computer Society, 2013. 6.2, (document) Rocco A. Servedio, Li-Yang Tan, and John Wright. Adaptivity helps for testing juntas. In Conference on Computational Complexity, volume 33 of LIPIcs, pages 264 -- 279. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2015. 1.2 Roei Tell. Deconstructions of reductions from communication complexity to property testing using generalized parity decision trees. Electronic Colloquium on Computa- tional Complexity (ECCC), 21:115, 2014. 1.2, 2 25
1811.10074
2
1811
2019-09-03T14:39:58
Parallel approach to sliding window sums
[ "cs.DS" ]
Sliding window sums are widely used in bioinformatics applications, including sequence assembly, k-mer generation, hashing and compression. New vector algorithms which utilize the advanced vector extension (AVX) instructions available on modern processors, or the parallel compute units on GPUs and FPGAs, would provide a significant performance boost for the bioinformatics applications. We develop a generic vectorized sliding sum algorithm with speedup for window size w and number of processors P is O(P/w) for a generic sliding sum. For a sum with commutative operator the speedup is improved to O(P/log(w)). When applied to the genomic application of minimizer based k-mer table generation using AVX instructions, we obtain a speedup of over 5X.
cs.DS
cs
Parallel approach to sliding window sums Roman Snytsar1 and Yatish Turakhia2 1 Microsoft Corp., One Microsoft Way, Redmond WA 98052, USA [email protected] 2 Stanford University, Stanford CA 94305, USA Abstract. Sliding window sums are widely used in bioinformatics ap- plications, including sequence assembly, k-mer generation, hashing and compression. New vector algorithms which utilize the advanced vector extension (AVX) instructions available on modern processors, or the par- allel compute units on GPUs and FPGAs, would provide a significant performance boost for the bioinformatics applications. We develop a generic vectorized sliding sum algorithm with speedup for window size w and number of processors P is O(P/w) for a generic sliding sum. For a sum with commutative operator the speedup is im- proved to O(P/log(w)). When applied to the genomic application of minimizer based k-mer table generation using AVX instructions, we ob- tain a speedup of over 5×. 1 Introduction Bioinformatics algorithms for sequence assembly, indexing, search, and compres- sion evolve at a breakneck rate. Still, many foundational ideas, like using short substrings known as k-mers, hashing schemas, and bespoke indexing mecha- nisms, stay relevant. A relatively new idea quickly gaining popularity is the use of minimizers [9]. Minimizers exploit the sequence contiguity allowing to repre- sent the sequence with a smaller number of k-mers, thus producing more compact indices. Minimizers have been successfully used for k-mer counting [3], sequence alignment [7], and indexing [14]. While some research has been directed towards improving the performance of minimizers [8], little attention has been paid to the properties of the underlying algorithm of sliding window minimum. In this paper we explore the properties of generic sliding window sums and uncover the potential for parallel speedup. We show a novel sliding sum ap- proach could be extended beyond minimizers to k-mer generation and hashing, and develop fast vector implementations not only for minimizer generation but also for k-mer hashing. In partiulcar, our approach provides a parallel speedup of O(P/w) for a generic sliding sum with a window size w and P processors, which could be further improved to a speedup of O(P/log(w)) for a sliding sum with a commutative operator. The rest of the paper is organized as follows. In 2 R. Snytsar and Y. Turakhia section 2, we provide background for prefix sum and sliding sum algorithms, and their applications to the popular seed-filter-extend paradigm used in bioinfor- matics, particularly in the context of minimizers. In section 3, we present our generic vectorized sliding sum algorithm and show how it could be applied to our bioinformatics applications. We present our results in section 4 and conclude in section 5. 2 Background 2.1 Prefix Sum Parallel algorithms are often constructed from a set of universal building blocks. One of the hardest to identify, but extremely useful is the concept of a prefix sum, and the accompanying scan algorithm. A prefix sum is a transformation that takes an operator ⊕, and a sequence of elements x0, x1, . . . , xk, . . . and returns the sequence yi = i(cid:88) j=0 xj = x0 ⊕ x1 ⊕ . . . ⊕ xi (1) Despite the data carry dependency, the first N elements of the prefix sum with an associative operator could be computed in O(log(N )) parallel steps using scan algorithm, as shown by [2]. 2.2 Sliding Window Sum Sliding window sum (sliding sum) takes a window size w in addition to an operator ⊕, and a sequence of elements, and returns the sequence i+w−1(cid:88) yi = xj = xi ⊕ xi+1 ⊕ . . . ⊕ xi+w−1 (2) j=i where each sum is defined in terms of the operator ⊕ and contains exactly w addends. The asymptotic complexity of a naive sliding sum algorithm is O(wN ) where N is the length of the source sequence. It is worth mentioning that every sum defined by Equation 2 is a prefix sum with operator ⊕ and input sequence xi . . . ⊕ xi+w−1. Many useful operators are associative, so the prefix scan algorithm is applicable here, reducing complex- ity of every sum in Equation 2 to O(log(w)) and, trivially, the overall sliding sum complexity to O(N log(w)) parallel steps. We have observed this optimiza- tion being implemented by the vectorizing compilers. It is, however, possible to further improve performance by exploiting more subtle operator properties. Parallel approach to sliding window sums 3 2.3 The seed-filter-extend paradigm Most heuristics to local sequence alignment are based on the seed-filter-extend paradigm, which was first popularized by the BLAST algorithm [1]. In aligning a reference sequence R with a query sequence Q, the seeding stage finds small local matches, called seed hits, of size k (also called k-mer, typically 10-19 base- pairs in size) between R and Q. The filtering stage itself may consist of several smaller sub-stages, which further reduces the search space by a combination of techniques, such as ungapped extension [1, 4] or chaining multiple seed hits in a diagonal band [7, 13]. The extension stage typically performs the compute- intensive dynamic programming step, usually employing the Smith-Waterman equations [10]. 2.4 Seed tables and minimizers Fig. 1: An example reference sequence and seed table used in D-SOFT. Heuristics based on the seed-filter-extend paradigm often maintain a seed table -- a data structure that enables fast lookup of seed hits in reference, R. Figure 1 shows an example reference sequence and seed table for seed size k=2. Seed table maintains two tables: (i) a seed pointer table and (ii) a seed position table. For each of the 4k possible seeds (16 seeds in Figure 1), lexicographically sorted, the seed pointer table points to the beginning of a list of hits in the seed position table. In Figure 1, lookups to 'CG' and 'CT' in the seed pointer table give the start and end addresses in the seed position table for hits of 'CT' in the reference. Starting with R = r0, r1, ...rn, we can define k-mers of R as a sliding sum over window size k, string concatenation operator, and R. 4 R. Snytsar and Y. Turakhia Minimizer seeds (or minimizers for short), an idea originally proposed for compressing large seed tables in 2004 by Roberts et al. [9], have seen a recent revival in bioinformatics with the advent long read alignment [7] and metage- nomics [15]. Minimizers can greatly reduce the storage requirements for the seed position table by storing only a subset of the seeds with only a small drop in sensitivity of the aligner. (a) (b) Fig. 2: Illustration of minimizer seeds using (k=3, w=3). (a) An example refer- ence sequence with a minimizer window sliding over 4 positions. The three seeds within the window are underlined in red and the minimizer seed within the win- dow is highlighted in bold. (b) Minimizer seed-position pairs as constructed from (a). Figure 2 illustrates how minimizers can be used to build a seed position table with an example. In addition to the seed size k, minimizers require a parameter w, the minimizer window size. In Figure 2, k = 3 and w = 3. In each position p of the reference R, a window w consecutive seeds of size k (k-mers) starting from position p in R are used to find the lexicograpically minimum seed s and its position p(cid:48), which is recorded in the seed position table. Adjacent windows can share the same minimizer (i.e. the (s, p(cid:48)) pair), which reduces the storage requirement for the seed position table. Figure 2a shows the minimizers for four consecutive positions 0-3 in R and the corresponding entries in the seed position table in Figure 2b. Windows at positions p = 1 and p = 2 share the same minimizer ('CTT', 2), which is stored only once in Figure 2b. Moreover, as seen in Figure 2b, seeds at position 0, 2 and 5 are stored in the seed position table but those at positions 1, 3 and 4 are dropped. Roberts et al. [9] have shown that with a minimizer window of size w, a new minimizer occurs every w/2 bases on average. Minimizers are a key innovation in Minimap [6] and its successor Minimap2 [7], both of which achieve an order of magnitude speedup over prior techniques, most speedup resulting from fewer seed hits per read due to minimizers. We have found that turning off minimizers (using w = 1 instead of the default w = 10) slows down the seeding and filtering stage of Minimap2 by nearly 7× with only 0.5% Parallel approach to sliding window sums 5 higher sensitivity for sequencing reads from Pacific Biosciences. As evident from figure 2, minimizer seed table construction is a form of sliding window sum with operator min over a window of k-mers, requiring O(wN ) for construction. It is possible to achieve O(N ) complexity at the cost of using elaborate queue-based data structures [12]. Constructing seed tables can take several hours for the de novo assembly of a human genome [13]. In this paper, we take a closer look at the connection between sliding sums and prefix sums, and attempt to supersede the linear complexity achieved by previous approaches. 3 Methods 3.1 Vector Algorithms Our first algorithm is a vector-friendly way of calculating sliding sum assuming the input sequence elements become available one by one and are processed using the vector instructions of width P > w: Algorithm 1 Scalar Input procedure ScalarInput(x0 . . . xn−1) xj, xj, . . . , xw−3 ⊕ xw−2, xw−2 (cid:17) , 0, . . . , 0 (cid:125) for i = w − 1 to N do xi, xi, . . . , xi , 0, . . . , 0 (cid:123)(cid:122) w−1 (cid:125) (cid:17) Y ←(cid:16) w−2(cid:88) (cid:124) X ←(cid:16) j=0 (cid:124) w−2(cid:88) j=1 (cid:123)(cid:122) w Y ← Y ⊕ X yi−w+1 ← Y [0] Y ← Y ≪ 1 end for end procedure Vector Y is initialized to the suffix sums with the number of elements de- creasing from w − 1 to 0. Then in a loop every incoming element xk is broadcast to the first w elements of vector X. After vector addition the zeroth element of Y contains the next sliding sum. Next, the vector Y is shifted left by one element, as denoted by operator ≪, and the state is ready for the next iteration. The data flow of the scalar algorithm is depicted on the Figure 3 tional requirements on the operator ⊕. Asymptotic complexity of the scalar input algorithm is O(N ) with no addi- This result could be improved if we assume that the input sequence arrives packed in vectors of width P > w. At every iteration P input elements are placed into vector X. X1 is filled with the prefix sums of up to w addends, and Y1 is filled with the suffix sums 6 R. Snytsar and Y. Turakhia Fig. 3: Data flow of the scalar input sliding sum algorithm. Algorithm 2 Vector Input procedure VectorInput(x0 . . . xn−1) xj, xj, . . . , xw−3 ⊕ xw−2, xw−2 w−2(cid:88) j=1 (cid:123)(cid:122) (cid:17) , 0, . . . , 0 (cid:125) Xj (cid:17) w−2(cid:88) (cid:125) p−2(cid:88) (cid:123)(cid:122) j=p−w w−1 j=0 w−1(cid:80) j=0 , Xj, . . . , (cid:17) Xj p−1(cid:80) (cid:17) j=p−w (cid:125) (cid:123)(cid:122) p−1(cid:88) w−1 j=p−w (cid:124) 0, . . . , 0, Xj, Xj, . . . , Xp−w j=0 Y ←(cid:16) w−2(cid:88) (cid:124) X ←(cid:16) X1 ←(cid:16) Y 1 ←(cid:16) (cid:124) w−1 for i = w − 1 to N step P do xk, xk+1, . . . , xk+p−1 X0, X0 ⊕ X1, . . . , Y ← Y ⊕ X1 yk−w+1 . . . yk−w+p ← Y [0] . . . Y [p − 1] Y ← Y 1 ≪ (P − w) end for end procedure Parallel approach to sliding window sums 7 Fig. 4: Data flow of the vector input sliding sum algorithm. constructed from the elements of X, as shown on the Figure 4. Then the vector sum of Y and X1 yields the next P output elements. Finally, the suffix sums from Y 1 are shifted into proper positions in vector Y , and it is ready for the next iteration. The asymptotic complexity thus is O(N · w/P ) with the parallel speedup O(P/w) for any operator ⊕. If ⊕ is associative, the prefix/suffix sums could be computed in parallel using the algorithm in [2], and the complexity is reduced to O(N · log(w)/P ) with the speedup improving to O(P/log(w)). For example, since min is an associative operator, the sliding window mini- mum can be computed using the faster version of the vector input algorithm. 4 Results We tested the performance of various sliding minimum algorithms using the hashed 15-mers of the reference human genome assembly (GRCh38) from the Genome Reference Consortium. The test imitates a minimizer based seed ta- ble construction by a long-read aligner, such as Minimap2 [7], GraphMap [11] or Darwin [13]. Figure 5 compares the performance of the naıve array-based algorithm, linear dequeue-based algorithm, and our proposed vector algorithm. Deque-based algorithm performance is indeed independent of the window size. It comes, however, at the cost of a significant overhead of managing the deque data structure and unpredictable branching. 8 R. Snytsar and Y. Turakhia 80 60 40 20 s e m T i Dequeue Array Vector 4 6 8 10 12 14 16 18 Window Size Fig. 5: Performance of the sliding minimum algorithms. Array-based algorithm, despite the worst asymptotic complexity, is simple to implement, and benefits from the automatic compiler vectorization. It is clear how the times drop when the window size is aligned with the SIMD vector width (P = 4, 8, and 16). For small window sizes the array algorithm is competitive with the deque approach. Our vector sliding sum algorithm beats both previous implementations by a factor of 5×. With the SSE/AVX instruction set, any window size requires the same number of instructions as the closest (larger) power of 2. So the perfor- mance of our vector implementation does not change linearly with w but drops when we switch to the different SIMD vector width P at w = 5, 9, 17. Also, prefix sum computation across wider vectors incurs additional latencies for cross-lane data exchanges, resulting in the speedup less than theoretical 2×. 5 Conclusion We introduced a family of algorithms for parallel evaluation of sliding window sums. The parallel speedup for window size w and number of processors P is O(P/w) for a generic sliding sum. For a sum with a commutative operator the speedup is improved to O(P/log(w)). For a family of sliding sums that al- low recurrent interpretations, the speedup is independent of w: O(P/log(P )). This gives the developer a choice of fast branchless algorithms suitable for im- plementation on any modern parallel architecture including modern CPUs with instruction-level parallelism, pipelined GPUs, or FPGA reconfigurable hardware. While we concentrate on the faster sliding window sum algorithms for bioin- formatics, our findings are relevant for accelerating all the numerous sliding Parallel approach to sliding window sums 9 window applications from compression and cryptography to high frequency data mining [5]. References 1. Altschul, S.F., Gish, W., Miller, W., Myers, E.W., Lipman, D.J.: Basic local align- ment search tool. Journal of Molecular Biology 215(3), 403 -- 410 (1990) 2. Blelloch, G.E.: Prefix sums and their applications. In: Synthesis of Parallel Algo- rithms. Morgan Kaufmann (1993) 3. Deorowicz, S., Kokot, M., Grabowski, S., Debudaj-Grabysz, A.: Kmc 2: fast and resource-frugal k-mer counting. Bioinformatics 31(10), 1569 -- 1576 (2015) 4. Harris, R.S.: Improved pairwise alignment of genomic DNA. ProQuest (2007) 5. Ikonomovska, E., Loskovska, S., Gjorgjevik, D.: A survey of stream data mining. In: Proceedings of 8th National Conference with International participation, ETAI. pp. 19 -- 21 (2007) 6. Li, H.: Minimap and miniasm: fast mapping and de novo assembly for noisy long sequences. Bioinformatics 32(14), 2103 -- 2110 (2016) 7. Li, H.: Minimap2: pairwise alignment for nucleotide sequences. Bioinformatics 1, 7 (2018) 8. Mar¸cais, G., Pellow, D., Bork, D., Orenstein, Y., Shamir, R., Kingsford, C.: Im- proving the performance of minimizers and winnowing schemes. Bioinformatics 33(14), i110 -- i117 (2017) 9. Roberts, M., Hayes, W., Hunt, B.R., Mount, S.M., Yorke, J.A.: Reducing storage requirements for biological sequence comparison. Bioinformatics 20(18), 3363 -- 3369 (2004) 10. Smith, T.F., Waterman, M.S.: Identification of common molecular subsequences. Journal of molecular biology 147(1), 195 -- 197 (1981) 11. Sovi´c, I., Siki´c, M., Wilm, A., Fenlon, S.N., Chen, S., Nagarajan, N.: Fast and sensitive mapping of nanopore sequencing reads with graphmap. Nature commu- nications 7, 11307 (2016) 12. Tangwongsan, K., Hirzel, M., Schneider, S.: Constant-time sliding window aggre- gation. IBM, IBM Research Report RC25574 (WAT1511-030) (2015) 13. Turakhia, Y., Bejerano, G., Dally, W.J.: Darwin: A genomics co-processor pro- vides up to 15,000 x acceleration on long read assembly. In: Proceedings of the Twenty-Third International Conference on Architectural Support for Program- ming Languages and Operating Systems. pp. 199 -- 213. ACM (2018) 14. Wood, D.E., Salzberg, S.L.: Kraken: ultrafast metagenomic sequence clas- R46 (Mar https://doi.org/10.1186/ sification using exact alignments. Genome Biology 15(3), 2014). gb-2014-15-3-r46 https://doi.org/10.1186/gb-2014-15-3-r46, 15. Wood, D.E., Salzberg, S.L.: Kraken: ultrafast metagenomic sequence classification using exact alignments. Genome biology 15(3), R46 (2014)
1901.00650
2
1901
2019-01-16T07:29:41
A Fast Sketch Method for Mining User Similarities over Fully Dynamic Graph Streams
[ "cs.DS" ]
Many real-world networks such as Twitter and YouTube are given as fully dynamic graph streams represented as sequences of edge insertions and deletions. (e.g., users can subscribe and unsubscribe to channels on YouTube). Existing similarity estimation methods such as MinHash and OPH are customized to static graphs. We observe that they are indeed sampling methods and exhibit a sampling bias when applied to fully dynamic graph streams, which results in large estimation errors. To solve this challenge, we develop a fast and accurate sketch method VOS. VOS processes each edge in the graph stream of interest with small time complexity O(1) and uses small memory space to build a compact sketch of the dynamic graph stream over time. Based on the sketch built on-the-fly, we develop a method to estimate user similarities over time. We conduct extensive experiments and the experimental results demonstrate the efficiency and efficacy of our method.
cs.DS
cs
A Fast Sketch Method for Mining User Similarities over Fully Dynamic Graph Streams 1MOE Key Laboratory for Intelligent Networks and Network Security, Xi'an Jiaotong University, China Peng Jia1, Pinghui Wang2,1, Jing Tao1,2,3, and Xiaohong Guan1,2,4 2Shenzhen Research Institute, Xi'an Jiaotong University, Shenzhen, China 3Zhejiang Research Institute, Xi'an Jiaotong University, Hangzhou, China 4Department of Automation and NLIST Lab, Tsinghua University, Beijing, China Email: {pengjia, phwang, jtao, xhguan}@sei.xjtu.edu.cn Abstract -- Many real-world networks such as Twitter and YouTube are given as fully dynamic graph streams represented as sequences of edge insertions and deletions. (e.g., users can subscribe and unsubscribe to channels on YouTube). Existing similarity estimation methods such as MinHash and OPH are customized to static graphs. We observe that they are indeed sampling methods and exhibit a sampling bias when applied to fully dynamic graph streams, which results in large estimation errors. To solve this challenge, we develop a fast and accurate sketch method VOS. VOS processes each edge in the graph stream of interest with small time complexity O(1) and uses small memory space to build a compact sketch of the dynamic graph stream over time. Based on the sketch built on-the-fly, we develop a method to estimate user similarities over time. We conduct extensive experiments and the experimental results demonstrate the efficiency and efficacy of our method. I. INTRODUCTION Many real-world network systems such as online social net- works (OSNs) and mobile phone networks are given as graph streams represented as sequences of edges over time, where entities are modeled as nodes and entity relations are modeled as edges. Estimating the similarities of users in large graph streams has been successfully used for applications such as duplicate detection [1] and collaborative filtering [2]. However, the graph streams studied in all these works only consist of edge insertions. In practice, real-world networks contain not only edge insertions but also deletions. For example, users on OSNs such as Twitter and Pinterest can follow other users, and can also unfollow users that they followed previously; users on YouTube can subscribe to interested channels, and can also unsubscribe from channels that they subscribed previously. For similarity estimation, MinHash [3] is a popular sketch method for approximately computing the Jaccard coefficient similarity, which builds a sketch of k registers with k distinct hash functions for each user and updates the minimum hash values of its subscribed items for each register. To reduce the memory usage of MinHash, [8], [9] develop methods b-bit minwise hashing and odd sketch, and the basic idea behind them is to use probabilistic methods such as sampling and sketching to build a compact digest for each user's MinHash sketch. b-bit minwise hashing, odd sketch, and MinHash *Pinghui Wang is the corresponding author. update each item with a high time complexity O(k). To solve this problem, Li et al. [4] further develop a method OPH and use only one hash functions to reduce the time complexity of updating each item from O(k) to O(1). Also there are many other works based on OPH such as [5], [6], [7] to improve its estimation accuracy. In detail, they fill empty registers generated from OPH by "rotation" with the value of the closest non-empty registers towards right [6], left or 2 [5], or based on tailored 2-universal right with probability 1 hashing [7]. [10], [11], [12], [13] develop a fast method to estimate the Jaccard coefficient between weighted vectors, where the general Jaccard coefficient between two positive (cid:80) real value vectors (cid:126)x = (x1, x2, . . . , xp) and (cid:126)y = (y1, y2, . . . , yp) (cid:80) 1≤j≤p min(xj ,yj ) is defined as J((cid:126)x, (cid:126)y) = 1≤j≤p max(xj ,yj ). Unfortunately, all these methods indeed are sampling methods customized for statistic datasets, but fail to uniformly sample edges from fully dynamic graph streams including item-subscriptions and item- unsubscriptions, which results in large estimation errors. To solve the above challenges, we develop a fast and accu- rate sketch method VOS (virtual odd sketch) for estimating the similarities of users occurred in fully dynamic graph streams. VOS processes each edge with small time complexity O(1) and uses small memory space to build a compact sketch of the graph stream over time. For each user, we build an odd sketch of its subscribed items on the fly, which is a binary sketch of k bits and embeds each subscribed item with xor (i.e., exclusive- or) operations. In graph streams, it is wasteful to assign a large k for each user to achieve reasonable estimation accuracy, especially for users with few subscribed items. Thus instead of directly keeping the odd sketch in memory, we store the sketch in k bits randomly selected from a shared bit array to reduce the memory usage. Based on the built virtual sketch, we develop a novel method to accurately estimate user similarities, and provide a theoretical proof for the estimation accuracy. We conduct extensive experiments on a variety of real-world graphs, and experimental results show that our method VOS is more accurate than state-of-the-art methods. II. PROBLEM FORMULATION In this paper, we focus on bipartite graphs, while our method can be easily extended to regular graphs. Let U u and I denote the set of users and items respectively. Let Π = e(1)e(2) ··· e(t) ··· denote the graph stream of interest, where e(t) = (u(t), i(t), a(t)) is the element (or, edge) of Π occurred at discrete time t > 0, u(t) ∈ U, i(t) ∈ I, and a(t) ∈ {" + ", " − "} are the tth element's user, item, and action (i.e., subscription and unsubscription). Let S(t) u be the u = ∅. set of items subscribed by user u at the end of time t, S(0) Similar to [14], [15], we restrict attention to "feasible" fully dynamic graph steams. In detail, if item i is in (resp. not in) the item set S(t−1) of user u, then element (u, i, " + ") (resp. element (u, i, " − ")) cannot occur in stream Π at time t. Let s(t) u,v denote the number of common items that users u and v v = subscribe to at time t and is computed as s(t) , where S refers to the cardinality of J(S(t) a set S. One can use a counter to easily keep tracking of the number of items (i.e., S(t) u ) subscribed by each user u over time t. Besides, another popular similarity measure the Jaccard S(t) coefficient J(S(t) can be v ) = S(t) easily computed from s(t) u,v, and vice versa. In this paper, we aim to develop a fast and accurate method to estimate s(t) u,v and J(S(t) v ) for any two users u and v over time. u +S(t) v ) v )+1 v u ∩S(t) v = u ∪S(t) v )(S(t) u ,S(t) u,v =S(t) s(t) u,v u +S(t) u ∩ S(t) u ,S(t) J(S(t) u , S(t) u , S(t) S(t) v −s(t) u,v III. SHORTCOMINGS OF EXISTING METHODS j (S2)) let h∗ k(S1) and h∗ (cid:80)k . . ., h∗ j=1 1(h∗ For any two sets S1 and S2, MinHash [3] applies k indepen- dent hash functions h1, . . . , hk to obtain an accurate estimation of J(S1, S2), where any hash function hj, 1 ≤ j ≤ k can be described as a random permutation from I to I itself. For a set S ⊂ I, j (S) denote the minimum hash value of items in S with respect to hash function hj, i.e., h∗ j (S) = mini∈S hj(i). Therefore, MinHash computes h∗ 1(S1), . . ., h∗ k(S2), and then estimates 1(S2), j (S1)=h∗ , where 1(P) J(S1, S2) as J(S1, S2) = k is an indicator function that equals 1 when predicate P is true and 0 otherwise. Actually, the MinHash sketch of a set S can be viewed as a vector of k items sampled with replacement from S using k hash functions respectively. Denote by φj(S) the item in S with the minimum hash value with respect to hash function hj, i.e., φj(S) = arg mini∈S hj(i). Because hash function hj maps items in I into distinct integers, i.e., hj(i1) (cid:54)= hj(i2) when i1 (cid:54)= i2, the MinHash sketch of S can be simply represented as a vector (φ1(S), . . . , φk(S)), where each element φj(S) is randomly sampled with replacement from S by function hj. For any two sets S1 and S2, we j (S2)), 1 ≤ j ≤ easily find that h∗ k. Therefore, the underlying MinHash sketch of the union φj(S1 ∪ S2) = φj(S1) when hj(φj(S1)) ≤ hj(φj(S2)) and φj(S2) otherwise. φj(S1∪S2) is an item in S1∩S2 if and only if φj(S1) = φj(S2), and we can have P (φj(S1) = φj(S2)) = S1∩S2 P (φj(S1 ∪ S2) ∈ (S1 ∩ S2)) = S1∪S2 = J(S1, S2). Moreover, one can extend MinHash to handle each element (u, i, a) arriving on fully dynamic stream Π as follows: case 1) when a = "+", update φj like a regular MinHash, i.e., set φj(Su) = i if φj(Su) = ∅ or hj(i) < hj(φj(Su)) and keep φj(Su) unchanged otherwise; case 2) when a = " − " and φj(Su) = i, j (S1 ∪ S2) = min(h∗ j (S1), h∗ set φj(Su) = ∅; case 3) when a = " − " and φj(Su) = ∅, keep φj(Su) =∅. However, this extension of MinHash samples an item not according to uniform distribution when item- unsubscriptions occur. The sampling bias is not only related with the number of user's subscribed items but also the order of item subscriptions and unsubscriptions occurred in stream Π. It is challenging to model and remove the sampling bias when a user has more than one unsubscriptions in stream Π. To reduce the time cost, OPH [4] only uses one hash function h to process each item, which is a random per- mutation from I = {0, 1, . . . , p − 1} to I itself and p is the maximum number of items. OPH equally divides I into k ), 1 ≤ j ≤ k. For a set S ⊂ I, , pj k bins: define S(h, j) = {i : i ∈ S ∧ h(i) ∈ [ p(j−1) k )}, and , pj then OPH computes a variable ophj(S) = h∗(S(h, j)) when S(h, j) (cid:54)= ∅ and ∅ otherwise. At last, it estimates J(S1, S2) as J(S1, S2) = , and the time complexity of updating each item is O(1). Similarly, OPH can also be treated as a sampling method and exhibits a sampling bias when there exist item-unsubscriptions in Π. (cid:80)k (cid:80)k j=1 1(ophj (S1)=ophj (S2)(cid:54)=∅) j=1 1(ophj (S1)(cid:54)=∅∨ophj (S2)(cid:54)=∅) [ p(j−1) k k Furthermore, there exist methods such as random pair- ing (RP) [14] for uniformly sampling from dynamic graph streams. One can extend RP to sample k items (φj(Su))1≤j≤k (resp. (φj(Sv))1≤j≤k) from S(t) v ). In this case, u (φj(Su))1≤j≤k and (φj(Sv))1≤j≤k generated are indepen- dent, i.e., φj(Su) = φj(Sv) happens with probability SuSv, which significantly differs from the probabilistic model of MinHash. Therefore, the number of common items can be estimated as su,v =SuSv(cid:80)k j=1 1(φj(Su) = φj(Sv)). (resp. S(t) 1 IV. OUR SKETCH METHOD u u of set S(t) u u [j] = ⊕i∈S(t) u into A. Formally, O(t) Our sketch method VOS consists of a one-dimension bit array A of length m, a hash function ψ that maps items into integers in {1, . . . , k} at random, and k independent hash functions f1, . . . fk that map users into integers in {1, . . . , m} at random. As shown in Figure 1,for each user u, we virtually build an odd sketch O(t) on the fly and embed O(t) u is a bit array of length k, where u [j] is the parity of the number of items in S(t) each bit O(t) u of which hash value equals j with respect to function ψ, 1(ψ(i) = j), 1 ≤ j ≤ k, where ⊕ i.e., O(t) is the xor operation. The above equation tells us that any two elements (u, i, " + ") and (u, i, " − ") occurred before and including time t offset to each other and they together are irrelevant to the value of O(t) u . Our method VOS differs from the original odd sketch method [9] in two aspects: 1) We directly build an odd sketch O(t) for each user u rather than generate a MinHash sketch first; 2) We do not directly store the odd sketch O(t) in memory, but use hash u functions f1, . . . fk to randomly select k bits from a shared bit array A to approximately store O(t) u . In addition, for each occurred user u, we use a counter nu to keep tracking of the number of its subscribed items over time. We also update bit array A and a counter β as A[fψ(i)(u)] ← A[fψ(i)(u)] ⊕ 1, u of S(t) u β ← β + 2[(A[fψ(i)(u)]⊕1)− 1 , where β is initialized to 0 and used to keep tracking of the fraction of 1-bits in A over time, Thus, the time complexity of updating each element is O(1). 2 ] m Figure 1. Overview of our method VOS. The red and bold bits are contaminated. At time t, for each bit O(t) u [j] is the last bit hashed into A. Let β(t) u [j], i.e. A[fj(u)] ← A[fj(u)]⊕O(t) u [j], 1 ≤ j ≤ k, we randomly select a bit from A using hashing function fj and xor the bit with O(t) u [j]. We easily find that the value of A at time t is irrelevant with the order of occurred users and the order of the bits in their odd sketches iterated in the above procedure. Therefore, we assume that O(t) u,j is the fraction of 1-bits in A before the event of hashing O(t) u [j] into A. We easily obtain that O(t) u [j] is hashed into a 1-bit in A with probability β(t) u [j] into A changes at most one bit in A, therefore we have β(t) m. In this paper, u,j as β(t) because m (cid:29) 1000. Based on the we approximate β(t) above observations, we model our method VOS as: we rebuild each bit O(t) u [j] = A[fj(u)], which does not equal O(t) u [j] with probability P ( O(t) u,j − β(t) ≤ 1 u [j] at time t as O(t) u,j. Hashing O(t) u [j] (cid:54)= O(t) u [j]) = β(t). j=1 u,v[j] O(t) k To estimate the similarity s(t) u,v of two users u and v, we first u and O(t) u,v by combining O(t) v using the (cid:80)k u [j] ⊕ O(t) v [j]. Define α(t) u,v[j] = O(t) u,v as u,v, α(t) u,v = v ) ∪ (S(t) v =(S(t) u,v[j] = 1) = 1−(1−2/k)n v [j] (cid:54)= O(t) compute a sketch O(t) xor operation, i.e., O(t) the fraction of 1-bits in O(t) , and n(t) u∆v as the cardinality of the symmetric difference of sets S(t) u and u ). v − S(t) u ∆S(t) S(t) v , i.e., n(t) From [9], we obtain P (O(t) . Since P ( O(t) v [j]) = β(t) we easily obtain P ( O(t) u,v[j] = 1) + 2β(t)(1− β(t))P (O(t) Then we have u,v[j] = 1) = ((β(t))2 + (1 − β(t))2)P (O(t) u,v[j] = 0) = 1−(1−2β(t))2(1−2/k)n u [j] (cid:54)= O(t) u∆v =S(t) u [j]) = P ( O(t) u − S(t) (t) u∆v (t) u∆v 2 2 . E(α(t) u,v) = (cid:17) E (cid:16)(cid:80)k ≈ 1 − (1 − 2β(t))2e−2n(t) j=1 1( O(t) k u,v[j] = 1) u∆v/k . 2 According to the above equation, we estimate n(t) u∆v as u,v) − 2 ln(1 − 2β(t))) . n(t) u∆v = − k(ln(1 − 2α(t) u,v = n(t) v −n(t) u +n(t) 2 u∆v 2 Since s(t) , then we estimate s(t) u,v as s(t) u,v = n(t) u + n(t) v 2 + k(ln(1 − 2α(t) u,v) − 2 ln(1 − 2β(t))) 4 . We easily find that the time complexity of computing s(t) u,v is O(k). Moreover, the Jaccard coefficient J(S(t) v ) can be estimated as J(S(t) . Furthermore, the nu+nv−s(t) expectation and variance of its estimate s(t) u,v are computed as − e4n(t) − kβ(t)e2n(t) u , S(t) u , S(t) u,v) ≈ s(t) E(s(t) v ) = u,v + u∆v/k s(t) u,v u,v u∆v/k (1 − 2β(t))2 1 8 , 8(1 − 2β(t))4 ke4n(t) u∆v/k 16(1 − 2β(t))4 . Var(s(t) u,v) ≈ − k 16 + k2β(t)e2n(t) u∆v/k 2(1 − 2β(t))2 V. EVALUATION + We perform our experiments on several publicly available real-world datasets YouTube, Flickr, Orkut and LiveJour- nal [16]. To generate fully dynamic graph streams includ- ing item-subscriptions and item-unsubscriptions, we follow the experiment settings in [15] and set the parameters as q = 2, 000, 000−1 and d = 0.5, which means there is a massive deletion of expected 50% edges every 2, 000, 000 edges in each graph dataset. Specially, we mainly focus on similarity estimation for users with a large number of subscribed items, which requires extremely large memory and computational resources for similarity estimation. Therefore, in our experiments, we first select 5, 000 users with largest cardinalities to generate user pairs of any two users in each graph dataset, and then retain the set of user pairs that have at least one common item to keep tracking of over time. u , S(t) We employ three baselines MinHash, OPH and RP as described in Section II and III to compare with our method VOS for estimating similarities over time. Here we use the metrics average absolute percentage error (AAPE) to measure the accuracy of estimating the number of common items s(t) u,v, and average root mean square error (ARMSE) to eval- uate the performance of estimating the Jaccard coefficient similarity J(S(t) v ) over time. Formally, the metrics are u,v−s(t) defined respectively as AAPE(t) = 1P s(t) u,v v )−J(S(t) u ,S(t) P and ARMSE(t) = . In our experiments, we compare the performance of all these methods under the same memory size m = 32kU bits, where the memory size of each value of the k registers in its generated sketch for each user u ∈ U is set as 32 bits. As for the parameter k for the size of virtual odd sketch of our method VOS, we can enumerate all possible values from 1 to max- cardinality to find an optimal value for each graph dataset, which minimizes either AAPE(t) or ARMSE(t) of selected (cid:80) (u,v)∈P s(t) (cid:114)(cid:80) (u,v)∈P ( J(S(t) u ,S(t) v ))2 u,v (cid:1)(cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:10)(cid:3)(cid:4)(cid:4)(cid:3)(cid:11)(cid:12)(cid:6)(cid:6)(cid:10)(cid:1)(cid:13)(cid:5)(cid:9)(cid:14)(cid:2)(cid:10)(cid:12)(cid:15)(cid:10)(cid:16)(cid:1)(cid:5)(cid:4)(cid:10)(cid:1)(cid:17)(cid:18)…(cid:18)(cid:18)(cid:18)…(cid:17)(cid:18)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:17)(cid:18)(cid:17)(cid:17)(cid:18)(cid:18)(cid:17)…(cid:18)(cid:18)(cid:1)…(cid:17)(cid:5)(cid:19)(cid:7)(cid:5)(cid:6)(cid:6)(cid:8)(cid:20)(cid:21)(cid:12)(cid:22)(cid:5)(cid:4)(cid:3)(cid:9)(cid:12)(cid:4)(cid:4)(cid:5)(cid:7)(cid:16)(cid:8)(cid:23)(cid:9)(cid:10)(cid:10)(cid:12)(cid:6)(cid:6)(cid:10)(cid:1)(cid:13)(cid:5)(cid:9)(cid:14)(cid:2)(cid:12)(cid:15)(cid:10)(cid:16)(cid:1)(cid:5)(cid:4)(cid:10)(cid:1)(cid:12)(cid:6)(cid:6)(cid:10)(cid:1)(cid:13)(cid:5)(cid:9)(cid:14)(cid:2)(cid:10)(cid:12)(cid:15)(cid:10)(cid:16)(cid:1)(cid:5)(cid:4)(cid:10)(cid:2)(cid:4)(cid:5)(cid:7)(cid:16)(cid:8)(cid:23)(cid:9)(cid:10)(cid:10)(cid:12)(cid:6)(cid:6)(cid:10)(cid:1)(cid:13)(cid:5)(cid:9)(cid:14)(cid:2)(cid:12)(cid:15)(cid:10)(cid:16)(cid:1)(cid:5)(cid:4)(cid:10)(cid:2)⊕⊕⊕⊕⊕⊕⊕⊕⊕⊕⊕⊕⊕⊕(cid:1) VI. CONCLUSIONS In this paper, we observe that state-of-the-art similarity estimation methods MinHash and OPH are indeed sampling methods for graph streams consisting of only item insertions, and exhibit a sampling bias for fully dynamic graph streams. To solve this problem, we develop a sampling method VOS. VOS uniformly samples at most k connected items for each user. It fast processes each edge in the graph stream with small time complexity O(1). Based on two users' sampled items, we propose a fast method to estimate not only the Jaccard coefficient between their connected items but also the number of their common connected items. We perform experiments on a variety of publicly available graphs, and experimental results demonstrate that our method VOS significantly outperforms the state-of-the-art methods. ACKNOWLEDGMENT The research presented in this paper supported in part by National Key R&D Program of China (2018YFC0830500), National Natural Science Foundation of China (U1736205, 61603290), Shenzhen Basic Research Grant (JCYJ20170816100819428), Natural Science Basic Re- search Plan in Shaanxi Province of China (2016JQ6034). is REFERENCES [1] W. Xia, H. Jiang, D. Feng, and Y. Hua, "Silo: A similarity-locality based near-exact deduplication scheme with low ram overhead and high throughput," in USENIX ATC, 2011, pp. 26 -- 28. [2] G. Guo, J. Zhang, and N. Yorke-Smith, "Trustsvd: Collaborative filtering with both the explicit and implicit influence of user trust and of item ratings," in AAAI, 2015, pp. 123 -- 129. [3] A. Z. Broder, M. Charikar, A. M. Frieze, and M. Mitzenmacher, "Min- wise independent permutations," J. Comput. Syst. Sci., vol. 60, no. 3, pp. 630 -- 659, 2000. [4] P. Li, A. B. Owen, and C. Zhang, "One permutation hashing," in NIPS, 2012, pp. 3122 -- 3130. [5] A. Shrivastava and P. Li, "Improved densification of one permutation hashing," in UAI, 2014, pp. 732 -- 741. [6] -- -- , "Densifying one permutation hashing via rotation for fast near neighbor search," in ICML, 2014, pp. 557 -- 565. [7] A. Shrivastava, "Optimal densification for fast and accurate minwise hashing," in ICML, 2017, pp. 3154 -- 3163. [8] P. Li and A. C. Konig, "b-bit minwise hashing," in WWW, 2010, pp. 671 -- 680. [9] M. Mitzenmacher, R. Pagh, and N. Pham, "Efficient estimation for high similarities using odd sketches," in WWW, 2014, pp. 109 -- 118. [10] S. Ioffe, "Improved consistent sampling, weighted minhash and l1 sketching," in ICDM, 2010, pp. 246 -- 255. [11] A. Shrivastava, "Simple and efficient weighted minwise hashing," in NIPS, 2016, pp. 1498 -- 1506. [12] W. Wu, B. Li, L. Chen, and C. Zhang, "Canonical consistent weighted sampling for real-value weighted min-hash," in ICDM, 2016, pp. 1287 -- 1292. [13] -- -- , "Consistent weighted sampling made more practical," in WWW, 2017, pp. 1035 -- 1043. [14] R. Gemulla, W. Lehner, and P. J. Haas, "Maintaining bounded-size sample synopses of evolving datasets," The VLDB Journal, vol. 17, no. 2, pp. 173 -- 201, 2008. [15] L. D. Stefani, A. Epasto, M. Riondato, and E. Upfal, "Tri`est: Counting local and global triangles in fully-dynamic streams with fixed memory size," in KDD, 2016. [16] A. Mislove, M. Marcon, K. P. Gummadi, P. Druschel, and B. Bhat- tacharjee, "Measurement and analysis of online social networks," in SIGCOMM IMC, 2007, pp. 29 -- 42. (a) YouTube (b) All Datasets Figure 2. Runtime of our method VOS in comparison with MinHash, OPH, and RP for different memory space m (bits). (a) YouTube (b) All Datasets (c) YouTube (d) All Datasets Figure 3. Accuracy of our method VOS in comparison with MinHash, OPH, and RP for different memory space m (bits) when k = 100. user pairs at any time t. Also we can directly set it as λ times (i.e., λ = 2, 3, . . .) larger than the memory space used by each sketch of MinHash, OPH and RP. In the later experiments, we set λ = 2. Figure 2 (a) shows the runtime of our method VOS in comparison with other three baselines in the dataset YouTube when the sketch size k varies from 1 to 105, and Figure 2 (b) shows the runtime of all methods when k = 105. In our experiments, we measure the runtime during which we implement all four methods respectively to update the sketch for each user. We can see that our method VOS and OPH are faster than MinHash and RP, and only require the time complexity O(1). Meanwhile, we fix the sketch size k = 100 and then compare the estimation accuracy of all four methods. The experimental results are shown in Figure 3. Figures 3 (a) and (c) show the accuracy of estimating s(t) u , S(t) v ) in dataset YouTube over time respectively, and Figures 3 (b) and (d) show the accuracy in all datasets at time t when all elements in graph streams arrive. We observe that our method VOS are more accurate than other three methods and significantly reduce the estimation bias for fully dynamic graph streams. u,v and J(S(t)         2    7:392080.43/83,8 !#!' $4:%:-0.7 7:9;04:73,       7:392080.43/8' $ !#!3,8 9      !×1063,8 !#!' $4:%:-0.7 7:9;04:73,     !' $ !#!3,8 9     #$×1063,8 !#!' $4:%:-0.7 7:9;04:73,     #$' $ !#!3,8
1110.4604
2
1110
2011-11-02T01:45:34
Improving Christofides' Algorithm for the s-t Path TSP
[ "cs.DS" ]
We present a deterministic (1+sqrt(5))/2-approximation algorithm for the s-t path TSP for an arbitrary metric. Given a symmetric metric cost on n vertices including two prespecified endpoints, the problem is to find a shortest Hamiltonian path between the two endpoints; Hoogeveen showed that the natural variant of Christofides' algorithm is a 5/3-approximation algorithm for this problem, and this asymptotically tight bound in fact has been the best approximation ratio known until now. We modify this algorithm so that it chooses the initial spanning tree based on an optimal solution to the Held-Karp relaxation rather than a minimum spanning tree; we prove this simple but crucial modification leads to an improved approximation ratio, surpassing the 20-year-old barrier set by the natural Christofides' algorithm variant. Our algorithm also proves an upper bound of (1+sqrt(5))/2 on the integrality gap of the path-variant Held-Karp relaxation. The techniques devised in this paper can be applied to other optimization problems as well: these applications include improved approximation algorithms and improved LP integrality gap upper bounds for the prize-collecting s-t path problem and the unit-weight graphical metric s-t path TSP.
cs.DS
cs
Improving Christofides’ Algorithm for the s-t Path TSP Hyung-Chan An ∗ Robert Kleinberg † David B. Shmoys ‡ Abstract We present a deterministic(cid:16) 1+√5 2 (cid:17)-approximation algorithm for the s-t path TSP for an arbitrary metric. Given a symmetric metric cost on n vertices including two prespecified endpoints, the problem is to find a shortest Hamiltonian path between the two endpoints; Hoogeveen showed that the natural variant of Christofides’ algorithm is a 5/3-approximation algorithm for this problem, and this asymp- totically tight bound in fact has been the best approximation ratio known until now. We modify this algorithm so that it chooses the initial spanning tree based on an optimal solution to the Held-Karp relaxation rather than a minimum spanning tree; we prove this simple but crucial modification leads to an improved approximation ratio, surpassing the 20-year-old barrier set by the natural Christofides’ algorithm variant. Our algorithm also proves an upper bound of 1+√5 on the integrality gap of the path- variant Held-Karp relaxation. The techniques devised in this paper can be applied to other optimization problems as well: these applications include improved approximation algorithms and improved LP integrality gap upper bounds for the prize-collecting s-t path problem and the unit-weight graphical metric s-t path TSP. 2 1 1 0 2 v o N 2 ] S D . s c [ 2 v 4 0 6 4 . 0 1 1 1 : v i X r a ∗[email protected]. Dept. of Computer Science, Cornell University, Ithaca, NY 14853. Research supported in part by NSF under grants no. CCF-1017688 and CCF-0729102, and the Korea Foundation for Advanced Studies. Part of this research was conducted while the author was a visiting student at CSAIL, MIT. †[email protected]. Dept. of Computer Science, Cornell University, Ithaca, NY 14853. Supported by NSF grants CCF-0643934 and CCF-0729102, AFOSR grant FA9550-09-1-0100, a Microsoft Research New Faculty Fellowship, a Google Research Grant, and an Alfred P. Sloan Foundation Fellowship. ‡[email protected]. School of ORIE and Dept. of Computer Science, Cornell University, Ithaca, NY 14853. Research supported in part by NSF under grants no. CCF-0832782 and CCF-1017688. Part of this research was conducted while the author was a visiting professor at Sloan School of Management, MIT. 1 Introduction After 35 years, Christofides’ 3/2-approximation algorithm [8] still provides the best performance guarantee known for the metric traveling salesman problem (TSP), and improving upon this bound is a fundamental open question in combinatorial optimization. For the path variant of the metric TSP in which the aim is to find a shortest Hamiltonian path between given endpoints s and t, Hoogeveen [17] showed that the natural variant of Christofides’ algorithm yields an approximation ratio of 5/3 that is asymptotically tight, and this has been the best approximation algorithm known for this s-t path variant for the past 20 years. Recently, there has been progress for the special case of metrics derived as shortest paths in unit-weight (undirected) graphs: Oveis Gharan, Saberi, and Singh [20] gave a (3/2 − ǫ0)-approximation algorithm for the TSP, which can be extended to yield an analogous result of a (5/3 − ǫ1)-approximation algorithm for the s-t path TSP in the same special case (see Appendix A). Momke and Svensson [18] gave a 1.4605- approximation algorithm for the same special case of the TSP, as well as a 1.5858-approximation algorithm for the s-t path TSP in the same case (where the results of Appendix A and Momke & Svensson [18] were obtained independently). We note the techniques devised in these results for the unit-weight graphical metric case proved useful in both path and ordinary (circuit) variants. The main result of this paper is to provide the first improvement for the general metric case of the s-t path TSP: more specifically, we give a deterministic (cid:16) 1+√5 2 (cid:17)-approximation algorithm for the metric s-t path TSP for an arbitrary metric, breaking the 5/3 barrier. It remains an open question whether these techniques can be extended to yield a comparable improvement (over the 3/2 barrier) for the general-metric ordinary (circuit) TSP. Our analysis gives the first constant upper bound on the integrality gap of the path-variant Held-Karp relaxation as well, showing it to be at most the golden ratio, 1+√5 . We will also demonstrate how the techniques devised in the present paper can be applied to other problems, such as the prize-collecting s-t path problem and the unit-weight graphical metric s-t path TSP, to obtain better approximation ratios and better LP integrality gap upper bounds than the current best known. 2 Proposed by Held and Karp [16] originally for the circuit problem, the Held-Karp relaxation [16] is a standard LP relaxation to (the variants of) TSP, and has been successfully used by many algorithms [6, 12, 4, 2, 20, 18, 19]. In the LP-based design of an approximation algorithm, one important measure of the strength of a particular LP relaxation is its integrality gap, i.e., the worst-case ratio between the integral and fractional optimal values; however, there exists a significant gap between currently known lower and upper bounds on the integrality gap of the Held-Karp relaxation. For the circuit case, the best upper bound known of 3/2 is constructively proven by the analyses of Christofides’ algorithm due to Wolsey [22] and Shmoys & Williamson [21]; yet, the best lower bound known is 4/3, achieved by the family of graphs depicted in Figure 1(a) under the unit-weight graphical metric [11]. For the path problem, Hoogeveen [17] shows the natural variant of Christofides’ algorithm is a 5/3-approximation algorithm, but the analysis compares the output solution value to the optimal (integral) solution; therefore it is unclear whether the algorithm yields an integrality gap bound for the Held-Karp relaxation formulated for the path problem. The analysis of the present algorithm, in contrast, reveals an upper bound of 1+√5 on its integrality gap, matching the approximation ratio; we also show in Appendix A that an LP-based analysis of Christofides’ algorithm proves a weaker upper bound of 5/3. We observe that the family of graphs in Figure 1(b) establishes the integrality gap lower bound of 3/2 under the unit-weight graphical metric. Note that this lower bound is strictly greater than the known upper bound of (3/2 − ǫ0) on the integrality gap of the circuit-variant Held-Karp relaxation under the unit-weight graphical metric; this suggests that the lack of a performance guarantee known for the s-t path TSP matching the 3/2 for other TSP variants has a true structural cause. 2 1 s t (a) (b) Figure 1: Examples establishing the integrality gap lower bounds for the circuit- and path-variant Held- Karp relaxations. s … t Figure 2: Example showing 5/3 is asymptotically tight [17]: a minimum spanning tree is marked with thick edges. A feasible solution to the path-variant Held-Karp relaxation is in the spanning tree polytope; thus, given a feasible Held-Karp solution, there exists a probability distribution over spanning trees whose marginal edge probabilities coincide with the Held-Karp solution. The present algorithm first computes an optimal solution to the Held-Karp relaxation, and samples a spanning tree from a probability distribution whose marginal is given by the Held-Karp solution. Then it augments this tree with a minimum T -join, where T is the set of vertices with “wrong” parity of degree, to obtain an Eulerian path visiting every vertex; this Eulerian path can be shortcut into an s-t Hamiltonian path of no greater cost. Our analysis of this algorithm shows that the expected cost of the Eulerian path is at most 1+√5 times the Held-Karp optimum; the analysis relies only on the marginal probabilities, and therefore holds for any arbitrary distribution with the given marginals. We note that this flexibility enables a simple derandomization: a feasible Held-Karp solution can be efficiently decomposed into a convex combination of polynomially many spanning trees (see Grotschel, Lov´asz, and Schrijver [15]) and trying every spanning tree in this convex combination yields a simple deterministic algorithm. We also note that our algorithm differs from Christofides’ in only one crucial respect: rather than taking a single tree and augmenting it with a T -join, we try out polynomially many trees and then take the one whose augmentation yields the lowest-cost path. The example in Figure 2 due to Hoogeveen [17] shows that this simple modification of the original algorithm is crucial to achieving the improved approximation ratio: if one only tries augmenting the minimum spanning tree, the approximation ratio remains no better than 5/3. 2 As the expected cost of the sampled spanning tree is equal to the Held-Karp optimum, the rest of the analysis focuses on bounding the cost of the minimum T -join by providing a low-cost fractional T -join dominator that serves as an upper bound on the cost of the minimum T -join. First we show that the Held-Karp solution and the spanning tree, while being costly fractional T -join dominators themselves, are complementary: a certain linear combination of them is a fractional T -join dominator whose expected cost is no greater than 2/3 times the Held-Karp optimum, thereby recovering the same 5/3 performance guarantee provided by Hoogeveen’s analysis of Christofides’ algorithm. Based on this beginning analysis, we present progressively better ways of constructing a low-cost fractional T -join dominator. In all of these approaches, we perturb the coefficients of the tree and the Held-Karp solution to reduce the cost of their linear combination, at the expense of potentially violating some constraints of the fractional T -join dominator linear program, and then we add a low-cost correction to repair the violated constraints. To 2 construct this correction vector and to bound its cost, we show that the only potentially violated constraints correspond to narrow cuts having a layered structure, as illustrated in Figure 3. The layered structure allows us to choose disjoint sets of representative edges for each cut and to correct the violated constraints using a sum of vectors each supported on the representative edge set of the corresponding narrow cut. We show that this idea leads to a slight improvement upon 5/3, using the fact that the representative edge sets, while being mutually disjoint, occupy a large portion of each cut and that each narrow cut constraint has only a small probability of being violated. After that, we present a tighter analysis with a similar construction. Finally, pushing the performance guarantee towards the golden ratio requires relaxing the disjointness of the representatives to a notion of “fractional disjointness”. We define this relaxed disjointness, construct the requisite fractionally disjoint vectors via the analysis of an auxiliary flow network, and prove the performance guarantee of 1+√5 . We note that neither the fractional T -join dominator nor the narrow cuts are actually computed by the algorithm: these progressive analyses all analyze the same single algorithm while different fractional T -join dominators are considered in each analysis. That is, it might be possible to obtain a better performance guarantee for the same algorithm by providing a better construction of a fractional T -join dominator. The narrow cuts are purely for the purpose of analysis in Section 3 and never determined by the algorithm; however, their algorithmic use is explored in Section 4. 2 Section 4 demonstrates how the present results can be applied to other problems to obtain better ap- proximation algorithms than the current best known. We first consider the metric prize-collecting s-t path problem. In a prize-collecting problem, we are given “prize” values defined on vertices, and the objective function becomes the sum of the “regular” solution cost and the total “missed” prize of the vertices that are not included in the solution. For example, the prize-collecting s-t path problem finds a (not necessarily spanning) s-t path that minimizes the sum of the path cost and the total prize of the vertices not on the path. Chaudhuri, Godfrey, Rao, and Talwar [7] give a primal-dual 2-approximation algorithm for this problem. Prize-collecting TSP, the circuit version of this problem, has been introduced in Balas [5]; Bienstock, Goe- mans, Simchi-Levi, and Williamson [6] give a LP-rounding 2.5-approximation algorithm, and Goemans & Williamson [14] show a primal-dual 2-approximation algorithm. For both problems, Archer, Bateni, Ha- jiaghayi, and Karloff [3] give improvement on approximation ratios: using the path-variant Christofides’ algorithm as a black box, Archer et al. give a 241/121-approximation algorithm for the prize-collecting s-t path problem; a 97/49-approximation algorithm is given for the prize-collecting TSP, using Christofides’ algorithm as a black box again. For the prize-collecting (circuit) TSP, Goemans [12] combines Bienstock et al. [6] and Goemans & Williamson [14] to obtain a 1.9146-approximation algorithm, the current best known. As the analysis of Archer et al. [3] treats Christofides’ algorithm as a black box, replacing this with the present algorithm readily gives an improvement. Furthermore, we will show that, since the present analysis produces the performance guarantee in terms of the Held-Karp optimum, Goemans’ analysis [12] can be extended to the prize-collecting s-t path problem. One obstacle is that the parsimonious property [13] used in Bienstock et al. does not immediately apply to the path case; however, we prove that a modification to the graph and the Held-Karp solution allows us to utilize this property. This yields a 1.9535-approximation algorithm for the prize-collecting s-t path problem; the same upper bound is established on the integrality gap of the LP relaxation used. Secondly, we study the unit-weight graphical metric s-t path TSP to present a 1.5780-approximation algorithm. As discussed above, there has been progress for this special case in both the ordinary (circuit) TSP and the s-t path TSP. In Appendix A, we show how the results of Oveis Gharan et al. [20] extend to the path case. Most recently, Mucha [19] gave an improved analysis of Momke & Svensson’s algorithm [18] to prove the performance guarantee of 13/9 for the circuit case and 19/12 + ǫ for the path case, for any 3 ǫ > 0. We observe that the critical case of this analysis is when the Held-Karp optimum is small, and we show how to obtain an algorithm that yields a better performance guarantee on this critical case, based on the main results of this paper. In particular, we devise an algorithm that works on narrow cuts to be run in parallel with the present algorithm; this illustrates that the narrow cuts are a useful algorithmic tool as well, not only an analytic tool. Our algorithm establishes an upper bound on the integrality gap of the path-variant Held-Karp relaxation under the unit-weight graphical metric, which does not match the performance guarantee but smaller than 1+√5 . 2 2 Preliminaries In this section, we introduce some definitions and notation to be used throughout this paper. Let G = (V, E) be the input complete graph with metric cost function c : E → R+. Endpoints s, t ∈ V are given as a part of the input; we call the other vertices internal points. i.e., For A, B ⊂ V such that A ∩ B = ∅, E(A, B) denotes the set of edges between A and B: E(A, B) = {{u, v} ∈ Eu ∈ A, v ∈ B}. Let E(A) denote the set of edges within A: E(A) := {{u, v} ∈ Eu, v ∈ A}. For nonempty U ( V , let (U, ¯U ) denote the cut defined by U, and δ(U ) be the edge set in the cut: δ(U ) = E(U, ¯U ). (U, ¯U ) is called an s-t cut if U ∩ {s, t} = 1; we call (U, ¯U ) nonseparating otherwise. For x, c ∈ RE and F ⊂ E, x(F ) is a shorthand for Pf∈F xf ; c(x) is Pe∈E cexe. The incidence vector χF ∈ RE of F ⊂ E is a (0, 1)-vector defined as follows: (χF )e :=(1 if e ∈ F, 0 otherwise. For two vectors a, b ∈ RI, let a ∗ b ∈ RI denote the vector defined as: Definition 1 ([16]). The path-variant Held-Karp relaxation is defined as follows: (a ∗ b)i := aibi. c(x) minimize subject to x(δ(S)) ≥ 1, x(δ(S)) ≥ 2, x(δ({s})) = x(δ({t})) = 1; x(δ({v})) = 2, x ≥ 0. ∀S ( V,{s, t} ∩ S = 1; ∀S ( V,{s, t} ∩ S 6= 1, S 6= ∅; ∀v ∈ V \ {s, t}; (1) This linear program can be solved in polynomial time via the ellipsoid method using a min-cut algo- rithm to solve the separation problem [15]. The following observation gives an equivalent formulation of (1). Observation 1. Following is an equivalent formulation of (1): c(x) minimize subject to x(E(S)) ≤ S − 1, x(E(S)) ≤ S − 2, x(δ({s})) = x(δ({t})) = 1; x(δ({v})) = 2, x ≥ 0. ∀S ( V,{s, t} 6⊆ S, S 6= ∅; ∀S ( V,{s, t} ⊆ S; ∀v ∈ V \ {s, t}; 4 Definition 2. For T ⊂ V and J ⊂ E, J is a T -join if the set of odd-degree vertices in G′ = (V, J) is T . Edmonds and Johnson [10] give a polyhedral characterization of T -joins: let PT (G) be the convex hull of the incidence vectors of the T -joins on G = (V, E); PT (G) + RE + is exactly characterized by (y(δ(S)) ≥ 1, ∀S ⊂ V,S ∩ T odd; y ∈ RE +. (2) We call a feasible solution to (2) a fractional T -join dominator. Lastly, the polytope defined by the path-variant Held-Karp relaxation is contained in the spanning tree polytope of the same graph; thus, given a feasible solution x∗ to the path-variant Held-Karp relaxation, i=1 λi = 1, there exist spanning trees T1, . . . , Tk and λ1, . . . , λk ∈ R+ such that x∗ =Pk where k is bounded by a polynomial. This follows from Grotschel, Lov´asz, and Schrijver [15]. i=1 λiχTi andPk 3 Improving upon 5/3 We present the algorithm for the metric s-t path TSP and its analysis in this section. 3.1 Algorithm Given a complete graph G = (V, E) with cost function c : E → R+ and the endpoints s, t ∈ V , the algorithm first computes an optimal solution x∗ to the path-variant Held-Karp relaxation. Then it decomposes x∗ into a convex combination P λiχTi of polynomially many spanning trees T1, . . . , Tk with coefficients λ1, . . . , λk ≥ 0; a spanning tree T is sampled among these spanning trees Ti’s from the probability distribution given by λi’s. This decomposition can be performed in polynomial time, as noted in Section 2. Let T ⊂ V be the set of the vertices with the “wrong” parity of degree in T : i.e., T is the set of odd-degree internal points and even-degree endpoints in T . The algorithm finds a minimum T -join J and an s-t Eulerian path of the multigraph T ∪ J. This Eulerian path is shortcut to obtain a Hamiltonian path H between s and t; H is the output of the algorithm. We note that this algorithm can be derandomized by trying each Ti instead of sampling T . Observe that E[c(H)] ≤ ρc(x∗) implies that the derandomized algorithm is a deterministic ρ-approximation algo- rithm. In the rest of this section, we prove the following theorem. Theorem 1. The present algorithm returns a Hamiltonian path between s and t whose expected cost is no more than 1+√5 s-t path TSP. Corollary 1. The integrality gap of the path-variant Held-Karp relaxation is at most 1+√5 c(x∗). Therefore, there exists a deterministic(cid:16) 1+√5 2 (cid:17)-approximation algorithm for the 2 . 2 3.2 Proof of 5/3-approximation In this subsection, we present a simple proof that the present algorithm is a (expected) 5/3-approximation algorithm. Improved analyses are presented in later subsections based on this simple proof. We can understand the well-known 2-approximation algorithm for the circuit TSP and Christofides’ 3/2-approximation algorithm as respectively using the minimum spanning tree and half the Held-Karp 5 solution [22, 21] as a fractional T -join dominator. Let us consider whether χT and x∗ can be used to bound the cost of a minimum T -join in our case. It can be seen from (1) that βx∗ is a fractional T -join dominator for β = 1. If it were not for the s-t 2 . However, an s-t cut may have capacity as low as 1, making it cuts, the same could be shown for β = 1 hard to establish the feasibility of βx∗ for any β < 1. αχT also is a fractional T -join dominator for α = 1; in this case, however, s-t cuts do have some slack. Suppose that an s-t cut (U, ¯U ) is odd with respect to T : i.e., U ∩ T is odd. Since U contains exactly one of s and t, U contains an even number of vertices that have odd degree in T . δ(U ) ∩ T is given as the sum of the degrees of the vertices in U minus twice the number of edges within U, and is therefore even. This shows χT (δ(U )) ≥ 2 and hence αχT for α = 1 2 does not violate (2) as far as s-t cuts are concerned. It is the nonseparating cuts that render it difficult to show the feasibility of αχT for α < 1. Given the difficulties in these two cases are complementary, it is natural to consider αχT + βx∗ as a candidate for a fractional T -join dominator; Theorem 2 elaborates this observation. Theorem 2. E[c(H)] ≤ 5 Proof. Let y := αχT + βx∗ for some parameters α, β > 0 to be chosen later. We examine a sufficient condition on α and β for y to be a feasible solution to (2). 3 c(x∗). It is obvious that y ≥ 0. Consider an odd cut (U, ¯U ) with respect to T : i.e., U ∩ T is odd. We have δ(U ) ∩ T > 0 from the connectedness of T . Suppose that (U, ¯U ) is an s, t-cut; then δ(U ) ∩ T is even as previously argued. Thus, y(δ(U )) = αδ(U ) ∩ T + βx∗(δ(U )) ≥ 2α + β. Suppose that (U, ¯U ) is nonseparating; then we have x∗(δ(U )) ≥ 2 from the Held-Karp feasibility, and hence y(δ(U )) ≥ αδ(U ) ∩ T + βx∗(δ(U )) ≥ α + 2β. Therefore, if 2α + β ≥ 1 and α + 2β ≥ 1 then y is feasible. Now we bound the expected cost of H: E[c(H)] = E[c(T )] + E[c(J)] ≤ E[c(T )] + E[c(y)] = E[c(T )] + E[c(αχT )] + E[c(βx∗)] = (1 + α + β)c(x∗), where the second line holds since y is a fractional T -join dominator. Choose α = 1 3 and β = 1 3. 3.3 First improvement upon 5/3 We demonstrate in this subsection that the above analysis can be slightly improved. Recall that the lower bound on the nonseparating cut capacities of y was given as α+2β in the previous analysis; consider perturbing α and β by small amount while maintaining α + 2β = 1. In particular, if we decrease α by 2ǫ and increase β by ǫ, we decrease the expected cost of y by ǫc(x∗), without changing 6 α + 2β; that is, if we can fix the possible deficiencies of y in s-t cuts with small cost, this perturbation will lead to an improvement in the performance guarantee. and thus, if x∗(δ(U )) is large enough, the bound remains greater than one after a small perturbation. Note that s-t cuts with large capacities are not a problem: (αχT + βx∗)(δ(U )) ≥ 2α + βx∗(δ(U )) On the other hand, cuts with x∗(δ(U )) = 1 are also not a concern. x∗(δ(U )) = E[δ(U ) ∩ T ], and δ(U ) ∩ T ≥ 1 from the connectedness of T ; hence δ(U ) ∩ T is identically 1 and U ∩ T is always even. Formulation (2) constrains the capacities of only the cuts that are odd with respect to T , so the capacity of this particular cut (U, ¯U ) will never be constrained. In fact, for an s-t cut (U, ¯U ), Pr[U ∩ T is odd] ≤ Pr[δ(U ) ∩ T ≥ 2] ≤ E[δ(U ) ∩ T ] − 1 = x∗(δ(U )) − 1. (3) We will begin with y ← αχT + βx∗ for perturbed α and β, and ensure that y is a fractional T - join dominator by adding small fractions of the deficient odd s-t cuts. Yet, a cut being odd with small probability as shown by (3) does not directly connect to its edge being added with small probability, since an edge belongs to many s-t cuts. We address this issue by showing that the s-t cuts of small capacities are “almost” disjoint. First, consider the s-t cuts (U, ¯U ) whose capacities are not large enough for 2α + βx∗(δ(U )) to be readily as large as 1; the following definition captures this idea. Let τ := 1−2α Definition 3. For some 0 < τ ≤ 1, an s-t cut (U, ¯U ) is called τ -narrow if x∗(δ(U )) < 1 + τ . β − 1. The following lemma shows that τ -narrow cuts do not cross. Lemma 1. Let 0 < τ ≤ 1. For U1 ∋ s and U2 ∋ s, if both (U1, ¯U1) and (U2, ¯U2) are τ -narrow, then U1 ⊂ U2 or U2 ⊂ U1. Proof. Suppose not. Then both U1 \ U2 and U2 \ U1 are nonempty and x∗(δ(U1)) + x∗(δ(U2)) ≥ x∗(δ(U1 \ U2)) + x∗(δ(U2 \ U1)) ≥ 2 + 2 = 4; (4) on the other hand, contradicting (4). x∗(δ(U1)) + x∗(δ(U2)) < 2 + 2τ ≤ 4, Lemma 1 shows that the τ -narrow cuts constitute a layered structure, as illustrated in Figure 3: Corollary 2. There exists a partition L1, . . . , Lℓ of V such that 1. L1 = {s}, Lℓ = {t}, and 2. {U(U, ¯U ) is τ -narrow, s ∈ U} = {Ui1 ≤ i < ℓ}, where Ui := ∪i Let L≤i denote ∪i Now we show that τ -narrow cuts are almost disjoint: for each τ -narrow cut (Ui, ¯Ui), we can choose k=1Lk and L≥i denote ∪ℓ k=iLk. Ui = L≤i. k=1Lk. Fi ⊂ δ(Ui) that occupies a large portion of δ(Ui) and mutually disjoint. Definition 4. Fi := E(Li, L≥i+1). 7 s 0.5 0.5 0.5 0.5 0.5 0.5 0.49 0.5 0.5 0.5 0.5 0.5 L1 L2 0.01 0.51 0.99 0.99 0.5 0.01 L3 0.01 L4 0.5 0.5 0.99 0.5 0.5 t L5 L6 Figure 3: 0.05-narrow cuts of a feasible Held-Karp solution (ℓ = 6). F3 is marked with thick edges. Lemma 2. For each τ -narrow cut (Ui, ¯Ui), x∗(Fi) > 1−τ +x∗(δ(Ui)) ≥ 1 − τ 2 . Proof. The lemma holds trivially for i = 1. Suppose 2 ≤ i ≤ ℓ − 1. We have 2 1 + τ > x∗(δ(Ui−1)) = x∗(E(L≤i−1, Li)) + x∗(E(L≤i−1, L≥i+1)) and From (5) and (6), on the other hand, Thus, x∗(δ(Ui)) = x∗(E(Li, L≥i+1)) + x∗(E(L≤i−1, L≥i+1)). x∗(δ(Ui)) − 1 − τ < x∗(E(Li, L≥i+1)) − x∗(E(L≤i−1, Li)); 2 ≤ x∗(δ(Li)) = x∗(E(Li, L≥i+1)) + x∗(E(L≤i−1, Li)). τ 2 x∗(Fi) = x∗(E(Li, L≥i+1)) > 1 − τ + x∗(δ(Ui)) 2 ≥ 1 − . (5) (6) It is obvious that Fi’s are disjoint and Fi ⊂ δ(Ui). For each τ -narrow cut Ui, we define f∗Ui as (f∗Ui)e :=(x∗e 0 if e ∈ Fi, otherwise. Theorem 3. E[c(H)] ≤ 1.6577c(x∗). Proof. Let y := αχT + βx∗ + Xi:Ui∩T is odd, 1≤i<ℓ 1 − (2α + β) 1 − τ 2 f∗Ui, for α = 0.30, β = 0.35 and τ = 1−2α β − 1 = 1 7. We claim y is a fractional T -join dominator. It is obvious that y ≥ 0, and we have argued that y(δ(U )) ≥ 1 for nonseparating (U, ¯U ). Suppose (U, ¯U ) is an s-t cut with U ∩ T odd. If (U, ¯U ) is not τ -narrow, then y(δ(U )) ≥ αδ(U ) ∩ T + βx∗(δ(U )) ≥ 2α + β(1 + τ ) = 1. 8 If (U, ¯U ) is τ -narrow, then y(δ(U )) ≥ αδ(U ) ∩ T + βx∗(δ(U )) + (cid:16)1 − 1 − (2α + β) ≥ 2α + β + = 1. 1 − τ 2 2 1 − τ 1 − (2α + β) 2(cid:17) τ f∗U (δ(U )) Thus y is a fractional T -join dominator. Now it remains to bound the expected cost of H. Let A := 1 − (2α + β) 1 − τ 2 . E[c(H)] = E[c(T )] + E[c(J)] ≤ E[c(T )] + E[c(y)] c = E[c(T )] + E[c(αχT )] + E[c(βx∗)] + E  = (1 + α + β)c(x∗) + c ℓ−1 Xi=1 Pr[Ui ∩ T is odd] · A · f∗Ui! . Xi:Ui∩T is odd, 1≤i<ℓ A · f∗Ui    From (3), E[c(H)] ≤ (1 + α + β)c(x∗) + τ Ac ℓ−1 Xi=1 ≤ (1 + α + β + τ A) c(x∗), f∗Ui! where the last line follows from the disjointness of Fi. Note that 1 + α + β + τ A < 1.6577. 3.4 A tighter analysis In the previous analysis, we separately bounded the probability that a τ -narrow cut is odd, the deficit of the cut, and f∗U (δ(U )); moreover, we used 1 − τ from Lemma 2. These observations 2 lead to some improvement, as shown in the following theorem. Theorem 4. E[c(H)] ≤ 9−√33 2 instead of 1−τ +x∗(δ(Ui)) 2 c(x∗). 1 − τ + x∗(δ(Ui)) 2 Proof. Let bi := Let denote the lower bound of f∗Ui (δ(Ui)) given by Lemma 2. y := αχT + βx∗ + Xi:Ui∩T is odd, 1≤i<ℓ 1 − {2α + βx∗(δ(Ui))} bi f∗Ui, where α and β are to be chosen later; τ := 1−2α the τ -narrow cuts and their layered structure. Assume 1 β − 1. As in the previous subsection, {Ui} and {Li} denote 3 ≤ β ≤ 1 2 and 1 − 2β ≤ α ≤ 1−β 2 . 9 A similar argument as in Theorem 3 proves that y is a fractional T -join dominator; it can also be shown that bi Pr[Ui ∩ T is odd] E[c(H)] ≤ (1 + α + β)c(x∗) + c ℓ−1 Xi=1 ≤ (1 + α + β)c(x∗) + c ℓ−1 Xi=1 0≤ω≤τ(cid:18)ω ≤ (1 + α + β)c(x∗) +(cid:20) max 2 + ω 0≤ω≤τ(cid:18)ω ≤ (cid:26)1 + α + β + max 1 − {2α + β(1 + ω)} 1 − {2α + β(1 + ω)} ω[1 − {2α + β(1 + ω)}] {x∗(δ(Ui)) − 1} 1 − τ 1 − τ 1 − {2α + β(1 + ω)} (cid:19)(cid:27) c(x∗). f∗Ui! 1 − {2α + βx∗(δ(Ui))} f∗Ui! 1 − {2α + βx∗(δ(Ui))} (cid:19)(cid:21) c ℓ−1 f∗Ui! Xi=1 . We have 2 + ω = bi 2 2 Let R(ω) := ω (7) 2 2 3 2 + ω β + ω 2β + α 2 − 1 1 − τ 2 ω2 + (1 − 2α − 3β)ω +(cid:16)2 − 4α − 3 R′(ω) = − β 2 β − 1 2(cid:17)2 1 − 2α β − 1) (cid:16) 3 2 − 1 (0 ≤ ω ≤ R′(ω) = 0 2β + α β + ω 2β + 2α β (cid:17) β − 2α2 and the unique solution to is ω = ω0 := 1 β (cid:16)1 − 2α − 3β +p(−2β)(1 − 2α − 3β)(cid:17) . β − 1 and R(0) = R( 1−2α β − 1) = 0, R(ω) is maximized at ω = ω0; Since R(ω) ≥ 0 for 0 ≤ ω ≤ 1−2α hence, from (7), Choose α = 1√33 , β = 1 E[c(H)] ≤(cid:16)5α + 11β − 1 − 4p(−2β)(1 − 2α − 3β)(cid:17) c(x∗). 2 − 1 2√33 and we obtain E[c(H)] ≤ 9 − √33 2 c(x∗). 3.5 Proof of(cid:16) 1+√5 In this final subsection, we show that E[c(H)] ≤ 1+√5 2 (cid:17)-approximation 2 In the previous analyses, Fi’s serve as “representatives” of τ -narrow cuts. These representatives are useful since they have large weights while being disjoint. We improve the performance guarantee by introducing a new set of representatives that are “fractionally disjoint”. Note that the three key properties of {f∗Ui} used in the proof of Theorem 4 are: c(x∗), proving Theorem 1 and Corollary 1. 10 3. f∗Ui i=1 f∗Ui ≤ x∗; and (δ(Ui)) ≥ 1−τ +x∗(δ(Ui)) 1. f∗Ui ≥ 0 for all i; 2. Pℓ−1 {f∗Ui} chosen in the previous analyses also satisfies that, for any given e ∈ E,(cid:0)f∗Ui(cid:1)e 6= 0 for at most one i. However, this was not a useful property in the analysis; Lemma 3 states that, by relaxing the definition of disjointness, we can choose { f∗Ui} that have larger weights. The definitions of τ , {Ui} and {Li} are unchanged. Lemma 3. There exists a set of vectors { f∗Ui}ℓ−1 i=1 satisfying: for all i. 2 1. f∗Ui ∈ RE 2. Pℓ−1 i=1 + for all i; f∗Ui ≤ x∗; and (δ(Ui)) ≥ 1 for all i. 3. f∗Ui This lemma is proven later; based on it, Lemma 3 proves the desired performance guarantee. Lemma 4. E[c(H)] ≤ 1+√5 2 c(x∗). Proof. Let y := αχT + βx∗ + Xi:Ui∩T is odd, 1≤i<ℓ [1 − {2α + βx∗(δ(Ui))}] f∗Ui, where α and β are parameters to be chosen later, satisfying 1 3 ≤ β ≤ 1 2 and 1 − 2β ≤ α ≤ 1 − β 2 . (8) By following the same argument as in Theorem 4, we can easily show that y is a fractional T -join dominator; the only slight difference is when (U, ¯U ) is τ -narrow and U ∩ T is odd, where we have y(δ(U )) ≥ αδ(U ) ∩ T + βx∗(δ(U )) + [1 − {2α + βx∗(δ(Ui))}] f∗U (δ(U )) ≥ 2α + βx∗(δ(U )) + [1 − {2α + βx∗(δ(Ui))}] · 1 = 1, from the first and the third properties of Lemma 3. Hence, y is a fractional T -join dominator. Now it remains to bound E[c(H)]. E[c(H)] ≤ E[c(T )] + E[c(y)] = (1 + α + β)c(x∗) + c ℓ−1 Pr[Ui ∩ T is odd] [1 − {2α + βx∗(δ(Ui))}] f∗Ui! Xi=1 ≤ (1 + α + β)c(x∗) + c ℓ−1 {x∗(δ(Ui)) − 1} [1 − {2α + βx∗(δ(Ui))}] f∗Ui! Xi=1 ω [1 − {2α + β(1 + ω))}](cid:27) c ℓ−1 ≤ (1 + α + β)c(x∗) +(cid:26) max Xi=1 f∗Ui! . 0≤ω≤τ (9) 11 0.5 e3 e4 0.5 0.5 e1 e2 0.5 s L1 1 L2 t L3 1 1 vsource vcut U1 vcut U2     0.5 vedge e1 0.5 vedge e2 0.5 vedge e3 0.5 vedge e4 Vsink Figure 4: A feasible Held-Karp solution (ℓ = 3) and its corresponding flow network. From the second property of Lemma 3, 0≤ω≤τ E[c(H)] ≤ (cid:26)1 + α + β + max = (cid:26)1 + α + β + max = (cid:26)1 + α + β + and β = 1√5 . ω [1 − {2α + β(1 + ω))}](cid:27) c(x∗) βω(τ − ω)(cid:27) c(x∗) (cid:27) c(x∗). 4β 0≤ω≤τ (1 − 2α − β)2 We choose α = 1 − 2√5 Proof of Lemma 3. Consider an auxiliary flow network illustrated in Figure 4, consisting of the source vsource, sink vsink, a node vcut for each edge e in one or more τ -narrow cuts. The network has arcs of: U for each τ -narrow cut U, and a node vedge e 1. capacity 1 from vsource to vcut U for every τ -narrow cut U; 2. capacity ∞ from vcut 3. capacity x∗e from vedge e U to vedge e for every e ∈ δ(U ), for all U; to vsink for every vedge e . Let g be this capacity function. Let (S, ¯S) be an arbitrary cut on this flow network, where vsource ∈ S. We claim the cut capacity of (S, ¯S) is at least ℓ − 1. /∈ S; the cut capacity Suppose there exists a τ -narrow cut U and e ∈ δ(U ) such that vcut is then ∞. So assume from now that (abusing the notation) every edge in any τ -narrow cut in S is also in Uik} for some 1 ≤ i1 < i2 < . . . < ik < ℓ. The cut S. Let S ∩ {vcut capacity is then at least Ui 1 ≤ i < ℓ} = {vcut U ∈ S and vedge , . . . , vcut , vcut Ui2 Ui1 e Xvcut U /∈S g(vsource, vcut U ) + Xe:∃vcut U ∈S e∈δ(U ) g(vedge e , vsink) = (ℓ − 1 − k) + Xe:∃vcut U ∈S e∈δ(U ) x∗e; 12 s L1 Ui1 L2 Ui2\ Ui1 L3 Ui3\ Ui2 t V \ Ui3 L4 L5 L6 Figure 5: Schematic diagram: ℓ = 6, k = 3, i1 = 2, i2 = 3, and i3 = 5. if k = 0, the claim holds; the claim also holds for k = 1 since x∗(δ(Ui1 )) ≥ 1. Suppose k ≥ 2 (see Figure 5). Xe:∃vcut U ∈S e∈δ(U ) proving the claim. k 1 2 x∗(δ(Ui1 )) + Xj=2 [1 + 2(k − 1) + 1] x∗e = 1 ≥ 2 = k, x∗(δ(Uij \ Uij−1)) + x∗(δ(V \ Uik ))  Thus the maximum flow on this flow network is of value at least ℓ − 1. Consider a maximum flow; U , since the cut capacity of ({vsource},{vsource}) is ℓ− 1. this flow saturates all the edges from vsource to vcut Now, for each τ -narrow cut U, define ( f∗U )e as the flow from vcut if e ∈ δ(U ), and 0 otherwise. Then the first property is satisfied from the definition of flow; the second property is satisfied from the capacity constraints on vedge to vsink; lastly, the third property is satisfied since every edge from vsource to U is saturated. vcut U to vedge e e 4 Application to other problems In this section, we exhibit how the present results can be applied to other problems to obtain approximation algorithms with better performance guarantees than the current best known and improved LP integrality gap upper bounds. 4.1 Prize-collecting s-t path problem We discuss the prize-collecting s-t path problem in this subsection. Definition 5 (Metric prize-collecting s-t path problem). Given a complete graph G = (V, E) with s, t ∈ V , metric edge cost function c : E → R+, and vertex prize π : V → R+, the metric prize-collecting s-t path problem is to find a simple s-t path P that minimizes the sum of the path cost and the total prize “missed”, i.e., c(P ) + π(V \ V (P )). The s-t path TSP can be considered as a special case of the prize-collecting s-t path problem, where π(v) = ∞ for all v ∈ V . approximation algorithm for the metric prize-collecting s-t path problem. 241 Archer et al. [3] use the path-variant Christofides’ algorithm [17] as a black box to obtain a 241 121 - 121 < 1.9918. 13 Theorem 5 (Archer et al. [3]). Given a ρ-approximation algorithm A for the metric s-t path TSP, one can uses A as a black box. 2+ρ(cid:17)2(cid:19)-approximation algorithm for the metric prize-collecting s-t path problem that obtain a (cid:18)2 −(cid:16) 2−ρ This theorem, combined with Theorem 1, readily produces an improvement. 1+4√5 Corollary 3. There exists a (cid:16) 1+4√5 5 < 1.9889. problem. 5 (cid:17)-approximation algorithm for the metric prize-collecting s-t path However, as the performance guarantee established by Theorem 1 is in terms of the Held-Karp op- timum, the theorem enables a further improvement via an analysis analogous to Goemans [12]. For the metric prize-collecting traveling salesman problem, Goemans [12] combines the LP rounding algorithm due to Bienstock et al. [6] and the primal-dual algorithm of Goemans & Williamson [14] (with the obser- vation of [9] and [3]) to achieve the best performance guarantee known for the problem. One obstacle in applying this approach to the prize-collecting s-t path problem is that, unlike the circuit-variant Held-Karp relaxation, the path-variant Held-Karp relaxation cannot be written as a set of edge-connectivity requirements between the pairs of vertices: the relaxation requires nonseparating cuts to have capacity of at least 2, whereas the edge connectivity between any two vertices can be as low as 1 in both a feasible Held-Karp solution and a (integral) Hamiltonian path. We will show that, despite this fact, the parsimonious property [13] still can be used, and will analyze the performance guarantee given by the approach. We start with the following LP relaxation of the problem: minimize subject to x(δ(S)) ≥ 1, c(x) + π(1 − y) x(δ(S)) ≥ 2yv, x(δ({s})) = x(δ({t})) = 1; x(δ({v})) = 2yv, xe ≥ 0, 0 ≤ yv ≤ 1, ∀S ( V,S ∩ {s, t} = 1; ∀S ( V, S ∩ {s, t} = ∅ ∀v ∈ S; ∀v ∈ V \ {s, t}; ∀e ∈ E; ∀v ∈ V \ {s, t}; (10) where 1 denotes the all-1 vector in V ∈ R prize-collecting s-t path problem. V \{s,t} + . It can be easily verified that this is a relaxation of the Given V ′ ⊂ V \ {s, t}, consider a related problem of finding a minimum s-t path on G that visits all the vertices in V ′, and only those vertices. The following LP is a relaxation to this problem: c(x) minimize subject to x(δ(S)) ≥ 1, x(δ(S)) ≥ 2, x(δ({s})) = x(δ({t})) = 1; x(δ({v})) = 2, x(δ({v})) = 0, xe ≥ 0, ∀S ( V,S ∩ {s, t} = 1; ∀S ( V, S ∩ {s, t} = ∅, S ∩ V ′ 6= ∅; ∀v ∈ V ′; ∀v ∈ V \ {s, t} \ V ′; ∀e ∈ E. (11) Observation 2. Let G′ = (V ′ ∪ {s, t}, E′) be the subgraph of G induced by V ′ ∪ {s, t}. Projecting a feasible solution to (11) to E′ yields a feasible solution to the path-variant Held-Karp relaxation for G′. 14 The following lemma shows that we can use the parsimonious property. Lemma 5. The optimal solution value to (11) is equal to the optimal solution value to the following relaxation without the degree constraints: c(x) minimize subject to x(δ(S)) ≥ 1, ∀S ( V,S ∩ {s, t} = 1; x(δ(S)) ≥ 2, ∀S ( V, S ∩ {s, t} = ∅, S ∩ V ′ 6= ∅; xe ≥ 0, ∀e ∈ E. (12) Proof. Let G = (V, E). It suffices to show that, given a feasible solution x∗ to (12), how to construct a feasible solution to (11) whose cost is no greater than c(x∗). We will extend the graph (and x∗) so that the relaxation (almost) becomes a set of edge-connectivity requirements between pairs of vertices, and then use a similar approach as in Bienstock et al. [6], along with the following lemma: Lemma 6 ([6]). Let G = (V, E) be an Eulerian multigraph. Suppose that, for some U ⊂ V and v ∈ V , any two vertices in U other than v are k-edge-connected. Let x be an arbitrary neighbor of v; then, there exists a neighbor y of v such that 1. x 6= y; and 2. any two vertices in U other than v are still k-edge-connected after splitting (x, v) and (y, v): i.e., replacing (x, v) and (y, v) (one copy each) with (x, y). Without loss of generality, we can assume x∗ is rational. Now we add three new vertices to the graph: s′, t′ and u. We set c(s′, v) = c(s, v) and c(t′, v) = c(t, v) for all v; c(s′, s) = c(t′, t) = 0: s′ and t′ will be the “proxy” of s and t. We do not define the cost between u and other vertices: these costs do not affect the rest of the analysis. However, for notational convenience, we set these costs to be zero, potentially violating the triangle inequality. Let ¯G = ( ¯V , ¯E) be this extended graph. We extend x∗ into ¯x∗ as well: ¯x∗(s, s′) = ¯x∗(s′, u) = ¯x∗(u, t′) = ¯x∗(t′, t) = 1, and all other newly added edges are set to zero. Note that the (fractional) degree of s′, t′ and u are 2. Let ¯V ′ := V ′ ∪ {s′, t′, u}; we claim that any two vertices in ¯V ′ are 2-edge-connected. If t /∈ S, then at least one edge of the path P : Claim 1. For any S ⊂ ¯V such that ¯V ′ ∩ S 6= ∅ and ¯V ′ \ S 6= ∅, ¯x∗(δ(S)) ≥ 2. Proof. Without loss of generality, assume s ∈ S. s − s′ − u − t′ − t is in δ(S); thus, ¯x∗(δ(S)) ≥ x∗(δG(S ∩ V )) + ¯x∗(δ(S) ∩ P ) ≥ 1 + 1. Suppose t ∈ S. If {s′, u, t′} \ S 6= ∅ then δ(S) ∩ P ≥ 2; hence, ¯x∗(δ(S)) ≥ ¯x∗(δ(S) ∩ P ) ≥ 2. Otherwise, V ′ \ S = ¯V ′ \ S 6= ∅ and thus, ¯x∗(δ(S)) ≥ x∗(δG(S ∩ V )) ≥ 2, since (S ∩ V ) ∩ V ′ ( V ′. 15 Now scale ¯x∗ by some large constant C so that ¯z∗ := C ¯x∗ is integral and, in the multigraph on ¯V whose edge multiplicities are given by ¯z∗, the degree of every vertex is even. Note that any two vertices in ¯V ′ are 2C-edge-connected in this multigraph. Let φ := Pv∈ ¯V ′[¯z∗(δ(v)) − 2C] +Pv∈ ¯V \ ¯V ′ ¯z∗(δ(v)); φ is an even integer. We will modify ¯z∗ until φ reaches 0: in particular, we split two edges in the multigraph so that (i) φ decreases by 2; (ii) c(¯z∗) do not increase; (iii) any two vertices in ¯V ′ are 2C-edge-connected; (iv) the degrees of s′, t′ and u all remain 2C; (v) the only edges incident to u are (s′, u) and (u, t′); and (vi) every vertex has even degree and hence the connected component containing ¯V ′ is Eulerian. It is clear that the invariants (iii) through (vi) initially hold. If there exists an edge that is not reachable from any vertex in ¯V ′, we can remove all such edges without violating any of the conditions (φ may decrease by more than 2). If there exists v ∈ ¯V \ ¯V ′ such that ¯z∗(δ(v)) > 0, then we apply Lemma 6 to pick two incident edges to split. Note that v /∈ {s′, t′, u} since s′, t′, u ∈ ¯V ′. (iii) is maintained from the lemma. Splitting does not change the degree of any vertex other than v; hence (i), (iv) and (vi) are satisfied. Neither of the chosen edges is incident to u, as can be seen from (v); thus, (v) is maintained and (ii) follows from the triangle inequality. Otherwise, we choose v ∈ ¯V ′ such that ¯z∗(δ(v)) > 2C. ¯z∗(δ(v)) ≥ 2C + 2 from (vi). Again Once φ reaches 0, we remove u and its incident edges. None of these edges got split during the process: v /∈ {s′, t′, u} from (iv); we can similarly verify all properties in this case as well. this is the reason why the cost of these edges can be left undefined. Note that the degree of s and t now are 0, whereas s′ and t′ are 1. Concatenate s and s′, and t and t′, respectively; we scale this multigraph back by 1/C to obtain a feasible solution to (11) whose cost is no greater than c(x∗). We are now ready to apply the analyses of Goemans [12] and Bienstock et al. [6]. Let x∗ and y∗ be an optimal solution to (10). Lemma 7. Let A ρ be an approximation algorithm for the s-t path TSP that produces a path of cost at most ρ times the Held-Karp optimum. Let Vγ = {vy∗v ≥ γ} for some 0 < γ ≤ 1. Running A ρ on the subgraph Gγ induced by Vγ ∪ {s, t} yields a path P with c(P ) ≤ ρ Proof. The proof is basically the same as [6]. Observe that x∗ γ is a feasible solution to (12), as can be seen from (10) and (12). From Lemma 5 and Observation 2, the Held-Karp optimum for Gγ is of cost no greater than c( x∗ γ c(x∗). γ ). The primal-dual algorithm of Chaudhuri et al. [7] can be used to obtain the following performance guarantee for the metric prize-collecting s-t path problem. Lemma 8 ([7, 3]). There exists a polynomial-time algorithm APD that produces an s-t path P satisfying c(P ) + π(V \ V (P )) ≤ 2c(x∗) + π(1 − y∗). 16 Now, the combined algorithm is as follows: let a := e1− 2 2−a+ρ ln a. The algorithm runs APD with probability p; otherwise, it computes an optimal solution x∗ and y∗ to (10), samples γ uniformly at random from (a, 1), and run A ρ on the subgraph induced by Vγ = {vy∗v ≥ γ}. ρ and p := 1+ρ ln a Theorem 6. Let A ρ be an approximation algorithm for the s-t path TSP that produces a path of cost This algorithm can be derandomized since there are only O(V ) different Vγ’s possible. 2 ≤ ρ < 2; then, there exists a at most ρ times the Held-Karp optimum, for some 3 approximation algorithm for the metric prize-collecting s-t path problem. ρ ρ!- ρ − e1− 2 Proof. The given algorithm is a polynomial-time algorithm. Let P denote the output path. It can be easily verified that 0 < a < 1 and 0 < p < 1. From Lemma 7, E[c(P )A ρ is chosen] ≤ E[ ρ γ c(x∗)A ρ is chosen] 1 1 − a 1 γ dγ = ρc(x∗)Z 1 = − ln a 1 − a a ρc(x∗). We have E[π(V \ V (P ))A ρ is chosen] = Xv∈V \{s,t} = Xv∈V \{s,t} ≤ 1 − a π(v) · Pr[v /∈ Vγ] π(v) · min(cid:18) 1 − y∗v 1 − a π(1 − y∗). 1 From (13), (14), and Lemma 8, (13) (14) , 1(cid:19) E[c(P ) + π(V \ V (P ))] = p [2c(x∗) + π(1 − y∗)] + (1 − p)(cid:20)− ln a 1 − a ρc(x∗) + 1 1 − a π(1 − y∗)(cid:21) = (cid:20)2p + (1 − p)− ln a 1 − a ρ(cid:21) c(x∗) +(cid:20)p + (1 − p) 1 1 − a(cid:21) π(1 − y∗) = ρ ρ − e1− 2 ρ [c(x∗) + π(1 − y∗)] . Theorem 6 along with Theorem 1 yields the following: Corollary 4. There exists a deterministic 1.9535-approximation algorithm for the metric prize-collecting s-t path problem. Corollary 5. The integrality gap of (10) is smaller than 1.9535. 17 4.2 Unit-weight graphical metrics In this subsection, we study the s-t path TSP for a special case where the cost function is a shortest-path metric defined by an underlying undirected, unit-weight graph. Let x∗ be an optimal solution to the path-variant Held-Karp relaxation; G0 be the underlying unit- weight graph defining the cost function. G0 is connected. Mucha [19] gives an improved analysis of the 1.5858-approximation algorithm of Momke and Svens- son [18]; following is from [19]. Lemma 9 ([19]). There exists an algorithm A0 for the s-t path TSP under unit-weight graphical metrics, which returns a solution of cost at most min(cid:18) 10 9 c(x∗) + 1 3 c(s, t) + 1 3V + 4 9 , 2V − 2 − c(s, t)(cid:19) . This immediately gives a ( 19 12 + ǫ)-approximation algorithm for any ǫ > 0. 19 12 < 1.5834. Theorem 7 ([19]). There exists a ( 19 graphical metrics, for any ǫ > 0. 12 + ǫ)-approximation algorithm for the s-t path TSP under unit-weight Proof. Let P be the output of A0. From Lemma 9, c(P ) ≤ 3 4(cid:18) 10 9 c(x∗) + 1 3 c(s, t) + 4 9(cid:19) + 1 4 (2V − 2 − c(s, t)) 1 3V + 7 12 5 6 5 6 c(x∗) + = (V − 1) + 7 c(x∗) + , 12 where the last line holds since c(e) ≥ 1 for all e. instances can be separately solved. Thus, there exists n0 such that c(P ) ≤ ( 19 c(x∗) + ≤ 3 4 3 4 12 + ǫ)c(x∗) for all input that has n0 or more vertices. Smaller It can be observed from Lemma 9 and Theorem 7 that the “critical case” determining the proven per- formance guarantee is when c(x∗) ≈ V . We will show that three different constructions of Hamiltonian paths carry performance analyses with complementary critical cases. Even though τ -narrow cuts function as a mere analytic tool in Section 3, we propose an algorithm that actually computes the τ -narrow cuts and utilize them: once the τ -narrow cuts are computed, the algorithm constructs an s-t path that traverses from the first layer to the last, without “skipping” any layer in-between. If the path is inexpensive, the number of τ -narrow cuts is also small so the algorithm presented in Section 3 produces a good solution. If the path is expensive but the Held-Karp optimum is close to V − 1, then we prove that the path already contains a large number of vertices and therefore can be augmented into a spanning Eulerian path with small additional cost. Lastly, if the Held-Karp optimum is bounded away from V − 1, then Momke & Svensson’s algorithm performs well provided that the graph has large number of vertices. Algorithm 1 shows the entire algorithm (except the separate handling of small instances); θ ∈ (0, 1) is a parameter to be chosen later. Let η : E → Z≥0 be a function such that η(e) := c(e) − 1. For U ⊂ V , G(U ) denotes the subgraph of G induced by U. Suppose V ≥ 3; this implies ℓ ≥ 3. 18 Let (pi, qi+1) be the shortest edge in E(Li, Li+1), where pi ∈ Li and qi+1 ∈ Li+1. Let Pi be the shortest path from qi to pi within G(Li), under edge cost given by η. Algorithm 1 The algorithm for the s-t path TSP under unit-weight graphical metrics Input: Complete graph G = (V, E) with cost function c : E → Z>0; endpoints s, t ∈ V . Output: Hamiltonian path between s and t. 1 Run A0; let HA be the output Hamiltonian path. 2 x∗ ←an optimal solution to the path-variant Held-Karp relaxation 3 Run the algorithm from Section 3; let HB be the output Hamiltonian path. 4 Compute the partition L1, . . . Lℓ defining all the (1 − θ)-narrow cuts Ui. 5 for 1 ≤ i < ℓ do 6 7 end for 8 for 1 < i < ℓ do 9 10 end for 11 Let PLT be an s-t path obtained by concatenating (s, q2), P2, (p2, q3), . . . , Pℓ−1, (pℓ−1, t). 12 GE ← (V, PLT) 13 while the multigraph GE is not spanning do 14 15 16 end while 17 Shortcut an Eulerian path of GE to obtain a Hamiltonian path HC. 18 Let Hout be the best among HA, HB and HC; output Hout. Choose (u, v) such that: c(u, v) = 1, u is isolated in GE, and v is not. Add two copies of (u, v) to GE. Lemma 10. Algorithm 1 is a well-defined, polynomial-time algorithm. Proof. Steps 13-16 start with an s-t path, and augment it into a spanning multigraph that has an Eulerian path between s and t. This follows from the preservation of the parity of degree. Choice of (u, v) satisfying c(u, v) = 1 is always possible since G0 is connected. PLT is an s-t path since L1 = {s} and Lℓ = {t}. Note that some of Pi’s may be a length-0 path. Step 4, unlike the algorithm from Section 3, actually computes the layered structure of (1 − θ)-narrow cuts, whereas this structure was only for the sake of analysis in Section 3. Yet, the layers can in fact be identified via a polynomial number of min-cut calculations; hence, the algorithm is a polynomial-time algorithm. Lemma 11. Proof. We have and From (15) and (16), x∗(E(L1, L2)) > θ. x∗(E(L1, L≥3)) + x∗(E(L2, L≥3)) = x∗(δ(U2)) < 2 − θ x∗(E(L1, L2) + x∗(E(L2, L≥3)) = x∗(δ(L2)) ≥ 2. (15) (16) x∗(E(L1, L2)) − x∗(E(L1, L≥3)) > θ. By symmetry, x∗(E(Lℓ−1, Lℓ)) > θ. 19 Lemma 12. For any i ≥ 1, j ≤ ℓ, V1 6= ∅ and V2 6= ∅ such that k=i+1Lk, and 1. i + 2 ≤ j, 2. V1 ∪ V2 = ∪j−1 3. V1 ∩ V2 = ∅, then x∗(E(V1, V2)) > θ. Proof. We have x∗(E(L≤i, V1)) + x∗(E(L≤i, V2)) + x∗(E(L≤i, L≥j)) = x∗(δ(L≤i)) < 2 − θ; by symmetry, x∗(E(L≤i, L≥j)) + x∗(E(V1, L≥j)) + x∗(E(V2, L≥j)) < 2 − θ; x∗(E(L≤i, V1)) + x∗(E(V1, V2)) + x∗(E(V1, L≥j)) = x∗(δ(V1)) ≥ 2; again by symmetry, x∗(E(L≤i, V2)) + x∗(E(V1, V2)) + x∗(E(V2, L≥j)) ≥ 2. From (17) through (20), 2x∗(E(V1, V2)) − 2x∗(E(L≤i, L≥j)) > 2θ. (17) (18) (19) (20) Corollary 6. For all 1 ≤ i < ℓ, x∗(E(Li, Li+1)) > θ. Proof. From Lemma 11 and Lemma 12 applied for j − i = 3. Corollary 7. For all i, G(Li) weighted by (the projection of) x∗ is θ-edge-connected. Proof. L1 and Lℓ are singleton; every cut in any other nonsingleton layer subgraphs are of capacity at least θ from Lemma 12, applied for j − i = 2. Let σ, κ ≥ 0 be some parameters to be chosen later. Lemma 13. κ(cid:21) c(x∗) Proof. Suppose c(x∗) ≥ (1 + σ)(V − 1); from the proof of Theorem 7, + c(Hout) ≤ c(HA) c(x∗) + 5 6 ≤ ≤ (cid:18) 5 6 + 7 12 3 4 3 (V − 1) + 4(1 + σ)(cid:19) c(x∗) + 7 12 ; thus, we can assume from now that c(x∗) < (1 + σ)(V − 1). 20 c(Hout) ≤ max 3 4(1 + σ)(cid:19) c(x∗) + 7 12 6 + (cid:18) 5 (cid:18)2 − κ + (cid:20) 3 + 2θ 2 + θ   2σ θ (cid:19) c(x∗) (1 − θ)2 4(2 + θ) .   Case 1. From Corollary 6 and the choice of (pi, qi+1), c(PLT) ≥ κ(V − 1). θ · η(pi, qi+1) ≤ (η ∗ x∗)(E(Li, Li+1)). (21) (22) For each layer Li with 1 < i < ℓ, consider a bidirected flow network on G(Li) whose capacities are given by x∗. From Corollary 7, we can route flow of θ from qi to pi. This flow can be decomposed into cycles and paths from qi to pi; thus, by the choice of Pi, From (22) and (23), θ · η(Pi) ≤ (η ∗ x∗)(E(Li)). θ · η(pi, qi+1) + X1<i<ℓ θ · η(Pi) (η ∗ x∗)(E(Li, Li+1)) + X1<i<ℓ θ · η(PLT) = X1≤i<ℓ ≤ X1≤i<ℓ ≤ (η ∗ x∗)(E) = c(x∗) − x∗(E) = c(x∗) − (V − 1) < σ(V − 1). (η ∗ x∗)(E(Li)) (23) (24) Let G′E be GE after finishing the execution of Steps 13-16 of Algorithm 1; PLT denotes the number of edges on PLT. We have c(Hout) ≤ c(HC) ≤ c(G′E) = c(PLT) + 2 [(V − 1) − PLT] = c(PLT) + 2 [(V − 1) − {c(PLT) − η(PLT)}] = 2(V − 1) − c(PLT) + 2η(PLT) ≤ (cid:20)2 − κ + ≤ (cid:18)2 − κ + θ (cid:21) · (V − 1) θ (cid:19) c(x∗), 2σ 2σ where the second last line follows from (21) and (24); the last from c(x∗) ≥ V − 1. Case 2. c(PLT) < κ(V − 1). Note that, from the construction of PLT, ℓ − 1 ≤ PLT; hence we have ℓ − 1 ≤ PLT ≤ c(PLT) < κ(V − 1). (25) 21 From each (1 − θ)-narrow cut (Ui, ¯Ui), we can pick an edge di ∈ δ(Ui) with c(di) = 1 due to the β − 1 = 1 − θ. Note that this i=1 of Lemma 3 is not used to derive connectedness of G0. Let f∗Ui choice of α and β satisfies (8). Since the second condition on { f∗Ui}ℓ−1 (9) (it is used in the later part of the proof), we have 2+θ , and τ = 1−2α := edi, α := θ 2+θ , β := 1 c(Hout) ≤ c(HB) ≤ E[c(H)] ω [1 − {2α + β(1 + ω)}](cid:27) c ℓ−1 ≤ (1 + α + β)c(x∗) +(cid:26) max Xi=1 c ℓ−1 f∗Ui! . (1 − θ)2 Xi=1 4(2 + θ) 3 + 2θ 2 + θ c(x∗) + 0≤ω≤τ = f∗Ui! As c(di) = 1 for all i, c(Hout) ≤ 3 + 2θ 2 + θ 3 + 2θ 2 + θ ≤ ≤ (cid:26) 3 + 2θ 2 + θ c(x∗) + c(x∗) + (1 − θ)2 4(2 + θ) (1 − θ)2 4(2 + θ) + (1 − θ)2 4(2 + θ) (ℓ − 1) κ(V − 1) κ(cid:27) c(x∗). mation algorithm for the s-t path TSP under unit-weight graphical metrics, for any ǫ > 0. 6 + 3 4(1+σ) , 2 − κ + 2σ θ , 3+2θ 2+θ + (1−θ)2 4(2+θ) κo. There exists a (ρ + ǫ)-approxi- Corollary 8. Let ρ := maxn 5 Corollary 9. There exists a 1.5780-approximation algorithm for the s-t path TSP under unit-weight graph- ical metrics. Proof. Directly follows from Corollary 8: if we choose, for example, θ = 1.2297 × 10−1, σ = 7.2774 × 10−3, and κ = 5.4045 × 10−1, we have ρ < 1.5780. Corollary 10. The integrality gap of the path-variant Held-Karp relaxation under the unit-weight graphi- cal metric is smaller than 1.6137. Proof. Trivial for V = 2. Let OPT denote the optimal (integral) solution value. Suppose 3 ≤ V ≤ 6. From a similar argument as in the proof of Lemma 10, if there exists a simple s-t path with m edges in G0, OPT ≤ m + 2(V − 1 − m) = 2V − 2 − m. Thus, if there exists a simple s-t path with at least two edges, OPT c(x∗) ≤ 2V − 4 V − 1 ≤ 8 5 < 1.6137. Suppose there does not exist a simple s-t path with more than one edge; then (s, t) ∈ G0 and (s, t) is a bridge of G0. Let (U, ¯U ) be the s-t cut defined by the removal of (s, t) from G0. x∗(s, t) = 0 since 22 2x∗(s, t) = x∗(δ({s})) + x∗(δ({t})) − x∗(δ({s, t})) ≤ 1 + 1 − 2 = 0; therefore, c(x∗) = (c ∗ x∗)(δ(U )) + (c ∗ x∗)(E \ δ(U )) = (c ∗ x∗)(δ(U ) \ {s, t}) + (c ∗ x∗)(E \ δ(U )) ≥ 2x∗(δ(U ) \ {s, t}) + x∗(E \ δ(U )) = x∗(δ(U )) + x∗(E) ≥ V and OPT c(x∗) ≤ 2V − 3 V ≤ 3 2 < 1.6137. Suppose V ≥ 7. Choose θ = 3.7304 × 10−1, σ = 8.5757 × 10−2, and κ = 8.4614 × 10−1; from Lemma 13, 3 4(1 + σ) + 7 12(V − 1)(1 + σ)(cid:19) c(x∗) 6 + (cid:18) 5 (cid:18)2 − κ + (cid:20) 3 + 2θ 2 + θ   2σ θ (cid:19) c(x∗) (1 − θ)2 4(2 + θ) + κ(cid:21) c(x∗) c(Hout) ≤ max < Qc(x∗),   for some Q < 1.6137. 5 Open questions An immediate open question is in improving the performance guarantee. The fractional T -join dominators constructed in the analyses are not directly derived from the algorithm; a different construction may lead to an improved performance guarantee. One related question is whether α and β can be chosen differently. In the proof of(cid:16) 1+√5 2 (cid:17)-approximation, Lemma 3 can be considered as distributing c(x∗) over the cuts of different capacities. An adaptive choice of α and β after seeing one such distribution does not appear to improve the analysis; from Yao’s Lemma, oblivious but stochastic choice of α and β does not either. A bigger open question is whether the techniques presented in this paper can be extended to the circuit case as well. Given the successful adaptation of the techniques devised in one variant to the other in the unit-weight graphical metric case, whether the present techniques can be extended to beat the longstanding 3/2 barrier of the general-metric circuit problem becomes an interesting question. It appears that the layered structure of τ -narrow cuts or the parity argument on them are less likely to directly extend to the circuit case, as the arguments rely on the characteristics of the path case; what could be more promising is the approach of repairing deficient cuts using a set of vectors obtained from an auxiliary flow network, since this approach might extend to work with some different type of “fragile cut structure”. 23 References [1] H.-C. An, R. Kleinberg, and D. B. Shmoys. Improving Christofides’ Algorithm for the s-t Path TSP. CoRR, abs/1110.4604, 2011. [2] H.-C. An, R. D. Kleinberg, and D. B. Shmoys. Approximation algorithms for the bottleneck asym- metric traveling salesman problem. In APPROX-RANDOM, pages 1–11, 2010. [3] A. Archer, M. Bateni, M. Hajiaghayi, and H. J. Karloff. Improved approximation algorithms for prize-collecting Steiner tree and TSP. SIAM J. Comput., 40(2):309–332, 2011. [4] A. Asadpour, M. X. Goemans, A. M ֒adry, S. Oveis Gharan, and A. Saberi. An O(log n/ log log n)- approximation algorithm for the asymmetric traveling salesman problem. In SODA ’10: Proceedings of the 21st Annual ACM-SIAM Symposium on Discrete Algorithms, pages 379–389, 2010. [5] E. Balas. The prize collecting traveling salesman problem. Networks, 19(6):621–636, 1989. [6] D. Bienstock, M. X. Goemans, D. Simchi-Levi, and D. P. Williamson. A note on the prize collecting traveling salesman problem. Math. Program., 59:413–420, 1993. [7] K. Chaudhuri, B. Godfrey, S. Rao, and K. Talwar. Paths, trees, and minimum latency tours. In Proceedings of the 44th Annual IEEE Symposium on Foundations of Computer Science, FOCS ’03, pages 36–45, 2003. [8] N. Christofides. Worst-case analysis of a new heuristic for the travelling salesman problem. Technical Report 388, Graduate School of Industrial Administration, CMU, 1976. [9] F. A. Chudak, T. Roughgarden, and D. P. Williamson. Approximate k-MSTs and k-Steiner trees via the primal-dual method and Lagrangean relaxation. Math. Program., 100(2):411–421, 2004. [10] J. Edmonds and E. Johnson. Matching: A well-solved class of integer linear programs. In M. Junger, G. Reinelt, and G. Rinaldi, editors, Combinatorial Optimization — Eureka, You Shrink!, volume 2570 of Lecture Notes in Computer Science, pages 27–30. Springer Berlin / Heidelberg, 2003. [11] M. X. Goemans. Worst-case comparison of valid inequalities for the TSP. Math. Program., 69:335– 349, 1995. [12] M. X. Goemans. Combining approximation algorithms for the prize-collecting TSP. CoRR, abs/0910.0553, 2009. [13] M. X. Goemans and D. Bertsimas. Survivable networks, linear programming relaxations and the parsimonious property. Math. Program., 60:145–166, 1993. [14] M. X. Goemans and D. P. Williamson. A general approximation technique for constrained forest problems. SIAM J. Comput., 24(2):296–317, 1995. [15] M. Grotschel, L. Lov´asz, and A. Schrijver. The ellipsoid method and its consequences in combinato- rial optimization. Combinatorica, 1(2):169–197, 1981. [16] M. Held and R. M. Karp. The traveling-salesman problem and minimum spanning trees. Operations Research, 18(6):1138–1162, 1970. 24 [17] J. A. Hoogeveen. Analysis of Christofides’ heuristic: some paths are more difficult than cycles. Operations Research Letters, 10(5):291–295, 1991. [18] T. Momke and O. Svensson. Approximating graphic TSP by matchings. In Proceedings of the 52nd Annual IEEE Symposium on Foundations of Computer Science, FOCS ’11, pages 560–569, 2011. [19] M. Mucha. 13/9-approximation for graphic TSP. CoRR, abs/1108.1130, 2011. [20] S. Oveis Gharan, A. Saberi, and M. Singh. A randomized rounding approach to the traveling salesman problem. In Proceedings of the 52nd Annual IEEE Symposium on Foundations of Computer Science, FOCS ’11, pages 550–559, 2011. [21] D. B. Shmoys and D. P. Williamson. Analyzing the Held-Karp TSP bound: a monotonicity property with application. Information Processing Letters, 35(6):281–285, 1990. [22] L. A. Wolsey. Heuristic analysis, linear programming and branch and bound. In Combinatorial Optimization II, volume 13 of Mathematical Programming Studies, pages 121–134. Springer Berlin Heidelberg, 1980. A An LP-based new analysis of the path-variant Christofides’ algorithm In this appendix, we present a new analysis of the path-variant Christofides’ algorithm [8, 17] for the metric s-t path TSP, and show how the critical case characterized by this analysis can lead to an improvement. The analysis compares the output solution value to the LP optimum of the path-variant Held-Karp relaxation, thereby proving the upper bound of 5/3 on the integrality gap of the path-variant Held-Karp relaxation. We note that the LP optimum is never computed by the algorithm. First we recall the following definition of the circuit-variant Held-Karp relaxation: Definition 6 ([16]). The circuit-variant Held-Karp relaxation is the following: c(x) minimize subject to x(δ(S)) ≥ 2, ∀S ( V, S 6= ∅; x(δ({v})) = 2, ∀v ∈ V ; x ≥ 0. (26) Let G = (V, E) be the input complete graph with cost function c : E → R+ and the endpoints s, t ∈ V . The path-variant Christofides’ algorithm first finds a minimum spanning tree Tmin of G; it then computes a minimum T -join J, where T ⊂ V is the set of the vertices with the “wrong” parity of degree in Tmin: i.e., T is the set of odd-degree internal points and even-degree endpoints in Tmin. Lastly, the algorithm shortcuts an Eulerian path of the multigraph Tmin ∪ J to obtain the output Hamiltonian path H. We give two different bounds on the cost of J, which together will establish the performance guarantee. Let x∗ ∈ RE be the LP optimum of the path-variant Held-Karp relaxation. Lemma 14. c(Tmin) ≤ c(x∗). Proof. As can be seen from Observation 1, the path-variant Held-Karp polytope is contained in the span- ning tree polytope. The lemma follows from this observation, since Tmin is a minimum spanning tree. Lemmas 15 and 16 give the two bounds. 25 2 {c(x∗) + c(s, t)}. Lemma 15. c(J) ≤ 1 Proof. Let x∗circuit := x∗ + e(s,t): i.e., x∗circuit is obtained by “adding” the edge (s, t) to x∗. Then x∗circuit is a feasible solution to the circuit-variant Held-Karp relaxation (see (1) and (26)). Let HKcircuit be the optimal value of the circuit-variant Held-Karp relaxation and we have c(J) ≤ ≤ = HKcircuit 1 2 1 2 1 2 {c(x∗) + c(s, t)} , c(x∗circuit) where the first inequality follows from [22, 21]. Lemma 16. c(J) ≤ c(x∗) − c(s, t). Proof. Let P Tmin that J′ is a T -join: v ∈ V has even degree in P Tmin the multigraph Tmin ∪ J′ = (Tmin ∪ Tmin) \ P Tmin that v has odd degree in J′ if and only if v ∈ T . st st We have be the path between s and t on Tmin. Consider an edge set J′ := Tmin \ P Tmin . Note if and only if v is internal; thus, v has even degree in if and only if v is an internal point, and this shows st st c(J) ≤ c(J′) = c(Tmin) − c(P Tmin ≤ c(x∗) − c(s, t). st ) The last inequality follows from Lemma 14 and the triangle inequality. Theorem 8. c(H) ≤ 5 algorithm, and the integrality gap of the path-variant Held-Karp relaxation is at most 5/3. 3 c(x∗); therefore, the path-variant Christofides’ algorithm is a 5/3-approximation Proof. We have c(H) ≤ c(Tmin) + c(J) ≤ c(x∗) + min(cid:20) 1 c(x∗) + min(cid:20) 1 = 2 {c(x∗) + c(s, t)} , c(x∗) − c(s, t)(cid:21) 2(cid:26)− c(x∗) + c(s, t)(cid:27) , 1 3 1 3 c(x∗) − c(s, t)(cid:21) 5 3 5 3 ≤ c(x∗), (27) where the second inequality follows from Lemmas 14, 15 and 16. We observe that the equality of (27) is achieved when c(s, t) = 1 3 c(x∗), and this is the critical case of this analysis that determines the performance guarantee proven. Hence, if we can improve the performance guarantee only near this critical case, such an improvement would lead to a better approximation ratio. We demonstrate this approach, by presenting how this analysis combines with the results of Oveis Gharan et al. [20] on the unit-weight graphical metric TSP to yield a comparable result in the s-t path TSP. 26 We consider the s-t path TSP under the unit-weight graphical metric; we show how to modify the 3 c(x∗), this modified algorithm of Oveis Gharan et al. for the path case and that, when c(s, t) is close to 1 algorithm carries a performance guarantee that is slightly better than 5/3. First we review the results in Oveis Gharan et al. [20]. In the following, the parameters ǫ1, ǫ2, γ, δ and ρ can be chosen as follows: ǫ1 = 1.875· 10−12, ǫ2 = 5· 10−2, γ = 10−7, δ = 6.25· 10−16, ρ = 1.5· 10−24, and n denotes V . Definition 7 (Nearly integral edges). An edge e is nearly integral with respect to x ∈ RE if xe ≥ 1 − γ. Definition 8. For some constant ν ≤ 1 5 and k ≥ 2, a maximum entropy distribution over spanning trees with approximate marginal x ∈ RE is a probability distribution µ defined by λ ∈ RE such that µ(T ) ∝ Qe∈T λe for every spanning tree T and the marginal probability of every edge e is no greater than (1 + ν Definition 9 (Good edges). A cut is (1+δ)-near-minimum if its weight is at most (1+δ) times the minimum cut weight. An edge e is even with respect to F ⊂ E if every (1 + δ)-near-minimum cut containing e has even number of edges intersecting with F . For a circuit-variant Held-Karp feasible solution x∗circuit, consider x∗circuit as the edge weight and let F be a spanning tree sampled from a maximum entropy distribution with approximate marginal (1 − 1 n )x∗circuit. We say an edge e is good with respect to x∗circuit if the probability that e is even with respect to F is at least ρ. nk )xe. Theorem 9 (Structure Theorem). Let x∗circuit be a feasible solution to the circuit-variant Held-Karp re- laxation, and let µ be a maximum entropy distribution over spanning trees with approximate marginal (1 − 1 n )x∗circuit. There exist small constants ǫ1, ǫ2 > 0 such that at least one of the following is true: 1. there exists a set E∗ ⊂ E such that x(E∗) ≥ ǫ1n and every edge in E∗ is good with respect to x∗circuit; 2. there exist at least (1 − ǫ2)n edges that are nearly integral with respect to x∗circuit. Lemma 17. Suppose that Case 1 of Theorem 9 holds and T is sampled from µ. Let T be the set of odd-degree vertices in T , then a minimum T -join J satisfies E[c(J)] ≤ c(x∗circuit)( 1 2 − ǫ1δρ 4(1 + δ) ). We are now ready to present the algorithm. Algorithm 2 describes the entire algorithm for the s-t path TSP under the unit-weight graphical metric. It first computes the LP optimum x∗. If c(s, t) is close to 1 3 c(x∗), we run a modified version of Oveis Gharan, Saberi, and Singh’s algorithm (Cases A1 and A2); otherwise, we invoke Christofides’ algorithm (Case B). Parameters σl, σu and ǫ′2 are to be chosen later. First we show that we can have a Structure Theorem analogous to Theorem 9 by adjusting ǫ2 and replacing n with (n − 1) in Case 2. The following corollary states that either there are good edges of significant weight with respect to x∗circuit or there are many nearly integral edges with respect to x∗. Corollary 11. Let x∗ be a feasible solution to the path-variant Held-Karp relaxation and x∗circuit := x∗ + e(s,t). Let µ be a maximum entropy distribution over spanning trees with approximate marginal (1 − 1 n )x∗circuit. There exist small constants ǫ1, ǫ′2 > 0 such that at least one of the following is true: 27 3 + α)c(x∗) for α ∈ [−σl, σu] then if at least (1 − ǫ′2)(n − 1) edges are nearly integral w.r.t. x∗ then {Case A1} Algorithm 2 Algorithm for the s-t path TSP under the unit-weight graphical metric Input: Complete graph G = (V, E) with cost function c : E → Z>0; endpoints s, t ∈ V . Output: Hamiltonian path between s and t. 1 x∗ ←optimal solution to the path-variant Held-Karp relaxation 2 if c(s, t) = ( 1 3 4 5 6 7 8 9 10 11 12 13 14 Find a minimum spanning subgraph F ′ containing all the nearly integral edges. Find a minimum spanning tree T of F ′. Let T be the set of odd-degree internal points and even-degree endpoints in T . Compute a minimum T -join J; L ← T ∪ J. x∗circuit := x∗ + e(s,t) Sample spanning tree T from max-entropy distribution with approx. marginal (1 − 1 Let T be the set of odd-degree vertices in T . Compute a minimum T -join J; L0 ← T ∪ J. if (s, t) ∈ L0 then L ← L0 \ {(s, t)} else L ← L0 ∪ {(s, t)} end if n )x∗circuit. else {Case A2} end if 15 else {Case B} Find a minimum spanning tree T of G. Let T be the set of odd-degree internal points and even-degree endpoints in T . Compute a minimum T -join J; L ← T ∪ J. 16 17 18 19 end if 20 Shortcut an Eulerian path of the multigraph L to obtain a Hamiltonian path H; output it. 1. there exists a set E∗ ⊂ E such that x(E∗) ≥ ǫ1n and every edge in E∗ is good with respect to x∗circuit; 2. there exist at least (1 − ǫ′2)(n − 1) edges that are nearly integral with respect to x∗. Proof. By Theorem 9, at least one of the two cases of Theorem 9 holds. Case 1 of Theorem 9 and Case 1 of this corollary are identical, so consider when Case 2 of Theorem 9 holds. Recall that ǫ2 was chosen as 5 · 10−2; we choose ǫ′2 = 6 · 10−2. Suppose n ≤ 19. x∗circuit has at least (1− ǫ2)n nearly integral edges; thus, x∗ has at least ⌈(1− ǫ2)n⌉− Suppose n ≥ 20. x∗ has at least 1 = n − 1 ≥ (1 − ǫ′2)(n − 1) nearly integral edges. (1 − ǫ2)n − 1 = (1 − ǫ2)(n − 1) − ǫ2 ǫ2)(n − 1) 20 19 ≥ (1 − ≥ (1 − ǫ′2)(n − 1) nearly integral edges. Lemma 18. In Case A1, c(H) ≤ ( 5 Proof. The following proof is adapted from [20] and modified for the path case. 3 − CA1)c(x∗) for some cA1 > 0. 28 Let S′ be the set of nearly integral edges. Since the metric is defined by an unweighted connected 3, we know that S′ is a union of γ . Thus, T ∩ S′ ≥ (n − 1)(1 − ǫ′2)(1 − γ) graph, c(F ′) = c(S′) + F ′ \ S′ ≤ (c∗x∗)(S′) disjoint cycles and paths and the lengths of cycles are at least 1 and T \ S′ ≤ (n − 1)(ǫ′2 + γ) ≤ c(x∗)(ǫ′2 + γ). Let S = S′ ∩ T . 1−γ + F ′ \ S′. From γ < 1 We construct a fractional T -join dominator y as follows. 1 x∗e x∗ e 2(1−γ) if e ∈ T \ S if e ∈ E \ T if e ∈ S ye =  We claim that y is a fractional T -join dominator. Let (U, ¯U ) be any cut that has an odd number of vertices in T on one side. If there exists an edge e ∈ (T \ S) ∩ δ(U ), then y(δ(U )) ≥ ye = 1. So suppose from now on that δ(U ) ∩ T ⊂ S. Then δ(U ) ∩ S = δ(U ) ∩ T . If U is nonseparating, U contains odd number of odd-degree vertices, and thus δ(U ) ∩ T is odd. We have x∗(δ(U )) ≥ 2 from the Held-Karp formulation and thus (y(δ(U )) ≥ x∗(δ(U ) \ T ) ≥ 1 y(δ(U )) ≥ y(δ(U ) ∩ S) ≥ 3 1−γ if δ(U ) ∩ T = 1 2(1−γ) > 1 if δ(U ) ∩ S ≥ 3. If (U, ¯U ) is an s-t cut, then U contains even number of odd-degree vertices, and thus δ(U ) ∩ T is even. We have (δ(U ) ∩ T ) 6= ∅ since T is connected and y(δ(U )) ≥ y(δ(U ) ∩ S) ≥ 2 Thus y is a fractional T -join dominator. Now, 1 − γ 2(1 − γ) = 1. + c(T \ S) + c(T \ S) + (c ∗ x∗)(E \ T ) + + 2c(x∗)(ǫ′2 + γ) + (c ∗ x∗)(E \ S) (c ∗ x∗)(S) 2(1 − γ) ≤ c(H) ≤ c(T ) + c(y) (c ∗ x∗)(S) 3(c ∗ x∗)(S) 2(1 − γ) 3 1 − γ ≤ ≤ c(x∗)( ≤ c(x∗)( 2(1 − γ) 5 3 − CA1) + 2ǫ′2 + 2γ) for some CA1 > 0. For example, we can choose cA1 = 4 · 10−2. Lemma 19. In Case A2, E[c(H)] ≤ ( 5 Proof. First we have 3 − CA2)c(x∗) for some CA2 > 0. E[c(T )] ≤ c(cid:18)(1 + ≤ (1 + ≤ (1 − 1 5n2 )(1 − 4 5n 4 3 )( ν nk )(1 − 1 n 1 n )( 4 3 + α)c(x∗). )x∗circuit(cid:19) + α)c(x∗) 29 From Lemma 17, We have E[c(J)] ≤ ( 4 3 + α)c(x∗)( 1 2 − ǫ1δρ 4(1 + δ) ). Pr[(s, t) ∈ L0] ≥ Pr[(s, t) ∈ T ] = n − 1 − E[T \ (s, t)] ≥ n − 1 − (n − 2 + ≥ n − 1 − (n − 2 + ≥ 1 − 1 n 1 n 7 5n )(1 + )(1 + ν nk ) 1 5n2 ) and hence E[c(H)] ≤ E[c(T )] + E[c(J)] − (1 − 4 5n 7 5n )( 4 3 1 3 ǫ1δρ )( ≤ c(x∗)(cid:26)(1 − −(1 − 5 3 − = c(x∗)(cid:26)( ≤ c(x∗)( 5 3 − CA2) c(s, t) ǫ1δρ ) 4(1 + δ) + α) + ( + α)( + α) + )c(s, t) + 7 5n 1 2 − + α)(cid:27) ǫ1δρ 7 5n 4 3 7 5n 1 2 − ( 1 3 ) + α( 3(1 + δ) 4(1 + δ) ) − 1 n ( 2 15 − 2α)(cid:27) for some CA2 > 0 by choosing sufficiently small σl, σu > 0. For example, we can choose σl = 7.8·10−52, σu = 3.9 · 10−52 and CA2 = 3.9 · 10−52. Lemma 20. In Case B, c(H) ≤ ( 5 Proof. Suppose that c(s, t) < ( 1 3 − CB)c(x∗) for some CB > 0. 3 − σl)c(x∗). From Lemmas 14 and 15, it follows that c(H) ≤ c(T ) + c(J) < c(x∗) + = (cid:18) 5 3 − 1 2(cid:26)c(x∗) + ( 2(cid:19) c(x∗). σl 1 3 − σl)c(x∗)(cid:27) Suppose c(s, t) > ( 1 3 + σu)c(x∗). From Lemmas 14 and 16, c(H) ≤ c(T ) + c(J) < c(x∗) +(cid:26)c(x∗) − ( 3 − σu(cid:19) c(x∗). = (cid:18) 5 1 3 + σu)c(x∗)(cid:27) Now choose CB := min( σl 2 , σu). 30 Lemmas 18, 19 and 20 yield the following theorem. Theorem 10. For some ǫ > 0, Algorithm 2 is a ( 5 under the unit-weight graphical metric. 3 − ǫ)-approximation algorithm for the s-t path TSP Proof. In Cases A1 and B, the multigraph L is the union of a spanning tree and a T -join where T is the set of the vertices with the wrong parity of degree. Thus, L has an Eulerian path between the two endpoints. In Case A2, L0 is Eulerian and hence 2-edge-connected; L ⊃ L0 \ {(s, t)} is therefore connected By choosing ǫ = min{CA1, CA2, CB}, ǫ = 3.9 · 10−52 for example, we have E[c(H)] ≤ ( 5 3 − ǫ)c(x∗) and L has an Eulerian path between the two endpoints. from Lemmas 18, 19 and 20. Thus, Algorithm 2 is a ( 5 3 − ǫ)-approximation algorithm. 31
1609.01870
6
1609
2016-10-21T14:57:21
Revisiting calculation of moments of number of comparisons used by the randomized quick sort algorithm
[ "cs.DS" ]
We revisit the method of Kirschenhofer, Prodinger and Tichy to calculate the moments of comparisons used by the quick sort algorithm. We reemphasize that this approach helps in calculating these quantities with less computation. We also point out that as observed by Knuth this method also gives moments for total path length of a binary search tree built over a random set of n keys.
cs.DS
cs
Revisiting calculation of moments of number of comparisons used by the randomized quick sort algorithm Sumit Kumar Jha Preprint of the following paper in Discrete Mathematics, Algorithms and Applications: http://www.worldscientific.com/doi/pdf/10.1142/S179383091750001X Abstract. We revisit the method of Kirschenhofer, Prodinger and Tichy to calculate the mo- ments of number of comparisons used by the randomized quick sort algorithm. We reemphasize that this approach helps in calculating these quantities with less computation. We also point out that as observed by Knuth this method also gives moments for total path length of a binary search tree built over a random set of n keys. 1. Introduction Consider the following variant of quick sort algorithm from [9]: the quick sort algorithm recursively sorts numbers in an array by partitioning it into two smaller and independent subarrays, and thereafter sorting these parts. The partitioning procedure chooses the last element in the array as pivot and puts it in its right place where numbers to the left of it are smaller than it, and those to its right are larger than it. For purposes of this analysis assume that the input array to the quick sort algorithm contains distinct numbers which are randomly ordered. We may assume the input to the algorithm is simply a permutation of {1, 2,··· , n} (if the input array has n elements). Let Sn be the set of all n! permutations of {1, 2,··· , n}. Consider a uniform probability distribution on the set Sn, and define for all σ ∈ Sn, Cn(σ) to be the number of comparisons used to sort σ by the quick sort algorithm. We wish to calculate mean and variance of Cn over the uniform distribution on Sn. Our aim here is to obtain following [6] [5] Theorem 1.1 (Knuth [8]). We have Mean(Cn) = 2((n + 1)Hn − n); and over the uniform probability distribution on Sn. Here we have used the notation Hn = (cid:80)n Var(Cn) = 7n2 − 4(n + 1)2H (2) n − 2(n + 1)Hn + 13n, 1 k k=1 n =(cid:80)n and H (2) 1 k2 . k=1 Before proceeding we would like to point out that Hennequin [3] has computed the first five cumulants of the number of comparisons of Quicksort. Also, the variance of the number of comparisons of Quicksort is computed in [4]. 2. Calculation of mean and variance Let an,s be the number of permutations of n elements requiring a total of s comparisons to sort by the procedure of quicksort. 1 2 SUMIT KUMAR JHA We start by defining the corresponding probability generating function: Theorem 2.1. For n ≥ 1 (2.1) and (2.2) Gn(z) = an,k zk n! . (cid:88) (cid:88) k≥0 1≤j≤n Gn(z) = zn+1 n Gn−j(z)Gj−1(z), G0(z) = 1. (cid:88) (cid:18)n − 1 (cid:19) (cid:88) (cid:88) k − 1 (cid:88) 1≤k≤n i+j=s−(n+1) Proof. The first partitioning stage requires n + 1 comparisons (for some other variants this might be n − 1). If the pivot element is kth largest, then the sub arrays after partitioning are of sizes k − 1 and n − k. Thus we can write (2.3) an,s = an−k,i ak−1,j. Multiplying equation (2.3) by zs and dividing by n! we get ·(cid:110) (cid:88) · zs−(n+1)(cid:110) zs n 1≤k≤n (cid:88) 1≤k≤n = = zn+1 n ans zs = zs n · ak−1,j (k − 1)! n! coefficient of zs−(n+1) in Gn−k(z) · Gk−1(z) an−k,i (n − k)! i+j=s−(n+1) 1≤k≤n coefficient of zs−(n+1) in Gn−k(z) · Gk−1(z) (cid:111) (cid:111) after which summing on s gives us equation (2.1). We will now consider the double generating function H(z, u) defined by (cid:88) n≥0 Gn(z)un. (2.4) H(z, u) = Corollary 2.2. We have (2.5) and (2.6) ∂H(z, u) ∂u = z2 · H 2(z, zu), H(1, u) = (1 − u)−1. Proof. From equation (2.1) we have = z2(cid:88) (uz)n−1 (cid:88) ∂H(z, u) (uz)n−1 ·(cid:8)coefficient of (uz)n−1 in H(z, uz) · H(z, uz)(cid:9) Gn−j(z)Gj−1(z) 1≤j≤n n≥1 ∂u = z2(cid:88) n≥1 = z2 · H(z, zu) · H(z, zu). Equation (2.6) follows from the fact that Gn(1) = 1. Now we write the sth factorial moments βs(n) of the random variable with the aid of the probability generating function Gn(z): (2.7) βs(n) = (cid:20) ds (cid:21) dzs Gn(z) . z=1 (cid:3) (cid:3) REVISITING CALCULATION OF MOMENTS OF NUMBER OF COMPARISONS 3 The generating functions fs(u) of βs(n) are (2.8) fs(u) = βs(n)un. By Taylor's formula and equation (2.7) we get (2.9) H(z, u) = fs(u) (z − 1)s s! . Theorem 2.3. For integer s ≥ 0 we have s(u) = s! · (cid:88) f(cid:48) i+j+k+l+m=s ai · f (k) j (u) · uk+m (u) · f (m) j! · k! · l! · m! l , (2.10) where (cid:88) (cid:88) n≥0 s≥0  (cid:88) (cid:88) k≥0 k≥0 ak = 1 2 1 0 if k = 0; if k = 1; if k = 2; if k > 2. Proof. Using Taylor's theorem we can write f (k) j fj(x) = (u)(x − u)k k! which on substituting x = uz gives (2.11) fj(uz) = f (k) j (u)(z − 1)kuk k! . Now substituting equation (2.9) in equation (2.5) gives: (cid:88) (z − 1)s f(cid:48) s(u) s! = i≥0 (cid:88) p (u)(z − 1)lul f (l) s≥0 (z − 1)p ai(z − 1)i ·(cid:88) (cid:88) (cid:88) (z − 1)h (cid:88) where in the second last line we replaced z2 by (cid:80) h≥0 p≥0 l≥0 p! = l! i+j+k+l+m=h both sides of the equation gives r! r≥0 ai · 1 j! = z2 ·(cid:88) ·(cid:88) p≥0 (z − 1)p fp(uz) p! (z − 1)r (cid:88) ·(cid:88) r≥0 f (m) r fr(uz) (z − 1)r r! (u)(z − 1)mum m≥0 m! · f (k) j (u) uk k! · 1 l! · f (m) l (u) um m! s(u) = s! · (cid:88) f(cid:48) i+j+k+l+m=s i≥0 ai(z − 1)i. Now comparing coefficients on ai · f (k) j (u) · uk+m (u) · f (m) j! · k! · l! · m! l . (cid:3) Remark 2.4. For asymptotic theory of differential equations originating here we recommend reader the paper [1]. Corollary 2.5. We have (2.12) (2.13) f0(u) = (1 − u)−1, f1(u) = 2 (1 − u)2 log 1 1 − u , 4 SUMIT KUMAR JHA (2.14) f2(u) = 8 log2(1 − u) (1 − u)3 − 8 log(1 − u) (1 − u)3 − 4 log2(1 − u) (1 − u)2 + 12 log(1 − u) (1 − u)2 + 6 (1 − u)3 − 6 (1 − u)2 . Proof. The equation (2.12) follows from the fact that β0(n) = 1 for all n ≥ 0. Setting s = 1 in equation (2.10) gives 1(u) = a1 · f (0) f(cid:48) 0 (u) · f (0) 0 (u) + f (1) 0 (u) · f (0) 0 (u) · u + f (1) 0 (u) · f (0) 0 (u) + f (0) f1(u) (1 − u) where we used the fact that f0(u) = (1 − u)−1. The above equation is (1 − u)2 + (1 − u)3 + (1 − u)3 + +f (0) = u u 2 1 (u) · f (0) 0 (u) · u 0 (u) · f (0) 1 (u) f1(u) (1 − u) + , (2.15) Solving the linear differential equation (2.15) by multiplying with integrating factor (1− u)2 gives (1 − u)3 + (1 − u)2 . = 1(u) − 2f1(u) f(cid:48) 1 − u 2u 1 − u Plugging s = 2 in (2.10) and solving the resultant differential equation gives (1 − u)2 log (1 − u)2 log + f1(0) = 1 − u f1(u) = . 2 1 1 f2(u) = (1 − u)3 − 8 log(1 − u) 8 log2(1 − u) (1 − u)3 − 4 log2(1 − u) (1 − u)2 + 12 log(1 − u) (1 − u)2 + 6 (1 − u)3 − 6 (1 − u)2 . (cid:3) Corollary 2.6. We have β1(n) = 2((n + 1)Hn − n), and β2(n) = 4(n + 1)2(H 2 n − H (2) n ) + 4(n + 1)2Hn − 8(n + 1)Hn + 8nHn − 4nHn(5 + 3n) + 11n2 + 15n. 2 2 Proof. We use following expansions from [2] (1 − u)m+1 log 1 − u = (Hn+m − Hm) (cid:19) (cid:88) n≥0 (cid:18) 1 (cid:88) = n≥0 1 (cid:18) 1 1 − u (cid:19) (cid:18)n + m (cid:19) n un; (cid:18)n + m n ((Hn+m − Hm)2 − (H (2) n+m − H (2) m )) 1 (1 − u)m+1 log2 to conclude the assertion. Proof of Theorem 1.1. We conclude the results after noting Mean(Cn) = β1(n), Var(Cn) = β2(n) − (β1(n))2 + β1(n). (cid:19) un, (cid:3) (cid:3) 3. Similar Partial Differential Functional Equations We point out that following two examples from [7] can be analyzed using the method employed here: 1. Moments of total path length Ln of a binary search tree built over a random set of n keys can be extracted from the where L(z, u) =(cid:80) ∂L(z, u) ∂z = L2(zu, u), ∂L(0, u) ∂z = 1, n≥0 Ln(u)zn is the bivariate generating function. REVISITING CALCULATION OF MOMENTS OF NUMBER OF COMPARISONS 5 2. A digital search tree for which the bivariate generating function L(z, u) satisfies ∂L(z, u) ∂z = L2 with L(z, 0) = 1. (cid:18) 1 2 (cid:19) zu, u , References [1] Hua-Huai Chern1, Hsien-Kuei Hwang, and Tsung-Hsi Tsai. An asymptotic theory for cauchy-euler differential equations with applications to the analysis of algorithms. http://www.stat.sinica.edu.tw/chonghi/Papers/ An_asymptotic_theory_for_Cauchy-Euler_differential_equations.pdf, 2002. [2] Daniel H. Greene and Donald E. Knuth. Mathematics for the Analysis of Algorithms: Modern Birkhuser Classics. Birkhauser Basel, 3rd edition, 2007. [3] Pascal Hennequin. Analyse en moyenne d'algorithmes, tri rapide et arbres de recherche. http://algo.inria. fr/AofA/Research/src/Hennequin.PhD.html/, 1991. [4] Vasileios Iliopoulos. The quicksort algorithm and related topics. http://repository.essex.ac.uk/13266/, 2013. [5] P. Kirschenhofer, H. Prodinger, and R.F. Tichy. Ober einige funktionaldifferentialgleichungen aus der analyse von algorithmen. http://math.sun.ac.za/~hproding/pdffiles/hlawka_funktionalgleichungen.pdf. [6] P. Kirschenhofer, H. Prodinger, and R.F. Tichy. A contribution to the analysis of in situ permutation. Glasnik Mathematicki, 22(42):269 -- 278, 1987. [7] Charles Knessl and Wojciech Szpankowskit. Quicksort algorithm again revisited. http://docs.lib.purdue.edu/ cgi/viewcontent.cgi?article=2351&context=cstech, 1997. [8] Donald E. Knuth. The Art of Computer Programming, Volume 3: (2Nd Ed.) Sorting and Searching. Addison Wesley Longman Publishing Co., Inc., Redwood City, CA, USA, 1998. [9] Robert Sedgewick and Kevin Wayne. Algorithms. Addison-Wesley Professional, 4th edition, 2011. Center for Security, Theory, and Algorithmic Research, International Institute of Information Technology, Hyderabad, India E-mail address: [email protected]
1603.02457
1
1603
2016-03-08T10:19:06
On Self-Reducibility and Reoptimization of Closest Substring Problem
[ "cs.DS" ]
In this paper, we define the reoptimization variant of the closest substring problem (CSP) under sequence addition. We show that, even with the additional information we have about the problem instance, the problem of finding a closest substring is still NP-hard. We investigate the combinatorial property of optimization problems called self-reducibility. We show that problems that are polynomial-time reducible to self-reducible problems also exhibits the same property. We illustrate this in the context of CSP. We used the property to show that although we cannot improve the approximability of the problem, we can improve the running time of the existing PTAS for CSP.
cs.DS
cs
On Self-Reducibility and Reoptimization of Closest Substring Problem Jeffrey A. Aborot, Henry Adorna, Jhoirene B. Clemente Algorithms and Complexity Laboratory Department of Computer Science [email protected], [email protected], [email protected] College of Engineering University of the Philippines Diliman ABSTRACT In this paper, we define the reoptimization variant of the closest substring problem (CSP) under sequence addition. We show that, even with the additional information we have about the problem instance, the problem of finding a closest substring is still NP-hard. We investigate the combinatorial property of optimization problems called self-reducibility. We show that problems that are polynomial-time reducible to self-reducible problems also exhibits the same property. We illustrate this in the context of CSP. We used the prop- erty to show that although we cannot improve the approx- imability of the problem, we can improve the running time of the existing PTAS for CSP. Keywords reoptimization, closest substring problem, approximation INTRODUCTION 1. The consensus pattern problem is a combinatorial problem applied to a wide range of applications from string match- ing problems in genomic sequences [4] to finding repeated patterns in graphs [7] and time-series databases [11]. Due to its utmost importance in the field of genomics, several ef- forts have been made to characterize the computational re- quirements needed to solve the problem. If the set of input instances is constrained only to a set of input strings, the problem is known as the closest substring problem (CSP). The problem seeks to identify a pattern that occurs approx- imately in each of the given set of sequences. It has been shown that the CSP is NP-hard [9], i.e., unless P=NP, we cannot obtain a polynomial-time algorithm solv- ing the problem. Moreover, it was also shown that fixing parameters such as pattern length or alphabet size, does not address the intractability of the problem [8]. Aside from parameterization attempts, other studies tried to re- lax the condition of always finding the optimal solution by providing approximation algorithms for the problem. The first constant-factor approximation algorithm is presented in [10], then subsequently improved in [12]. These results in- clude CSP to the class of problems that are constant-factor approximable (APX). In addition to this, several studies [12, 13, 14] even presented a polynomial-time approximation scheme (PTAS) for the problem. To address the intractability and to improve the solution quality of approximation algorithms, another approach is to use additional information about the problem instance whenever possible. A method called reoptimization has al- ready been applied to a variety of hard problems in the liter- ature. The idea of reoptimization is to make use of a solution to a locally modified version of the input instance. It was shown that reoptimization can help to either improve the ap- proximability and even provide a PTAS for some problems that are APX-hard. These results include improvements for the metric-traveling salesman problem [3], the Steiner tree problem [2], the common superstring problem [1], and hered- itary graph problems [5]. In this paper, we investigate whether reoptimization can help in approximating the closest substring problem. The additional information given in advance is a solution to a smaller instance of the problem. The algorithm for the re- optimization variant of the problem aims to make use of the given solution to become feasible for the larger instance. We show that, using the given solution as a greedy partial solution to the larger instance, we can achieve an additive error (with respect to the optimal solution) that grows lin- early as we increase the number of sequences added to the original instance, which can be worse than the existing σ- approximation algorithms for the original problem. The self-reducibility property of some hard combinatorial problem has been showed to improve the approximability of the problem. However, existing general approaches incur a much longer time for providing a solution with improved quality. Providing an improved ratio is already possible for CSP, due to the existence of a PTAS. However, [17] deemed the PTASs in the literature as impractical for small error bounds. In this paper, we showed that it is possible to im- prove the running time of the existing PTAS for CSP while maintaining the same approximation ratio through reopti- mization. 2. CLOSEST SUBSTRING PROBLEM Given a set of sequences S = {S1, S2, . . . , St} defined over some alphabet Σ, where each Si is of length n, and for some l ≤ n, find a string v of length l and a set of substrings yi each from Si, where v, yi ∈ Σl such that the total Hamming distance d(v, yi) is minimized [9]. t Pi PTAS Approximation Ratio Running Time [Li1999] [Li1999] [Ma2000] 1 + 4Σ−4 √e(√4r+1−3) 1 + O(q log r r ) 2r−1 + 3ǫr 1 + 1 O(l(tn)r+1) O(l(tn)r+1) O(l(tn)r+1Σ √4/ǫ2 log tn)1 The closest substring of a given set of input sequences, may not be unique given the closest substring occurrences yi, for 1 ≤ i ≤ t. So instead of focusing on the closest substring v, we will use the collection of yi's to represent a feasible solu- tion for the problem. We can represent a feasible solution SOL = (y1, y2, . . . , yt) using a sequence of substrings obtained from each of the given sequences to S. We may refer to SOL as a feasible solution and OPT as the optimal solution for input instance S. We can easily obtain a substring v from the collection of occurrences SOL. This is done by aligning all substrings in SOL and taking the majority symbol for each column of the alignment. Let us call this string the consensus of SOL. Moreover, the consensus of OP T is called the closest sub- string of S. It is easy to see that the consensus of OPT will minimize the total Hamming distance for all v ∈ Σl. On the other hand, given a string v ∈ Σl, we can also obtain a set of occurrences SOL by searching the best aligning substrings from each of the sequences in S. Given the closest substring, we can obtain OPT in O(tn). Naively, we can search for the optimal solution by consid- ering all possible locations of the closest substring in each sequence Si from S. For smaller alphabet sizes, it is easier to search over all Σl as compared to O(nt) possible occur- rences. However, since we are considering the general CSP, we do not restrict the alphabet size of the given sequences. 2.1 Related Works Algorithms for the CSP can be categorized into three classes: exact, heuristics, and approximate. Exact algorithms always obtain the optimal solution, but are exhaustive and imprac- tical due to the NP-hardness of the problem. Among the ear- liest exact algorithms, some use graphs to model the prob- lem. This includes WINNOWER [15] which involves finding cliques in graphs obtained from the set of sequences. An in- teger linear programming (ILP) formulation of the problem was also presented in [18]. Some algorithms make use of some strategy in searching through the set of all feasible solutions. Algorithms following this approach are called heuristic algorithms. A majority of these results use probabilistic models to represent solutions. When it is possible to guarantee the quality of the solution by means of identifying the bounds of its solution's cost, it is called an approximation algorithm. Since we do not know the cost of an optimal solution, certain properties of the input instances and the problem itself are needed to design the algorithm. For the CSP, the first constant-factor 2-approximation algorithm was presented in [10], which was subsequently improved in [12]. Table 1: Summary of approximation ratio and run- ning time of the existing PTASs for CSP in the lit- erature. Due to the hardness results presented in [4], several other efforts were made to identify for which types of input in- stances the problem becomes easier to solve. A result in [6] shows that even if the set of input instances is defined over the binary alphabet, we still cannot obtain a practical polynomial-time algorithm for small error bounds. Aside from characterizing input instances, one line of research fo- cused on the parameterization of the problem [8]. Based on these studies, it is shown that the problem is fixed-parameter intractable, i.e., fixing a parameter such as the pattern length or alphabet size will not make the problem easier to solve. A PTAS for a hard problem is set of polynomial-time algo- rithms for which one can specify a certain guaranteed qual- ity. However, since there is a trade-off between the quality of solution and the running time of the algorithm, we can expect a longer running time for smaller error bounds. The summary of the approximation ratio and running time of the existing PTASs for CSP is shown in Table 1. The second on the list is a randomized PTAS for CSP, while the third one assumes a general alphabet Σ. We can see that the approximation ratio of the third PTAS is only dependent on the sampling size r, because the alphabet size is compen- sated in the running time of the algorithm. In contrast, we have the alphabet size as a parameter in the approximation ratio of the first PTAS. We consider the first PTAS in Table 1 for our study, since we will only focus on deterministic algorithms for reoptimiza- tion. Moreover, we assume that the set of input instances are obtained from a general alphabet Σ and so choosing the third PTAS may not be ideal in our case since it will not just have r as a parameter but also the alphabet size. The first PTAS from [12] is shown in Algorithm 1. For each parameter r, it describes an approximation algorithm for CSP that outputs a solution SOL with cost(SOL) ≤ (cid:18)1 + √e√4r + 1 − 3(cid:19) · cost(OP T ) 4Σ − 4 in O(l(tn)r+1) time. An r-sample from a given instance S, i.e., r-sample(S) = {yi1 , yi2 , . . . , yir}, is a collection of r l-length substrings from S. Repetition of substrings are allowed for as long as no two substrings are obtained from the same sequence. Let R(S) denote the set of all possible r-sample from S. The total number of samples in S is (cid:0)tn r(cid:1) which is bounded above by O((tn)r). From each sample, the algorithm obtains a consensus pattern. Solution SOL is then derived by aligning the t closest substrings from the given consensus. The Algorithm 1 minimizes through all possible r-sample in S to provide a feasible solution with a guaranteed quality. Algorithm 1 PTAS for the CSP [Li1999] Input: Set of sequences S, pattern length l, sampling size r Output: SOL and consensus string vsol 1: min = ∞ 2: for each r-sample {yi1 , . . . , yir} from S do v = consensus pattern from {yi1 , . . . , yir} 3: SOL = ∅ 4: for each Si ∈ S do 5: 6: d(v, yi) yi = min ∀yi∈Si SOL = merge yi to SOL end for return SOL with min cost(SOL) 7: 8: 9: 10: end for 1. For a SOL ∈ R(S) there is a corresponding SOLα ∪ {α} ∈ R(Iα). Note that, SOL = (y1, y2, . . . , yt) guar- antees at least one occurrence of the closest substring per sequence. For any atom yi, a solution SOL ∈ R(Syi) corresponds to SOLi ⊕ yi, i.e., (y1, y2, . . . , yi−1, yi+1, . . . , yt) ⊕ yi ∈ R(Syi). Instead of using the operation '∪' for sets, we used ⊕ to denote the merge of an element to a sequence. 2. For any feasible solution SOLi to the reduced instance S \ {Si}, we can obtain a feasible solution SOLi ⊕ yi for S with cost(S, SOLi ⊕ yi) equal to the sum of cost(S \ {Si}, SOLi) and cost(S, yi), since cost(SOLi ⊕ yi) = cost(S \ {Si}, SOLi) + cost(S, yi) = d(v, yj) + d(v, yi), t Pi=1 j6=i where v is the consensus of SOLi ⊕ yi. 3. SELF-REDUCIBILITY A solution to a combinatorial optimization problem is com- posed of a set of discrete elements called atoms [19]. For certain graph problems, it can be the set of all vertices or set of all edges, e.g., a clique in the maximum clique problem is a collection of vertices. A problem Π is said to be self-reducible if there is a polynomial- time algorithm, ∆, satisfying the following conditions [19]. 1. Given an instance I and an atom α of a solution to I, ∆ outputs an instance Iα. We require that the size of Iα is smaller than the size of I, i.e., Iα < I. Let R(Iα) represent the set of feasible solutions to I containing the atom α. We require that every solution SOL of Iα, i.e., SOL ∈ R(Iα), has a corresponding SOL ∪ {α} ∈ R(Iα) and that this correspondence is one-to-one. 2. For any set H ∈ R(Iα) it holds that the cost(I, H ∪ {α}) = cost(Iα, H) + cost(I, α). Given the properties of a self-reducible problem, we prove that the following lemma is true. Lemma 1. CSP is self-reducible. Proof. With the assumption that the pattern length l is constant, a valid input instance I to CSP is a set of t sequences S. A feasible solution SOL ∈ R(S) is an ordered set SOL = (y1, y2, . . . , yt). The set of atoms in CSP are all possible l-length substrings in S. Let us define a reduction function ∆(S, yi), which returns a reduced instance S\{Si}. The reduced instance is derived by removing one sequence Si where yi is obtained. We argue next that ∆(S, yi) has the following properties. Let us use the concept of polynomial-time reduction for com- binatorial problems. We say that a problem A is polynomial- time reducible to B, denoted by A ≤P B, if ∃ a polynomial- time transformation f , which for every input x ∈ A ↔ f (x) ∈ B. In other words, in order to solve problem A, we must at least solve problem B. The problem of finding the clos- est substring is reduced to a graph problem in [15]. The transformation is as follows. Given a set of sequences S and a pattern length l, an edge weighted t-partite graph GS = (V, E, c) is obtained, where the problem is reduced to finding a minimum weighted clique on a t-partite graph (MWCP). Each substring in S represents a vertex in GS. A part Vi ⊂ V represents the set of vertices obtained from a single sequence Si ∈ S. A vertex v ∈ Vi is connected to all other vertices in V except those belonging to Vi. The cost defined by function c : (V × V ) → Z+ between two ver- tices can be interpreted as the Hamming distance between two substrings in S. The cost of a clique in GS , which is computed by getting the sum of all the edges is equal to sum of all pairwise Hamming distances of substrings in SOL in S. Moreover, we can create an instance GS from S in polynomial-time. Thus, showing a polynomial-time reduc- tion from CSP to MWCP. It is also shown that MWCP has an exact reduction to Mini- mum Weighted Independent Set Problem (MWISP), since a clique in a graph is an independent set in the corresponding complement of the graph [9]. In line with this we would like to cite the following Lemma from [19]. Lemma 2. Maximum Weighted Independent Set Problem (MWISP) is self-reducible. Since we proved earlier that CSP is self-reducible and we know that there is a polynomial-time reduction from CSP to MWCP, which is equivalent to a self-reducible problem MWISP, we are interested to know if all problems that are polynomial-time reducible to self-reducible problems also ex- hibit the same property. Theorem 1. If problem A is polynomial-time reducible to problem B (A ≤P B), and B is self-reducible, then A is self-reducible. Proof. Let A = (DA,RA, costA, goalA) and B = (DB,RB, costB, goalB) be two NP optimization prob- lems. Let IA ∈ DA, SOLA ∈ R(IA), where SOLA is com- posed of atoms αA. Similarly, let IB ∈ DB, SOLB ∈ R(IB), where SOLB is composed of atoms αB. Given that A ≤P B, then by definition, there exists a polynomial- time computable function f such that for every instance IA for problem A, f (IA) is an instance of problem B and for every solution SOLA to A, f (SOLA) ∈ IB. Equivalently, as a decision problem, the polynomial-time reducibility implies (IA, SOLA) ∈ (DA × R(IA)) ↔ (f (IA), f (SOLA)) ∈ (DB × R(IB)) By definition of self-reducibility, if B is self-reducible then we can obtain a self-reduction function ∆B(IB, αB) = IαB , such that IαB < IB and the following conditions hold. 1. For SOLB ∈ R(IB) there is a corresponding SOLαB ∪ {αB} ∈ R(IBαB), where SOLαB ∈ R(IαB ). 2. For a subset of atoms HB ⊆ R(IαB ), costB(IB, HB ∪ {αB}) = costB(IB, αB) + costB(IαB , HB). Given that B is self-reducible, we need to show that problem A is also self-reducible. If so, we must construct a self- reduction function ∆A(IA, αA) = IαA that follows the two properties. Given the polynomial-time function f and the self-reduction function ∆B, we realize ∆A using ∆B through the following, ∆B(f (IA), f (αA)) = f (IαA ). The self-reduction function for ∆A clearly inherits the two conditions because of our premise that B is self-reducible. Moreover, the reduction function runs in polynomial-time since f is polynomial-time computable. Theorem 1 is presented in the hope that we can use the current approaches for the reoptimization variants of clique and independent set problem for providing improvements for CSP. It is shown that for some defined reoptimization variant of clique and independent set, a general method is shown to improve the approximability with trade-off on the running time of the approximation algorithm. 4. REOPTIMIZATION For real-world applications, additional information about the problems we are solving often is available and so we may not have to solve them from scratch. One of the ap- proaches is to make use of a priori information, which can be a solution to a smaller input instance of a problem to solve a larger instance of it. This approach is called reop- timization. The idea was first mentioned in [16]. For some problems, we can transform the given optimal solution so that it may become feasible for the modified instance in polynomial-time. Furthermore, this approach can help to improve the approximability of the problem or the running time of the algorithms solving it. In fact, we can obtain a PTAS for a reoptimization variant of some problem given that the unmodified problem has a constant-factor approxi- mation algorithm [3]. In the reoptimization variant of any problem, it is impor- tant to define precisely the modification relation M over the set of input instances. For graph problems, common modifications involve addition/deletion of edges and ver- tices. Other types of modification involve changes in the edge/vertex weights. A simple definition of reoptimization is as follows. INPUT: Original instance I, its optimal solution OPT, and a modified instance I′, where (I, I′) ∈ M OUTPUT: Solution SOL′ to I′. For the CSP, we consider the basic type of modification where one or several sequences are added to S. Since the length of the pattern remains unchanged, we will only de- fine the modification relation over the given set of sequences. When a single sequence is added to S, we have the modifi- cation relation M+, where (S,S′) ∈ M+, if S′ = S ∪{St+1} and St+1 /∈ S. As a generalization, we define the modifica- tion relation Mk+ to denote addition of k sequences to S, i.e., (S,S′) ∈ Mk+ , if S′ = S ∪ {St+1, St+2, . . . , St+k} and St+i /∈ S, for 1 ≤ i ≤ k. Let us define the reoptimization variant of the CSP under single sequence addition. In the following definition, we can see that we already have the optimal solution with closest substring pattern vopt, of the original instance S. Note that we can easily compute occurrences of vopt in S, i.e., the set of substrings yi, each from Si and their positions where vopt is obtained. Definition 1. Reopt-CSPM+ INPUT: Pattern length l, original instance S, the optimal closest substring vopt of S, and a modified instance S′ where (S,S′) ∈ M+ OUTPUT: Solution v′sol to the modified instance S′. Even with the additional information we have, the reopti- mization variant of the problem is still NP-hard, i.e., no polynomial-time algorithm exists to obtain the optimal so- lution for S′, unless P = N P . Theorem 2. Reopt-CSPM+ is NP-hard. Proof. Towards contradiction, assume that Reopt-CSPM+ is polynomial-time solvable. We will make use of the polynomial- time algorithm for Reopt-CSPM+ to solve the CSP. We start by showing that for two sequences, both of length n, in S, we can obtain the optimal closest substring vopt in polynomial-time. We can obtain vopt in O(l·n2) by exhaust- ing all possible l-length patterns in both sequences. By making use of the optimal solution vopt and a polynomial- time algorithm for Reopt-CSPM+, we can solve the CSP for any number of sequences in S in polynomial-time by adding one sequence at a time. But then, we know that closest substring is NP-hard. Therefore, Reopt-CSPM+ is also NP- hard. get the optimal solution using Algorithm 2, let us consider the following example. Example 1. Let S = {S1, S2, S3, S4} with S5 as the ad- ditional sequence for the modified input S′. If we are looking for a closest substring of length l = 4, the optimal solution for S is vopt : AAAA. S1: A A A A B B B B S2 : B B B B A A A A S3 : A A A A B B B A S4 : B B B B A A A A S5 : B B B B B B B B 4.1 Approximation Algorithms for CSP For the purpose of our discussion, we may refer to OPT and OP T ′ to be the optimal solution of the smaller instance and the larger instance of the problem, respectively. The output of the presented approximation algorithms is denoted by SOL′, unless otherwise stated. First, we show how we can use a simple algorithm to give an approximate solution for Reopt-CSPM+. The algorithm makes use of the given solution as a greedy partial solution to the larger instance. Algorithm 2 Given a sequence St+1 ∈ Σn and solution SOL of input instance S, procedure BEST-ALIGN produces a feasible solution SOL′ by aligning the closest substring from St+1 to vsol 1: procedure BEST-ALIGN(SOL, St+1) vsol = Consensus pattern from SOL 2: min = ∞ 3: 4: for each l-length substring x of St+1 do 5: 6: 7: 8: end for 9: SOL′ = (y1, . . . , yt, yt+1) 10: return SOL′ 11: 12: end procedure min = cost(x) yt+1 = x if d(vsol, x) < min then end if Algorithm 2 searches for the best aligning substring yt+1 In adding one sequence to S, the to the given solution. computed solution may or may not be the optimal solution for the larger instance. For the first case, if OPT is subset of OP T ′ for S′, then the result of Algorithm 2 will yield the optimal solution for S′. Otherwise, there exists a non optimal solution for S that is part of the optimal solution for S′, i.e., ∃SOL ⊂ OP T ′. The solution SOL′ of Algorithm 2 is obtained by merging the given optimal solution OPT with the best possible align- ing substring in the new sequence. Algorithm 2 obviously runs in linear time with respect to the length of the addi- tional sequence St+1. To illustrate that we cannot always Algorithm 2 will return a solution by aligning the most sim- ilar substring y5 : BBBB from the new sequence S5. The solution produced by Algorithm 2 will have cost(SOL′) = 4. On the other hand, the optimal solution for S′ is v′opt : BBBB with cost(OP T ′) = 1. In this case, the subset of the optimal solution for the larger instance is not the optimal solution for the smaller instance. Algorithm 2 obviously runs in linear time with respect to the length of the additional sequence St+1, multiplied by getting the cost of each substring x. To get the quality of the approximation algorithm, we need to compare cost(OP T ′) and cost(SOL′). Using Algorithm 2 and the second property of self-reducibility, we have cost(SOL′) = cost(OP T ) + d(vopt, yt+1), where yt+1 is the best aligning substring to vopt from the new sequence. We know that the cost of the optimal solution for the smaller instance is less than or equal to the cost of the optimal solution for the larger instance, i.e., cost(OP T ) ≤ cost(OP T ′). Therefore, cost(SOL′) ≤ cost(OP T ′) + d(vopt, yt+1). In the worst case scenario, we can get cost(SOL′) ≤ cost(OP T ′) + l. Since we only added a single sequence, the quality of the solution depends solely on how long the pattern is. Using Algorithm 2, we can get a feasible solution for S′ in O(ln). Compared to the 2-approximation algorithm for CSP with running time O(l(tn)2) from [10], our approach can benefit an improved approximation ratio and running time for in- stances S′ where OP T ′ < l. Note that, the first property of the self-reducibility of CSP allows us to provide a feasible so- lution for the modified instance by extending the additional information that we have. We illustrate in the following gen- eralization that it is possible to produce a feasible solution even if we add k-sequences to S. 4.2 Generalization In this section, we consider the extension of the reopti- mization variant where, instead of adding one sequence, the modification relation, denoted by M+ k , is characterized by adding k sequences to the original instance. The definition of the generalized reoptimization version under sequence ad- dition is as follows. Definition 2. Reopt-CSP M+ k INPUT: Pattern length l, original instance S, the optimal closest substring vopt of S, and a modified instance S′ where (S,S′) ∈ M+ OUTPUT: Solution v′sol to the modified instance S′. k M+ is a generalization of Reopt-CSPM+, Since Reopt-CSP where k = 1, we no longer need to show that this variant is also NP-hard. To give an approximate solution, we can generalize Algorithm 2 for Reopt-CSP . k M+ k vsol = Consensus pattern from SOL for each i in 1 to k do Algorithm 3 Given k additional sequences {St+1, . . . St+k}, where each St+i ∈ Σn and solution SOL for input instance S, procedure K-BEST-ALIGN produces a feasible solution SOL′ by aligning the closest substrings from each of the additional sequences to vsol 1: procedure K-BEST-ALIGN(SOL,{St+1, . . . St+k}) 2: 3: 4: 5: 6: 7: 8: 9: 10: end for 11: SOL′ = (y1, . . . , yt, yt+1, . . . , yt+k) 12: return SOL′ 13: 14: end procedure min = ∞ for each l-length substring x of St+i do min = cost(x) yt+i = x if d(vsol, x) < min then end for end if Given vopt, we can give a feasible solution for S′ by getting the best aligning substring yt+i from each of the newly added sequences. Let Y be the set of substrings yt+i and let cost(Y ) = k Xi=1 d(vopt, yt+i) be the contribution of the set Y to SOL′. If vopt is the same as v′opt, then we can always guarantee optimality, otherwise cost(SOL′) ≤ cost(OP T ′) + cost(Y ). In the worst case scenario, we can have k M+ cost(SOL′) ≤ cost(OP T ′) + kl. can pro- The extension of Algorithm 3 for Reopt-CSP duce a feasible solution in O(kln). However, the quality of the solution degrades as we increase the number of sequences added to the original instance. A general method for reop- timization is applied to several self-reducible hard problems to further improve the approximability of the problem but with tradeoff on the running time of the algorithm. The PTAS for the CSP already provides the option of improving the approximation ratio by increasing the sampling size r in Algorithm 1. As r approaches t, we can have a solution with error that converges to 0 but with running time that is com- parable to the naive exhaustive search that is exponential in t. In the following section, we illustrate how reoptimization can help in improving the running time of the PTAS in [12]. 4.3 Improving the PTAS for Reopt-CSPMk+ Let us consider an input instance S′ = {S1, . . . , St} for CSP with a given optimal solution for a subset of its se- quences. Without loss of generality, suppose we have an optimal solution OPT for the first r sequences in S′, i.e., S = {S1, . . . , Sr}. Let us also assume that S′ \ S = k. Algorithm 1 can provide a feasible solution for S′ with an √e(√4r+1−3) in O(l· (tn)r+1). We approximation ratio of 1 + argue in this section that we can achieve the same approxi- mation ratio in O(ltn((t − r)n)r) time using the given OPT for S, as presented in Theorem 3 In the following approximation algorithm, we implement the PTAS in Algorithm 1 by using the given optimal solution OPT. 4Σ−4 Algorithm 4 Approximation algorithm for Reopt- CSPMk+ using the K-BEST-ALIGN procedure from Algo- rithm 3. Input: Set of sequences S′ = {S1, . . . , St}, pattern length l, and optimal closest substring OPT of S = {S1, . . . , Sr} Output: Solution SOL′ for S′. 1: SOL′A = K-BEST-ALIGN(OP T, {Sr+1, . . . , St}) 2: 3: SOL′B = ∅ 4: min = ∞ 5: for each r-sample ∈ {R(S′) \ R(S)} do 6: 7: 8: 9: 10: 11: end for 12: 13: if cost(SOL′A) < cost(SOL′B ) then 14: 15: else 16: 17: end if SOL′ = K-BEST-ALIGN(SOL, sample) if cost(SOL′) < min then min = cost(SOL′) SOL′B = SOL′ return SOL′B return SOL′A end if Theorem 3. Algorithm 4 is a 1 + Reopt-CSP M+ k which runs in O(ltn · (t − r)n)r). 4Σ−4 √e(√4r+1−3) PTAS for Proof. To prove that Algorithm 4 provides the same ap- proximation ratio as Algorithm 1 from [12], we need to show that the set of all samples in R(S′) is considered in Algo- rithm 4. SOLA is obtained by aligning OP T to k other sequences in S′ using Algorithm 2. Since we have the op- timal solution for S, cost(SOLA) is equal to the minimum over all feasible solutions sampled over R(S). On the other hand, solution SOLB is obtained by getting the minimum over all feasible solutions sampled from R(S′) \ R(S). The output SOL′ is the minimum between SOLA and SOLB. Thus, all samples from R(S′) are considered in Algorithm 4. For the running time of Algorithm 4, getting SOLA will re- quire O(kn) steps. Line 5 will iterate in O((tn)r − (rn)r). Getting the best alignment for each sample will require O(tn) and getting the distance between two l-length substrings will take O(l). Thus, Algorithm 4 runs in O(ltn· (t− r)n)r ). 5. CONCLUSION AND FUTURE WORK In this paper, we presented reoptimization variant of the CSP under sequence addition. The additional information, i.e., optimal solution to a smaller instance, does not help to address the intractability of the problem, as shown in Theorem 2. We considered the basic type of modification M+, where the new instance contains an additional sequence. The general approach in reoptimization is to transform the given optimal solution for it to become feasible to the new instance. For some cases, i.e., vopt = v′opt, our simple transformation can lead to OP T ′, otherwise we can have the worst case scenario where OPT cannot help to obtain OP T ′. In fact, even for a small modification such as M+, vopt can be totally different from v′opt. We generalized this approach by considering the modifica- tion Mk+ , characterized by adding k new sequences to the original instance. By using the same approach for Reopt- CSPM+ , we can obtain an error that grows as the number of additional sequences is increasing. However, we showed that by using the given optimal solution for reoptimization we can improve the running of the existing PTAS for CSP. With the same approximation ratio, we can improve the running time from O((tn)r) to O(((t − r)n)r). It is natural to consider the opposite scenario, where an optimal solution to a larger instance is given and we are looking for the solution to a smaller subset of the instance. We argue that we are not also guaranteed to get the optimal solution by transforming the larger solution to provide a feasible solution to the smaller instance. Example 1 can also illustrate the idea. Exploring other techniques to make use of such kind of information is still part of our future work. Moreover, we would like to study other types of modification in the input instance such as changes in pattern length l. 6. ACKNOWLEDGEMENTS The authors would like to give their utmost gratitude to Dr. Hans-Joachim Bockenhauer and Dr. Dennis Komm for patiently reading and proof-reading this paper, to Prof. Juraj Hromkovic for his supervision and valuable inputs. Ms. Jhoirene Clemente would like to thank the Engineer- ing Research and Development for Technology (ERDT) for funding her PhD program in University of the Philippines Diliman and the Bases Conversion and Development Au- thority (BCDA) project for funding her Sandwich program. 7. REFERENCES [1] Davide Bil`o, Hans-Joachim Bockenhauer, Dennis Komm, Richard Kr´alovic, Tobias Momke, Sebastian Seibert, and Anna Zych. Reoptimization of the shortest common superstring problem. Algorithmica (New York), 61(2):227 -- 251, 2011. [2] Davide Bilo and Anna Zych. New Advances in Reoptimizing the Minimum Steiner Tree Problem. In Proc. of the Mathematical Foundations of Computer Science, LNCS, 7464:184 -- 197, 2012. [3] Hans-Joachim Bockenhauer, Juraj Hromkovic, Tobias Momke, and Peter Widmayer. On the hardness of reoptimization. In Proc. of the 34th International Conference on Current Trends in Theory and Practice of Computer Science (SOFSEM 2008), LNCS, 4910, 2008. [4] Hans L. Bodlaender, Rodney G. Downey, Michael R. Fellows, and Harold T. Wareham. The parameterized complexity of sequence alignment and consensus. Theoretical Computer Science, 147(1-2):31 -- 54, 1995. [5] Nicolas Boria, C´ecile Murat, and Vangelis Paschos. On the Probabilistic Min Spanning Tree Problem. Journal of Mathematical Modelling and Algorithms, 11(1):45 -- 76, 2012. [6] Brona Brejov´a, Daniel Brown, Ian M Harrower, and T Vinar. New Bounds for Motif Finding in Strong Instances. In Proc. of the Combinatorial Pattern Matching, pages 94 -- 105, 2006. [7] Riccardo Dondi, Guillaume Fertin, and St´ephane Vialette. Finding approximate and constrained motifs in graphs. Theoretical Computer Science, 483:10 -- 21, April 2013. [8] Patricia A. Evans, Andrew D. Smith, and H. Todd Wareham. On the complexity of finding common approximate substrings. Theoretical Computer Science, 306(1-3):407 -- 430, September 2003. [9] Michael R. Garey and David S. Johnson. A Guide to the Theory of NP-Completeness. Computers and Intractibility, January 1979. [10] J. Kevin Lanctot, Ming Li, Bin Ma, Shaojiu Wang, and Louxin Zhang. Distinguishing string selection problems. Information and Computation, 185(1):41 -- 55, August 2003. [11] Heng Li and Nils Homer. A survey of sequence alignment algorithms for next-generation sequencing. Briefings in Bioinformatics, 11(5):473 -- 483, September 2010. [12] Ming Li, Bin Ma, and Lusheng Wang. Finding similar regions in many strings. Proceedings of the thirty-first annual ACM symposium on Theory of computing - STOC '99, 65(1):473 -- 482, August 1999. [13] Bin Ma. A Polynomial Time Approximation Scheme for the Closest Substring Problem. Combinatorial Pattern Matching, Lecture Notes in Computer Science, 1848:99 -- 107, 2000. [14] Bin Ma and Xiaoming Sun. More efficient algorithms for closest string and substring problems. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 4955 LNBI(4):396 -- 409, 2008. [15] Pavel Pevzner and Sing-Hoi Sze. Combinatorial approaches to finding subtle signals in DNA sequences. Proceedings of the International Conference on Intelligent Systems for Molecular Biology ; ISMB. International Conference on Intelligent Systems for Molecular Biology, 8:269 -- 278, 2000. [16] Markus W. Schaffter. Scheduling with forbidden sets. Discrete Applied Mathematics, 72(1-2):155 -- 166, 1997. [17] Jianxin Wang, Jianer Chen, and Min Huang. An improved lower bound on approximation algorithms for the Closest Substring problem. Information Processing Letters, 107(1):24 -- 28, June 2008. [18] Elena Zaslavsky and Mona Singh. A combinatorial optimization approach for diverse motif finding applications. Algorithms for molecular biology : AMB, 1:13, January 2006. [19] Anna Zych. Reoptimization of NP-hard Problems. PhD thesis, ETH Zurich, 2012.
1612.02990
1
1612
2016-12-09T12:04:20
Approximation Algorithm for Cycle-Star Hub Network Design Problems and Cycle-Metric Labeling Problems
[ "cs.DS", "cs.DM" ]
We consider a single allocation hub-and-spoke network design problem which allocates each non-hub node to exactly one of given hub nodes so as to minimize the total transportation cost. This paper deals with a case in which the hubs are located in a cycle, which is called a cycle-star hub network design problem. The problem is essentially equivalent to a cycle-metric labeling problem. The problem is useful in the design of networks in telecommunications and airline transportation systems.We propose a $2(1-1/h)$-approximation algorithm where $h$ denotes the number of hub nodes. Our algorithm solves a linear relaxation problem and employs a dependent rounding procedure. We analyze our algorithm by approximating a given cycle-metric matrix by a convex combination of Monge matrices.
cs.DS
cs
Approximation Algorithm for Cycle-Star Hub Network Design Problems and Cycle-Metric Labeling Problems Yuko Kuroki⋆ and Tomomi Matsui⋆ ⋆ Department of Industrial Engineering and Economics, Graduate School of Engineering, Tokyo Institute of Technology, Abstract. We consider a single allocation hub-and-spoke network de- sign problem which allocates each non-hub node to exactly one of given hub nodes so as to minimize the total transportation cost. This paper deals with a case in which the hubs are located in a cycle, which is called a cycle-star hub network design problem. The problem is essen- tially equivalent to a cycle-metric labeling problem. The problem is useful in the design of networks in telecommunications and airline transporta- tion systems. We propose a 2(1 − 1/h)-approximation algorithm where h denotes the number of hub nodes. Our algorithm solves a linear relax- ation problem and employs a dependent rounding procedure. We analyze our algorithm by approximating a given cycle-metric matrix by a convex combination of Monge matrices. 1 Introduction In this paper, we propose a 2(1 − 1/h)-approximation algorithm for cycle-star hub network design problems with h hubs and/or a cycle-metric labeling problem with h labels. Hub-and-spoke networks arise in airline transportation systems, delivery sys- tems and telecommunication systems. Hub networks have an important role when there are many origins and destinations. Hub facilities work as switching points for flows. In order to reduce transportation costs and set-up costs in a large network, each non-hub node is allocated to exactly one of the hubs instead of assigning every origin-destination pair directly. Hub location problems (HLPs) consist of locating hubs and of designing hub networks so as to minimize the total transportation cost. HLPs are formulated as quadratic integer programming problem by O'Kelly [25], first. Since O'Kelly proposed HLPs, many researches on HLPs have been done in various applications (see [3,9,12,16,20,26] for example). In this paper, we discuss the situation in which the locations of the hubs are given, and deal with a problem, called a single allocation hub-and-spoke network design problem, which finds a connection of the non-hubs to the given hubs minimizing total transportation cost. Sohn and Park [27,28] proposed a 6 1 0 2 c e D 9 ] S D . s c [ 1 v 0 9 9 2 0 . 2 1 6 1 : v i X r a 2 Y. Kuroki and T. Matsui polynomial time exact algorithm for a problem with 2 hubs and proved NP- completness of the problem even if the number of hubs is equal to 3. Iwasa et al. [18] proposed a simple 3-approximation algorithm and a randomized 2- approximation algorithm under the assumptions of triangle inequality. They also proposed a (5/4)-approximation algorithm for the special case where the number of hubs is 3. Ando and Matsui [5] deal with the case in which all the nodes are embedded in a 2-dimensional plane and the transportation cost of an edge per unit flow is proportional to the Euclidean distance between the end nodes of the edge. They proposed a randomized (1 + 2/π)-approximation algorithm. Saito et al. [29] discussed some facets of polytopes corresponding to the convex hull of feasible solutions of the problem. Fundamental HLPs assume a full interconnection between hubs. Recently, several researches consider incomplete hub networks which arise especially in telecommunication systems (see [10,11,4,8] for example). These models are useful when set-up costs of hub links are considerably large or full interconnection is not required. There are researches which assume that hub networks constitute a particular structure such as a tree [19,14,15,23], a star [22,30,31], a path [24] or a cycle [17]. In this paper, we consider a single allocation hub-and-spoke network design problem where the given hubs are located in a cycle. We call this problem the cycle-star hub network design problem. When the number of hubs is 3, the hub network becomes a 3-cycle and constitutes a complete graph. Thus, the 4/3- approximation algorithm for a complete 3-hub network proposed in [18] is valid for this special case. In this paper we propose a 2(1 − 1/h)-approximation algo- rithm when a set of h hubs forms an h-cycle. To the best of our knowledge, our algorithm is the first approximation algorithm for this problem. A single allocation hub-and-spoke network design problem is essentially equiv- alent to a metric labeling problem introduced by Kleinberg and Tardos in [21], which has connections to Markov random field and classification problems that arise in computer vision and related areas. They proposed an O(log h log log h)- approximation algorithm where h is the number of labels (hubs). Chuzhoy and Naor [13] showed that there is no polynomial time approximation algorithm with a constant ratio for the problem unless P = NP. We deal with a cycle-metric labeling problem where a given metric matrix is defined by an undirected cycle and non-negative edge length. Thus, our results give an important class of the metric labeling problem, which has a polynomial time approximation algorithm with a constant approximation ratio. 2 Problem Formulation Let H = {1, 2, . . . , h} be a set of hub nodes and N be a set of non-hub nodes where H ≥ 3 and N = n. This paper deals with a single assignment hub network design problem which assigns each non-hub node to exactly one hub node. We discuss the case in which the set of hubs forms an undirected cycle, and the corresponding problem is called the cycle-star hub network design problem. Approximation Algorithm for Cycle-Star Hub Network Design Problems 3 More precisely, we are given an undirected cycle Γ = (H, T ) defined by a vertex- set H and an edge-set T = {{1, 2}, {2, 3}, . . . , {h − 1, h}, {h, 1}}. In the rest of this paper, we identify hub i and hub h + i when there is no ambiguity. For each edge e = {i, i + 1} ∈ T , the corresponding length, denoted by ce or ci i+1 represents a non-negative cost per unit of flow on the edge. For each ordered pair (p, i) ∈ N × H, cpi also denotes a non-negative cost per unit flow on an undirected edge {p, i}. We denote a given non-negative amount of flow from a non-hub p to another non-hub q by wpq(≥ 0). Throughout this paper, we assume that wpp = 0 (∀p ∈ N ). We discuss the problem for finding an assignment of non-hubs to hubs which minimizes the total transportation cost defined below. When non-hub nodes p and q (p 6= q) are assigned hubs i and j, respectively, an amount of flow wpq is sent along a path ((p, i), Ωij , (j, q)) where Ωij denotes a shortest path in Γ = (H, T ) between i and j. For each pair of hub nodes (i, j) ∈ H 2, cij denotes the length of a shortest path Ωij. More precisely, cycle Γ contains exactly two paths between i and j and cij denotes the minimum of the lengths of these two paths. It is easy to see that cij = cji. In the rest of this paper, a matrix C = (cij ) defined above is called a cost matrix and/or a cycle-metric matrix. The transportation cost corresponding to a flow from p to q is defined by wpq(cpi + cij + cqj ). Now we describe our problem formally. First, we introduce a 0-1 variable xpi for each pair {p, i} ∈ N × H as follows: xpi =(cid:26) 1 (p ∈ N is assigned to i ∈ H), 0 (otherwise). We have a constraint Pi∈H xpi = 1 for each p ∈ N , since each non-hub is connected to exactly one hub. Then, the cycle-star hub network design problem can be formulated as follows: SAP: min. X(p,q)∈N 2 wpq Xi∈H cpixpi +Xj∈H cjqxqj + X(i,j)∈H 2 cijxpixqj  s. t. Xi∈H xpi = 1 (∀p ∈ N ), xpi ∈ {0, 1} (∀(p, i) ∈ N × H). The above formulation also appears in [28,18]. In case h = 3, 3-cycle Γ is a complete graph, and thus the corresponding problem is NP-complete [28]. Next we describe an integer linear programming problem proposed in [18], which is derived from SAP by employing the linearization technique introduced by Adams and Sherali [1]. We replace xpixqj with ypiqj . We have a new constraint Pi∈H ypiqj = xqj from the equation Pi∈H xpi = 1 by multiplying both sides by xqj . We also obtain a constraint Pj∈H ypiqj = xpi in a similar way. Then we 4 Y. Kuroki and T. Matsui obtain the following 0-1 integer linear programming problem: SAPL: min. X(p,q)∈N 2 wpq Xi∈H cpixpi +Xj∈H cjqxqj + X(i,j)∈H 2 xpi = 1 (∀p ∈ N ), cijypiqj  s. t. Xi∈H Xj∈H Xi∈H ypiqj = xpi (∀(p, q) ∈ N 2, ∀j ∈ H, p < q), ypiqj = xqj (∀(p, q) ∈ N 2, ∀i ∈ H, p < q), xpi ∈ {0, 1} ypiqj ∈ {0, 1} (∀(p, i) ∈ N × H), (∀i ∈ H). By substituting non-negativity constraints of all the variables for 0-1 con- straints in SAPL, we obtain a linear relaxation problem, denoted by LRP. We can solve LRP in polynomial time by employing an interior point algorithm. 3 Monge Property and Dependent Rounding Procedure First, we give the definition of a Monge matrix. A comprehensive research on the Monge property appears in a recent survey [7]. Definition 1. An m × n matrix C′ is a Monge matrix if and only if C′ satisfies the so-called Monge property c′ ij + c′ i′j ′ ≤ c′ ij ′ + c′ i′j for all 1 ≤ i < i′ ≤ m, 1 ≤ j < j′ ≤ n. Although the Monge property depends on the orders of the rows and columns, in this paper, we say that a matrix is a Monge matrix when there exist permutations of rows and columns which yield the Monge property. For each edge e ∈ T , we define a path Γ e = (H, T \ {e}) obtained from cycle ij denotes the ij ) be a cost matrix where ce Γ by deleting the edge e. Let C e = (ce length of the unique subpath of Γ e connecting i and j. Lemma 1. For any edge e = {ℓ, ℓ + 1} ∈ T , a Monge matrix is obtained from C e by permuting rows and columns simultaneously in the ordering (ℓ + 1, ℓ + 2, . . . , h, 1, 2, . . . , ℓ). Proof is omitted (see Appendix A or [7] for example). Next, we approximate a given cost matrix (cycle-metric matrix) C by a con- vex combination of h Monge matrices {C e e ∈ T }. Alon et al. [2] considered ap- proximating a cycle-metric matrix by a probability distribution over path-metric matrices, and showed a simple distribution such that the expected length of each edge is no more than twice its original length. The following theorem improves their result especially when the size of the cycle (number of hubs) is small. Approximation Algorithm for Cycle-Star Hub Network Design Problems 5 Theorem 1. Let C be a cost matrix obtained from a cycle Γ = (H, T ) and non-negative edge lengths (ce e ∈ T ). Then, there exists a vector of coefficients (θe e ∈ T ) satisfying θe ≥ 0 (∀e ∈ T ), Xe∈T θe = 1, and C ≤Xe∈T θeC e ≤ 2(cid:18)1 − 1 h(cid:19) C. Proof. When there exists an edge e◦ ∈ T satisfying ce◦ ≥ (1/2)Pf ∈T cf , it is easy to see that for every pair (i, j) ∈ H 2, there exists a shortest path Ωij on cycle Γ = (H, T ) between i and j excluding edge e◦. Thus, a given cost matrix C is equivalent to the Monge matrix C e◦ . In this case, the desired result is trivial. We assume that 2ce < L = Pf ∈T cf (∀e ∈ T ) and introduce a positive coefficient θe for each e ∈ T defined by θe = (L − 2cf ) ce K Yf ∈T \{e} where K is a normalizing constant which yields the equality Pe∈T θe = 1. Let Ωij ⊆ T be a set of edges in a shortest path in Γ between i and j. The definition of the coefficients (θe e ∈ T ) directly implies that for each pair (i, j) ∈ H 2, θece Xe∈T θecij + Xe∈Ωij ij = Xe6∈Ωij ≤ cijXe∈T θe + Xe∈Ωij  = cij + Xe∈Ωij (L − 2ce) = cij + Qf ∈T (L − 2cf ) K θe(L − cij ) = Xe∈T θecij + Xe∈Ωij θe(L − 2cij) θe(L − 2ce) (L − 2cf )  ce K Yf ∈T \{e} Xe∈Ωij ce = cij + Qf ∈T (L − 2cf ) K cij. From the assumption, the last term appearing above is positive. Then, we have K = Pe∈T (cid:16)ceQf ∈T \{e}(L − 2cf )(cid:17) Qf ∈T (L − 2cf ) Qf ∈T (L − 2cf ) Now we introduce a function f (z1, . . . , zh) = Ph ℓ=1 zℓ/(L − 2zℓ) defined on a domain {z ∈ [0, L/2)h z1 + · · · + zh = L}. From the convexity and symmetry of variables of f , the minimum of f is attained at z1 = z2 = · · · = zh = L/h, and f (L/h, . . . , L/h) = 1/(1 − 2/h), which gives the following inequality ce L − 2ce . = Xe∈T θece ij ≤ cij + Qf ∈T (L − 2cf ) Xe∈T Since C ≤ C e (∀e ∈ T ), it is obvious that C ≤Pe∈T θeC e. cij ≤ cij +(cid:18)1 − K 2 h(cid:19) cij = 2(cid:18)1 − 1 h(cid:19) cij . 6 Y. Kuroki and T. Matsui Dependent Rounding (x, y; π) Input: A feasible solution (x, y) of LRP and a total order π of the hubs. Step 1: Generate a random variable U which follows a uniform distribution defined on [0, 1). Step 2: Assign each non-hub node p ∈ N to a hub π(i), where i ∈ {1, 2, . . . h} is the minimum number that satisfies U < xpπ(1) + · · · + xpπ(i). Next, we describe a rounding technique proposed in [18]. We will describe a connection between the Monge matrix and the rounding technique, later, The above procedure can be explained roughly as follows (see Figure 1). For each non-hub p ∈ N , we subdivide a rectangle of height 1 with horizontal segments into smaller rectangles whose heights are equal to the values of the given feasible solution xpπ(1), xpπ(2), . . . , xpπ(h). Here we note thatPi∈H xpπ(i) = 1 (∀p ∈ N ). We assume that the smaller rectangles are heaped in the order π. We generate a horizontal line whose height is equal to the random variable U and round a variable xpi to 1 if and only if the corresponding rectangle intersects the horizontal line. Given a feasible solution (x, y) of LRP and a total order π of H, a vec- tor of random variables X π, indexed by N × H, denotes a solution obtained by Dependent Rounding (x, y; π). In the following, we discuss the probability Pr[X π piX π qj = 1]. Lemma 2. [18] Let (x, y) be a feasible solution of LRP and π a total order of H. A vector of random variables X π obtained by Dependent Rounding (x, y; π) satisfies that (1) E[X π (2) E[X π piqj (∀(p, q) ∈ N 2, ∀(i, j) ∈ H 2), (∀(p, i) ∈ N × H), pi] = xpi piX π qj] = yπ Fig. 1. Dependent Rounding πℓ where (π(1), π(2), π(3), π(4)) = (2, 3, 4, 1). Approximation Algorithm for Cycle-Star Hub Network Design Problems 7 where yπ is a unique solution of the following system of equalities i′ j ′ Xi=1 Xj=1 yπ pπ(i)qπ(j) = min  i′ Xi=1 xpπ(i), i′ Xi=1 xqπ(j) (cid:0)∀(p, q) ∈ N 2, ∀(i′, j′) ∈ H 2(cid:1) . (1) Proof is omitted (see Appendix C or [18]). In the rest of this paper, a pair of vectors (x, yπ) defined by (1) is called a north-west corner rule solution with respect to (x, y; π). When x is non-negative and Pi∈H xpi = Pi∈H xqi holds, the unique solution of (1) gives the so-called north-west corner rule solution for a Hitchcock transportation problem (Figure 2 shows an example of a north-west corner rule solution where details are given in Appendix B or [18]). Here we note that the above definition is different from the ordinary definition of the north-west corner rule solution, which is known as a result of a procedure for finding a feasible solution of a Hitchcock transporta- tion problem. In the rest of this section, we describe Hitchcock transportation (sub)problems contained in LRP. Fig. 2. North-west corner rule solution where (π(1), π(2), π(3), π(4)) = (2, 3, 4, 1). In this case, E[X π q4] = 0.1, E[X π q1] = 0.2, E[X π q1] = 0.1, E[X π q4] = 0.2, E[X π p3X π q2] = 0.2, and E[X π p4X π q2] = 0.1. p4X π p3X π p1X π p3X π q3] = 0.1, E[X π p2X π Let (x◦, y◦) be a feasible solution of LRP. For any p ∈ N , x◦ p denotes a subvector of x◦ defined by (x◦ ph). When we fix variables x in LRP to x◦, we can decompose the obtained problem into n2 Hitchcock transportation p2, . . . , x◦ p1, x◦ 8 Y. Kuroki and T. Matsui problems {HTP(x◦ p, x◦ q, C) (p, q) ∈ N 2} where HTP(x◦ p, x◦ q, C): min. Xi∈H Xj∈H cij ypiqj s. t. Xj∈H Xi∈H ypiqj = x◦ pi (∀i ∈ H), ypiqj = x◦ qj (∀j ∈ H), ypiqj ≥ 0 (∀(i, j) ∈ H 2). Next, we describe a well-known relation between a north-west corner rule solution of a Hitchcock transportation problem and the Monge property. Theorem 2. If a given cost matrix C = (cij ) is a Monge matrix with respect to a total order π of hubs, then the north-west corner rule solution yπ de- fined by (1) gives optimal solutions of all the Hitchcock transportation problems {HTP(x◦ q, C) (p, q) ∈ N 2}. p, x◦ Proof is omitted here (see [6,7] for example). 4 Approximation Algorithm In this section, we propose an algorithm and discuss its approximation ratio. First, we describe our algorithm. Alogorithm 4 Step 1: Solve the linear relaxation problem LRP and obtain an optimal solution (x ∗, y ∗). Step 2: For each edge e ∈ T , execute Dependent Rounding (x ∗; πe) where πe denotes a total order (πe(1), πe(2), . . . , πe(h)) = (ℓ+1, ℓ+2, . . . , h, 1, 2, . . . , ℓ−1, ℓ). ∗, y Step 3: Output a best solution obtained in Step 2. In the rest of this section, we discuss the approximation ratio. We define W ∗ 1 = X(p,q)∈N 2 and where (x∗, y∗) is an optimal solution of LRP. cpix∗ wpq Xi∈H wpq  X(i,j)∈H 2 pi + Xj∈H cjqx∗ qj  cij y∗ piqj  W ∗ 2 = X(p,q)∈N 2 Approximation Algorithm for Cycle-Star Hub Network Design Problems 9 Theorem 3. Algorithm 4 is a 2(1 − 1/h)-approximation algorithm. Proof. Let z∗∗ be the optimal value of the original problem SAP and (θe e ∈ T ) be a vector of coefficients defined in Theorem 1. For each e ∈ T , (X π(e)) denotes a solution obtained by Dependent Rounding(x∗, y∗; πe) and yπ(e) be the north- west corner rule solution defined by (1) (where π is set to πe). Then we have that 1 + W ∗ 2 ) piqj  p, x∗ 1 1 θeW ∗ θeW ∗ θeW ∗ θeW ∗ 1 2(cid:18)1 − ≥ W ∗ 2 = W ∗ 1 1 h(cid:19) (W ∗ wpq h(cid:19) cijy∗  X(i,j)∈H 2 piqj  (Theorem 1) piqj    ijy∗ ce ijy∗ h(cid:19) (optimal value of LRP) = 2(cid:18)1 − 2(cid:18)1 − h(cid:19) z∗∗ ≥ 2(cid:18)1 − 1 + 2(cid:18)1 − h(cid:19) W ∗ 1 + X(p,q)∈N 2 wpq  X(i,j)∈H 2Xe∈T ≥ Xe∈T 1 + X(p,q)∈N 2 θe wpq = Xe∈T 1 +Xe∈T  X(p,q)∈N 2  X(i,j)∈H 2 θe ≥ Xe∈T 1 +Xe∈T  X(p,q)∈N 2 wpq(cid:0)optimal value of HTP(x∗ wpq θe = Xe∈T  X(i,j)∈H 2 1 +Xe∈T  X(p,q)∈N 2 wpq θe = Xe∈T Xi∈H  X(p,q)∈N 2 pi + Xj∈H θe wpq Pi∈H cpiE[X π(e) = Xe∈T  X(p,q)∈N 2 = E θe wpq Pi∈H cpiX π(e) Xe∈T  X(p,q)∈N 2 e∈T  ≥ E wpq Pi∈H cpiX π(e) X(p,q)∈N 2 min  q, C e)(cid:1)  piqj   (Theorem 2)  piqj  qj + X(i,j)∈H 2   ! ] +Pj∈H cjqE[X π(e)   ! pi +Pj∈H cjqX π(e)   !  pi +Pj∈H cjqX π(e)   +P(i,j)∈H 2 cijE[X π(e) +P(i,j)∈H 2 cij X π(e) +P(i,j)∈H 2 cijX π(e) pi X π(e) pi X π(e) pi X π(e) ijyπ(e) ce cij yπ(e) ] qj ] qj qj cpix∗ cjqx∗ qj qj qj = E[Z] θece pi where Z denotes the objective value of a solution obtained by Algorithm 4. The last inequality in the above transformation is obtained from the equality Pe∈T θe = 1 and the non-negativity of coefficients (θe e ∈ T ). 10 Y. Kuroki and T. Matsui 5 Discussions In this paper, we proposed a polynomial time 2(1−1/h)-approximation algorithm for a cycle-star hub network design problem with h hubs. Our algorithm solves a linear relaxation problem and employs a dependent rounding procedure. The attained approximation ratio is based on an approximation of a cycle-metric matrix by a convex combination of Monge matrices. Lastly we discuss a simple independent rounding technique which indepen- dently connects each non-hub node p ∈ N to a hub node i ∈ H with probability pi, where (x∗, y∗) is an optimal solution of LRP. Iwasa et al. [18] showed that x∗ the independent rounding technique gives a 2-approximation algorithm for a single allocation hub-and-spoke network design problem under the following as- sumption. Assumtion 1 A given symmetric non-negative cost matrix C satisfies cij ≤ cik + ckj (∀(i, j, k) ∈ H 3) and cij ≤ cpi + cpj (∀(i, j, p) ∈ H 2 × N ). We also have the following result. Lemma 3. Under an assumption that cij ≤ cpi + cpj (∀(i, j, p) ∈ H 2 × N ), 2 − 1 a (cid:16) 3 2(h−1)(cid:17)-approximation algorithm (for a cycle-star hub network design problem) is obtained by choosing the better of the two solutions given by Algo- rithm 4 and the independent rounding technique. Proof. Let a random variable Z2 be an objective function value with respect to a solution obtained by the independent rounding technique. Iwasa et al. [18] showed that E[Z2] ≤ 2W ∗ 2 . In the proof of Theorem 3, we have shown that E[Z] ≤ W ∗ 2 . By combining these results, we obtain that 1 + 2(1 − 1/h)W ∗ 1 + W ∗ E[min{Z2, Z}] ≤ E(cid:20) h − 2 2(h − 1) Z2 + h 2(h − 1) E[Z](cid:21) E[Z2] + h = ≤ h − 2 2(h − 1) h − 2 2(h − 1) E[Z] 2(h − 1) (2W ∗ 1 + W ∗ 2 ) + =(cid:18) 3 2 − 1 2(h − 1)(cid:19) (W ∗ 1 + W ∗ 1 h 2(h − 1)(cid:18)W ∗ 2 ) ≤(cid:18) 3 h(cid:19) W ∗ 2(cid:19) 1 + 2(cid:18)1 − 2(h − 1)(cid:19) (opt. val. of SAP). − 1 2 References 1. M. P. Adams and H. D. Sherali, "A tight linearization and an algorithm for zero-one quadratic programming problems," Management Science, 32 (1986), pp. 1274 -- 1290. 2. N. Alon, R. M. Karp, D. Peleg, and D. West, "A graph-theoretic game and its application to the k-server problem," SIAM Journal on Computing, 24 (1995), pp. 78 -- 100. Approximation Algorithm for Cycle-Star Hub Network Design Problems 11 3. S. A. Alumur and B. Y. Kara, "Network hub location problems: The state of the art," European Journal of Operational Research, 190 (2008), pp. 1 -- 21. 4. S. A. Alumur, B. Y. Kara, and O. E. Karasan, "The design of single allocation incomplete hub networks," Transportation Research Part B, 43 (2009), pp. 936 -- 951. 5. R. Ando and T. Matsui, "Algorithm for single allocation problem on hub-and-spoke networks in 2-dimensional plane," in: Proceedings of ISAAC 2009, Lecture Notes in Computer Science, 7074 (2011), pp. 474 -- 483. 6. W. Bein, P. Brucker, K. Park, and K. Pathak, "A Monge property for the d- dimensional transportation problem," Discrete Applied Mathematics, 58 (1995), pp. 97 -- 109. 7. R. E. Burkard, B. Klinz, and R. Rudolf, "Perspectives of Monge properties in optimization," Discrete Applied Mathematics, 70 (1996), pp. 95 -- 161. 8. H. Calik, S. A. Alumur, B. Y. Kara, and O. E. Karasan, "A tabu-search based heuristic for the hub covering problem over incomplete hubnetworks," Computers and Operations Research, 36 (2009), pp. 3088 -- 3096. 9. J. F. Campbell, "A survey of network hub location," Studies in Locational Analysis, 6 (1994), pp. 31 -- 47. 10. J. F. Campbell, A. T. Ernst, and M. Krishnamoorthy, "Hub arc location problems: Part I: introduction and results," Management Science, 51 (2005), pp. 1540 -- 1555. 11. J. F. Campbell, A. T. Ernst, and M. Krishnamoorthy, "Hub arc location problems: Part II: formulations and optimal Algorithms," Management Science, 51 (2005), pp. 1556 -- 1571. 12. J. F. Campbell and M. E. O'Kelly, "Twenty-five years of hub location research," Transportation Science, 46 (2012), pp. 153 -- 169. 13. J. Chuzhoy and J. Naor, "The hardness of metric labeling," in: Proceedings of the 45th Annual IEEE Symposium on Foundations of Computer Science, 2004, pp. 108 -- 114. 14. I. Contreras, E. Fern´andez, and A. Mar´ın, "Tight bounds from a path based formu- lation for the tree of hub location problem," Computers and Operations Research, 36 (2009), pp. 3117 -- 3127. 15. I. Contreras, E. Fern´andez, and A. Mar´ın, "The tree of hubs location problem," European Journal of Operational Research, 202 (2010), pp. 390 -- 400. 16. I. Contreras, "Hub location problems," in: Location Science, Chapter 12, G. La- porte, S. Nickel, and F. S. da Gama (Eds), Springer, 2015, pp. 311 -- 344, 17. I. Contreras, M. Tanash, and N. Vidyarthi, "Exact and heuristic approaches for the cycle hub location problem," Annals of Operations Research, 2016, DOI:10. 1007/s10479-015-2091-2. 18. M. Iwasa, H. Saito, and T. Matsui, "Approximation algorithms for the single allo- cation problem in hub-and-spoke networks and related metric labeling problems," Discrete Applied Mathematics, 157 (2009), pp. 2078 -- 2088. 19. J. G. Kim and D. W. Tcha, "Optimal design of a two-level hierarchical network with tree-star configuration," Computers and Industrial Engineering, 22 (1992), pp. 273 -- 281. 20. J. G. Klincewicz, "Hub location in backbone/tributary network design: a review," Location Science, 6 (1998), pp. 307 -- 335. 21. J. Kleinberg and E. Tardos, "Approximation algorithms for classification problems with pairwise relationships," Journal of ACM, 49 (2002), pp. 616 -- 630. 22. M. Labb´e and H. Yaman, "Solving the hub location problem in a star-star net- work," Networks, 51 (2008), pp. 19 -- 33. 12 Y. Kuroki and T. Matsui 23. E. Martins de S´a, R. S. de Camargo, and G. de Miranda, "An improved Benders decomposition algorithm for the tree of hubs location problem," European Journal of Operational Research, 226 (2013), pp. 185 -- 202. 24. E. Martins de S´a, I. Contreras, J. F. Cordeau, R.S. de Camargo, and G. de Miranda, "The hub line location problem," Transportation Science, 49 (2015), pp. 500 -- 518. 25. M. E. O'Kelly, "A quadratic integer program for the location of interacting hub facilities," European Journal of Operational Research, 32 (1987), pp. 393 -- 404. 26. M. E. O'Kelly and H. J. Miller, "The hub network design problem: A review and synthesis," Journal of Transport Geography, 2 (1994), pp. 31 -- 40. 27. J. Sohn and S. Park, "A linear program for the two-hub location problem," Euro- pean Journal of Operational Research, 100 (1997), pp. 617 -- 622. 28. J. Sohn and S. Park, "The single allocation problem in the interacting three-hub network," Networks, 35 (2000), pp. 17 -- 25. 29. H. Saito, T. Fujie, T. Matsui, and S. Matuura, "A study of the quadratic semi- assignment polytope," Discrete Optimization, 6 (2009), pp. 37 -- 50. 30. H. Yaman, "Star p-hub median problem with modular arc capacities," Computers and Operations Research, 35 (2008), pp. 3009 -- 3019. 31. H. Yaman and S. Elloumi, "Star p-hub center problem and star p-hub median problem with bounded path lengths," Computers and Operations Research, 39 (2012), pp. 2725 -- 2732. Approximation Algorithm for Cycle-Star Hub Network Design Problems 13 Appendix A Proof of Lemma 1 Here we briefly describe a proof of Lemma 1. Proof. Let C′ be a matrix obtained from C e by permuting rows and columns simultaneously in the ordering (ℓ + 1, ℓ + 2, . . . , h, 1, 2, . . . , ℓ). We consider each quadruple (i, i′, j, j′) of indices satisfying 1 ≤ i < i′ ≤ m, 1 ≤ j < j′ ≤ n. Since C e is symmetric, it suffices to show the following three cases: (i) if i ≤ i′ ≤ j ≤ j′, then c′ (ii) if i ≤ j ≤ i′ ≤ j′, then c′ (iii) if i ≤ j ≤ j′ ≤ i′, then c′ ij + c′ ij +c′ ij + c′ (c′ ij ′ + c′ i′j). i′j + c′ jj ′ = (c′ i′j ′ = c′ i′j ′ ≤ c′ ii′ + 2c′ ij +c′ i′j ′ +c′ ji′ +c′ j ′i′ + 2c′ i′j = (c′ jj ′ = c′ ij + c′ i′j ′ ≤ c′ ij ′ + c′ i′j), ij ′ +c′ ij ′ + c′ i′j), ji′ = Thus, we have the desired result. Appendix B North-West Corner Rule A Hitchcock transportation problem is defined on a complete bipartite graph consists of a set of supply points A = {1, 2, . . . , I} and a set of demand points B = {1, 2, . . . , J}. Given a pair of non-negative vectors (a, b) ∈ RI × RJ sat- ij ), a Hitchcock j=1 bj and an I × J cost matrix C′ = (c′ transportation problem is formulated as follows: isfying PI i=1 ai = PJ HTP(a, b, C′) : min. s. t. c′ ijyij Xj=1 yij = ai (i ∈ {1, 2, . . . , I}), yij = bj (j ∈ {1, 2, . . . , J}), I J J Xi=1 Xj=1 Xi=1 I yij ≥ 0 (∀(i, j) ∈ {1, 2, . . . , I} × {1, 2, . . . , J}), where yij denotes the amount of flow from a supply point i ∈ A to a demand point j ∈ B. We describe north-west corner rule in Algorithm NWCR, which finds a feasi- ble solution of Hitchcock transportation problem HTP(a, b, C′). It is easy to see that the north-west corner rule solution Y = (yij ) satisfies the equalities that i′ j ′ Xi=1 Xj=1 yij = min  i′ Xi=1 αi , j ′ Xj=1 βj  (∀(i′, j′) ∈ {1, 2, . . . , I} × {1, 2, . . . , J}). 14 Y. Kuroki and T. Matsui Algorithm NWCR Step 1: Set all the elements of matrix Y to 0 and set the target element yij to y11 (top-left corner). Step 2: Allocate a maximum possible amount of transshipment to the target element without making the row or column total of the matrix Y exceed the supply or demand respectively. Step 3: If the target element is yIJ (the south-east corner element), then stop. Step 4: Denote the target element by yij. If the sum total of jth column of Y is equal to bj , set the target element to yij+1. Else (the sum total of Y of ith row is equal to ai), set the target element to yi+1j . Go to Step 2. Since the coefficient matrix of the above equality system is nonsingular, the north-west corner rule solution is a unique solution of the above equality system. Thus, the above system of equalities has a unique solution which is feasible to HTP(a, b, C′). Appendix C Proof of Lemma 2 We describe a proof of Lemma 2 briefly. See [18] for detail. Proof. (1) When we introduce an index i′ satisfying π(i′) = i, it is easy to see that E[X π pi] = Pr[X π pi = 1] = Pr  i′−1 xpπ(j) ≤ U < Xj=1 xpπ(j) i′ Xj=1  = xpπ(i′) = xpi. (2) We denote E[X π vector y′ satisfies that for any pairs (p, q) ∈ N 2 and (i′, j′) ∈ H 2, qj] = Pr[X π qj = 1] by y′ piX π piX π piqj for simplicity. Then, the j ′ Xj=1 Xqπ(j) = 1    i′ i′ i′ j ′ y′  pπ(i)qπ(j) = Pr Xi=1 Xj=1 Xi=1   xpπ(i)  ∧ = Pr  Xi=1 U < U <  U < min = Pr Xj=1  xqπ(j) = min Xi=1   Xi=1 Xj=1 xpπ(i), xpπ(i), j ′ j ′ i′ i′ j ′ Xpπ(i) = 1  ∧  xqπ(j)  Xj=1   xqπ(j)    . From the above, (x, y′) satisfies the system (1) defined by (x, y; π). The non- singularity of (1) implies y′ = yπ.
1905.07455
3
1905
2019-10-23T14:56:50
Speeding up the Karatsuba algorithm
[ "cs.DS", "math.NT", "stat.CO" ]
This paper describes an $\sim {\cal O}(n)$ pre-compute technique to speed up the Karatsuba algorithm for multiplying two numbers.
cs.DS
cs
Speeding up the Karatsuba algorithm Satish Ramakrishna Department of Physics & Astronomy, Rutgers, the State University of New Jersey, 136 Frelinghuysen Road Piscataway, NJ 08854-8019∗ Kamesh Aiyer Kashi Software Inc, 11 Magazine Street, Cambridge, MA 02139† Abstract The Karatsuba method was the first published attempt to speed up the multiplication of two It is well-known to be of complexity ∼ O(nlog2 3). There are currently, improved numbers [1]. mathematical algorithms, that surpass this algorithm in complexity [3 -- 7]. While it does not seem possible to improve upon the basic mechanism of the Karatsuba technique and we demonstrate why it is the most efficient of its type, it is possible that one can improve its implementation for particular decile ranges of numbers. This article presents an approach to speed up the implementation of the Karatsuba technique, utilizing extra memory to supplement the original method. While the method is conceptually similar to the "Method of Four Russians" technique used to speed up Matrix Multiplications, it applies the concept in a different area. 9 1 0 2 t c O 3 2 ] S D . s c [ 3 v 5 5 4 7 0 . 5 0 9 1 : v i X r a 1 The Karatsuba algorithm [1, 2], an O(nlog2 3) technique to multiply two n-digit numbers, has been surpassed by newer techniques that are O(n×log n×log log n) [3 -- 7] and O(n×log n) [8] respectively. However, the simplicity of the algorithm allows improvements that are easily implemented and can be reduced to fewer multiplications, supplemented by look-ups. THE KARATSUBA ALGORITHM For simplicity, consider multiplying two n-digit numbers x and y, written as x = x0 + x110m y = y0 + y110m (1) where for simplicity,we use n = 2k, m = n 2 and work in base-10. The product can be simplified to x.y = x0y0 + (x0y1 + x1y0) × 10m + x1y1102m = x0y0 + ((x0 + x1)(y0 + y1) − x0y0 − x1y1) × 10m + x1y1102m (2) so that the product of the n-digit numbers can be reduced to the multiplication of three independent m-digit (and occasionally m+1-digit) numbers, instead of four m-digit numbers. Note that multiplications by 10 are ignored in the complexity calculations, since they can be reduced to decimal point shifts before additions. Also, as a general principle, the complexity calculation ignores the number of additions, since they are sub-dominant in complexity. The order of magnitude ("complexity") of the number of separate multiplications to multiply these two numbers can be reduced to the relation M(n) = 3M( n 2 ) + O(n) → M(n) ∼ O(nlog2 3) (3) The Karatsuba technique is sometimes referred to as the "divide-by-two-and-conquer" method. An alternative approach to computing the complexity above is as follows. At every step, the starting number (initially n = 2s digits long) is split into two numbers with half the number of digits. After s steps, it is easy to see that 3s multiplications of single-digit numbers need to be performed. This number, the number of multiplications required, can be written as 3s = 3log2 n = nlog2 3; hence the above complexity result. This calculation is exact (as explained above) for a number with a power of 2 as the number of digits. 2 THE IMPROVED VERSION We generalize the Karatsuba divide-by-two-and-conquer algorithm as follows and write (in base-B) x = x0 + x1 × Bm + x2 × B2m + ... + xN × BN m y = y0 + y1 × Bm + y2 × B2m + ... + yN × BN m (4) As can be quickly checked, each of the numbers x0, ..., xN , y0, ..., yN are m-digits long and (N + 1)m = n where n is the total number of digits in x and y. The number of multiplications required to multiply x and y, i.e., the order of complexity, is M = (N +1)+C(N +1, 2) ∼ (N +1)2 2m2 individual products of m-digit (and occasionally m + 1-digit) numbers. For instance, if N = 1, as in the usual Karatsuba technique, M = 2 + 1 = 3 which is what we use in the order-of-magnitude estimate in Equation (3). 2 ∼ n2 In the Karatsuba technique, the m(= 2) digit numbers are further multiplied by the same technique, carrying on recursively till we are reduced to single-digit multiplications. That leads to the recursive complexity calculation noted in Equation (3). However, note that if we simply pre-computed the individual m-digit multiplications and looked up the individual multiplications, we end up with essentially ∼ n2 2m2 lookups rather than actual multiplications. Indeed, lookups take, on average, 1/5 the time taken for single- digit multiplication (and then we have to multiply by the number of operations L required to perform the lookup), hence the complexity when lookups are added are ∼ n2 10m2 × L in comparison with the Karatsuba method. As we will show below, L ∼ 6m, so that the total complexity of the algorithm is ∼ n2 N +1, the complexity is ∼ (N + 1)n. When compared to the Karatsuba technique, this is much quicker than n1.58. This is the main result of this short note. m . If m were chosen to be a fraction of n, i.e., m = n The lookups of m-digit multiplications need to be performed against a table of size Bm × Bm. This lookup, as can be verified by standard binary-search techniques, is (for B = 10) of complexity ∼ log2(102m) = 2m log2 10 ∼ 6m. There are some additional additions and subtractions, which add additional (though sub-dominant) complexity ∼ n as can be easily checked and are detailed in the below example. m Analyzing this further, we could choose to mix and match in two different ways, i.e., 1. We could apply k Karatsuba-style divide-by-two-and-conquer steps, then apply the 3 lookup method to look-up 3k pre-calculated products of n 2k digits or 2. We could use the (N + 1) = 2k-block technique (break-up into m digit blocks) with m = n 2k , we'd have to look-up 2k + C(2k, 2) products. It is clear that 3k < 2k + C(2k, 2), so the divide-by-two-and-conquer strategy yields fewer lookups - it is the quickest way to speed up the calculation. A graph of the reduced com- 3)N−k) achieved this way is plotted in Figure 1 - clearly, cutting the plexity (essentially 3N ( 2 recursion off early is advantageous. A little reflection will show why divide-and-conquer by 2 for k times followed by lookup is the most efficient way to carry out the above procedure, in fact it is illustrative for it demonstrates why the Karatsuba technique is the most efficient of the divide-and-conquer techniques. Each time we divide an n-digit number into N + 1 blocks of m-digits, we have to (recursively) perform (N + 1) + C(N + 1, 2) multiplications. After k such recursions, we are (N +1)k digits each and have to perform ((N + 1) + C(N + 1, 2))k left with (N + 1)k blocks of n multiplications. At this point, if we look up pre-computed products of numbers of this type, that is a complexity factor of ∼ n (N +1)k . The total number of operations is ∼ ((N + 1) + C(N + 1, 2))k × n (N + 1)k = n(1 + N 2 )k which is smallest for smallest N , i.e., N = 1. The complexity then matches exactly the complexity of the Karatsuba algorithm. A numerical example The above arithmetic is demonstrated in the case below for N = 4, where we have used n = 5m, x = x0 + x1Bm + x2B2m + x3B3m + x4B4m y = y0 + x1Bm + y2B2m + y3B3m + y4B4m (5) 4 FIG. 1. Plot of the Efficiency of cutting off Karatsuba early which leads to the product x.y = B0x0y0 + Bm ((x0 + x1)(y0 + y1) − x0y0 − x1y1) +B2m ((x0 + x2)(y0 + y2) − x0y0 − x2y2 + x1y1) +B3m ((x0 + x3)(y0 + y3) − x0y0 − x3y3 + (x1 + x2)(y1 + y2) − x1y1 − x2y2) +B4m ((x0 + x4)(y0 + y4) − x0y0 − x4y4 + (x1 + x3)(y1 + y3) − x1y1 − x3y3 + x2y2) +B5m ((x1 + x4)(y1 + y4) − x1y1 − x4y4 + (x2 + x3)(y2 + y3) − x2y2 − x3y3) +B6m ((x2 + x4)(y2 + y4) − x2y2 − x4y4 + x3y3) +B7m ((x3 + x4)(y3 + y4) − x3y3 − x4y4) + B8m (x4y4) (6) As can be observed, this expression has 5 + C(5, 2) = 15 independent products that can be pre-computed, i.e.., the 5 simple products x0y0, x1y1, x2y2, x3y3, x4y4 and the 10 combination products (x0+x1)(y0+y1), (x0+x2)(y0+y2), (x0+x3)(y0+y3), (x0+x4)(y0+y4), (x1+x2)(y1+ y2), (x1 +x3)(y1 +y3), (x1 +x4)(y1 +y4), (x2 +x3)(y2 +y3), (x2 +x4)(y2 +y4), (x3 +x4)(y3 +y4). If these products are found in a pre-computed table of m and (m + 1)-digit numbers, we would not need any multiplications at all, just 15 lookups, for any m, with n = 5m. We would need to perform additions and subtractions, of course and there are 34 of them 5 in the above example - this number of elementary operations depends, however, only upon n m. Memory Requirements Typical RSA encryption algorithms use ∼ 1000-digit base-10 composite numbers that are the product of five-hundred-digit primes. If one were to attack the problem by pre-computing keys, i.e., pre-multiplying pairs of five-hundred-digit primes (n = 500 ∼ 29) and storing the results of multiplying all possible 6-digit numbers (m = 6 ∼ 23), one has a complexity m = 85n ∼ 42, 500, which is worse than the new ∼ n log2 n ∼ 4500 complexity [8], albeit ∼ n2 the fact that the newer approach also has multipliers, which we have not accounted for. If we use the hybrid method (Karatsuba followed by look-up of 6-digit products), the complexity is ∼ 36 × 6 ∼ 4200, which is arguably much better (no pre-factors missing) than even the n log2 n algorithms. We would need to store ∼ 1012 twelve-digit numbers, roughly 20 TB of memory, which is a reasonable size. CONCLUSION This paper presents a rapid pre-computed approach to speeding up multiplications. Though one needs to pre-compute and store all possible m-digit multiplications, one can compute the products of two integers with number of digits equal to any integer times m in time proportional to the number of digits (times the afore-mentioned integer). Memory is cheaper than CPU-speed, so this is a method that can be exploited in other (for instance signal-processing) situations to speed up intensive calculations too. Useful conversations are acknowledged with Dr. B. Kumar. As this paper was being prepared, an article about using pre-stored calculations was released, where the Eratosthenes sieve was sped up in calculation complexity [9]. ∗ [email protected][email protected] [1] An. Karatsuba and Yu. Ofman (1962). "Multiplication of Many-Digital Numbers by Auto- 6 matic Computers". Proceedings of the USSR Academy of Sciences. 145: 293294. Translation in the academic journal Physics-Doklady, 7 (1963), pp. 595596Nuovo Cimento B37 (1977). [2] A. A. Karatsuba (1995). "The Complexity of Computations" (PDF). Proceedings of the Steklov Institute of Mathematics. 211: 169183. Translation from Trudy Mat. Inst. Steklova, 211, 186202 (1995) [3] A. Schonhage and V. Strassen, "Schnelle Multiplikation groer Zahlen", Computing 7 (1971), pp. 281292 [4] A. Toom. The Complexity of a Scheme of Functional Elements Realizing the Multiplication of Integers. Soviet Mathematics - Doklady, 1963, v. 3, pp 714-716. Originally published in Russian [5] S. A. Cook. "On the Minimum Computation Time of Functions". Ph.D. Thesis. Cambridge, MA: Harvard University, pp. 51-77, 1966. [6] A. Dutt and V. Rokhlin, "Fast Fourier transforms for nonequispaced data", SIAM J. Sci. Comput. 14 (1993), no. 6, 1368 (1393. MR 1241591) [7] M. Furer, "Faster integer multiplication" STOC07 -- Proceedings of the 39th Annual ACM Symposium on Theory of Computing, ACM, New York, 2007, pp. 57 (66. MR 2402428 (2009e:68124)) [8] D. Harvey and J. Van Der Hoeven. Integer Multiplication in time O(n × log n), https://hal.archives-ouvertes.fr/hal-02070778 [9] Helfgott, Harald Andrs. https://doi.org/10.1090/mcom/3438 "An improved sieve of Eratos- thenes" [10] Arlazarov, V., Dinic, E., Kronrod, M., Faradev, I. "On economical construction of the tran- sitive closure of a directed graph", Dokl. Akad. Nauk SSSR, 194 (11) (1970). 7
1003.4012
1
1003
2010-03-21T19:00:06
Phase Synchronization in Railway Timetables
[ "cs.DS", "math.OC", "physics.soc-ph" ]
Timetable construction belongs to the most important optimization problems in public transport. Finding optimal or near-optimal timetables under the subsidiary conditions of minimizing travel times and other criteria is a targeted contribution to the functioning of public transport. In addition to efficiency (given, e.g., by minimal average travel times), a significant feature of a timetable is its robustness against delay propagation. Here we study the balance of efficiency and robustness in long-distance railway timetables (in particular the current long-distance railway timetable in Germany) from the perspective of synchronization, exploiting the fact that a major part of the trains run nearly periodically. We find that synchronization is highest at intermediate-sized stations. We argue that this synchronization perspective opens a new avenue towards an understanding of railway timetables by representing them as spatio-temporal phase patterns. Robustness and efficiency can then be viewed as properties of this phase pattern.
cs.DS
cs
EPJ manuscript No. (will be inserted by the editor) 0 1 0 2 r a M 1 2 ] S D . s c [ 1 v 2 1 0 4 . 3 0 0 1 : v i X r a Phase Synchronization in Railway Timetables Christoph Fretter1, Lachezar Krumov2, Karsten Weihe2, Matthias Muller-Hannemann1, and Marc-Thorsten Hutt3 a 1 Institut fur Informatik, Martin-Luther-Universitat Halle-Wittenberg, Halle, Germany 2 Fachgebiet Algorithmik, Technische Universitat Darmstadt, Darmstadt, Germany 3 School of Engineering and Science, Jacobs University, Bremen, Germany Received: date / Revised version: date Abstract. Timetable construction belongs to the most important optimization problems in public trans- port. Finding optimal or near-optimal timetables under the subsidiary conditions of minimizing travel times and other criteria is a targeted contribution to the functioning of public transport. In addition to efficiency (given, e.g., by minimal average travel times), a significant feature of a timetable is its robust- ness against delay propagation. Here we study the balance of efficiency and robustness in long-distance railway timetables (in particular the current long-distance railway timetable in Germany) from the per- spective of synchronization, exploiting the fact that a major part of the trains run nearly periodically. We find that synchronization is highest at intermediate-sized stations. We argue that this synchronization perspective opens a new avenue towards an understanding of railway timetables by representing them as spatio-temporal phase patterns. Robustness and efficiency can then be viewed as properties of this phase pattern. PACS. 89.75.Fb Structures and organization in complex systems – 89.75.Hc Networks and genealogical trees – 89.20.Ff Computer science and technology – 89.40.-a Transportation 1 Introduction Railway timetables should be designed to achieve a max- imum level of utilization from a passenger's perspective. That is, regular waiting times for connecting trains should be kept to a minimum. However, this limits the network's robustness against perturbations: Depending on the wait- ing policy among connecting trains, a single delayed train may cause a cascade of further train delays in remote parts of the network. Minimal regular waiting times (minimal buffering times) cause maximal risk of such delay propaga- tion. Understanding this trade-off and limiting the prop- agation of delays through the networks is a challenge of practical importance. The construction of periodic railway timetables is al- gorithmically difficult and has been intensively studied as a periodic event scheduling problem (PESP), see for ex- ample [34,29,20]. The technical and economical side con- straints for a valid non-periodic schedule can be mod- eled as a feasible differential problem on a directed graph G = (V, E) with lower and upper edge bounds (cid:96), u ∈ QE. In a basic model, the vertex set V corresponds to depar- ture and arrival events, while the directed edges together with the bound values model constraints (travel times, minimum headway, minimum transfer times, etc.). One a supported by Volkswagen Foundation grants I/82717, I/82718 and I/83435. The authors wish to thank Deutsche Bahn AG for providing test data for scientific use. seeks for a vector π ∈ QV , called the timetable, which assigns to each event j a time-stamp πj satisfying (cid:96)e ≤ πj − πi ≤ ue for all e = (i, j) ∈ E. Thus, lower and upper edge bounds restrict the difference between two timestamps from below and above, respec- tively. For example, (cid:96)(i,j) = 15 ≤ πj − πi means that event j has to occur at least 15 time units after event i. See Figure 1 for a small example. In a periodic timetable, trains are grouped into lines which are to be operated by some period T . In the periodic event scheduling problem (with one fixed period T ) one searches for a vector π ∈ [0, T ) such that for all e = (i, j) ∈ E there exists ke ∈ Z with (cid:96)e ≤ πj − πi + T · ke ≤ ue. Fig. 1. Small excerpt of a periodic event scheduling problem. [15,17][15,17][1,3][1,3][3,T/3][5,20][20,22]arrival eventdeparture eventstanding edgetransfer edgeheadway edgelower bound upper bound train 3train 2train 1station Astation Bstation Ctraveling edge 2 Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables For the local public transport in Berlin (Germany), the first optimized periodic timetable used in daily operation has been obtained using mixed-integer linear program- ming techniques [21]. Netherlands Railways also have re- cently introduced a completely new periodic timetable, generated by a number of sophisticated operations re- search techniques, including constraint programming [15]. For countries with a less periodic timetable, including Ger- many, the construction process for long-distance timeta- bles is quite complex, and therefore still done to a large extent manually by experienced engineers. The planning process has a hierarchical component (international trains are scheduled first), and a behavioral component (keep as much as possible from the previous year's schedule). So far, railway timetables have been studied predom- inantly as an algorithmic challenge with the objective of constructing optimal (or near-optimal) connection pat- terns, minimizing resources and overall waiting time. Only recently, there have been first computational studies aim- ing at delay resistant periodic timetables [14,22,23]. Here we adopt an opposite perspective to timetable construction and analyze the spatio-temporal patterns in- duced by the timetable. A suitable language for this study is a representation of the train arrival/departure events as a spatio-temporal phase pattern. We study the distribu- tion of synchronization across stations. Synchronization phenomena have received a lot of attention in traffic mod- eling over the last few years, in particular for car traffic in cities and the impact of traffic light synchronization on the formation of traffic jams [8,18,19]. In the case of railway timetables, the situation is differ- ent in several ways: The "load" of a station is essentially determined by the number of tracks (giving the maxi- mal number of simultaneous or nearly simultaneous ar- rival/departure events). The typical number of directions (which can be interpreted as the degree of a station in a suitable effective network representation), from which one can select, is higher for train stations than for typical street crossings. If one considers a network of long-distance train con- nections as a mesh of routes through a planar system, where trains are started periodically at the endpoints of these routes, the spatial distances between the intersection sites of these routes determine a spatio-temporal phase pattern. The free parameters of this pattern are the rel- ative phases of the periodically started trains. In reality, the travel time between two stations can serve as an ad- ditional degree of freedom allowing for a shaping of the phase pattern beyond this simple thought experiment. Our main hypothesis is that the rank of the stations sorted according to size is the organizing parameter (i.e. the "control parameter" from the perspective of self-orga- nized systems [26, 31,38]), along which synchronization can be understood. In this paper, we use the notion buffer- ing time to denote the amount of time available to change between two trains (transfer time) for the planned sched- ule, i.e. without induced delays. Our other two observables are the average buffering time bi at station i and the sec- ondary delays si(p) induced by a primary (incoming) delay p because trains have to wait for other trains. The main result of our analysis is that a railway time- table induces a spatio-temporal phase pattern, and that properties of the phase pattern are linked to the efficiency and the robustness of the system. We observe that syn- chronization is highest at intermediate-sized stations. Here we contribute two points to the general debate: (1) We show that the current planning of railway time- tables (which involves some algorithmic construction, some manual curation and the resorting to features from previ- ous timetables) leads to an unexpected coherence on the level of the spatio-temporal phase pattern. (2) At the same time, our analysis shows that the gen- eral concept of a spatio-temporal phase pattern is a novel and helpful view for network-based scheduling problems. The remainder of this paper is structured as follows. In Section 2, we first give a detailed description of our numer- ical experiment, and then discuss the results in Section 3. Afterwards, we introduce an avalanche model for delay propagation on graphs (Section 4) helping us to under- stand the observed relation between synchronization and robustness. Finally, we conclude with a short summary and an outlook for future work (Section 5). 2 Formalism and Numerical Experiments The quality of the timetable is related to two distinct (and often conflicting) objectives: The sum of travel times over all routes should be minimal (efficiency) and typical delays should minimally increase the overall travel time (robust- ness). Apart from some freedom to determine the planned travel time from one station to another (i.e. the prescribed average speed of the train), the main tuning capacity lies in the interchange time between connecting trains. While efficiency requires a minimization of interchange time, ro- bustness can be established by using the interchange time as a buffer for incoming delays. The secondary delays si observed at each station i across a range of primary delays p have been obtained by a large-scale numerical experiment performed on the actual timetable of Deutsche Bahn AG, together with real pas- senger information. Throughout our investigation we con- sider only long-distance train connections (served by the train categories ICE and IC/EC). To simulate the effects of delays, we use the dependency graph model introduced in [28] and its implementation within the fully realistic multi-criteria timetable information system MOTIS [33]. The dependency graph is basically a time-expanded graph model with distinct nodes for each departure and arrival event in the entire schedule for the current and following days. In addition, the model includes two further types of nodes: forecast and schedule nodes. Each node has a time-stamp which can dynamically change. The timestamps reflect the current situation, i.e. the expected departure or arrival time subject to all de- lay information known up to this point. Schedule nodes are marked with the planned time of an arrival or depar- ture event, whereas the time-stamp of a forecast node is Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables 3 Fig. 3. Data flow in the delay propagation experiment. Fig. 2. from [28]). Illustration of the dependency graph model (taken the current external prediction for its departure or arrival time. The nodes are connected by five different types of edges (see Figure 2). The purpose of an edge is to model a con- straint on the time-stamp of its head node. – Schedule edges connect schedule nodes to departure or arrival nodes. They carry the planned time for the corresponding event of the head node (according to the published schedule). – Forecast edges connect forecast nodes to departure or arrival nodes. They represent the time stored in the associated forecast node. – Standing edges connect arrival events at a certain sta- tion to the following departure event of the same train. They model the condition that the arrival time of train t at station k plus its minimum standing time must be respected before the train can depart (to allow for boarding and disembarking of passengers). – Traveling edges connect a departure node of some train t at a certain station k to the very next arrival node of this train at station k(cid:48). – Transfer edges connect arrival nodes to departure nodes of other trains at the same station, if there is a planned transfer between these trains. The current time-stamp for each departure or arrival node can be defined recursively, for details see [28]. The MOTIS tool can be used as follows. Given the planned train connection of a passenger and a concrete delay scenario (for example, a single primary delay of a train), we can query MOTIS for the fastest train connec- tion towards the passenger's destination, subject to the standard waiting rules between connecting trains. In par- ticular, the train waiting regulations of Deutsche Bahn have been used. From the difference between the planned arrival time at the destination and the calculated arrival time in the delay scenario we obtain the individual delay for each passenger. Passenger information has been available to us for a single day in the form of all travel agency bookings for that day. While these data are certainly distorted by the fact that most tickets are sold via vendor machines at the station (and these data have not been available to us), it Fig. 4. Distribution of daily numbers of arrival/departure (A/D) events. is nevertheless helpful to include passenger data for two reasons: (1) Only routes, which have really been traveled, enter our analysis; in this way we avoid artifacts, e.g., from back- and-forth contributions. (2) We can discuss both the average delay per passen- ger and the cumulative delay over all affected passengers (as a measure of the total systemic effect). In Figure 3, we sketch the data flow within our numer- ical experiment, where we have processed 43772 train seg- ments, 2622 stations, 130071 passenger routes, and about 1.8 million MOTIS queries. In order to illustrate the raw data obtained from this numerical experiment, we show the station size distribu- tion (where the station size is given by the number of arrival/departure events per day) in Figure 4; and the buffering time distribution in Figure 5. Both distribu- tions are essentially unimodal and have a non-negligible tail at large values. The rare occurrence of low buffer- ing times can be explained by the fact that the timetable information system does not provide connections where a (station-specific) minimal interchange time is not reached. It should be noted that this general rule is accompanied by a long list of exceptions for specific trains and specific connections. All these constraints and subsidiary condi- tions have been included in the numerical experiment, in order to obtain realistic event data. TravelRequestScheduleMOTISQueryDepartureTime ExtractionItineraryDepartureTimesDelayPropagationBuffering TimeExtractionProcessingSynchronizationData on Delay PropagationBuffering TimeSynchron.Data 4 Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables Fig. 5. Distribution of the average buffering time per station. Fig. 7. Secondary delay as a function of the buffering time for a fixed primary delay p = 5 minutes, raw data. Fig. 6. Conversion of the arrival/departure times at a station k into the synchronization index σk. (cid:110) As a next step we compare these delays with unper- turbed features of the timetable. Our approach for con- verting the timetable into an event pattern uses the lan- guage of phase synchronization. Let be the set of arrival/departure (A/D) times t(k) of the jth train at station k. The quantity Tk denotes the number of A/D events at station k per day. These A/D times are now translated into phases , j = 1 . . . Tk (cid:111) t(k) j j φ(k) j (τ ) = 2π r (t(k) j mod τ ) (1) with the period length τ as a parameter. In our analy- sis we set this parameter to the maximal period length observed in the system, i.e., τ = 120 minutes. For each station k we can now compute the synchronization index (as known from the classical studies of synchronization in populations of phase oscillators, see [16,36,39]; see also the scheme depicted in Figure 6): σk = σk(τ ) = eiφ(k) j (τ ) (2) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 1 Tk Tk(cid:88) j=1 (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Fig. 8. Dependence of buffering time b on station rank. 3 Results The large-scale numerical experiment described in the pre- vious section in particular yields realistic values of the sec- ondary (induced) delay s(p) as a function of the primary (input) delay p. While at low p the value of s(p) is mainly (but indirectly!) shaped by the buffering time b, at higher p the value is strongly influenced by the number of alter- native connections. On face value, one would expect a negative correlation of the secondary delay s(p) and the buffering time b in this low-p region. In the raw data, Figure 7, there is rather a lack of correlation (or even a slight tendency towards pos- itive correlations), which can be explained as follows: The buffering time b grows slowly with the station rank, i.e. decreases slightly with the station size (cf. Figure 8). At the same time, larger stations (i.e. more A/D events) offer more alternative routes, effectively reducing the secondary delay, even at low primary delay p. The view we want to propagate here, is that the per- formance (in a very general sense) of a given timetable of train connections is related to its phase pattern. In the example shown in Figure 9, there are only 4 minutes of buffering time which induce no delay. When p is in the range of [4, 9] minutes, the secondary delay becomes Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables 5 p=5 minutes and p=30 minutes. There is a wide spread of deviations from the solid line showing the expectation for the case of a linear s(p). This is indicative of the multitude of strengths with which these additional, higher-p effects contribute. The challenge is now to establish in detail the relations between the degree of synchronization and the perfor- mance of the system (given by low delay propagation, i.e. robustness, and low overall transfer times, i.e. efficiency). On the level of our data, the main performance indica- tors of the system, namely the efficiency and robustness, are only indirectly accessible via the secondary delays and the buffering times. We expect that a small s(p) is related to high robustness (a given perturbation p induces a small effect s), while a small b can be associated with high ef- ficiency (during a full itinerary only a small amount of time, given by the local buffering times b, is accumulated upon train interchanges). Fig. 9. Secondary delay as a function of the primary delay for a single train. Fig. 10. Average secondary delay as a function of the primary delay for a sin- gle station (here: Frankfurt (Main) central). 4 minutes, and then jumps to 25 minutes. Figure 10 shows the average secondary delay at a station, which is, as a first approximation a linear function. At higher values of p, additional effects can be expected to set in: (1) with higher p more alternative routes become accessible, (2) more passengers will be affected, and (3) longer avalanches of delayed trains are triggered upon waiting. These contributions are partially compensated by the waiting policy: Avalanche length is strongly reduced by maximal waiting times. Also, the second contribution has a smaller (but still non-zero) effect on the average sec- ondary delay per passenger. Fig. 12. Secondary delay as a function of the buffering time for a fixed primary delay p = 5 minutes, averaged and connected along the station rank, together with a phenomenological sep- aration into quadrants according to high/low efficiency (first quadrant label) and high/low robustness (second label). When splitting the b-s(p)–plane into four quadrants corresponding of contributions of high/low delays and buffering times – and, consequently, low/high (−/+) per- formance –, one can observe very different usages (i.e., frequencies of occurrence in the data) of the quadrants: The ++ region, which is the most efficient one as those stations are both efficient (small buffering time) and ro- bust (small secondary delays), is most densely populated, followed by the +− region (high efficiency, low robust- ness). Very few stations are found in the −− region. Inter- estingly we do not find stations in the −+ region. Probably those are quickly eliminated during the schedule building or avoided during the route search. Fig. 11. Correlation of the secondary delay with primary delay of 5 and 30 minutes. Figure 11 shows the correlation between the secondary delays for two different values of the primary delay, namely 6 Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables Fig. 13. The synchronization indices of the stations in ascend- ing order of the station rank in Germany with NR = 100 and an averaging window of 40 Fig. 14. Average σ∗ for small, medium and large stations. The rank is split at 80 and 170 A/D events per day, respectively. k , shown as the black curve in Figure 13. k In order to better understand the systematic relation between s(p) and b it is again helpful to use the station size as a control parameter along which local averages can be performed. The resulting curve is shown in Figure 12. This curve displays the backbone systematics of the interplay between efficiency (inverse b) and robustness (inverse s(p)) studied from the raw data in Figure 7, when using station size as an ordering parameter. Figure 13 shows the synchronization index σ∗ k as a function of the station rank k. The phase data are dis- torted by the mere number of A/D events. In particular, at few A/D events large fluctuations of σ are induced. We therefore subtracted from each σk an average σ(R) over NR runs of a null model, where the same number of A/D events has randomly been distributed in time. This procedure yields the reduced synchronization indices k=σk − σ(R) σ∗ Furthermore, stations with neighboring ranks will dif- fer (even though they are similar in size) in a variety of additional parameters. The original reduced synchroniza- tion index shows a strong local fluctuation along the rank. In order to eliminate the variation coming from these addi- tional differences between similar-sized stations, we com- pute local averages over the σ∗ k. These values are shown as the red curve in Figure 13. Remarkably, synchroniza- tion is highest at intermediate station rank, decreasing towards both larger and smaller station sizes. In order to obtain this result, several processing steps of the raw data have been necessary. The systematic difference between the synchronization of large, small and intermediate train stations, respectively, is also seen, when average synchro- nization indices for each of these three categories are com- puted directly (Figure 14). In order to assess, whether this elevated synchroniza- tion of intermediate-size stations is a property of train timetables beyond this individual case, we also computed the synchronization indices σ∗ k for four other counties, Austria, France, Norway, and the Czech Republic (Fig- (a) Austria (b) France (c) Norway (d) Czech Republic Fig. 15. The synchronization in the long-distance train con- nections of different European countries with NR = 100 and an averaging window of 40. ures 15(a)-15(d)). France shows only a very weak signal, whereas the shapes of the synchronization curves in Aus- tria, Norway and the Czech Republic are very similar to the one observed in Germany (Figure 13). In the following we will show results for the inter- dependencies of our main quantities bk, sk(p) and σ∗ k. In all cases, like before, we compute local averages with re- spect to the rank. By grouping the stations according to their position in the b-s(p)–plane, Figure 12, i.e. accord- ing to their robustness and efficiency, one can now study, whether stations from the same regions share a common synchronization index σ∗ k. Figure 16 shows the average σ for the three regions containing stations. The stations from the most prefer- able region ++ show extremely low synchronization, while Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables 7 those of the regions +− and −− are much more synchro- nized. consequently, an anti-correlation between synchronization and robustness. 4 Avalanche Model Can the negative correlation between synchronization and robustness that we observe in the data also be under- stood in some minimal model of delay propagation? The general dynamical mechanism resembles some aspects of avalanches on graphs. While avalanche models are an im- portant focus of interest in complex systems theory and in particular in the field of self-organized criticality [9, 2], we do not expect here a power-law distribution of event sizes, as the elementary processes behind delay propaga- tion are different from the threshold-driven re-distribution schemes encoded, e.g. in the Bak-Tang-Wiesenfeld (BTW) model [3]. Therefore, we adapt the general concept of an avalanche model to the dynamical needs of delay propa- gation. In our passenger delay avalanche model the dynamical variables are the accumulated delays di(t) at node i as a function of time t. The model has three parameters: (1) The transmission probability p is the probability that a delay propagates from one node to an adjacent node, if the threshold is crossed. This probability describes the capacity to buffer incoming delays via transfer times. (2) The amplification factor m acknowledges the fact that a single train delay corresponds to multiple passenger delays; consequently, if a few incoming passengers cause a train with many outgoing passengers to wait, the to- tal (passenger-based) delay is amplified. This parameter can be seen as the ratio of these passenger numbers, i.e. the average rate of additionally delayed passengers due to waiting. (3) Delays only propagate from a node i to adjacent nodes, when the delay variable di(t) is above a threshold T , as we assume that only incoming delays higher than this threshold are capable of triggering delay propagation. Figure 18 shows that the tail of the size distribution of delay avalanches is exponential. In order to analyze the relation between synchroniza- tion and robustness within this model, we compare the av- erage avalanche length for a system, where a single node is periodically driven, with the case of a stochastically driven node. We assume that the gradual insertion of delay units into the system corresponds to incoming delays from other parts of the network entering the sub-network, which is here studied in detail. A periodic insertion of such delay units then corresponds to highly synchronized arrival/de- parture (A/D) events (as only those can give rise to pe- riodic delays), while the stochastically driven node repre- sents the typical pattern of incoming delays for a station with less synchronized A/D events. Figure 19 shows the distribution of these average ava- lanche lengths for the two cases. The periodically driven node (high synchronization of A/D events) coincides with a high average size of the delay avalanches (i.e. higher vulnerability or lower robustness), while the stochastically Fig. 16. Average synchronization of the stations grouped to- gether by robustness and efficiency according to the quadrants in Figure 12. Fig. 17. Dependencies of buffering time b, secondary delay s(p), and synchronization index σ∗ k. In order to show the dependencies among these quanti- ties more directly, Figure 17 represents all three quantities bk, sk(p) and σ∗ k, simultaneously. The smoothing window size is set to 26. It is clearly visible that most stations are in the regions of low σ∗ k, low bk and low sk(p). Further- more, there is a clear correlation between sk(p) and σ∗ k and 8 Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables for example, we can translate those events into phases. Summing over all different phases we can compute a syn- chronization index for each station. Then, by exhaustive simulation we produce a primary delay at each station and record the induced secondary delays. Our results show a clear and surprising correlation between the synchroniza- tion index of a station, its robustness and efficiency. In the Introduction, we have discussed the difference between car traffic in cities and the impact of traffic light synchronization on the one side and railway timetables on the other. It would be interesting to compare these two types of traffic in detail, to quantitatively analyze the number of directions (node degrees) in the context of an effective dimension, and in particular to study the complexity (given, e.g., by the pattern of elementary deci- sions needed to specify the path) of a typical path in the train network compared to the car traffic case. A suitable methodology could be the framework developed in [32]. The balance between this antagonistic pair of require- ments, efficiency and robustness, is of broad interest across many disciplines, ranging from industrial production to biological processes. Lack of robustness due to too high efficiency is sometimes called the systemic risk, which has recently been discussed from a theoretical perspective, for example for complex economical systems (see [4,5,25]). Starting from an information-theoretical description of resilience in ecology, Ulanowicz et al. [37] could establish quantitative links between sustainability, efficiency and in- vestments in diversity. This general framework has been employed to analyze the current bank crisis from a ecosys- tem perspective [24]. We believe that a quantitative view on synchronization of arrival/departure events in the net- work of long-distance train connections, as presented here, can similarly serve as a starting point for a theoretical understanding, and subsequently systemic optimization, of the balance between efficiency and robustness for such timetables underlying public transportation. For biological processes this balance between efficiency and robustness has been explored in a multitude of ways resorting to both analysis of experimental data and the mathematical modeling of cellular processes. Motivated by graph theory and nonlinear dynamics, an influential trend in systems biology at the moment is to relate ro- bustness to small regulatory devices [1, 7], serving e.g. as a noise buffer or providing a suitable amount of redundancy for maintaining systemic function even under perturba- tions. In particular such relations between the architec- ture of regulatory devices and dynamical functions have been worked out for circuits of negative feedback loops [30], for feedforward loops as noise filtering devices in gene regulation [1,35], for interlinked feedback loops acting on different time scales [6], for a particular composition of regulatory units [27] and their relation to robustness [13, 10,11,12], for number of positive and negative feedback loops in regulatory circuits [17]. It could well be that in the network of long-distance train connections such small, motif-like network compo- nents serve as mediators between synchronization, relia- bility and efficiency. Exploring the involvement of network Fig. 18. The distribution of the avalanche lengths for stochas- tic and periodic drivers with a driving period of 17, T = 4, m = 0.9, N = 70 nodes and M = 240 edges. Fig. 19. The average avalanche length for stochastic and pe- riodic drivers with a driving period of 17, T = 4, m = 0.9, N = 70 nodes and M = 240 edges. driven node (low synchronization of A/D events) displays a lower average size of delay avalanches (and therefore a higher robustness). This is in agreement with the relation- ship discovered in the real train connection data studied in the previous section. 5 Conclusions In this work we have studied railway timetables from a novel and yet unexplored view, namely that of phase syn- chronization. For our analysis we investigated the German long-distance train timetable with respect to three distinct properties: robustness, efficiency and phase synchroniza- tion. The robustness reflects the stability of the system to small perturbations, while efficiency is related to short ac- cumulated waiting times per train route. These two prop- erties have been evolved over the years by gathered expe- rience and heuristic optimization. When we consider the arrival and departure events of all trains at a given station over a period of time, 24 hours Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables 9 topology in shaping this relationship is one of our principal goals in the continuation of the work presented here. References 1. U. Alon. Network motifs: theory and experimental ap- proaches. Nat Rev Genet, 8:450–461, 2007. 2. P. Bak. How Nature Works: The Science of Self-Organised Criticality. Copernicus Press, New York, 1996. 3. P. Bak, C. Tang, and K. Wiesenfeld. Self-organized criti- cality: An explanation of the 1/f noise. Phys. Rev. Lett., 59(4):381–384, Jul 1987. 4. S. Battiston, D. Delli Gatti, and M. Gallegati. Trade credit networks and systemic risk. In D. Helbing, editor, Man- aging Complexity: Insights, Concepts, Applications, pages 219–239. Springer, 2008. 5. S. Battiston, D. Delli Gatti, M. Gallegati, B. Greenwald, and J. Stiglitz. Credit chains and bankruptcy propagation in production networks. Journal of Economic Dynamics and Control, 31(6):2061–2084, 2007. 6. O. Brandman, J.E. Ferrell, R. Li, and T. Meyer. Inter- linked fast and slow positive feedback loops drive reliable cell decisions. Science, 310:496, 2005. 7. O. Brandman and T. Meyer. Feedback loops shape cellular signals in space and time. Science, 322:390–395, 2008. 8. E. Brockfeld, R. Barlovic, A. Schadschneider, and M. Schreckenberg. Optimizing traffic lights in a cellular au- tomaton model for city traffic. Phys. Rev. E, 64(5):056132, 2001. 9. H. J. Jensen. Self-Organized Criticality: Emergent Com- plex Behavior in Physical and Biological Systems. Cam- bridge University Press, 1998. 10. P. Kaluza, M. Ipsen, M. Vingron, and A. S. Mikhailov. Design and statistical properties of robust functional net- works: A model study of biological signal transduction. Phys. Rev. E, 75:015101, 2007. 11. P. Kaluza and A. S. Mikhailov. Evolutionary design of functional networks robust against noise. Europhys. Lett., 79:48001, 2007. 12. P. Kaluza, M. Vingron, and A. S. Mikhailov. Self- correcting networks: Function, robustness, and motif distributions in biological signal processing. Chaos, 18:026113, 2008. 13. K. Klemm and S. Bornholdt. Topology of biological net- works and reliability of information processing. PNAS, 102:18414–18419, 2005. 14. L.G. Kroon, R. Dekker, and M.J.C.M. Vromans. Cyclic railway timetabling: a stochastic optimisation approach. In F. Geraets, L.G. Kroon, A. Schobel, D. Wagner, and C. Zaroliagis, editors, Algorithmic Methods in Railway Op- timization, volume 4359 of Lecture Notes in Computer Sci- ence, pages 41–66. Springer, 2007. 15. L.G. Kroon, D. Huisman, E.J.W. Abbink, P.J. Fioole, M. Fischetti, G. Mar´oti, A. Schrijver, A. Steenbeek, and R. Ybema. The new Dutch timetable: The OR revolution. Interfaces, 39(1):6–17, 2009. 16. Y Kuramoto. Chemical Oscillations, Waves, and Turbu- lence. Springer, Berlin, 1984. 17. Y.-K. Kwon and K-H. Cho. Quantitative analysis of ro- bustness and fragility in biological networks based on feed- back dynamics. Bioinformatics, 24:987–994, 2008. 18. S. Lammer and D. Helbing. Self-control of traffic lights and vehicle flows in urban road networks. Journal of Statisti- cal Mechanics: Theory and Experiment, 2008(04):P04019 (34pp), 2008. 19. S. Lammer, H. Kori, K. Peters, and D. Helbing. Decen- tralised control of material or traffic flows in networks us- ing phase-synchronisation. Physica A: Statistical Mechan- ics and its Applications, 363(1):39 – 47, 2006. 20. C. Liebchen. Periodic timetable optimization in public transport. PhD thesis, Technische Universitat Berlin, 2006. 21. C. Liebchen. The first optimized railway timetable in prac- tice. Transportation Science, 42:420–435, 2008. 22. C. Liebchen, M. Schachtebeck, A. Schobel, S. Stiller, and A. Prigge. Computing delay resistant railway timetables. Computers and Operations Research, 37:857–868, 2010. 23. C. Liebchen and S. Stiller. Delay resistant timetabling. Public Transport, 1:55–72, 2009. 24. B. Lietaer, U. Ulanowicz, and S. Goerner. Options for managing a systemic bank crisis. SAPIENS, 2:1–15, 2009. 25. J. Lorenz, S. Battiston, and F. Schweitzer. Systemic risk in a unifying framework for cascading processes on networks. European Physical Journal B, 71:441–460, 2009. 26. S. C. Manrubia, A. S. Mikhailov, and D. H. Zannette. Emergence of Dynamical Order, Synchronization Phenom- ena in Complex Systems. World Scientific, 2004. 27. R. Milo, S. Itzkovitz, N. Kashtan, R. Levitt, S. Shen-Orr, I. Ayzenshtat, M. Sheffer, and U. Alon. Superfamilies of evolved and designed networks. Science, 303:1538, 2004. 28. M. Muller-Hannemann and M. Schnee. Efficient timetable information in the presence of delays. In R. K. Ahuja, R. H. Mohring, and C. D. Zaroliagis, editors, Robust and Online Large-Scale Optimization: Models and Techniques for Transportation Systems, volume 5868, pages 249–272. Springer, 2009. 29. L.W.P. Peeters. Cyclic railway timetable optimization. PhD thesis, Erasmus University Rotterdam, Rotterdam School of Management, The Netherlands, 2003. 30. S. Pigolotti, S. Krishna, and M.H. Jensen. Oscillation pat- terns in negative feedback loops. PNAS, 104:6533–6537, 2007. 31. A. Pikovsky, M. Rosenblum, and J. Kurths. Synchroniza- tion: A Universal Concept in Nonlinear Sciences. Cam- bridge University Press, 2003. 32. M. Rosvall, A. Gronlund, P. Minnhagen, and K. Sneppen. Searchability of networks. Phys. Rev. E, 72(4):046117, Oct 2005. 33. M. Schnee. Fully Realistic Multi-Criteria Timetable Infor- mation. PhD thesis, Technische Universitat Darmstadt, Germany, 2009. 34. P. Serafini and W. Ukovich. A mathematical model for pe- riodic event scheduling problems. SIAM Journal on Dis- crete Mathematics, 2:550–581, 1989. 35. S. Shen-Orr, R. Milo, S. Mangan, and U. Alon. Net- work motifs in the transcriptional regulation network of escherichia coli. Nat Genet, 31:64–68, 2002. 36. S. H. Strogatz. Exploring complex networks. Nature, 410(6825):268–276, 2001. 37. U. Ulanowicz, S. Goerner, B. Lietaer, and R. Gomez. Quantifying sustainability: Resilience, efficiency and the return of information theory. Ecological Complexity, 6:27– 36, 2009. 38. J. Walleczek, editor. Self-organized biological dynamics and nonlinear control. Cambridge University Press, 2000. 10 Fretter, Krumov, Weihe, Muller-Hannemann and Hutt: Phase Synchronization in Railway Timetables 39. A. T. Winfree. The Geometry of Biological Time. Springer, New York, 1980.
1304.4327
1
1304
2013-04-16T04:04:42
Tree-Independent Dual-Tree Algorithms
[ "cs.DS" ]
Dual-tree algorithms are a widely used class of branch-and-bound algorithms. Unfortunately, developing dual-tree algorithms for use with different trees and problems is often complex and burdensome. We introduce a four-part logical split: the tree, the traversal, the point-to-point base case, and the pruning rule. We provide a meta-algorithm which allows development of dual-tree algorithms in a tree-independent manner and easy extension to entirely new types of trees. Representations are provided for five common algorithms; for k-nearest neighbor search, this leads to a novel, tighter pruning bound. The meta-algorithm also allows straightforward extensions to massively parallel settings.
cs.DS
cs
Tree-Independent Dual-Tree Algorithms Ryan R. Curtin William B. March Parikshit Ram David V. Anderson Alexander G. Gray Charles L. Isbell, Jr. Georgia Institute of Technology, 266 Ferst Drive NW, Atlanta, GA 30332 USA [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] Abstract Dual-tree algorithms are a widely used class of branch-and-bound algorithms. Unfortu- nately, developing dual-tree algorithms for use with different trees and problems is often complex and burdensome. We introduce a four-part logical split: the tree, the traversal, the point-to-point base case, and the pruning rule. We provide a meta-algorithm which al- lows development of dual-tree algorithms in a tree-independent manner and easy exten- sion to entirely new types of trees. Repre- sentations are provided for five common al- gorithms; for k -nearest neighbor search, this leads to a novel, tighter pruning bound. The meta-algorithm also allows straightforward extensions to massively parallel settings. 1. Introduction In large-scale machine learning applications, algorith- mic scalability is paramount. Hence, much study has been put into fast algorithms for machine learning tasks. One commonly-used approach is to build trees on data and then use branch-and-bound algorithms to minimize runtime. A popular example of a branch- and-bound algorithm is the use of the trees for near- est neighbor search, pioneered by Bentley (1975), and subsequently modified to use two trees (“dual-tree”) (Gray & Moore, 2001). Later, an optimized tree struc- ture, the cover tree, was designed (Beygelzimer et al., 2006), giving provably linear scaling in the number of queries (Ram et al., 2009)—a significant improvement over the quadratically-scaling brute-force algorithm. Asymptotic speed gains as dramatic as described above are common for dual-tree branch-and-bound al- gorithms. These types of algorithms can be applied to a class of problems referred to as ‘n-body prob- lems’ (Gray & Moore, 2001). The n-point correla- Proceedings of the 30 th International Conference on Ma- chine Learning, Atlanta, Georgia, USA, 2013. JMLR: W&CP volume 28. Copyright 2013 by the author(s). tion, important in astrophysics, is an n-body problem and can be solved quickly with trees (March et al., 2012). In addition, Euclidean minimum spanning trees can be found quickly using tree-based algorithms (March et al., 2010). Other dual-tree algorithms include kernel density estimation (Gray & Moore, 2003a), mean shift (Wang et al., 2007), Gaussian sum- mation (Lee & Gray, 2006), kernel density estima- tion, fast singular value decomposition (Holmes et al., 2008), range search, furthest-neighbor search, and many others. The dual-tree algorithms referenced above are each quite similar, but no formal connections between the algorithms have been established. The types of trees used to solve each problem may differ, and in addition, the manner in which the trees are traversed can differ (depending on the problem or the tree). In practice, a researcher may have to implement entirely separate algorithms to solve the same problems with different trees; this is time-consuming and makes it difficult to explore the properties of tree types that make them more suited for particular problems. Worse yet, par- allel dual-tree algorithms are difficult to develop and appear to be far more complex than serial implemen- tations; yet, both solve the same problem. We make these contributions to address these shortcomings: • A representation of dual-tree algorithms as four separate components: a space tree, a traversal, a base case, and a pruning rule. • A meta-algorithm that produces dual-tree al- gorithms, given those four separate components. • Base cases and pruning rules for a variety of dual-tree algorithms, which can be used with any space tree and any traversal. • A theoretical framework, used to prove the correctness of these meta-algorithms and develop a new, tighter bound for k -nearest neighbor search. • Implications of our representation, including easy creation of large-scale distributed dual-tree algorithms via our meta-algorithm. Tree-Independent Dual-Tree Algorithms 2. Overview of Meta-Algorithm In other works, dual-tree algorithms are described as standalone algorithms that operate on a query dataset Sq and a reference dataset Sr . By observing common- alities in these algorithms, we propose the following logical split of any dual-tree algorithm into four parts: • A space tree (a type of data structure). • A pruning dual-tree traversal, which visits nodes in two space trees, and is parameterized by a BaseCase() and a Score() function. • A BaseCase() function that defines the action to take on a combination of points. • A Score() function that determines if a subtree should be visited during the traversal. We can use this to define a meta-algorithm: Given a type of space tree, a pruning dual- tree traversal, a BaseCase() function, and a Score() function, use the pruning dual- tree traversal with the given BaseCase() and Score() functions on two space trees Tq (built on Sq ) and Tr (built on Sr ). In Sections 3 and 4, space trees, traversals, and related quantities are rigorously defined. Then, Sections 5–8 define BaseCase() and Score() for various dual-tree algorithms. Section 9 discusses implications and future possibilities, including large-scale parallelism. 3. Space Trees To develop a framework for understanding dual-tree algorithms, we must introduce some terminology. Definition 1. A space tree on a dataset S ∈ ℜN ×D is an undirected, connected, acyclic, rooted simple graph with the fol lowing properties: • Each node (or vertex), holds a number of points (possibly zero) and is connected to one parent node and a number of child nodes (possibly zero). • There is one node in every space tree with no par- ent; this is the root node of the tree. • Each point in S is contained in at least one node of the tree. • Each node N of the tree has a convex subset of ℜD that contains each of the points in that node as wel l as the convex subsets represented by each child of the node. Notationally, we use the following conventions: Nr : {x1 , x3 } Np : {x1 , x5} x4 x2 x5 Sp x1 Nc : {x2} Nd : {x4} x3 Sr (a) Abstract representation. (b) ℜ2 representation. Figure 1. An example space tree. • The set of child nodes of a node Ni is denoted C (Ni ) or Ci . • The set of points held in a node Ni is denoted P (Ni ) or Pi . • The convex subset represented by node Ni is de- noted S (Ni ) or Si . • The set of descendant nodes of a node Ni , de- noted D n (Ni ) or D n i , is the set of nodes C (Ni ) ∪ C (C (Ni )) ∪ . . . . • The set of descendant points of a node Ni , de- noted D p (Ni ) or D p i , is the set of points { p : p ∈ D n (Ni ) ∪ P (Ni ) }. • The parent of a node Ni is denoted Par(Ni ). An abstract representation of an example space tree on a five-point dataset in ℜ2 is shown in Figure 1(a). In this illustration, Nr is the root node of the tree; it has no parent and it contains the points x3 and x1 (that is, Pr = {x1 , x5 }. The node Np contains points x1 and x5 and has children Nc and Nd (which each have no children and contain points x2 and x4 , respectively). In Figure 1(b), the points in the tree and the subsets Sr (darker rectangle) and Sp (lighter rectangle) are plotted. Sc = {x2} and Sd = {x4} are not labeled. Definition 2. The minimum distance between two nodes Ni and Nj is defined as dmin (Ni , Nj ) = min (cid:8) kpi − pj k ∀ pi ∈ D p i , pj ∈ D p j (cid:9) . Definition 3. The maximum distance between two nodes Ni and Nj is defined as i , pj ∈ D p dmax (Ni , Nj ) = max (cid:8) kpi − pj k ∀ pi ∈ D p j (cid:9) . Definition 4. The maximum child distance of a node Ni is defined as the maximum distance between the centroid Ci of Si and each point in Pi : ρ(Ni ) = max p∈Pi kCi − pk. Tree-Independent Dual-Tree Algorithms Definition 5. The maximum descendant dis- tance of a node Ni is defined as the maximum dis- tance between the centroid Ci of Si and points in D p i : kCi − pk. λ(Ni ) = max p∈D p i It is straightforward to show that kd-trees, octrees, metric trees, ball trees, cover trees (Beygelzimer et al., 2006), R-trees, and vantage-point trees all satisfy the conditions of a space tree. The quantities dmin (Nq , Nr ), dmax(Nq , Nr ), λ(Ni ), and ρ(Ni ) are easily derived (or bounded, which in many cases is sufficient) for each of these types of trees. For a kd-tree, dmin (Ni , Nj ) is bounded below by the minimum distance between Si and Sj ; dmax (Ni , Nj ) is bounded above similarly by the maximum distance between Si and Sj . Both ρ(Ni ) and λ(Ni ) are bounded above by dmax(Ci , Ni ). For the cover tree (Beygelzimer et al., 2006), each node Ni contains only one point pi and has ‘scale’ dmin (Ni , Nj ) is bounded below by d(pi , pj ) − si . 2si+1 − 2sj +1 and dmax(Ni , Nj ) is bounded above by d(pi , pj ) + 2si+1 + 2sj +1 . Because pi is the centroid of Si , ρ(Ni ) = 0. λ(Ni ) is simply 2si+1 . 4. Tree Traversals In general, the nodes of each space tree can be tra- versed in a number of ways. However, there have been no attempts to formalize tree traversal. Therefore, we introduce several definitions which will be useful later. Definition 6. A single-tree traversal is a process that, given a space tree, wil l visit each node in that tree once and perform a computation on any points contained within the node that is being visited. As an example, the standard depth-first traversal or breadth-first traversal are single-tree traversals. From a programming perspective, the computation in the single-tree traversal can be implemented with a sim- ple callback BaseCase(point) function. This allows the computation to be entirely independent of the single-tree traversal itself. As an example, a simple single-tree algorithm to count the number of points in a given tree would increment a counter variable each time BaseCase(point) was called. However, this concept by itself is not very useful; without pruning branches, no computations can be avoided. Definition 7. A pruning single-tree traversal is a process that, given a space tree, wil l visit nodes in the tree and perform a computation to assign a score to that node. If the score is above some bound, the node is “pruned” and none of its descendants wil l be visited; otherwise, a computation is performed on any points Algorithm 1 DepthFirstTraversal(Nq, Nr ). if Score(Nq, Nr ) = ∞ then return for each pq ∈ Pq , pr ∈ Pr do BaseCase(pq, pr ) for each Nqc ∈ Cq , Nrc ∈ Cr do DepthFirstTraversal(Nqc, Nrc) contained within that node. If no nodes are pruned, then the traversal wil l visit each node in the tree once. Clearly, a pruning single-tree traversal that does not prune any nodes is a single-tree traversal. A prun- ing single-tree traversal can be implemented with two callbacks: BaseCase(point) and Score(node). This allows both the point-to-point computation and the scoring to be entirely independent of the traversal. Thus, single-tree branch-and-bound algorithms can be expressed in a tree-independent manner. Extensions to the dual-tree case are given below. Definition 8. A dual-tree traversal is a process that, given two space trees Tq (query tree) and Tr (reference tree), wil l visit every combination of nodes (Nq , Nr ) once, where Nq ∈ Tq and Nr ∈ Tr . At each visit (Nq , Nr ), a computation is performed be- tween each point in Nq and each point in Nr . Definition 9. A pruning dual-tree traversal is a process which, given two space trees Tq (query tree) and Tr (reference tree), wil l visit combinations of nodes (Nq , Nr ) such that Nq ∈ Tq and Nr ∈ Tr no more than once, and perform a computation to assign a score to that combination. If the score is above some bound, the combination is pruned and no combinations (Nqc , Nrc ) such that Nqc ∈ D n q and Nrc ∈ D n r ) wil l be visited; otherwise, a computation is performed between each point in Nq and each point in Nr . Similar to the pruning single-tree traversal, a prun- ing dual-tree algorithm can use two callback functions BaseCase(pq, pr ) and Score(Nq, Nr ). An exam- ple implementation of a depth-first pruning dual-tree traversal is given in Algorithm 1. The traversal is started on the root of the Tq and the root of Tr . Algorithm 1 provides only one example of a commonly- used pruning dual-tree traversal. Other possibilities not explicitly documented here include breadth-first traversals and the unique cover tree dual-tree traversal described by Beygelzimer et al. (2006), which can be adapted to the generic space tree case. The rest of this work is devoted to using these concepts to represent existing dual-tree algorithms in the four parts described in Section 2. Tree-Independent Dual-Tree Algorithms 5. k-Nearest Neighbor Search k -nearest neighbor search is a well-studied problem with a plethora of algorithms and results. The prob- lem can be stated as follows: Given a query dataset Sq ∈ ℜn×d , a reference dataset Sr ∈ ℜm×d , and an integer k : 0 < k < m, for each point pq ∈ Sq , find the k nearest neighbors in Sr and their distances from pq . The list of nearest neighbors for a point pq can be referred to as Npq and the dis- tances to nearest neighbors for pq can be referred to as Dpq . Thus, the k -th nearest neighbor to point pq is Npq [k ] and Dpq [k ] = kpq − Npq [k ]k. This can be solved using a brute-force approach: com- pare every possible point combination and store the k smallest distance results for each pq . However, this scales poorly – O(nm); hence the importance of fast algorithms to solve the problem. Many existing al- gorithms employ tree-based branch-and-bound strate- gies (Beygelzimer et al., 2006; Cover & Hart, 1967; Friedman et al., 1977; Fukunaga & Narendra, 1975; Gray & Moore, 2001; Ram et al., 2009). We unify all of these branch-and-bound strategies by defining methods BaseCase(pq, pr ) and Score(Nq, Nr ) for use with a pruning dual-tree traversal. At the initialization of the tree traversal, the lists Npq and Dpq are empty lists for each query point pq . After the traversal is complete, for a query point pq , the set {Npq [1], ..., Npq [k ]} is the ordered set of k nearest neighbors of the point pq , and each Dpq [i] = kpq − Npq [i]k. If we assume that Dpq [i] = ∞ if i is greater than the length of Dpq , we can formulate BaseCase() as given in Algorithm 21 . With the base case established, only the pruning rule remains. A valid pruning rule will, for a given query node Nq and reference node Nr , prune the reference subtree rooted at Nr if and only if it is known that there are no points in D p r that are in the set of k nearest neighbors of any points in D p q . Thus, at any point in the traversal, we can prune the combination (Nq , Nr ) if and only if dmin (Nq , Nr ) ≥ B1 (Nq ), where B1 (Nq ) = max p∈D p q Dp [k ]. Now, we can describe this bound recursively. This is important for implementation; a recursive function 1 In practice, k-nearest-neighbors is often run with iden- tical reference and query sets. In that situation it may be useful to modify this implementation of BaseCase() so that a point does not return itself as the nearest neighbor (with distance 0). Algorithm 2 k -nearest-neighbors BaseCase() Input: query point pq , reference point pr , list of k nearest candidate points Npq and k candidate dis- tances Dpq (both ordered by ascending distance) Output: distance d between pq and pr d ← kpq − pr k if d < Dpq [k ] and BaseCase(pq, pr ) not yet called then insert d into ordered list Dpq and truncate list to length k insert pr into Npq such that Npq is ordered by distance and truncate list to length k return d can cache previous calculations for large speedups. Dp [k ], max Nc∈Cq Dp [k ], max Nc∈Cq Dp [k ], max p∈D p q ,p6∈Pq Dp [k ](cid:9) B1 (Nq ) = max (cid:8) max p∈Pq Dp [k ]}(cid:9) = max (cid:8) max { max p∈D p p∈Pq c B1 (Nc )(cid:9) = max (cid:8) max p∈Pq Suppose we have, at some point in the traversal, two points p0 , p1 ∈ D p q for some node Nq , with Dp0 [k ] = ∞ and Dp1 [k ] < ∞. This means there exist k points {p1 r } in Sr such that d(p1 , pi r , . . . , pk r ) ≤ Dp1 [k ] for i = {1, . . . , k}. Because p0 , p1 ∈ D p q , we can apply the tri- angle inequality to see that d(p0 , p1 ) ≤ 2λ(Nq ). There- fore, d(p0 , pi r ) ≤ Dp1 [k ] + 2λ(Nq ) for i = {1, . . . , k}. Using this observation we can construct an alternate bound function B2 (Nq ): B2 (Nq ) = min p∈D p q Dp [k ] + 2λ(Nq ) which can, like B1 (Nq ), be rearranged to provide a recursive definition. In addition, if p0 ∈ Pq and p1 ∈ D p q , we can bound d(p0 , p1 ) more tightly with ρ(Nq ) + λ(Nq ) instead of 2λ(Nq ). These observations yield B2 (Nq ) = min (cid:26) min (Dp [k ] + ρ(Nq ) + λ(Nq )), p∈Pq (B2 (Nc ) + 2(λ(Nq ) − λ(Nc ))(cid:27) . min Nc∈Cq Both B1 (Nq ) and B2 (Nr ) provide valid pruning rules. We can combine both to get a tighter pruning rule by taking the tighter of the two bounds. In addi- tion, B1 (Nq ) ≥ B1 (Nc ) and B2 (Nq ) ≥ B2 (Nc ) for all Nc ∈ Cq . Therefore, we can prune (Nq , Nr ) if dmin (Nq , Nr ) ≥ min{B1 (Par(Nq )), B2 (Par(Nq ))}. Tree-Independent Dual-Tree Algorithms Algorithm 3 k -nearest-neighbors Score() Input: query node Nq , reference node Nr a score for the node combination Output: (Nq , Nr ), or ∞ if the combination should be pruned if dmin (Nq , Nr ) < B (Nq ) then return dmin (Nq , Nr ) return ∞ These observations are combined for a better bound: B (Nq ) = min (cid:26)max (cid:8) max B (Nc )(cid:9), Dp [k ], max Nc∈Cq p∈Pq p∈Pq (cid:0)Dp [k ] + ρ(Nq ) + λ(Nq )(cid:1), min Nc∈Cq (cid:16)B (Nc ) + 2(cid:0)λ(Nq ) − λ(Nc )(cid:1)(cid:17) min B (Par(Nq ))(cid:27). As a result of this bound function being expressed re- cursively, previous bounds can be cached and used to calculate the bound B (Nq ) quickly. We can use this to structure Score() as given in Algorithm 3. Applying the meta-algorithm in Section 2 with any tree type and any pruning dual-tree traversal gives a correct implementation of k -nearest neighbor search. Proving the correctness is straightforward; first, a (non-pruning) dual-tree traversal which uses BaseCase() as given in Algorithm 2 will give correct results for any space tree. Then, we already know that B (Nq ) is a bounding function that, at any point in the traversal, will not prune any subtrees which could contain better nearest neighbor candidates than the current candidates. Thus, the true nearest neighbors for each query point will always be visited, and the results will be correct. We now show that this algorithm is a generalization of the standard kd-tree k -NN search, which uses a pruning dual-tree depth-first traversal. The archety- pal algorithm for all-nearest neighbor search (k -nearest neighbor search with k = 1) given for kd-trees in Alex Gray’s Ph.D. thesis (2003) is shown here in Algorithm 4 with converted notation. δnn is the bound for a node q Nq and is initialized to ∞; Dpq represents the nearest distance for a query point pq , and Npq represents the nearest neighbor for a query point pq . Nq .left repre- sents the left child of Nq and is defined to be Nq if Nq has no children; Nq .right is similarly defined. The structure of the algorithm matches Algorithm 1; it is a dual-tree depth-first recursion. Because this is Algorithm 4 AllNN(Nq, Nr ) (Gray, 2003) if dmin (Nq , Nr ) ≥ δnn q , then return if Nq is leaf and Nr is leaf then for each pq ∈ Pq , pr ∈ Pr do dqr ← kpq − pr k. if dqr < Dpq then Dpq = dqr ; Npq = pr if dqr < δnn then δnn q ← dqr q AllNN(Nq.left, closer-of(Nr .left, Nr .right)) AllNN(Nq.left, farther-of(Nr .left, Nr .right)) AllNN(Nq.right, closer-of(Nr .left, Nr .right)) AllNN(Nq.right, farther-of(Nr .left, Nr .right)) δnn q = min(δnn q , max(δnn q.left , δnn q.right )) a depth-first recursion, δnn q = ∞ for a node Nq if no descendants of Nq have been recursed into. Otherwise, is the maximum of Dpq for all pq ∈ D p δnn q . That q is, δnn q = B1 (Nq ). Thus, the comparison in the first line of Algorithm 4 is equivalent to Algorithm 3 with B1 (Nq ) instead of B (Nq ). The first two lines of the inside of the for each loop (the base case) are equivalent to Algorithm 2 with k = 1. kd-trees only hold points in leaves; therefore, the base case is called for all combinations of points in each node combination, identically to the depth-first traverser (Algorithm 1). A kd-tree is a space tree and the dual depth-first re- cursion is a pruning dual-tree traversal. Also, we showed the equivalency of the pruning rule (that is, the Score() function) and the equivalency of the base case. So, it is clear that Algorithm 4 is produced using our meta-algorithm with these parameters. In addi- tion, because B (Nq ) is always less than B1 (Nq ), Al- gorithm 3 provides a tighter bound than the pruning rule in Algorithm 4. This algorithm is also a generalization of the standard cover tree k -NN search (Beygelzimer et al., 2006). The cover tree search is a pruning dual-tree traver- sal where the query tree is traversed depth-first while the reference tree is simultaneously traversed breadth- first. The pruning rule (after simple adaptation to the k -nearest-neighbor search problem instead of the nearest-neighbor search problem) is equivalent to dmin (Nq , Nr ) ≥ Dpq [k ] + λ(Nq ) where pq is the point contained in Nq (remember, each node of a cover tree contains one point). This is equiva- lent to B2 (Nq ) because ρ(Nq ) = 0 for cover trees. The transformation from the algorithm given by Beygelz- imer et al. (2006) to our representation is made clear in Appendix A (supplementary material) and in the k -nearest neighbor search implementation of the C++ Tree-Independent Dual-Tree Algorithms library MLPACK (Curtin et al., 2011); this is imple- mented in terms of our meta-algorithm. Specific algorithms for ball trees, metric trees, VP trees, octrees, and other space trees are trivial to cre- ate using the BaseCase() and Score() implementa- tion given here (and in MLPACK). Note also that this implementation will work in any metric space. An extension to k -furthest neighbor search is straight- forward. The bound function must be ‘inverted’ by changing ‘max’ to ‘min’ (and vice versa); in addition, the distances Dpq [i] must be initialized to 0 instead of ∞, and the lists D and N must be sorted by descend- ing distance instead of ascending distance. Lastly, the comparison d < Dpq [k ] must be changed to d > Dpq [k ]. With these simple changes, we have solved an entirely different problem using our meta-algorithm with very little effort. A k -furthest neighbor search using our meta-algorithm for both kd-trees and cover trees is also available in MLPACK. 6. Range Search Range search is another popular neighbor searching problem related to k -nearest neighbor search. In addi- tion to being a fairly standard machine learning task, it has numerous uses in applications such as databases and geographic information systems (GIS). A treatise on the history of the problem and solutions is given by Agarwal & Erickson (1999). The problem is: Given query and reference datasets Sq , Sr and a range [δ1 , δ2 ], for each point pq ∈ Sq , find all points in Sr such that δ1 ≤ kpq − pr k ≤ δ2 . As with k -nearest neighbor search, refer to the list of neighbors for each query point pq as Npq and the corresponding distances as Dpq . These lists are not sorted in any particular order, and at initialization time, they are empty. In different settings, the problem of range search may not be stated identically; however, our results are eas- ily adaptable. A BaseCase() implementation is given in Algorithm 5, and a Score() implementation is given in Algorithm 6. The only bounds to consider are [δ1 , δ2 ], so no complex bound handling is necessary. While range search is sometimes mentioned in the con- text of dual-tree algorithms (Gray & Moore, 2001), the focus is usually on k -nearest neighbor search. As a result, we cannot find any explicitly published dual-tree algorithms to generalize; however, a single- tree algorithm was proposed by Bentley and Fried- man (1979). Thus, the BaseCase() and Score() pro- posed here can be used with our meta-algorithm to produce entirely novel range search implementations; MLPACK has kd-tree and cover tree implementations. Algorithm 5 Range search BaseCase(). Input: query point pq , reference point pr , neighbor list Npq , distance list Dpq Output: distance d between pq and pr d ← kpq − pr k if δ1 ≤ d ≤ δ2 and BaseCase(pq, pr ) not yet called then Npq ← Npq ∪ {pr } Dpq ← Dpq ∪ {d} return d Algorithm 6 Range search Score(). Input: query node Nq , reference node Nr Output: a score for (Nq , Nr ), or ∞ if the combi- nation should be pruned if δ1 ≤ dmin (Nq , Nr ) ≤ δ2 then return dmin (Nq , Nr ) return ∞ 7. Boruvka’s Algorithm Finding a Euclidean minimum spanning tree has been a relevant problem since Boruvka’s algorithm was proposed in 1926. Recently, a dual-tree version of Boruvka’s algorithm was developed (March et al., 2010) for kd-trees and cover trees. We unify these two algorithms and generalize to other types of space tree by formulating BaseCase() and Score() functions. For a dataset Sr ∈ ℜN ×D , Boruvka’s algorithm con- nects each point to its nearest neighbor, giving many ‘components’. For each component c, the nearest point in Sr to any point of c that is not part of c is found. The points are connected, combining those components. This process repeats until only one component—the minimum spanning tree—remains. During the algorithm, we maintain a list F made up of i components Fi : {Ei , Vi } where Ei is the list of edges and Vi is the list of vertices in the component Fi (these are points in Sr ). Each point in Sr belongs to only one Fi . At initialization, F = Sr and Fi = {∅, {pi}} for i = {1, . . . , Sr }, where pi is the i’th point in Sr . For p ∈ Sr we define F (p) = Fi if Fi is the component containing p. During the algorithm, we maintain N (Fi ) as the candidate nearest neighbor of component Fi and pc (Fi ) as the point in component Fi nearest to N (Fi ). Then, D(Fi ) = kpc (Fi ) − N (Fi )k. Remember that F (N (Fi )) 6= Fi . To run Boruvka’s algorithm with a space tree Tr built on the set of points Sr , a pruning dual-tree traversal is run with BaseCase() as Algorithm 7, Score() as Al- gorithm 8, Tr as both of the trees, and F as initialized Tree-Independent Dual-Tree Algorithms Algorithm 7 Boruvka’s algorithm BaseCase(). Input: query point pq , reference point pr , nearest candidate point N (F (pq )) and distance D(F (pq )) Output: distance d between pq and pr if pq = pr then return 0 if F (pq ) 6= F (pr ) and kpq − pr k < D(F (pq )) then D(F (pq )) ← kpq − pr k N (F (pq )) ← pr ; pc (F (pq )) ← pq return kpq − pr k Algorithm 8 Boruvka’s algorithm Score(). Input: query node Nq , reference node Nr the node combination a score for Output: (Nq , Nr ), or ∞ if the combination should be pruned if dmin (Nq , Nr ) < B (Nq ) then if F (pq ) = F (pr ) ∀pq ∈ D p q , pr ∈ D p r then return ∞ return dmin (Nq , Nr ) return ∞ before. Note that Score() uses B (Nq ) from Section 5 with k = 1. Upon traversal completion, we have a list N (Fi ) of nearest neighbors of each component Fi . The edge (N (Fi ), pc (Fi )) is added to Fi for each Fi . Then, any components in F with shared edges are merged into a new list F ′ where F ′ < F . The pruning dual- tree traversal is then run again with F = F ′ and the traversal-merge process repeats until F = 1. When F = 1, then F1 is the minimum spanning tree of Sr . To prove the correctness of the meta-algorithm, see Theorem 4.1 in March et al. (2010). That proof can be adapted from kd-trees to general space trees. Our representation is a generalization of their algorithms; our meta-algorithm to produces their kd-tree and cover tree implementations with a tighter distance bound B (Nq ). Our meta-algorithm produces a provably cor- rect dual-tree algorithm with any type of space tree. 8. Kernel Density Estimation Much work has been produced regarding the use of dual-tree algorithms for kernel density estimation (KDE), including by Gray & Moore (2001; 2003b) and later by Lee et al. (2006; 2008). KDE is an important machine learning problem with a vast range of applica- tions, such as signal processing to econometrics. The problem is, given query and reference sets Sq , Sr , to es- timate a probability density fq at each point pq ∈ Sq using each point pr ∈ Sr and a kernel function Kh . The exact probability density at a point pq is the sum of K (kpq − pr k) for all pr ∈ Sr . In general, the kernel function is some zero-centered probability density function, such as a Gaussian. This means that when kpq − pr k is very large, the contri- bution of K to fq is very small. Therefore, we can approximate small values using a dual-tree algorithm to avoid unnecessary computation; this is the idea set forth by Gray & Moore (2001). Because K is a func- tion which is decreasing with distance, the maximum difference between K values for a given combination (Nq , Nr ) can be bounded above with BK (Nq , Nr ) = K (dmin (Nq , Nr )) − K (dmax (Nq , Nr )). The algorithm takes a parameter ǫ; when BK (Nq , Nr ) is less than ǫ/Sr , the kernel values are approximated using the kernel value of the centroid Cr of the refer- ence node. The division by Sr ensures that the total approximation error is bounded above by ǫ. The base case on pq and pr merely needs to add K (kpq − pr k) to the existing density estimate fq . When the algorithm is initialized, fq = 0 for all query points. BaseCase() is Algorithm 10 and Score() is Algorithm 9. Again we emphasize the flexibility of our meta- algorithm. To our knowledge cover trees, octrees, and ball trees have never been used to perform KDE in this manner. Our meta-algorithm can produce these implementations with ease. 9. Discussions We have now shown five separate algorithms for which we have taken existing dual-tree algorithms and con- structed a BaseCase() and Score() function that can be used with any space tree and any dual-tree traver- sal. Single-tree extensions of these four methods are straightforward simplifications. Algorithm 9 KDE Score(Nq, Nr ). Input: query node Nq , reference node Nr Output: a score for (Nq , Nr ) or ∞ if the combina- tion should be pruned if BK (Nq , Nr ) ≥ ǫ Sr then for each pq ∈ D p q do fq ← fq + D p r K (kpq − Cr k) return ∞ return dmin (Nq , Nr ) Algorithm 10 KDE BaseCase(pq, pr ). Input: query point pq , reference point pr , density estimate fq Output: distance between pq and pr if BaseCase(pq, pr ) already called then return fq ← fq + Kh (kpq − pr k) return kpq − pr k Tree-Independent Dual-Tree Algorithms This modular way of viewing tree-based algorithms has several useful immediate applications. The first is implementation. Given a tree implementation and a dual-tree traversal implementation, all that is re- quired is BaseCase() and Score() functions. Thus, code reuse can be maximized, and new algorithms can be implemented simply by writing two new functions. More importantly, the code is now modular. MLPACK (Curtin et al., 2011), written in C++, uses templates for this. One example is the DualTreeBoruvka class, which implements the meta-algorithm discussed in Section 7, and has the following arguments: template<typename MetricType, typename TreeType, typename TraversalType> class DualTreeBoruvka; This means that any class satisfying the constraints of the TreeType template parameter can be de- signed without any consideration or knowledge of the DualTreeBoruvka class or of the TraversalType class; it is entirely independent. Then, assuming a TreeType and TraversalType without bugs, the dual- tree Boruvka’s algorithm is guaranteed to work. An immediate example of the advantage of this is that cover trees were implemented for MLPACK for use with k -nearest neighbor search. This cover tree imple- mentation could, without any additional work, be used with DualTreeBoruvka—which was never an intended goal during the cover tree implementation but still a particularly valuable result! Of course, the utility of these abstractions are not lim- ited implementation details. Each of the papers cited in the previous sections describe algorithms in terms (2010) of one specific tree structure. March et al. discuss implementations of Boruvka’s Algorithm on both kd-trees and cover trees and give algorithms for both. Each algorithm given is quite different and it is not easy to see their similarities. Using our meta- algorithm, any of these tree-based algorithms can be expressed with less effort—especially for more complex trees like the cover tree—and in a more general sense. In addition, correctness proofs for our algorithms tend to be quite simple. The proofs for each algorithm here can be given in two simple sub-proofs: (1) prove the correctness of BaseCase() when no prunes are made, and (2) prove that Score() does not prune any sub- trees which the correctness of the results depends on. The logical split of base case, pruning rule, tree type, and traversal can also be advantageous. A strong ex- ample of this is the function B (Nq ) devised in Section 5, which is a novel, tighter bound. When not consider- ing a particular tree, the path to a superior algorithm can often be simpler (as in that case). 9.1. Parallelism Nowhere in this paper has parallelism been discussed in any detail. In fact, all of the given algorithms seem to be suited to serial implementation. However, the pruning dual-tree traversal is entirely separate from the rest of the dual-tree algorithm; therefore, a par- allel pruning dual-tree traversal can be used without modifying the rest of the algorithm. For instance, consider k -nearest neighbor search. Most large-scale parallel implementations of k -NN do not use space trees but instead techniques like LSH for fast (but inexact) search. To our knowledge, no freely available software exists that implements distributed dual-tree k -nearest neighbor search. As a simple (and not necessarily efficient) proof-of- concept idea for a distributed traversal, suppose we have t2 machines and a “master” machine for some t > 0. Then, for a query tree Tq and a reference tree Tr , we can split Tq into t subtrees and one “master tree” Tqm . The reference tree Tr is split the same way. Each possible combination of query and reference subtrees is stored on one of the t2 machines, and the master trees are stored on the master machine. The lists D and N can be stored on the master machine and can be updated or queried by other machines. The traversal starts at the roots of the query tree and reference tree and proceeds serially on the mas- ter. When a combination in two subtrees is reached, Score() and BaseCase() are performed on the ma- chine containing those two subtrees and that subtree traversal continues in parallel. This idea satisfies the conditions of a pruning dual-tree traversal; thus, we can use it to make any dual-tree algorithm parallel. Recently, a distributed dual-tree algorithm was devel- oped for kernel summation (Lee et al., 2012); this work could be adapted to a generalized distributed pruning dual-tree traversal for use with our meta-algorithm. 10. Conclusion We have proposed a tree-independent representation of dual-tree algorithms and a meta-algorithm which can be used to create these algorithms. A dual-tree algorithm is represented as four parts: a space tree, a pruning dual-tree traversal, a BaseCase() function, and a Score() function. We applied this representa- tion to generalize and extend five example dual-tree algorithms to different types of trees and traversals. During this process, we also devised a novel bound for k -nearest neighbor search that is tighter than existing bounds. Importantly, this abstraction can be applied to help approach the problem of parallel dual-tree al- gorithms, which currently is not well researched. Tree-Independent Dual-Tree Algorithms References Agarwal, Panka j K, Erickson, Jeff, et al. Geomet- ric range searching and its relatives. Contemporary Mathematics, 223:1–56, 1999. Bentley, J.L. Multidimensional binary search trees used for associative searching. Communications of the ACM, 18(9):509–517, 1975. Bentley, Jon Louis and Friedman, Jerome H. Data structures for range searching. ACM Computing Surveys (CSUR), 11(4):397–409, 1979. Beygelzimer, A., Kakade, S., and Langford, J. Cover trees for nearest neighbor. In Proceedings of the 23rd International Conference on Machine Learning (ICML ’06), volume 23, pp. 97, 2006. Cover, T. and Hart, P. Nearest neighbor pattern clas- sification. Information Theory, IEEE Transactions on, 13(1):21–27, 1967. Curtin, Ryan R., Cline, James R., Slagle, Neil P., Amidon, Matthew L., and Gray, Alexander G. ML- PACK: A Scalable C++ Machine Learning Library. In BigLearning: Algorithms, Systems, and Tools for Learning at Scale, 2011. Friedman, J.H., Bentley, J.L., and Finkel, R.A. An algorithm for finding best matches in logarithmic expected time. ACM Transactions on Mathematical Software (TOMS), 3(3):209–226, 1977. Fukunaga, K. and Narendra, P.M. A branch and bound algorithm for computing k-nearest neighbors. Computers, IEEE Transactions on, 100(7):750–753, 1975. Gray, A. and Moore, A. Rapid evaluation of multiple density models. In Advances in Neural Information Processing Systems 16 (NIPS 2003), volume 2003 of NIPS ’03, 2003a. Gray, A.G. Bringing Tractability to Generalized N- Body Problems in Statistical and Scientific Com- putation. PhD thesis, Carnegie Mellon University, 2003. Holmes, Michael P., Gray, Alexander G., and Isbell Jr., Charles L. Quic-svd: Fast svd using cosine trees. Advances in Neural Information Processing Systems (NIPS), 21, 2008. Lee, Dongryeol and Gray, Alexander. Faster gaussian summation: Theory and experiment. In In Pro- ceedings of the Twenty-second Conference on Un- certainty in Artificial Intel ligence (UAI), 2006. Lee, Dongryeol and Gray, Alexander. Fast high- dimensional kernel summations using the monte carlo multipole method. Advances in Neural Infor- mation Processing Systems (NIPS), 21, 2008. Lee, Dongryeol, Gray, Alexander, and Moore, An- drew. Dual-tree fast gauss transforms. In Weiss, Y., Scholkopf, B., and Platt, J. (eds.), Advances in Neural Information Processing Systems 18, pp. 747– 754. MIT Press, Cambridge, MA, 2006. Lee, Dongryeol, Vuduc, Richard, and Gray, Alexan- der G. A distributed kernel summation framework for general-dimension machine learning. In SIAM International Conference on Data Mining, volume 2012, pp. 5, 2012. March, W.B., Connolly, A.J., and Gray, A.G. Fast al- gorithms for comprehensive n-point correlation esti- mates. In Proceedings of the 18th ACM SIGKDD in- ternational conference on Know ledge discovery and data mining, pp. 1478–1486. ACM, 2012. March, William B., Ram, Parikshit, and Gray, Alexan- der G. Fast Euclidean minimum spanning tree: al- gorithm, analysis, and applications. In Proceedings of the 16th ACM SIGKDD International Conference on Know ledge Discovery and Data Mining, KDD ’10, pp. 603–612, 2010. Ram, P., Lee, D., March, W., and Gray, A. Linear- time algorithms for pairwise statistical problems. Advances in Neural Information Processing Systems 22 (NIPS 2009), 23, 2009. Wang, P., Lee, D., Gray, A., and Rehg, J. Fast mean shift with accurate and stable convergence. In Work- shop on Artificial Intel ligence and Statistics (AIS- TATS), 2007. Gray, Alexander G. and Moore, Andrew W. ‘N-Body’ problems in Statistical Learning. In Advances in Neural Information Processing Systems 14 (NIPS 2001), volume 4, pp. 521–527. Citeseer, 2001. URL http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.28.7138. Gray, Alexander G. and Moore, Andrew W. Nonpara- metric density estimation: Toward computational tractability. In SIAM International Conference on Data Mining (SDM). Citeseer, 2003b.
1802.06212
1
1802
2018-02-17T08:46:50
Multi-Pass Streaming Algorithms for Monotone Submodular Function Maximization
[ "cs.DS" ]
We consider maximizing a monotone submodular function under a cardinality constraint or a knapsack constraint in the streaming setting. In particular, the elements arrive sequentially and at any point of time, the algorithm has access to only a small fraction of the data stored in primary memory. We propose the following streaming algorithms taking $O(\varepsilon^{-1})$ passes: ----a $(1-e^{-1}-\varepsilon)$-approximation algorithm for the cardinality-constrained problem ---- a $(0.5-\varepsilon)$-approximation algorithm for the knapsack-constrained problem. Both of our algorithms run in $O^\ast(n)$ time, using $O^\ast(K)$ space, where $n$ is the size of the ground set and $K$ is the size of the knapsack. Here the term $O^\ast$ hides a polynomial of $\log K$ and $\varepsilon^{-1}$. Our streaming algorithms can also be used as fast approximation algorithms. In particular, for the cardinality-constrained problem, our algorithm takes $O(n\varepsilon^{-1} \log (\varepsilon^{-1}\log K) )$ time, improving on the algorithm of Badanidiyuru and Vondr\'{a}k that takes $O(n \varepsilon^{-1} \log (\varepsilon^{-1} K) )$ time.
cs.DS
cs
Multi-Pass Streaming Algorithms for Monotone Submodular Function Maximization Chien-Chung Huang CNRS, École Normale Supérieure [email protected] Naonori Kakimura∗ Keio University [email protected] September 20, 2018 Abstract We consider maximizing a monotone submodular function under a cardinality constraint or a knapsack constraint in the streaming setting. In particular, the elements arrive sequentially and at any point of time, the algorithm has access to only a small fraction of the data stored in primary memory. We propose the following streaming algorithms taking O(ε−1) passes: 1. a (1 − e−1 − ε)-approximation algorithm for the cardinality-constrained problem 2. a (0.5 − ε)-approximation algorithm for the knapsack-constrained problem. Both of our algorithms run in O∗(n) time, using O∗(K) space, where n is the size of the ground set and K is the size of the knapsack. Here the term O∗ hides a polynomial of log K and ε−1. Our streaming algorithms can also be used as fast approximation algorithms. In particular, for the cardinality-constrained problem, our algorithm takes O(nε−1 log(ε−1 log K)) time, improving on the algorithm of Badanidiyuru and Vondrák that takes O(nε−1 log(ε−1K)) time. 1 Introduction A set function f : 2E → R+ on a ground set E is submodular if it satisfies the diminishing marginal return property, i.e., for any subsets S ⊆ T ( E and e ∈ E \ T , f (S ∪ {e}) − f (S) ≥ f (T ∪ {e}) − f (T ). A function is monotone if f (S) ≤ f (T ) for any S ⊆ T . Submodular functions play a fundamental role in combinatorial optimization, as they capture rank functions of matroids, edge cuts of graphs, and set coverage, just to name a few examples. Besides their theoretical interests, submodular functions have attracted much attention from the machine learning community because they can model various practical problems such as online advertising [1, 16, 26], sensor location [17], text summarization [21, 22], and maximum entropy sampling [19]. Many of the aforementioned applications can be formulated as the maximization of a monotone submodular function under a knapsack constraint. In this problem, we are given a monotone submodular function f : 2E → R+, a size function c : E → N, and an integer K ∈ N, where N denotes the set of positive integers. The problem is defined as maximize f (S) subject to c(S) ≤ K, S ⊆ E, (1) ∗Supported by JST ERATO Grant Number JPMJER1201, Japan, and by JSPS KAKENHI Grant Number JP17K00028. 1 where we denote c(S) = Pe∈S c(e) for a subset S ⊆ E. Throughout this paper, we assume that every item e ∈ E satisfies c(e) ≤ K as otherwise we can simply discard it. Note that, when c(e) = 1 for every item e ∈ E, the constraint coincides with a cardinality constraint: maximize f (S) subject to S≤ K, S ⊆ E. (2) The problem of maximizing a monotone submodular function under a knapsack or a cardinality constraint is classical and well-studied [13, 28]. The problem is known to be NP-hard but can be approximated within the factor of (close to) 1− e−1; see e.g., [3, 10, 14, 18, 27, 29]. Notice that for both problems, it is standard to assume that a function oracle is given and the complexity of the algorithms is measured based on the number of oracle calls. In this work, we study the two problems with a focus on designing space and time efficient approximation algorithms. In particular, we assume the streaming setting: each item in the ground set E arrives sequentially, and we can keep only a small number of the items in memory at any point. This setting renders most of the techniques in the literature ineffective, as they typically require random access to the data. Our contribution Our contributions are summarized as follows. Theorem 1.1 (Cardinality Constraint). Let n = E. We design streaming (1−e−1−ε)-approximation algorithms for the problem (2) requiring either 1. O (K) space, O(ε−1 log(ε−1 log K)) passes, and O(cid:0)nε−1 log(ε−1 log K)(cid:1) running time, or 2. O(cid:0)Kε−1 log K(cid:1) space, O(ε−1) passes, and O(cid:0)nε−1 log K + nε−2(cid:1) running time. Theorem 1.2 (Knapsack Constraint). Let n = E. We design streaming (0.5 − ε)-approximation algorithms for the problem (1) requiring O(cid:0)Kε−7 log2 K(cid:1) space, O(ε−1) passes, and O(cid:0)nε−8 log2 K(cid:1) running time. To put our results in a better context, we list related work in Tables 1 and 2. For the cardinality- constrained problem, our first algorithm achieves the same ratio 1 − e−1 − ε as Badanidiyuru and Vondrák [3], using the same space, while strictly improving on the running time and the number of passes. The second algorithm improves further the number of passes to O(ε−1), which is independent of K and n, but slightly loses out in the running time and the space requirement. For the knapsack-constrained problem, our algorithm gives the best ratio so far using only small space (though at the cost of using more passes than [15, 30]). In the non-streaming setting, Sviridenko [27] gave a (1− e−1)-approximation algorithm, which takes O(Kn4) time. Very recently, Ene and Nguyễn [11] gave (1−e−1−ε)-approximation algorithm, which takes O((1/ε)O(1/ε4) log n).1 Our Technique We first give an algorithm, called Simple, for the cardinality-constrained problem (2). This algorithm is later used as a subroutine for the knapsack-constrained problem (1). The basic idea of Simple is similar to those in [3, 23]: in each pass, a certain threshold is set; items whose marginal value exceeds the threshold are added into the collection; others are just ignored. In [3, 23], the threshold is decreased in a conservative way (by the factor of 1 − ε) in each pass. In contrast, we adjust the threshold dynamically, based on the f-value of the current collection. We show that, after O(ε−1) passes, we reach a (1 − e−1 − ε)-approximation. To set the threshold, we 1In [3], a (1 − e−1 ε )ε−8 ) was claimed. However, this algorithm seems to require some assumption on the curvature of the submodular function. See [11, 29] for details on this issue. − ε)-approximation algorithm of running time O(n2(ε−1 log n 2 Table 1: The cardinality-constrained problem Badanidiyuru et al. [2] Ours Ours Badanidiyuru -- Vondrak [3] Mirzasoleiman et al. [24] Greedy [14] approx. ratio 0.5 − ε 1 − e−1 − ε 1 − e−1 − ε 1 − e−1 − ε 1 − e−1 − ε 1 − e−1 (in expectation) # passes 1 space running time O(cid:0)ε−1(cid:1) O(cid:0)ε−1 log(cid:0)ε−1 log K(cid:1)(cid:1) O(K) O(cid:0)ε−1 log(ε−1K)(cid:1) O(cid:0) n O(K) O(cid:0)Kε−1 log K(cid:1) O(cid:0)nε−1 log K(cid:1) O(cid:0)Kε−1 log K(cid:1) O(cid:0)nε−1 log K + nε−2(cid:1) O(cid:0)nε−1 log(cid:0)ε−1 log K(cid:1)(cid:1) O(cid:0)nε−1 log(ε−1K)(cid:1) O(cid:0)n log ε−1(cid:1) K log ε−1(cid:1) O(K) O(nK) K K Table 2: The knapsack-constrained problem. The algorithms [11, 27] are not for the streaming setting. Yu et al. [30] Huang et al. [15] Huang et al. [15] Ours Ours Ours Ene and Nguyễn [11] Sviridenko [27] 1 1 3 approx. ratio # passes 1/3 − ε 0.363 − ε 0.4 − ε 0.39 − ε 0.46 − ε 0.5 − ε 1 − e−1 − ε -- -- 1 − e−1 O(cid:0)ε−1(cid:1) O(cid:0)ε−1(cid:1) O(cid:0)ε−1(cid:1) space running time O(cid:0)Kε−1 log K(cid:1) O(cid:0)nε−1 log K(cid:1) O(cid:0)Kε−4 log4 K(cid:1) O(cid:0)nε−4 log4 K(cid:1) O(cid:0)Kε−4 log4 K(cid:1) O(cid:0)nε−4 log4 K(cid:1) O(cid:0)Kε−2(cid:1) O(cid:0)Kε−4 log K(cid:1) O(cid:0)nε−5 log K(cid:1) O(cid:0)Kε−7 log2 K(cid:1) O(cid:0)nε−8 log2 K(cid:1) O(cid:0)nε−1 log K + nε−3(cid:1) O(cid:16)(1/ε)O(1/ε4)n log n(cid:17) O(cid:0)Kn4(cid:1) -- -- need a prior estimate of the optimal value, which we show can be found by a pre-processing step requiring either O(Kε−1 log K) space and a single pass, or O(K) space and O(ε−1 log(ε−1 log K)) passes. The implementation and analysis of the algorithm are very simple. See Section 2 for the details. For the knapsack-constrained problem (1), let us first point out the challenges in the streaming setting. The techniques achieving the best ratios in the literature are in [11, 27]. In [27], partial enumeration and density greedy are used. In the former, small sets (each of size at most 3) of items are guessed and for each guess, density greedy adds items based on the decreasing order of marginal ratio (i.e., the marginal value divided by the item size). To implement density greedy in the streaming setting, large number of passes would be required. In [11], partial enumeration is replaced by a more sophisticated multi-stage guessing strategies (where fractional items are added based on the technique of multilinear extension) and a "lazy" version of density greedy is used so as to keep down the time complexity. This version of density greedy nonetheless requires a priority queue to store the density of all items, thus requiring large space. We present algorithms, in increasing order of sophistication, in Sections 3 to 5, that give 0.39−ε, 0.46 − ε, and 0.5 − ε approximations respectively. The first simpler algorithms are useful for illustrating the main ideas and also are used as subroutines for later, more involved algorithms. The first algorithm adapts the algorithm Simple for the cardinality-constrained case. We show that Simple still performs well if all items in the optimal solution (henceforth denoted by OPT) are small in size. Therefore, by ignoring the largest optimal item o1, we can obtain a (0.39 − ε)-approximate solution (See Section 3). The difficulty arises when c(o1) is large and the function value f (o1) is too large to be ignored. To take care of such a large-size item, we first aim at finding a good item e whose size approximates that of o1, using a single pass [15]. This item e satisfies the following properties: (1) f (e) is large, 3 (2) the marginal value of OPT − o1 with respect to e is large. Then, after having this item e, we apply Simple to pack items in OPT − o1. Since the largest item size in OPT − o1 is smaller, the performance of Simple is better than just applying Simple to the original instance. The same argument can be applied for OPT − o1 − o2, where o2 is the second largest item. These solutions, together with e, yield a (0.46 − ε)-approximation (See Section 4 for the details). The above strategy would give a (0.5 − ε)-approximation if f (o1) is large enough. When f (o1) is small, we need to generalize the above ideas further. In Section 5, we propose a two-phase In Phase 1, an initial good set Y ⊆ E is chosen (instead of a single good item); in algorithm. Phase 2, pack items in some subset OPT′ ⊆ OPT using the remaining space. Ideally, the good set Y should satisfy the following properties: (1) f (Y ) is large, (2) the marginal value of OPT′ with respect to Y is large, and (3) the remaining space, K − c(Y ), is sufficiently large to pack items in OPT′. To find a such a set Y , we design two strategies, depending on the sizes, c(o1), c(o2) of the two largest items in OPT. The first case is when c(o1) + c(o2) is large. As mentioned above, we may assume that f (o1) is small. In a similar way, we can show that f (o2) is small. Then there exists a "dense" set of small items in OPT, i.e., f (OPT\{o1,o2}) c(OPT\{o1,o2}) is large. The good set Y thus can be small items approximating f (OPT \ {o1, o2}) while still leaving enough space for Phase 2. The other case is when c(o1) + c(o2) is small. In this case, we apply a modified version of Simple to obtain a good set Y . The modification allows us to lower-bound the marginal value of OPT′ with respect to Y . Furthermore, we can show that Y is already a (0.5 − ε)-approximation when c(Y ) is large. Thus we may assume that c(Y ) is small, implying that we have still enough space to pack items in OPT′ in Phase 2. Related Work Maximizing a monotone submodular function subject to various constraints is a subject that has been extensively studied in the literature. We do not attempt to give a complete survey here and just highlight the most relevant results. Besides a knapsack constraint or a car- dinality constraint mentioned above, the problem has also been studied under (multiple) matroid constraint(s), p-system constraint, multiple knapsack constraints. See [5, 7, 8, 10, 12, 18, 20] and the references therein. In the streaming setting, researchers have considered the same problem with matroid constraint [6] and knapsack constraint [15, 30], and the problem without monotonic- ity [9, 25]. For the special case of set-covering function with cardinality constraint, McGregor and Vu [23] give a (1−e−1−ε)-approximation algorithm in the streaming setting. They use a sampling technique to estimate the value of f (OPT) and then collect items based on thresholds using O(ε−1) passes. Batani et al. [4] independently proposed a streaming algorithm with a sketching technique for the same problem. Notation For a subset S ⊆ E and an element e ∈ E, we use the shorthand S + e and S − e to stand for S ∪ {e} and S \ {e}, respectively. For a function f : 2E → R, we also use the shorthand f (e) to stand for f ({e}). The marginal return of adding e ∈ E with respect to S ⊆ E is defined as f (e S) = f (S + e) − f (S). 4 2 Cardinality Constraint 2.1 Simple Algorithm with Approximated Optimal Value In this section, we introduce a procedure Simple (see Algorithm 1). This procedure can be used to give a (1− e−1 − ε)-approximation with the cardinality constraint; moreover, it will be adapted for the knapsack-constrained problem in Section 3. The input of Simple consists of 1. An instance I = (f, K, E) for the problem (2). 2. Approximated values v and W of f (OPT) and c(OPT), respectively, where OPT is an optimal solution of I. Specifically, we suppose v ≤ f (OPT) and W ≥ c(OPT). The output of Simple is a set S that satisfies f (S) ≥ βv for some constant β that will be determined later. If f (OPT) ≤ (1 + ε)v in addition, then the output turns out to be a (β − ε)-approximation. We will describe how to find such v satisfying that v ≤ f (OPT) ≤ (1 + ε)v in the next subsection. Algorithm 1 1: procedure Simple(I = (f, K, E); v, W ) ⊲ v ≤ f (OPT) and W ≥ c(OPT) S := ∅. repeat until S= K return S. 2: 3: 4: 5: 6: 7: 8: 9: . W S0 := S and α := (1−ε)v−f (S0) for each e ∈ E do T := S \ S0. if f (e S) ≥ α and S< K then S := S + e. The following observations hold for the algorithm Simple. Lemma 2.1. During the execution of Simple in each round (in Lines 3 -- 8 ), the following hold: (1) The current set S ⊆ E always satisfies f (T ′ S0) ≥ αT ′, where T ′ = S \ S0. (2) If an item e ∈ E fails the condition f (e Se) < α at Line 6, where Se is the set just before e arrives, then the final set S in the round satisfies f (e S) < α. Proof. (1) Every item e ∈ T ′ satisfies f (e Se) ≥ α, where Se is the set just before e arrives. Hence f (T S0) = Pe∈T f (e Se) ≥ αT. (2) follows from the definition of submodularity. Moreover, we can bound f (S) from below using the size of S. Lemma 2.2. In the end of each round (in Lines 3 -- 8 ), we have f (S) ≥ (cid:16)1 − e− S W − 2ε(cid:17) v. Proof. We prove the statement by induction on the number of rounds. Let S be a set in the end of some round. Furthermore, let S0 and T be corresponding two sets in the round; thus S = S0 ∪ T . By induction hypothesis, we have f (S0) ≥ (cid:16)1 − e− S0 W − 2ε(cid:17) v. 5 Note that S0 = ∅ in the first round, that also satisfies the above inequality. Due to Lemma 2.1(1), it holds that f (S) = f (S0) + f (T S0) ≥ f (S0) + αT, where α = (1−ε)v−f (S0) W . Hence it holds that f (S) ≥ f (S0)(cid:18)1 − T W (cid:19) + (1 − ε)T W − 2ε(cid:17)(cid:18)1 − T W v ≥ (cid:16)1 − e− S0 = (cid:18)1 −(cid:18)1 − T ≥ (cid:18)1 −(cid:18)1 − T W (cid:19) e− S0 W (cid:19) e− S0 W v − T W (cid:19) εv W W (cid:19) v + T W (cid:19) v −(cid:18)2 − T W (cid:19) v − 2εv, εv where the second inequality uses the induction hypothesis. Since (cid:16)1 − T W − 2ε(cid:17) v = (cid:16)1 − e− SW − 2ε(cid:17) v, f (S) ≥ (cid:16)1 − e− S0+T W (cid:17) ≤ e− T W , we have which proves the lemma. The next lemma says that the function value increases by at least εf (OPT) in each round. This implies that the algorithm terminates in O(ε−1) rounds. Lemma 2.3. Suppose that we run Simple(I; v, K) with v ≤ f (OPT) and W ≥ OPT. In the end of each round, if the final set S = S0 ∪ T (at Line 7 ) satisfies S< K, then f (S)− f (S0) ≥ εf (OPT). Proof. Suppose that the final set S0 ∪ T satisfies S0 ∪ T< K. This means that, in the last round, each item e in OPT \ (S0 ∪ T ) is discarded because the marginal return is not large, which implies that f (e S) < α by Lemma 2.1(2). As OPT \ S≤ W and α = (1−ε)v−f (S0) , we have from submodularity that W f (OPT) ≤ f (S) + Xe∈OPT\S f (e S) ≤ f (S) + αW ≤ f (S) + (1 − ε)v − f (S0). Since v ≤ f (OPT), this proves the lemma. From Lemmas 2.2 and 2.3, we have the following. Theorem 2.4. Let I = (f, K, E) be an instance of the cardinality-constrained problem (2). Suppose that v ≤ f (OPT) ≤ (1 + ε)v. Then Simple(I; v, K) can compute a (1 − e−1 − O(ε))-approximate solution in O(ε−1) passes and O(K) space. The total running time is O(ε−1n). Proof. While S< K, the f-value is increased by at least εf (OPT) in each round by Lemma 2.3. Hence, after p rounds, the current set S satisfies that f (S) ≥ pεf (OPT). Since f (S) ≤ f (OPT), the number of rounds is at most ε−1 + 1. As each round takes O(n) time, the total running time is O(ε−1n). Since we only store a set S, the space required is clearly O(K). The algorithm terminates when S= K. From Lemma 2.2 and the fact that f (OPT) ≤ (1+ε)v, we have f (S) ≥ (cid:0)1 − e−1 − 2ε(cid:1) v ≥ (cid:0)1 − e−1 − O(ε)(cid:1) f (OPT). 6 2.2 Algorithm with guessing the optimal value We first note that m ≤ f (OPT) ≤ mK, where m = maxe∈E f (e). Hence, if we prepare V = {(1 + ε)im (1+ ε)i ≤ K, i = 0, 1, . . . }, then we can guess v such that v ≤ f (OPT) ≤ (1+ ε)v. As the size of V is equal to O(ε−1 log K), if we run Simple for each element in V, we need O(Kε−1 log K) space and O(ε−1) passes in the streaming setting. This, however, will take O(nε−2 log K) running time. We remark that, using a (0.5− ε)-approximate solution X by a single-pass streaming algorithm [3], we can guess v from the range between f (X) and (2 + ε)f (X), which leads to O(Kε−1 log K) space and O(nε−1 log K + nε−2) time, taking O(ε−1) passes. This proves the second part in Theorem 1.1. Below we explain how to reduce the running time to O(ε−1n log(ε−1 log K)) by the binary search. Theorem 2.5. We can find a (1 − e−1 − ε)-approximate solution in O(ε−1 log(ε−1 log K)) passes and O(K) space, running in O(nε−1 log(ε−1 log K)) time. Proof. We here describe an algorithm using Simple with slight modification. Let p be the minimum integer that satisfies (1 + ε)p ≥ K. It follows that p = O(ε−1 log K). We set s0 = 1 and t0 = p. Suppose that m(1 + ε)si ≤ f (OPT) ≤ m(1 + ε)ti for some i ≥ 0. Set u = ⌊(si + ti)/2⌋, and take the middle v′ = m(1 + ε)u. Perform Simple(I; v′, K), but we stop the repetition in ε−1 + 1 rounds. Suppose that the output S is of size K. Then, if v′ ≥ f (OPT), we have f (S) ≥ (1 − e−1 − O(ε))v′ ≥ (1 − e−1 − O(ε))f (OPT) by Lemma 2.2. Hence we may assume that v′ ≤ f (OPT) ≤ m(1 + ε)ti. So we set si+1 = u and ti+1 = ti. Suppose that the output S is of size < K. It follows from Lemma 2.3 that, if f (OPT) ≥ v′, it holds that f (S) > pεf (OPT) after p rounds. Hence, after ε−1 + 1 rounds, we have f (S) > f (OPT), a contradiction. Thus we are sure that f (OPT) < v′. So we see that m(1 + ε)si ≤ f (OPT) ≤ v′, and we set si+1 = si and ti+1 = u. We repeat the above binary search until the interval is 1. As t0/s0 = p, the number of it- it takes erations is O(log p) = O(cid:0)log(cid:0)ε−1 log K(cid:1)(cid:1). Since each iteration takes O(ε−1) passes, O(ε−1 log(ε−1 log K)) passes in total. The running time is O(nε−1 log(ε−1 log K)). Notice that there is no need to store the solutions obtained in each iteration, rather, just the function val- ues and the corresponding indices ui are enough to find out the best solution. Therefore, just O(cid:0)K + log(cid:0)ε−1 log K(cid:1)(cid:1) = O(K) space suffices. The algorithm description is given in Algo- rithm 2. 3 Simple Algorithm for the Knapsack-Constrained Problem In the rest of the paper, let I = (f, c, K, E) be an input instance of the problem (1). Let OPT = {o1, . . . , oℓ} denote an optimal solution with c(o1) ≥ c(o2) ≥ ··· ≥ c(oℓ). We denote ci = c(oi)/K for i = 1, 2, . . . , ℓ. Similarly to Section 2, we suppose that we know in advance the approximate value v of f (OPT), i.e., v ≤ f (OPT) ≤ (1 + ε)v. The value v can be found with a single-pass streaming algorithm with constant ratio [30] in O(nε−1 log K) time and O(Kε−1 log K) space. Specifically, letting X be the output of a single-pass α-approximation algorithm, we know that the optimal value is between f (X) and f (X)/α. We can guess v by a geometric series {(1 + ε)i i ∈ Z} in this range, and then the number of guesses is O(ε−1). Thus, if we design an algorithm running in O(T1) time and O(T2) space provided the approximate value v, then the total running time is O(nε−1 log K + ε−1T1) and the space required is O(max{ε−1 log K, ε−1T2}). 7 Algorithm 2 Algorithm for the cardinality-constrained problem 1: procedure Cardinality(I = (f, K, E)) m := maxe∈E f (e), and let p be the minimum integer that satisfies (1 + ε)p ≥ K. i := 0, si := 1, and ti := p. while ti − si> 1 do ⊲ Perform Simple but stop in ε−1 + 1 rounds ui = ⌊(si + ti)/2⌋ and v′ = m(1 + ε)ui. S := ∅. for j = 1, . . . , ε−1 + 1 do S0 := S and α := (1−ε)v−f (S0) for each e ∈ E do W . if f (e S) ≥ α and S< K then S := S + e. vi := f (S). if S= K then else si+1 := u and ti+1 := ti. si+1 := si and ti+1 := u. vi+1 := f ( S) where S :=Simple(I; m(1 + ε)si, K). i∗ := arg maxi vi and return Simple(I; m(1 + ε)ui∗ , K). 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 2: 3: 4: 5: 6: 7: 8: 9: 3.1 Simple Algorithm We first claim that the algorithm Simple in Section 2 can be adapted for the knapsack-constrained problem (1) as below (Algorithm 3). At Line 6, we pick an item when the marginal return per unit weight exceeds the threshold α. We stop the repetition when f (S) − f (S0) < εv. Clearly, the algorithm terminates. Algorithm 3 1: procedure Simple(I = (f, c, K, E); v, W ) S := ∅. repeat . W S0 := S and α := (1−ε)v−f (S0) for each e ∈ E do T := S \ S0. until f (S) − f (S0) < εv return S. if f (e S) ≥ αc(e) and c(S + e) ≤ K then S := S + e. In a similar way to Lemmas 2.1 and 2.2, we have the following observations. We omit the proof. Lemma 3.1. During the execution of Simple in each round (in Lines 3 -- 8 ), the following hold: (1) The current set S ⊆ E always satisfies f (T ′ S0) ≥ αc(T ′), where T ′ = S \ S0. (2) If an item e ∈ E fails the condition f (e Se) < αc(e) at Line 6, where Se is the set just before e arrives, then the final set S in the round satisfies f (e S) < αc(e). (3) In the end of each round, we have f (S) ≥ (cid:16)1 − e− c(S) W − 2ε(cid:17) v. 8 Furthermore, similarly to the proof of Lemma 2.3, we see that the output has size more than K − c(o1). Lemma 3.2. Suppose that we run Simple(I; v, K) with v ≤ f (OPT) and W ≥ c(OPT). In the end of the algorithm, it holds that c(S) > K − c(o1). Proof. Suppose to the contrary that c(S) ≤ K − c(o1) in the end. Then, in the last round, each item e in OPT \ S is discarded because the marginal return is not large, which implies that f (e S) < αc(e) by Lemma 3.1(2). As c(OPT \ S) ≤ W and α = (1−ε)v−f (S0) , where S0 is the initial set in the last round, we have W f (OPT) ≤ f (S) + Xe∈OPT\S f (e S) ≤ f (S) + αW ≤ f (S) + (1 − ε)v − f (S0). Since v ≤ f (OPT), we obtain f (S) − f (S0) ≥ εv, which proves the lemma. Thus, we obtain the following approximation ratio, depending on size of the largest item. Lemma 3.3. Let I = (f, c, K, E) be an instance of the problem (1). Suppose that v ≤ f (OPT) ≤ O(1)v and W ≥ c(OPT). The algorithm Simple(I; v, W ) can find in O(ε−1) passes and O(K) space a set S such that K − c(o1) < c(S) ≤ K and f (S) ≥ (cid:16)1 − e− K−c(o1) W − O(ε)(cid:17) v. (3) The total running time is O(ε−1n). Proof. Let S be the final set of Simple(I; v, K). By Lemma 3.2, the final set S satisfies that c(S) > K − c(o1). Hence (3) follows from Lemma 3.2 (3). The number of passes is O(ε−1), as each round increases the f-value by εv and f (OPT) ≤ O(1)v. Hence the running time is O(ε−1n), and the space required is clearly O(K). Lemma 3.3 gives us a good ratio when c(o1) is small (see Corollary 5.1 in Section 5.1). However, the ratio worsens when c(o1) becomes larger. In the next subsection, we show that Simple can be used to obtain a (0.39 − ε)-approximation by ignoring large-size items. 3.2 0.39-Approximation: Ignoring Large Items Let us remark that Simple would work for finding a set S that approximates any subset X. More precisely, given an instance I = (f, c, K, E) of the problem (1), consider finding a feasible set to I that approximates (∗) a subset X ⊆ E such that v ≤ f (X) ≤ O(1)v and W ≥ c(X). This means that v and W are the approximated values of f (X) and c(X), respectively. Let X = {x1, . . . , xℓ} with f (x1) ≥ . . . ≥ f (xℓ). Note that X is not necessarily feasible to I, i.e., c(X) (and thus W ) may be larger than K, but we assume that c(xi) ≤ K for any i = 1, . . . , ℓ. Then Simple(I; v, W ) can find an approximation of X. Corollary 3.4. Suppose that we are given an instance I = (f, c, K, E) for the problem (1) and v, W satisfying the above condition (∗) for some subset X ⊆ E. Then Simple(I; v, W ) can find a set S in O(ε−1) passes and O(K) space such that K − c(x1) < c(S) ≤ K and W − O(ε)(cid:17) v. W − O(ε)(cid:17) v ≥ (cid:16)1 − e− K−c(x1) f (S) ≥ (cid:16)1 − e− c(S) The total running time is O(ε−1n). 9 In particular, Corollary 3.4 can be applied to approximate OPT − o1, with estimates of c(o1) and f (o1). Corollary 3.5. Suppose that we are given an instance I = (f, c, K, E) for the problem (1) such that v ≤ f (OPT) ≤ O(1)v and W ≥ c(OPT). We further suppose that we are given c1 with c1K ≤ c(o1) ≤ (1 + ε)c1K and τ with f (o1) ≤ τ v. Then we can find a set S in O(ε−1) passes and O(K) space such that K − c(o2) < c(S) ≤ K and f (S) ≥ (1 − τ )(cid:18)1 − e W−c1 − O(ε)(cid:19) v. − K−c(o2) In particular, when W = K, we have f (S) ≥ (1 − τ )(cid:0)1 − e−1 − O(ε)(cid:1) v. (4) Proof. We may assume that τ ≤ 0.5, as otherwise by taking a singleton e with maximum return f (e), we have f (e) ≥ τ v, implying that S = {e} satisfies the inequality as τ ≥ 0.5. Moreover, it holds that c(OPT − o1) ≤ W − c1K and f (OPT − o1) ≥ f (OPT) − f (o1) ≥ (1 − τ )v, and thus f (OPT − o1) ≤ v ≤ 2(1 − τ )v. Using the fact, we perform Simple(I; (1 − τ )v, W − c1K) to approximate OPT − o1. Since the largest size in OPT − o1 is c(o2), by Corollary 3.4, we can find a set S such that K − c(o2) < c(S) ≤ K and f (S) ≥ (1 − τ )(cid:18)1 − e − K−c(o2) W−c1K − O(ε)(cid:19) v. Thus the first part of the lemma holds. When W = K, the above bound is equal to f (S) ≥ (1 − τ )(cid:18)1 − e − 1−c2 1−c1 − O(ε)(cid:19) v. (5) We note that 1 − c2 1 − c1 ≥ 1 − ε. Indeed, the inequality clearly holds when c2 ≤ c1. Consider the case when c2 ≥ c1. Then, since c2 ≤ 1 − c1, we see that c1 ≤ 0.5. Hence, since c2 ≤ c1 ≤ (1 + ε)c1, we obtain 1 − c2 1 − c1 ≥ 1 − ε c1 1 − c1 ≥ 1 − ε, where the last inequality holds since c1 ≤ 0.5. Thus we have (4) from (5). The above corollary, together with Lemma 3.3, delivers a (0.39 − ε)-approximation. Corollary 3.6. Suppose that we are given an instance I = (f, c, K, E) for the problem (1) with v ≤ f (OPT) ≤ (1 + ε)v. Then we can find a (0.39 − O(ε))-approximate solution in O(ε−1) passes and O(ε−1K) space. The total running time is O(ε−2n). Proof. Fist suppose that c(o1) ≤ 0.505K. Then Lemma 3.3 with W = K implies that we can find a set S1 such that f (S1) ≥ (cid:16)1 − e− K−c(o1) K − O(ε)(cid:17) v ≥ (cid:16)1 − e−(1−0.505) − O(ε)(cid:17) v ≥ (0.39 − O(ε))v. 10 Thus we may suppose that c(o1) > 0.505K. We guess c1 with c1K ≤ c(o1) ≤ (1 + ε)c1K by a geometric series of the interval [0.505, 1.0], i.e., we find c1 such that 0.505 ≤ c1 ≤ c(o1)/K ≤ (1 + ε)c1 ≤ 1 using O(ε−1) space. We may also suppose that f (o1) < 0.39v, as otherwise we can just take a singleton with maximum return from E. By Corollary 3.5 with W = K and τ = 0.39, we can find a set S2 such that f (S2) ≥ 0.61(cid:18)1 − e − 1−c2 1−c1 − O(ε)(cid:19) v. Since c2 ≤ 1 − c1 ≤ 0.495, we have Therefore, it holds that 1 − c2 1 − c1 ≥ 1 − 0.495 1 − 0.505 ≥ 1.02. This completes the proof. f (S2) ≥ 0.61(cid:0)1 − e−1.02 − O(ε)(cid:1) ≥ (0.39 − O(ε))v. 4 0.46-Approximation Algorithm In this section, we present a (0.46 − ε)-approximation algorithm for the knapsack-constrained problem. In our algorithm, we assume that we know in advance approximations of c1 and c2. That is, we are given ci, ci such that ci ≤ ci ≤ ci and ci ≤ (1 + ε)ci for i ∈ {1, 2}. Define Ei = {e ∈ E c(e) ∈ [ci, ci]} for i ∈ {1, 2}. We call items in E1 large items, and items in E \ (E1 ∪ E2) are small. Notice that we often distinguish the cases c1 ≤ 0.5 and c1 ≥ 0.5. In the former case, we assume that c1 ≤ 0.5 while in the latter, c1 ≥ 0.5. We first show that we may assume that c1 + c2 ≤ 1 − ε. This means that we may assume that c1 + c2 ≤ 1. See Appendix for the proof. Lemma 4.1. Suppose that we are given v such that v ≤ f (OPT) ≤ (1 + ε)v. If c1 + c2 ≤ 1 − ε, we can find a (0.5 − O(ε))-approximate solution in O(ε−1K) space using O(ε−1) passes. The total running time is O(nε−1). maximize g(S) The main idea of our algorithm is to choose an item e ∈ E1 such that both f (OPT − o1 e) and f (OPT− o1 − o2 e) are large. After having this item e, we define g(·) = f (· e), and consider the problem: (6) We then try to find feasible sets to (6) that approximate OPT − o1 and OPT − o1 − o2. These solutions, together with the item e, will give us well-approximate solutions for the original instance. More precisely, we have the following observation. Observation 1. Let e ∈ E be an item. Define g(·) = f (· e). If g(OPT − o1) ≥ p1v and S1 is a feasible set to the problem (6) such that g(S1) ≥ κ1p1v, then it holds that c({e} ∪ S1) ≤ K and subject to c(S) ≤ K − c(e), S ⊆ E. f ({e} ∪ S1) ≥ f (e) + κ1p1v. Similarly, if g(OPT − o1 − o2) ≥ p2v and S2 is a feasible set to the problem (6) such that g(S2) ≥ κ2p2v, then it holds that c({e} ∪ S2) ≤ K and f ({e} ∪ S2) ≥ f (e) + κ2p2v. 11 To make the RHSs in Observation 1 large, we aim to find an item e from E1 such that f (e) ≈ f (o1) and p1, p2 are large simultaneously. We propose two algorithms for finding such e in Section 4.1. We then apply Simple to approximate OPT− o1 and OPT− o1− o2 for (6), respec- tively. Since the largest item sizes in OPT − o1 and OPT − o1 − o2 are smaller, the performances κ1 and κ2 of Simple are better than just applying Simple to the original instance. Therefore, the total approximation ratio becomes at least 0.46. The following subsections give the details. 4.1 Finding a Good Item One of the important observation is the following, which is useful for analysis when c1 ≤ 0.5. Lemma 4.2. Let e0 ∈ E. Suppose that f (OPT) ≥ v. If f (e0 + o1) < βv, then we have Moreover, if f (e0 + o2) < βv in addition, then we obtain f (OPT − o1 e0) ≥ (1 − β)v. f (OPT − o1 − o2 e0) ≥ (1 − 2β + f (e0))v. Proof. By assumption, it holds that βv > f (e0 + o1) = f (e0) + f (o1 e0), implying f (OPT − o1 e0) ≥ f (OPT e0) − f (o1 e0) ≥ (f (OPT) − f (e0)) − (βv − f (e0)) ≥ (1 − β)v. Moreover, if f (e0 + o2) < βv in addition, then we have βv > f (e0 + o2) = f (e0) + f (o2 e0), implying f (OPT − o1 − o2 e0) ≥ f (OPT − o1 e0) − f (o2 e0) ≥ (1 − β)v − (βv − f (e0)). Thus the statement holds. When c1 ≤ c1 ≤ 0.5, for any item e0 ∈ E1, we see that e0 + o1 is a feasible set. Hence, by checking whether f (e0 + e′) ≥ βv for some e′ ∈ E using a single pass, it holds that, either we have a feasible set e0 +e′ such that f (e0 +e′) ≥ βv, or we bound f (OPT−o1 e0) and f (OPT−o1−o2 e0) from below by the above lemma. Another way to lower-bound p1 and p2 in Observation 1 is to use the algorithm in [15]. It is difficult to correctly identify o1 among the items in E1, but we can nonetheless find a reasonable approximation of it by a single pass [15]. For the sake of convenience, we define a procedure PickNiceItem. This procedure PickNiceItem takes an estimate v of f (OPT) along with the estimate of the size of o1 and of its f-value. It then returns an item of similar size, which, together with OPT − o1, guarantees (2/3 − O(ε))v. More precisely, we have the following proposition. Theorem 4.3 ([15]). Let X ⊆ E such that f (X) ≥ v. Furthermore, assume that there exists x1 ∈ X such that cK ≤ c(x1) ≤ cK and τ v/(1 + ε) ≤ f (x1) ≤ τ v. Then PickNiceItem(v, (c, c), τ), a single-pass streaming algorithm using O(1) space, returns a set Y of O(1) items such that some item e∗ in Y satisfies where 3 6 − t 10 − t 9 2 f (X − x1 + e∗) ≥ Γ(f (x1))v − O(ε)v, Γ(t) =   t ≥ 0.5 0.5 ≥ t ≥ 0.4 0.4 ≥ t ≥ 0. if if if 2 3 5 12 Moreover, for any item e ∈ Y , we have τ v/(1 + ε) ≤ f (e) ≤ τ v and cK ≤ c(e) ≤ cK. Using the procedure PickNiceItem, we can find a good item e. Lemma 4.4. Let Y :=PickNiceItem(v, (c1, c1), τ), where f (OPT) ≥ v and τ v/(1 + ε) ≤ f (o1) ≤ τ v. Then there exists e ∈ Y such that τ v/(1 + ε) ≤ f (e) ≤ τ v and Moreover, if f (e + o2) < βv in addition, then f (OPT − o1 e) ≥ (Γ(τ ) − τ )v − O(ε)v. f (OPT − o1 − o2 e) ≥ (Γ(τ ) − β)v − O(ε)v. Proof. It follows from Theorem 4.3 that some e ∈ Y satisfies that f (OPT − o1 + e) ≥ Γ(f (o1))v − O(ε)v ≥ Γ(τ )v − O(ε)v and f (e) ≤ τ v, and hence f (OPT − o1 e) = f (OPT − o1 + e) − f (e) ≥ (Γ(τ ) − τ )v − O(ε)v. Moreover, if f (e + o2) < βv in addition, then we have βv > f (e + o2) = f (e) + f (o2 e) ≥ τ 1 + ε v + f (o2 e) ≥ τ v + f (o2 e) − O(ε)v, implying f (OPT − o1 − o2 e) ≥ f (OPT − o1 e) − f (o2 e) ≥ (Γ(τ ) − τ )v − (β − τ )v − O(ε)v. Thus the statement holds. 4.2 Algorithm: Taking a Good Large Item First Suppose that we have e ∈ E1 such that f (OPT − o1 e) ≥ p1v and f (OPT − o1 − o2 e) ≥ p2v, knowing that such e can be found by Lemma 4.2 or 4.4. More precisely, when c1 ≥ 0.5, we first find a set T by PickNiceItem(v, (c1, c1), τ), where τ v/(1 + ε) ≤ f (o1) ≤ τ v; when c1 ≤ 0.5, set T = {e} for arbitrary e ∈ E1. Then T= O(1) and some e ∈ T satisfies f (OPT − o1 e) ≥ p1v and f (OPT − o1 − o2 e) ≥ p2v, where p1 and p2 are determined by Lemma 4.2 or 4.4. Then, for each item e ∈ T , consider the problem (6), and let I ′ be the corresponding instance. We apply Simple to the instance I ′ approximating OPT − o1 and OPT − o1 − o2, respectively. It follows that Here we set vℓ = pℓv (ℓ = 1, 2), W1 = W − c1K, and W2 = W − c1K − c2K. ℓ = e+ Simple(I ′; pℓv, Wℓ) for ℓ = 1, 2. c(OPT − o1) ≤ W1 and c(OPT − o1 − o2) ≤ W2. Define Se Also define Se 0 = e + e∗, where e∗ = arg maxe′∈E:c(e′)≤K−c(e) f (e + e′). Moreover, for ℓ = 0, 1, 2, define Sℓ to be the set that achieves max{f (Se 8 in parallel using the same O(ε−1) passes. Since T= O(1), it takes O(K) spaces. The algorithm, called LargeFirst, can be summarized as in Algorithm 4. We can perform Lines 3 -- The following bounds follow from Corollary 3.4 and Observation 1. ℓ ) e ∈ T}. Lemma 4.5. Suppose that v ≤ f (OPT) ≤ (1 + ε)v and c(OPT) ≤ W . We further suppose that cℓ ≤ cℓ ≤ cℓ ≤ (1 + ε)cℓ (ℓ = 1, 2) and τ 1+ε v ≤ f (o1) ≤ τ v. Let e ∈ E1 be an item such that f (OPT− o1 e) ≥ p1v and f (OPT− o1− o2 e) ≥ p2v. Then, if c1 + c2 ≤ 1− ε/δ for some constant δ, it holds that f ( S1) ≥ (cid:18)τ + p1(cid:18)1 − e f ( S2) ≥ (cid:18)τ + p2(cid:18)1 − e − K−c1K−c2K W−c1K (cid:19) − O(ε)(cid:19) v, W−c1K−c2K(cid:19) − O(ε)(cid:19) v. − K−c1K−c3K (7) (8) 13 Algorithm 4 1: procedure LargeFirst(I; v, W, τ) ⊲ τ v/(1 + ε) ≤ f (o1) ≤ τ v If c1 ≥ 0.5, compute T :=PickNiceItem(v, (c1, c1), τ), and if c1 ≤ 0.5, set T := {e} for for each item e ∈ T do arbitrary e ∈ E1. 2: 3: 4: 5: 6: 7: 8: 9: 10: 0 := e + e∗, where e∗ := arg maxe′∈E:c(e′)≤K−c(e) f (e + e′). Se Define I ′ := (g, c, K − c(e), E), where g(·) := f (· e). Set pℓ (ℓ = 1, 2) as in Lemma 4.2 for c1 ≤ 0.5 and Lemma 4.4 for c1 ≥ 0.5. W1 := W − c1K and W2 := W − c1K − c2K. Compute Se ℓ := e+ Simple(I ′; pℓv, Wℓ) for ℓ = 1, 2. Denote by Sℓ the set that achieves max{f (Se return a set S that achieves max{f ( Sℓ) ℓ ∈ {0, 1, 2}}. ℓ ) e ∈ T} for ℓ ∈ {0, 1, 2}. In particular, if W = K and c1 + c2 ≤ 1 − ε/δ for some constant δ, it holds that f ( S1) ≥ (cid:16)τ + p1(cid:16)1 − e−(1−δ)µ(cid:17) − O(ε)(cid:17) v, f ( S2) ≥ (cid:18)τ + p2(cid:18)1 − e µ −1(cid:17)(cid:19) − O(ε)(cid:19) v, , −(cid:16) 1−δ (9) (10) . 1−c1 where µ = 1−c1−c2 Proof. We note that c(OPT − o1) ≤ W1 = W − c1K, and items in OPT − o1 are of size at most c(o2). By Corollary 3.4, Simpe(I ′; p1v, W1) can find a set S such that W−c1K − O(ε)(cid:19) v g(S) ≥ p1(cid:18)1 − e − K−c1K−c2K as the capacity K − c(e) ≥ K − c1K. Therefore, since f (e) ≥ (τ − O(ε))v, the inequality (7) follows from Observation 1. The inequality (8) holds in a similar way, noting that c(OPT − o1 − o2) ≤ W − c1K − c2K, and items in OPT − o1 − o2 are of size at most c(o3). Suppose that W = K. Then the above inequalities (7) and (8) can be transformed to f ( S1) ≥ (cid:18)τ + p1(cid:18)1 − e f ( S2) ≥ (cid:18)τ + p2(cid:18)1 − e − 1−c1−c2 1−c1 (cid:19) − O(ε)(cid:19) v, 1−c1−c2(cid:19) − O(ε)(cid:19) v. − 1−c1−c3 (11) (12) Since cℓ ≤ (1 + ε)cℓ for ℓ = 1, 2, we have λ1 := λ2 := c1 1 − c1 1 − c1 ≥ 1 − ε 1 − c1 − c2 1 − c1 − c2 ≥ 1 − ε 1 − c1 ≥ 1 − δ + ε, c1 + c2 and 1 − c1 − c2 ≥ 1 − δ + ε, where the second inequalities of each follow because c1 ≤ c1 + c2 ≤ 1− ε/δ. Using λ1, the exponent in (11) is equal to 1 − c1 − c2 1 − c1 = λ1 1 − c1 − c2 1 − c1 ≥ (1 − δ) µ. 14 Thus (9) holds. Moreover, since c3 ≤ 1 − c1 − c2, using λ2, the exponent in (12) is equal to 1 − c1 − c3 1 − c1 − c2 ≥ 1 − c1 1 − c1 − c2 − 1 = λ2 1 − c1 1 − c1 − c2 − 1 ≥ (1 − δ) 1 − c1 1 − c1 − c2 − 1. Thus (10) holds. 4.3 Analysis: 0.46-Approximation We next analyze the approximation ratio of the algorithm. We consider two cases when c1 ≤ 0.5 and c1 ≥ 0.5 separately; we will show that LargeFirst, together with Simple, admits a (0.46 − ε)- approximation when c1 ≤ 0.5 and a (0.49 − ε)-approximation when c1 ≥ 0.5, respectively. Lemma 4.6. Suppose that c1 ≤ 0.5 and c1 + c2 ≤ 1 − ε/δ, where δ = 0.01. We further suppose that cℓ ≤ cℓ ≤ cℓ ≤ (1 + ε)cℓ (ℓ = 1, 2), c1 ≤ 0.5, and v ≤ f (OPT) ≤ (1 + ε)v. Then Algorithm LargeFirst, together with Simple, can find a (0.46 − O(ε))-approximate solution in O(ε−1) passes and O(ε−1K) space. The total running time is O(ε−2n). Proof. First suppose that f (o1) ≤ 0.272v. Then, by Corollary 3.5, we can find a set S such that f (S) ≥ 0.728(cid:0)1 − e−1 − O(ε)(cid:1) v ≥ (0.46 − O(ε))v. Thus we may suppose that f (o1) ≥ 0.272v. We may also suppose that f (o1) ≤ 0.46v, as otherwise taking a singleton with maximum return from E1 gives a 0.46-approximation. We guess τ and τ with 0.272v ≤ τ v ≤ f (o1) ≤ τ v ≤ 0.46v and τ ≤ (1 + ε)τ from the interval [0.272, 0.46] by a geometric series using O(ε−1) space. By Lemmas 4.2 and 4.5, the output of LargeFirst(I; v, K, τ ) is lower-bounded by the RHSs of (13) (14) the following three inequalities: f ( S0) ≥ βv, f ( S1) ≥ (cid:16)τ + (1 − β)(cid:16)1 − e−(1−δ)µ(cid:17) − O(ε)(cid:17) v, f ( S2) ≥ (cid:18)τ + (1 − 2β + τ )(cid:18)1 − e . We may assume that β < 0.46. If µ ≥ 0.5, then (13) implies that 2 (cid:17) − O(ε)(cid:17) v ≥ (0.46 − O(ε))v, f ( S1) ≥ (cid:16)0.272 + (1 − 0.46)(cid:16)1 − e− 1−δ where µ = 1−c1−c2 −(cid:16) 1−δ µ −1(cid:17)(cid:19) − O(ε)(cid:19) v, 1−c1 when δ = 0.01. On the other hand, if µ ≤ 0.5, then (14) implies that f ( S2) ≥ (cid:16)0.272 + (1 − 2 · 0.46 + 0.272)(cid:16)1 − e−( 1−δ 0.5 −1)(cid:17) − O(ε)(cid:17) v ≥ (0.46 − O(ε))v, when δ = 0.01. Thus the statement holds. Similarly, we have the following guarantee when c1 ≥ 0.5. Lemma 4.7. Suppose that c1 ≥ 0.5 and c1 + c2 ≤ 1 − ε/δ, where δ = 0.01. We further suppose that cℓ ≤ cℓ ≤ cℓ ≤ (1 + ε)cℓ (ℓ = 1, 2), c1 ≥ 0.5, and v ≤ f (OPT) ≤ (1 + ε)v. Then Algorithm LargeFirst, together with Simple, can find a (0.49 − O(ε))-approximate solution in O(ε−1) passes and O(ε−1K) space. The total running time is O(ε−2n). 15 Proof. First suppose that f (o1) ≤ 0.224v. Then, by Corollary 3.5, we can find a set S such that f (S) ≥ 0.776(cid:0)1 − e−1 − O(ε)(cid:1) v ≥ (0.49 − O(ε))v. Thus we may suppose that f (o1) ≥ 0.224v. We may also suppose that f (o1) ≤ 0.49v, as otherwise taking a singleton with maximum return from E1 gives a 0.49-approximation. We guess τ and τ with 0.224v ≤ τ v ≤ f (o1) ≤ τ v ≤ 0.49v and τ ≤ (1 + ε)τ from the interval [0.224, 0.49] by a geometric series using O(ε−1) space. Let µ = 1−c1−c2 1−c1 . By Corollary 3.5, we can find a set S such that f ( S) ≥ (1 − τ )(cid:18)1 − e − 1−c2 1−c1 − O(ε)(cid:19) v ≥ (1 − τ )(cid:16)1 − e−(1−δ)µ−1 − O(ε)(cid:17) v. (15) Here we note that 1 − c2 1 − c1 = 1 − c1 (cid:18) 1 − c1 − c2 1 − c1 1 − c1 (cid:19) + c1 1 − c1 ≥ (1 − δ) µ + 1, c1 since 1−c1 ≥ 1 when c1 ≥ c1 ≥ 0.5. Moreover, there exists e′ ∈ T such that f (OPT − o1 e′) and f (OPT − o1 − o2 e′) are bounded as in Lemma lem:good_e_2. By Lemma 4.5, the output of LargeFirst(I; v, K, τ ) is lower-bounded by the RHSs of the following three inequalities: f ( S0) ≥ βv, f ( S1) ≥ (cid:16)τ + (Γ(τ ) − τ )(cid:16)1 − e−(1−δ)µ(cid:17) − O(ε)(cid:17) v, f ( S2) ≥ (cid:18)τ + (Γ(τ ) − β)(cid:18)1 − e µ −1(cid:17)(cid:19) − O(ε)(cid:19) v. −(cid:16) 1−δ (16) (17) We may assume that β < 0.49. The above inequalities (15) -- (17) imply that one of S, Sℓ (ℓ = 0, 1, 2) admits a (0.49 − O(ε))-approximation. τ ≤ 0.3562, then (15) implies that More specifically, we can obtain the ratio as follows. First suppose that µ ≥ 0.505. Then, if f ( S) ≥ (1 − 0.3562)(cid:16)1 − e−((1−δ)0.505+1) − O(ε)(cid:17) v ≥ (0.50 − O(ε))v. If 0.4 ≥ τ ≥ 0.3562, then (16) implies that 3 · 0.3562 f ( S1) ≥ (cid:18)0.3562 +(cid:18) 9 10 − If τ ≥ 0.4, then (16) implies that 2 (cid:19)(cid:16)1 − e−(1−δ)0.505(cid:17) − O(ε)(cid:19) v ≥ (0.50 − O(ε))v. f ( S1) ≥ (cid:18)0.4 +(cid:18)5 6 − 3 (cid:19)(cid:16)1 − e−(1−δ)0.505(cid:17) − O(ε)(cid:19) v ≥ (0.51 − O(ε))v. 4 · 0.4 Thus we obtain a (0.5 − O(ε))-approximation when µ ≥ 0.505 using (15) and (16). follows from (15) that Next suppose that µ < 0.505. First consider the case when τ ≤ 0.22. Then, since µ ≥ 0, it f ( S) ≥ (1 − 0.22)(cid:0)1 − e−1 − O(ε)(cid:1) v ≥ (0.49 − O(ε))v, 16 Next assume that τ ≥ 0.22 and µ ≥ 3.5 (τ − 0.22). Since µ < 0.505, we have τ ≤ 0.365. Hence (15) implies that f ( S) ≥ (1 − τ )(cid:16)1 − e−((1−δ)3.5(τ −0.22)+1) − O(ε)(cid:17) v ≥ (0.50 − O(ε))v. Otherwise, that is, if µ ≥ 3.5 (τ − 0.22), then (17) implies that f ( S2) ≥ (cid:18)2 7 µ + 0.22 +(cid:18) 5 6 − ≥ (0.49 − O(ε))v, 1 3 (cid:18) 2 7 µ + 0.22(cid:19) − 0.49(cid:19)(cid:18)1 − e −(cid:16) 1−δ µ −1(cid:17)(cid:19) − O(ε)(cid:19) v when µ < 0.505. Thus the statement holds. We remark that the proof of Lemmas 4.6 works when K ≥ W , and that of Lemma 4.7 works when K ≥ W and c1 ≥ c1 ≥ 0.5W . In summary, we have the following theorem. Theorem 4.8. Suppose that we are given an instance I = (f, c, K, E) for the problem (1). Then we can find a (0.46− ε)-approximate solution in O(ε−1) passes and O(Kε−4 log K) space. The total running time is O(nε−5 log K). Proof. As mentioned in the beginning of Section 3, if we design an algorithm running in O(T1) time and O(T2) space provided the approximate value v, then the total running time is O(nε−1 log K + ε−1T1) and the space required is O(max{ε−1 log K, ε−1T2}). Thus suppose that we are given v such that v ≤ f (OPT) ≤ (1 + ε)v. By Lemma 4.1, we may assume that c1 + c2 ≤ 1 − ε/δ where δ = 0.01. We may assume that c1 ≥ 0.383, as otherwise Lemma 3.3 implies that Simple(I; v, K) yields a (0.46 − ε)-approximation. For i ∈ {1, 2}, we guess ci, ci such that ci ≤ ci ≤ ci and ci ≤ (1 + ε)ci by a geometric series. This takes O(ε−2 log K) space, since the range of c1 is [0.383, 0.46] and that of c2 is [1/K, 1]. When c1 ≤ 0.5, it follows from Lemma 4.6 that we can find a (0.46 − ε)-approximate solution in O(ε−1) passes and O(ε−1K) space. When c1 ≥ 0.5, it follows from Lemma 4.7 that we can find a (0.49 − ε)-approximate solution in O(ε−1) passes and O(ε−1K) space. Hence, for each ci, ci, it takes O(ε−1) passes and O(ε−1K) space, running in O(nε−2) time in total. Thus, for a fixed v, the space required is O(Kε−3 log K), and the running time is O(nε−4 log K). Therefore, the algorithm in total uses O(ε−1) passes and O(Kε−4 log K) space, running in O(nε−5 log K) time. Thus the statement holds. 5 Improved 0.5-Approximation Algorithm In this section, we further improve the approximation ratio to 0.5. Recall that we are given v with v ≤ f (OPT) ≤ (1 + ε)v taking O(ε−1) space. 5.1 Overview We first remark that algorithms so far give us a (0.5 − ε)-approximation for some special cases. In fact, Lemma 3.3 and Corollary 3.5 lead to a (0.5 − ε)-approximation when c(o1) ≤ 0.3K or f (o1) ≤ 0.15v. Corollary 5.1. If c(o1) ≤ 0.3K or f (o1) ≤ 0.15v, then we can find a set S in O(ε−1) passes and O(K) space such that c(S) ≤ K and f (S) ≥ (0.5 − O(ε))v. 17 Proof. First suppose that c(o1) ≤ 0.3K. By Lemma 3.3, the output S of Simple(I; v, K) satisfies that f (S) ≥ (cid:16)1 − e− K−c(o1) K − O(ε)(cid:17) v ≥ (cid:0)1 − e−0.7 − O(ε)(cid:1) v ≥ (0.5 − O(ε))v. Next suppose that f (o1) ≤ 0.15v. We see that f (OPT − o1) ≥ f (OPT) − f (o1) ≥ 0.85v. By Corollary 3.5, we can find a set S such that K − c(o2) < c(S) ≤ K and f (S) ≥ 0.85(cid:0)1 − e−1 − O(ε)(cid:1) v ≥ (0.5 − O(ε))v. Moreover, the following corollary asserts that we may suppose that f (o1) and f (o2) are small. Corollary 5.2. In the following cases, LargeFirst, together with Simple, can find a (0.5 − ε)- approximate solution in O(ε−1) passes and O(Kε−4 log K) space: 1. when c1 ≥ 0.5 and f (o1) ≥ 0.362v. 2. when c1 ≤ 0.5 and f (o1) ≥ 0.307v. 3. when f (o2) ≥ 0.307v. Proof. (1) Suppose that c1 ≥ 0.5 and f (o1) ≥ 0.362v. We may also suppose that f (o1) < 0.5v, as otherwise we can just take a singleton with maximum return from E. We guess τ and τ such that 0.362v ≤ τ v ≤ f (OPT) ≤ τ v ≤ 0.5v and τ ≤ (1 + ε)τ from the interval [0.362, 0.5] by a geometric series using O(ε−1) space. Consider applying LargeFirst(I; v, K, τ ) for each τ. By Lemmas 4.4 and 4.5, the output of LargeFirst(I; v, K, τ ) is lower-bounded by the RHSs of the inequalities (16) and (17), where we may assume that β < 0.5. First suppose that µ = 1−c1−c2 f ( S1) ≥ (cid:18)0.4 +(cid:18)5 6 − 1−c1 ≥ 0.495. Then (16) implies that, if τ ≥ 0.4, we obtain 3 · 0.4(cid:19)(cid:16)1 − e−(1−δ)0.495(cid:17) − O(ε)(cid:19) v ≥ (0.51 − O(ε))v, 4 and if τ < 0.4, then f ( S1) ≥ (cid:18)0.362 +(cid:18) 9 10 − 3 2 · 0.362(cid:19)(cid:16)1 − e−(1−δ)0.495(cid:17) − O(ε)(cid:19) v ≥ (0.50 − O(ε))v. Otherwise, suppose that µ < 0.495. Then (17) implies that, if τ ≥ 0.4, we have f ( S2) ≥ (cid:18)0.4 +(cid:18) 5 6 − and if τ < 0.4, then f ( S2) ≥ (cid:18)0.362 +(cid:18) 9 10 − Thus the statement holds. 1 3 · 0.4 − 0.5(cid:19)(cid:16)1 − e−( 1−δ 0.495 −1)(cid:17) − O(ε)(cid:19) v ≥ (0.52 − O(ε))v. 1 2 · 0.362 − 0.5(cid:19)(cid:16)1 − e−( 1−δ 0.495 −1)(cid:17) − O(ε)(cid:19) v ≥ (0.50 − O(ε))v. (2) The argument is similar to (1). Suppose that c1 ≤ 0.5 and f (o1) ≥ 0.307v. We guess τ and τ such that 0.307v ≤ τ v ≤ f (OPT) ≤ τ v ≤ 0.50v and τ ≤ (1 + ε)τ from the interval [0.307, 0.5] by a geometric series using O(ε−1) space. Consider applying LargeFirst(I; v, K, τ ) for each τ. By 18 Lemmas 4.2 and 4.5, the output of LargeFirst(I; v, K, τ ) is lower-bounded by the RHSs of (13) and (14), where we may assume that β < 0.5. First suppose that µ = 1−c1−c2 1−c1 ≥ 0.495. Then (13) implies that f ( S1) ≥ (cid:16)0.307 + (1 − 0.5)(cid:16)1 − e−(1−δ)0.495(cid:17) − O(ε)(cid:17) v ≥ (0.50 − O(ε))v. Otherwise, if µ ≤ 0.495, then (14) implies that f ( S2) ≥ (cid:16)0.307 + (1 − 2 · 0.5 + 0.307)(cid:16)1 − e−( 1−δ 0.495 −1)(cid:17) − O(ε)(cid:17) v ≥ (0.50 − O(ε))v. Thus the statement holds. (3) This case can be shown by applying LargeFirst to E2. More precisely, we replace c1 with c2 in LargeFirst with τ v ≥ f (o2) ≥ τ v/(1 + ε). We also set W1 = W − c2K instead of W − c1K. Then, since (c1 + c2)K ≤ K, we can use the same analysis as in the proof of Lemma 4.6; the output of LargeFirst(I; v, W, τ) is lower-bounded by the RHSs of the following three inequalities: f ( S0) ≥ βv, f ( S1) ≥ (cid:16)τ + (1 − β)(cid:16)1 − e−(1−δ)µ′(cid:17) − O(ε)(cid:17) v, f ( S2) ≥ (cid:18)τ + (1 − 2β + τ )(cid:18)1 − e −(cid:16) 1−δ µ′ −1(cid:17)(cid:19) − O(ε)(cid:19) v, where µ′ = 1−c1−c2 and (14) in the proof (2), the statement holds. 1−c2 . We may assume that β < 0.5. Since the lower bounds are the same as (13) Recall that, in Section 4, we found an item e such that Observation 1 can be applied, that is, f (OPT− o1 e) and f (OPT− o1− o2 e) are large. In this section, we aim to find a good set Y ⊆ E such that f (OPT′ Y ) is large for some OPT′ ⊆ OPT, using O(ε−1) passes, while guaranteeing that the remaining space K − c(Y ) is sufficiently large. We then solve the problem of maximizing the function f (· Y ) to approximate OPT′ with algorithms in previous sections. Specifically, we devise two strategies depending on the size of c1 + c2 (see Sections 5.2 and 5.3 for more specific values of c1 and c2). First Strategy: Packing small items first First consider the case when c1 + c2 is large. Recall that f (o1) and f (o2) are supposed to be small by Corollary 5.2. Hence, there is a "dense" set OPT− o1 − o2 of small items, i.e., f (OPT\{o1,o2}) c(OPT\{o1,o2}) is large. Therefore, we consider collecting such small items. However, if we apply Simple to the original instance (1) to approximate OPT− o1− o2, then we can only find a set whose function value is at most f (OPT − o1 − o2). The main idea of this case is to stop collecting small items early. That is, we introduce maximize f (S) subject to c(S) ≤ K1, S ⊆ E, (18) where K1 ≤ K − c(o1), and apply Simple to this instance to approximate OPT− o1 − o2. Let Y be the output. The key observation is that, in Phase 2, since we still have space to take o1, we may assume that f (OPT − o1 Y ) ≥ 0.5v in a way similar to Lemma 4.2. Given such a set Y , define g(·) = f (· Y ) and the problem: maximize g(S) subject to c(S) ≤ K − c(Y ), S ⊆ E. (19) 19 We apply approximation algorithms in Sections 3 -- 4 to approximate OPT − o1, using the fact that g(OPT − o1) ≥ 0.5v and c(OPT − o1) ≤ (1 − c1)K. Let S be the output of this phase. Then Y ∪ S is a feasible set to the original instance, and it holds that f (Y ∪ S) = f (Y ) + g( S). We remark that the lower bound for f (Y ) depends on the size c(Y ) by Corollary 3.4, and that for g( S) depends on the knapsack capacity K − c(Y ). Hence the lower bound for f (Y ∪ S) can be represented as a function with respect to c(Y ). By balancing the two lower bounds with suitable K1, we can obtain a (0.5 − O(ε))-approximation. See Sections 5.2.1 and 5.2.2 for more details. Second Strategy: Packing small items later Suppose that c1 + c2 is small. Then c(OPT \ {o1, o2}) is large and we do not have the dense set of small items as before. For this case, we introduce a modified version of Simple for the original problem (1) to find a good set Y . The difference is that, in each round, we check whether any item in E, by itself, is enough to give us a solution with 0.5v. Such a modification would allow us to lower bound f (OPT′Y ) for some OPT′ ⊆ OPT for Phase 2. We may assume that c(Y ) < 0.7K, as otherwise we are done by Lemma 3.1, which means that we still have enough space to pack other items. That is, define g(·) = f (· Y ) and the problem: maximize g(S) subject to c(S) ≤ K − c(Y ), S ⊆ E. (20) Let OPT′ = {e ∈ OPT c(e) ≤ K − c(Y )}. We aim to find a feasible set to this problem that approximates OPT′ in Phase 2. Thanks to the modification of Simple, we can assume that g(OPT′) is large. However, an extra difficulty arises if K − c(Y ) ≥ c(OPT′), we cannot apply our algorithms developed in previous sections. For this, we need to combine Simple and LargeFirst to obtain the better ratios, where the results are summarized as below. Lemma 5.3. Suppose that we are given an instance I ′ = (f, c, K ′, E) for the problem (1). Let X be a subset such that c(e) ≤ K ′ for any e ∈ X and c(X) ≤ W ′ = ηK ′, where η > 1. We further suppose that v′ ≤ f (X) ≤ O(1)v′. Then we can find a set S in O(nε−4 log K ′) time and O(K ′ε−3 log K ′) space, using O(ε−1) passes, such that the following hold: (a) If η ∈ [1, 1.4], then f (S) ≥ (0.315 − O(ε))v′. (b) If η ∈ [1.4, 1.5], then f (S) ≥ (0.283 − O(ε))v′. (c) If η ∈ [1.5, 2], then f (S) ≥ (0.218 − O(ε))v′. (d) If η ∈ [2, 2.5], then f (S) ≥ (0.178 − O(ε))v′. The proof will be given in Section 5.4. Using Lemma 5.3 with case analysis, we can find a feasible set to (20) that approximates OPT′. This solution, together with Y , gives a (0.5 − O(ε))-approximate solution. 5.2 Packing Small Items First 5.2.1 When c1 ≥ 0.5 In this section, we assume that c1 ≥ c1 ≥ 0.5. Since the range of c1 is [0.5, 1], we can guess c1 and c1 using O(ε−1) space. We also guess c2 and c2 using O(ε−1 log K) space. Recall that in the proof of Lemma 4.7, we have shown that we obtain a (0.5− ε)-approximation 1−c1 ≥ 0.505. Therefore, in this section, we assume that µ < 0.505, i.e., when µ = 1−c1−c2 1 − c1 ≥ 200 101 (1 − c1 − c2) ≥ 1.98(1 − c1 − c2). (21) 20 This implies that c1 + c2 ≥ 0.747. Lemma 5.4. Then, if (21) holds, we can find a (0.5 − ε)-approximate solution in O(ε−1) passes and O(Kε−5 log2 K) space. The total running time is O(nε−6 log2 K). The rest of this subsection is devoted to the proof of the above lemma. It suffices to design an O(ε−1)-pass algorithm provided the approximated value v and ci, ci (i = 1, 2) such that ci ≤ (1 + ε)ci, running in O(Kε−2 log K) space and O(nε−3 log K) time. We may also assume that c1 + c2 ≤ 1 − ε/δ where δ = 0.01. Finding a good set Y . By Corollary 5.2, we may assume that f (OPT − o1 − o2) is relatively large. More specifically, f (OPT − o1 − o2) ≥ f (OPT) − f (o1) − f (o2) ≥ 0.33v. On the other hand, (21) implies that c1 + c2 ≥ 0.747, which means that c(OPT − o1 − o2) is small. We consider collecting such a "dense" set of small items by introducing maximize f (S) subject to c(S) ≤ 1.98csK, S ⊆ E, (22) where we define cs = 1 − c1 − c2. We apply Simple to (22) to find a set Y that approximates OPT − o1 − o2. By (21), we still have space to take o1 after taking Y . We denote cs = 1 − c1 − c2. Lemma 5.5. We can find a subset Y in O(ε−1) passes and O(K) space such that f (Y ) ≥ 0.33(cid:18)1 − e− c(Y ) csK (cid:19) v − O(ε)v, 1.98csK ≥ c(Y ) ≥ (0.98cs − 1.98ε(c1 + c2)) K. Moreover, if f (Y + o1) < 0.5v, then f (OPT − o1 Y ) ≥ 0.5v. Proof. The first inequality follows from Corollary 3.4 applied to approximate OPT − o1 − o2 for the instance (22), noting that f (OPT − o1 − o2) ≥ 0.33v. Since items in OPT − o1 − o2 are of size at most c(o3), it is obvious from Lemma 3.2 that (1.98cs − c3)K ≤ c(Y ) ≤ 1.98csK. Since cs ≥ cs − (1 + ε)(c1 + c2) and c3 ≤ cs, the lower bound is bounded by (1.98cs − c3)K ≥ 1.98(cs − ε(c1 + c2))K − csK = (0.98cs − 1.98ε(c1 + c2)) K. Finally, if f (Y + o1) < 0.5v, then we have f (OPT − o1 Y ) ≥ f (OPT Y ) − f (o1 Y ) ≥ (f (OPT) − f (Y )) − (0.5v − f (Y )) ≥ 0.5v. Packing the remaining space. Define g(·) = f (· Y ). Consider the problem (19), and let I ′ be the corresponding instance. We shall find a feasible set to approximate OPT − o1. By Lemma 5.5, we may assume that g(OPT − o1) ≥ v′ = v/2, as otherwise we can find an item e such that c(Y + e) ≤ K and f (Y + e) ≥ 0.5v using a single pass. Let W ′ = (1 − c1)K and K ′ = K − c(Y ). Then c(OPT − o1) ≤ W ′ holds. The algorithm Simple(I ′; 0.5v, W ′) can find a set S such that 1−c1 − O(ε)(cid:19) v, 2 (cid:18)1 − e − 1−y−c2 1 g( S) ≥ where y = c(Y )/K. 21 Moreover, noting that c(Y ) ≤ 1.98cs ≤ (1 − c1) ≤ 0.5 ≤ c1 since c1 ≥ 0.5 and (21), we have W ′ ≤ K ′. Hence we can apply a (0.46 − ε)-approximation algorithm in Lemmas 4.6 and 4.7 with g(OPT − o1) ≥ v′ = v/2 and c(OPT − o1) ≤ W ′. That is, we can find a set S′ such that g( S′) ≥ 1 2 (0.46 − O(ε))v = (0.23 − O(ε))v. Then Y ∪ S and Y ∪ S′ are both feasible set to the original instance. By Lemma 5.5, we have f (Y ∪ S) = f (Y ) + g( S) ≥ 0.33(cid:16)1 − e− y f (Y ∪ S′) = f (Y ) + g( S′) ≥ 0.33(cid:16)1 − e− y 1 − 1−y−c2 2 (cid:18)1 − e cs(cid:17) v + cs(cid:17) v + 0.23v − O(ε)v. 1−c1 (cid:19) v − O(ε)v, (23) (24) Since each bound is a concave function with respect to y, the worst case is achieved when y = 0.98cs − 1.98ε(c1 + c2) or 1.98cs. Suppose that y = 0.98cs − 1.98ε(c1 + c2). Then it holds that y cs 1 − c1 − c2 ≥ 0.98 − 1.98δ, assuming that c1 + c2 ≤ 1 − ε/δ. Moreover, since y ≤ cs = 1 − c1 − c2, c2 = 0.98 − 1.98ε c1 1 − (1 − c1 − c2) − c2 c1 + c2 1 − y − c2 1 − c1 ≥ 1 − c1 ≥ 1 − c1 − ε 1 − c1 ≥ 1 − ε, where the last inequality follows since c1 ≥ 0.5 and c2 ≤ 1 − c1. Hence, by (23), we obtain f (Y ∪ S) ≥ 0.33(cid:16)1 − e−(0.98−1.98δ)(cid:17) + when δ = 0.01. Suppose that y = 1.98cs. Then we have 1 2 (cid:0)1 − e−1(cid:1) − O(ε)v ≥ (0.51 − O(ε))v Hence (24) implies that y cs = 1.98 cs cs ≥ 1.98 (1 − δ) . f (Y ∪ S′) ≥ 0.33(cid:16)1 − e−1.98(1−δ)(cid:17) v + 0.23v − O(ε)v ≥ (0.51 − O(ε))v when δ = 0.01. Therefore, it follows that the maximum of f (Y ∪ S) and f (Y ∪ S′) is at least (0.51 − O(ε))v for any c(Y ). Thus we can find a (0.5 − O(ε))-approximate solution assuming (21). In the above, we apply the algorithms in Sections 4 to I ′ to approximate OPT − o1. To do it, we need to have approximated sizes of c(o2) and c(o3), which are the two largest items in OPT− o1. Since c2, c2 are given in the beginning, it suffices to guess approximated values c3 and c3 of c(o3) using O(ε−1 log K) space. Therefore, the space required is O(Kε−2 log K) and the running time is O(nε−3 log K). In summary, when c1 ≥ 0.5, we have the following, combining the above discussion with Lem- mas 4.1 and 4.7. Theorem 5.6. For any instance I = (f, c, K, E) for the problem (1), if c1 ≥ 0.5, then we can find a (0.5 − ε)-approximate solution in O(ε−1) passes and O(Kε−5 log2 K) space. The total running time is O(nε−6 log2 K). 22 5.2.2 When c1 ≤ 0.5 In this section, we assume that c1 ≤ 0.5. Note that we may assume that c1 ≥ 0.3 by Corollary 5.1. Furthermore, we suppose that (25) (Section 5.3 handles the case when this inequality does not hold.) This implies that c1 + c2 ≥ 14/19 ≥ 0.735, where the minimum is when c1 = c2. Thus c1 ≥ 7/19 ≥ 0.36. The argument is similar to the previous subsection. That is, we first try to find a dense set of small items, and then apply algorithms in Sections 3 -- 4. Lemma 5.7. Suppose that 0.3 ≤ c1 ≤ 0.5. Then, if (25) holds, we can find a (0.5− ε)-approximate solution in O(ε−1) passes and O(Kε−6 log K) space. The total running time is O(nε−7 log K). 2.4(1 − c1 − c2) ≤ 1 − c1. The rest of this subsection is devoted to the proof of the above lemma. Since the range of c1 is [0.3, 0.5], we can guess c1 and c1, where c1 ≥ 0.3 and c1 ≤ 0.5, using O(ε−1) space. We also guess c2 and c2 using O(ε−1) space, since the range of c2 is [0.235, 0.5] by (25). Recall that they satisfy ci ≤ ci ≤ ci ≤ (1 + ε)ci for i = 1, 2. Therefore, it suffices to design an O(ε−1)-pass algorithm provided the approximated value v and ci, ci (i = 1, 2) such that ci ≤ (1 + ε)ci, running in O(Kε−3 log K) space and O(nε−4 log K) time. We may also assume that c1 + c2 ≤ 1− ε/δ where δ = 0.01. Finding a good set Y . By Corollary 5.2, we may assume that f (OPT−o1−o2) is relatively large, while c(OPT − o1 − o2) is small. More specifically, f (OPT − o1 − o2) ≥ f (OPT) − f (o1) − f (o2) ≥ 0.386v, but c(OPT − o1 − o2) ≤ 5/19K ≤ 0.265K. We consider collecting such a "dense" set of small items by introducing maximize f (S) subject to c(S) ≤ 2.4csK, S ⊆ E, (26) where we recall cs = 1 − c1 − c2. By (25), we still have space to take o1 after applying Simple to (26). We denote cs = 1 − c1 − c2. Similarly to Lemma 5.5, we have the following lemma. Lemma 5.8. We can find a subset Y in O(ε−1n) time and O(K) space such that csK (cid:19) v − O(ε)v, f (Y ) ≥ 0.386(cid:18)1 − e− c(Y ) 2.4csK ≥ c(Y ) ≥ (2.4cs − c3)K. Moreover, if f (Y + o1) < 0.5v, then f (OPT − o1 Y ) ≥ 0.5v. Packing the remaining space. Let Y be a set found by Lemma 5.8. Define g(·) = f (· Y ). Consider the problem (19). By Lemma 5.8, we may assume that g(OPT − o1) ≥ v/2 by checking whether adding an item e to Y gives us a 0.5-approximation using a single pass. We set W ′ = (1 − c1)K ≥ c(OPT − o1) and K ′ = K − c(Y ). There are two cases depending on the sizes of W ′ and K ′. Note that K ′ ≥ W ′ if and only if y ≤ c1, where we denote y = c(Y )/K. 23 In this case, K ′ ≥ W ′ holds. Hence we can apply our algorithm in Section 4 with (a) y ≤ c1. g(OPT − o1) ≥ v′ = 0.5v and c(OPT − o1) ≤ W ′. Our algorithm in fact admits a (0.49 − ε)- approximation by Lemma 4.7 since the biggest size in OPT − o1 is c2K and, by (25), c2K ≥ (1 − ε)c2K ≥ 1.4 2.4 (1 − c1)K − c2εK ≥ 0.5W ′, when ε is small, e.g., ε < 1/12. Let S be the obtained set, that is, it satisfies that c(S) ≤ K − c(Y ) and g(Y ) ≥ (0.49 − O(ε))v′. Then Y ∪ S is a feasible set to the original instance. By Lemma 5.8, the set Y ∪ S satisfies f (Y ∪ S) = f (Y ) + g(S) ≥ 0.386(cid:16)1 − e− y cs(cid:17) v + 0.5 · 0.49v − O(ε)v. (27) Since y ≥ 2.4cs − c3 ≥ 2.4cs − cs by Lemma 5.8, the exponent in (27) is cs cs − 1 ≥ 2.4(1 − δ) − 1 ≥ 1.4 − 2.4δ, y cs ≥ 2.4 when c1 + c2 ≤ 1 − ε/δ. Hence the RHS of (27) is lower-bounded by 0.386(cid:16)1 − e−1.4+2.4δ(cid:17) v + 0.5 · 0.49v − O(ε)v ≥ (0.53 − O(ε))v. To apply the algorithms in Sections 4 to approximate OPT− o1, we need to have approximated sizes of c(o2) and c(o3). Since we need to guess c3, c3 using O(ε−1 log K) additional space, the space required is O(Kε−2 log K) and the running time is O(nε−3 log K). In this case, K ′ < W ′ holds. We consider the problem (19) to approximate OPT − (b) y > c1. o1 − o2. Suppose that τ v′ ≥ g(o2) ≥ τ v′/(1+ε). Since g(OPT−o1) ≥ v′, it holds that g(OPT−o1−o2) ≥ g(OPT − o1) − g(o2) ≥ (1 − τ )v′ − εv′. Since v′ = v/2, it follows from Corollary 3.4 that we can find a set S1 such that c( S1) ≤ K − c(Y ) and g( S1) ≥ 1 2 (1 − τ )(cid:16)1 − e− 1−y−c3 cs (cid:17) v − O(ε)v. (28) Moreover, if we take a singleton e with maximum return g(e) such that c(e) ≤ K − c(Y ), then letting S2 = {e}, we have c( S2) ≤ K − c(Y ) and g( S2) ≥ g(o2) ≥ τ v − O(ε)v. 1 2 (29) Note that c(OPT − o1 − o2) = (1 − c1 − c2)K ≤ 5/19K and K ′ = K − c(Y ) ≥ c1K ≥ 7/19K. Hence Lemmas 4.6 and 4.7 are applicable to approximate OPT − o1 − o2, and we can find a set S3 such that c( S3) ≤ K − c(Y ) and g( S3) ≥ 1 2 (1 − τ )0.46v − O(ε)v. (30) Then the lower bound of the best solution is max{f (Y ∪ Sℓ) ℓ = 1, 2, 3} ≥ 0.386(cid:16)1 − e− y cs(cid:17) v + maxng( Sℓ) ℓ = 1, 2, 3o − O(ε)v. Since every bound is a concave function with respect to y, the worst case is achieved when y = c1 or 2.4cs. Recall that c1 ≥ 7/19 and c1 + c2 ≥ 14/19. 24 Suppose that y = c1. If τ ≥ 0.42, then (29) implies that f (Y ∪ S2) ≥ 0.386(cid:16)1 − e− c1 0.42v − O(ε)v ≥ (0.50 − O(ε))v, since If τ ≤ 0.42, then (28) implies c1 cs ≥ 1 2 cs(cid:17) v + 7/19 − ε 5/19 + ε ≥ 1.4 − O(ε). f (Y ∪ S1) ≥ 0.386(cid:16)1 − e− c1 cs(cid:17) v + 1 2 (1 − 0.42)(cid:18)1 − e− 1−c1−c3 cs − O(ε)(cid:19) v. (31) Since c3 ≤ cs ≤ 5/19 + ε, we have c1 − O(ε), and c1 cs ≥ 19 5 Hence (31) implies that 1 − c1 − c3 cs 1 − c1 cs − 1 ≥ 19 5 ≥ (1 − c1) − 1 − O(ε). f (Y ∪ S1) ≥ 0.386(cid:16)1 − e− 19 5 c1(cid:17) v + 0.29(cid:16)1 − e− 19 5 (1−c1)+1(cid:17) v − O(ε)v ≥ (0.50 − O(ε))v as 0.5 ≥ c1 ≥ 7/19. then (29) implies that Suppose that y = 2.4cs. Then we have y cs ≥ 2.4(1 − δ), since c1 + c2 ≤ 1 − ε/δ. If τ ≥ 0.314, f (Y ∪ S2) ≥ 0.386(cid:16)1 − e−2.4(1−δ)(cid:17) v + 1 2 0.314v − O(ε)v ≥ (0.50 − O(ε))v. If τ ≤ 0.314, then (30) implies that f (Y ∪ S3) ≥ 0.386(cid:16)1 − e−2.4(1−δ)(cid:17) v + 1 2 (1 − 0.314)0.46 − O(ε)v ≥ (0.50 − O(ε))v. Therefore, it holds that max{f (Y ∪ Sℓ) ℓ = 1, 2, 3} ≥ (0.50 − O(ε))v. Thus we can find a (0.5 − O(ε))-approximate solution. Note that we apply the algorithms in Sections 4 to approximate OPT − o1 − o2 in the above, and hence we need to estimate approximations of c(o3) and c(o4), which are the two largest items in OPT − o1 − o2. This requires O(ε−2 log K) space in a similar way to the proof of Theorem 4.8. Therefore, the space required is O(Kε−3 log K) and the running time is O(nε−4 log K). 5.3 Packing Small Items Later In this section, we consider the remaining case. By Corollary 5.1 and Theorem 5.6, it suffices to consider the case when 0.3 ≤ c1 ≤ 0.5. Moreover, we assume that 2.4(1 − c1 − c2) > 1 − c1, as otherwise Lemma 5.7 implies a (0.5 − ε)-approximation. That is, c2 < 1.4 2.4 (1− c1). Hence it suffices to consider when c2 ≤ 7/19 ≤ 0.37. Lemma 5.9. Suppose that 0.3 ≤ c1 ≤ 0.5. Then, if (25) does not hold, then we can find a (0.5− ε)-approximate solution in O(ε−1) passes and O(Kε−7 log2 K) space. The total running time is O(nε−8 log2 K). 25 We first show that we may assume that c2 is bounded from below. Corollary 5.10. Suppose that 0.3 ≤ c1 ≤ 0.5. If 1−c2 f (S) ≥ (0.5 − O(ε))v in O(K) space and O(ε−1) passe. Proof. By Corollary 5.2, we may suppose that f (o1) < 0.307v. If 1−c2 1−c1 ≥ 1.3, then we can find a set S such that 1−c1 ≥ 1.3, then it holds that 1 − c2 1 − c1 ≥ 1 − c1 1 − c1 1 − c2 1 − c1 ≥ 1.3(1 − δ). Hence Corollary 3.4 with τ = 0.307 implies that we can find a set S such that f (S) ≥ (1 − 0.307)(cid:16)1 − e−1.3(1−δ) − O(ε)(cid:17) v ≥ (0.5 − O(ε))v. Since the range of c1 is [0.3, 0.5], we can guess c1, c1 with c1 ≤ (1 + ε)c1 using O(ε−1) space. Moreover, the above corollary implies that we may assume that c2 ≥ 1 − 1.3(1 − c1) ≥ 0.09 as c1 ≥ 0.3. Hence the range of c2 is [0.09, 0.5], which implies that we can guess c2, c2 with c2 ≤ (1 + ε)c2 using O(ε−1) space. We also guess c3 and c3 using O(ε−1 log K) space. To prove Lemma 5.9, we will show that, given such ci, ci (i = 1, 2, 3) and v, there is an algorithm using O(Kε−3 log K) space and O(nε−4 log K) time. Finding a good set Y . The first phase, called ModifiedSimple (see Algorithm 5), is roughly similar to Simple. As before, we assume v ≤ f (OPT) ≤ (1 + ε)v and c(OPT) ≤ K (notice that we here set W = K). The difference is in that, in each round, we check whether any item in E, by itself, is enough to give us a solution with 0.5v (Lines 4 -- 5). We terminate the repetition when c(S) > (1− c1)K. As will be explained (see Lemma 5.13), we can lower-bound f (OPT− Z Y ) for some subset Z ⊆ OPT, because c2 is small. Algorithm 5 1: procedure ModifiedSimple(I; v) S := ∅. repeat 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: return S + e. if ∃e ∈ E such that f (S + e) ≥ 0.5v and c(S + e) ≤ K then S0 := S and α := (1−ε)v−f (S0) for each e ∈ E do T := S \ S0. if f (e S) ≥ αc(e) and c(S + e) ≤ K then S := S + e. . K until c(S) > (1 − c1)K return S. It is clear that Lemma 3.1(1)(2) still hold in ModifiedSimple. Moreover, ModifiedSimple termi- nates in O(ε−1n) time. In the following discussion, let Y be the final output set of ModifiedSimple, Y ′ the set in the beginning of the last round, and T ′ be the elements added in the last round, i.e., Y = Y ′ ∪ T ′. We now give two different bounds on f (Y ). The proof is identical to Lemmas 2.2 and 3.1(3), where the first one is a stronger bound obtained in the proof of Lemma 2.2. 26 Lemma 5.11. 1. f (Y ) ≥ (cid:18)1 −(cid:16)1 − c(T ′) K (cid:17) e− c(Y ′) K − O(ε)(cid:19) v. 2. f (Y ) ≥ (cid:16)1 − e− c(Y ) To avoid triviality, we assume that f (Y ) < 0.5v. Then we may assume that c(Y ) ≤ 0.7K, as K − O(ε)(cid:17) v. otherwise, Lemma 5.11(2) immediately implies that f (Y ) ≥ (0.5 − O(ε))v (cf. Corollary 5.1). Lemma 5.12. Suppose that f (Y ) < 0.5v. Then for any j, we have f (oj Y ) ≤ (cid:18)e− c(Y ′) K − 0.5(cid:19) v. K − 0.5(cid:19) v, where the last inequality follows by Lemma 5.11(2). Proof. By submodularity, f (oj Y ) ≤ f (oj Y ′). As c(Y ′) < (1 − c1)K and f (Y ) < 0.5v, in the last round, Lines 4 -- 5 imply that every item e, including oj, has f (e Y ′) ≤ 0.5v − f (Y ′) ≤ (cid:18)e− c(Y ′) Lemma 5.13. If f (Y ) < 0.5v and c2 ≤ 0.37, then it satisfies the following. Case 1: If (1 − c2)K ≥ c(Y ) ≥ (1 − c1)K then f (OPT − o1 Y ) ≥ 0.693v − f (Y ). Case 2: If c(Y ) ≥ (1 − c2)K then f (OPT − o1 − o2 Y ) ≥ 0.54v − f (Y ). Case 3: If c(Y ) ≥ (1 − c3)K then f (OPT − o1 − o2 − o3 Y ) ≥ 0.567v − f (Y ). Proof. Case 1: follows immediately, as f (o1) ≤ 0.307v by Corollary 5.2 (2). Case 2: Since c2 ≤ 0.37, in this case, we can assume that 0.63K ≤ c(Y ). Claim 1. If c(T ′) ≥ 0.315K, then f (Y ) ≥ (0.5 − O(ε))v. Proof. We write c(Y )/K = a and c(T ′)/K = b. Then Lemma 5.11(1) implies that f (Y ) ≥ (1 − (1 − b)e−(a−b) − O(ε))v. We lower-bound the function h(a, b) = 1 − (1 − b)eb−a as follows. As ∂h lower bound of a and b into h. By assumption, b ≥ 0.315; a = c(Y )/K ≥ 0.63. Then ∂a , ∂h ∂b ≥ 0, we plug in the The proof follows. h(a, b) ≥ 1 − 0.685e−0.315 ≥ 0.50. By Claim 1, we may assume that c(T ′) < 0.315K. This implies that c(Y ′) ≥ c(Y ) − c(T ′) > 0.315K. Hence, by Lemma 5.12, it holds that f (o1 Y ), f (o2 Y ) < (cid:0)e−0.315 − 0.5(cid:1) v ≤ 0.2297v. Therefore, f (OPT − o1 − o2 Y ) ≥ 0.54v − f (Y ) holds as f (OPT − o1 − o2 Y ) ≥ f (OPT Y ) − f (o1 Y ) − f (o2 Y ) and f (OPT Y ) ≥ v − f (Y ). Case 3: We can prove it in a similar way to Case 2. Since c3 ≤ 1/3, in this case, we can assume that 2/3K ≤ c(Y ) ≤ 0.7K. Claim 2. If c(T ′) ≥ 0.22K, then f (S) ≥ (0.5 − O(ε))v. 27 Proof. We write c(Y )/K = a and c(T ′)/K = b. Then Lemma 5.11(1) implies that In a similar way to Claim 1, we lower-bound the function h(a, b) = 1 − (1 − b)eb−a by setting b = 0.22 and a = c(Y )/K = 2/3. Then f (Y ) ≥ (1 − (1 − b)e−(a−b) − O(ε))v. Thus the proof follows. h(a, b) ≥ 1 − 0.78e−(2/3−0.22) ≥ 0.50. By Claim 2, we see that c(T ′) < 0.22K. This implies that c(Y ′) ≥ c(Y ) − c(T ′) ≥ 2/3 − 0.22 > 0.44. Hence, by Lemma 5.12, it holds that f (oj Y ) < 0.144v for j = 1, 2, 3. Therefore, f (OPT − o1 − o2 − o3 Y ) ≥ 0.567v − f (Y ) holds from submodularity and the fact that f (OPT Y ) ≥ v − f (Y ). Packing the remaining space. Let Y be a set found by ModifiedSimple(I; v). After taking Y , we consider the problem (20) to fill in the remaining space. We approximate OPT−o1, OPT−o1−o2, and OPT − o1 − o2 − o3, respectively, depending on the size c(Y ) of Y . Recall that c(Y ) < 0.7K. Case 1: (1 − c2)K ≥ c(Y ) ≥ (1 − c1)K. By Lemma 5.13, it holds that f (OPT − o1 Y ) ≥ 0.693v − f (Y ). (32) Let v′ = 0.693v−f (Y ). Define g(·) = f (· Y ). Consider the problem (20) to approximate OPT−o1. We set W ′ = (1 − c1)K and K ′ = K − c(Y ). If we can find a set S such that c( S) ≤ K − c(Y ) and g( S) ≥ κv′, then Y ∪ S is a feasible set to the original instance, and it holds by Lemma 5.11 and (32) that f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + κ(cid:0)0.693 −(cid:0)1 − e−y(cid:1)(cid:1) v − O(ε)v, (33) We shall use Lemma 5.3 to find such a set S. Since 0.3 ≤ c1 and y ≤ 0.7, the ratio η of W ′ and where y = c(Y )/K. K ′ is η = W ′ K ′ = 1 − c1 1 − y ≤ 0.7 0.3 ≤ 2.5. (i) η ∈ [2, 2.5]. In this case, we see that η ≥ 2 if and only if y ≥ 1 + c1 2 ≥ 0.65, since c1 ≥ 0.3. It follows from Lemma 5.3 (d) that we can find a set S such that c( S) ≤ K − c(Y ) and g( S) ≥ 0.178v′. Hence, since y ≥ 0.65, (33) implies that f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.178 ·(cid:0)0.693v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.51 − O(ε))v. 28 (ii) η ∈ [1.5, 2]. We see that η ≥ 1.5 if and only if 0.5 + c1 = y ≥ 1.5 1 + 2c1 3 . Also, since c(Y ) ≥ (1 − c1)K, we have y ≥ max(cid:26) 1 + 2c1 3 , 1 − c1(cid:27) ≥ 0.6 − O(ε), where the lower bound is achieved when both the terms are equal. It follows from Lemma 5.3 (c) that we can find a set S such that c( S) ≤ K − c(Y ) and g( S) ≥ 0.218v′. Hence, by (33), we obtain f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.218 ·(cid:0)0.693v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.50 − O(ε))v, as y ≥ 0.6 − O(ε). (iii) η ∈ [1.4, 1.5]. It means that 0.4 + c1 1.4 y ≥ = 2 + 5c1 7 . Also, since c(Y ) ≥ (1 − c1)K, we have y ≥ max(cid:26) 2 + 5c1 7 , 1 − c1(cid:27) ≥ 7 12 − O(ε). It follows from Lemma 5.3 (b) that we can find a set S such that c( S) ≤ K−c(Y ) and g( S) ≥ 0.283v′. Hence, by (33), we obtain f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.283 ·(cid:0)0.693v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.51 − O(ε))v, as y ≥ 7/12 − O(ε). (iv) η ∈ [1, 1.4]. and g( S) ≥ 0.315v′. Hence, by (33), we obtain It follows from Lemma 5.3 (a) that we can find a set S such that c( S) ≤ K−c(Y ) f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.315 ·(cid:0)0.693v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v. This is at least (0.5 − O(ε))v if y ≥ 0.53. Thus we may suppose that c(Y ) < 0.53K. Since c(Y ) ≥ (1 − c1)K, we see c1 ≥ 1 − 0.53 = 0.47. Moreover, since 2.4(1 − c1 − c2) > (1 − c1), we have c2 ≤ 0.31. Hence we have that 1 − c2 1 − c1 ≥ 1 − c2 1 − c1 ≥ (1 − δ) 0.69 0.5 ≥ 1.38(1 − δ), 1 − c1 1 − c1 as c1 ≤ 1 − ε/δ. Therefore, by Corollary 5.10, we can find an (0.5 − O(ε))-approximation. (v) η ∈ [0, 1]. K − c(Y ) and g( S) ≥ 0.46v′. By (33), we have It follows from Lemmas 4.6 and 4.7 that we can find a set S such that c( S) ≤ f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.46 ·(cid:0)0.693v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.53 − O(ε))v, since y ≥ 0.5. Therefore, in each case, the algorithm in Lemma 5.3 yields a (0.5 − O(ε))-approximation. The space required is O(Kε−3 log K) and the running time is O(nε−4 log K). Thus Lemma 5.9 holds for Case 1. 29 Case 2: c(Y ) > (1− c2)K. We may suppose that c(Y ) ≤ 0.7K. Since c(Y ) ≥ (1− c2)K, we have 0.3 ≤ c2. Also c(Y ) ≥ (1 − c2)K ≥ 0.63K holds since c2 ≤ 0.37. Define g(·) = f (· Y ), and consider the problem (20) to approximate OPT − o1 − o2. By Lemma 5.13, it holds that g(OPT − o1 − o2) ≥ 0.54v − f (Y ). Let v′ = 0.54v − f (Y ). In a way similar to Case 1, if we can find a set S such that c( S) ≤ K − c(Y ) and g( S) ≥ κv′, then Y ∪ S is a feasible set to the original instance, and it holds by Lemma 5.11 that (34) We denote W ′ = (1 − c1 − c2)K, K ′ = K − c(Y ), and y = c(Y )/K. Since y ≤ 0.7 and f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + κ(cid:0)0.54 −(cid:0)1 − e−y(cid:1)(cid:1) v − O(ε)v. c1 + c2 ≥ (1 − ε)(c1 + c2) ≥ 0.6(1 − ε), it holds that 1 − c1 − c2 η = W ′ K ′ ≤ 4 3 ≤ + 2ε ≤ 1.5, 1 − y where the last inequality follows because we may suppose that ε ≤ 1/12. (i) η > 1. In this case, it holds that y ≥ c1 + c2. Since y ≥ 1 − c2, we have y ≥ max{c1 + c2, 1 − c2} ≥ 2 3 − O(ε). By Lemma 5.3, we can find a set S such that c( S) ≤ K − c(Y ) and g( S) ≥ 0.315v′. Hence, by (34), we obtain f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.315 ·(cid:0)0.54v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.50 − O(ε))v when y ≥ 2/3 − O(ε). (ii) η ≤ 1. and g( S) ≥ 0.46v′. By (34), we have It follows from Lemmas 4.6 and 4.7 that we can find a set S such that c( S) ≤ K − c(Y ) f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.46 ·(cid:0)0.54v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.51 − O(ε))v, since y ≥ 0.63. Therefore, in each case, the algorithm in Lemma 5.3 yields a (0.5 − O(ε))-approximation. The space required is O(Kε−3 log K) and the running time is O(nε−4 log K). Thus Lemma 5.9 holds for Case 2. In this case, we may assume that c3 ≥ 0.3 since c(Y ) ≤ 0.7K, and Define g(·) = f (· Y ), and consider the problem (20) to approximate OPT − o1 − o2 − o3. By Case 3: c(Y ) > (1 − c3)K. hence c1 + c2 + c3 ≥ 0.9. Lemma 5.13, it holds that g(OPT − o1 − o2 − o3) ≥ 0.567v − f (Y ). Let v′ = 0.567v − f (Y ). We set W ′ = (1 − c1 − c2 − c3)K and K ′ = K − c(Y ). Then, since c1 + c2 + c3 ≥ 0.9(1 − ε), we have W ′ ≤ (0.1 + 0.9ε)K. In addition, since c(Y ) ≤ 0.7K, we see K ′ ≥ 0.3K. Since W ′ ≤ K ′, the algorithm in Section 4 is applicable, and we can find a set S such that c( S) ≤ K − c(Y ) and g( S) ≥ 0.46v′. Since y = c(Y )/K ≥ 2/3, we obtain by Lemma 5.13 f (Y ∪ S) ≥ (cid:0)1 − e−y(cid:1) v + 0.46 ·(cid:0)0.567v −(cid:0)1 − e−y(cid:1) v(cid:1) − O(ε)v ≥ (0.52 − O(ε))v. Therefore, since the algorithm in Section 4 runs in O(Kε−3 log K) space and O(nε−4 log K) time, provided the approximated optimal value, Lemma 5.9 holds for Case 3. 30 5.4 Proof of Lemma 5.3 In this subsection, we prove Lemma 5.3. Recall that W ′ = ηK ′ for some η > 1 and that c(e) ≤ K ′ for any e ∈ X. Note that Simple would work even if η ≥ 1, and, by Corollary 3.4, Simple can find a set S such that (35) f (S) ≥ (cid:18)1 − e− 1−c1 η − O(ε)(cid:19) v. Moreover, when η ≤ 1, we can obtain a (0.46 − O(ε))-approximate solution by LargeFirst in Sec- tion 4. This algorithm runs in O(K ′ε−3 log K ′) space and O(nε−4 log K ′) time using O(ε−1) passes, provided the approximated optimal value v. If there exists an item e such that f (e) ≥ 0.315v, then taking a singleton with (a) η ∈ [1, 1.4]. maximum return admits a 0.315-approximation. Thus we may assume that f (e) ≤ 0.315v for any item e ∈ E. If c1 ≤ η − 1, then the set S in (35) satisfies that f (S) ≥ (cid:18)1 − e− 1−c1 η − O(ε)(cid:19) v ≥ (cid:16)1 − e− 3 7 − O(ε)(cid:17) v ≥ (0.348 − O(ε))v. Otherwise, we consider approximating OPT− o1. Since c(OPT− o1) ≤ K ′− (η− 1)K ′ ≤ ηK ′ = W ′, we can use a (0.46− O(ε))-approximation algorithm in Section 4. Since f (OPT− o1) ≥ v − f (o1) ≥ 0.685v, we can find a set S such that Thus the statement holds. f (S) ≥ 0.685(0.46 − O(ε))v ≥ (0.315 − O(ε))v. (b) η ∈ [1.4, 1.5]. The proof is similar to (a). We may assume that f (e) ≤ 0.283v for any item e ∈ E. If c1 ≤ η − 1, then the set S in (35) satisfies that η − O(ε)(cid:19) v ≥ (cid:16)1 − e− 1 3 − O(ε)(cid:17) v ≥ (0.283 − O(ε))v. f (S) ≥ (cid:18)1 − e− 1−c1 Otherwise, apply a (0.46−O(ε))-approximation algorithm to approximate OPT−o1. Since f (OPT− o1) ≥ v − f (o1) ≥ 0.72v, the ratio of the output S is Thus the statement holds. f (S) ≥ 0.72(0.46 − O(ε))v ≥ (0.331 − O(ε))v. (c) η ∈ [1.5, 2]. We will use the above argument in (a) and (b) recursively. We may assume that f (e) < 0.22v for any e ∈ E. If c1 < 0.5, then then the set S in (35) satisfies that f (S) ≥ (cid:18)1 − e− 1−c1 η − O(ε)(cid:19) v ≥ (cid:16)1 − e− 0.5 2 − O(ε)(cid:17) v ≥ (0.22 − O(ε))v. So consider the case when c1 ≥ 0.5. Consider approximating OPT − o1. Since c(OPT − o1) ≤ 2K ′ − 0.5K ′ ≤ 1.5K ′ and f (OPT − o1) ≥ 0.78v, the algorithm in (b) can find a set S such that Thus the statement holds. f (S) ≥ 0.78(0.28 − O(ε))v ≥ (0.218 − O(ε))v. 31 (d) η ∈ [2, 2.5]. We may assume that f (e) < 0.18v for any item e ∈ E. If c1 < 0.5, then then the set S in (35) satisfies that f (S) ≥ (cid:18)1 − e− 1−c1 η − O(ε)(cid:19) v ≥ (cid:16)1 − e− 0.5 2.5 − O(ε)(cid:17) v ≥ (0.18 − O(ε))v. So consider the case when c1 ≥ 0.5. Consider approximating OPT − o1. Since c(OPT − o1) ≤ 2.5K ′ − 0.5K ′ ≤ 2.0W ′ and f (OPT − o1) ≥ 0.82v, the algorithm in (c) can find a set S such that f (S) ≥ 0.82 · (0.218 − O(ε))v ≥ (0.178 − O(ε))v. Thus the statement holds. References [1] N. Alon, I. Gamzu, and M. Tennenholtz. Optimizing budget allocation among channels and influencers. In Proceedings of the 21st International Conference on World Wide Web (WWW), pages 381 -- 388, 2012. [2] A. Badanidiyuru, B. Mirzasoleiman, A. Karbasi, and A. Krause. Streaming submodular max- imization: massive data summarization on the fly. In Proceedings of the 20th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), pages 671 -- 680, 2014. [3] A. Badanidiyuru and J. Vondrák. Fast algorithms for maximizing submodular functions. In Proceedings of the 25th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1497 -- 1514, 2013. [4] M. Bateni, H. Esfandiari, and V. Mirrokni. Almost optimal streaming algorithms for coverage In Proceedings of the 29th ACM Symposium on Parallelism in Algorithms and problems. Architectures, SPAA '17, pages 13 -- 23, New York, NY, USA, 2017. ACM. [5] G. Calinescu, C. Chekuri, M. Pál, and J. Vondrák. Maximizing a monotone submodular function subject to a matroid constraint. SIAM Journal on Computing, 40(6):1740 -- 1766, 2011. [6] A. Chakrabarti and S. Kale. Submodular maximization meets streaming: matchings, matroids, and more. Mathematical Programming, 154(1-2):225 -- 247, 2015. [7] T.-H. H. Chan, Z. Huang, S. H.-C. Jiang, N. Kang, and Z. G. Tang. Online submodular maximization with free disposal: Randomization beats for partition matroids online. In Pro- ceedings of the 28th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1204 -- 1223, 2017. [8] T.-H. H. Chan, S. H.-C. Jiang, Z. G. Tang, and X. Wu. Online submodular maximization problem with vector packing constraint. In Annual European Symposium on Algorithms (ESA), pages 24:1 -- 24:14, 2017. [9] C. Chekuri, S. Gupta, and K. Quanrud. Streaming algorithms for submodular function maxi- mization. In Proceedings of the 42nd International Colloquium on Automata, Languages, and Programming (ICALP), volume 9134, pages 318 -- 330, 2015. 32 [10] C. Chekuri, J. Vondrák, and R. Zenklusen. Submodular function maximization via the multi- linear relaxation and contention resolution schemes. SIAM Journal on Computing, 43(6):1831 -- 1879, 2014. [11] A. Ene and H. L. Nguyễn. A nearly-linear time algorithm for submodular maximization with a knapsack constraint. arXive https://arxiv.org/abs/1709.09767, 2017. [12] Y. Filmus and J. Ward. A tight combinatorial algorithm for submodular maximization subject to a matroid constraint. SIAM Journal on Computing, 43(2):514 -- 542, 2014. [13] M. L. Fisher, G. L. Nemhauser, and L. A. Wolsey. An analysis of approximations for maxi- mizing submodular set functions i. Mathematical Programming, pages 265 -- 294, 1978. [14] M. L. Fisher, G. L. Nemhauser, and L. A. Wolsey. An analysis of approximations for maxi- mizing submodular set functions ii. Mathematical Programming Study, 8:73 -- 87, 1978. [15] C.-C. Huang, N. Kakimura, and Y. Yoshida. Streaming algorithms for maximizing monotone submodular functions under a knapsack constraint. In The 20th International Workshop on Approximation Algorithms for Combinatorial Optimization Problems(APPROX2017), 2017. [16] D. Kempe, J. Kleinberg, and É. Tardos. Maximizing the spread of influence through a social In Proceedings of the 9th ACM SIGKDD International Conference on Knowledge network. Discovery and Data Mining (KDD), pages 137 -- 146, 2003. [17] A. Krause, A. P. Singh, and C. Guestrin. Near-optimal sensor placements in gaussian processes: Theory, efficient algorithms and empirical studies. Journal of Machine Learning Research, 9:235 -- 284, 2008. [18] A. Kulik, H. Shachnai, and T. Tamir. Maximizing submodular set functions subject to multiple In Proceedings of the 20th Annual ACM-SIAM Symposium on Discrete linear constraints. Algorithms (SODA), pages 545 -- 554, 2013. [19] J. Lee. Maximum Entropy Sampling, volume 3 of Encyclopedia of Environmetrics, pages 1229 -- 1234. John Wiley & Sons, Ltd., 2006. [20] J. Lee, M. Sviridenko, and J. Vondrák. Submodular maximization over multiple matroids via generalized exchange properties. Mathematics of Operations Research, 35(4):795 -- 806, 2010. [21] H. Lin and J. Bilmes. Multi-document summarization via budgeted maximization of submod- ular functions. In Proceedings of the 2010 Annual Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL- HLT), pages 912 -- 920, 2010. [22] H. Lin and J. Bilmes. A class of submodular functions for document summarization. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies (ACL-HLT), pages 510 -- 520, 2011. [23] A. McGregor and H. T. Vu. Better streaming algorithms for the maximum coverage problem. In International Conference on Database Theory (ICDT), 2017. [24] B. Mirzasoleiman, A. Badanidiyuru, A. Karbasi, J. Vondrák, and A. Krause. Lazier than lazy greedy. In Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, AAAI'15, pages 1812 -- 1818. AAAI Press, 2015. 33 [25] B. Mirzasoleiman, S. Jegelka, and A. Krause. Streaming non-monotone submodular max- In Proc. Conference on Artificial imization: Personalized video summarization on the fly. Intelligence (AAAI), Feburary 2018. [26] T. Soma, N. Kakimura, K. Inaba, and K. Kawarabayashi. Optimal budget allocation: Theo- retical guarantee and efficient algorithm. In Proceedings of the 31st International Conference on Machine Learning (ICML), pages 351 -- 359, 2014. [27] M. Sviridenko. A note on maximizing a submodular set function subject to a knapsack con- straint. Operations Research Letters, 32(1):41 -- 43, 2004. [28] L. Wolsey. Maximising real-valued submodular functions: primal and dual heuristics for loca- tion problems. Mathematics of Operations Research, 1982. [29] Y. Yoshida. Maximizing a monotone submodular function with a bounded curvature under a knapsack constraint. https://arxiv.org/abs/1607.04527, 2016. [30] Q. Yu, E. L. Xu, and S. Cui. Streaming algorithms for news and scientific literature recom- mendation: Submodular maximization with a d-knapsack constraint. IEEE Global Conference on Signal and Information Processing, 2016. 34 A Proof of Lemma 4.1 We discuss how to obtain a (0.5 − O(ε))-approximation when c1 + c2 is almost 1. Claim 3. Suppose that f (o1 + o2) ≥ v′. We can find a set S using two passes and O(ε−1K) space such that S= 2 and f (S) ≥ (cid:18) 2 3 − ε(cid:19) v′. We begin by reviewing the algorithm2 in [15]. Theorem A.1. Let ER ⊆ E be a subset of the ground set (and we call ER red items). Let X ⊆ E such that v ≤ f (X) ≤ (1 + ε)v. Assume that there exists x ∈ X ∩ ER such that τ v ≤ f (x) ≤ τ v. τ Then we can find a set Y ⊆ ER of red items, in one pass and O(n) time, with Y = O(log1+ε τ ) such that some item e∗ in Y satisfies f (X − x + e∗) ≥ (2/3 − O(ε))v. Proof of Claim 3. For each t = 1, 2, . . . , K/2, define Et = {e ∈ E t ≤ c(e) ≤ K − t} as the red items. The critical thing to observe is that, if t ≤ c(o2), we see o1 ∈ Ec(o2). The above observation suggests the following implementation. In the first pass, for each set Et, apply Theorem A.1 to collect a set Xt ⊆ Et (apparently we can set τ = 2/3 and τ = 1/3). Since Xt= O(log1+ε 2) = O(ε−1), it takes O(ε−1K) space and O(n) time in total. Then it follows from Theorem A.1 that, for each t with t ≤ c(o2), there exists e∗ ∈ Xt such that f (o2+e∗) ≥ (2/3−O(ε))v′ and c(e∗) ≤ K − c(o2). In the second pass, for each item e in E, check whether there exists e′ in Xc(e) such that c(e + e′) ≤ K and f (e + e′) ≥ (2/3 − O(ε))v′. It follows that there exists at least one pair of e and e′ satisfying the condition. The second pass also takes O(ε−1K) space as we keep Xt's. Since Xt= O(ε−1), the second phase takes O(ε−1n) time. Suppose that v ≤ f (OPT) ≤ (1 + ε)v. If f (o1 + o2) ≥ 0.75v, then we are done using Claim 3. So assume otherwise, meaning that f (OPT − o1 − o2) ≥ 0.25v. Notice that we can also assume that f (OPT − o1) ≥ 0.5v. Now consider two possibilities. Claim 4. If c1 ≥ 1 − √ε, then we can find a set S in O(ε−1) passes and O(K) space such that c(S) ≤ K and f (S) ≥ (0.5 − O(ε))v. Proof. Since c1 ≥ 1 − √ε, we have c(OPT − o1) ≤ √εK. Consider the problem (1) to approximate OPT − o1. Then the largest item in OPT − o1 is c(o2) which is at most √εK. By Corollary 3.4, Simple(I; 0.5v,√εK) can obtain a set S satisfying that √ε − O(ε)(cid:19) v ≥ (0.5 − O(ε))v, f (S) ≥ 0.5(cid:18)1 − e− 1−√ε where the last inequality follows because e− 1−√ε Claim 5. If c1 < 1 − √ε, then we can find a set S in O(ε−1) passes and O(K) space such that c(S) ≤ K and f (S) ≥ (0.5 − O(ε))v. Proof. Consider the problem: √ε ≤ ε when ε ≤ 1. maximize f (S) subject to c(S) ≤ √εK, S ⊆ E, 2This theorem is essentially a rephrasing of Theorem 4.3. 35 to approximate OPT−o1−o1. Let I ′ be the corresponding instance. Since f (OPT−o1−o2) ≥ 0.25v and c(OPT − o1 − o2) ≤ εK, Corollary 3.4 implies that Simple(I ′; 0.25v, εK) can obtain a set Y satisfying that f (Y ) ≥ 0.25(cid:16)1 − e− √ε−ε ε − O(ε)(cid:17) v ≥ (0.25 − O(ε))v, since the largest item in OPT − o1 − o2 has size at most ε. After taking the set Y , we still have space for packing either o1 or o2, since c(Y ) ≤ √εK < K − c(o1). Define g := f (· Y ). If some element e satisfies c(Y ) + c(e) ≤ K and f (Y + e) ≥ 0.5v, then we are done. Thus we may assume that no such element exists, implying that f (Y + oℓ) < 0.5v for ℓ = 1, 2. Hence it holds that g(OPT − o1) ≥ g(OPT) − g(o1) ≥ (f (OPT) − f (Y )) − (f (Y + o1) − f (Y )) ≥ 0.5v, This implies that g(OPT − o1 − o2) ≥ g(OPT − o1) − g(o2) ≥ 0.5v − (f (Y + o1) − f (Y )) ≥ f (Y ) ≥ (0.25 − O(ε))v. Consider the problem: maximize g(S) subject to c(S) ≤ K − c(Y ), S ⊆ E, to approximate OPT − o1 − o1. Denote by I ′′ the corresponding instance. Since K − c(Y ) ≥ (1 − √ε)K and g(OPT − o1 − o2) ≥ (0.25 − O(ε))v, Corollary 3.4 implies that Simple(I ′′; (0.25 − O(ε))v, εK) can obtain a set S satisfying that f (S) ≥ (0.25 − O(ε))(cid:16)1 − e− 1−√ε−ε Therefore, Y ∪ S satisfies that c(Y ∪ S) ≤ K and ε − O(ε)(cid:17) v ≥ (0.25 − O(ε))v. f (Y ∪ S) = f (Y ) + g(S) ≥ (0.5 − O(ε))v. For a given v, the above can be done in O(ε−1K) space using O(ε−1) passes. The total running time is O(nε−1). This completes the proof of Lemma 4.1. 36
1506.00063
1
1506
2015-05-30T03:14:38
An Efficient Dynamic Programming Algorithm for STR-IC-SEQ-EC-LCS Problem
[ "cs.DS" ]
In this paper, we consider a generalized longest common subsequence problem, in which a constraining sequence of length $s$ must be included as a substring and the other constraining sequence of length $t$ must be excluded as a subsequence of two main sequences and the length of the result must be maximal. For the two input sequences $X$ and $Y$ of lengths $n$ and $m$, and the given two constraining sequences of length $s$ and $t$, we present an $O(nmst)$ time dynamic programming algorithm for solving the new generalized longest common subsequence problem. The time complexity can be reduced further to cubic time in a more detailed analysis. The correctness of the new algorithm is proved.
cs.DS
cs
An Efficient Dynamic Programming Algorithm for STR-IC-SEQ-EC-LCS Problem Daxin Zhu, Lei Wang, Yingjie Wu, and Xiaodong Wang July 22, 2018 Abstract In this paper, we consider a generalized longest common subsequence problem, in which a constraining sequence of length s must be included as a substring and the other constraining sequence of length t must be excluded as a subsequence of two main sequences and the length of the result must be maximal. For the two input sequences X and Y of lengths n and m, and the given two constraining sequences of length s and t, we present an O(nmst) time dynamic programming algorithm for solving the new generalized longest common subsequence problem. The time complexity can be reduced further to cubic time in a more detailed analysis. The correctness of the new algorithm is proved. 1 Introduction The longest common subsequence (LCS) problem is a well-known measurement for computing the similarity of two strings. It can be widely applied in diverse areas, such as file comparison, pattern matching and computational biology[3, 4, 8, 9]. Given two sequences X and Y , the longest common subsequence (LCS) problem is to find a subsequence of X and Y whose length is the longest among all common subsequences of the two given sequences. For some biological applications some constraints must be applied to the LCS problem. These kinds of variant of the LCS problem are called the constrained LCS (CLCS) problem. Recently, Chen and Chao[1] proposed the more generalized forms of the CLCS problem, the generalized constrained longest common subsequence (GC-LCS) problem. For the two input sequences X and Y of lengths n and m,respectively, and a constraint string P of length r, the GC-LCS problem is a set of four problems which are to find the LCS of X and Y including/excluding P as a subsequence/substring, respectively. In this paper, we consider a more general constrained longest common subsequence problem called STR- IC-SEQ-EC-LCS, in which a constraining sequence of length s must be included as a substring and the other constraining sequence of length t must be excluded as a subsequence of two main sequences and the length of the result must be maximal. We will present the first efficient dynamic programming algorithm for solving this problem. The organization of the paper is as follows. In the following 4 sections we describe our presented dynamic programming algorithm for the STR-IC- SEQ-EC-LCS problem. In section 2 the preliminary knowledge for presenting our algorithm for the STR-IC-SEQ-EC-LCS prob- lem is discussed. In section 3 we give a new dynamic programming solution for the STR-IC-SEQ-EC-LCS problem with time complexity O(nmst), where n and m are the lengths of the two given input strings, and s and t the lengths of the two constraining sequences. In section 4 the time complexity is further improved to O(nmt). Some concluding remarks are in section 5. 1 2 Characterization of the STR-IC-SEQ-EC-LCS problem A sequence is a string of characters over an alphabet P. A subsequence of a sequence X is obtained by deleting zero or more characters from X (not necessarily contiguous). A substring of a sequence X is a subsequence of successive characters within X. For a given sequence X = x1x2 · · · xn of length n, the ith character of X is denoted as xi ∈ P for any i = 1, · · · , n. A substring of X from position i to j can be denoted as X[i : j] = xixi+1 · · · xj. If i 6= 1 or j 6= n, then the substring X[i : j] = xixi+1 · · · xj is called a proper substring of X. A substring X[i : j] = xixi+1 · · · xj is called a prefix or a suffix of X if i = 1 or j = n, respectively. An appearance of sequence X = x1x2 · · · xn in sequence Y = y1y2 · · · ym, for any X and Y , starting at position j is a sequence of strictly increasing indexes i1, i2, · · · , in such that i1 = j, and X = yi1 , yi2 , · · · , yin . A compact appearance of X in Y starting at position j is the appearance of the smallest last index in. A match for sequences X and Y is a pair (i, j) such that xi = yj. The total number of matches for X and Y is denoted by δ. It is obvious that δ ≤ nm. For the two input sequences X = x1x2 · · · xn and Y = y1y2 · · · ym of lengths n and m, respectively, and two constrained sequences P = p1p2 · · · ps and Q = q1q2 · · · qt of lengths s and t, the SEQ-IC-STR-IC- LCS problem is to find a constrained LCS of X and Y including P as a substring and excluding Q as a subsequence. Definiton 1 Let Z(i, j, k, r) denote the set of all LCSs of X[1 : i] and Y [1 : j] such that for each z ∈ Z(i, j, k, r), z includes P [1 : k] as a substring, and excludes Q[1 : r] as a subsequence, where 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ s, and 0 ≤ r ≤ t. The length of an LCS in Z(i, j, k, r) is denoted as g(i, j, k, r). Definiton 2 Let W (i, j, k, r) denote the set of all LCSs of X[1 : i] and Y [1 : j] such that for each w ∈ W (i, j, k, r), w excludes Q[1 : r] as a subsequence, and includes P [1 : k] as a suffix, where 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ s, and 0 ≤ r ≤ t. The length of an LCS in W (i, j, k, r) is denoted as f (i, j, k, r). Definiton 3 Let U (i, j, k) denote the set of all LCSs of X[i : n] and Y [j : m] such that for each u ∈ U (i, j, k), u excludes Q[k : t] as a subsequence, where 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ t. The length of an LCS in U (i, j, k) is denoted as h(i, j, k). Definiton 4 Let V (i, j, k) denote the set of all LCSs of X[1 : i] and Y [1 : j] such that for each v ∈ V (i, j, k), v excludes Q[1 : k] as a subsequence, where 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ t. The length of an LCS in V (i, j, k) is denoted as v(i, j, k). The following theorem characterizes the structure of an optimal solution based on optimal solutions to subproblems, for computing the LCSs in W (i, j, k, r), for any 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ s, and 0 ≤ r ≤ t. Theorem 1 If Z[1 : l] = z1, z2, · · · , zl ∈ W (i, j, k, r), then the following conditions hold: 1. If i, j, k > 0, r = 1, xi = yj = pk = qr, then zl 6= xi and Z[1 : l] ∈ W (i − 1, j − 1, k, r). 2. If i, j, k > 0, r > 1, xi = yj = pk = qr, then zl 6= xi implies Z[1 : l] ∈ W (i − 1, j − 1, k, r); zl = xi implies Z[1 : l − 1] ∈ W (i − 1, j − 1, k − 1, r − 1). 3. If i, j, k > 0, xi = yj = pk and r > 0, xi 6= qr or r = 0, then zl = xi = yj = pk and Z[1 : l − 1] ∈ W (i − 1, j − 1, k − 1, r). 4. If i, j, k > 0, xi = yj and xi 6= pk, then zl 6= xi and Z[1 : l] ∈ W (i − 1, j − 1, k, r). 5. If i, j > 0, k = 0, r = 1, xi = yj = qr, then zl 6= xi and Z[1 : l] ∈ W (i − 1, j − 1, k, r). 6. If i, j > 0, k = 0, r > 1, xi = yj = qr, then zl 6= xi implies Z[1 : l] ∈ W (i − 1, j − 1, k, r); zl = xi implies Z[1 : l − 1] ∈ W (i − 1, j − 1, k, r − 1). 7. If i, j > 0, k = 0, xi = yj and r > 0, xi 6= qr or r = 0, then zl = xi and Z[1 : l − 1] ∈ W (i − 1, j − 1, k, r). 2 8. If i, j > 0, xi 6= yj , then zl 6= xi implies Z[1 : l] ∈ W (i − 1, j, k, r). 9. If i, j > 0, xi 6= yj , then zl 6= yj implies Z[1 : l] ∈ W (i, j − 1, k, r). Proof. 1. In this case, if xi = zl, then Z[1 : l] includes Q[1 : r], a contradiction. Therefore, we have xi 6= zl, and Z[1 : l] must be an LCS of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence, i.e. Z[1 : l] ∈ W (i − 1, j − 1, k, r). 2. There are two subcases to be distinguished in this case. 2.1. If zl = xi, then Z[1 : l − 1] is a common subsequence of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k − 1] as a suffix and excluding Q[1 : r − 1] as a subsequence. We can show that Z[1 : l − 1] is an LCS of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k − 1] as a suffix and excluding Q[1 : r − 1] as a subsequence. Assume by contradiction that there exists a common subsequence a of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k − 1] as a suffix and excluding Q[1 : r − 1] as a subsequence, whose length is greater than l − 1. Then the concatenation of a and zl will result in a common subsequence of X[1 : i] and Y [1 : j] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence, whose length is greater than l. This is a contradiction. Therefore, in this case we have Z[1 : l − 1] ∈ W (i − 1, j − 1, k − 1, r − 1). 2.2. If zl 6= xi, then Z[1 : l] must be an LCS of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence, i.e. Z[1 : l] ∈ W (i − 1, j − 1, k, r). 3. In this case, we have no constraints on Q, provided r > 0, xi 6= qr or r = 0. Therefore we have xi = yj = pk = zl. It is obvious that Z[1 : l − 1] is a common subsequence of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k − 1] as a suffix and excluding Q[1 : r] as a subsequence. We can show that Z[1 : l − 1] is an LCS of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k − 1] as a suffix and excluding Q[1 : r] as a subsequence. Assume by contradiction that there exists a common subsequence a of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k − 1] as a suffix and excluding Q[1 : r] as a subsequence, whose length is greater than l − 1. Then the concatenation of a and zl will result in a common subsequence of X[1 : i] and Y [1 : j] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence, whose length is greater than l. This is a contradiction. 4. In this case, since xi = yj 6= pk, we have xi 6= zl, otherwise Z[1 : l] will not including P [1 : k] as a suffix. Therefore, Z[1 : l] must be an LCS of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence, i.e. Z[1 : l] ∈ W (i − 1, j − 1, k, r). 5. Since xi = yj = q1 and r = 1, we have xi 6= zl, otherwise Z[1 : l] will including Q[1 : r] as a subsequence. Therefore, Z[1 : l] must be an LCS of X[1 : i − 1] and Y [1 : j − 1] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence, i.e. Z[1 : l] ∈ W (i − 1, j − 1, k, r). 6. There are two subcases to be distinguished in this case. 6.1. If zl = xi, then Z[1 : l − 1] is a common subsequence of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r − 1] as a subsequence. We can show that Z[1 : l − 1] is an LCS of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r − 1] as a subsequence. Assume by contradiction that there exists a common subsequence a of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r − 1] as a subsequence, whose length is greater than l − 1. Then the concatenation of a and zl will result in a common subsequence of X[1 : i] and Y [1 : j] excluding Q[1 : r] as a subsequence, whose length is greater than l. This is a contradiction. Therefore, in this case we have Z[1 : l − 1] ∈ W (i − 1, j − 1, k, r − 1). 6.2. If zl 6= xi, then Z[1 : l] must be an LCS of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r] as a subsequence, i.e. Z[1 : l] ∈ W (i − 1, j − 1, k, r). 7. Since xi = yj and r > 0, xi 6= qr or r = 0, we have zl = xi, and Z[1 : l − 1] is a common subsequence of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r] as a subsequence. We can show that Z[1 : l − 1] is an LCS of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r] as a subsequence. Assume by contradiction that there exists a common subsequence a of X[1 : i − 1] and Y [1 : j − 1] excluding Q[1 : r] as a subsequence, whose length is greater than l − 1. Then the concatenation of a and zl will result in a common subsequence of X[1 : i] and Y [1 : j] excluding Q[1 : r] as a subsequence, whose length is greater than l. This is a contradiction. 8. Since xi 6= yj and zl 6= xi, Z[1 : l] must be a common subsequence of X[1 : i − 1] and Y [1 : j] including P [1 : k] as a suffix and including Q[1 : r] as a subsequence. It is obvious that Z[1 : l] is also an LCS of X[1 : i − 1] and Y [1 : j] including P [1 : k] as a suffix and including Q[1 : r] as a subsequence. 3 9. Since xi 6= yj and zl 6= yj, Z[1 : l] must be a common subsequence of X[1 : i] and Y [1 : j − 1] including P [1 : k] as a suffix and including Q[1 : r] as a subsequence. It is obvious that Z[1 : l] is also an LCS of X[1 : i] and Y [1 : j − 1] including P [1 : k] as a suffix and including Q[1 : r] as a subsequence. The proof is completed. (cid:3) 3 A simple dynamic programming algorithm Our new algorithm for solving the STR-IC-SEQ-EC-LCS problem consists of three main stages. The main idea of the new algorithm can be described by the following Theorem 2. Theorem 2 Let Z[1 : l] = z1, z2, · · · , zl be a solution of the STR-IC-SEQ-EC-LCS problem, i.e. Z[1 : l] ∈ Z(n, m, s, t), then its length l = g(n, m, s, t) can be computed by the following formula: g(n, m, s, t) = max 1≤i≤n,1≤j≤m,1≤r≤t {f (i, j, s, r) + h(i + 1, j + 1, r)} (1) where f (i, j, s, r) is the length of an LCS in W (i, j, s, r) defined by Definiton 2, and h(i, j, r) is the length of an LCS in U (i, j, r) defined by Definiton 3. Proof. Since Z[1 : l] ∈ Z(n, m, s, t), Z[1 : l] must be an LCS of X and Y including P as a substring, and excludes Q as a subsequence. Let the first appearance of the string P in Z[1 : l] starts from position l′ − s + 1 to l′ for some positive integer s ≤ l′ ≤ l, i.e. Z[l′ − s + 1 : l′] = P . Let r∗ = max 1≤r≤t {rQ[1 : r] is a subsequence of Z[1 : l′]} Since Z[1 : l′] excludes Q as a subsequence, we have r∗ < t, and thus Z[1 : l′] excludes Q[1 : r∗ + 1] as a subsequence. For the same reason, Z[l′ + 1 : l] excludes Q[r∗ + 1 : t] as a subsequence. Let (i∗, j∗) = min 1≤i≤n,1≤j≤m {(i, j)Z[1 : l′] is a common subsequence of X[1 : i] and Y [1 : j]} Then, Z[1 : l′] is a common subsequence of X[1 : i∗] and Y [1 : j∗] including P as a suffix and excluding Q[1 : r∗ + 1] as a subsequence. It follows from Definition 2 that l′ ≤ f (i∗, j∗, s, r∗ + 1) (2) Since Z[1 : l] is a common subsequence of X and Y , Z[l′ + 1 : l] must be a common subsequence of X[i∗ + 1 : n] and Y [j∗ + 1 : m]. We have known Z[l′ + 1 : l] excludes Q[r∗ + 1 : t] as a subsequence. Therefore, Z[l′ + 1 : l] is a common subsequence of X[i∗ + 1 : n] and Y [j∗ + 1 : m] excluding Q[r∗ + 1 : t] as a subsequence. It follows from Definition 3 that Combining formulas (2) and (3) we have, l − l′ ≤ h(i∗ + 1, j∗ + 1, r∗ + 1) l ≤ f (i∗, j∗, s, r∗ + 1) + h(i∗ + 1, j∗ + 1, r∗ + 1) Therefore, l ≤ max 1≤i≤n,1≤j≤m,1≤r≤t {f (i, j, s, r) + h(i + 1, j + 1, r)} (3) (4) On the other hand, for any a ∈ W (i, j, s, r) and b ∈ U (i + 1, j + 1, r), 1 ≤ i ≤ n, 1 ≤ j ≤ m, 1 ≤ r ≤ t, then c = aL b, the concatenation of a and b, must be a common subsequence of X[1 : n] and Y [1 : m] including P as a substring. Furthermore, we can prove c excludes Q as a subsequence. 4 In fact, let r∗ = max 0≤r′≤t {r′Q[1 : r′] is a subsequence of a} We then have r∗ < r, since a excludes Q[1 : r] as a subsequence. In this case, if c includes Q as a subsequence, then b must include Q[r∗ + 1 : t] as a subsequence. It follows from r∗ + 1 ≤ r that b includes Q[r : t] as a subsequence. This is a contradiction. Therefore, we have c = aL b is a common subsequence of X[1 : n] and Y [1 : m] including P as a substring and excluding Q as a subsequence, and thus aL b ≤ l. That is: max 1≤i≤n,1≤j≤m,1≤r≤t {f (i, j, s, r) + h(i + 1, j + 1, r)} ≤ l (5) Combining formulas (4) and (5) we have, l = max 1≤i≤n,1≤j≤m,1≤r≤t {f (i, j, s, r) + h(i + 1, j + 1, r)} The proof is completed. (cid:3) The first stage is to find LCSs in W (i, j, k, r). Let f (i, j, k, r) denote the length of an LCS in W (i, j, k, r). By the optimal substructure properties of the STR-IC-SEQ-EC-LCS problem shown in Theorem 1, we can build the following recursive formula for computing f (i, j, k, r). For any 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ s, and 0 ≤ r ≤ t, the values of f (i, j, k, r) can be computed by the following recursive formula (6). f (i, j, k, r) = max {f (i − 1, j, k, r), f (i, j − 1, k, r)} 1 + f (i − 1, j − 1, k − 1, r) f (i − 1, j − 1, k, r) max {1 + f (i − 1, j − 1, k − 1, r − 1), f (i − 1, j − 1, k, r)} f (i − 1, j − 1, k, r) 1 + f (i − 1, j − 1, k, r) f (i − 1, j − 1, k, r) max {1 + f (i − 1, j − 1, k, r − 1), f (i − 1, j − 1, k, r)} if xi 6= yj if xi = yj = pk ∧ (r = 0 ∨ xi 6= qr) if xi = yj = pk = qr ∧ r = 1 if xi = yj = pk = qr ∧ r > 1 if i, j, k > 0 ∧ xi = yj 6= pk if k = 0 ∧ xi = yj ∧ (r = 0 ∨ xi 6= qr) if k = 0 ∧ xi = yj ∧ (r = 1 ∧ xi = qr) if k = 0 ∧ xi = yj = qr ∧ r > 1   (6) The boundary conditions of this recursive formula are f (i, 0, 0, 0) = f (0, j, 0, 0) = 0 and f (i, 0, k, r) = f (0, j, k, r) = −∞ for any 0 ≤ i ≤ n, 0 ≤ j ≤ m, 1 ≤ k ≤ s, and 1 ≤ r ≤ t. Based on this formula, our algorithm for computing f (i, j, k, r) is a standard dynamic programming algorithm. By the recursive formula (1), the dynamic programming algorithm for computing f (i, j, k, r) can be implemented as the following Algorithm 1. It is obvious that the algorithm requires O(nmst) time and space. For each value of f (i, j, k, r) computed by algorithm Suffix, the corresponding LCS of X[1 : i] and Y [1 : j] including P [1 : k] as a subsequence, and including Q[1 : r] as a suffix, can be constructed by backtracking through the computation paths from (i, j, k, r) to (0, 0, 0, 0). The following algorithm back(i, j, k, r) is the backtracking algorithm to obtain the LCS, not only its length. The time complexity of the algorithm back(i, j, k, r) is obviously O(n + m). The second stage of our algorithm is to find LCSs in U (i, j, k). The length of an LCS in U (i, j, k) is denoted as h(i, j, k). Chen et al.[1] presented a dynamic programming algorithm with O(nmt) time and space. A reverse version of the dynamic programming algorithm for computing h(i, j, k) can be described as follows. For each value of h(i, j, k) computed by algorithm SEQ-EC-R, the corresponding LCS of X[i : n] and Y [j : m] excluding Q[k : t] as a subsequence, can be constructed by backtracking through the computation paths from (i, j, k) to (0, 0, 0). The following algorithm backr(i, j, k) is the backtracking algorithm to obtain the corresponding LCS, not only its length. The time complexity of the algorithm backr(i, j, k) is obviously O(n + m). By Theorem 2, the dynamic programming matrices f (i, j, k, r) and h(i, j, k) computed by the algorithms Suffix and SEQ-EC-R can now be combined to obtain the solutions of the STR-IC-SEQ-EC-LCS problem as follows. This is the final stage of our algorithm. 5 Algorithm 1 Suffix Input: Strings X = x1 · · · xn, Y = y1 · · · ym of lengths n and m, respectively, and two constrained sequences P = p1p2 · · · ps and Q = q1q2 · · · qt of lengths s and t Output: f (i, j, k, r), the length of an LCS of X[1 : i] and Y [1 : j] fix, and excluding Q[1 : r] as a subsequence, 0 ≤ r ≤ t. including P [1 : k] as a suf- for all 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ s, and 1: for all i, j, k, r , 0 ≤ i ≤ n, 0 ≤ j ≤ m, 0 ≤ k ≤ s and 0 ≤ r ≤ t do 2: f (i, 0, k, r), f (0, j, k, r) ← −∞, f (i, 0, 0, 0), f (0, j, 0, 0) ← 0 {boundary condition} 3: end for 4: for all i, j, k, r , 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ s and 0 ≤ r ≤ t do 5: if xi 6= yj then 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: f (i, j, k, r) ← max{f (i − 1, j, k, r), f (i, j − 1, k, r)} else if k > 0 and xi = pk then if r = 0 and xi 6= qr then f (i, j, k, r) ← 1 + f (i − 1, j − 1, k − 1, r) else if r = 1 and xi = qr then f (i, j, k, r) ← f (i − 1, j − 1, k, r) else f (i, j, k, r) ← max{1 + f (i − 1, j − 1, k − 1, r − 1), f (i − 1, j − 1, k, r)} end if else if k = 0 then if r = 0 or xi 6= qr then f (i, j, k, r) ← 1 + f (i − 1, j − 1, k, r) else if r = 1 and xi = qr then f (i, j, k, r) ← f (i − 1, j − 1, k, r) else f (i, j, k, r) ← max{1 + f (i − 1, j − 1, k, r − 1), f (i − 1, j − 1, k, r)} end if else f (i, j, k, r) ← f (i − 1, j − 1, k, r) 25: end if 26: end for 6 Algorithm 2 back(i, j, k, r) Input: Integers i, j, k, r Output: The LCS of X[1 : i] and Y [1 : j] including P [1 : k] as a suffix and excluding Q[1 : r] as a subsequence 1: if i < 1 or j < 1 then 2: return 3: end if 4: if xi 6= yj then 5: if f (i − 1, j, k, r) > f (i, j − 1, k, r) then 6: 7: 8: back(i − 1, j, k, r) else back(i, j − 1, k, r) end if 9: 10: else if k > 0 and xi = pk then 11: if r = 0 and xi 6= qr then back(i − 1, j − 1, k − 1, r) print xi else if r = 1 and xi = qr then back(i − 1, j − 1, k, r) else if 1 + f (i − 1, j − 1, k − 1, r − 1) > f (i − 1, j − 1, k, r) then back(i − 1, j − 1, k − 1, r − 1) print xi else back(i − 1, j − 1, k, r) end if 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: end if 23: 24: else if k = 0 then 25: if r = 0 or xi 6= qr then back(i − 1, j − 1, k, r) print xi else if r = 1 and xi = qr then back(i − 1, j − 1, k, r) else if 1 + f (i − 1, j − 1, k, r − 1) > f (i − 1, j − 1, k, r) then back(i − 1, j − 1, k, r − 1) print xi else back(i − 1, j − 1, k, r) end if end if 38: else 39: back(i − 1, j − 1, k, r) 40: end if 7 Algorithm 3 SEQ-EC-R Input: Strings X = x1 · · · xn, Y = y1 · · · ym of lengths n and m, respectively, and a constrained sequence Q = q1q2 · · · qt of lengths t Output: h(i, j, k), the length of an LCS of X[i : n] and Y [j : m] excluding Q[k : t] as a subsequence, for all 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ t. 1: for all i, j, k , 0 ≤ i ≤ n, 0 ≤ j ≤ m, 1 ≤ k ≤ t do 2: h(i, m + 1, k), h(n + 1, j, k) ← −∞ {boundary condition} 3: end for 4: for i = n down to 1 do 5: for j = m down to 1 do 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: for k = t + 1 down to 1 do if xi 6= yj then h(i, j, k) ← max{h(i + 1, j, k), h(i, j + 1, k)} else if k > t or k ≤ t and xi 6= qk then h(i, j, k) ← 1 + h(i + 1, j + 1, k) else if xi = qk then if k = t then h(i, j, k) ← h(i + 1, j + 1, k) else h(i, j, k) ← max{1 + h(i + 1, j + 1, k + 1), h(i + 1, j + 1, k)} end if end if end if end for end for 22: end for 8 Algorithm 4 backr(i, j, k) Input: Integers i, j, k Output: The LCS of X[i : n] and Y [j : m] including P [k : s] as a subsequence 1: if i > n or j > m then 2: return 3: end if 4: if xi 6= yj then 5: if h(i + 1, j, k) > h(i, j + 1, k) then 6: 7: 8: 9: backr(i + 1, j, k) else backr(i, j + 1, k) end if 10: else 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: if k > t or k ≤ t and xi 6= qk then print xi backr(i + 1, j + 1, k) else if xi = qk then if k = t then backr(i + 1, j + 1, k) else if h(i + 1, j + 1, k) > 1 + h(i + 1, j + 1, k + 1) then backr(i + 1, j + 1, k) else print xi backr(i + 1, j + 1, k + 1) end if end if end if 26: end if 9 Algorithm 5 STR-IC-SEQ-EC-LCS Input: Strings X = x1 · · · xn, Y = y1 · · · ym of lengths n and m, respectively, and two constrained sequences P = p1p2 · · · ps and Q = q1q2 · · · qt of lengths s and t Output: The constrained LCS of X and Y including P as a substring, and including Q as a subse- quence. 1: Suffix {compute f (i, j, k, r)} 2: SEQ-EC-R {compute h(i, j, k)} 3: i∗, j∗, k∗ ← 0, tmp ← −∞ 4: for i = 1 to n do 5: for j = 1 to m do 6: 7: 8: 9: 10: 11: 12: for k = 1 to t do x ← f (i, j, s, k) + h(i + 1, j + 1, k) if tmp < x then tmp ← x, i∗ ← i, j∗ ← j, k∗ ← k end if end for end for 13: end for 14: if tmp > 0 then 15: back(i∗, j∗, s, k∗) backr(i∗ + 1, j∗ + 1, k∗) 16: 17: end if 18: return max{0, tmp}, i∗, j∗, k∗ From the 'for' loops of the algorithm, it is readily seen that the algorithm requires O(nmt) time. There- fore, the overall time of our algorithm for solving the STR-IC-SEQ-EC-LCS problem is O(nmst). 4 Improvements of the algorithm S. Deorowicz[3] proposed the first quadratic-time algorithm for the STR-IC-LCS problem. A similar idea can be exploited to improve the time complexity of our dynamic programming algorithm for solving the STR-IC-SEQ-EC-LCS problem. The improved algorithm is also based on dynamic programming with some preprocessing. To show its correctness it is necessary to prove some more structural properties of the problem. Let Z[1 : l] = z1, z2, · · · , zl ∈ Z(n, m, s, t), be a constrained LCS of X and Y including P as a substring and excluding Q as a subsequence. Let also I = (i1, j1), (i2, j2), · · · , (il, jl) be a sequence of indices of X and Y such that Z[1 : l] = xi1 , xi2 , · · · , xil and Z[1 : l] = yj1 , yj2 , · · · , yjl. From the problem statement, there must exist an index d ∈ [1, l − t + 1] such that P = xid , xid+1 , · · · , xid+s−1 and P = yjd , yjd+1 , · · · , yjd+s−1. Theorem 3 Let i′ of X such that xid+e = xi′ d+e . The sequence of indices d = id and for all e ∈ [1, s − 1], i′ d+e be the smallest possible, but larger than i′ d+e−1, index I ′ = (i1, j1), (i2, j2), · · · , (id−1, jd−1), (i′ defines the same constrained LCS as Z[1 : l]. d, jd), (i′ d+1, jd+1), · · · , (i′ d+s−1, jd+s−1), (id+s, jd+s), · · · , (il, jl) Proof. From the definition of indices i′ i′ d+s−1 ≤ id+s−1. The sequence i′ Therefore, both components of I ′ pairs form increasing sequences and for any (i′ I ′ defines the same constrained LCS as Z[1 : l]. d+e, it is obvious that they form an increasing sequence, since i′ d, · · · , i′ d = id, and d+s−1 is of course a compact appearance of P in X starting at id. u = yju . Therefore, u, ju), xi′ The proof is completed. (cid:3) 10 The same property is also true for the jth components of the sequence I. Therefore, we can conclude that when finding a constrained LCS in Z(i, j, k, r), instead of checking any common subsequences of X and Y it suffices to check only such common subsequences that contain compact appearances of P both in X and Y . The number of different compact appearances of Q in X and Y will be denoted by δx and δy, respectively. It is obvious that δxδy ≤ δ, since a pair (i, j) defines a compact appearance of Q in X starting at ith position and compact appearance of Q in Y starting at jth position only for some matches. Base on Theorem 2, we can reduce the time complexity of our dynamic programming from O(nmst) to O(nmt). The improved algorithm consists of also three main stages. Definiton 5 For each occurrence i of the first character p1 of P [1 : s] in X[1 : n], lxi is defined as the index of the last character ps of a compact appearance of P in X. If xi 6= p1 or there is no compact appearance of P after i, then lxi = 0. Similarly, for each occurrence j of the first character p1 of P [1 : s] in Y [1 : m], lyj is defined as the index of the last character ps of a compact appearance of P in Y . In the first stage both sequences X and Y are preprocessed to determine two corresponding arrays lx and ly. Algorithm 6 Prep Input: X, Y Output: For each 1 ≤ i ≤ n, the minimal index r = lxi such that X[i : r] includes P as a subsequence For each 1 ≤ j ≤ m, the minimal quence index r = lyj such that Y [j : r] includes P as a subse- 1: for i = 1 to n do if xi = p1 then 2: 3: 4: 5: lxi ← lef t(X, n, i) else lxi ← 0 6: end if 7: end for 8: for j = 1 to m do if yj = p1 then 9: 10: 11: 12: lyj ← lef t(Y, m, j) else lyj ← 0 13: end if 14: end for In the algorithm Prep, function lef t is used to find the index lxi of the last character ps of a compact appearance of P . In the second stage two DP matrices of SEQ-EC-LCS problem are computed: h(i, j, k), the reverse one defined by Definition 3, and v(i, j, k), the forward one defined by Definition 4. Both of the DP matrices can be computed by the SEQ-EC-LCS algorithm of Chen et al.[1]. In the last stage, two preprocessed arrays lx and ly are used to determine the final results. To this end for each match (i, j) for X and Y the ends (lxi, lyi) of compact appearances of P in X starting at position i and in Y starting at position j are read. The length of an STR-IC-SEQ-EC-LCS, g(n, m, s, t) defined by Definition 1, containing these appearances of P is determined as a sum of three parts. For some indices i, j, k, r, v(i − 1, j − 1, k), the constrained LCS length of prefixes of X and Y ending at positions i − 1 and j − 1, excluding Q[1 : k] as a subsequence, h(lxi + 1, lyj + 1, r) the constrained LCS length of suffixes of X and Y starting at positions lxi + 1 and lyj + 1, excluding Q[r : t] as a subsequence, and the constraint length s. The integers k and r have some relations. 11 Algorithm 7 lef t(X, n, i) Input: Integers n, i and X[1 : n] Output: The minimal index r such that X[i : r] includes P as a subsequence 1: a ← i + 1, b ← 2 2: while a ≤ n and b ≤ s do 3: if xa = pb then 4: 5: 6: 7: b ← b + 1 else a ← a + 1 end if 8: end while 9: if b > s then 10: return a − 1 11: else 12: return 0 13: end if Algorithm 8 SEQ-EC Input: Strings X = x1 · · · xn, Y = y1 · · · ym of lengths n and m, respectively, and a constrained sequence Q = q1q2 · · · qt of length t Output: v(i, j, k), the length of an LCS of X[1 : i] and Y [1 : j] excluding Q[1 : k] as a subsequence, for all 1 ≤ i ≤ n, 1 ≤ j ≤ m, 0 ≤ k ≤ t. 1: for all i, j, k , 0 ≤ i ≤ n, 0 ≤ j ≤ m, 1 ≤ k ≤ t do h(i, 0, k), h(0, j, k) ← −∞ {boundary condition} 2: 3: end for 4: for i = 1 to n do 5: for j = 1 to m do 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: for k = 0 to t do if xi 6= yj then v(i, j, k) ← max{v(i − 1, j, k), v(i, j − 1, k)} else if k = 0 or k > 0 and xi 6= qk then v(i, j, k) ← 1 + v(i − 1, j − 1, k) else if xi = qk then if k = 1 then v(i, j, k) ← v(i − 1, j − 1, k) else v(i, j, k) ← max{1 + v(i − 1, j − 1, k − 1), v(i − 1, j − 1, k)} end if end if end if end for end for 22: end for 12 Algorithm 9 backf (i, j, k) Input: Integers i, j, k Output: The LCS of X[1 : i] and Y [1 : j] excluding Q[1 : k] as a subsequence 1: if i < 1 or j < 1 then 2: return 3: end if 4: if xi 6= yj then 5: if v(i − 1, j, k) > v(i, j − 1, k) then 6: 7: 8: 9: backr(i − 1, j, k) else backr(i, j − 1, k) end if 10: else 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: if k = 0 or k > 0 and xi 6= qk then backr(i − 1, j − 1, k) print xi else if xi = qk then if k = 1 or v(i − 1, j − 1, k) > 1 + v(i − 1, j − 1, k − 1) then backr(i − 1, j − 1, k) else backr(i − 1, j − 1, k − 1) print xi end if end if 22: end if Definiton 6 For each integer k, 1 ≤ k ≤ t, the index α(k) is defined as: α(k) = max 0≤r≤s−k+1 {rP includes Q[k : k + r − 1] as a subsequence} (7) Since the constrained LCS A of prefixes of X and Y ending at positions i − 1 and j − 1, excludes Q[1 : k] as a subsequence, the concatenation of A and P will exclude Q[1 : r] as a subsequence, where r = k + α(k). The constrained LCS B of suffixes of X and Y starting at positions lxi + 1 and lyj + 1, excludes Q[r : t] as a subsequence. Therefore, the concatenation of A,P and B excludes Q as a subsequence. According to the matrices v(i, j, k) and h(i, j, k), backtracking can be used to obtain the optimal subse- quence, not only its length. Theorem 4 The algorithm STR-IC-SEQ-EC-LCS correctly computes a constrained LCS in Z(n, m, s, t). The algorithm requires O(nmt) time and to O(nmt) space in the worst case. Proof. Let Z[1 : l] = z1, z2, · · · , zl be a solution of the STR-IC-SEQ-EC-LCS problem, i.e. Z[1 : l] ∈ Z(n, m, s, t), and its length be denoted as l = g(n, m, s, t). To prove the theorem, we have to prove in fact that g(n, m, s, t) = s + max 1≤i≤n,1≤j≤m,0≤k≤t {v(i − 1, j − 1, k) + h(lxi + 1, lyj + 1, k + α(k))} (8) where h(i, j, k) is the length of an LCS in U (i, j, k) defined by Definiton 3, and v(i, j, k) is the length of an LCS in V (i, j, k) defined by Definiton 4. Since Z[1 : l] ∈ Z(n, m, s, t), Z[1 : l] must be an LCS of X and Y including P as a substring, and excludes Q as a subsequence. Let the first appearance of the string P in Z[1 : l] starts from position l′ − s + 1 to l′ for some positive integer s ≤ l′ ≤ l, i.e. Z[l′ − s + 1 : l′] = P . 13 Algorithm 10 α(k) Input: Integers k Output: The maximum length r (0 ≤ r ≤ s − k + 1) such that P includes P [k : k + r − 1] as a subse- quence 1: a ← k, b ← 1, r ← 0 2: while a ≤ s and b ≤ t do 3: if pa = qb then 4: 5: 6: 7: a ← a + 1, r ← r + 1 else b ← b + 1 end if 8: end while 9: return r Algorithm 11 STR-IC-SEQ-EC-LCS Input: Strings X = x1 · · · xn, Y = y1 · · · ym of lengths n and m, respectively, and two constrained sequences P = p1p2 · · · ps and Q = q1q2 · · · qt of lengths s and t Output: The length of an LCS of X and Y including P as a substring, and excluding Q as a subse- quence. 1: SEQ-EC {compute v(i, j, k)} 2: SEQ-EC-R {compute h(i, j, k)} 3: Prep {compute lx, ly} 4: i∗, j∗, k∗, r∗ ← 0, tmp ← 0 5: for i = 1 to n do 6: for j = 1 to m do 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: if lxi > 0 and lyj > 0 then for k = 1 to t do r ← k + α(k) c ← v(i − 1, j − 1, k) + h(lxi + 1, lyj + 1, r) + s if r > t then tmp ← ∞ end if if tmp < c then tmp ← c, i∗ ← i, j∗ ← j, k∗ ← k, r∗ ← r end if end for end if end for 20: end for 21: if tmp > 0 then 22: backf (i∗ − 1, j∗ − 1, k∗) print P backr(lxi∗ + 1, lyj∗ + 1, r∗) 23: 24: 25: end if 26: return max{0, tmp}, i∗, j∗, k∗, r∗ 14 Let r∗ = max 1≤r≤t {rQ[1 : r] is a subsequence of Z[1 : l′ − s]} Since Z[1 : l′ − s] excludes Q as a subsequence, we have r∗ < t, and thus Z[1 : l′ − s] excludes Q[1 : r∗ + 1] as a subsequence. Let (i∗, j∗) = min 1≤i≤n,1≤j≤m {(i, j)Z[1 : l′ − s + 1] is a common subsequence of X[1 : i] and Y [1 : j]} Then, xi∗ = yj∗ = p1 = zl′−s+1, and xlxi∗ = ylyj∗ = ps = zl′ . Therefore, Z[1 : l′ − s] is a common subsequence of X[1 : i∗ − 1] and Y [1 : j∗ − 1] excluding Q[1 : r∗ + 1] as a subsequence; Z[l′ + 1 : l] is a common subsequence of X[lxi∗ + 1 : n] and Y [lyj∗ + 1 : m]. It follows from Definition 4 that Since Q[1 : r∗] is the longest prefix of Q in Z[1 : l′ − s], and l′ − s ≤ v(i∗ − 1, j∗ − 1, r∗ + 1) (9) α(r∗ + 1) = max {rP includes Q[r∗ + 1 : r∗ + r] as a subsequence} 0≤r≤s−r∗+2 we have, Z[1 : l′] includes Q[1 : r∗ + α(r∗ + 1)] as a subsequence. It follows from Z[1 : l] excludes Q as a subsequence that Z[l′ + 1 : l] excludes Q[r∗ + 1 + α(r∗ + 1) : t] as a subsequence. Therefore, we have Z[l′ + 1 : l] is a common subsequence of X[lxi∗ + 1 : n] and Y [lyj∗ + 1 : m] excluding Q[r∗ + 1 + α(r∗ + 1) : t] as a subsequence. It follows from Definition 3 that l − l′ ≤ h(lxi∗ + 1, lyj∗ + 1, r∗ + 1 + α(r∗ + 1)) (10) Combining formulas (9) and (10) we have, l − s ≤ v(i∗ − 1, j∗ − 1, r∗ + 1) + h(lxi∗ + 1, lyj∗ + 1, r∗ + 1 + α(r∗ + 1)) Therefore, l ≤ s + max 1≤i≤n,1≤j≤m,0≤k≤t {v(i − 1, j − 1, k) + h(lxi + 1, lyj + 1, k + α(k))} (11) On the other hand, for any a ∈ V (i, j, k) and b ∈ U (lxi + 1, lyj + 1, k + α(k)), 1 ≤ i ≤ n, 1 ≤ j ≤ m, 1 ≤ k ≤ t, let c = aL P L b. If lxi > 0 and lyj > 0, then c must be a common subsequence of X[1 : n] and Y [1 : m] including P as a substring. Furthermore, we can prove c excludes Q as a subsequence. In fact, since a excludes Q[1 : k] as a subsequence, the length of the longest prefix of Q in a is at most k − 1, and thus the length of the longest prefix of Q in aL P is at most k − 1 + α(k). Since b is a common subsequence of X[lxi + 1 : n] and Y [lyj + 1 : m] excluding Q[k + α(k) : t] as a subsequence, we have, c = aL P L b is a common subsequence of X[1 : n] and Y [1 : m] including P as a substring and excluding Q as a subsequence, and thus aL P L b ≤ l. Therefore, s + max 1≤i≤n,1≤j≤m,0≤k≤t {v(i − 1, j − 1, k) + h(lxi + 1, lyj + 1, k + α(k))} ≤ l (12) Combining formulas (11) and (12) we have, l = max 1≤i≤n,1≤j≤m,0≤k≤t {v(i − 1, j − 1, k) + h(lxi + 1, lyj + 1, k + α(k))} The time and space complexities of the algorithm are dominated by the computation of the two dynamic programming matrices v(i, j, k) and h(i, j, k). It is obvious that they are all O(nmt) in the worst case. The proof is completed. (cid:3) 15 5 Concluding remarks We have suggested a new dynamic programming solution for the new generalized constrained longest common subsequence problem STR-IC-SEQ-EC-LCS. The first dynamic programming algorithm requires O(nmst) in the worst case, where n, m, s, t are the lengths of the four input sequences respectively. The time complexity can be reduced further to cubic time in a more detailed analysis. Many other generalized constrained longest common subsequence (GC-LCS) problems have similar structures. It is not clear that whether the same technique of this paper can be applied to these problems to achieve efficient algorithms. We will investigate these problems further. References [1] Chen Y.C., Chao K.M. On the generalized constrained longest common subsequence problems, J. Comb. Optim. 21(3), 2011, pp. 383-392. [2] Crochemore M.,Hancart C., and Lecroq T., Algorithms on strings, Cambridge University Press, Cam- bridge, UK, 2007. [3] Deorowicz S., Quadratic-time algorithm for a string constrained LCS problem, Inform. Process. Lett. 112(11), 2012, pp. 423-426. [4] Deorowicz S., Obstoj J., Constrained longest common subsequence computing algorithms in practice, Comput. Inform. 29(3), 2010, pp. 427-445. [5] Gotthilf Z., Hermelin D., Lewenstein M., Constrained LCS: hardness and approximation. In: Proceedings of the 19th annual symposium on combinatorial pattern matching, CPM'08, Pisa, Italy, 2008, pp. 255- 262. [6] Gotthilf Z., Hermelin D., Landau G.M., Lewenstein M., Restricted LCS. In: Proceedings of the 17th international conference on string processing and information retrieval, SPIRE'10, Los Cabos, Mexico, 2010, pp. 250-257. [7] Gusfield, D.,Algorithms on Strings, Trees, and Sequences: Computer Science and Computational Biol- ogy. Cambridge University Press, Cambridge, UK, 1997. [8] Peng Y.H., Yang C.B., Huang K.S., Tseng K.T., An algorithm and applications to sequence alignment with weighted constraints, Int. J. Found. Comput. Sci. 21(1),2010, pp. 51-59. [9] Tang C.Y., Lu C.L., Constrained multiple sequence alignment tool development and its application to RNase family alignment, J. Bioinform. Comput. Biol. 1, 2003, pp. 267-287. [10] Tseng C.T., Yang C.B., Ann H.Y., Efficient algorithms for the longest common subsequence problem with sequential substring constraints. J. Complexity 29, 2013, pp. 44-52. 16
1512.01829
1
1512
2015-12-06T20:35:37
On Routing Disjoint Paths in Bounded Treewidth Graphs
[ "cs.DS" ]
We study the problem of routing on disjoint paths in bounded treewidth graphs with both edge and node capacities. The input consists of a capacitated graph $G$ and a collection of $k$ source-destination pairs $\mathcal{M} = \{(s_1, t_1), \dots, (s_k, t_k)\}$. The goal is to maximize the number of pairs that can be routed subject to the capacities in the graph. A routing of a subset $\mathcal{M}'$ of the pairs is a collection $\mathcal{P}$ of paths such that, for each pair $(s_i, t_i) \in \mathcal{M}'$, there is a path in $\mathcal{P}$ connecting $s_i$ to $t_i$. In the Maximum Edge Disjoint Paths (MaxEDP) problem, the graph $G$ has capacities $\mathrm{cap}(e)$ on the edges and a routing $\mathcal{P}$ is feasible if each edge $e$ is in at most $\mathrm{cap}(e)$ of the paths of $\mathcal{P}$. The Maximum Node Disjoint Paths (MaxNDP) problem is the node-capacitated counterpart of MaxEDP. In this paper we obtain an $O(r^3)$ approximation for MaxEDP on graphs of treewidth at most $r$ and a matching approximation for MaxNDP on graphs of pathwidth at most $r$. Our results build on and significantly improve the work by Chekuri et al. [ICALP 2013] who obtained an $O(r \cdot 3^r)$ approximation for MaxEDP.
cs.DS
cs
On Routing Disjoint Paths in Bounded Treewidth Graphs Andrej Risteski§ Alina Ene∗ Marcin Pilipczuk‡ Matthias Mnich† 5 1 0 2 c e D 6 ] S D . s c [ 1 v 9 2 8 1 0 . 2 1 5 1 : v i X r a Abstract We study the problem of routing on disjoint paths in bounded treewidth graphs with both edge and node capacities. The input consists of a capacitated graph G and a collection of k source-destination pairs M = {(s1, t1), . . . , (sk, tk)}. The goal is to maximize the number of pairs that can be routed subject to the capacities in the graph. A routing of a subset M0 of the pairs is a collection P of paths such that, for each pair (si, ti) ∈ M0, there is a path in P connecting si to ti. In the Maximum Edge Disjoint Paths (MaxEDP) problem, the graph G has capacities cap(e) on the edges and a routing P is feasible if each edge e is in at most cap(e) of the paths of P. The Maximum Node Disjoint Paths (MaxNDP) problem is the node-capacitated counterpart of MaxEDP. In this paper we obtain an O(r3) approximation for MaxEDP on graphs of treewidth at most r and a matching approximation for MaxNDP on graphs of pathwidth at most r. Our results build on and significantly improve the work by Chekuri et al. [ICALP 2013] who obtained an O(r · 3r) approximation for MaxEDP. Introduction 1 In this paper, we study disjoint paths routing problems on bounded treewidth graphs. In this set- ting, we are given an undirected capacitated graph G and a collection of source-destination pairs M = {(s1, t1), (s2, t2), . . . , (sk, tk)}. The goal is to select a maximum-sized subset M0 ⊆ M of the pairs that can be routed subject to the capacities in the graph. More precisely, a routing of M0 is a collection P of paths such that, for each pair (si, ti) ∈ M0, there is a path in P connecting si to ti. In the Maximum Edge Disjoint Paths (MaxEDP) problem, the graph G has capacities cap(e) on the edges and a routing P is feasible if each edge e is in at most cap(e) of the paths of P. The Maximum Node Disjoint Paths (MaxNDP) problem is the node-capacitated counterpart of MaxEDP. Disjoint paths problems are fundamental problems with a long history and significant connections to optimization and structural graph theory. The decision versions of MaxEDP and MaxNDP ask whether all of the pairs can be routed subject to the capacities. Karp showed that, when the number of pairs is part of the input, the decision problems are NP-complete (the node disjoint paths is part of Karp's original list of NP-complete problems [18]). In undirected graphs, MaxEDP and MaxNDP are solvable in polynomial time when the number of pairs is a fixed constant; this is a very deep result of Robertson and Seymour [24] that builds on several fundamental results in structural graph theory from their graph minors project. In this paper, we consider the optimization problems MaxEDP and MaxNDP when the number of pairs are part of the input. These problems are NP-hard and the main focus in this paper is on approximation algorithms for these problems in bounded treewidth graphs. Although they may appear to be quite specialized at first, MaxEDP and MaxNDP on capacitated graphs of small treewidth capture a surprisingly rich class of problems; in fact, as shown by Garg, Vazirani, and Yannakakis [16], these problems are quite interesting and general even on trees. WorstCase). ∗Department of Computer Science and DIMAP, University of Warwick. [email protected] †Institut für Informatik, Universität Bonn. [email protected]. Supported by ERC Starting Grant 306465 (Beyond- ‡Institute of Informatics, University of Warsaw. [email protected]. Research done while at University of Warwick, §Department of Computer Science, Princeton University. [email protected] partially supported by DIMAP and by Warwick-QMUL Alliance in Advances in Discrete Mathematics and its Applications. 1 MaxEDP and MaxNDP have received considerable attention, leading to several breakthroughs both in terms of approximation algorithms and hardness results. MaxEDP is APX-hard even in edge-capacitated trees [16], whereas the decision problem is trivial on trees; thus some of the hardness of the problem stems from having to select a subset of the pairs to route. Moreover, by subdividing the edges, one can easily show that MaxNDP generalizes MaxEDP in capacitated graphs. However, node capacities pose several additional technical challenges and extending the results for MaxEDP to the MaxNDP setting is far from immediate even in restricted graph classes and our understanding of MaxNDP is more limited. n) approximation [6, 19], where n is the number of nodes, whereas the best hardness for undirected graphs is only Ω((log n)1/2−) [2]. Bridging this gap is a fundamental open problem that seems quite challenging at the moment. There have been several breakthrough results on a relaxed version of these problems where congestion is allowed1. This line of work has culminated with a polylog(n) approximation with congestion 2 for MaxEDP [13] and congestion 51 for MaxNDP [5]. In addition to the routing results, this work has led to several significant insights into the structure of graphs with large treewidth and to several surprising applications [4]. In general graphs, the best approximation for MaxEDP and MaxNDP is an O( √ √ n), and this is the main obstacle for improving the O( Most of the results for routing on disjoint paths use a natural multi-commodity flow relaxation as a starting point. A well-known integrality gap instance due to Garg et al. [16] shows that this relaxation has √ an integrality gap of Ω( n) approximation in general graphs. The integrality gap example is an instance on an n × n grid that exploits a topological obstruction in the plane that prevents a large integral routing (see Fig. 2). Since an n × n grid has treewidth Θ( n), it suggests the following natural and tantalizing conjecture that was asked by Chekuri et al. [9]. Conjecture 1 ([9]). The integrality gap of the standard multi-commodity flow relaxation for MaxEDP (and MaxNDP) is Θ(r) with congestion 1, where r is the treewidth of the graph. √ Recently, Chekuri, Naves, and Shepherd [10] showed that MaxEDP admits an O(r · 3r) approximation on graphs of treewidth at most r. This is the first approximation for the problem that is independent of n and k, and the first step towards resolving the conjecture. One of the main questions left open by the work of Chekuri et al. [10] -- that was explicitly asked by them -- is whether the exponential dependency on the treewidth is necessary. In this paper, we address this question and we make a significant progress towards resolving Conjecture 1. Theorem 1.1. The integrality gap of the multi-commodity flow relaxation is O(r3) for MaxEDP in edge- capacitated undirected graphs of treewidth at most r. Moreover, there is a polynomial time algorithm that, given a tree decomposition of G of width at most r and a fractional solution to the relaxation of value OPT, it constructs an integral routing of size Ω(OPT/r3). As mentioned above, MaxNDP in node-capacitated graphs is more general than MaxEDP and it poses several additional technical challenges. In this paper, we give an O(r3) approximation for MaxNDP on graphs of pathwidth at most r with arbitrary node capacities. This is the first result for MaxNDP that is independent of n and it improves the O(r log r log n) approximation of Chekuri et al. [9]. Theorem 1.2. The integrality gap of the multi-commodity flow relaxation is O(r3) for MaxNDP in node- capacitated undirected graphs of pathwidth at most r. Moreover, there is a polynomial time algorithm that, given a path decomposition of G of width at most r and a fractional solution to the relaxation of value OPT, it constructs an integral routing of size Ω(OPT/r3). The study of routing problems in bounded treewidth graphs is motivated not only by the goal of under- standing the integrality gap of the multi-commodity flow relaxation but also by the broader goal of giving a more refined understanding of the approximability of routing problems in undirected graphs. Andrews et al. [2] have shown that MaxEDP and MaxNDP in general graphs cannot be approximated within a factor better than (log n)Ω(1/c) even if we allow a constant congestion c ≥ 1. Thus in order to obtain constant factor 1A collection of paths has an edge (resp. node) congestion of c if each edge (resp. node) is in at most c · cap(e) (resp. c · cap(v)) paths. 2 approximations one needs to use additional structure. However, this seems challenging with our current techniques and there are only a handful of results in this direction. One of the main obstacles for obtaining constant factor approximations for disjoint paths problems is that most approaches rely on a powerful pre-processing step that reduces an arbitrary instance of MaxEDP/MaxNDP to a much more structured instance in which the terminals2 are well-linked. This reduction is achieved using the well-linked decomposition technique of Chekuri, Khanna, and Shepherd [7], which necessarily leads to an Ω(log n) loss even in very special classes of graphs such as bounded treewidth graphs. Chekuri, Khanna, and Shepherd [8] showed that the well-linked decomposition framework can be bypassed in planar graphs, leading to a O(1) approximation for MaxEDP with congestion 4 (the congestion was later improved by Séguin-Charbonneau and Shepherd [26] from 4 to 2). This result suggests that it may be possible to obtain constant factor approximations with constant congestion for much more general classes of graphs. In particular, Chekuri et al. [10] conjecture that this is the case for the class of all minor-free graphs. Conjecture 2 ([10]). Let G be any proper minor-closed family of graphs. Then the integrality gap of the multi-commodity flow relaxation for MaxEDP is at most a constant cG when congestion 2 is allowed. A natural approach is to attack Conjecture 2 using the structure theorem for minor-free graphs given by Robertson and Seymour [23, 25] that asserts that every such graph admits a tree decomposition where the size of every adhesion (the intersection of neighboring bags) is bounded, and after turning the adhesions into cliques, every bag induces a structurally simpler graph: one of bounded genus, with potentially a bounded number of apices and vortices. Thus in some sense, in order to resolve Conjecture 2, one needs to understand the base graph class (bounded genus graphs with apices and vortices) and how to tackle bounded width tree decompositions. The recent work of Chekuri et al. [10] has made a significant progress toward resolving Conjecture 2 by providing a toolbox for the latter issue, and the only ingredient that is still missing is an algorithm for planar and bounded genus graphs with a constant number of vortices (in the disjoint paths setting, apices are very easy to handle). However, one of the main drawbacks of their approach is that it leads to approximation guarantees that are exponential in the treewidth. Our work strengthens the approach of Chekuri et al. [10] and it gives a much more graceful polynomial dependence in the approximation ratio. Theorem 1.3. Let G be a minor-closed class of graphs such that the integrality gap of the multi-commodity flow relaxation is α with congestion β. Let G' be the class of graphs that admit a tree decomposition where, after turning all adhesions into cliques, each bag induces a graph from G, and each adhesion has size at most '. Then the integrality gap of the relaxation for the class G' is O('3) · α with congestion β + 3. We also revisit the well-linked decomposition framework of Chekuri et al. [7] and we ask whether the Ω(log n) loss is necessary for very structured graph classes. For bounded treewidth graphs, we give a well- linked decomposition framework that reduces an arbitrary instance of MaxEDP to node-disjoint instances of MaxEDP that are well-linked. The loss in the approximation for our decomposition is only O(r3), which improves the guarantee of O(log r log n) from Chekuri et al. [9] when r is much smaller than n. It is straightforward to obtain the improved well-linked decomposition from our algorithm for MaxEDP. Nevertheless, we believe it is beneficial to have such a well-linked decomposition, given that well-linked decompositions are one of the technical tools at the heart of the recent algorithms for routing on disjoint paths, integral concurrent flows [3], and flow and cut sparsifiers [12]. In particular, we hope that such a well-linked de- composition will have applications to finding flow and cut sparsifiers with Steiner nodes for bounded treewidth graphs. A sparsifier for a graph G with k source-sink pairs is a significantly smaller graph H containing the terminals (and potentially other vertices, called Steiner nodes) that approximately preserves multi-commodity flows or cuts between the terminals. Such sparsifiers have been extensively studied and several results are known both in general graphs and in bounded treewidth graphs (see Andoni et al. [1] and references therein). A different question one could ask for problems in bounded treewidth graphs is whether additional compu- tational power beyond polynomial-time running time can help with MaxEDP or MaxNDP. It is a standard exercise to design an nO(r)-time dynamic programming algorithm (i.e., polynomial for every constant r) for 2The vertices participating in the pairs M are called terminals. 3 t0 α(t){γ(t) t β(t0) σ(t) β(t) Figure 1: Notations used for a node t with parent t0 in a tree decomposition (T , β). MaxNDP in uncapacitated graphs of treewidth r, while the aforementioned results on hardness of MaxEDP in capacitated trees [16] rule out similar results for capacitated variants. Between the world of having r as part of the input, and having r as a fixed constant, lies the world of parameterized complexity, that asks for algorithms (called fixed-parameter algorithms) with running time f(r)· nc, where f is any computable function, and c is a constant independent of the parameter. It is natural to ask whether allowing such running time can lead to better approximation algorithms. As a first step towards resolving this question, we show a hardness for MaxNDP parameterized by treedepth, a much more restrictive graph parameter than treewidth (cf. [22]). Theorem 1.4. MaxNDP parameterized by the treedepth of the input graph is W[1]-hard, even with unit capacities. Consequently, the existence of an exact fixed-parameter algorithm is highly unlikely. We remark that our motivation for the choice of treedepth as a parameter stems also from the observation that a number of algorithms using the Sherali-Adams hierarchy to approximate a somewhat related problem of Nonuniform Sparsest Cut in bounded treewidth graphs [11, 17] in fact implicitly uses a rounding scheme based on treedepth rather than treewidth. Paper organization. The rest of this paper is organized as follows. In Sect. 2, we formally define the problems and the multi-commodity flow relaxation. In Sect. 3, we give our algorithm for MaxEDP in bounded treewidth graphs and prove Theorems 1.1 and 1.3. In Sect. 4, we extend our MaxEDP algorithm to MaxNDP in bounded pathwidth graphs, and prove Theorem 1.2. We give a well-linked decomposition for edge-capacitated graphs in Sect. 5. Finally, we prove Theorem 1.4 in Sect. 6. 2 Preliminaries Tree and path decompositions. In this paper all tree decompositions are rooted; that is, a tree decom- position of a graph G is a pair (T , β) where T is a rooted tree and β : V (T ) → 2V (G) is a mapping satisfying the following properties: (i) for every e ∈ E(G), there exists a node t ∈ V (T ) with e ⊆ β(t); (ii) for every v ∈ V (G) the set {t : v ∈ β(t)} is nonempty and connected in T . For a node t ∈ V (T ), we call the set β(t) the bag at node t, while for an edge st ∈ E(T ), the set β(t) ∩ β(s) is called an adhesion. For a non-root node t ∈ V (T ), by parent(t) we denote the parent of t, and by σ(t) := β(t) ∩ β(parent(t)) the adhesion on the edge to the parent of t, called henceforth the parent adhesion; for the root node t0 ∈ V (T ) we put σ(t0) = ∅. For two nodes s, t ∈ V (T ), we denote by s (cid:22) t if A torso at node t is a graph obtained from G[β(t)] by turning every adhesion for an edge incident to t into a clique. We say that (A, B) is a separation in G if A ∪ B = V (G) and there does not exist an edge of G with an endpoint in A \ B and the other endpoint in B \ A. We use the following well-known property of a tree decomposition. Lemma 2.1 (Lemma 12.3.1 in [14]). Let (T , β) be a tree decomposition for a graph G. Then for every t ∈ V (T ) the pair (γ(t), V (G) \ α(t)) is a separation of G; note that γ(t) ∩ (V (G) \ α(t)) = σ(t). s is a descendant of t, and put γ(t) :=S s(cid:22)t β(s), α(t) := γ(t) \ σ(t), and G(t) := G[γ(t)] \ E(G[σ(t)]). A path decomposition is a tree decomposition where T is a path, rooted at one of its endpoints. 4 (MaxEDP-LP) max xi kX s.t. X X i=1 p∈P(si,ti) f(p) = xi ≤ 1, i = 1, . . . , k f(p) ≤ cap(e), p: e∈p f(p) ≥ 0, e ∈ E(G) p ∈ P . Figure 2: The multi-commodity flow relaxation for MaxEDP. The instance on the right is the Ω( n) integrality gap example for MaxEDP with unit edge capacities [16]. Any integral routing routes at most one pair whereas there is a multi-commodity flow that sends 1/2 units of flow for each pair (si, ti) along the canonical path from si to ti in the grid. √ The width of a tree or path decomposition (T , β) is defined as maxt β(t)−1. To ease the notation, we will always consider decompositions of width less than r, for some integer r, so that every bag is of size at most r. Problem definitions. The input to MaxEDP is an undirected graph G with edge capacities cap(e) ∈ Z+ and a collection M = {(s1, t1), . . . , (sk, tk)} of vertex pairs. A routing for a subset M0 ⊆ M is a collection P of paths in G such that, for each pair (si, ti) ∈ M0, P contains a path connecting si to ti. The routing is feasible if every edge e is in at most cap(e) paths. In the Maximum Edge Disjoint Paths problem (MaxEDP), the goal is to maximize the number of pairs that can be feasibly routed. The Maximum Node Disjoint Paths problem (MaxNDP) is the node-capacitated variant of MaxEDP in which each node v has a capacity cap(v) and in a feasible routing each node appears in at most cap(v) paths. We refer to the vertices participating in the pairs M as terminals. It is convenient to assume that M form a matching on the terminals; this can be ensured by making several copies of a terminal and attaching them as leaves. Multicommodity flow relaxation. We use the following standard multicommodity flow relaxation for MaxEDP (there is an analogous relaxation for MaxNDP). We use P(u, v) to denote the set of all paths in G from u to v, for each pair (u, v) of nodes. Since the pairs M form a matching, the sets P(si, ti) are pairwise dis- i=1 P(si, ti). The LP has a variable f(p) for each path p ∈ P representing the amount of flow on p. For each pair (si, ti) ∈ M, the LP has a variable xi denoting the total amount of flow routed for the pair (in the corresponding IP, xi denotes whether the pair is routed or not). The LP imposes the constraint that there is a flow from si to ti of value xi. Additionally, the LP has capacity constraints that ensure that the total amount of flow on paths using a given edge (resp. node for MaxNDP) is at the capacity of the edge (resp. node). It is well-known that the relaxation MaxEDP-LP can be solved in polynomial time, since there is an efficient separation oracle for the dual (alternatively, one can write a compact relaxation). We use (f, x) to denote a feasible solution to MaxEDP-LP for an instance (G,M) of MaxEDP. For each terminal v, we also use x(v) to denote the total amount of flow routed for v and we refer to x(v) as the marginal value of v in the multi-commodity flow f. joint. Let P =Sk 3 Algorithm for MaxEDP in Bounded Treewidth Graphs We give a polynomial time algorithm for MaxEDP that achieves an O(r3) approximation for graphs with treewidth less than r. Our algorithm builds on the work of Chekuri et al. [10], and it improves their approximation guarantee from O(r · 3r) to O(r3). We use the following routing argument as a building block. Proposition 3.1 (Proposition 3.4 in [10]). Let (G,M) be an instance of MaxEDP and let (f, x) be a feasible fractional solution for the instance. If there is a second flow that routes at least x(v)/α units of flow 5 s1s2skt1t2tk for each v to some set S ⊆ V (G), where α ≥ 1 then there is an integral routing of at least f 36αS pairs. Our starting point is a tree decomposition (T , β) for G of width less than r and a fractional solution (f, x) to the multicommodity flow relaxation for MaxEDP given in Section 2, that is, the flow f routes x(v) units of flow for each vertex v ∈ V . We let f denote the total amount of flow routed by f, i.e., f = 1 v∈V x(v). 2 P The following definitions play a key role in our algorithm. Definition 3.2 (Safe node). A node t ∈ V (T ) is safe with respect to (f, x) if there is a second multicommodity flow g in G(t) such that g satisfies the edge capacities of G(t) and, for each vertex z ∈ γ(t), g routes at least 4r · x(z) units of flow from z to the adhesion σ(t). The node t is unsafe if it is not safe. 1 Definition 3.3 (Good node). A node t ∈ V (T ) is good with respect to (f, x) if every flow path in the support of f that has an endpoint in γ(t) also intersects σ(t); in other words, there does not exist a flow path that is completely contained in G[α(t)]. A node is bad if it is not good. Remark 3.4. If a node t is good then it is also safe, as shown by the following multicommodity flow g in G(t). For each path p in the support of f that originates in γ(t), let p0 be the smallest prefix of p that ends at a vertex of σ(t) (since p intersects σ(t), there is such a prefix); we set g(p0) = f(p). The resulting flow g is a feasible multicommodity flow in G(t) that routes x(z) units of flow from z to σ(t) for each vertex z ∈ γ(t). Therefore, t is safe. Our approach is an inductive argument based on the maximum size of a parent adhesion that is bad or unsafe. More precisely, we prove the following: Theorem 3.5. Let (G,M) be an instance of MaxEDP and let (f, x) be a fractional solution for (G,M), where f is a feasible multicommodity flow in G for M with marginals x. Let (T , β) be a tree decomposition for G of width less than r. Let '1 be the maximum size of a parent adhesion of an unsafe node, and let '2 be the maximum size of a parent adhesion of a bad node. There is a polynomial time algorithm that constructs an integral routing of size at least (cid:1)'1+'2 · f. 144r3 ·(cid:0)1 − 1 1 r We start with a bit of preprocessing. If f = 0, then we return an empty routing. Otherwise, the root node of T is always unsafe and bad, and the integers '1 and '2 are well-defined. By considering every connected component of G independently (with inherited tree decomposition from (T , β)), we assume that G is connected; note that in this step all safe or good adhesions remain safe or good for every connected component. Further- more, we delete from (T , β) all nodes with empty bags; note that the connectivity of G ensures that the nodes with non-empty bags induce a connected subtree of T . In this step, the root of T may have moved to a different node (the topmost node with non-empty bag), but the parent-children relation in the tree remains unchanged. Once G is connected and no bag is empty, the only empty parent adhesion is the one for the root node. We prove Theorem 3.5 by induction on '1 + '2 + V (G). Base case. In the base case, we assume that '1 = '2 = 0. Since every parent adhesion of a non-root node is non-empty, that implies that the only bad node is the root t0, that is, every flow path in f passes through β(t0), which is of size at most r. By applying Proposition 3.1 with S = β(t0) and α = 1, we construct an integral routing of size at least In the inductive step, we consider two cases, depending on whether 0 ≤ '1 < '2 or 0 < '1 = '2. 36rf ≥ 1 Inductive step when 0 ≤ '1 < '2. Let {t1, t2, . . . , tp} be the topmost bad nodes of T with parent adhesions of size '2, that is, it is a minimal set of such bad nodes such that for every bad node t with parent adhesion of size '2, there exists an i ∈ {1, . . . , p} with t (cid:22) ti. For 1 ≤ i ≤ p, let f inside be the subflow of f consisting of all paths that are completely contained in G[α(ti)]. Furthermore, since '1 < '2, the node ti is safe; let gi be the 4r x(v) from every v ∈ γ(ti) to σ(ti) in G(ti). By applying Propo- Pp corresponding flow, i.e., a flow that routes 1 pairs. Since the subgraphs sition 3.1, there is an integral routing Pi in G(ti) that routes at least i=1 f inside . rf, then we can return the routing P as the desired solution. Otherwise, we drop > 1 r )f. Furthermore, by , every node ti is good with respect to f0. Since deleting a flow path cannot turn a good {G(ti): 1 ≤ i ≤ p} are edge-disjoint, we get an integral routing P :=S IfPp , that is, consider a flow f0 := f −Pp i=1 f inside the flows f inside definition of f inside 144r2f inside 1 i Pi of size at least . Clearly, f0 ≥ (1 − 1 144r3f. i=1 f inside 144r2 1 1 i i i i i i i 6 node into a bad one nor a safe node into an unsafe one, and all descendants of a good node are also good, we infer that every unsafe node with respect to f0 has parent adhesion of size at most '1, while every bad node with respect to f0 has parent adhesion of size less than '2. Consequently, by induction hypothesis we obtain an integral routing of size at least 1 − 1 (cid:19)'1+'2 f. (cid:18) 1 − 1 (cid:19)'1+'2−1 (cid:18) f0 ≥ 1 144r3 r 1 144r3 r Inductive step when 0 < '1 = '2. In this case, we pick a node t◦ to be the lowest node of T that is unsafe and has parent adhesion of size '1. By the definition of an unsafe node and Menger's theorem, there exists a set U ⊆ α(t◦) such that cap(δ(U)) < 1 4rx(U). With a bit more care, we can extract a set U with one more property: Lemma 3.6. In polynomial time we can find a set U ⊆ α(t◦) for which 1. cap(δ(U)) < 1 2. for every non-root node t, if σ(t) ⊆ U, then γ(t) ⊆ U. 4rx(U); Proof. Consider an auxiliary graph G0, obtained from G[γ(t◦)] by adding a super-source s∗, linked for every v ∈ γ(t◦) by an arc (s∗, v) of capacity 1 4rx(v), and a super-sink t∗, linked for every v ∈ σ(t◦) by an arc (v, t∗) of infinite capacity. Let U be such a set that δ(U ∪ {s∗}) is a minimum s∗-t∗ cut in this graph. Clearly, since U is unsafe, cap(δG0(U ∪ {s∗})) < 1 4rx(γ(t◦)) = cap(δG0(s∗)), so U 6= ∅. Also, U ⊆ α(t◦), as each node in σ(t◦) is connected to t∗ with an infinite-capacity arc. We claim that U satisfies the desired properties. The first property is immediate: cap(δG(U)) = cap(δG0(U ∪ {s∗})) − 1 4r x(γ(t◦) \ U) < 1 4r (x(γ(t◦)) − x(γ(t◦) \ U)) = 1 4r x(U). For the second property, pick a non root node t with σ(t) ⊆ U. Since σ(t) ⊆ U ⊆ α(t◦), we have t (cid:22) t◦, t 6= t◦, and γ(t) ⊆ α(t◦). Let U0 := U ∪ γ(t). By Lemma 2.1, δG(U0) ⊆ δG(U), and hence δG0(U0 ∪ {s∗}) ⊆ δG0(U ∪ {s∗}). However, since δG0(U ∪ {s∗}) is a minimum cut, we have actually δG(U0) = δG(U). Since G is connected, this implies that U = U0, and thus γ(t) ⊆ U. As the choice of t was arbitrary, U satisfies the second property. Using the cut U, we split the graph G and the flow f into two pieces as follows. Let G1 = G[U] and G2 = G − U. Let fi be the restriction of f to Gi, i.e., the flow consisting of only flow paths that are contained in Gi. Let xi be the marginals of fi and let Mi be the subset of M consisting of all pairs (s, t) such that {s, t} ⊆ V (Gi); note that xi(s) = xi(t) for each pair (s, t) ∈ Mi and thus (fi, xi) is a fractional routing for the instance (Gi,Mi). Let (T , β1) and (T , β2) be the restriction of (T , β) to the vertices of G1 and G2, respectively; we define mappings σi, γi, and αi naturally. In what follows, we consider separately two instances Ii := h(Gi,Mi), (fi, xi), (T , βi)i for i = 1, 2. An important observation is the following: Lemma 3.7. Every node t ∈ V (T ) that is good in the original instance (i.e., as a node of T , with respect to (f, x)) is also good in Ii with respect to (fi, xi). Proof. Note that every flow path in fi is also present in f, and therefore intersects the parent adhesion of f if t is a good node in the original instance. Consequently, every node t ∈ V (T ) with σ(t) > '2 is good in the instance Ii, and the maximum size of a parent adhesion of a bad node in instance Ii is at most '2. Hence, both I1 and I2 satisfy the assumptions of Theorem 3.5 with not larger values of '1 and '2. Furthermore, note that V (Gi) < V (G) for i = 1, 2. For I2, the above reasoning allows us to simply just apply inductive step, obtaining an integral routing P2 of size at least (cid:18) 1 − 1 (cid:19)'1+'2 · f2 . r P2 ≥ 1 144r3 7 For I1, we are going to obtain a larger routing via an inductive step with better bounds. (1) Lemma 3.8. The size of the largest parent adhesion of an unsafe note in I1 is less than '1. Proof. Assume the contrary, let t ∈ V (T ) be an unsafe adhesion with σ1(t) ≥ '1. If σ(t) > '1, then t is good in the original instance, and by Lemma 3.7 it remains good in I1. Consequently, σ(t) = σ1(t) = '1; in particular, σ(t) = σ1(t) ⊆ U. By Lemma 3.6, property 2, we have γ(t) ⊆ U. Consequently, t is safe in the original instance if and only if it is safe in I1. Since t (cid:22) t◦, t 6= t◦, but σ(t) = '2, by the choice of t◦ it holds that t is safe in the original instance, a contradiction. Lemma 3.8 allows us to apply the inductive step to I1 and obtain an integral routing P1 of size at least (2) Let us now estimate the amount of flow lost by the separation into I1 and I2, i.e., g = f − f1 − f2. As 2x(U) (no 4rx(U). Since f1 + g ≥ 1 r P1 ≥ 1 144r3 1 − 1 (cid:18) (cid:19)'1−1+'2 · f1 . (3) every flow path in g passes through δ(U), we have g ≤ cap(δ(U)) < 1 (cid:18) flow path in f2 originates in U), we have that g ≤ 1 1 − 1 2r (cid:19)'1+'2 (cid:19)'1+'2 (cid:19)−1 4r · 2 · (f1 + g) . Hence, (cid:18) 1 − 1 g ≤ 1 2r (cid:18) (cid:18) By putting up together (1), (2), and (3), we obtain that f1 ≤ 1 (cid:19)−1 1 − 1 f2 + f1 . ! f1 · r r r P1 + P2 ≥ 1 144r3 ≥ 1 144r3 (cid:18) 1 − 1 (cid:19)'1+'2 f . r r 1 − 1 (f2 + f1 + g) = 1 144r3 This concludes the proof of Theorem 3.5. Since '1, '2 ≤ r, while (1 − 1 r )2r = Ω(1), Theorem 3.5 immediately implies the promised O(r3)-approximation algorithm. Remark 3.9. We conclude with observing that the improved approximation ratio of O(r3) directly translates to the more general setting of k-sums of graph from some minor closed family G, as discussed in [10]. That is, if we are able to α-approximate MaxEDP with congestion β in graphs from G, we can have O(αr5)- approximation algorithm with congestion (β + 3) in graphs admitting a tree decomposition of maximum adhesion size at most r, and the torso of every bag being from the class G. To see this, observe that the only place when our algorithm uses that the bags are of bounded size (as opposed to adhesions) is the base case, where all flow paths pass through the bag β(t0) of the root node t0. However, in this case we can proceed exactly as Chekuri et al. [10]: using the flow paths, move the terminals to β(t0), replace connected components of G − β(t0) with their (r2, 2)-sparsifiers, and apply the algorithm for the class G. In addition to the O(r3) approximation factor of our algorithm, the application of the algorithm for G incurs an approximation ratio of α and congestion of β, the use of sparsifiers adds a factor of r2 to the approximation ratio and an additive constant +1 to the congestion, while the terminal move adds an additional amount of 2 to the final congestion. 4 Algorithm for MaxNDP in Bounded Pathwidth Graphs In this section we develop an O(r3)-approximation algorithm for MaxNDP in graphs of pathwidth less than r. We follow the outline of the MaxEDP algorithm from the previous section, with few essential changes. Most importantly, we can no longer use Proposition 3.1, as it refers to edge disjoint paths, and the proof of its main ingredient by Chekuri et al. [6] relies on a clustering technique that stops to work for node disjoint paths. We fix this issue by providing in Sect. 4.1 a node-disjoint variant of Proposition 3.1, using the more involved clustering approach of Chekuri et al. [7]. 8 Then, in Sect. 4.2 we revisit step-by-step the arguments for MaxEDP, pointing out remaining differences. We remark that the use of pathwidth instead of treewidth is only essential in the inductive step for the case '1 < '2: if we follow the argument for MaxEDP for bounded-treewidth graphs, the graphs G(ti) may not be node disjoint (but they are edge disjoint), breaking the argument. Note that for bounded pathwidth graphs, there is only one such graph considered, and the issue is nonexistent. 4.1 Routing to a small adhesion in a node-disjoint setting In this section we prove the following statement. Proposition 4.1. Let (G,M) be an instance of MaxNDP and let (f, x) be a feasible fractional solution for the instance. Suppose that there is also a second (feasible, i.e., respecting node capacities) flow that routes at least x(v)/α units of flow for each v to some set S ⊆ V , where α ≥ 1. Then there is an integral routing of Ω(f/(αS)) pairs. Without loss of generality, we may assume that the terminals of M are pairwise distinct and of degree and ca- pacity one: we can always move a terminal from a vertex t to a newly-created degree-1 capacity-1 neighbour of t. Let g be the second flow mentioned in the statement. In what follows, we modify and simplify the flows f and g in a number of steps. We denote by f1, f2, . . . and g1, g2, . . . flows after subsequent modification steps; for the flow fi, by xi we denote its marginals. Symmetrizing the flow g. In the first step, we construct flows f1 and g1 with the following property: for every terminal pair (s, t) ∈ M, for every v ∈ S, g1 sends the same amount of flow from s to v as from t to v. To obtain this goal, we first take the flow g/3, and then for every (s, t) ∈ M redirect the flow originating at s to first go along the commodity for the pair (s, t) in flow f /(3α) to the vertex t, and then go to S in exactly the same manner as the flow originating at t does. It is easy to see that g1 consists of three feasible flows scaled down by at least 1/3, thus it is feasible. Finally, we set f1 := f /3, so that g1 again sends x1(v)/α flow from every vertex v to S. Note that f1 = f/3. Restricting to single vertex of S. To construct flows f2 and g2, pick a vertex u ∈ S that receives the most flow in g1. Take g2 to be the flow g1, restricted only to flow paths ending in u. Then, restrict f1 to obtain f2 as follows: for every terminal pair (s, t) ∈ M, reduce the amount of flow from s to t to α times the total amount of flow sent from s to u by g2; note that, by the previous step, it is also equal α times the total amount of flow sent from t to u by g2. By this step, we maintain the invariant that g2 sends x2(v)/α flow from every v ∈ V (G), and we have f2 ≥ f1/S ≥ f/(3S). Rounding to a half-integral flow. In the next step, we essentially repeat the integral rounding procedure by Chekuri et al. [6, Section 3.2]. We use the following operation as a basic step in the rounding. Lemma 4.2 (Theorem 2.1 of [6]). Let G be a directed graph with edge capacities. Given a flow h in G that goes from set X ⊆ V (G) to a single vertex u ∈ V (G), such that for every v ∈ X the amount of flow originating in v is z(v), and a vertex v0 ∈ X such that z(v0) is not an integer, one can in polynomial time compute a flow h0 in G, sending z0(v) amount of flow from every v ∈ X to u, such that h0 ≥ h, z0(v) = z(v) for every v ∈ X where z(v) is an integer, and z0(v0) = dz(v0)e. ones3, Lemma 4.2 applies also to undirected graphs with integral node capacities. Since a standard reduction reduces flows in undirected node-capacitated graphs to directed edge-capacitated Split g2 into two flows hs and ht: for every terminal pair (s, t) ∈ M, we put the flow originating in s into hs, and the flow originating in t into ht. We perform a sequence of modifications to the flows hs and ht, maintaining the invariant that the same amount of flow originates in s in hs as in t in ht for every (s, t) ∈ M. Along the process, both hs and ht are feasible flows, but hs + ht may not be. In a single step, we pick a terminal pair (s, t) ∈ M such that the amount of flow in hs originating in s is not integral (and stop if no such pair exists). We apply Lemma 4.2 separately to s in hs and to t in ht, 3Replace every edge with two infinite-capacity arcs in both directions, and then split every vertex into two vertices, connected by an edge of capacity equal to the capacity of the vertex, with all in-edges connected to the first copy, and all out-edges connected to the second copy. 9 s and h0 s + h◦ t from t0). s from s0 and by h0 t ≥ (hs + ht)/2 = g2/2 = f2/α ≥ f/(3αS). Finally, we define g3 := (h◦ t. Finally, if for some terminal pair (s0, t0), the amount of flow originating in s0 in h0 obtaining flows h0 and in t0 in h0 t differ, we restrict one of the flows so that both route the same amount of flow (being the minimum of the flows routed by h0 Since the rounding algorithm of Lemma 4.2 never modifies a source that already has an integral flow, this procedure stops after at most M steps. Furthermore, if in one step the flow from s has been increased from z to dze, the total loss of flow to other pairs is 2(dze − z). Therefore, if h◦ t are the final integral flows, we have h◦ t )/2; note that g3 is a feasible flow, since both h◦ Clustering a node-flow-linked set. Note that for every (s, t) ∈ M, the flow g3 routes either 0 or 1/2 flow from both s and t to u. Let M0 be the set of pairs for which the flow is 1/2, and let X0 be the set of terminals in M0. Note that M0 = g3/2 ≥ f/(6αS). (a, b) ∈ X0 × X0 routes from u. This allows us to apply the following clustering result. Lemma 4.3 (Lemma 2.7 of [7]). If X is α-node-flow-linked in a graph G with unit node capacities, then for any h ≥ 2 there exists a forest F in G of maximum degree O( 1 α log h) such that every tree in F spans at least h nodes from X. 4-node-flow-linked: using g3, we can find a multicommodity flow that for every 1 4X amount of flow from a to b, by routing it along g3 to u and along reversed g3 Observe that the set X0 is 1 s and h◦ s and h◦ t are. s s + h◦ i 1, T 0 2, . . . , T 0 Since we can assume that no capacity in G exceeds M, we can replace every vertex v of capacity cap(v) with its cap(v) copies. To such unweighted graph G0 we apply Lemma 4.3 for X0, α = 1/4 and h = 3, obtaining a forest F 0; recall that the terminals X0 are of capacity 1, thus they are kept unmodified in G0. By standard argument we split the forest F 0 into node-disjoint trees T 0 p, such that every tree T 0 contains at least three, and at most d = O(1) terminals of X0. By projecting the trees T 0 i back onto G, we obtain a sequence of trees T1, T2, . . . , Tp, such that every vertex v ∈ V (G) is present in at most cap(v) trees Ti. Furthermore, since terminals are of capacity one, every terminal belongs to at most one tree, and every tree Ti contains at least three and at most d terminals. In a greedy fashion, we chose a set M00 ⊆ M0 of size at least M0/d2, such that for every tree Ti, at most one terminal pair of M00 has at least one terminal in Ti. A pair (s, t) ∈ M00 is local if both s and t lie in the same tree Ti, and distant otherwise. If at least half of the pairs of M00 are local, we can route them along trees Ti, obtaining a desired routing of size at least M00/2 ≥ M0/(2d2) = Ω(f/(αS)) and terminate the algorithm. Otherwise, we obtain a flow g4 as follows: for every terminal t in a distant pair in M00, we take the tree Ti it lies on, route 3/5 amount of flow along Ti equidistributed to three arbitrarily chosen terminals t1, t2, t3 on Ti from M0 (i.e., every terminal tj receives 1/5 amount of flow), and then route the flow along the flow 2 5 g3 to u. Since every tree Ti routes 3/5 amount of flow, and g3 is a feasible flow, the flow g4 is a feasible flow that routes 3/5 amount of flow from every terminal of M00 to u. Furthermore, since at least half terminal pairs in M00 is distant, we have g4 ≥ 1 Final rounding of the flow. Let X00 be the set of all terminals of M00. Since the flow g4 routes more than 1/2 amount of flow for every terminal in X00, we can conclude with simple rounding the flow g4 in the same manner as it is done by Chekuri et al. [6, Section 3]. Construct an auxiliary graph G0 by adding a super-source s∗ of infinite capacity, adjacent to all terminals of M00. Extend g4 in the natural manner, by routing every flow path first from s∗ to an appropriate terminal. The extended flow g4 is now a single souce single sink flow from s∗ to u in a graph with integer capacities, thus there exists an integral flow g5 of no smaller size: 2 · 2M00 = Ω(f/(αS)). g5 ≥ g4 = 3 5X00 = 6 5M00. Hence, for at least 1/5 of the pairs (s, t) ∈ M00, the flow g5 routes a single unit of flow both from s and from t to u. By combining these paths into a single path from s to t, we obtain an integral routing of size at least 5M00 = Ω(f/(αS)). This finishes the proof of Proposition 4.1. 1 10 4.2 Details of the algorithm Equipped with Proposition 4.1, we can now proceed to the description of the approximation algorithm. Assume we are given an MaxNDP instance (G,M) and a path decomposition (T , β) of G of width less than r; recall that T rooted in one of its endpoints. Let (f, x) be a fractional solution to the multicommodity flow relaxation for MaxNDP, as in Section 2. The definitions of safe and good node are analogous, and we follow the same induction scheme. Definition 4.4 (Safe node). A node t ∈ V (T ) is safe with respect to (f, x) if there is a second multicommodity flow g in G(t) such that g satisfies the node capacities of G(t) and, for each vertex z ∈ γ(t), g routes at least 4r · x(z) units of flow from z to the adhesion σ(t). The node t is unsafe if it is not safe. 1 Definition 4.5 (Good node). A node t ∈ V (T ) is good with respect to (f, x) if every flow path in the support of f that has an endpoint in γ(t) also intersects σ(t); in other words, there does not exist a flow path that is completely contained in G[α(t)]. A node is bad if it is not good. Theorem 4.6. Let (G,M) be an instance of MaxNDP and let (f, x) be a fractional solution for the instance, where f is a feasible multicommodity flow in G for the pairs M with marginals x. Let (T , β) be a path decomposition for G of width less than r. Let '1 be the maximum size of a parent adhesion of an unsafe node, and let '2 be the maximum size of a parent adhesion of a bad node. There is a constant c and a polynomial time algorithm that constructs an integral routing of size at least (cid:18) 1 − 1 (cid:19)'1+'2 · f . r 1 cr3 · Again as in the case of MaxEDP, we can assume that the considered graph G is connected and that no bag is empty, and thus the only empty adhesion is the parent adhesion of the root. Base case. In the base case '1 = '2 = 0 nothing changes as compared to MaxEDP: all flow paths pass through the root bag, and Proposition 4.1 allows us to route integrally Ω(f/r) paths. Inductive step when 0 ≤ '1 < '2. Since we are considering now a path decomposition (as opposed to tree decomposition in the previous section), there exists a single topmost bad node t◦ with parent adhesion of size '2. Define f inside to be the subflow of f consisting of all flow paths completely contained in G[α(t◦)]. Since '1 < '2, the node t◦ is safe, and the flow witnessing it together with Proposition 4.1 allows us to integrally route Ω(f inside/r2) terminal pairs. If f inside > f/r, then we are done. Otherwise, we drop the flow f inside from f, making t◦ and all its descendants good (thus decreasing '2 in the constructed instance), while losing only 1/r fraction of the flow f, and pass the instance to an inductive step. Inductive step when 0 < '1 = '2. Here again we take t◦ to be the lowest node of T that is unsafe and has parent adhesion of size '1. By the definition of an unsafe node and Menger's theorem, there exists a set U ⊆ α(t◦) such that cap(N(U)) < 1 4rx(U). Using the same argument as in the proof of Lemma 3.6, we can ensure property 2, that is that if U contains an adhesion σ(t), it contains as well the entire set γ(t). As in the case of MaxEDP, we split into instances I1 and I2 by taking G1 = G[U] and G2 = G − N[U], with inherited tree decompositions from (T , β). Since all nodes with parent adhesions of size larger than '1 = '2 are good, there are also good in instances Ii (i.e., Lemma 3.7 holds here as well) and we can again apply the inductive step to every connected component of the instance I2 with the same values of '1 and '2, obtaining a routing P2 of size as in (1) (with 144 replaced by a constant c). We analyse the instance I1, without breaking it first into connected components. That is, we argue that in I1 the value of '1 dropped, that is, all nodes t satisfying σ(t) = σ1(t) = '1 are safe; note that they will remain safe once we consider every connected component separatedly. However, this fact follows from property 2 of the set U (Lemma 3.6): if for some node t we have σ(t) = σ1(t), it follows that σ(t) ⊆ U hence γ(t) ⊆ U and the notion of safeness for t is the same in I1 and in the original instance. However, σ(t) ⊆ U ⊆ α(t◦) implies t (cid:22) t◦ and t 6= t◦, hence t is safe in the original instance. Consequently, an application of inductive step for every connected component of I1 uses strictly smaller value of '1, and we obtain an integral routing P1 in I1 of size as in (2) (again with 144 replaced by a constant c). The remainder of the analysis from the previous section does not change, concluding the proof of Theorem 4.6.(cid:3) 11 is routable. The sparsity of a cut S ⊆ V is the ratio δ(S)/demd(S), where demd(S) =P 5 Well-linked decomposition In this section, we show that the argument given in Section 3 gives the following well-linked decomposition for edge-capacitated graphs. We first give some preliminary definitions. Multi-commodity flows. We represent a multi-commodity flow instance as a demand vector d that assigns a demand d(u, v) ∈ R+ to each ordered pair (u, v) of vertices of G. A product multi-commodity flow instance satisfies d(u, v) = w(u)w(v) for each pair (u, v), where w : V → R+ is a weight functions on the vertices of G. We say that d is routable if there is a feasible multi-commodity flow in G that routes d(u, v) units of flow from u to v for each pair (u, v). We recall the following two quantities associated with a multi-commodity flow instance: the maximum concurrent flow and the sparsest cut. The maximum concurrent flow is the maximum value λ ≥ 0 such that λd u∈S,v∈V \S d(u, v) is the total demand separated by S. A sparsest cut is a cut with minimum sparsity. The minimum sparsity of any cut is an upper bound on the maximum concurrent flow, and the former could be strictly larger. The flow-cut gap is the worst-case ratio between the sparsest cut and the maximum concurrent flow. The flow-cut gap is O(log k) in general graphs, where k is the number of commodities (that is, the number of non-zero demands d(u, v)) [20]. For product multi-commodity flows, the flow-cut gap is O(log r) for graphs of treewidth r [9]. Moreover, for both of these results, there are polynomial time algorithms for computing a cut with sparsity at most α(G) · λ, where α(G) is the flow-cut gap value and λ is the maximum concurrent flow for d [20, 9]. Well-linked sets. Following [7], we work with two notions of well-linked sets, cut well-linked sets and flow well-linked sets. For convenience, we work with graphs with unit edge capacities; it is straightforward to extend the argument to arbitrary edge capacities. Let π : X → R+ be a weight function on a set X ⊆ V (G) of vertices. The set X is π-flow-well- linked in G if there is a feasible multi-commodity flow that simultaneously routes d(u, v) := π(u)π(v)/π(X) units of flow from u to v for every pair (u, v) of nodes in X. The set X is π-cut-well-linked in G if δ(S) ≥ min {π(S ∩ X), π((V \ S) ∩ X)}. Chekuri et al. [7] gave the following well-linked decomposition theorem for general graphs that has found many applications. We only state the theorem for flow-well-linked instances, there is an analogous result for cut-well-linked instances. Theorem 5.1 ([7]). Let OPT be the value of a solution to MaxEDP-LP for a given instance (G,M) of MaxEDP on a general graph G. Let α = α(G) ≥ 1 be an upper bound on the worst case flow-cut gap for product multi-commodity flows in G. There is a partition of G into node-disjoint induced subgraphs G1, G2, . . . , Gq and weight functions πi : V (Gi) → R+ with the following properties. Let Mi be the induced pairs of M in Gi and let Xi be the endpoints of the pairs in Mi. We have (a) πi(u) = πi(v) for each pair uv ∈ Mi. (b) Xi is πi-flow-well-linked in Gi. (c) Pq i=1 πi(Xi) = Ω(OPT/(α log OPT)) = Ω(OPT/ log2 k). Moreover, such a partition is computable in polynomial time if there is a polynomial time algorithm for computing a node separator with sparsity at most α(G) times the maximum concurrent flow. In the remainder of this section, we show that, for graphs with treewidth at most r, the argument in Sect. 3 implies a well-linked decomposition that loses a factor of O(r3) instead of O(log2 k). Theorem 5.2. Let OPT be the value of a solution to MaxEDP-LP for a given instance (G,M) of MaxEDP on a graph G of treewidth at most r. There is a partition of G into node-disjoint induced subgraphs G1, G2, . . . , Gq and weight functions πi : V (Gi) → R+ with the following properties. Let Mi be the induced pairs of M in Gi and let Xi be the endpoints of the pairs in Mi. We have (a) πi(u) = πi(v) for each pair uv ∈ Mi. 12 (b) There is a feasible multi-commodity flow gi in Gi from Xi to a single vertex z that routes πi(v) units of flow from v to z for each vertex v ∈ Xi. Thus Xi is πi-flow-well-linked in Gi. (c) Pq i=1 πi(Xi) = Ω(OPT/r3). Moreover, such a partition is computable in polynomial time if one is given a tree decomposition of G of width at most r. We use the definitions and notation introduced in Section 3. In the remainder of this section, we show how to modify the argument in Section 3 to prove Theorem 5.2. As before, our starting point is a fractional solution (f, x) to MaxEDP-LP for the instance (G,M). We prove the following theorem by induction on the maximum size of a parent adhesion that is bad or unsafe. Theorem 5.3. Let (G,M) be an instance of MaxEDP and let (f, x) be a fractional solution for the instance, where f is a feasible multicommodity flow in G for the pairs M with marginals x. Let (T , β) be a tree decomposition for G of width less than r. Let '1 be the maximum size of a parent adhesion of an unsafe node, and let '2 be the maximum size of a parent adhesion of a bad node. There is a polynomial time algorithm that constructs a partition of G into node-disjoint induced subgraphs G1, G2, . . . , Gq and weight functions πi : V (Gi) → R+ with the following properties. Let Mi be the induced pairs of M in Gi and let Xi be the endpoints of the pairs in Mi. We have (a) πi(u) = πi(v) for each pair uv ∈ Mi. (b) There is a feasible multi-commodity flow gi in Gi from Xi to a single vertex z that routes πi(v) units of flow from v to z for each vertex v ∈ Xi. Thus Xi is πi-flow-well-linked in Gi. (c) Pq i=1 πi(Xi) ≥ 1 12r3 ·(cid:0)1 − 1 r (cid:1)'1+'2 · f. In addition to the definitions of a good and safe node from Section 3, it is convenient to have the following definition. Definition 5.4 (Nice flow). A multi-commodity flow f is nice for a node t ∈ V (T ) if there exists a single vertex z ∈ σ(t) such that each flow path P in the support of f ends at z and P − z is contained in G[α(t)]. The proof of the following lemma follows from a result by Chekuri et al. [10, Proposition 3.4], and we include it for completeness. Lemma 5.5. Consider a node t ∈ V (T ). Let M be a collection of pairs with both endpoints in α(t) such that each vertex of α(t) appears in at most one pair. Let f be a multi-commodity flow in G[α(t)] with marginals x satisfying x(u) = x(v) for each pair (u, v) ∈ M. Suppose that there is a second multi-commodity flow g in G(t) that routes at least x(v)/c units of flow for each vertex v ∈ V (M) to σ(t), where c ≥ 1. Then there is a multi-commodity flow h from V (M) to z with the following properties: h is nice for t; for each pair (u, v) ∈ M, h routes the same amount of flow for u and v; h ≥ 1 Proof. Note that we may assume that each flow path in the support of G(t) is contained in G[α(t)] except for its end vertex. Let z ∈ σ(t) be a vertex that receives the most g-flow, where the g-flow received by z is P the total amount of flow on paths ending at z. Let g0 be the sub-flow of g consisting of only the flow paths ending at z, and let x0 be the marginals of g0. v∈α(t) f. However, there may be pairs (u, v) ∈ M for which x0(u) 6= x0(v). We use the flow f to ensure the latter property as follows. Consider a pair (u, v) ∈ M such that x0(u) 6= x0(v), and suppose without loss of generality that x0(u) < x0(v). We create x0(v) units of flow from u to z as follows: since x0(v) ≤ x(v)/c, we can route x0(v) units of flow from u to v using the flow paths of f and then route x0(v) units of flow from v to z using the flow paths of g0. Therefore f + 2g0 contains a congestion three sub-flow that routes x0(u) = x0(v) units of flow for each pair (u, v) ∈ M. If we scale down this flow by a factor of 3, we obtain a feasible flow h with the desired properties. Note that x0(v) ≤ x(v)/c for every v ∈ V (M) and g0 ≥ 1 3cσ(t) · f ≥ 1 3cr · f. cσ(t) 13 no bag is empty. We preprocess the tree decomposition as in Section 3. Thus we may assume that G is connected and We prove Theorem 3.5 by induction on '1 + '2 + V (G). Base case. In the base case, we assume that '1 = '2 = 0. Since every parent adhesion of a non-root node is non-empty, that implies that the only bad node is the root t0, that is, every flow path in f passes through β(t0), which is of size at most r. We can obtain a flow g from M to β(t0) as follows: for each path P in the support of f, let P 0 be the smallest prefix of P that ends at a vertex of β(t0), and let g(P 0) = f(P) (since each path P in the support of f intersects β(t0), there exists such a prefix P 0). Using the flows f and g, we can construct a flow h in G from V (M) to a single vertex z ∈ β(t0) with marginals π such that π(u) = π(v) for each pair (u, v) ∈ M and h ≥ 1 3rf. (This follows from the argument used in the proof of Lemma 5.5.). Thus (G, π) is the desired decomposition. In the inductive step, we consider two cases, depending on whether 0 ≤ '1 < '2 or 0 < '1 = '2. The latter case can be handled in the same way as in Section 3. The former case requires a different argument. Inductive step when 0 ≤ '1 < '2. Let {t1, t2, . . . , tp} be the topmost bad nodes of T with parent adhesions of size '2, that is, it is a minimal set of such bad nodes such that for every bad node t with parent adhesion of size '2, there exists 1 ≤ i ≤ p with t (cid:22) ti. For 1 ≤ i ≤ p, let f inside be the subflow of f consisting of all paths that are completely contained in G[α(ti)]. Furthermore, since '1 < '2, the node ti is safe; let gi be 4r x(v) from every v ∈ γ(ti) to σ(ti) in G(ti). By applying the corresponding flow, i.e., a flow that routes 1 Lemma 5.5, for each i such that 1 ≤ i ≤ p, there is a flow hi that is nice for ti and satisfies hi ≥ 1 12r2f inside . rf, we construct the desired decomposition as follows. Let zi ∈ σ(ti) be the end- point of all the flow paths of hi. Let Hi = G[α(ti)] ∪ {zi}. Note that hi is completely contained in Hi and the graphs Hi are node-disjoint except for the vertices zi. We group together the graphs with the If Pp same zi vertex as follows. For each distinct vertex z ∈ {z1, . . . , zp}, let Hz =S{Hi : 1 ≤ i ≤ p, zi = z} and hz =P{hi : 1 ≤ i ≤ p, zi = z}. Note that hz is a feasible flow in Hz whose flow paths all end at z. The Therefore we may assume thatPp a flow f0 := f−Pp i=1 f inside . Clearly, f0 ≥ (1− 1 i=1 f inside desired decomposition has a component (Hz, πz) for each distinct vertex z, where πz are the marginals of hz. , that is, consider , every node ti is good with respect to f0. Since deleting a flow path cannot turn a good node into a bad one nor a safe node into an unsafe one, and all descendants of a good node are also good, we infer that every unsafe node with respect to f0 has parent adhesion of size at most '1, while every bad node with respect to f0 has parent adhesion of size less than '2. Consequently, by induction hypothesis we obtain a decomposition (G1, π1), . . . , (Gq, πq) satisfying ≤ 1 rf. In this case, we drop the flows f inside r )f. Furthermore, by the definition of f inside i=1 f inside > 1 i i i i i i (cid:18) (cid:19)'1+'2 f. i qX i=1 (cid:18) (cid:19)'1+'2−1 πi(Xi) ≥ 1 12r3 1 − 1 r f0 ≥ 1 12r3 1 − 1 r Inductive step when 0 < '1 = '2. This case follows from the argument given in Section 3. We define two node-disjoint instances I1 and I2 exactly as before. We apply the induction hypothesis to each of the instaces and obtain a decomposition for each. Since the instances are node-disjoint, the union of the two decompositions is the desired decomposition. This concludes the proof of Theorem 5.3, which immediately implies Theorem 5.2. (cid:3) 6 Hardness for MaxNDP in bounded treedepth graphs In this section we prove Theorem 1.4. We reduce from the W[1]-hard Multicolored Clique problem [15], where given a graph G, an integer k, and a partition V = V 1 ] V 2 ] . . .] V k, we are to check if there exists k-clique in G with exactly one vertex in every set V i. By adding dummy vertices, we can assume that V i = n for every 1 ≤ i ≤ k, and that n, k ≥ 2. Construction. Given an instance (G, k, (V i)k equivalent instance (H,M, ') of MaxNDP. i=1) of Multicolored Clique, we aim at constructing an 14 v,i−1, xi v,2, . . . , xi v,i+1, . . . , xi v,2 and xi v,k−1 and xi v on vertices xi ui,1 if i > 1 or xi We start with a construction, for every set V i, a gadget W i as follows. First, for every v ∈ V i we construct v,k. Second, we select an arbitrary v (i.e., xi v,1 v,k and xi an (k − 1)-vertex path X i vertex ui ∈ Vi. Third, for every v ∈ V i \ {ui}, we add a vertex si and xi v adjacent to the last vertex of X i if i < k or xi v, ti of the gadget W i. By Mst we denote the set of terminal pairs constructed in this step. v) a terminal pair. This concludes the description To encode adjacencies in G, we proceed as follows. For every pair 1 ≤ i < j ≤ k, we add a vertex pi,j, u,i for u ∈ Vj. For every edge vu ∈ E(G) with v ∈ Vi u,i). Let Mx be the set of terminal pairs constructed in this step; u1,2 if i = 1), a vertex ti ui,k−1 if i = k), and make (si adjacent to all vertices xi and u ∈ Vj, we add a terminal pair (xi we have M = Mst ∪ Mx. instance (H,M, '); see Figure 3 for an illustration. Finally, we set the required number of paths ' := k(n − 1) +(cid:0)k (cid:1). This concludes the description of the v,j for v ∈ Vi and all vertices xj v adjacent to the first vertex of X i v (i.e., xi ui,k v,1, xi v,j, xj 2 Figure 3: Part of the construction of the graph H: gadgets W i and W j, together with a connection via pi,j. v to ti From a clique to disjoint paths. Assume that the input Multicolored Clique instance is a "yes"- instance, and let {vi : 1 ≤ i ≤ k} be a clique in G with vi ∈ V i for every 1 ≤ i ≤ k. We construct a family of ' vertex-disjoint paths as follows. First, for every 1 ≤ i ≤ k and every v ∈ V i \ {ui}, we route a path from si ui if v = vi. Note that in this step we v through the path X i have created k(n− 1) vertex-disjoint paths connecting terminal pairs, and in every gadget W i the only unused vertices are vertices on the path X i vj ,i through pi,j; note that the assumption that vivj ∈ E(G) ensures take the 3-vertex path from xi that (xi (cid:1) paths, for every pair 1 ≤ i < j ≤ k we vi. To construct the remaining(cid:0)k v if v 6= vi, and through the path X i vj ,i) is indeed a terminal pair in M. vi,j to xj vi,j, xj 2 In the other direction, let P be a family of ' vertex-disjoint paths From disjoint paths to a clique. connecting terminal pairs in H. Let Pst ⊆ P be the set of paths connecting terminal pairs from Mst, and sim- ilarly define Px. First, observe that the set P := {pi,j : 1 ≤ i < j ≤ k} separates every terminal pair from Mx. Hence, every path from Px contains at least one vertex from P. Since P =(cid:0)k sequently, Pst ≥ '−(cid:0)k any vertex of P, while Px routes(cid:0)k (cid:1), and, con- (cid:1) = k(n−1) = Mst. We infer that Pst routes all terminal pairs in Mst without using (cid:1) pairs from Mx, and every path from Px contains exactly one vertex from P. (cid:1), we have Mx ≤(cid:0)k Since the paths in Pst cannot use any vertex in P, every such path needs to be contained inside one gadget W i. Furthermore, observe that a shortest path between terminals si v,a inside W i is either X i v, prolonged with the terminals at endpoints, and thus contains k + 1 vertices. Furthermore, a shortest or X i path between two terminals in Mx contains three vertices. We infer that the total number of vertices on v,a and ti ui 2 2 2 2 15 ...xiui,1xiv,1xiui,2xiv,2xiui,3xiv,3xiui,kxiv,ksivtiv...xjuj,1xjv,1xjuj,2xjv,2xjuj,3xjv,3xjuj,kxjv,ksjvtjvxiui,jxiv,jxjuj,ixjv,ipi,j paths in P is at least Pst · (k + 1) + Px · 3 = k(n − 1)(k + 1) + 3 (cid:18)k 2 (cid:19) = k (n(k − 1) + 2(n − 1)) + (cid:19) (cid:18)k 2 = V (H). v or X i We claim that {vi : 1 ≤ i ≤ k} is a clique in G. To this end, consider a pair 1 ≤ i < j ≤ k. Since Px =(cid:0)k We infer that every path in Pst consists of k + 1 vertices, and every path in Px consists of three vertices. In particular, for every 1 ≤ i ≤ k and v ∈ V i \ {ui}, the path in Pst that connects si v goes either ui. Consequently, for every 1 ≤ i ≤ k there exists a vertex vi ∈ V i such that the vertices through X i of W i that do not lie on any path from Pst are exactly the vertices on the path X i vi. 2 there exists a path in Px that goes through pi,j. Moreover, this path has exactly three vertices. Since the only neighbours of pi,j that are not used by paths from Pst are xi vj ,i) ∈ M and, consequently, vivj ∈ E(G). This concludes the proof of the correctness of the construction. vj ,i, we infer that (xi vi,j and xj v and ti vi,j, xj (cid:1), Treedepth bound. We are left with a proof that H has bounded treedepth. To this end, we use the alternative definition of treedepth [21]: treedepth of an empty graph is 0, while for any graph G on at least one vertex we have that (1 + min{td(G − v) : v ∈ V (G)} td(G) = max{td(C) : C connected component of G} if G is connected otherwise. First, observe that H − P contains k connected components, being the gadgets W i. Second, observe that the deletion of the endpoints of the path X i ui from the gadget W i breaks W i into connected components being paths on at most k + 1 vertices. Consequently, td(H) ≤ P + 2 + k + 1 = O(k2). This finishes the proof of Theorem 1.4. (cid:3) References [1] A. Andoni, A. Gupta, and R. Krauthgamer. Towards (1 + ε)-approximate flow sparsifiers. In Proc. SODA 2014, pages 279 -- 293, 2014. [2] M. Andrews, J. Chuzhoy, V. Guruswami, S. Khanna, K. Talwar, and L. Zhang. Inapproximability of edge-disjoint paths and low congestion routing on undirected graphs. Combinatorica, 30(5):485 -- 520, 2010. [3] P. Chalermsook, J. Chuzhoy, A. Ene, and S. Li. Approximation algorithms and hardness of integral concurrent flow. In Proc. STOC 2012, pages 689 -- 708, 2012. [4] C. Chekuri and J. Chuzhoy. Large-treewidth graph decompositions and applications. In Proc. STOC 2013, pages 291 -- 300, 2013. [5] C. Chekuri and A. Ene. Poly-logarithmic approximation for maximum node disjoint paths with constant congestion. In Proc. SODA 2013, pages 326 -- 341, 2013. √ [6] C. Chekuri, S. Khanna, and F. Shepherd. An O( unsplittable flow. Theory Comput., 2(7):137 -- 146, 2006. n) approximation and integrality gap for disjoint paths and [7] C. Chekuri, S. Khanna, and F. B. Shepherd. Multicommodity flow, well-linked terminals, and routing problems. [8] C. Chekuri, S. Khanna, and F. B. Shepherd. Edge-disjoint paths in planar graphs with constant congestion. [9] C. Chekuri, S. Khanna, and F. B. Shepherd. A note on multiflows and treewidth. Algorithmica, 54(3):400 -- 412, In Proc. STOC 2005, pages 183 -- 192, 2005. SIAM J. Comput., 39(1):281 -- 301, 2009. 2009. [10] C. Chekuri, G. Naves, and F. B. Shepherd. Maximum edge-disjoint paths in k-sums of graphs. In Proc. ICALP 2013, volume 7965 of LNCS, pages 328 -- 339, 2013. [11] E. Chlamtac, R. Krauthgamer, and P. Raghavendra. Approximating sparsest cut in graphs of bounded treewidth. In Proc. APPROX-RANDOM 2010, volume 6302 of LNCS, pages 124 -- 137, 2010. 16 [12] J. Chuzhoy. On vertex sparsifiers with Steiner nodes. In Proc. STOC 2012, pages 673 -- 688, 2012. [13] J. Chuzhoy and S. Li. A polylogarithmic approximation algorithm for edge-disjoint paths with congestion 2. In Proc. FOCS 2012, pages 233 -- 242, 2012. [14] R. Diestel. Graph theory, volume 173. Springer, third edition, 2005. [15] M. R. Fellows, D. Hermelin, F. Rosamond, and S. Vialette. Parameterized complexity of multiple-interval graph problems. Theoret. Comput. Sci., 410(1):53 -- 61, 2009. [16] N. Garg, V. V. Vazirani, and M. Yannakakis. Primal-dual approximation algorithms for integral flow and [17] A. Gupta, K. Talwar, and D. Witmer. Sparsest cut on bounded treewidth graphs: algorithms and hardness multicut in trees. Algorithmica, 18(1):3 -- 20, 1997. results. In Proc. STOC 2013, pages 281 -- 290, 2013. [18] R. M. Karp. Reducibility among combinatorial problems. In Complexity of Computer Computations, pages 85 -- 103, 1972. Prog., 99(1):63 -- 87, 2004. [19] S. Kolliopoulos and C. Stein. Approximating disjoint-path problems using packing integer programs. Math. [20] T. Leighton and S. Rao. Multicommodity max-flow min-cut theorems and their use in designing approximation algorithms. J. ACM, 46(6):787 -- 832, 1999. [21] J. Nešetřil and P. O. de Mendez. Tree-depth, subgraph coloring and homomorphism bounds. Eur. J. Comb., [22] J. Nešetřil and P. O. de Mendez. Sparsity - Graphs, Structures, and Algorithms, volume 28 of Algorithms and [23] N. Robertson and P. D. Seymour. Graph minors. V. Excluding a planar graph. J. Combinatorial Theory, Ser. [24] N. Robertson and P. D. Seymour. Graph minors. XIII. The disjoint paths problem. J. Combinatorial Theory, [25] N. Robertson and P. D. Seymour. Graph minors. XVI. Excluding a non-planar graph. J. Combinatorial Theory, 27(6):1022 -- 1041, 2006. combinatorics. Springer, 2012. B, 41(1):92 -- 114, 1986. Ser. B, 63(1):65 -- 110, 1995. Ser. B, 89(1):43 -- 76, 2003. [26] L. Séguin-Charbonneau and F. B. Shepherd. Maximum edge-disjoint paths in planar graphs with congestion 2. In Proc. FOCS 2011, pages 200 -- 209, 2011. 17
1012.3932
1
1012
2010-12-17T17:26:31
Balanced Interval Coloring
[ "cs.DS" ]
We consider the discrepancy problem of coloring $n$ intervals with $k$ colors such that at each point on the line, the maximal difference between the number of intervals of any two colors is minimal. Somewhat surprisingly, a coloring with maximal difference at most one always exists. Furthermore, we give an algorithm with running time $O(n \log n + kn \log k)$ for its construction. This is in particular interesting because many known results for discrepancy problems are non-constructive. This problem naturally models a load balancing scenario, where $n$ tasks with given start- and endtimes have to be distributed among $k$ servers. Our results imply that this can be done ideally balanced. When generalizing to $d$-dimensional boxes (instead of intervals), a solution with difference at most one is not always possible. We show that for any $d \ge 2$ and any $k \ge 2$ it is NP-complete to decide if such a solution exists, which implies also NP-hardness of the respective minimization problem. In an online scenario, where intervals arrive over time and the color has to be decided upon arrival, the maximal difference in the size of color classes can become arbitrarily high for any online algorithm.
cs.DS
cs
Balanced Interval Coloring Antonios Antoniadis, Falk Hüffner, Pascal Lenzner, Carsten Moldenhauer, and Alexander Souza Institut für Informatik, Humboldt-Universität zu Berlin, D-10099 Berlin, Germany {antoniad,hueffner,lenzner,moldenha,souza}@informatik.hu-berlin.de Abstract We consider the discrepancy problem of coloring n intervals with k colors such that at each point on the line, the maximal difference between the number of intervals of any two colors is minimal. Somewhat surprisingly, a coloring with maximal difference at most one always exists. Furthermore, we give an algorithm with running time O(n log n + kn log k) for its construction. This is in particular interesting because many known results for discrepancy problems are non-constructive. This problem naturally mod- els a load balancing scenario, where n tasks with given start- and endtimes have to be distributed among k servers. Our results imply that this can be done ideally balanced. When generalizing to d-dimensional boxes (instead of intervals), a solution with difference at most one is not always possible. We show that for any d ≥ 2 and any k ≥ 2 it is NP-complete to decide if such a solution exists, which implies also NP-hardness of the respective minimization problem. In an online scenario, where intervals arrive over time and the color has to be decided upon arrival, the maximal difference in the size of color classes can become arbitrarily high for any online algorithm. 1998 ACM Subject Classification F.2.2 Nonnumerical Algorithms and Problems -- Sequencing and scheduling Keywords and phrases Load balancing, discrepancy theory, NP-hardness Introduction 1 In this paper, we consider the following load balancing problem: We are given a set I = {I1, . . . , In} of tasks, where each task is represented by an interval I = [', r] ∈ I with starttime ' and endtime r. Furthermore, we are given k servers and have to assign the tasks to the servers as evenly as possible. That is, we want to minimize the maximal difference of the numbers of tasks processed by any two servers over all times. We formalize this in terms of an interval coloring problem: We are given a set I = {I1, . . . , In} of n intervals on the real line and a set K = {1, . . . , k} of k colors. A k-coloring is a mapping χ : I → K. For a fixed k-coloring χ and a point x ∈ R, let ci(x) denote the number of intervals containing x that have color i in χ. Define the imbalance of χ at x by imb(x) = max i,j∈K ci(x) − cj(x). (1) In words, this is the maximum difference in the size of color classes at point x. The imbalance of χ is given by imb(χ) = maxx∈R imb(x). These definitions yield the following minimization problem: MINIMUM IMBALANCE INTERVAL k-COLORING Instance: A set of intervals I. Task: Find a k-coloring χ with minimal imb(χ). We call a k-coloring with imbalance at most one balanced. Observe that if the number of intervals intersecting at some point is not divisible by k, then imbalance at least one is unavoidable. On the © Antonios Antoniadis and Falk Hüffner and Pascal Lenzner and Carsten Moldenhauer and Alexander Souza; licensed under Creative Commons License ND Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 0 1 0 2 c e D 7 1 ] S D . s c [ 1 v 2 3 9 3 . 2 1 0 1 : v i X r a 2 Balanced Interval Coloring other hand, if the number of intersecting intervals is divisible by k, then no coloring having imbalance one exists. Thus, if a balanced coloring exists, its imbalance is minimal. As we will see shortly, it is always possible to find a balanced interval k-coloring. Hence, we will mostly be concerned with its construction. More specifically, the questions considered in this paper are outlined as follows: (i) Is there always a balanced k-coloring? (ii) If so, is it possible to construct a balanced k-coloring in polynomial time? (iii) If we consider arcs of a circle (instead of intervals), do balanced k-colorings always exist? (iv) How is the situation if intervals arrive online? (v) If d-dimensional boxes (instead of intervals) are considered, can the existence of a balanced k-coloring be decided in polynomial time? The problem has close connections to discrepancy theory; see Doerr [9] and Matoušek [17] for introductions to the field. Let H = (X, U) be a hypergraph consisting of a set X of vertices and a set U ⊆ 2X of hyperedges. Analogous to the previous definitions, a k-coloring is a mapping χ : X → K, and the imbalance imb(χ) is the largest difference in size between two color classes over all hyperedges. The discrepancy problem is to determine the smallest possible imbalance, i. e., disc(H) = minχ:X→K imb(χ). Hence our problem is to find the discrepancy of the hypergraph H = (I, U), where U is the family of all maximal subsets of intervals intersecting at some point. It turns out that this hypergraph has totally unimodular incidence matrix, which is useful because de Werra [22] proved that balanced k-colorings exist for hypergraphs with totally unimodular incidence matrix. However, the proof in [22] is only partially constructive: A balanced k-coloring is constructed by iteratively solving the problem of balanced 2-coloring on hypergraphs with totally unimodular incidence matrix, for which no algorithm was given in [22]. Further related work in discrepancy theory mostly considers hypergraph coloring with two colors and often from existential, rather than algorithmic perspective. For an arbitrary hypergraph H with probabilistic method; see also [9]. For m ≥ n, Spencer [20] proved the stronger result disc(H) = n vertices and m hyperedges, the bound disc(H) ≤p2n ln(2m) for 2-coloring follows with the O(pn log(m/n)), which is in particular interesting for m = O(n). If each vertex is contained √ in at most t edges, the 2-coloring bound disc(H) = O( t log n) was shown by Srinivasan [21] and the bound disc(H) ≤ 2t − 1 by Beck and Fiala [5]. Biedl et al. [6] improved the bound to disc(H) ≤ max{2t − 3, 2} for 2-colorings and established disc(H) ≤ 4t − 3 for general k- colorings. They also showed that it is NP-complete to decide the existence of balanced k-colorings for hypergraphs with t ≥ max{3, k − 1} and k ≥ 2. Bansal [4] recently gave efficient algorithms that achieve 2-color imbalances similar to [20, 21] √ n log(2m/n)) matching up to constant factors. In particular, an algorithm yields disc(H) = O( √ the result of Spencer [20] if m = O(n). Furthermore, disc(H) = O( t log n) complies with the non-constructive result of Srinivasan [21]. For general k > 2, Doerr and Srivastav [10] gave a recursive method constructing k-colorings from (approximative) 2-colorings. Unfortunately, these results on general discrepancy theory do not answer any of the problems considered here, because t is only bounded by the number of vertices. Our Contributions. We contribute the following answers to the above questions: (i) Balanced k-colorings exist for any set I of intervals, i. e., question (i) can always be answered in the affirmative. We establish this by showing that our hypergraph H has totally unimodular incidence matrix and then applying a result of de Werra [22]. This also follows independently from our algorithmic results below. A. Antoniadis et al. 3 (ii) We present an O(n log n) time algorithm for finding a balanced 2-coloring, thereby establishing the first constructive result for intervals. Furthermore, we give an O(n log n + kn log k) algorithm for finding a balanced k-coloring. This is an improvement in time complexity, since the construction of de Werra [22] combined with our algorithm for 2-coloring only yields O(n log n + k2n). We also note that our algorithm works for any hypergraph with incidence matrix having the consecutive-ones property. (iii) If we consider arcs of a circle instead of intervals, balanced k-colorings do not exist in general. However, we give an algorithm achieving imbalance at most two with the same time complexity as in the interval case. (iv) In an online scenario, in which we learn intervals over time, the imbalance of any online algorithm can be made arbitrarily high. (v) For d-dimensional boxes, it is NP-complete to decide if a balanced k-coloring exists for any d ≥ 2 and any k ≥ 2. Our reduction is from NOT-ALL-EQUAL 3SAT. This result clearly implies NP-hardness of the respective minimization problem. 2 Interval Colorings In this section, we consider MINIMUM IMBALANCE INTERVAL k-COLORING, establish the existence of balanced k-colorings, and give algorithms for 2 and k colors, respectively. Later, we consider arcs of a circle and an online version. 2.1 Existence of Balanced k-Colorings We begin by observing the existence of balanced k-colorings. In the proof below, we use a theorem of de Werra [22], but the existence of balanced k-colorings also follows from our algorithmic results. (cid:73) Theorem 1. For any set I of intervals and any k ∈ N, there is a balanced k-coloring. Proof. Let I be the set of given intervals. Define a hypergraph H = (I, U), where U is the family of all maximal subsets of intervals intersecting at some point. For H with I = {I1, . . . , In} and U = {U1, . . . , Um}, the incidence matrix is defined by A = (ai,j) with ai,j = 1 if Ii ∈ Uj and ai,j = 0 otherwise. De Werra [22] showed that any hypergraph with totally unimodular incidence matrix admits a balanced k-coloring. It is well-known [19] that a 0 -- 1-matrix is totally unimodular if it has the consecutive-ones property, i. e., if there is a permutation of its columns such that all 1-entries appear consecutively in every row. The incidence matrix A of H has this property: If we order the Uj in increasing order of intersection points, then the entries ai,j = 1 appear consecutively in each row. (cid:74) 2.2 Algorithm for Two Colors In this section, we present an algorithm that constructs a balanced 2-coloring in polynomial time. Since the algorithm produces a valid solution for every possible instance, Theorem 1 for k = 2 also follows from this algorithmic result. We note in passing that a polynomial-time algorithm can also be obtained by solving a simple Integer Linear Program (ILP) with a totally unimodular constraint matrix. However, this gives a much worse running time bound of O(n5/ log n) [3]. The main idea of our algorithm is to simplify the structure of the instance such that the remaining intervals have start- and endpoints occurring pairwise. We then build a constraint graph that has the intervals as vertices. Finally, a proper 2-coloring of the constraint graph induces a solution to the problem. 4 Balanced Interval Coloring The start- and endpoints of the intervals are called events. A region is an interval spanned by two consecutive events and is called even (odd) if it is contained in an even (odd) number of input intervals. (cid:73) Theorem 2. For any set I of n intervals, there is a balanced 2-coloring that can be constructed in O(n log n) time. Proof. W. l. o. g. we can assume that the start- and endpoints of the input intervals are pairwise disjoint. If not, a new instance can be obtained by repeatedly increasing one of the coinciding start- or endpoints by /2, where  is the minimum size of a region. Since the new instance includes a corresponding region for every region of the original instance, a balanced coloring for the new instance is a balanced coloring for the old instance (the converse is not true). Observe that a coloring that is balanced on all even regions is also balanced on all odd regions. This is because odd regions only differ by one interval from a neighboring even region. Thus, the task reduces to constructing a balanced coloring of the even regions. Since between two consecutive even regions, exactly two events occur, it suffices to consider only pairs of consecutive events enclosing odd regions. If a pair of events consists of the start- and endpoint of the same interval, this interval is assigned any color and is removed from the instance. If a pair consists of start- and endpoint of different intervals, these intervals are removed from the instance and substituted by a new (minimal) interval that covers their union. In a final step of the algorithm, both intervals will be assigned the color of their substitution. The remaining instance consists solely of pairs of events where two intervals start or two intervals end. Clearly, a balanced coloring has to assign opposite colors to the corresponding two intervals of such a pair, and any such assignment yields a balanced coloring. The remaining pairs of events induce a constraint graph. Every vertex corresponds to an interval, and an edge is added between two vertices if there is a pair of events containing both startpoints or both endpoints. Finding a proper vertex two-coloring of this graph gives a balanced 2-coloring. The constraint graph is bipartite: Each edge can be labeled by "'" or "a" if it corresponds to two start- or endpoints, respectively. Since each interval is incident to exactly two edges, any path must traverse '- and a-edges alternatingly. Therefore, every cycle must be of even length and hence the graph is bipartite. Thus, a proper vertex two-coloring of the constraint graph can be found in linear time by depth-first search. Sorting events takes O(n log n) time. Creation of the constraint graph and coloring it takes linear (cid:74) time. Note that if intervals are given already sorted, or interval endpoints are described by small integers, then the above algorithm can even find a balanced 2-coloring in linear time. 2.3 Algorithms for k Colors In this section, we extend the results of the previous section to an arbitrary number of colors k and show that a balanced interval k-coloring can be found in polynomial time. A first polynomial time algorithm can be obtained using a construction by de Werra [22]: Start with an arbitrary coloring and find two colors i and j for which maxx ci(x) − cj(x) is maximal. Use the algorithm from Section 2.2 to find a balanced 2-coloring of all intervals that currently have color i or j and recolor them accordingly. Repeat until the coloring is balanced. This algorithm has running time O(n log n + k2n), because sorting intervals is needed only once for the above algorithm for 2 colors, and there are at most(cid:0)k (cid:1) recolorings necessary. 2 In the following, we present an alternative algorithm for k colors, which is faster than O(n log n + k2n). We will first give an overview of the argument, and then a more formal description. A. Antoniadis et al. 5 As in Section 2.2, we assume w. l. o. g. that all start- and endpoints are pairwise disjoint. The idea is to scan the events in order, beginning with the smallest, and to capture dependencies in k-tuples of intervals that indicate pairwise different colors. That is, we reduce the MINIMUM IMBALANCE INTERVAL k-COLORING instance to an instance of STRONG HYPERGRAPH COLORING, formally defined as follows. STRONG HYPERGRAPH COLORING Instance: A ground set X, a family S of constraints S1, . . . , Sn ⊆ X, and an integer k. Task: Find a k-coloring χ : X → K with ∀ 1 ≤ i ≤ n : x, y ∈ Si, x 6= y ⇒ χ(x) 6= χ(y). For example, in the special case that each block of k consecutive events consists only of start- or only of endpoints, the constraints that the corresponding k intervals have to be differently colored will capture the whole solution. As we will see below, also different interval nesting structures can be captured by such constraints. STRONG HYPERGRAPH COLORING is NP-hard in general [1]. However, each interval will occur in at most two constraints, corresponding to its start- and endpoint. Thus, we can further reduce the STRONG HYPERGRAPH COLORING instance to EDGE COLORING, where the goal is to color edges of a multigraph such that the edges incident to each vertex are all differently colored. More formally: EDGE COLORING Instance: A multigraph G = (V, E) and an integer k. Task: Find a k-coloring χ : E → K with ∀e, e0 ∈ E, e ∩ e0 6= ∅, e 6= e0 ⇒ χ(e) 6= χ(e0). It is easy to see that any instance (X,S, k) of STRONG HYPERGRAPH COLORING where each element of X occurs in at most two constraints can be reduced to EDGE COLORING as (G = (S, E), k), where for each x ∈ X that occurs in Si and Sj with i 6= j, we add the edge {Si, Sj} to E. For our case, a constraint corresponds to a vertex, and an interval corresponds to an edge that connects the two constraints it occurs in. An edge coloring with k colors will thus provide a balanced interval k-coloring. Clearly, an edge coloring of a multigraph with maximum degree ∆ needs at least ∆ colors. Finding an edge coloring of minimum size is NP-hard in general [14]. However, Konig [16] showed that for bipartite multigraphs, ∆ colors in fact always suffice. Further, an edge coloring of a bipartite multigraph with m edges can be found in O(m log ∆) time [8]. The multigraph we will construct has maximum degree k and is bipartite. Thus, a balanced interval k-coloring always exists and can be found in polynomial time. We now describe the construction of the constraints and give a more rigorous description of the results. From a MINIMUM IMBALANCE INTERVAL k-COLORING instance I, we construct a STRONG HYPERGRAPH COLORING instance (I,S, k) over the ground set of the intervals. The algorithm scans the set of events in order, beginning with the smallest. It keeps a set of active events and adds constraints to S. The set of active events will be cleared at each region where the number of intervals is 0 modulo k. Thus, the active events always describe the change from a situation where each color occurs the same number of times. The construction of the constraints can be visualized with a decision tree, depicted for the example k = 4 in Figure 1. At the beginning, the set of active events is empty (which corresponds to the root of the decision tree). Whenever the set of events is empty, the algorithm branches into two cases depending on the type of the next event. Both branches are equivalent, with the roles of start- and endpoints interchanged. Therefore, assume the next event is the start of an interval (depicted a' on the left branch). It is added to the active set. This continues until either k startpoints of as intervals I1, . . . , Ik are added, or an endpoint is encountered. In the first case, the constraint (I1, . . . , Ik) (2) 6 Balanced Interval Coloring Figure 1 Tracking of active events for k = 4 is constructed and the set of active events is cleared (dashed arrow returning to the root). In the second case, assume the startpoints of intervals I1, . . . , Ij have been added and the endpoint of interval Ij+1 is encountered. Then, the two constraints (I1, . . . , Ij, xj+1, . . . , xk) (y1, . . . , yj−1, Ij+1, xj+1, . . . , xk) (3) (4) are constructed. Here, xj+1, . . . , xk and y1, . . . , yj−1 are new "virtual" intervals that have not been used in previous constraints. That is, they do not correspond to actual intervals of the real line and only serve as placeholders in the active set. Furthermore, the startpoints of the intervals I1, . . . , Ij are replaced by the startpoints of y1, . . . , yj−1 in the active set of events (indicated by the dashed arrows pointing one level higher in the decision tree). We now prove the correctness of the two chained reductions. (cid:73) Lemma 3. A solution to the STRONG HYPERGRAPH COLORING instance (I,S, k), constructed as described above, yields a balanced k-coloring for I. Proof. Recall that a region is an interval spanned by two consecutive events. The proof is by induction over all regions, in the order of events. At each region, we count the number of times each of the k colors is used among the intervals containing the region. We will show that these counters differ by at most one, i. e., the coloring is balanced. Clearly, all counters are equal to zero before the first event. In particular, we show that in regions where the number of intervals is 0 modulo k, all counters are equal, and that between these regions the counters change by at most one and all in the same direction. We distinguish the same cases as in the construction, limiting the discussion to the case that the event first added to the empty set of active events is a startpoint. If k startpoints of intervals I1, . . . , Ik are encountered, there is a constraint of the form (2), which ensures that all of them have different colors. Therefore, at each startpoint, a different counter increases by one. Hence, the counters differ by at most one in all regions up to the startpoint of Ik, and are all equal in the region beginning with the startpoint of Ik. Consider that only j < k startpoints of the intervals I1, . . . , Ij are encountered. Since these startpoints were added to the set of active events during the construction, the intervals I1, . . . , Ij do all occur in one constraint. This constraint forces them to have different colors, and therefore the colors of I1, . . . , Ij are exactly the colors with increased count. Now, we distinguish two subcases caaaa'b'c'ba':(abx3x4)a:(y1cx3x4)a←y1d'da':(ax2x3x4)a:(bx2x3x4)':(abcx4)a:(y1y2dx4)a←y1,b←y2':(abcd)a:(ax2x3x4)':(bx2x3x4)a:(abx3x4)':(y1cx3x4)a←y1a:(abcx4)':(y1y2dx4)a←y1,b←y2b'c'd'bacadaa:(abcd) A. Antoniadis et al. 7 Figure 2 Complete example of the constraints and bipartite EDGE COLORING instance for k = 3 with a valid coloring. depending on the next event. If the next event is a startpoint of some interval, denoted by Ij+1, it will also be part of the same constraint. Hence, Ij+1 has a different color whose count is not yet increased. The second subcase is that the next event is the endpoint of some interval, denoted by Ij+1. The interval Ij+1 is forced to have the same color as one of the intervals I1, . . . , Ij. This is because there is a constraint of the form (3) that collects all other colors in variables xj+1, . . . , xk, which occur together with Ij+1 in a constraint of the form (4). Thus, the previously increased counter for the color of Ij+1 decreases again. Because of the constraint of the form (3), the virtual intervals y1, . . . , yj−1 must have all of the colors of I1, . . . , Ij except for the color of Ij+1. Hence, the colors of y1, . . . , yj−1 are exactly all remaining colors with increased count. Therefore, we are in the same situation as before encountering the endpoint of Ij+1. By repeating the above argument, the claim follows in this case. If the event first added is an endpoint, the argument is symmetrical. (cid:74) (cid:73) Lemma 4. A STRONG HYPERGRAPH COLORING instance (I,S, k) constructed as described above can be reduced to a bipartite EDGE COLORING instance. Proof. We need to show that each interval occurs in at most two constraints. Once this is proved, it is possible to build a multigraph with the constraints as vertices and edges between them if they share a common interval. Further, it has to be shown that this multigraph is bipartite. To show both parts at once, we color the constraints in S with the two colors ' and a. It then suffices to show that every interval can occur in at most one '-constraint and in at most one a-constraint. Consider Figure 2 for an illustration of the constructed constraints and the respective bipartite EDGE COLORING instance. We color a constraint with ' if all involved events belonging to nonvirtual intervals are startpoints, and with a if all these events are endpoints (see Figure 1). All nonvirtual intervals therefore occur in exactly two constraints, constructed when the start- and endpoint get removed from the active set of events. A virtual x-interval always occurs in a pair of subsequent differently colored constraints, and is not used anywhere else. For the left branch of the decision tree, a virtual y-interval occurs first in a a-constraint, and its startpoint is then added to the list of active events. Then, it will be used in a constraint of type either (2) or (3), both of which are of type '. The argument is symmetrical for the (cid:74) right branch of the decision tree. (cid:73) Theorem 5. Every set of n intervals I has a balanced k-coloring for any k ∈ N, and it can be found in O(n log n + kn log k) time. abcdefghijA':(abc)B':(dx1x2)Ba:(dx1x2)C':(efx3)Ca:(y1cx3)D':(y1x4x5)Da:(ex4x5)Ea:(fx6x7)E':(gx6x7)F':(hix8)Fa:(y2gx8)G':(y2x9x10)Ga:(ix9x10)H':(jx11x12)Ha:(bx11x12)Ia:(a,h,j)A'B'BaC'CaD'DaEaE'F'FaG'GaHaH'Iaabcdx1x2efx3y1x4x5x6x7ghix8y2x9x10x12x11j 8 Balanced Interval Coloring Proof. By Lemmas 3 and 4, MINIMUM IMBALANCE INTERVAL k-COLORING can be reduced to EDGE COLORING with fixed k in a bipartite multigraph. The maximum degree of this multigraph is k, since by construction no constraint has more than k elements. By Konig's theorem [16] existence follows. To be able to process the events, they have to be sorted in O(n log n) time. We have O(kn) virtual intervals and thus O(kn) edges in the EDGE COLORING instance. Finding an edge k-coloring for (cid:74) this multigraph with maximum degree k can be done in O(kn log k) time [8]. Note that the EDGE COLORING algorithm by Cole, Ost, and Schirra [8] uses quite involved data structures. In practice, it might be preferable to use the much simpler algorithm by Alon [2] running in O(m log m) time for an m-edge graph, which gives a worst-case bound of O(kn log n). An implementation of our algorithm in Python using a simple edge coloring algorithm based on augmenting paths can be found at http://www2.informatik.hu-berlin.de/~hueffner/intcol.py. For an extension, recall that a matrix has the consecutive-ones property if there is a permutation of its columns such that all 1-entries appear consecutively in every row. Such a permutation can be found in linear time by the PQ-algorithm [7]. Given such a matrix, it is straightforward to construct an instance of MINIMUM IMBALANCE INTERVAL k-COLORING. (cid:73) Theorem 6. For any hypergraph H with an n × m incidence matrix having the consecutive ones property, a balanced k-coloring can be found in O(nm + kn log k) time. 2.4 Arcs of a Circle In a periodic setting, the tasks I might be better described by a set of arcs of a circle rather than a set of intervals. In this case, there are instances that require an imbalance of two (e. g., three arcs that intersect exactly pairwise and k = 2). We show that two is also an upper bound and a coloring with maximal imbalance two can be found in polynomial time. (cid:73) Theorem 7. The maximal imbalance for arcs of a circle is two, and finding a coloring with imbalance at most two can be done in O(n log n + kn log k) time. Proof. Define a point on the circle, called zero, and consider counterclockwise orientation. We build an instance of MINIMUM IMBALANCE INTERVAL k-COLORING by "unfolding" the circle at zero in the following way. Consider only arcs that do not span the full circle. Map all such arcs not containing zero to intervals of same length at the same distance right of zero on the real line. Map the arcs containing zero to intervals of same length such that the positive part of the interval has the same length as the part of the arc in counterclockwise direction from zero. Finally, map the arcs containing the full circle to intervals spanning all of the instance constructed so far. Use the above algorithm to obtain a coloring of the intervals with imbalance at most one at every point. By reversing the mapping, the obtained coloring of the arcs has imbalance at most two (each point on the circle is (cid:74) mapped to at most two points of the real line). 2.5 Online Algorithms In load balancing problems, it is often more realistic to assume an online scenario, where not all information is known in advance, but is rather arriving piece-by-piece, and irrevocable decisions have to be made immediately. In our setting, this means that intervals arrive in order of their startpoint, including the information of their endpoint, and a color has to be assigned to them immediately. The problem of finding a proper coloring (i. e., a coloring where no two intersecting intervals have the same color) of intervals in an online setting has found considerable interest [15, 11]. In these works, the objective is to use a minimum number of colors. In contrast, we consider a fixed number A. Antoniadis et al. 9 of colors and the minimization of the imbalance. We show that in contrast to the offline scenario, here the imbalance can become arbitrarily large. (cid:73) Theorem 8. In online MINIMUM IMBALANCE INTERVAL k-COLORING, the imbalance is unbounded. Proof. We first consider the case k = 2 with colors "+1" and "−1". Denote the signed imbalance simb(x) to be the sum of the colors of the intervals containing x. Note that imb(x) = simb(x). In the following, we outline how a sequence of intervals can be constructed such that no online algorithm can yield a bounded imbalance. Initially, simb ≡ 0. Set L = [0, 1] and R = [2, 3]. Let L', R', Lr, and Rr denote the start- and endpoints of the current L and R, respectively. Repeat the following steps. Present the interval [(L' + Lr)/2, (R' + Rr)/2] to the online algorithm. If it chooses color +1, set R ← [R', (R' + Rr)/2], else R ← [(R' + Rr)/2, Rr]. Set L ← [(L' + Lr)/2, Lr]. This sequence of intervals is legal, since the startpoints increase strictly monotonously. In each repetition, if the algorithm chooses color +1, the signed imbalances in L and R increase by one. If the algorithm chooses −1, the signed imbalance decreases by one in L and remains unchanged in R, i. e., the difference of the signed imbalance in L and R increases. Therefore, the signed imbalance diverges in L or R. Since the imbalance is the absolute value of the signed imbalance, it becomes unbounded. The construction easily generalizes to k > 2 colors. We only track two arbitrary colors, and whenever the algorithm assigns an untracked color to an interval, we present the same interval (with a slightly increased startpoint) again, forcing it to eventually assign a tracked color or to produce (cid:74) unbounded imbalance. 3 Hardness of Generalizations We consider several generalizations of MINIMUM IMBALANCE INTERVAL k-COLORING and show that they are NP-hard. Note that the hardness results of Biedl et al. [6] do not apply to the problems we consider here. d-Dimensional Boxes. Gyárfás and Lehel [13] suggest to examine d-dimensional boxes as generalizations of intervals for coloring problems. The problem MINIMUM IMBALANCE d-BOX k-COLORING has as input an integer k and a set I = {I1, . . . , In} of n d-dimensional boxes Ii = (['i,1, ri,1], ['i,2, ri,2], . . . , ['i,d, ri,d]) for 1 ≤ i ≤ n. For every point x = (x1, . . . , xd), let S(x) be the set of boxes that include x, i. e., S(x) contains all the elements Ii such that 'i,j ≤ xj ≤ ri,j for all 1 ≤ j ≤ d. For a coloring χ : I → K, a color i, and a point x, let ci(x) be the number of boxes in S(x) of color i. With the analog definition of imbalance imb(χ) and balance for d-dimensional boxes, the problem statement becomes: MINIMUM IMBALANCE d-BOX k-COLORING Instance: A set I of d-dimensional boxes. Task: Find a k-coloring χ with minimal imb(χ). First note that, unlike for the case d = 1, a balanced coloring may not exist: already for three rectangles, some instances require imbalance two. Hence, we also have a related decision problem: BALANCED d-BOX k-COLORING Instance: A set I of d-dimensional boxes. Question: Is there a balanced k-coloring χ? 10 Balanced Interval Coloring W q5 q1 q4 V2 q2 q3 V q0 V1 zi Ai yi xi (a) Gadget for clause Ci = (xi, yi, zi) (b) Gadget for crossing chains V and W Figure 3 The gadgets of the reduction. We show that for all d ≥ 2 and k ≥ 2, it is NP-complete to decide BALANCED d-BOX k- COLORING. This clearly implies NP-hardness of MINIMUM IMBALANCE d-BOX k-COLORING. (cid:73) Theorem 9. BALANCED d-BOX k-COLORING is NP-complete for any d ≥ 2 and any k ≥ 2. We will reduce from NOT-ALL-EQUAL 3SAT (NAE-3SAT) [18]. Note that the classic definition of NAE-3SAT [12] allows negated variables. However, this is not needed to make the problem NP-complete [18]. Thus, in the sequel, we will assume that all variables occur only non-negatedly. NOT-ALL-EQUAL 3SAT (NAE-3SAT) Instance: A Boolean formula with clauses C1, . . . , Cm, each having at most 3 variables. Question: Is there a truth assignment such that in every clause, not all variables have the same value? We first consider k = 2 and then generalize to arbitrary k. We present the gadgets of the reduction, then show how they are combined together, and conclude by proving correctness. For each clause Ci = (xi, yi, zi), we construct a clause gadget comprised of three rectangles (see Figure 3a). Note that all three rectangles overlap in region Ai, and only there. Then we also construct a separate rectangle rj for every variable. Finally, we connect each rj to all rectangles that appear in a clause gadget, and correspond to the same variable as rj. We do this by a chain with odd number of rectangles. This ensures that in any balanced 2-coloring, rj and the corresponding rectangle in the clause gadget have the same color. If two chains need to cross, we introduce a crossing gadget as seen in Figure 3b. Three rectangles are relevant for the crossing of two chains V and W . The first is V1 and contains areas q0, q1, and q2, the second is V2, containing q1, q2, and q3. Both V1 and V2 belong to chain V . The last rectangle contains areas q1, q4 and q5 and belongs to chain W . Note that the crossing does not induce any dependencies on the colorings between chains V and W . See Figure 4 for a construction of an instance for BALANCED 2-BOX 2-COLORING. Observe that the above construction only requires a number of rectangles polynomial in the size of the NAE-3SAT instance. (cid:73) Lemma 10. BALANCED d-BOX 2-COLORING is NP-complete for any d ≥ 2. Proof. The problem is in NP, since feasibility of a color assignment can be checked in polynomial time. For NP-hardness, we show that a NAE-3SAT instance is satisfiable if and only if the answer to the corresponding BALANCED 2-BOX 2-COLORING instance is "yes". This also implies NP- completeness for every d ≥ 2 by taking intervals of length 0 in higher dimensions. (⇒) Assume that there is a satisfying assignment of the NAE-3SAT instance. Then, color the rectangles rj according to the truth values of their corresponding variables. This coloring can be A. Antoniadis et al. 11 x1 x2 x3 x4 x5 x6 x2 x4 x5 x1 x3 x3 x5 x1 x6 Figure 4 Example for NAE-3SAT instance (x1, x2, x3), (x3, x4, x5), (x1, x5, x6). easily extended to all the rectangles by alternatively coloring rectangles along a chain (and crossings) starting from each rj and ending at a clause gadget. It remains to show that imb(x) ≤ 1 holds for every point x ∈ Ai for all 1 ≤ i ≤ m. Consider Ai corresponding to clause Ci = (xi, yi, zi). The three rectangles that intersect at Ai have the colors corresponding to the truth values of their variables xi, yi, and zi in the solution of NAE-3SAT. Since the three variables do not have all the same truth value, the three rectangles cannot have all the same color, and imb(x) ≤ 1. (⇐) Assume that we have a balanced 2-coloring for the constructed BALANCED 2-BOX 2- COLORING instance. Consider only the clause gadgets. We have already observed that rectangles that correspond to the same variable and appear in clause gadgets must have the same color. We can assign the truth values of the variables according to the colors in the corresponding rectangles. Since in no Ai all three rectangles have the same color, in no Ci all three variables have the same truth (cid:74) value, yielding a feasible solution for NAE-3SAT. Proof of Theorem 9. First apply the construction for BALANCED 2-BOX 2-COLORING and call its rectangles reduction rectangles. Then add k − 2 additional rectangles that fully contain the construction and all intersect at least in one point outside the construction; these are called cover rectangles. By the latter property, cover rectangles must have distinct colors in any balanced coloring. Observe that each reduction rectangle contains some point that does not intersect with other reduction rectangles but only with all the cover rectangles. This implies that the reduction rectangles have available only the two colors not used by the cover rectangles. We conclude that the problem of k-coloring the constructed instance is equivalent to the problem of 2-coloring only the reduction (cid:74) rectangles. Further Generalizations. The weighted version, where intervals have weights and the weighted imbalance is to be minimized, is NP-complete by reduction from PARTITION. Furthermore, the variant with multiple intervals [13] is NP-complete by reduction from NAE-3SAT. Both hardness results generalize to higher dimensions. The proofs can be found in Appendix A. 4 Open Questions We have given a polynomial time algorithm for k-coloring hypergraphs with the consecutive-ones property, i. e., a special case of a totally unimodular incidence matrix. It would be interesting to generalize to arbitrary totally unimodular incidence matrices. For arcs of a circle, we have shown how to find a coloring with imbalance at most two in polynomial time, but it is not clear how to find an optimal one. 12 Balanced Interval Coloring It remains open how large the imbalance can become for d-dimensional boxes, and whether we can find polynomial-time approximations for it. We were not able to find an instance requiring an imbalance greater than 2 for the 2-dimensional case. References 1 G. Agnarsson and M. M. Halldórsson. Strong colorings of hypergraphs. In Proc. 2nd WAOA, volume 3351 of LNCS, pages 253 -- 266. Springer, 2005. 2 N. Alon. A simple algorithm for edge-coloring bipartite multigraphs. Information Processing 3 K. M. Anstreicher. Linear programming in O( n3 ln n L) operations. SIAM Journal on Optimization, Letters, 85(6):301 -- 302, 2003. 9(4):803 -- 812, 1999. 4 N. Bansal. Constructive algorithms for discrepancy minimization. In Proc. 51st FOCS. IEEE 5 6 Computer Society, 2010. To appear. Also in arXiv:1002.2259v4. J. Beck and T. Fiala. "Integer making" theorems. Discrete Applied Mathematics, 3(1):1 -- 8, 1981. T. C. Biedl, E. Cenek, T. M. Chan, E. D. Demaine, M. L. Demaine, R. Fleischer, and M.-W. Wang. Balanced k-colorings. Discrete Mathematics, 254(1 -- 3):19 -- 32, 2002. 8 7 K. S. Booth and G. S. Lueker. Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms. Journal of Computer and System Sciences, 13(3):335 -- 379, 1976. R. Cole, K. Ost, and S. Schirra. Edge-coloring bipartite multigraphs in O(E log D) time. Combi- natorica, 21(1):5 -- 12, 2001. B. Doerr. 2005. B. Doerr and A. Srivastav. Multicolour discrepancies. Combinatorics, Probability and Computing, 12:365 -- 399, 2003. L. Epstein. Online interval coloring. 594 -- 598. Springer, 2008. Integral Approximation. Habilitationsschrift, Christian-Albrechts-Universität zu Kiel, In M.-Y. Kao, editor, Encyclopedia of Algorithms, pages 9 10 11 12 M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of NP- Completeness. W. H. Freeman, 1979. 13 A. Gyárfás and J. Lehel. Covering and coloring problems for relatives of intervals. Discrete 14 Mathematics, 55(2):167 -- 180, 1985. I. Holyer. The NP-completeness of edge-coloring. SIAM Journal on Computing, 10(4):718 -- 720, 1981. 15 H. A. Kierstead and W. T. Trotter. An extremal problem in recursive combinatorics. Congressus Numerantium, 33:143 -- 153, 1981. 16 D. Konig. Gráfok és alkalmazásuk a determinánsok és a halmazok elméletére [in Hungar- ian: Graphs and their application to determinant theory and set theory]. Matematikai és Ter- mészettudományi Értesíto, 34:104 -- 119, 1916. J. Matoušek. Geometric Discrepancy: An Illustrated Guide, volume 18 of Algorithms and Combi- natorics. Springer, 1999. T. J. Schaefer. The complexity of satisfiability problems. ACM, 1978. In Proc. 10th STOC, pages 216 -- 226. 18 17 19 A. Schrijver. Theory of Linear and Integer Programming. Wiley, 1986. 20 J. Spencer. Six standard deviations suffice. Transactions of the American Mathematical Society, 289(2):679 -- 706, 1985. 21 A. Srinivasan. Improving the discrepancy bound for sparse matrices: Better approximations for sparse lattice approximation problems. In Proc. 8th SODA, pages 692 -- 701. ACM-SIAM, 1997. 22 D. de Werra. Equitable colorations of graphs. Revue Française d'Informatique et de Recherche opérationnelle, R-3:3 -- 8, 1971. A. Antoniadis et al. A Appendix We consider further generalizations that can be shown to be NP-complete. 13 A.1 Weighted Version We consider the variant where each interval I ∈ I has a weight wI ∈ N, and we want to k-color I as evenly as possible. For a coloring χ : I → K, let wi(x) denote the total weight of the intervals containing x that have color i. Then the weighed imbalance is imb(x) = maxi,j∈K wi(x) − wj(x), which we seek to minimize. Even for k = 2, it is NP-complete to decide if the minimum weighted imbalance of I is zero. This also implies NP-hardness of the minimization problem. We will reduce from PARTITION [12]: Given a set A = {a1, a2, . . . , an} and a cost function s : A → N, is there a subset A0 ⊆ A such a∈A\A0 s(a)? The reduction is straightforward: For any given instance of PARTITION of size n, construct n identical intervals [', r] for arbitrary ' < r, with each interval Ii, for 1 ≤ i ≤ n, having weight s(ai). This instance has an exactly balanced color assignment if and only if the answer to the corresponding PARTITION instance is "yes". a∈A0 s(a) = P thatP Note that the above reduction is for 1-dimensional problems, but implies the NP-completeness of higher-dimensional problems, too. A.2 Multiple intervals Another generalization suggested by Gyárfás and Lehel [13] is multiple intervals, where specific subsets of non-intersecting intervals must receive the same color. This variant is also NP-complete. Given a NAE-3SAT instance where no negations are allowed, for every clause Ci construct three intervals corresponding to the three variables of the clause. All these three intervals have the same startpoints 'i and endpoints ri and 'i > ri−1. Finally, for every variable, pack all the corresponding constructed intervals into a subset that enforces that they receive the same color. This is legal, since different intervals for the same variable are disjoint, and it can be easily seen that the multiple intervals instance has a balanced coloring if and only if the corresponding NAE-3SAT instance has a satisfying assignment. Again, the hardness generalizes to higher dimensions.
1201.5513
1
1201
2012-01-26T13:35:33
Faster and Simpler Minimal Conflicting Set Identification
[ "cs.DS" ]
Let C be a finite set of N elements and R = r_1,r_2,..., r_m a family of M subsets of C. A subset X of R verifies the Consecutive Ones Property (C1P) if there exists a permutation P of C such that each r_i in X is an interval of P. A Minimal Conflicting Set (MCS) S is a subset of R that does not verify the C1P, but such that any of its proper subsets does. In this paper, we present a new simpler and faster algorithm to decide if a given element r in R belongs to at least one MCS. Our algorithm runs in O(N^2M^2 + NM^7), largely improving the current O(M^6N^5 (M+N)^2 log(M+N)) fastest algorithm of [Blin {\em et al}, CSR 2011]. The new algorithm is based on an alternative approach considering minimal forbidden induced subgraphs of interval graphs instead of Tucker matrices.
cs.DS
cs
Faster and Simpler Minimal Conflicting Set Identification∗ Aida Ouangraoua† Mathieu Raffinot‡ April 4, 2019 Abstract Let C be a finite set of n elements and R = {r1, r2, . . . , rm} a family of m subsets of C. A subset X of R verifies the Consecutive Ones Property (C1P) if there exists a permutation P of C such that each ri in X is an interval of P . A Minimal Conflicting Set (MCS) S ⊆ R is a subset of R that does not verify the C1P, but such that any of its proper subsets does. In this paper, we present a new simpler and faster algorithm to decide if a given element r ∈ R belongs to at least one MCS. Our algorithm runs in O(n2m2+nm7), largely improving the current O(m6n5(m+n)2 log(m+n)) fastest algorithm of [Blin et al, CSR 2011]. The new algorithm is based on an alternative approach considering minimal forbidden induced subgraphs of interval graphs instead of Tucker matrices. Introduction 1 Let C = {c1, . . . , cn} be a finite set of n elements and R = {r1, r2, . . . , rm} a family of m subsets of C. Those sets can be seen as a m × n 0-1 matrix M = (R,C), such that the set C represents the columns of the matrix, and the set R the rows of the matrix: each ri ∈ R represents the set of columns where row i has an entry 1. A subset X of R verifies the consecutive ones property (C1P) if there exists a permutation P of C such that each ri in X is an interval of P . Testing the con- secutive ones property is the core of many algorithms that have applications in a wide range of domains, from VLSI circuit conception through planar embed- dings [8] to computational biology for the reconstruction of ancestral genomes [1, 2, 4, 5, 9]. We focus on this last field in this paper. On real biological matrices, the C1P is rarely verified, and only some subsets of rows might verify the desired property.However, the combinatorics of such sets is difficult to handle, and a strategy to deal with them has been proposed in [1, 5, 9]. It consists in identifying the rows belonging to minimal conflicting subsets of rows that do not verify the C1P, but such that any of their row subset does. ∗This work is partly supported by the french MAPPI project (ANR-2010-COSI-004). †INRIA, Centre de recherche INRIA Haute-Borne, Bat. A, Park Plaza 40 avenue Halley, ‡CNRS/LIAFA, Universit´e Paris Diderot - Paris 7, France, [email protected] 59650 Villeneuve d'Ascq, France. [email protected] 1 Definition 1 A set S ⊆ R,S (cid:54)= ∅ is a Minimal Conflicting Set (MCS) if S does not verify the C1P, but such that ∀X ,X ⊂ S, the set X verifies the C1P. However, it is not difficult to build examples of matrices such that the number of MCS is polynomial or even exponential in the num- ber of rows. Figure 1 shows such an example in which each sub set of 3 rows is a MCS. Thus, such a construction with m rows gives C m 3 = O(m3) MCS. Note that, on this example, a single row is included in O(m2) MCS. Figure 2-(a) shows another example where the number of MCS is exponential in the number of rows. Let k be the number of nodes of external rows, which are r7, r8, and r9 on the figure. The total number of rows is 3k, the number of columns 2k, and the num- ber of MCS is 2k since any induced chordless cycle in the row intersection graph of the matrix (Figure 2-(b)) constitutes a MCS. Figure 1: A matrix not verifying the C1P and such that each set of 3 rows is a MCS. Figure 2: (a) A matrix not verifying the C1P and such that the number of MCS is exponential in the number of rows. (b) A row intersection graph of the matrix whose vertices correspond to the rows of the matrix, and such that there exists an edge between two rows ri and rj if ri ∩ rj (cid:54)= ∅. From a computational point of view, the first question that arises is the following: is a given row r ∈ R included in at least one MCS ? This question has been raised in [1], recalled in [4, 5] and recently solved in polynomial time O(m6n5(m + n)2log(m + n)) in [3]. This currently fastest algorithm is based on the identification of minimal Tucker forbidden submatrices [10, 6]. In this paper we present a new simpler O(m2n2 + nm7) time algorithm for deciding if a given row belongs to at least one MCS and if true exhibit one. Our algorithm is based on an alternative approach considering minimal forbidden 2 1cc2c3c4c5c6c7c811110000000011010010100001000111000011234567rrrrrrrc4c61cc2c3c56r1r5r7r8r000101000000000100110000100001110110010011000010111000912345679234rrrrrrrrrrrrr8(a)(b) induced subgraphs of interval graphs [7] instead of Tucker matrices. Moreover, our central paradigm consists in reducing the recognition of complex forbidden induced subgraphs to the detection of induced cycles in ad-hoc graphs, while in [3] only induced paths are considered. Our approach is faster and simpler, but a limit shared by both approaches resides in avoiding to report the number of MCS to which a given row belongs. 2 MCS and Forbidden induced subgraphs The row-column intersection graph of a 0-1 matrix M = (R,C) is a vertex- colored bipartite graph GRC(M ) whose set of vertices is R ∪ C ; the vertices corresponding to rows (resp. columns) are black (resp. white) ; there exists an edge between two rows ri ∈ R and rj ∈ R if ri ∩ rj (cid:54)= ∅, and there exists an edge between a row r ∈ R and a column c ∈ C if c ∈ r. It should be noted that a column vertex (white) is only connected to row vertices (black). The neighborhood N (r) of a row r is the set of rows intersecting r, N (r) = {x ∈ R : r∩ x (cid:54)= ∅} and N (ri, rj) = N (ri)∩ N (rj). The span L(c) of a column c is the set of rows containing x, L(c) = {r ∈ R : c ∈ r}. Figure 3: Forbidden induced subgraphs for the row-column intersection graph of M = (R,C) to verify C1P. Theorem 1 ([7], Theorem 4) A 0-1 matrix M = (R,C) verifies the C1P if and only if its row-column intersection graph does not contain a forbidden induced subgraph of the form I, II, III, IV, or V (Figure 3). Property 1 From Theorem 1, a set S ⊆ R is a MCS if the row-column inter- section graph GRC(S,C) contains a subgraph of the form I, II, III, IV, or V; and for any T ⊂ S, GRC(T ,C) does not contain a subgraph of the form I, II, III, IV, or V. 3 a132e4g2e4gb1a12e3kga12eg3k43IVIIIIIV1k243567Ik>3k>2k>2 Given a MCS S ⊆ R, a forbidden induced subgraph contained in GRC(S,C) is said to be responsible for the MCS S. If this forbidden induced subgraph is of the form I (resp. II; III; IV; V), we simply say that S is a MCS of the form I (resp. II; III; IV; V). Definition 2 A row of a MCS S that intersects all other rows of S is called a kernel of S. In a forbidden induced subgraph responsible for S, any kernel of S constitutes a black vertex that is connected to all other black vertices. Property 2 Note that an induced subgraph of the form II, III, IV, or V nec- essarily contains at least one kernel, while an induced subgraph of the form I contains no kernel. We denote by GR(M ), the subgraph of GRC(M ) induced by the set of rows R, thus containing only black vertices. Graph sizes. GR(M ) has m vertices and at most min(mn, m2) edges, while GRC(M ) has m + n vertices and at most min((m + n)2, m2n) edges. 3 A global algorithm Our algorithm to decide if a row r ∈ R of a 0-1 matrix M = (R,C) belongs to at least one MCS, is based on a sequence of algorithms for finding a forbidden subgraph of GRC(M ) responsible for a MCS containing r. It looks for forbidden subgraph of the form I, III, II, IV, V, in the following order: 1. MCS of type I, 2. MCS of size 3 (types IV or V), 3. MCS of type II, 4. MCS of type III, 5. MCS of type IV and size larger or equal to 4, and MCS of type V and size larger or equal to 4. See Figure 4 for an overview. The steps 1 to 4 are based on straightforward brute-force algorithms, while the two last steps relies to a reduction to the detection of induced chordless cycles in ad-hoc graphs. In the following, we simply write GRC(M ) as G and GR(M ) as GR. 3.1 Step 1: Forbidden induced subgraph I We first test if r belongs to a MCS of the form I. If it is true, then r belongs to an induced chordless cycle of G of length at least 4 containing only black vertices. Such a cycle exists in G if and only if is also a chordless cycle in GR since GR is the subgraph of G induced by the set of rows R. Thus it suffices to search for an induced chordless cycle in GR. Proposition 1 Algorithm Check I is correct and runs in worst case O(m5) time. Proof. The correctness of Algorithm Check I comes from the fact that, r is contained in a MCS of the form I if and only if r belongs to an induced chordless cycle of GR of length at least 4 whose set of vertices S constitutes the MCS (Figure 4.I). A P4 of GR is an induced chordless path of GR containing 4 vertices. 4 Figure 4: The different steps of the algorithm: in each case, when row r has a specific location in the forbidden induced subgraph that is looked for, this location is indicated in bold character. Other rows and columns of the forbidden induced subgraph are indicated in grey color characters. In this case, Algorithm Check I returns such a set of vertices since an induced chordless cycle of GR of length at least 4 containing r is a P4 containing r whose extremities are linked by a chordless path in the subgraph of G that does not contain the neighborhood of the internal vertices of the P4. This set S cannot contain a smaller subset of rows that is a MCS, as no subset of S can be a MCS of the form I, or a MCS of any other form because of Property 2. Algorithm Check I might be implemented in O(m5). The test performed on a give P4 containing r (lines 2-5 of the algorithm) can be achieved in O(min(mn, m2) + m log m) as follows: removing the neighborhood of its inter- nal vertices might be done in min(mn, m2) time, and finding a chordless path between the two extremities might be performed using Dijkstra's algorithm in O(min(mn, m2) + m log m) time. Enumerating all P4 containing r might be done in time O(m3) using a BFS from r stopping at depth 4. Eventually, the whole algorithm is in O(m3(min(mn, m2) + m log m)) = O(m5) time. 2 5 !!!!"#"$!"#"$"$"%"#!"$"%!"#!"#!!"#"#"$"$"$"%"%"%""#$#$%""$&"""$&"#$&"#'!"#"$&!&"#('#$&#$)#'#(!'(&&'!)"'"("#"$'("#"$"#"$))) Algorithm 1 Check I (r, GR) -- O(m5) Input: a row r, the subgraph GR. returns a MCS S given by a forbidden induced subgraph of Output: the form I containing r if such a MCS exists, otherwise returns "NO". 1: for any P4 of GR containing r do 2: Consider the graph G(cid:48) obtained from GR after removing the two internal vertices of the P4 and their neighborhood from the graph, and consider the extremities ri and rj of the P4 if there exists a rirj-path in G(cid:48) then 3: 4: 5: find a chordless path P in this graph linking ri and rj. return the set of vertices of the P4 plus the set of vertices of P end if 6: 7: end for 8: return "NO" Precomputation. In the following steps, we assume that the following pre- computations have been achieved: • For any triplet of rows (r, ri, rj) that are pairwise intersecting, i.e each couple is an edge in G, r − (ri ∪ rj) and (ri ∩ rj) − r are precomputed ; • Two rows ri and rj are overlapping if ri ∩ rj (cid:54)= ∅ and ri − rj (cid:54)= ∅ and (cid:54)= ∅. The overlapping relation between any couple of rows is rj − ri precomputed ; • For any quadruplet of rows (r, ri, rj, rk) such that ri, rj, and rk overlap r, r − (ri ∩ rj ∩ rk) is precomputed. All those precomputations can simply be performed in O(m4n) time using straightforward algorithms, that is, scanning the n columns of the input matrix for each triplet or quadruplet of rows. 3.2 Step 2: Forbidden induced subgraph responsible for a MCS of size 3 We test here if r belongs to a MCS of size 3. A MCS of size 3 is necessarily caused by a forbidden induced subgraph of the form IV or V. As a consequence, the following property is immediate. Property 3 A MCS of size 3 is always composed of 3 rows that are pairwise overlapping. 6 Algorithm 2 Check IV V 3 (r, G) -- O(m2) Input: a row r, the row-column intersection graph G. Output: returns a MCS S of size 3 given by a forbidden induced subgraph of the form IV or V containing r if such a MCS exists, otherwise returns "NO". 1: for any couple (ri, rj) of black vertices that both overlap r, and overlap each other do if r − (ri ∪ rj) (cid:54)= ∅ and ri − (r ∪ rj) (cid:54)= ∅ and rj − (r ∪ ri) (cid:54)= ∅ then return {r, ri, rj} end if if (ri ∩ rj) − r (cid:54)= ∅ and (r ∩ rj) − ri (cid:54)= ∅ and (r ∩ ri) − rj (cid:54)= ∅ then return {r, ri, rj} 2: 3: 4: 5: 6: end if 7: 8: end for 9: return "NO" Proposition 2 Algorithm Check IV V 3 is correct and runs in O(m2) time. Proof. The correctness of Algorithm Check IV V 3 comes from the fact that, r is contained in a MCS of size 3 if and only if this MCS is caused by a forbidden induced subgraph of the form IV or V (Property 3). Thus, r should belong to a triplet of rows (r, ri, rj) that are pairwise overlapping, and satisfy the conditions given in: • either, line 2 of the algorithm to produce a forbidden induced subgraph of the form IV (left-end graph in Figure 4.IV V 3), • or, line 5 of the algorithm to produce a forbidden induced subgraph of the form V (right-end graph in Figure 4.IV V 3). In both cases, Algorithm Check IV V 3 returns the set {r, ri, rj} as a MCS if such a set of rows exists. This set cannot contain a smaller subset of rows that is a MCS as 3 is the minimum size of any MCS. Algorithm Check IV V 3 runs in O(m2) time since, given r, there might be O(m2) couples (ri, rj) on which the tests performed (lines 2-8 of the algorithm) might be achieved in O(1), thanks to the precomputations that have been done. 2 3.3 Step 3: Forbidden induced subgraph II We test here if r belongs to a MCS of the form II, with the assumption that r is not contained in any MCS of size 3. Note that such a MCS is of size 4. 7 Algorithm 3 Check II 4 (r, G) -- O(m3) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3. returns a MCS S given by a forbidden induced subgraph of Output: the form II containing r if such a MCS exists, otherwise returns "NO". return {r, ri, rj, rk} if there are no edges (ri, rj), (ri, rk), and (rj, rk) in G then 1: for any triplet (ri, rj, rk) of black vertices such that ri, rj, rk overlap r do 2: 3: end if 4: 5: end for 6: for any triplet (ri, rj, rk) of black vertices of such that ri overlaps r, and rj, rk overlap ri do if there are no edges (r, rj), (r, rk), or (rj, rk) in G then return {ri, r, rj, rk} 7: 8: end if 9: 10: end for 11: return "NO" Proposition 3 Algorithm Check II 4 is correct and runs in O(m3) time. Proof. The correctness of Algorithm Check II 4 comes from the fact that, if r belongs to a MCS of the form II, then r should belong to a quadruplet of rows (r, ri, rj, rk) such that one these rows is a kernel, and the three other rows do not intersect each other. Thus, the row r is: • either, a kernel of the MCS, tested in lines 1-5 of the algorithm (left-end graph in Figure 4.II 4), • or, not a kernel of the MCS tested in lines 6-10 of the algorithm (right-end graph in Figure 4.II 4). In both cases, Algorithm Check II 4 returns the set {r, ri, rj, rk} as a MCS if such a set of rows exists. This set cannot contain a smaller subset of rows that is a MCS as this subset would be a subset of 3 rows that cannot satisfy Property 3. Algorithm Check IV V 4 runs in O(m3) time since all the tests performed on a given triplet (ri, rj, rk) in lines 2-4 and 7-9 of algorithm can be achieved in O(1), and given r there might be O(m3) such triplets. 2 8 3.4 Step 4: Forbidden induced subgraph III We test here if r belongs to a MCS of the form III, with the assumption that r is not contained in a MCS of size 3. Note that such a MCS is of size 4. Algorithm 4 Check III 4 (r, G) -- O(m3) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3. returns a MCS S given by a forbidden induced subgraph of Output: the form III containing r if such a MCS exists, otherwise returns "NO". r − (ri ∩ rj ∩ rk) (cid:54)= ∅ do 1: for any triplet (ri, rj, rk) of black vertices such that ri, rj, rk overlap r, and if there are no edge (ri, rk) in G, and (ri∩rj)−r (cid:54)= ∅, and (rj∩rk)−r (cid:54)= ∅ then 2: return {r, ri, rj, rk} 3: end if 4: 5: end for 6: for any triplet (ri, rj, rk) of black vertices of such that ri overlaps r, and rj, rk overlap ri, and ri − (r ∩ rj ∩ rk) (cid:54)= ∅, and {ri, rj, rk} is not a MCS do if there are no edge (r, rk) in G, and (r∩rj)−ri (cid:54)= ∅, and (rj∩rk)−ri (cid:54)= ∅ then 7: return {ri, r, rj, rk} 8: end if 9: 10: end for 11: for any triplet (ri, rj, rk) of black vertices of such that ri overlaps r, and if there are no edge (rj, rk) in G, and (rj∩r)−ri (cid:54)= ∅, and (r∩rk)−ri (cid:54)= ∅ then rj, rk overlap ri, and ri − (r ∩ rj ∩ rk) (cid:54)= ∅ do 12: return {ri, rj, r, rk} 13: end if 14: 15: end for 16: return "NO" Proposition 4 Algorithm Check III 4 is correct and runs in O(m3) time. Proof. The correctness of Algorithm Check III 4 comes from the fact that, r belongs to a MCS of the form III if and only if r should belong to a quadruplet of rows (r, ri, rj, rk) included in an induced subgraph of the form III such that two of these rows are kernels of the subgraph, and one of these kernels contains a column of the induced subgraph that is not shared with any of the other rows. 9 Let us call this kernel kernel 1, and the other kernel kernel 2. For example in the left-end graph in Figure 4.III 4, kernel 1=r, and kernel 2=rj. Thus, the row r is: • either, kernel 1, tested in lines 1-5 of the algorithm (left-end graph in Figure 4.III 4), • or, not a kernel, tested in lines 6-10 of the algorithm (middle graph in Figure 4.III 4). • or, kernel 2, tested in lines 11-15 of the algorithm (right-end graph in Figure 4.III 4). In the first, and third cases, the set {ri, rj, rk} cannot be a MCS because such a set cannot satisfy Property 3 In all cases, Algorithm Check III 4 returns the set {r, ri, rj, rk} as a MCS if such a set of rows exists, and {ri, rj, rk} is not a MCS (in the second case). Since we made the assumption that r is not contained in a MCS of size 3, there cannot exists a smaller subset of {ri, rj, rk} containing r that is a MCS. Algorithm Check III 4 runs in O(m3) time using a similar proof as the com- plexity proof for Check IV V 4: all the tests performed by the algorithm (lines 2-4, 7-9, and 12-14 of the algoritms) on a given triplet (ri, rj, rk) are achieved in O(1) thanks to the precomputations, and given r there might be O(m3) such triplets. 2 3.5 Step 5: Forbidden induced subgraph IV We test here if r belongs to a MCS of the form IV, with the assumption that r is contained, neither in a MCS of size 3, nor in a MCS of type I. Depending on whether the size of the MCS is 4 or larger than 4, we describe two algorithms. 3.5.1 MCS of size 4 We first test if r belongs to a MCS of the form IV of size 4. We look for a triplet of rows (ri, rj, rk) such that the set {r, ri, rj, rk} is a MCS of the form IV (Figure 4.IV 4). In an induced subgraph of the form IV containing 4 rows {r, ri, rj, rk}, two rows are kernels, and in that case, r is either a kernel of the MCS, or not. If r is a kernel, then it is either a kernel -- called kernel 1 -- containing a column of the induced subgraph that is not shared with any of the other rows , or not -- called kernel 2 -- . For example, in the left-end graph in Figure 4.IV 4, the two kernel are the two central black vertices of the graph: the top one is a kernel 1, and the bootom one a kernel 2. Algorithm Check IV 4 looks for each of these configurations: • r is a kernel 1, tested in lines 1-5 of the algorithm; • r is not a kernel,tested in lines 6-10 of the algorithm; • r is a kernel 2, tested in lines 11-15 of the algorithm. 10 The proof of the correctness of Algorithm Check IV 4 is similar to the proof for Algorithm Check III 4. Algorithm 5 Check IV 4 (r , G) -- O(m3) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3. Output: returns a MCS S of size 4 given by a forbidden induced subgraph of the form IV containing r if such a MCS exists, otherwise returns "NO". to r, and r − (ri ∩ rj ∩ rk) (cid:54)= ∅ do 1: for any triplet (ri, rj, rk) of black vertices such that ri, rj, rk are connected there are no edge (ri, rk) in G, and (ri ∩ rj) (cid:54)= ∅, and (rj ∩ rk) (cid:54)= ∅, return {r, ri, rj, rk} if and ri − (r ∪ rj) (cid:54)= ∅, and rk − (r ∪ rj) (cid:54)= ∅ then 3: end if 4: 5: end for 6: for any triplet (ri, rj, rk) of black vertices of such that ri is connected to r, and rj, rk are connected to ri, and ri − (r ∩ rj ∩ rk) (cid:54)= ∅, and {ri, rj, rk} is not a MCS do if there are no edge (r, rk) in G, and (r ∩ rj) (cid:54)= ∅, and (rj ∩ rk) (cid:54)= ∅, and r − (ri ∪ rj) (cid:54)= ∅, and rk − (ri ∪ rj) (cid:54)= ∅ then 2: 7: return {ri, r, rj, rk} 8: end if 9: 10: end for 11: for any triplet (ri, rj, rk) of black vertices of such that ri is connected to if there are no edge (rj, rk) in G, and (rj ∩ r) (cid:54)= ∅, and (r ∩ rk) (cid:54)= ∅, and rj − (r ∪ ri) (cid:54)= ∅, and rk − (r ∪ ri) (cid:54)= ∅ then r, and rj, rk are connected to ri, and ri − (r ∩ rj ∩ rk) (cid:54)= ∅ do 12: return {ri, rj, r, rk} 13: end if 14: 15: end for 16: return "NO" Proposition 5 Algorithm Check IV 4 is correct and runs in O(m3) time. Proof. The proof for Algorithm Check IV 4 is similar to the proof for Algorithm Check III 4. 2 3.5.2 MCS of size larger than 4 We test here if r belongs to a MCS of the form IV of size larger than 4. A MCS of the form IV of size larger than 4 contains one and only one kernel. Depending 11 on whether r is the kernel or not, we distinguish two cases here. Case 1: If row r is the kernel of the MCS Algorithm Check IVk recovers a MCS S of the form IV of size larger than 4 containing r as a kernel, with the assumption that r is not contained in a MCS of size 3 (Figure 4.IVk). The principle of the algorithm relies in first choosing the column c ∈ C, of the forbidden induced subgraph of type IV responsible for S, that is contained in r, and in no other row of the MCS (see Figure 4.IVk). Next, it considers the subgraph H of G induced by the set of black vertices (rows) that are neighbors of r, but do not contain the column c. We denote this subgraph by H = G[N (r) − L(c)]. Then, it looks for a set of rows Q, constituting a chordless path in H, such that {r} ∪ Q is a MCS of the form IV. Algorithm 6 Check IVk (r, G) -- O(nm2) returns forbidden Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3. Output: a nel 1: for any column c ∈ r do 2: H = G[N (r) − L(c)] a MCS S subgraph a MCS induced such of exists, of size the if is r larger that 4 given form IV whose otherwise returns by ker- "NO". 3: 4: 5: 6: 7: for any connected component C of H do pick a a couple (ri, rj) of black vertices in C that satisfies 1) ri and rj are not connected, and 2) ri, rj overlap r. find a chordless path P in C linking ri and rj pick the smallest subpath Q of P linking two vertices r(cid:48) that the couple (r(cid:48) return {r} ∪ Q j) also satisfies 1) and 2) i and r(cid:48) j, such i, r(cid:48) end for 8: 9: end for 10: return "NO" Proposition 6 Algorithm Check IVk is correct and runs in O(nm2) time. Proof. Note that, if the MCS exists, then all the rows belonging to the MCS, except r, belong to a same connected component of H. Thus, in each connected component of H, the algorithm looks for a chordless path Q linking two vertices ri, rj satisfying 1) ri and rj are not connected, and 2) ri, rj overlap r, and 3) Q does not contain any smaller subpath satisfying conditions 1) and 2). These conditions are necessary and sufficient for the set {r} ∪ Q to form the rows of 12 a induced subgraph of the form IV . The set {r} ∪ Q cannot contain a subset that is a MCS as such a smaller MCS should be: • either a MCS of size 3 including r, which impossible by assumption, • or a MCS of type II or III necessarily including r as kernel, • or a MCS of type IV and size larger than 3 having r as kernel. The two last cases are also impossible, since Q would not have satisfy condition 3) in these cases. Next, there might be n columns c ∈ r and up to m2 couples (ri, rj) of black vertices to test before finding a valid couple (ri, rj) satisfying the conditions in line 4 of the algorithm. Up to this point, the complexity is in O(nm2). Assume now that such a couple exist. Then finding a chordless path between ri and rj might be done by searching for a shortest path between ri and rj in the connected component C using Dijkstra's algorithm, which thus requires at worst O(min(mn, m2) + m log m) time. The path is of length at most m, and thus identifying r(cid:48) j is bounded by testing each pair on this path in C, which requires at worst O(m2) time. Thus, in total, the algorithm is O(nm2) worst case time. 2 i and r(cid:48) Case 2: If row r is not the kernel of the MCS Algorithm Check IVp recovers a MCS S of the form IV of size larger than 4 containing r, but not as a kernel, with the assumptions that r is not contained in a MCS of size 3, and r does not belong to an induced chordless cycle of GR (Figure 4.IVp). The principle of the algorithm consists in first choosing the kernel a of S among the black vertices (rows) neighbors of r, and the column c ∈ C, of the induced subgraph of type IV responsible for S, that is contained in a, but in no other row of the MCS. (see Figure 4.IVp). Next, the algorithm calls Algorithm Check IV to look for the MCS S with r, a, c, and G given as parameters. Algorithm Check IV is called in Algorithm Check IVp. It recovers a MCS S of the form IV of size larger than 4 containing r, given the row r, the kernel a of the MCS S, and the column c ∈ C, of the induced subgraph of type IV responsible for S, that is contained in a, but in no other row of the MCS (Figure 4.IVp). Proposition 7 Algorithm Check IVp is correct, and runs in O(nm6) time. Proof. The correctness and the complexity of Check IVp follows directly from the the correctness and the complexity of Algorithm Check IV that is called in Algorithm Check IVp. The correctness of Check IV comes from the fact that, r does not belong to any chordless cycle in the graph C computed at line 2 of the algorithm by assumption. Then at line 6 of the algorithm, any chordless cycle in the graph 13 Algorithm 7 Check IVp (r, G) -- O(nm6) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3. r does not belong to an induced chordless cycle of GR. returns a MCS S of the Output: bidden induced subgraph of nel such not a MCS is if r size larger that 4 given by a for- form IV containing r whose ker- "NO". otherwise returns exists, 1: for any black vertex a ∈ N (r) do for any column c ∈ a − r do return Check IV(r, a, c, G) 2: 3: 4: 5: end for 6: return "NO" end for Algorithm 8 Check IV (r, a, c, G) -- O(m5) Input: two rows r and a, and a column c ∈ a such that r ∈ (N (a) − L(c)) . Assumption: r is not contained in a MCS of size 3. r does not belong to an induced chordless cycle of GR. returns a MCS S of size larger Output: bidden whose kernel induced subgraph of the form IV containing is a if such a MCS exists, that 4 given by a for- a, returns "NO". otherwise and r 1: H = G[N (a) − L(c)] 2: let C = (VC, EC) be the connected component of H to which r belongs. 3: let Va be the set of vertices Va = {u ∈ VC : u − a (cid:54)= ∅}. 4: let Ea be the set of edges Ea = {(u, v) ∈ V 2 5: let D = (VD, ED) be the graph such that VD = VC and ED = EC ∪ Ea. 6: Q = Check I (r, DR) 7: if Q (cid:54)= "NO" then a : u ∩ v = ∅}. return {a} ∪ Q 8: 9: end if 10: return "NO" 14 D containing vertex r necessarily contains at least one edge (ri, rj) belonging to the set Ea. The number of edges belonging to the set Ea in such a chordless cycle Q cannot be greater than 1 as any couple of such edges in the chordless cycle would induce a chord. Indeed, if Q contains more than one edge belonging to Ea, any two such edges would have to extremities in Va, one from each of the two edges, that are not connected in the graph C. These extremities would thus be linked by an edge in Ea, creating a chord for the cycle Q in the graph D. Therefore, the set of vertices of the chordless cycle Q induces a chordless path in G such that each vertex of Q is connected to vertex a by definition of the graph H, and the extremities ri and rj of Q satisfy 1) ri and rj are not connected in G, and 2) ri, rj overlap r, and 3) Q does not contain any smaller subpath satisfying conditions 1) and 2). These conditions are necessary and sufficient for the set {a} ∪ Q to form the rows of an induced subgraph of the form IV , and this set cannot contain a smaller MCS since such a MCS would be: • either a MCS of size 3 including a, • or a MCS of type II or III necessarily including a as kernel, • or a MCS of type IV and size larger than 3 having a as kernel. The 3 cases are impossible, since they would induce a chord from the set Ea in the chordless cycle induced by Q in the graph D. Algorithm Check IV calls Algorithm Check I. Both algorithms have the same time complexity in O(m5) time. It follows immediately that Algorithm Check IVp runs in Onm6 time. 2 3.6 Step 6: Forbidden induced subgraph V We test here if r belongs to a MCS of the form V, with the assumption that r is contained neither in a MCS of size 3, nor in a MCS of type I. Depending on whether the size of the MCS is 4, 5 or larger than 5, we describe three algorithms. 3.6.1 MCS of size 4 or 5 We first test if r belongs to a MCS of the form V of size 4 or 5. For a MCS of size 4, we look for a triplet of rows (ri, rj, rk) such that the set (r, ri, rj, rk) is a MCS of the form V. In such a case, we look for an induced subgraph responsible for the MCS, containing r, ri, rj, rk as four black vertices pairwise connectedr, and we can pick three different couples of r, ri, rj, rk such that each couple shares a column (white vertex) that is not shared with the two other of the MCS (see Figure 4.V 4). Proposition 8 Algorithm Check V 4 is correct and runs in O(m3) time. 15 Algorithm 9 Check V 4 (r , G) -- O(m3) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3. Output: returns a MCS S of size 4 given by a forbidden induced subgraph of the form V containing r if such a MCS exists, otherwise returns "NO". to r, and are pairwise connected do 1: for any triplet (ri, rj, rk) of black vertices such that ri, rj, rk are connected (ri, rj, rk) is not a MCS, and (r ∩ ri) − (rj ∪ rk) (cid:54)= ∅, and (rj ∩ rk) − if (ri ∩ rj) − (r ∪ rk) (cid:54)= ∅ then if (r ∪ ri) (cid:54)= ∅ then 2: 3: 4: return {r, ri, rj, rk} end if if (r ∩ rj) − (ri ∪ rk) (cid:54)= ∅ then return {ri, r, rj, rk} 5: 6: 7: 8: end if 9: 10: end for 11: return "NO" end if 16 Proof. Algorithm Check V 4 looks for an induced subgraph with 4 black vertices {r, ri, rj, rk}, that are pairwise connected to each other. These 4 black vertices should be such that there exist three different couples of vertices among them, such that two couples are disjoint and the third one (called couple kernel) over- laps the two first, and the 2 rows of each of these couples share a column that is not shared with the two other rows of the set. In this case, if {ri, rj, rk} is not a MCS, then the subgraph induced by {r, ri, rj, rk} and the 3 columns (white vertices) connected to the 3 couples of rows is of the form V, and is responsible for a MCS {r, ri, rj, rk}. Algorithm Check V 4 looks for two cases, depending on whether r belong to couple kernel (lines 3-5), or not (lines 6-8). Next, all the tests performed by Algorithm Check V 4 (lines 2-9 of the algo- ritm) on a given triplet (ri, rj, rk) are achieved in O(1) thanks to the precom- putations, and given r there might be O(m3) such triplets. Thus, Algorithm Check V 4 runs in O(m3) time. 2 Next, for a MCS of size 5, we look for a quadruplet of rows (ri, rj, rk, rl) such that the set {r, ri, rj, rk, rl} is a MCS of the form V (Figure 4.V 5). Algo- rithm Check V 5 looks for an induced subgraph of the form V, consisting of 5 rows (black vertices) r, ri, rj, rk, rl that are pairwise connected, except for a on missing edge, say (ra, rb) in {r, ri, rj, rk, rl}×{r, ri, rj, rk, rl}, and three columns (white vertices) satisfying the configuration of Figure 4.V 5. Proposition 9 Algorithm Check V 5 is correct and runs in O(m4) time. Proof. Algorithm Check V 5 looks for an induced subgraph with 5 black vertices {r, ri, rj, rk, rl}, that are pairwise connected, except for one missing edge (ra, rb) in {r, ri, rj, rk, rl}×{r, ri, rj, rk, rl}. The 4 black vertices that belong to the set with r, should correspond to a set of rows that is C1P. Moreover, there should exist two particular rows (black vertices) of the set, with three columns (white vertices) that satisfy the conditions on line 4 of the algorithm in order to fit the configuration depicted in Figure 4.V 5. Next, all the tests performed by Algorithm Check V 5 (lines 2-8 of the al- goritm) on a given quatruplet (ri, rj, rk, rl) are achieved in O(1) thanks to the precomputations, and given r there might be O(m4) such triplets. Thus, Algo- rithm Check V 5 runs in O(m4) time. 2 3.6.2 MCS of size larger than 5 A MCS of the form V of size larger than 5 contains exactly two kernels. De- pending on whether r is a kernel or not, we distinguish two cases. Case 1: If row r is a kernel of the MCS Algorithm Check Vk recovers a MCS S of the form V of size larger than 5 containing r as a kernel, with the assumption that r is not contained in a MCS of size 3, or 4 (Figure 4.Vk). The principle of the algorithm is similar to Algorithm Check IVk. It relies in first choosing the second kernel a of the MCS, and the column c, of the induced subgraphof type V responsible for S, 17 Algorithm 10 Check V 5 (r , G) -- O(m4) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3 or 4. Output: returns a MCS S of size 5 given by a forbidden induced subgraph of the form V containing r if such a MCS exists, otherwise returns "NO". 1: for any quadruplet (ri, rj, rk, rl) of black vertices such that r, ri, rj, rk, rl are pairwise connected, except for one edge (ra, rb) in {r, ri, rj, rk, rl} × {r, ri, rj, rk, rl} missing do if {ri, rj, rk, rl} is C1P then 2: 3: 4: 5: for any pair (a, b) in ({r, ri, rj, rk, rl} − {ra, rb}) × ({r, ri, rj, rk, rl} − {ra, rb}) do if (a ∩ b) − ∪(cid:0){r, ri, rj, rk, rl} − {a, b}(cid:1) (cid:54)= ∅, and (rk ∩ a) − ∪(cid:0){r, ri, rj, rk, rl} − {rk, a}(cid:1) (cid:54)= ∅, and (rl ∩ b) − ∪(cid:0){r, ri, rj, rk, rl} − {rl, b}(cid:1) (cid:54)= ∅ then return {r, ri, rj, rk, rl} end if end for 6: 7: end if 8: 9: end for 10: return "NO" 18 that is contained in both r and a, but in no other row of the MCS (see Figure 4.Vk). Next, it considers the subgraph H of G induced by the set of black vertices (rows) that are neighbors of r and a, but do not contain c. We denote this subgraph by H = G[N (r, a) − L(c)]. Then, it looks for a set of rows Q, constituting a chordless path in H, such that {r} ∪ Q is a MCS of the form V. Algorithm 11 Check Vk (r, G) -- O(n2m2) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3, or 4. Output: forbidden induced subgraph of of a MCS S of the a MCS returns kernel, exists, larger such size otherwise its if form V such that that 5 given by a is one "NO". r returns 1: for any black vertex a ∈ N (r) do for any column c ∈ (r ∩ a) do H = G[N (r, a) − L(c)] for any connected component C of H do 2: 3: 4: 5: 6: 7: end for 8: 9: 10: 11: end for 12: return "NO" end for pick a a couple (ri, rj) of black vertices in C that satisfies 1) ri and rj are not connected, and 2) (ri ∩ r) − a (cid:54)= ∅, and 3) (rj ∩ a) − r (cid:54)= ∅. find a chordless path P in C linking ri and rj pick the smallest subpath Q of P linking two vertices r(cid:48) that the couple (r(cid:48) return {r} ∪ Q j) also satisfies 1) and 2) and 3) i, r(cid:48) i and r(cid:48) j, such Proposition 10 Algorithm Check Vc is correct and runs in O(n2m2) time. Proof. The proofs are similar to the proofs for the correctness and the complexity of Algorithm Check IVc as the two algorithms are based on the same principle. However, here the complexity is multiplied by a factor n due to considering all black vertices a ∈ N (r). 2 Case 2: If row r is not a kernel of the MCS Algorithm Check Vp recovers a MCS S of the form V of size larger than 5 containing r, but not as a kernel, with the assumptions that r is not contained in a MCS of size 3 or 4, and r does not belong to an induced chordless cycle of GR (Figure 4.V). 19 The principle of the algorithm is similar to the principle of Algorithm Check IVp. It consists in first choosing the two kernels (a, b) of S among the black vertices (rows) neighbors of r, and the column c, of the induced subgraph responsible for S, that is contained in both a and b, but in no other row of the MCS. Next, the algorithm calls Algorithm Check V to look for the MCS S with r, (a, b), c, and G given as parameters. Algorithm 12 Check Vp (r, G) -- O(nm7) Input: a row r, the row-column intersection graph G. Assumption: r is not contained in a MCS of size 3, 4. r does not belong to an induced chordless cycle of GR. Output: bidden induced subgraph of as returns a MCS S of the a MCS kernel, such if a size larger form V containing exists, that 5 given by a for- but not "NO". otherwise returns r, 1: for any couple of connected black vertices (a, b) ∈ N (r)2 do for any column c ∈ (a ∩ b) − r do return Check V (r, (a, b), c, G) 2: 3: 4: 5: end for 6: return "NO" end for Algorithm Check V is called in Algorithm Check Vp. It recovers a MCS S of the form V of size larger than 5 containing r, given the row r, the kernels a and b of the MCS, and the column c, of the induced subgraph responsible for S, that is contained in a and b, but in no other row of the MCS. Proposition 11 Algorithm Check Vp is correct and runs in O(nm7) time. Proof. In order to prove the correctness and the complexity of Algorithm Check Vp, we need to prove the correctness and give the complexity of Al- gorithm Check V that is called in Check Vp. The correctness of Check V comes from the fact that r does not belong to any chordless cycle in the graph C computed at line 2 of the algorithm by assumption. Let Q be a chordless cycle in the graph D containing vertex r, computed at line 9 of the algorithm. Since r does not belong to an induced chordless cycle of the C by assumption, then Q necessarily contains at least one edge belonging to the set EAB ∪ Ea ∪ Eb. We first give two trivial but useful properties for the remaining of the proof: (i) For any two edges of Q, there always exists two extremities u and v of these edges, one in each edge, that are not disjoint in the graph C, i.e u ∩ v = ∅ 20 Algorithm 13 Check V (r, (a, b), c, G) -- O(m5) three rows r, a and b, and a column c ∈ a ∩ b such that Input: r ∈ (N (a, b) − L(c)) . Assumption: r is not contained in a MCS of size 3, 4 or 5. r is not contained in a MCS of type IV . r does not belong to an induced chordless cycle of GR. Output: induced subgraph of the form V containing a, kernels are a and b, returns a MCS S of size larger that 5 given by a forbidden b, and r, and whose if such a MCS exists, otherwise returns "NO". 1: H = G[N (a, b) − L(c)] 2: let C = (VC, EC) be the connected component of H to which r belongs. 3: let VA be the set of vertices VA = {u ∈ VC : (u ∩ a) − b (cid:54)= ∅}. 4: let VB be the set of vertices VB = {v ∈ VC : (v ∩ b) − a (cid:54)= ∅}. 5: let EAB be the set of edges EAB = {(u, v), u ∈ VA, v ∈ VB : u ∩ v = ∅}. 6: let Va be the set of vertices Va = {u ∈ VC : u − a (cid:54)= ∅}, and Ea be the set 7: let Vb be the set of vertices Vb = {u ∈ VC : u − b (cid:54)= ∅}, and Eb be the set 8: let D = (VD, ED) be the graph such that VD = VC and ED = EC ∪ EAB ∪ of edges Ea = {(u, v) ∈ V 2 of edges Eb = {(u, v) ∈ V 2 Ea ∪ Eb a : u ∩ v = ∅}. : u ∩ v = ∅}. b 9: Q = Check I (r, DR) 10: if Q (cid:54)= "NO" then return {a, b} ∪ Q 11: 12: end if 13: return "NO" 21 (ii) VA ⊆ Vb, and VB ⊆ Va. We also prove the following useful property: (iii) Va ⊆ (VB ∪ Vb) and Vb ⊆ (VA ∪ Va). Let x ∈ Va, there exists c such that c ∈ x and c (cid:54)∈ a. Then, either c (cid:54)∈ b in which case x ∈ Vb, or c ∈ b, which implies that x ∈ VB. The proof is similar for Vb ⊆ (VA ∪ Va). We now prove that the cycle Q necessarily contains at most one edge of the set EAB ∪ Ea ∪ Eb. Indeed, if Q contains two edges of EAB ∪ Ea ∪ Eb, let u, v be two disjoint extremities of these edges (Property (i)). We can distinguish 7 cases according to the belonging of u and v to the sets VA, VB, Va and Vb, and we show in the following that, in all these cases, a chord is induced in the chordless cycle Q in the graph D: contradiction. 1. If (u, v) ∈ V 2 (resp. (u, v) ∈ V 2 A (resp. (u, v) ∈ V 2 B), then from Property (ii), (u, v) ∈ V 2 a ), and thus (u, v) ∈ Eb (resp. (u, v) ∈ Ea). b a (resp. (u, v) ∈ V 2 b ), then (u, v) ∈ Ea (resp. (u, v) ∈ Eb). 2. If (u, v) ∈ V 2 3. If (u, v) ∈ VA × VB (or the symmetric), then (u, v) ∈ EAB. 4. If (u, v) ∈ VA × Va (or the symmetric), then from Property (iii), (u, v) ∈ VA × VB or (u, v) ∈ VA × Vb, and thus (u, v) ∈ EAB or (u, v) ∈ Eb from cases 3. and 6. 5. If (u, v) ∈ VB × Vb (or the symmetric), then from Property (iii), (u, v) ∈ VB × VA or (u, v) ∈ VB × Va, and thus (u, v) ∈ EAB or (u, v) ∈ Ea from cases 3. and 6. 6. If (u, v) ∈ VA × Vb (resp. (u, v) ∈ VB × Va) (or the symmetric), then from a ), and thus (u, v) ∈ Eb (resp. b (resp. (u, v) ∈ V 2 Property (ii), (u, v) ∈ V 2 (u, v) ∈ Ea). 7. If (u, v) ∈ Va × Vb (or the symmetric), then from Property (iii), (u, v) ∈ Vb × Vb or (u, v) ∈ VB × Vb, and thus (u, v) ∈ Eb or (u, v) ∈ EAB ∪ Ea from cases 1 and 5. In consequence, there exits at most one edge, and then exactly one edge of the set EAB ∪ Ea ∪ Eb in the cycle Q in the graph D. Next, let (ri, rj) be the only edge of Q belonging to EAB ∪ Ea ∪ Eb. We show that (ri, rj) (cid:54)∈ Ea ∪ Eb. Indeed, if (ri, rj) ∈ Ea (resp. (ri, rj) ∈ Eb), then the set {a}∪ Q (resp. {b}∪ Q) satisfies the conditions to be a MCS of type IV with a (resp. b) as kernel, which is impossible by assumption. So, we have (ri, rj) ∈ EAB − (Ea ∪ Eb). Finally, removing the edge (ri, rj) from the cycle yields a chordless path Q in G containing r such that each vertex of Q is connected to vertices a and b, and the extremities ri and rj of Q satisfy 1) ri and rj are not connected, and 2) (ri ∩ a) − b (cid:54)= ∅, and 3) (rj ∩ b) − a (cid:54)= ∅. and 4) Q does not contain any smaller subpath satisfying conditions 1) and 2) 22 and 3). These conditions are necessary and sufficient for the set {a, b} ∪ Q to form the rows of an induced subgraph of the form V, and this set cannot contain a smaller MCS since such a MCS would be: • either a MCS of size 3 including a or b, • or a MCS of type II or III necessarily including a or b as kernel, • or a MCS of type IV and size larger than 3 having a or b as kernel. • or a MCS of type IV and size larger than 3 having a and b as kernels. The 3 cases are impossible, since they would induce a chord from the set EAB ∪ Ea ∪ Eb in the chordless cycle induced by Q in the graph D. The correctness of Algorithm Check Vp follows immediately from the cor- rectness of Algorithm Check V. Algorithm Check V calls Algorithm Check I. Both algorithms have the same time complexity in O(m5) time. It follows immediately that Algorithm Check IVp runs in Onm7 time. 2 Acknowledgment We would like to thanks Nicolas Trotignon for his valuable comments on induced subgraphs and also Juraj Stacho for his participation to some meeting on the subject. References [1] A. Bergeron, M. Blanchette, A. Chateau, and C. Chauve. Reconstructing ancestral gene orders using conserved intervals. In Workshop on Algo- rithms in Bioinformatics (WABI04), number 3240 in LNCS, pages 14 -- 25. Springer, 2004. [2] G. Blin, R. Rizzi, and S. Vialette. A faster algorithm for finding minimum tucker submatrices. In 6th Conference on Computability in Europe (CiE), volume 6158 of LNCS, pages 69 -- 77, 2010. [3] G. Blin, R. Rizzi, and S. Vialette. A polynomial-time algorithm for finding a minimal conflicting set containing a given row. In CSR, volume 6651 of Lecture Notes in Computer Science, pages 373 -- 384. Springer, 2011. [4] C. Chauve, U.-U Haus, T. Stephen, and V.P. You. Minimal conflicting sets for the consecutive ones property in ancestral genome reconstruction. In Recomb - Comparative Genomics (Recomb-CG09), number 5817 in LNCS, pages 48 -- 58. Springer, 2009. [5] C. Chauve and E. Tannier. A methodological framework for the recon- struction of contiguous regions of ancestral genomes and its application to mammalian genomes. PLoS Comput Biol, 4(11), 11 2008. 23 [6] M. Dom. Algorithmic aspects of the consecutive-ones property. Bulletin of the Eur. Assoc. for Theor. Comp. Science (EATCS), 98:27 -- 59, 2009. [7] C.G. Lekkerkerker and J.C. Boland. Representation of a finite graph by a set of intervals on the real line. Fund. Math., 51:45 -- 64, 1962. [8] T. Nishizeki and Md. S. Rahman. Planar Graph Drawing. World Scientific, 2004. [9] J. Stoye and R. Wittler. A unified approach for reconstructing ancient gene clusters. IEEE/ACM Trans. Comput. Biol. Bioinf., 6(3):387 -- 400, 2009. [10] A.C. Tucker. A structure theorem for the consecutive 1s property. Journal of Combinatorial Theory. Series B, 12:153 -- 162, 1972. 24
1512.06532
1
1512
2015-12-21T08:55:41
Path computation in multi-layer multi-domain networks: A language theoretic approach
[ "cs.DS", "cs.FL", "cs.NI" ]
Multi-layer networks are networks in which several protocols may coexist at different layers. The Pseudo-Wire architecture provides encapsulation and de-capsulation functions of protocols over Packet-Switched Networks. In a multi-domain context, computing a path to support end-to-end services requires the consideration of encapsulation and decapsulation capabilities. It appears that graph models are not expressive enough to tackle this problem. In this paper, we propose a new model of heterogeneous networks using Automata Theory. A network is modeled as a Push-Down Automaton (PDA) which is able to capture the encapsulation and decapsulation capabilities, the PDA stack corresponding to the stack of encapsulated protocols. We provide polynomial algorithms that compute the shortest path either in hops or in the number of encapsulations and decapsulations along the inter-domain path, the latter reducing manual configurations and possible loops in the path.
cs.DS
cs
Path Computation in Multi-Layer Multi-Domain Networks: A Language Theoretic Approach Mohamed Lamine Lamalia,∗, H´elia Pouyllaua, Dominique Barthb aAlcatel-Lucent Bell Labs, Route de Villejust, 91620 Nozay, France bLab. PRiSM, UMR8144, Universit´e de Versailles, 45, av. des Etas-Unis, 78035 Versailles Cedex, France Abstract Multi-layer networks are networks in which several protocols may coexist at different layers. The Pseudo-Wire architecture provides encapsulation and de- capsulation functions of protocols over Packet-Switched Networks. In a multi- domain context, computing a path to support end-to-end services requires the consideration of encapsulation and decapsulation capabilities. It appears that graph models are not expressive enough to tackle this problem. In this paper, we propose a new model of heterogeneous networks using Automata Theory. A network is modeled as a Push-Down Automaton (PDA) which is able to capture the encapsulation and decapsulation capabilities, the PDA stack corresponding to the stack of encapsulated protocols. We provide polynomial algorithms that compute the shortest path either in hops or in the number of encapsulations and decapsulations along the inter-domain path, the latter reducing manual configurations and possible loops in the path. Keywords: Multi-layer networks, Pseudo-Wire, Push-Down Automata 1. Introduction Most carrier-grade networks comprise multiple layers of technologies (e.g. Ethernet, IP, etc.). These layers are administrated by different control and/or management plane instances. The Pseudo-Wire (PWE3) architecture [2] unifies control plane functions in heterogeneous networks to allow multi-layer services (e.g. Layer 2 VPN). To this end, it defines encapsulation (a protocol is encapsu- lated into another) and decapsulation (a protocol is unwrapped from another) functions, called adaptation functions further in this paper. These functions ∗Corresponding author Email addresses: [email protected] (Mohamed Lamine Lamali), [email protected] (H´elia Pouyllau), [email protected] (Dominique Barth) c(cid:13) 2013. Licensed under the Creative Commons CC-BY-NC-ND 4.0 license http://creativecommons.org/licenses/by-nc-nd/4.0/ c(cid:13)Published version: http: // dx. doi. org/ 10. 1016/ j. comcom. 2012. 11. 009 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 allow the emulation of services (e.g. Frame Relay, SDH, Ethernet, etc.) over Packet-Switched Networks (PSN, e.g. IP or MPLS). Prior to a service deployment in a multi-layer network, the resources must be identified during the path computation process. The path computation must take into account the adaptation function capabilities in order to explore all resources and to ensure the end-to-end service deployment. The authors of [1] defined the multi-segment Pseudo-Wire architecture for multi-domain networks. In [4], the authors mention the problem of path determination over such an architecture, stressing the importance of having path computation solutions. In such an architecture, the path computation should comply with protocol compatibility constraint: if a protocol is encapsulated in a node, it must be decapsulated in another node; the different encapsulation processes should be transparent to the source and target nodes. Thus, some nodes may be physically connected but, due to protocol incompatibility, no feasible path (i.e., which com- ply with protocol compatibility) can be found between them. This constraint leads to non trivial characteristics of a shortest path [7]: i) it may involve loops (involving the same link several times but with different protocols); ii) its sub- paths may not be feasible. Computing such a path is challenging and cannot be performed by classical shortest path algorithms. Currently, the configuration of these functions is manually achieved within each network domain: when an encapsulation function is used, the correspond- ing decapsulation function is applied within the domain boundaries. In large- scale carrier-grade networks or in multi-domain networks, restricting the loca- tion of the adaptation functions to the domain boundaries might lead to ignore feasible end-to-end paths leading to a signaling failure. Hence, in the path computation process, it must be possible to nest several encapsulations (e.g. Ethernet over MPLS over SDH). A decapsulation should not be restricted to the same domain as its corresponding encapsulation. This allows the exploration of more possible paths and new resources in the path computation. The problem we address is to compute the shortest feasible path either in the number of nodes or in the number of involved (and possibly nested) adap- tation functions. The latter is motivated by two goals: i) as such functions are manually configured on router interfaces, minimizing their number would simplify the signaling phase when provisioning the path; ii) as our algorithms do not allow loops without adaptation functions (loops without encapsulations or decapsulations are useless and can be deleted), reducing the number of adap- tation functions leads to reducing the number of loops. Reducing the number of loops is important because if there are several loops involving the same link, the available bandwidth on this link may be exceeded. The authors of [14, 6] focused on the problem of computing a path in a multi- layer network under bandwidth constraints. In [16], we demonstrated that the problem under multiple Quality of Service constraints is NP-Complete. In this paper we demonstrate that the problem without QoS constraints is polynomial, and we provide algorithms to compute the shortest path. These algorithms use a new model of multi-layer networks based on Push-Down Automata (PDAs). The encapsulation and decapsulation functions are designed as pushes and pops 2 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 in a PDA respectively, the PDA stack allowing to memorize the nested protocols. If the goal is to minimize the number of adaptation functions, the PDA is trans- formed in order to bypass sub-paths without adaptation functions. The PDA or transformed PDA is then converted into a Context-Free Grammar (CFG) using a method of [13]. A shortest word, either corresponding to the shortest path in nodes or in adaptation functions, is generated from this CFG. This paper extends the work published in [15], providing the detailed proofs of the correctness of the algorithms and including new algorithms (transforming the PDA, converting the PDA to a CFG, generating the shortest word). Further- more, the complexity analyses are refined and the total worst case complexity of the path computation is significantly reduced. This paper is organized as follows: Section 2 recalls the context of multi- layer multi-domain networks and the related work on path computation in such networks and presents the proposed approach; Section 3 provides a model of multi-layer multi-domain networks and a formal definition of the problem; Sec- tion 4 explains how a network is converted into a PDA and provides the com- plexity of this transformation; finally, Section 5 gives the different methods that compute the shortest path in nodes or in encapsulations/decapsulation. In order to ease the paper reading, a table summarizing the used notations is provided in Appendix A. 2. Path computation in Pseudo-Wire networks Some standards define the emulation of lower layer protocols over a PSN (e.g. Ethernet over MPLS, [19], Time-Division Multiplexing (TDM) over IP, [21]). For instance, one node in the network encapsulates the layer 2 frames in layer 3 packets and another node unwraps them. This allow to cross a part of the network by emulating a lower layer protocol, and thus to overcome protocol incompatibilities. The PWE3 architecture [2], as well as the multi-layer networking description of [20], assumes an exhaustive knowledge of the network states. This assumption is not valid at the multi-domain scale. Thus, the authors of [1] defines an architecture for extending the Pseudo-Wire emulation across multiple PSNs segments. The authors of [4] stress the importance of path determination in such a context and suggest it to be an off-line management task. They also suggest to use the Path Computation Element architecture (PCE) [8], which is adapted to the multi-domain context. It could be a control plane container for solution detailed in this paper. It would require protocol and data structure extensions in order to add encapsulation/decapsulation capabilities in the PCE data model. 2.1. Related work on path computation in multi-layer networks The problem of path computation in heterogeneous networks raised first at the optical layer. Due to technology incompatibilities (different wavelengths, different encodings, etc.), it soon became clear that classical graph models can- not capture these incompatibilities thus forbidding classical routing algorithms 3 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 to tackle this problem. The authors of [3] propose a Wavelength Graph Model instead of the classical network graph models to resolve the problem of wave- length continuity. The authors of [23] propose an Auxiliary Graph Model to resolve the problems of traffic grooming and wavelength continuity in heteroge- neous WDM mesh networks, this model is later simplified in [22]. The common feature of these works is that they model each physical device as several nodes, each node being indexed by a technology. The existence of an edge depends on the existence of a physical link, but also on the technology compatibility. In [11], the authors take into account the compatibility constraints on several layers: wavelength continuity, label continuity, etc. They propose a Channel Graph Model to resolve the multi-layer path computation problem. The pro- posed models and algorithms take into account protocol and technology but ignore the encapsulation/decapsulation (adaptation) capabilities. As they do not have a stack to store the encapsulated protocols, they cannot model the PWE3 architecture. In the PWE3 architecture, the compatibility between two technologies on a layer depends also on the encapsulated protocols on the lower layer. In [6], the authors addressed the problem of computing the shortest path in the context of the ITU-T G.805 recommendations on adaptation functions. They stress the lack of solutions on path selection and the limitations of graph theory to handle this problem. The authors of [7] present the specificities of a multi-layer path computation taking into account the encapsulation/decapsulation (adaptation) capabilities: the shortest path can contain loops and its sub-paths may not sat- isfy the compatibility constraints. They provide an example of topology where classical routing algorithms cannot find the shortest path because it contains a loop. In [14], the authors addressed the same problem in a multi-layer network qualifying it as an NP-Complete problem. The NP-Completeness comes from the problem definition as they consider that the loops in the path can exceed the available bandwidth, because if the path involves the same link several times it may overload this link. They aim to select the shortest path in nodes and provide new graph models allowing to express the adaptation capabilities. They propose a Breadth-First Search algorithm which stores all possible paths and selects the shortest one. This algorithm has an exponential time complexity. In the problem we consider, we exclude bandwidth constraints and propose a solution for minimizing the number of encapsulations and decapsulations. Our algorithm does not allow loops without adaptation functions, the only loops that may exist involve encapsulations or decapsulations. Thus, minimizing the number of adaptation functions in the path also leads to minimizing the number of loops - and avoiding them if a loop-free feasible path with less encapsulations exists. 2.2. Proposed approach In this work, we propose a new multi-domain multi-layer network model wich takes into account encapsulation and decapsulation capabilities. To the best of our knowledge no previous work has considered this problem at the multi-domain scale. It induces to go beyond the domain boundaries allowing 4 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 multi-domain compatibility to determine a feasible inter-domain path: when an encapsulation for a given protocol is realized in one domain its corresponding decapsulation must be done in another. It appears that PDAs are naturally adapted to model the encapsulation and decapsulation capabilities, as push and pop operations easily model encapsulations and decapsulations, and the PDA stack can model the stack of encapsulated protocols. By using powerful tools of Automata and Language Theory, we propose polynomial algorithms that generate the shortest sequence of protocols of a feasible path. This sequence allows to find the shortest feasible path. Furthermore, we consider two kind of objectives: either the well-known ob- jective of minimizing the number of hops or the objective of minimizing the number of adaptation functions. The latter is motivated by the fact that it is equivalent to minimize the number of configuration operations, which are often done manually and can be quite complex. It is also motivated by reducing the number of possible loops (as the number of adaptation functions involved in a path is correlated with the number of loops), and thus avoiding to use the same link several times and to exhaust the available bandwidth on it. Figure 1 summarizes our proposed approach. It presents the different models leading to the shortest path and the algorithms computing them. I. Convert a multi-domain Pseudo-Wire network into a PDA, i. If the goal is to minimize the number of adaptation functions, trans- form the PDA to bypass the "passive" functions (i.e. no protocol adaptation), ii. Else let the PDA as is, II. Derive a CFG from the PDA or the transformed PDA, III. Determine the "shortest" word generated by the CFG, IV. Identify the shortest path from the shortest word. Figure 1: Proposed approach to compute the shortest feasible path. 5 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Compared to the preliminary version of this work [15], we detail the proofs of correctness and refine the complexity of our algorithms. We also provide the detailed algorithm which converts the PDA to a CFG, and we propose a new method to generate the shortest word which is linear in the length of the shortest word. Appendix A summarizes the notations used in this paper. 3. Multi-layer multi-domain network model A multi-domain network having routers with encapsulation/decapsulation capabilities can be defined as a 3-tuple: a directed graph G = (V, E) modeling the routers of a multi-domain network, we consider a pair of vertices (S, D) in G corresponding to the source and the destination of the path we focus on; a finite alphabet A = {a, b, c, . . .} in which each letter is a protocol; an encapsulation or a decapsulation function is a pair of different letters in the alphabet A: • Figure 2(a) illustrates the encapsulation of the protocol x by the node U in the protocol y; • Figure 2(b) illustrates that the protocol x is unwrapped by the node U from the protocol y; • Figure 2(c) illustrates that the protocol x transparently crosses the node U (no encapsulation or decapsulation function is applied). Such pairs are referred as passive further in this paper. We denote by ED and by ED the set of all possible encapsulation functions and decapsulation functions respectively, (i.e., ED ⊂ A2). A subset P (U ) of ED∪ED indicates the set of encapsulation, passive and decapsulation functions supported by vertex U ∈ V. We define In(U ) = {a ∈ A s.t. ∃b ∈ A s.t. (a, b) or (b, a) ∈ P (U )} and Out(U ) = {b ∈ A s.t. ∃a ∈ A s.t. (a, b) or (b, a) ∈ P (U )}. The set T (U ) = {a ∈ A s.t. (a, a) ∈ P (U )} is the set of protocols that can passively cross the node U . (a) Encapsulation of protocol x in protocol y, (x, y) ∈ P (U ) (b) Decapsulation of pro- tocol x from protocol y, (x, y) ∈ P (U ) Passive (c) crossing, (x, x) ∈ P (U ) Figure 2: Different transitions when a protocol crosses a node U 6 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Considering a network N = (G = (V, E),A, P ), a source S ∈ V, a destina- tion D ∈ V and a path C = S, x1, U1, x2, . . . , Un−1, xn, D where each Ui is a vertex in V and each xi ∈ A ∪ A (where A = {a : a ∈ A}). • TC = x1 . . . xn represents the sequence of protocols which is used over the path C. It is called the trace of C. For each xi: -- xi = a and xi+1 = b or b, means that Ui encapsulates the protocol a in b ( a, b, b ∈ A ∪ A) -- xi = a and xi+1 = b or b means that Ui unwraps the protocol b from a -- xi = a and xi+1 = a or a means that Ui passively transports a • The transition sequence of C, denoted HC, is the sequence β1, . . . , βn obtained from C s.t. for i = 1..n: -- if xi = a ∈ A and xi+1 = b ∈ A or xi+1 = b ∈ A then βi = (a, b) -- if xi = b ∈ A and xi+1 = a ∈ A\{b} or xi+1 = a ∈ A\{b} then βi = (a, b) Note that the pair (a, a), a ∈ A can appear in a transition sequence, as it represents a passive function. However, according the definition above, a pair (a, a), a ∈ A cannot appear, as it is forbidden to encapsulate (and thus to decapsulate) a protocol a in itself. 1, . . . , β(cid:48) m, is ob- tained from HC by deleting each passive transition βi s.t. βi = (a, a) and a ∈ A • The well-parenthesized sequence of C, denoted MC = β(cid:48) Example. Consider the path C = S, a, U, b, V, b, W, a, D in the network illus- trated by Fig. 3(a). The transition sequence corresponding to C is HC = (a, b), (b, b), (a, b) and its trace is TC = abba. The well-parenthesized sequence from C is MC = (a, b), (a, b). Let  denotes the empty word, "•" indicates the concatenation operation, and HC denotes the transition sequence obtained from a path C as explained above. The following definitions give a formal characterization of the feasible paths. Definition 1. A sequence MC from HC is valid if and only if MC ∈ L, where L is the formal language recursively defined by:  • L  (cid:91) (x,y)∈A2 L =  ∪ (x, y) • L • (x, y) Definition 2. A path C is a feasible path in N from S to D if: • S, U1, . . . , Un−1, D is a path in G = (V, E), 7 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 • The well-parenthesized sequence MC from C is valid, • For each i ∈ {1, . . . , n}: -- if xi = a and xi+1 = b or b then (a, b) ∈ P (Ui) -- if xi = a and xi+1 = b or b then (a, b) ∈ P (Ui) -- if xi = a and xi+1 = a or a then a ∈ T (Ui) The language L of valid sequences is known as the generalized Dyck language [17]. It is well-known that this language is context free but not regular. Thus, push-down automata are naturally adapted to model this problem. Example. The multi-domain network illustrated by Fig. 3(a) has 6 routers and two protocols labeled a and b. Adaptation function capabilities are indicated below each node. For example, the node U can encapsulate the protocol a in the protocol b (function denoted by (a, b)) or can passively transmit the protocol a (function denoted by (a, a)). In this multi-domain network, the only feasible path between S and D is S, a, U, b, V, ¯b, W, a, D and involves the encapsulation of the protocol a in the protocol b by the node U , the passive transmission of the protocol b by the node V and the decapsulation of the protocol a from b by the node W . (functions (a, b), (b, b) and (a, b) respectively). Problem definition. As explained above, our goal is to find a feasible multi- domain path. Furthermore, we set as an objective function either the size of the sequence of adaptation functions or the size of the path in number of nodes. Hence, the problem we aim to solve can be defined as follows: min HC or MC C s.t. C is a feasible path 4. From the network model to a PDA In this section, we address the conversion from a network to a PDA. Algo- rithm 1 takes as input a network N = (G = (V, E),A, P ) and converts it to a PDA AN = (Q, Σ, Γ, δ, SA, Z0,{DA}), where Q is the set of states of the PDA, Σ the input alphabet, Γ the stack alphabet, δ the transition relation, SA the start state, Z0 the initial stack symbol and DA the accepting state,  is the empty string. The automaton AN from N is obtained as follows: • Create a state Ux of the automaton for each U ∈ V and each x ∈ In(U ), except for the source node S for which a single state SA is created, • The top of the stack is the last encapsulated protocol, • If the current state is Ux then the current protocol is x, 8 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 • The adaptation functions will be converted into transitions in the PDA. A transition t ∈ δ is denoted (Ux,(cid:104)x, α, β(cid:105), Vy) where Ux ∈ Q is the state of the PDA before the transition, x ∈ Σ is the input character, α ∈ Γ is the top of the stack before the transition (it is popped by the transition), β ∈ Γ∗ is the sequence of symbols pushed to the stack, and Vy is the state of the PDA after the transition. Thus if β = α then t is a passive transition, if β = xα then t is a push of x, and if β = ∅ then t is a pop, • A passive transition of a protocol x across a node U is modeled as a transition without push or pop between the state Ux and the following state Vx. It is denoted (Ux,(cid:104)x, α, α(cid:105), Vx), • An encapsulation of a protocol x in a protocol y by a node U is modeled as a push of the character x in the stack between the state Ux and the following state Vy. It is denoted (Ux,(cid:104)x, α, xα(cid:105), Vy)2 , • A decapsulation of y from x by a node U is modeled as a pop of the protocol y from the stack. It is denoted (Ux,(cid:104)x, y,∅(cid:105), Vy). Algorithm 1 Convert a network to a PDA Create a transition (SA,(cid:104), Z0, Z0(cid:105), Ux) Input: a network N = (G = (V, E),A, P ), a source S and a destination D Output: push-down automaton AN = (Q, Σ, Γ, δ, SA, Z0,{DA}) (1) Σ ← A ∪ A ; Γ ← A ∪ {Z0} (2) Create a single state SA for the node S (3) For each node U (cid:54)= S and each protocol x ∈ In(U ), create a state Ux (4) For each state Ux s.t. (S, U ) ∈ E and x ∈ Out(S) (5) For each link (U, V )∈ E s.t. U (cid:54)= S and for each (x, y)∈ P (U ) and each α∈Γ\{x} (5.1) If x ∈ T (U ) ∩ In(V ) Create a transition (Ux,(cid:104)x, α, α(cid:105), Vx){passive trans.} (5.2) If x (cid:54)= y and y ∈ In(V ) Create a transition (Ux,(cid:104)x, α, xα(cid:105), Vy){encap.} (6) For each link (U, V ) ∈ E s.t. U (cid:54)= S and for each (y, x) ∈ P (U ) (6.1) If x ∈ In(V ) Create a transition (Ux,(cid:104)x, y,∅(cid:105), Vy){decap.} (7) Create a fictitious final state DA. (8) For each x ∈ In(D) and each α ∈ Γ\{x} Create a transition (Dx,(cid:104)x, Z0,∅(cid:105), DA) Complexity. Each node U from the graph generates In(U ) states, except the source node S. A fictitious final state is added. Thus, the number of states is 2Note that, even if x = a ∈ A, the transition has the form (Ua, (cid:104)a, α, aα(cid:105), Vy). Characters in A are only used as input characters. Characters indexing states and pushed characters in the stack are their equivalent in A. 9 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 at worst 2 + (V − 1) × A so in O(V × A). The worst case complexity of algorithm 1 is in O(max((V×A), (E× ((A×ED) +ED))))). We assume that the network is connected, so E ≥ V − 1. Since ED is a subset of A2, then ED < A2 and ED < A2. Thus, the upper bound complexity is in O(A3 × E), which is also an upper bound for the number of transitions. Proposition 1. Considering a network N = (G = (V, E),A, P ), a source S ∈ V and a destination D ∈ V, the language recognized by AN is the set of traces of the feasible paths from S to D in N . Proof. Let a feasible path C = Sx1U1x2 . . . xiUixi+1 . . . Un−1xnD in a net- work N and its trace TC = x1 . . . xixi+1 . . . xn leading to a valid sequence MC. We aim to demonstrate that: i) TC is recognized by AN and ii) U1, . . . , Un−1 is a path in N and iii) There exists a feasible path corresponding to TC in N if TC is recognized by the PDA AN . It is sufficient to show that C = S, x1, U1, x2, . . . , Un−1, xn, D is a feasible path in N if and only if TC is recog- nized by AN (i.e the final state is reached and the stack is empty). From C we deduce the following path in AN defined as a sequence of tran- sitions. This path begins with transitions: (SA,(cid:104), Z0, Z0(cid:105), (Ui)x1) for each Ui s.t. x1 ∈ In(Ui). Hence, transition (SA,(cid:104), Z0, Z0(cid:105), (U1)x1 ) belongs to this set. Then, the path in AN follows the order induced by TC, for each element in x1, . . . , xn, we consider one or two transitions in AN as follows: • if xi = a then -- if xi+1 = a or xi+1 = a consider the transition ((Ui)a,(cid:104)a, α, α(cid:105), (Ui+1)a) -- if xi+1 = b or xi+1 = b consider the transition ((Ui)a,(cid:104)a, α, aα(cid:105), (Ui+1)b), where α ∈ Γ\{a}, where α ∈ Γ\{a} • else (i.e., if xi = a) then consider the transition ((Ui)a, (cid:104)a, b,∅(cid:105), (Ui+1)b). Note that, if i = n then Ui+1 = D. It is clear that this sequence of transitions is a path in AN recognizing the trace TC. Since MC is a well parenthesized word, if xi = a then the head of the stack when reaching state (Ui)xi contains aZ0 and when reaching state (Ui+1)xi+1, the head of the stack is reduced to Z0. Then, when reaching state DA, the stack is empty. Conversely, we can show with a similar construction that any well recognized word on a path in AN induces one unique trace TC of feasible paths in G from 2 S to D. Example. Figure 3(b) is an example of output of algorithm 1. The algorithm transforms the network illustrated by Fig. 3(a) into a PDA of Fig 3(b). For instance, the link (U, V ) is transformed into the transitions (Ua,(cid:104)a, Z0, aZ0(cid:105), Vb) and (Ua,(cid:104)a, b, ab(cid:105), Vb) (pushes) because the node U should encapsulate the pro- tocol a in the protocol b using the adaptation function (a, b) before trans- mitting to the node V . The link (W, D) is transformed into the transitions 10 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 (Wb,(cid:104)b, Z0, bZ0(cid:105), Da) and (Wa,(cid:104)b, a, ba(cid:105), Da) (pushes) according to the adapta- tion function (a, b). It is also transformed into the transition (Wb,(cid:104)b, a,∅(cid:105), Da) (pop) because the node W can decapsulate the protocol a from b using the adaptation function (a, b) before transmitting to the node D. The link (V, W ) is transformed into the transitions (Vb,(cid:104)b, Z0, Z0(cid:105), Wb) and (Vb,(cid:104)b, a, a(cid:105), Wb) (pas- sive transitions) according the capability of the node V (adaptation function (b, b)). 5. The shortest feasible path In section 4, we provided a method to build a PDA allowing to determine the feasible paths. The next step is to minimize either the number of nodes or the number of adaptation functions. The method to minimize the number of nodes uses directly the PDA as described in section 5.1. But to minimize the number of adaptation functions, the PDA is transformed in order to bypass the sub-paths without any adaptation function, as detailed in section 5.2. Then, a CFG derived from the PDA (or the transformed PDA) generates words whose length is equivalent to the number of nodes (or to the number of adaptations). An algorithm browses the CFG to determine the shortest word. Finally, another algorithm identifies the multi-domain path corresponding to this shortest word. 5.1. Minimizing the number of nodes The number of characters in a word accepted by the automaton AN is the number of links in the corresponding feasible path (each character is a protocol used on a link). Thus the step of automaton transformation (section 5.2) should be skipped. The automaton AN is directly transformed into a CFG, then the shortest word is generated as described in section 5.3.2. The corresponding feasible path is computed by algorithm 6 described in section 5.3.3. 5.2. Minimizing the number of adaptation functions N is the number of adaptation functions plus a fixed constant. Let us define Qa (a ∈ A) as Qa = {Vx ∈ Qx = a}, and let Aa To enumerate only encapsulations and decapsulations in the length of each word (and thus minimize adaptation functions by finding the shortest word accepted), a transformed automaton A(cid:48) N in which all sequences involving passive transitions are bypassed must be determined. The length of the shortest word accepted by A(cid:48) N be the sub- automaton induced by Qa. By analogy with an induced subgraph, an induced sub-automaton is a multigraph with labeled edges such that the set of vertices is Qa and the set of edges is the set of transitions between elements of Qa. Since there are only passive transitions between two states in Qa, all paths in the sub- automaton are passive. Let define P (Ux, Vx) as the shortest path length between Ux and Vx. This length can be computed between all pairs of nodes in Qa using the Floyd-Warshall algorithm. Let Succ(Vx) be the set of successors of Vx in the original automaton AN , i.e., Succ(Vx) = {Wy ∈ Q∃(Vx,(cid:104)x, α, β(cid:105), Wy) ∈ δ}. 11 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Algorithm 2 takes as input AN and computes the transformed automaton N = (Q(cid:48), Σ(cid:48), Γ(cid:48), δ(cid:48), SA, Z0,{DA}). A(cid:48) A(cid:48) N is initialized with the values of AN . Then, the algorithm computes the sub-automaton for each character x ∈ A (step (1)) and the length values P (Ux, Vx) for each pair of states in the sub- automaton (step (2)). Each path between a pair of states is a sequence of passive transitions. If such a path exists (step (3.1)), the algorithm adds transitions to δ(cid:48) from Ux to each state in Succ(Vx) (steps (3.1.2) and (3.1.3)). These added transitions are the same that those which connect Vx to its successors Wy, but with an input character indexed by the number of passive transitions between Ux and Vx, (i.e., P (Ux, Vx)) plus one (indicating that there is a transition sequence which matches with a sequence of protocols xx . . . x of length P (Ux, Vx) + 1). The indexed character is added to the input alphabet Σ(cid:48) (step (3.1.1)). Algorithm 2 Transform automaton AN Input: push-down automaton AN = (Q, Σ, Γ, δ, SA, Z0,{DA}) automaton Output: transformed (Q(cid:48), Σ(cid:48), Γ(cid:48), δ(cid:48), SA, Z0,{DA}) Q(cid:48) ← Q, Σ(cid:48) ← Σ, Γ(cid:48) ← Γ, δ(cid:48) ← δ For each x ∈ A push-down A(cid:48) N = in Ax N (1) Compute Ax N (2) Compute the distance P (Ux, Vx) between all pairs of states Ux and Vx (3) For each Ux ∈ Qx and each Vx in Qx (3.1) If P (Ux, Vx) < ∞ {there is a path between Ux and Vx} (3.1.1) Add xP (Ux,Vx)+1 and xP (Ux,Vx)+1 to Σ (3.1.2) For each Wy ∈ Succ(Vx)\{Ux} and each (Vx,(cid:104)x, α, β(cid:105), Wy) ∈ δ Add the transition (Ux,(cid:104)xP (Ux,Vx)+1, α, β(cid:105), Wy) to δ(cid:48) (3.1.3) For each Wy ∈ Succ(Vx)\{Ux} and each (Vx,(cid:104)x, α, β(cid:105), Wy) ∈ δ Add the transition (Ux,(cid:104)xP (Ux,Vx)+1, α, β(cid:105), Wy) to δ(cid:48) Complexity. Computing the sub-automaton (step (1)) is done in O(δ + Q) by checking all the nodes and all the transitions. Computing the shortest path length between all pairs of states is done by the Floyd-Warshall algorithm in O(Qx3). If x=y, there are at worst A− 1 transitions between Vx and Wy in Q (transitions in the form (Ux,(cid:104)x, α, α(cid:105), Wx) for all possible values of α except x -- as the construction of the automaton forbids the encapsulation of a protocol x in x, and thus it is impossible to have x as current protocol and at the top of the stack in the same time). If x (cid:54)= y, there are at worst A transitions between Vx and Wy in Q (the pop (Vx,(cid:104)x, y,∅(cid:105), Wy) and the pushes (Vx,(cid:104)x, α, xα(cid:105), Wy) for all possible values of α except x). And as Succ(Vx) < Q, the steps (3.1.2) and (3.1.3) are bounded by O(Q × A). However, a state belongs to only one sub-automaton, the complexity of algorithm 2 is therefore bounded by 12 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 x∈A (see algorithm 1 for the construction of the set of states Q). Thus, the complex- O(cid:0)(cid:80) (cid:2)δ + Q + Qx3 + (Qx2 × Q × A)(cid:3)(cid:1). And ∀x ∈ A,Qx ≤ A ity of algorithm 2 is in O(cid:0)max(cid:0)A × (δ + Q),A × V3,A2 × V2 × Q(cid:1)(cid:1), which corresponds to O(cid:0)max(A4 × E,A3 × V3)(cid:1) in the network model. x∈A(Qx2 × Q × A)(cid:1), The number of transitions in δ(cid:48) is bounded by δ+O(cid:0)(cid:80) which corresponds to O(A3 × V3) in the network model. Example. Algorithm 2 transforms the PDA in Fig. 3(b) into the PDA in Fig. 3(c). For the protocol b, the algorithm computes the sub-automaton in- duced by the states Vb, Wb and Kb. The distance P (Vb, Wb) = 1 is then com- puted. Thus, to bypass the sequence of transitions (Vb,(cid:104)b, a, a(cid:105), Wb) (Wb,(cid:104)b, a,∅(cid:105), Da), the transition (Vb,(cid:104)b2, a,∅(cid:105), Da) is added. Let L(AN ) be the set of words accepted by AN , and let L(A(cid:48) words accepted by A(cid:48) N . Let f : Σ(cid:48) → Σ∗ be a function s.t.: N ) be the set of • if xi = ai ∈ A(cid:48) then f (xi) = aa . . . aa • if xi = ai ∈ A(cid:48) then f (xi) = aa . . . aa (cid:124) (cid:124) (cid:123)(cid:122) (cid:123)(cid:122) (cid:125) (cid:125) i occurrences i occurrences ∗ The domain of f is extended to (Σ(cid:48)) : ∗ → Σ∗ k → f (w(cid:48)) = f (x1 f : (Σ(cid:48)) i x2 j . . . xn w(cid:48) = x1 i )f (x2 j ) . . . f (xn k ) For simplicity, we consider that x and x1 are the same character. f (L(A(cid:48) denotes the set of words accepted by A(cid:48) {f (w(cid:48)) s.t. w(cid:48) ∈ L(A(cid:48) transformation between L(AN ) and L(A(cid:48) for each w = xx . . . x N ), we define g : Σ∗ → (Σ(cid:48))∗ s.t. : (cid:124) (cid:123)(cid:122) (cid:125) ∈ Σ∗, g(w) = xiyj . . . zk. zz . . . z N )}). (cid:124) (cid:123)(cid:122) (cid:125) N transformed by f (i.e. f (L(A(cid:48) It is clear that f is not a bijection (f (xixj) = f (xi+j)). So to operate the N )) N )) = (cid:124) (cid:123)(cid:122) (cid:125) yy . . . y . . . In other words, w(cid:48) = g(w) is the shortest word in (Σ(cid:48))∗ s.t. f (w(cid:48)) = w. i occurrences j occurrences k occurrences The following lemmas and proposition show that the set of words accepted by the transformed automaton is 'equivalent' to the set of words accepted by the original automaton. Equivalent in the meaning that, using f , each word accepted by the transformed automaton can be associated to a word accepted by the original one. In addition, the transformed automaton has a new propri- ety: there is a linear relation between the length of an accepted word and the minimum number of pushes (and pops) involved to accept it. This propriety allows to find the word requiring the minimum number of pushes accepted by the original automaton. This is done by finding the shortest word accepted by the transformed automaton. 13 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Lemma 1. f (L(A(cid:48) is equal to L(AN ), the set of words accepted by AN . N )), the set of words accepted by A(cid:48) N and transformed by f , Proof. We prove this by double inclusion: 1. L(AN ) ⊆ f (L(A(cid:48) 2. L(AN ) ⊇ f (L(A(cid:48) N )) (2) N )). N )) : Let w(cid:48) = x1 i x2 N )) : ∀w ∈ L(AN ), f (w) = w (remind that we consider that x = x1). So f (L(AN )) = L(AN ) (1). On the other hand, the con- struction of A(cid:48) N by algorithm 2 does not delete any character, transition, state or set of final states from AN . So L(AN ) ⊆ L(A(cid:48) N ). And thus f (L(AN )) ⊆ f (L(A(cid:48) By (1) and (2), L(AN ) ⊆ f (L(A(cid:48) N ) and let n+1 be a sequence of transitions accepting w(cid:48). For each transi- 1t(cid:48) t(cid:48) 2 . . . t(cid:48) , α, β(cid:105), Wxm) (1 < m < n) in this sequence, s.t. m = (Uxm−1,(cid:104)xm−1 tion t(cid:48) m ∈ δ(cid:48)\δ, there is a sequence of k − 1 passive transitions in AN (be- t(cid:48) cause the creation of t(cid:48) N requires the existence of such a sequence in AN ). This sequence begins from the state Uxm−1 and is followed by a transition (Vxm−1 ,(cid:104)xm−1, α, β(cid:105), Wxm ). Thus, this sequence in AN matches with f (xm−1 m matches with m ∈ δ(cid:48)\δ and there is a sequence of transitions in xm+1 k AN which matches with f (xm+1 ) (if k > 1). And since, by definition, N )) ⊆ L(AN ). f (w(cid:48)) = f (x1 l ), f (w(cid:48)) ∈ L(AN ). Thus f (L(A(cid:48) l be a word in L(A(cid:48) ) And for each t(cid:48) (if k = 1), or t(cid:48) m ∈ δ so t(cid:48) N , either t(cid:48) m in A(cid:48) m in A(cid:48) j ) . . . f (xn j . . . xn i )f (x2 k k k 2 push(w(cid:48)) be the minimum N , and let pop(w(cid:48)) be the minimum number of pops in a sequence of transitions accepting Let w(cid:48) be the shortest word accepted by A(cid:48) number of pushes in a sequence of transitions accepting w(cid:48) in A(cid:48) N bA(cid:48) w(cid:48) in A(cid:48) N . N , let N bA(cid:48) N N N N N N i xm+1 push(w(cid:48)) + 1. N is 1 + N bA(cid:48) pop(w(cid:48)) and N bA(cid:48) push(w(cid:48)) + N bA(cid:48) Lemma 2. The length of the shortest path (sequence of transitions) accepting pop(w(cid:48)) = N bA(cid:48) w(cid:48) in A(cid:48) Proof. First we prove that w(cid:48) cannot be in the form of . . . xm . . . with xm = xm+1. Let Uxm be the state in which A(cid:48) N is before reading the character i . Let Vxm+1 be the state in which A(cid:48) xm N is after reading xm i and before reading . And let Wy be the state in which A(cid:48) xm+1 . If xm = j i+j, α, β(cid:105), Wy) (where xm+1, then, by construction, there is a transition (Uxm,(cid:104)xm α, β is a pop of y or a push of xm if xm (cid:54)= y). So, if xm i xm+1 is replaced by i+j in w(cid:48), the word obtained is shorter then w(cid:48) and is also accepted by A(cid:48) xm N . k where xm (cid:54)= xm+1 Thus, the shortest word accepted by A(cid:48) for (1 ≤ m < n). in w(cid:48), there is a push transition (Uxm,(cid:104)xm i ∈ A(cid:48). So all transitions in the shortest sequence that accepts w(cid:48) are pops or pushes, except the first transition from the initial state (SA,(cid:104), Z0, Z0(cid:105), Ux1) and the final pop (Vxn,(cid:104)xn k , Z0,∅(cid:105), DA). The number of other pops is equal to i ∈ A(cid:48) or a transition (Uxm ,(cid:104)xm i , α, xmα(cid:105), Wy) if xm i , y,∅(cid:105), Wy) if xm By construction of A(cid:48) N is after reading xm+1 N , for each character xm i N is w(cid:48) = x1 j . . . xn i x2 j j j 14 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 the number of pushes (in order to have Z0 at the top of the stack before the 2 final transition). Now let w be a word accepted by AN , let N bAN push(w) be the minimum number of pushes in a sequence of transitions accepting w in AN , and let N bAN pop(w) be the minimum number of pops in a sequence of transitions accepting w in AN . Lemma 3. For each w ∈ L(AN ): • N bAN • N bAN pop(w) = N bA(cid:48) push(w) = N bA(cid:48) N pop(g(w)) N push(g(w)) Proof. Let t1t2 . . . tn be the sequence of transitions accepting w in AN with minimum number of pushes and pops. For each sequence titi+1 . . . tj of passive transitions, followed by a push or a pop transition, there is a transition with the same push or pop and the same input character indexed by j − i + 1. So g(w) ∈ L(A(cid:48) N ). Let t(cid:48) 1t(cid:48) 2 . . . t(cid:48) n(cid:48) be the sequence of transitions with minimum pushes and pops accepting g(w) in A(cid:48) N . It is clear that f (g(w)) = w. So if there is a sequence 1t(cid:48) n(cid:48) that accepts g(w) with less pops and pushes than t(cid:48) 2 . . . t(cid:48)(cid:48) t(cid:48)(cid:48) 1 t(cid:48)(cid:48) 2 . . . t(cid:48) n(cid:48), then i ∈ δ(cid:48)\δ can be replaced by a sequence of passive transitions followed by each t(cid:48)(cid:48) a pop or a push in AN . And theses sequences accept f (g(w)) (which is w) with less pops and pushes than in the sequence t1t2 . . . tn, which contradicts the fact 2 that it minimizes the number of pops and pushes to accept w. N . N minimizes the number N (since the number of pushes grows linearly as a function of the Proposition 2. The word accepted by AN which minimizes the number of pushes is f (w(cid:48)), where w(cid:48) is the shortest word (i.e., with minimum number of characters) accepted by A(cid:48) Proof. By lemma 2, the shortest word accepted by A(cid:48) of pushes in A(cid:48) length of the word). Let w(cid:48) be this word. Suppose that there is a word w accepted by AN such that N bAN By lemma 3, N bA(cid:48) N bA(cid:48) minimizes the number of pushes in AN . push(w), which leads to N bA(cid:48) push(g(w)) < push. Ad absurdum, f (w(cid:48)) is the word which push(g(w)) = N bAN push(w(cid:48)), while w(cid:48) = arg min N bA(cid:48) push(w) < N bA(cid:48) push(w(cid:48)). 2 N N N N N 5.3. The shortest path as a shortest word In order to find the shortest word accepted by AN (resp. A(cid:48) such that L(GN ) = L(AN ) (resp. L(A(cid:48) L(GN ) is then generated. N ), the CFG GN N )) is computed. The shortest word in 15 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 5.3.1. From the PDA to the CFG. The transformation of a PDA into a CFG is well-known. We adapted a general method described in [13] to transform AN (resp. A(cid:48) N ) into a CFG. The output of algorithm 3 is a CFG GN = (N , Σ, [SG],P) (resp. (N , Σ(cid:48), [SG],P)) where N is the set of nonterminals (variables), Σ (resp. Σ(cid:48)) is the input alpha- bet, [SG] is the initial symbol (initial nonterminal) and P is the set of production rules. Except [SG], nonterminals are in the form [U XV ] where U, V ∈ Q and X ∈ Γ (resp. Q(cid:48) and Γ(cid:48)). The demonstration of the correctness of this trans- formation is also in [13]. Algorithm 3 Converting a PDA to a CFG Input: PDA AN = (Q, Σ, Γ, δ, SA, Z0,{DA}) (resp. Transformed PDA A(cid:48) (Q(cid:48), Σ(cid:48), Γ(cid:48), δ(cid:48), SA, Z0,{DA})) Output: a CFG GN = (N , Σ, [SG],P) (resp. (N , Σ(cid:48), [SG],P)) (1) Create the nonterminal [SG] (2) For each state Ux ∈ Q (3) For each transition (Ux,(cid:104)x, α, β(cid:105), Vy) [UxαVy] → x (2.1) create a nonterminal [SAZ0Ux] and a production [SG] → [SAZ0Ux] (3.1) If β = ∅ (pop), create a nonterminal [UxαVy] and a production (3.2) If β = α (passive transition), create for each state W ∈ Q (resp. Q(cid:48)) N = (3.2.1) Nonterminals [UxαW ] and [VyαW ] (3.2.2) A production [UxαW ] → x[VyαW ] (3.3) If β = xα, x ∈ Γ (push), create for each states (W, W (cid:48)) ∈ Q2 (resp. Q(cid:48)2) (3.3.1) Nonterminals [UxαW (cid:48)], [VyαW ] and [W αW (cid:48)] (3.3.2) A production [UxαW (cid:48)] → x[VyxW ][W αW (cid:48)] Complexity. The number of production rules in GN is bounded by 1 + Q + (δ×Q2) (resp. 1 +Q(cid:48) + (δ(cid:48)×Q(cid:48)2). As all the nonterminals (except [SG]) are in the form [UxαVy] with Ux, Vy ∈ Q and α ∈ Γ, the number of non terminals is bounded by O(A × Q2) (resp. O(A × Q2)). The worst case complexity of algorithm 3 is in O(δ × Q2) (resp. O(δ(cid:48) × Q(cid:48)2)). W.r.t. the definition of the network, the upper bound is in O(A5×V2×E) (resp. O(A5×V5)). Example. This method transforms the PDA in Fig. 3(c) into a CFG. Fig- ure 3(d) is a subset of production rules of the obtained CFG. This subset allows generating the shortest trace of a feasible path in the network in Fig. 3(a). For instance, the transition (Vb,(cid:104)b2, a,∅(cid:105), Da) gives the production rule [VbaDa] → b2. The transition (Ua,(cid:104)a, Z0, aZ0(cid:105), Vb) gives all the production rules [UaZ0X(cid:48)] → a[VbaX][XZ0X(cid:48)] where X, X(cid:48) ∈ Q(cid:48), including the production [UaZ0DA] → a[VbaDa][DaZ0DA] . Remark. There are two mechanisms of acceptance defined for PDAs: an input word can be accepted either by empty stack (i.e., if the stack is empty after reading the word) or by final state (i.e., if a final state is reached after reading the 16 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 word - even if the stack is not empty). Algorithm 3 takes as input an automaton which accepts words by empty stack. AN and A(cid:48) N accept words by empty stack and by final state, because the only transitions that empty the stack are those that reach the final state (the transitions in the form (Dx,(cid:104)x, Z0,∅(cid:105), DA), x ∈ In(D)). Thus, Algorithm 3 performs correctly with AN or A(cid:48) N as input. 5.3.2. The shortest word generated by a CFG. nonterminal to the length of the shortest word that it generates. To find the shortest word generated by GN , a function (cid:96) associates each More formally, (cid:96) : {N ∪ Σ ∪ {}}∗ • if w =  then (cid:96)(w) = 0, • if w ∈ Σ or Σ(cid:48) then (cid:96)(w) = 1, • if w = α1 . . . αn (with αi ∈ {N ∪ Σ ∪ {}} or {N ∪ Σ(cid:48) ∪ {}}) then (cid:96)(w) = or {N ∪ Σ(cid:48) ∪ {}}∗ → N ∪ {∞} s.t.: (cid:80)n i=1 (cid:96)(αi). Algorithm 4 computes the value of (cid:96)([X]) for each [X] ∈ N . Algorithm 4 Compute the values (cid:96)([X]) for each nonterminal [X] ∈ N Input: GN = (N , Σ, [SG],P) or (N , Σ(cid:48), [SG],P) Output: (cid:96)([X]) for each nonterminal [X] (1) Initialize each (cid:96)([X]) to ∞ (2) While there is at least one (cid:96)([X]) updated at the previous iteration do (2.1) For each production rule [X] → α1 . . . αn in P (2.1.1) (cid:96)([X]) ← min{(cid:96)([X]),(cid:80)n i=1 (cid:96)(αi)} Proposition 3. Algorithm 4 terminates at worst after N iterations, and each (cid:96)([X]) ([X] ∈ N ) obtained is the length (number of characters) of the shortest word produced by [X]. Proof. We prove that at each iteration (except the last one), there is a least one nonterminal [X] s.t. (cid:96)([X]) is updated with the length of the shortest word that [X] produces.Thus, the update of all (cid:96)([X]) with their correct values is done at worst in N iterations. We proceed by induction on the number of iterations: Basis: There is no -production in GN , and there is at least one production in the form [X] → x where [X] ∈ N and x ∈ Σ (resp. Σ(cid:48)) (see algorithm 3 for the construction of GN ). For each [X] ∈ N s.t. {[X] → x} ∈ P, (cid:96)([X]) = 1. And algorithm 4 assigns these values to each (cid:96)([X]) at the first iteration. Induction: Suppose that at iteration n, there are at least n(cid:48) (n ≤ n(cid:48) < N) nonterminals [X] s.t. the algorithm has assigned the correct value to (cid:96)([X]). So there are N − n(cid:48) nonterminals which have not the correct (cid:96)-value yet. 17 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 • Either there is a nonterminal [Y ] s.t. (cid:96)([Y ]) has not already the correct value (i.e., it can already be updated), but for all productions [Y ] → γ1 . . .γm (each [Y ] → γi is a production) all nonterminals in γ1, . . . , γm have their correct (cid:96)-values. And thus, (cid:96)([Y ]) will be updated with the correct value at the end of the following iteration. • Or, for each nonterminal [Y ] with a wrong (cid:96)-value, there is at least a nonterminal in each of its productions [Y ] → γ1 . . .γm which has not its correct (cid:96)-value yet. -- Either each γi contains a nonterminal which generates no word. Thus, [Y ] generates no word and the value of (cid:96)([Y ]) = ∞ is correct. -- Or all nonterminals in each γi generate a word. However, in the derivation of the shortest word generated by any nonterminal, no nonterminal is used twice or more (otherwise a shorter word can be generated by using this nonterminal once). Thus, among all nonter- minals with a wrong (cid:96)-value, there is one which does not use others to generate its shortest word. So its (cid:96)-value is already correct or it 2 will be updated to the correct value at the following iteration. Complexity. As there is at worst N iteration of the while loop, the complexity of algorithm 4 is in O(N × P) which is O(A8 × V 4 × E) (resp. O(A8 × V 7)) in the network model There are several algorithms which allow the generation of a uniform random word of some length from a CFG [12, 9, 18], or, more recently, a non-uniform random generation of a word according to some targeted distribution [5, 10]. For instance, the boustrophedonic and the sequential algorithms described in [9] generate a random labeled combinatorial object of some length from any decomposable structure (including CFGs). The boustrophedonic algorithm is in O(n log n) (where n is the length of the object) and the sequential algo- rithm is in O(n2) but may have a better average complexity. Both algorithms use a precomputed table of linear size. This table can be computed in O(n2). These algorithms require an unambiguous CFG, and the CFG computed by algorithm 3 can be inherently ambiguous depending on the input network (as several feasible paths can use the same sequence of protocols and thus have the same trace TC). However, the unambiguity requirement is only for the ran- domness of the generation. Recall that our goal is to generate the trace of the shortest feasible path. Thus, we do not take into consideration the random- ness and the distribution over the set of shortest traces. In order to generate the shortest word in L(GN ), the boustrophedonic algorithm can take GN and (cid:96)([SG]) as input (recall that (cid:96)([SG]) is the length of the shortest word generated by GN ). Thus, the generation of the shortest word w (resp. w(cid:48)) would have been in O(w2) (resp. O(w(cid:48)2)), where w denotes the length (number of characters) of w. This complexity includes the precomputation of the table. However, this complexity hides factors depending of the size of the CFG, the construction of the precomputed table requires at least one pass over all the production rules. 18 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Actually, as the (cid:96)-values are already computed, the generation can simply be done in linear time in the length of the shortest word. The standard algorithm 5 takes as input the CFG and the (cid:96)-values. Each nonterminal is replaced by the left part with minimal (cid:96)-value among its productions. Algorithm 5 Computing the shortest word generated by GN Input: GN = (N , Σ(cid:48), [SG],P) and all (cid:96)-values Output: w, the shortest word generated by GN {[SG] → γ1γ2 . . .γm are all production rules with [SG] as left part} (1) w ← arg min{(cid:96)(γ1), . . . , (cid:96)(γm)} (2) While there is at least one nonterminal in w (2.1.1) Replace [X] in w by arg min{(cid:96)(γ(cid:48) {[X] → γ(cid:48) m(cid:48) are all production rules with [X] as left part} (2.1) For each nonterminal [X] in w do 1), . . . , (cid:96)(γ(cid:48) 1 . . .γ(cid:48) m(cid:48))} Complexity. Since there is no derivation of the form [X] →  in GN (see algorithm 3), all branches in the derivation tree end with a character from Σ (resp. Σ(cid:48)). The length of each branch is at worst N (as a nonterminal does not appears twice in the same branch, otherwise a shorter word could be derivated by using this nonterminal once). Thus, the number of derivations and the com- plexity of algorithm 5 are bounded by O(N×w) (resp. O(N×w(cid:48))), which corresponds to O(A3 × V2 × w) (resp. O(A3 × V2 × w(cid:48))) in the network model. Example. Algorithm 4 gives (cid:96)([SG]) = 3. Algorithm 5 computes the shortest word using the production rules in Fig. 3(d). The derivation is: [SG] (2)(cid:96) [UaZ0DA] (1)(cid:96) [SAZ0DA] (5)(cid:96) ab2a Thus, the shortest word accepted by the transformed PDA is ab2a. And the shortest trace of a feasible path is f (ab2a) = abba. (3)(cid:96) a[VbaDa][DaZ0DA] (4)(cid:96) ab2[DaZ0DA] 5.3.3. From the shortest word to the path. If the goal is to minimize the number of nodes in the path, algorithm 6 takes as input the shortest word w accepted by AN . Otherwise, as w(cid:48) is the shortest word accepted by A(cid:48) N and generated by GN , according to proposition 2, f (w(cid:48)) is the word which minimizes the number of pops and pushes in AN . In such a case it is the trace TC of the shortest feasible path C in the network N . It is possible that several paths match with the trace TC = w (resp. f (w(cid:48))). In such a case, a load-balancing policy can choose a path. Algorithm 6 is a dynamic programming algorithm that computes C. It starts at the node S and takes at each step all the links in E which match with the current character in TC. Let TC = x1x2 . . . xn (xi ∈ A∪A). At each step i, the algorithm starts from each node U in N odes[i] and adds to Links[i] all links (U, V ) which match with xi. It also adds each V in N odes[i+1]. When reaching D, it backtracks to S and selects the links from D to S. 19 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Algorithm 6 Find the shortest path Input: Network N and TC Output: Shortest path C (1) N odes[1] ← S ; i ← 1 (2) While D is not reached do (2.1) for each U ∈ N odes[i] and each V ∈ V s.t. (U, V ) ∈ E do (2.1.1) If xi ∈ A, xi ∈ Out(U ), xi ∈ In(V ) and (xi−1, xi) ∈ P (U ) (2.1.1.1) Add (U, V ) to Links[i] and V to N odes[i + 1] (2.1.2) If xi ∈ A, xi ∈ Out(U ), xi ∈ In(V ) and (xi, xi−1) ∈ P (U ) (2.1.2.1) Add (U, V ) to Links[i] and V to N odes[i + 1] (2.2) i + + (3) Backtrack from D to S by adding each covered link in the backtracking to C. Algorithm Upper-Bound Complexity Minimizing hops Minimizing enc./dec. Algo. 1: Network to PDA Algo. 2: Transform PDA O(A5 × V2 × E) Algo. 3: PDA to CFG Algo. 4: Shortest word length O(A8 × V4 × E) O(A3 × V2 × w) Algo. 5: Shortest word Algo. 6: Shortest path / O(A3 × E) O(max(A4 × E, A3 × V3) O(A5 × V5) O(A8 × V7) O(A3 × V2 × w(cid:48)) O(TC × V × E) Table 1: Algorithms and their complexities Complexity. The while loop stops exactly after TC steps, because it is sure that there is a feasible path of length TC if TC is accepted by the automaton AN . At each step, all links and nodes are checked in the worst case. Thus, algorithm 6 is in O(TC × V × E) in the worst case. Example. From the shortest trace abba, algorithm 6 computes the only feasible path in the network on Fig. 3(a), which is S, a, U, b, V, b, W, a, D. 6. Conclusion The problem of path computation in a multi-layer network has been studied in the field of intra-domain path computation but is less addressed in the inter- domain field with consideration of the Pseudo-Wire architecture. There was no polynomial solution to this problem and the models used were not expressive enough to capture the encapsulation/decapsulation capabilities described in the Pseudo-Wire architecture. In this paper, we provide algorithms that compute the shortest path in a multi-layer multi-domain network, minimizing the number of hops or the number of encapsulations and decapsulations. The presented algorithms involve Automata and Language Theory methods. A Push-Down Automaton models 20 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 the multi-layer multi-domain network. It is then transformed in order to bypass passive transitions and converted into a Context-Free Grammar. The grammar generates the shortest protocol sequence, which allows to compute the path matching this sequence. The different algorithms of our methodology have polynomial upper-bound complexity as summarized by Table 1. Compared to the preliminary version of this work, the proofs of correctness of the algorithms are detailed and the complexity analysis is significantly refined (the highest algorithm complexity is in O(A8 × V7) instead of O(A11 × V7 × E2)). In order to figure out the whole problem of end-to-end service delivery, we plan to extend our solution to support end-to-end Quality of Service constraints and model all technology constraints on the different layers (conversion or "map- ping" of protocols). As a future work, we also plan to investigate which part of our algorithms can be distributed (e.g., Can the domains publish their encap- sulation/decapsulation capabilities without disclosing their internal topology?) and how such a solution can be established on today's architectures. Acknowledgment The first author would like to thank Kaveh Ghasemloo for his help about Algorithm 4. This work is partially supported by the ETICS-project, funded by the European Commission. Grant agreement no.: FP7-248567 Contract Number: INFSO-ICT-248567. Appendix A. List of notations In order to facilitate the paper reading, Table A.2 summarizes the symbols used in the paper. References [1] M. Bocci and S. Bryant. RFC5659 - An Architecture for Multi-Segment Pseudowire Emulation Edge-to-Edge, 2009. [2] S. Bryant and P. Pate. RFC3985 - Pseudo Wire Emulation Edge-to-Edge (PWE3) Architecture, 2005. [3] I. Chlamtac, A. Farag´o, and T. Zhang. Lightpath (Wavelength) Routing in Large WDM Networks. IEEE Journal on Selected Areas in Communi- cations, 14(5):909 -- 913, 1996. [4] H. Cho, J. Ryoo, statically and end multi-segment draft-cho-pwe3-mpls-tp-mixed-ms-pw-setup-01.txt, 2011. pseudowires. provisioned and D. King. segments Stitching dynamically end-to- http://www.ietf.org/id/ construct to 21 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 (a) Network (b) Corresponding PDA (c) Transformed PDA (d) Subset of GN which generates TC Figure 3: Example 22 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 Symbols and their signification V: The set of nodes of the network G = (V, E): The graph modeling the network topology D: The destination node A: {a s.t. a ∈ A} ED: The set of all possible encapsula- tions and passive functions In(U ): The set of protocols that node U can receive T (U ): The set of protocols that can pas- sively cross node U (a, b): Encapsulation of protocol a in b TC: The sequence of protocols used over the path C (trace of C) MC: The well-parenthesized sequence of C Q: The set of states of AN Γ: The stack alphabet of AN SA: Initial state of AN DA: Final state of AN Qa: Sub-automaton indexed by a L(AN ): Language accepted by AN Symbols and their signification E: The set of links of the network S: The source node A: The alphabet (set of protocol) P(U): The set of adaptation functions of node U ED: The set of all possible decapsula- tions Out(U ): The set of protocols that node U can send (a, a): Passive function (a, b): Decapsulation of protocol a from b HC: Sequence of adaptation functions involved in path C (transition sequence of C) AN : Automaton corresponding to net- work N Σ: The input alphabet of AN δ: The set of transitions of AN Z0: Initial stack symbol (Ux,(cid:104)x, α, β(cid:105), Vy): A transition between states Ux and Vy, where x is read, α is popped from the stack and β is pushed on the stack A(cid:48) N : Transformed PDA N bAN push(w): Minimum number of pushes in a sequence of transitions accepting the word w in AN N : The set of nonterminals of GN GN : Context-free grammar correspond- ing to network N [SG]: Initial nonterminal (axiom) of GN P: The set of production rules of GN (cid:96)([X]): Length of the shortest word gen- erated by nonterminal [X] Table A.2: List of symbols used in the paper. 23 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 [5] A. Denise, Y. Ponty, and M. Termier. Controlled non-uniform random gen- eration of decomposable structures. Theoretical Computer Science, 411(40- 42):3527 -- 3552, 2010. [6] F. Dijkstra, B. Andree, K. Koymans, J. van der Ham, P. Grosso, and C. de Laat. A multi-layer network model based on ITU-T G.805. Comput. Netw., 2008. [7] F. Dijkstra, J. Van der Ham, P. Grosso, and C. de Laat. A path finding implementation for multi-layer networks. Future Generation Comp. Syst., 25(2):142 -- 146, 2009. [8] A. Farrel, JP. Vasseur, and J. Ash. RFC4655 - A Path Computation Ele- ment (PCE)-Based Architecture, 2006. [9] Ph. Flajolet, P. Zimmermann, and B. Van Cutsem. A calculus for the ran- dom generation of labelled combinatorial structures. Theoretical Computer Science, 1994. [10] D. Gardy and Y. Ponty. Weighted random generation of context-free lan- guages: Analysis of collisions in random urn occupancy models. GASCom, 2010. [11] S. Gong and B. Jabbari. Optimal and Efficient End-to-End Path Compu- tation in Multi-Layer Networks. In ICC, pages 5767 -- 5771, 2008. [12] T. Hickey and J. Cohen. Uniform random generation of strings in a context- free language. SIAM J. Comput., 12(4):645 -- 655, 1983. [13] J. E. Hopcroft, R. Motwani, and J. D. Ullman. From PDA's to Grammars. In Introduction to Automata Theory, Languages, and Computation, chap- ter 6.3.2, pages 247 -- 251. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2006. [14] F. A. Kuipers and F. Dijkstra. Path selection in multi-layer networks. Computer Communications, 2009. [15] M. L. Lamali, H. Pouyllau, and D. Barth. Path computation in Multi-Layer multi-domain networks. In IFIP/TC6 Networking 2012 (NETWORKING 2012), Prague, Czech Republic, May 2012. [16] M.L. Lamali, H. Pouyllau, and D. Barth. End-to-End Quality of Service in Pseudo-Wire Networks. In ACM CoNEXT Student Workshop, 2011. [17] Jens Liebehenschel. Lexicographical Generation of a Generalized Dyck Language. SIAM J. Comput., 2003. [18] H. G. Mairson. Generating Words in a Context-Free Language Uniformly at Random. Inf. Process. Lett., 49(2):95 -- 99, 1994. 24 Author's personal copy Published version doi:10.1016/j.comcom.2012.11.009 [19] L. Martini, E. Rosen, N. El-Aawar, and G. Heron. RFC4448 - Encapsula- tion Methods for Transport of Ethernet over MPLS Networks, 2008. [20] K. Shiomoto, D. Papadimitriou, JL. Le Roux, M. Vigoureux, and D. Brun- gard. RFC5212 - Requirements for GMPLS-based multi-region and multi- layer networks (MRN/MLN), 2008. [21] Y(J). Stein, R. Shashoua, R. Insler, and M. Anavi. RFC5087 - Time Divi- sion Multiplexing over IP (TDMoIP), 2007. [22] W. Yao and B. Ramamurthy. A Link Bundled Auxiliary Graph Model for Constrained Dynamic Traffic Grooming in WDM Mesh Networks. IEEE Journal on Selected Areas in Communications, 23(8):1542 -- 1555, 2005. [23] H. Zhu, H. Zang, K. Zhu, and B. Mukherjee. A novel generic graph model for traffic grooming in heterogeneous WDM mesh networks. IEEE/ACM Trans. Netw., 11(2):285 -- 299, 2003. 25
1608.07505
1
1608
2016-08-26T16:21:15
A Note on the Practicality of Maximal Planar Subgraph Algorithms
[ "cs.DS", "cs.CC" ]
Given a graph $G$, the NP-hard Maximum Planar Subgraph problem (MPS) asks for a planar subgraph of $G$ with the maximum number of edges. There are several heuristic, approximative, and exact algorithms to tackle the problem, but---to the best of our knowledge---they have never been compared competitively in practice. We report on an exploratory study on the relative merits of the diverse approaches, focusing on practical runtime, solution quality, and implementation complexity. Surprisingly, a seemingly only theoretically strong approximation forms the building block of the strongest choice.
cs.DS
cs
A Note on the Practicality of Maximal Planar Subgraph Algorithms Markus Chimani1, Karsten Klein2, Tilo Wiedera1 1 University Osnabruck, Germany {markus.chimani,tilo.wiedera}@uni-osnabrueck.de 2 Uni Konstanz, Germany [email protected] Abstract. Given a graph G, the NP-hard Maximum Planar Subgraph problem (MPS ) asks for a planar subgraph of G with the maximum number of edges. There are several heuristic, approximative, and exact algorithms to tackle the problem, but -- to the best of our knowledge -- they have never been compared competitively in practice. We report on an exploratory study on the relative merits of the diverse approaches, focusing on practical runtime, solution quality, and imple- mentation complexity. Surprisingly, a seemingly only theoretically strong approximation forms the building block of the strongest choice. 1 Introduction We consider the problem of finding a large planar subgraph in a given non-planar graph G = (V, E); n := V , m := E. We distinguish between algorithms that find a large, maximal, or maximum such graph: while the latter (MPS) is one with largest edge cardinality and NP-hard to find [18], a subgraph is inclusionwise maximal if it cannot be enlarged by adding any further edge of G. Sometimes, the inverse question -- the skewness of G -- is asked: find the smallest number skew (G) of edges to remove, such that the remaining graph is planar. The problem is a natural non-trivial graph property, and the probably best known non-planarity measure next to crossing number. This already may be reason enough to investigate its computation. Moreover, MPS/skewness arises at the core of several other applications: E.g., the practically strongest heuristic to draw G with few crossings -- the planarization method [2, 7]3 -- starts with a large planar subgraph, and then adds the other edges into it. Recognizing graphs of small skewness also plays a crucial role in parameter- ized complexity: Many problems become easier when considering a planar graph; e.g., maximum flow can be computed in O(n log n) time, the Steiner tree prob- lem allows a PTAS, the maximum cut can be found in polynomial time, etc. It hence can be a good idea to (in a nutshell) remove a couple of edges to obtain a planar graph, solve the problem on this subgraph, and then consider suitable 3 In contrast to this meaning, the MPS problem itself is also sometimes called pla- narization. We refrain from the latter use to avoid confusion. 6 1 0 2 g u A 6 2 ] S D . s c [ 1 v 5 0 5 7 0 . 8 0 6 1 : v i X r a 2 Markus Chimani, Karsten Klein, Tilo Wiedera modifications to the solution to accommodate for the previously ignored edges. E.g., we can compute a maximum flow in time O(skew (G)3 · n log n) [13]. While solving MPS is NP-hard, there are diverse polynomial-time approaches to compute a large or maximal planar subgraph, ranging from very trivial to sophisticated. By Euler's formula we know that already a spanning tree gives a 1/3-approximation for MPS. Hence all reasonable algorithms achieve this ratio. Only the cactus algorithms (see below) are known to exhibit better ratios. We will also consider an exact MPS algorithm based on integer linear programs (ILPs). All algorithms considered in this paper are known (for quite some time, in fact), and are theory-wise well understood both in terms of worst case solution quality and running time. To our knowledge, however, they have never been practically compared. In this paper we are in particular interested in the follow- ing quality measures, and their interplay: -- What is the practical difference in terms of running time? -- What is the practical difference in solution quality (i.e., subgraph density)? -- What is the implementation effort of the various approaches? Overall, understanding these different quality measures as a multi-criteria set- ting, we can argue for each of the considered algorithms that it is pareto-optimal. We are in particular interested in studying a somewhat "blurred" notion of pareto-optimality: We want to investigate, e.g., in which situations the addi- tional sophistication of algorithms gives "significant enough" improvements.4 Also the measure of "implementation complexity" is surprisingly hard to con- cisely define, and even in the field of software-engineers there is no prevailing notion; "lines of code" are, for example, very unrelated to the intricacies of algo- rithm implementation. We will hence only argue in terms of direct comparisons between pairs of algorithms, based on our experience when implementing them.5 As we will see in the next section, there are certain building blocks all al- gorithms require, e.g., a graph data structure and (except for C, see below) an efficient planarity test. When discussing implementation complexity, it seems safe to assume that a programmer will already start off with some kind of graph library for her basic datastructure needs.6 In the context of the ILP-based ap- proach, we assume that the programmer uses one of the various freely available (or commercial) frameworks. Writing a competitive branch-and-cut framework from ground up would require a staggering amount of knowledge, experience, time, and finesse. The ILP method is simply not an option if the programmer may not use a preexisting framework. In the following section, we discuss our considered algorithms and their im- plementation complexity. In Section 3, we present our experimental study. We 4 Clearly, there is a systematic weakness, as it may be highly application-dependent what one considers "significant enough". We hence cannot universally answer this question, but aim to give a guideline with which one can come to her own conclusions. 5 This measure is still intrinsically subjective (although we feel that the situation is quite clear in most cases), and opinions may vary depending on the implementor's knowledge, experience, etc. We discuss these issues when they become relevant. 6 Many freely available graph libraries contain linear-time planarity tests. They usually lack sophisticated algorithms for finding large planar subgraphs. A Note on the Practicality of Maximal Planar Subgraph Algorithms 3 first consider the pure problem of obtaining a planar subgraph. Thereafter, we investigate the algorithm choices when solving MPS as a subproblem in a typical graph drawing setting -- the planarization heuristic. 2 Algorithms Naıve Approach (Nı). The algorithmically simplest way to find a maximal planar subgraph is to start with the empty graph and to insert each edge (in random order) unless the planarity test fails. Given an O(n) time planarity test (we use the algorithm by Boyer and Myrvold [3], which is also supposed to be among the practically fastest), this approach requires O(nm) overall time.7 In our study, we consider a trivial multi-start variant that picks the best solu- tion after several runs of the algorithm, each with a different randomized order. The obvious benefit of this approach is the fact that it is trivial to understand and implement -- once one has any planarity test as a black box. Augmented Planarity Test (BM, BM+). Planarity tests can be modified to allow the construction of large planar subgraphs. We will briefly sketch these modifi- cations in the context of the above mentioned O(n) planarity test by Boyer and Myrvold [3]: In the original test, we start with a DFS tree and build the original graph bottom-up; we incrementally add a vertex together with its DFS edges to its children and the backedges from its decendents. The test fails if at least one backedge cannot be embedded. We can obtain a large (though in general not maximal) planar subgraph by ignoring whether some backedges have not been embedded, and continuing with the algorithm (BM). If we require maximality, we can use Nı as a prostprocessing to grow the obtained graph further (BM+). While this voids the linear runtime, it will be faster than the pure naıve approach. Given an implementation of the planarity testing algorithm, the required modifications are relatively simple per se -- however, they are potentially hard to get right as the implementor needs to understand side effects within the complex planarity testing implementation. Alternatively, Hsu [14] showed how to overcome the lack of maximality di- rectly within the planarity testing algorithm [19] (which is essentially equivalent to [3]), retaining linear runtime. While this approach is the most promising in terms of running time, it would require the most demanding implementation of all approaches discussed in this paper (including the next subsection) -- it means to implement a full planarity testing algorithm plus intricate additional proce- dures. We know of no implementation of this algorithm. Cactus Algorithm (C, C+). The only non-trivial approximation ratios are achieved by two cactus-based algorithms [4]. Thereby, one starts with the disconnected vertices of G. To obtain a ratio of 7/18 (C), we iteratively add triangles connect- ing formerly disconnected components. This process leaves a forest F of tree-like 7 We could speed-up the process in practice by starting with a spanning tree plus three edges. However, there are instances where the initial inclusion of a spanning tree prohibits the optimal solution and restricts one to approximation ratios ≤ 2/3 [8]. 4 Markus Chimani, Karsten Klein, Tilo Wiedera structures made out of triangles -- cactusses. Finally, we make F connected by adding arbitrary edges of E between disconnected components. Since this sub- graph will not be maximal in general, we can use Nı to grow it further (C+). From the implementation point of view, this algorithm is very trivial and -- unless one requires maximality -- does not even involve any planarity test. While a bit more complex than the naıve approach, it does not require modifications to complex and potentially hard-to-understand planarity testing code like BM. For the best approximation ratio of 4/9 one seeks not a maximal but a maximum cactus forest. However, this approach is of mostly theoretical interest as it requires non-trivial polynomial time matroid algorithms. xe (cid:12)(cid:12)(cid:12) Xe∈K ILP Approach (ILP). Finally, we use an integer linear program (ILP) to solve MPS exactly in reasonable (but formally non-polynomial) time, see [15]. With binary variables for each edge, specifying whether it is in the solution, we have maxnXe∈E xe ≤ K−1 for all Kuratowski subdivisions K ⊆ Go. Kuratowski's theorem [17] states that a graph is planar if and only if it does not contain a K5 or a K3,3 as a subdivision -- Kuratowski subdivisions. Hence we guarantee a planar solution by requiring to remove at least one edge in each such subgraph K. While the set of these constraints is exponential in size, we can separate them heuristically within a branch-and-cut framework, see [15]: after each LP relaxation, we round the fractional solution and try to identify a Kuratowski subdivision that leads to a violated constraint. This separation in fact constitutes the central implementation effort. Typ- ical planarity testing algorithms initially only answer yes or no. In the latter case, however, all known linear-time algorithms can be extended to extract a witness of non-planarity in the form of a Kuratowski subdivision in O(n) time. If the available implementation does not support this additional query, it can be simulated using O(n) calls to the planarity testing algorithm, by incremen- tally removing edges whenever the graph stays non-planar after the removal. Both methods result in a straight-forward implementation (assuming some fa- miliarity with ILP frameworks), but an additional tuning step to decide, e.g., on rounding thresholds, is necessary. The overall complexity is probably somewhere in-between C and BM. In our study, we decided to use the effective extraction scheme described in [10] which gives several Kuratowski subdivions via a single call. We propose, however, to use this feature only if it is already available in the library: its implementation effort would otherwise be comparable to a full planarity test, and in particular for harder instances its benefit is not significant. 3 Experiments For an exploratory study we conducted experiments on several benchmark sets. We summarize the results as follows -- observe the inversion between F1 and F2. F1. C+ yields the best solutions. Choosing a "well-growable" initial subgraph -- in our case a good cactus -- is practically important. The better solution of BM is a weak starting point for BM+; even Nı gives clearly better solutions. A Note on the Practicality of Maximal Planar Subgraph Algorithms 5 F2. BM gives better solutions than C; both are the by far fastest approaches. Thus, if runtime is more crucial than maximality, we suggest to use BM. F3. ILP only works for small graphs. Expander graphs (they are sparse but well-connected) seem to be among the hardest instances for the approach. F4. Larger planar subgraphs lead to fewer crossings for the planarization method. However, this is much less pronounced with modern insertion methods. Setup & Instances. All considered algorithms are implemented in C++ (g++ 5.3.1, 64bit, -O3) as part of OGDF [5], the ILP is solved via CPLEX 12.6. We use an Intel Xeon E5-2430 v2, 2.50 GHz running Debian 8; algorithms use singles cores out of twelve, with a memory limit of 4GB per process. We use the non-planar graphs of the established benchmark sets North [12] (423 instances), Rome [11] (8249), and SteinLib [16] (586), all of which include real-world instances. In our plots, we group instances according to V rounded to the nearest multiple of 10; for Rome we only consider graph with ≥ 25 vertices. Additionally, we consider two artificial sets: BaAl [1] are scale-free graphs, and Regular [20] (implemented as part of the OGDF) are random regular graphs; they are expander graphs w.h.p. [folklore]. Both sets contain 20 instances for each combination of V ∈ {102, 103, 104} and E/V ∈ {2, 3, 5, 10, 20}. Evaluation. Our results confirm the need for heuristic approaches, as ILP solves less than 25% of the larger graphs of the (comparably simple) Rome set within 10min. Even deploying strong preprocessing [6] (+PP) and doubling the computa- tion time does not help significantly, cf. Fig. 1(d). Already 30-vertex graphs with density 3, generated like Regular, cannot be solved within 48 hours (→F3). We measure solution quality by the density (edges per vertices) of the com- puted planar subgraph. Independently of the benchmark set, C+ always achieves the best solutions, cf. Fig. 1(a)(b)(table) (→F1). We know instances where Nı is only a 1/3 approximation whereas the worst ratio known for BM+ is 2/3 [8]. Surprisingly, Nı yields distinctly better solutions than BM+ in practice (→F1). On SteinLib, BaAl, and Regular, both C and BM behave similar w.r.t. solution quality. For Rome and North, however, BM yields solutions that are 20 -- 30% better, respectively (→F2). This discrepancy seems to be due the fact that the found subgraphs are generally very sparse for both algorithms on BaAl and Regular (average density of 1.1 and 1.2, respectively, for the largest graphs). Both C and BM are extremly (and similarly) fast; Fig. 1(c)(table) (→F2). For BM+ and C+, the Nı-postprocessing dominates the running time: Nı is worst, followed by C+ and BM+ -- a larger initial solution leads to fewer trys for growing. Nonetheless, we observe that the (weaker) solution of C allows for significantly more successful growing steps that BM (→F1). Finally, we investigate the importance of the subgraph selection for the pla- narization method, cf. Fig. 1(e)(f). For the simplest insertion algorithms (itera- tive edge insertions, fixed embedding, no postprocessing, [2]), a strong subgraph method (C+) is important; C leads to very bad solutions. For state-of-the-art in- sertion routines (simultaneous edge insertions, variable embedding, strong post- processing, [7, 9]) the subgraph selection is less important; even C is feasible. 6 Markus Chimani, Karsten Klein, Tilo Wiedera density, relative to best runtime [s] SteinLib BaAl Regular SteinLib BaAl Regular B-E I* S† V† 2 4 2 3 4 3 4 2 3 4 BM .86 .85 .82 .84 .72 .64 .66 .82 .84 .95 2 BM+ .90 .90 .88 .86 .85 .74 .73 .89 .89 .97 47.34 8.85 2.70 90.97 .06 10.57 143 .03 4.60 236 1 C C+ 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 9.19 16.22 3.13 16.35 .06 12.32 152 .04 5.34 217 Nı .92 .98 .91 .91 .96 .94 .92 .92 .91 .97 49.38 28.59 2.43 95.08 .05 7.92 239 .04 4.85 252 †S (= constr. sparse): PUC, SP; V (= VLSI): ALUE, ALUT, LIN, TAQ, DIW, DMXA, GAP, MSM, 1R, 2R .84 .67 .81 .87 .60 .68 .75 .74 .88 .95 V 2 .11 .00 S I* .07 .01 1 .00 .02 0 .00 .01 .04 .01 B-E .06 .07 .00 .01 3 .02 .04 (a) Rome, solution quality, C = 1.02[1.01, 1.06] (b) North, solution quality relative to ILP (over instances solved by ILP), C = 0.76[0.64, 0.85] 1.25 y t i s n e d 1.2 1.15 BM BM+ C+ Nı 40 60 80 100 # vertices (c) Rome, running time, BM ≈ 0, C ≈ 0 ) 0 0 1 × ( s e c n a t s n i # 20 15 10 5 0 BM+ C+ Nı 40 60 80 100 # vertices 25 20 15 10 5 0 ) 0 0 1 × ( s e c n a t s n i # y t i s n e d e v i t a l e r 1 0.98 0.96 0.94 0.92 1 e t a r - s s e c c u s 0.75 0.5 0.25 0 50 # vertices 0 100 (d) Rome, success-rate of ILP 20 15 10 5 0 ILP, 10min ILP+PP, 10min ILP+PP, 20min 40 60 80 100 # vertices 80 60 40 20 s e c n a t s n i # BM BM+ C+ Nı ) 0 0 1 × ( s e c n a t s n i # ) 0 0 1 × ( s e c n a t s n i # 5 4 3 2 1 0 20 15 10 5 0 ] s m [ e m i t n u r ) % ∆ ( t s e b o t e v i t a l e r , s g n i s s o r c f o . o n (e) Rome, simple planarization, C = 102[61, 173] BM BM+ C+ Nı 40 60 80 100 # vertices 20 15 10 5 0 ) 0 0 1 × ( s e c n a t s n i # ) % ∆ ( t s e b o t e v i t a l e r , s g n i s s o r c f o . o n (f ) Rome, state-of-the-art planarization 10 7.5 5 2.5 0 BM BM+ C C+ Nı 40 60 80 100 # vertices 20 15 10 5 0 Fig. 1. We may omit algorithms whose values are unsuitable for a plot; instead we give their average[min, max] in the caption. A Note on the Practicality of Maximal Planar Subgraph Algorithms 7 References 1. BarabasiAlbertGenerator of the java universal network/graph framework, jung.sourceforge.net 2. Batini, C., Talamo, M., Tamassia, R.: Computer aided layout of entity relationship diagrams. Journal of Systems and Software 4(2-3), 163 -- 173 (1984) 3. Boyer, J.M., Myrvold, W.J.: On the cutting edge: Simplified O(n) planarity by edge addition. J. Graph Algorithms Appl. 8(2), 241 -- 273 (2004) 4. Calinescu, G., Fernandes, C., Finkler, U., Karloff, H.: A better approximation algorithm for finding planar subgraphs. J. Algorithms 27, 269 -- 302 (1998) 5. Chimani, M., Gutwenger, C., Junger, M., Klau, G.W., Klein, K., Mutzel, P.: The open graph drawing framework (OGDF). In: Tamassia, R. (ed.) Handbook of Graph Drawing and Visualization, chap. 17, pp. 543 -- 569. CRC Press (2014), www.ogdf.net 6. Chimani, M., Gutwenger, C.: Non-planar core reduction of graphs. Discrete Math- ematics 309(7), 1838 -- 1855 (2009) 7. Chimani, M., Gutwenger, C.: Advances in the planarization method: Effective mul- tiple edge insertions. J. Graph Algorithms Appl. 16(3), 729 -- 757 (2012) 8. Chimani, M., Hedtke, I., Wiedera, T.: Limits of greedy approximation algorithms for the maximum planar subgraph problem. In: Proc. Int'l Workshop on Combi- natorial Algorithms (IWOCA) 2016. LNCS (2016), to appear 9. Chimani, M., Hlinen´y, P.: Inserting multiple edges into a planar graph. CoRR abs/1509.07952 (2015), http://arxiv.org/abs/1509.07952 10. Chimani, M., Mutzel, P., Schmidt, J.M.: Efficient extraction of multiple kuratowski subdivisions. In: Graph Drawing, 15th Int'l Symposium, GD 2007, Sydney, Aus- tralia, September 24-26, 2007. Revised Papers. pp. 159 -- 170 (2007) 11. Di Battista, G., Garg, A., Liotta, G., Tamassia, R., Tassinari, E., Vargiu, F.: An experimental comparison of four graph drawing algorithms. Computational Geom- etry 7(56), 303 -- 325 (1997) 12. Di Battista, G., Garg, A., Liotta, G., Parise, A., Tassinari, R., Tassinari, E., Vargiu, F., Vismara, L.: Drawing directed acyclic graphs: An experimental study. Int'l J. of Computational Geometry & Applications 10(06), 623 -- 648 (2000) 13. Hochstein, J.M., Weihe, K.: Maximum s-t-flow with k crossings in O(k3n log n). In: Proc. SODA 2007. pp. 843 -- 847. ACM-SIAM (2007) 14. Hsu, W.: A linear time algorithm for finding a maximal planar subgraph based on PC-trees. LNCS, vol. 3595, pp. 787 -- 797. Springer (2005) 15. Junger, M., Mutzel, P.: Maximum planar subgraphs and nice embeddings: Practical layout tools. Algorithmica 16(1), 33 -- 59 (1996) 16. Koch, T., Martin, A., Voss, S.: SteinLib: An updated library on steiner tree prob- lems in graphs. Tech. Rep. ZIB-Report 00-37, Konrad-Zuse-Zentrum fur Informa- tionstechnik Berlin (2000), http://elib.zib.de/steinlib 17. Kuratowski, C.: Sur le problme des courbes gauches en topologie. Fundamenta Mathematicae 15(1), 271 -- 283 (1930) 18. Liu, P.C., Geldmacher, R.C.: On the deletion of nonplanar edges of a graph. In: Proc. 10th Southeastern Conf. on Combinat., Graph Theory and Comput. pp. 727 -- 738. Congress. Numer., XXIII -- XXIV, Utilitas Math., Winnipeg, Man. (1979) 19. Shih, W., Hsu, W.: A new planarity test. Theor. Comput. Sci. 223(1-2), 179 -- 191 (1999) 20. Steger, A., Wormald, N.C.: Generating random regular graphs quickly. Combina- torics, Probability & Computing 8(4), 377 -- 396 (1999)
1002.2147
1
1002
2010-02-10T17:48:15
Optimization with More than One Budget
[ "cs.DS" ]
A natural way to deal with multiple, partially conflicting objectives is turning all the objectives but one into budget constraints. Some classical polynomial-time optimization problems, such as spanning tree and forest, shortest path, (perfect) matching, independent set (basis) in a matroid or in the intersection of two matroids, become NP-hard even with one budget constraint. Still, for most of these problems deterministic and randomized polynomial-time approximation schemes are known. In the case of two or more budgets, typically only multi-criteria approximation schemes are available, which return slightly infeasible solutions. Not much is known however for the case of strict budget constraints: filling this gap is the main goal of this paper. We show that shortest path, perfect matching, and spanning tree (and hence matroid basis and matroid intersection basis) are inapproximable already with two budget constraints. For the remaining problems, whose set of solutions forms an independence system, we present deterministic and randomized polynomial-time approximation schemes for a constant number k of budget constraints. Our results are based on a variety of techniques: 1. We present a simple and powerful mechanism to transform multi-criteria approximation schemes into pure approximation schemes. 2. We show that points in low dimensional faces of any matroid polytope are almost integral, an interesting result on its own. This gives a deterministic approximation scheme for k-budgeted matroid independent set. 3. We present a deterministic approximation scheme for 2-budgeted matching. The backbone of this result is a purely topological property of curves in R^2.
cs.DS
cs
Optimization with More than One Budget∗ Fabrizio Grandoni† Rico Zenklusen‡ November 13, 2018 Abstract A natural way to deal with multiple, partially conflicting objectives is turning all the objectives but one into budget constraints. Some classical polynomial-time optimization problems, such as spanning tree and forest, shortest path, (perfect) matching, independent set (basis) in a ma- troid or in the intersection of two matroids, become NP-hard even with one budget constraint. Still, for most of these problems deterministic and randomized polynomial-time approximation schemes are known. In the case of two or more budgets, typically only multi-criteria approx- imation schemes are available, which return slightly infeasible solutions. Not much is known however for the case of strict budget constraints: filling this gap is the main goal of this paper. We show that shortest path, perfect matching, and spanning tree (and hence matroid basis and matroid intersection basis) are inapproximable already with two budget constraints. For the remaining problems, whose set of solutions forms an independence system, we present de- terministic and randomized polynomial-time approximation schemes for a constant number k of budget constraints. Our results are based on a variety of techniques: 1. We present a simple and powerful mechanism to transform multi-criteria approximation schemes into pure approximation schemes. This gives, for example, deterministic approx- imation schemes for k-budgeted forest and bipartite matching, and randomized approxi- mation schemes for k-budgeted matching, independent set in matroids, and independent set in the intersection of two representable matroids. 2. We show that points in low dimensional faces of any matroid polytope are almost integral, an interesting result on its own. This gives a deterministic approximation scheme for k-budgeted matroid independent set. 3. We present a deterministic approximation scheme for 2-budgeted matching. The backbone of this result is a purely topological property of curves in R2. 0 1 0 2 b e F 0 1 ] S D . s c [ 1 v 7 4 1 2 . 2 0 0 1 : v i X r a 1 Introduction In many applications, one has to compromise between several, partially conflicting goals. Multi- Objective Optimization is a broad area of study in Operations Research, Economics and Computer Science [11, 14, 29]. A variety of approaches have been employed to formulate such problems including Goal Programming [4], Pareto-Optimality [10], and Multi-Budgeted Optimization [29]. We adopt the latter approach and cast one of the goals as the objective function, and the others as budget constraints. More precisely, we are given a (finite) set F of solutions for the problem, where each solution is a subset S of elements from a given universe E (e.g., the edges of a graph). We ∗Partially developed while both authors were visiting EPFL. †Computer Science Department, University of Rome Tor Vergata, [email protected] ‡Institute for Operations Research, ETH Zurich, [email protected] 1 are also given a weight function w : F → Q+ and a set of k = O(1)1 length functions ℓi : F → Q+, 1 ≤ i ≤ k, that assign a weight w(S) := Pe∈S w(e) and an ith-length ℓi(S) := Pe∈S ℓi(e), 1 ≤ i ≤ k, to every candidate solution S. For each length function ℓi, there is a budget Li ∈ Q+. The multi-budgeted optimization problem can then be formulated as follows: maximize/minimize w(S) subject to S ∈ F, ℓi(S) ≤ Li, 1 ≤ i ≤ k. (1) We next use OP T to denote an optimum solution. Following the literature on the topic, we focused on the set of problems below: • k-budgeted (perfect) matching: F is given by the (perfect) matchings of an undirected graph G = (V, E). • k-budgeted spanning tree (forest): F is given by the spanning trees (forests) of G. • k-budgeted shortest path: F is given by the paths connecting two given nodes s and t in G. • k-budgeted matroid independent set (basis): F is given by the independent sets (bases) of a matroid M = (E, I)2. • k-budgeted matroid intersection independent set (basis): F is given by the inde- pendent sets (bases) in the intersection of two matroids M1 = (E, I1) and M2 = (E, I2). All the problems above are polynomial-time solvable (see, e.g., [31]) in their unbudgeted version (k = 0), but become NP-hard [1, 6, 12] even for a single budget constraint (k = 1). For the case of one budget (k = 1), polynomial-time approximation schemes (PTASs) are known for spanning tree [28] (see also [17]), shortest path [32] (see also [16, 21]), and matching [6] (see also [5]). The approach in [28] easily generalizes to the case of matroid basis. A PTAS is also known for matroid intersection independent set [6]. The results in [6] do not generalize to the case of perfect matching and matroid intersection basis. No approximation algorithm is known for the problems above in the case k ≥ 2 (excluding multi-criteria algorithms which provide slightly infeasible solutions): investigating the existence of such algorithms is the main goal of this paper. 1.1 Our Results We start by observing that several of the mentioned problems are inapproximable already for two budget constraints. More precisely, the corresponding feasibility problem is NP-complete. The simple proof of the following theorem is given in the appendix. Theorem 1. For k ≥ 2, unless P = N P there is no polynomial-time approximation algorithm for k-budgeted spanning tree, k-budgeted shortest path, k-budgeted perfect matching, k-budgeted matroid basis, and k-budgeted matroid intersection basis. The remaining problems have a common aspect: the set of solutions F forms an independence system. In other terms, for S ∈ F and S′ ⊆ S, we have S′ ∈ F. For these problems, we present deterministic and randomized approximation schemes, based on a variety of techniques. 1The assumption that k is a constant is crucial in this paper. 2We recall that E is a finite ground set and I ⊆ 2E is a nonempty family of subsets of E (independent sets) which have to satisfy the following two conditions: (i) I ∈ I, J ⊆ I ⇒ J ∈ I and (ii) I, J ∈ I, I > J ⇒ ∃z ∈ I \ J : J ∪ {z} ∈ I. A basis is a maximal independent set. For all matroids used in this paper we make the usual assumptions that independence of a set can be checked in polynomial time. For additional information on matroids, see e.g. [31]. 2 Our first result (see Section 2) is a simple but powerful mechanism to transform a multi-criteria PTAS, i.e. a PTAS that might violate the budgets by a small multiplicative factor, into a pure PTAS, where no budget is violated. Similarly, a multi-criteria polynomial randomized-time ap- proximation scheme (PRAS) can be transformed into a pure PRAS. Theorem 2. (Feasibilization) Let Pind be a k-budgeted problem where the set of solutions F is an independence system. Suppose that we are given an algorithm A which, for any constant δ > 0, computes in polynomial time an (1 − δ) (resp., expected (1 − δ)) approximate solution to Pind violating each budget by a factor at most (1 + δ). Then there is a PTAS (resp., PRAS) for Pind. The idea behind the proof is showing that a good solution exists even if we scale down the budgets by a small factor. This is done by applying a greedy discarding strategy similar to the greedy algorithm for knapsack. Applying a multi-criteria PTAS (given as a black box!) to the scaled problem gives a feasible solution for the original one, of weight close to the optimal weight. To the best of our knowledge, this simple result was never observed before. Indeed, it implies im- proved approximation algorithms for a number of problems. A general construction by Papadim- itriou and Yannakakis [25] provides multi-criteria PTASs (resp., PRASs) for problems whose exact version admits a pseudo-polynomial-time (PPT) deterministic (resp., Monte-Carlo) algorithm. We recall that the exact version of a given optimization problem asks for a feasible solution of exactly a given target weight. Combining their approach with our mechanism one obtains approximation schemes for several problems. For example, using the PPT-algorithm for exact forest in [3], one obtains a PTAS for k-budgeted forest. Similarly, the Monte-Carlo PPT-algorithm for exact matching in [24] gives a PRAS for k-budgeted matching. The Monte-Carlo PPT-algorithms for exact matroid intersection independent set in [8], which works in the special case of representable matroids3, implies a PRAS for the corresponding budgeted problem. Of course, one can also exploit multi-criteria approximation schemes obtained with different tech- niques. For example, exploiting the multi-criteria PTAS in [13] for k-budgeted matching in bipartite graphs, which is based on iterative rounding, one obtains a PTAS for the same prob- lem. Very recently [9], a multi-criteria PRAS for k-budgeted matroid independent set, based on dependent randomized rounding, has been presented. This implies a PRAS for k-budgeted matroid independent set. Corollary 3. There are PTASs for k-budgeted forest and k-budgeted matching in bipartite graphs. There are PRASs for k-budgeted matching, k-budgeted matroid independent set, and k-budgeted matroid intersection in representable matroids. Based on a different, more direct approach, we are able to turn the PRAS for k-budgeted matroid independent set into a PTAS. The main insight is the following structural property of faces of the matroid polytope which might be of independent interest (proof in Section 3). Theorem 4. Let M = (E, I) be a matroid and let F be a face of dimension d of the matroid polytope4 PI . Then any x ∈ F has at most 2d non-integral components. Furthermore, the sum of all fractional components of x is at most d. A PTAS can then be easily derived as follows. We first guess the k/ε elements EH of largest weight in the optimum solution in a preliminary phase, and reduce the problem consequently. This guessing 3A matroid M = (S, I) is representable if its ground set S can be mapped in a bijective way to the columns of a matrix over some field, and I ⊆ S is independent in M iff the corresponding columns are linearly independent. 4For some given matroid M = (E, I), the corresponding matroid polytope PI is the convex hull of the incidence vectors of all independent sets. 3 step guarantees that the maximum weight wmax of an element in the reduced problem satisfies kwmax ≤ εw(EH ). For the reduced problem, we compute an optimal fractional vertex solution x∗ to the LP which seeks to find a maximum weight point in the matroid polytope intersected with the k budget constraints. Since x∗ is chosen to be a vertex solution, and only k linear constraints are added to the matroid polytope, x∗ lies on a face of the matroid polytope of dimension at most k. We then round down the fractional components of x∗ to obtain an incidence vector x which corresponds to some independent set EL. By Theorem 4, x∗ − x ≤ k, and hence, w(EL) ≥ w(x∗) − kwmax. Then, it is not hard to see that EH ∪ EL is a (1 − ε)-approximate feasible solution for the starting problem. Corollary 5. There is a PTAS for k-budgeted matroid independent set. Eventually, we present a PTAS (rather than a PRAS as in Corollary 3) for 2-budgeted matching (see Section 4). Theorem 6. There is a PTAS for 2-budgeted matching. Our PTAS, works as follows. Let us confuse a matching M with the associated incidence vector xM . We initially compute an optimal fractional matching x∗, and express it as the convex combination x∗ = α1x1 + α2x2 + α3x3 of three matchings x1, x2, and x3. Then we exploit a patching procedure which, given two matchings x′ and x′′ with high Lagrangian weight and a parameter µ ∈ [0, 1], computes a matching z which is not longer than xµ := µx′ + (1 − µ)x′′ with respect to both lengths, and has a comparable weight. This procedure is applied twice: first on the matchings x1 and x2 with parameter µ = α1/(α1 + α2), hence getting a matching z′. Second, on the two matchings z′ and x3 with parameter µ = (α1 + α2)/(α1 + α2 + α3). The resulting matching z′′ is feasible and almost optimal (modulo a preliminary guessing step). Our patching procedure relies on a topological property of curves in R2, that we prove via Jordan's curve theorem [22]. An extension of the property above to curves in Rk would imply a PTAS for k-budgeted matching: this is left as an interesting open problem. 1.2 Related Work There are a few general tools for designing approximation algorithms for budgeted problems. One basic approach is combining dynamic programming (which solves the problem for polyno- mial weights and lengths) with rounding and scaling techniques (to reduce the problem to the case of polynomial quantities). This leads for example to the FPTAS for 1-budgeted shortest path [16, 21, 32]. Another fundamental technique is the Lagrangian relaxation method. The basic idea is relaxing the budget constraints, and lifting them into the objective function, where they are weighted by Lagrangian multipliers. Solving the relaxed problem, one obtains two or more solutions with optimal Lagrangian weight, which can - if needed - be patched together to get a good solution for the original problem. Demonstrating this method, Goemans and Ravi [28] gave a PTAS for 1- budgeted spanning tree, which also extends to 1-budgeted matroid basis. Using the same approach, with an involved patching step, Berger, Bonifaci, Grandoni, and Schafer [6] obtained a PTAS for 1-budgeted matching and 1-budgeted matroid intersection independent set. Their approach does not seem to generalize to the case of multiple budget constraints. The techniques above apply to the case of one budget. Not much is known for problems with two or more budgets. However, often multi-criteria approximation schemes are known, which provide a (1 − ε)-approximate solution violating the budgets by a factor (1 + ε). First of all, there is a very general technique by Papadimitriou and Yannakakis [25], based on the construction of ε- approximate Pareto curves. Given an optimization problem with multiple objectives, the Pareto 4 curve consists of the set of solutions S such that there is no solution S′ which is strictly better than S (in a vectorial sense). Papadimitriou and Yannakakis show that, for any constant ε > 0, there always exists a polynomial-size ε-approximate Pareto curve A, i.e., a set of solutions such that every solution in the Pareto curve is within a factor of (1 + ε) from some solution in A on each objective. Furthermore, this approximate curve can be constructed in polynomial time in the size of the input and 1/ε whenever there exists a PPT algorithm for the associated exact problem. This implies multi-criteria FPTASs for k-budgeted spanning tree and k-budgeted shortest path. Furthermore, it implies a multi-criteria FPRAS for k-budgeted (perfect) matching. The latter result exploits the Monte-Carlo PPT algorithm for exact matching in [24]. Our PRAS improves on these results, approximation-wise (the running time is larger in our case). Recently, Grandoni, Ravi and Singh [13] showed that the iterative rounding technique is an al- ternative way to achieve similar (or better) results. The idea behind iterative rounding [18] (see also, e.g., [2, 20]) is to consider a linear relaxation of the problem, compute an optimal fractional solution, and round one of its variables. The process is then iterated on the residual problem until a feasible integral solution is obtained. This approach can be enhanced with a relaxation step, where a constraint which cannot be violated too much is relaxed (i.e., deleted). Using this method, Grandoni et al. obtain a multi-criteria PTAS for k-budgeted spanning tree, which computes a solution of optimal cost violating each budget by a factor (1 + ε). This improves, approximation- wise, on the result in [25] for the same problem (where the solution returned is suboptimal). The authors also show how to obtain a deterministic (rather than randomized [25]) multi-criteria PTAS for k-budgeted matching in bipartite graphs. All the mentioned problems are easy in the unbudgeted version. Given an NP-hard unbudgeted problem which admits a ρ approximation, the parametric search technique in [23] provides a multi- criteria kρ approximation algorithm violating each budget by a factor kρ for the corresponding problem with k budgets. Other techniques lead to logarithmic approximation factors (see, e.g., [7, 26, 27]). 2 A Feasibilization Mechanism In this section we illustrate our feasibilization mechanism, proving Theorem 2. Proof of Theorem 2. Let ε ∈ (0, 1] be a given constant. Consider the following algorithm. Initially we guess the h = k/ε elements5 EH of OP T of largest weight, and reduce the problem conse- quently6, hence getting a problem P ′. Then we scale down all the budgets by a factor (1 − δ), and solve the resulting problem P ′′ by means of A, where δ = ε/(k + 1). Let EL be the solution returned by A. We eventually output EH ∪ EL. Let OP T ′ and OP T ′′ be the optimum solution to problems P ′ and P ′′, respectively. We also denote by L′ i the ith budget in the two problems, respectively. Eventually, let wmax be the largest weight in P ′ and P ′′. We observe that trivially i and L′′ (a) w(OP T ) = w(EH) + w(OP T ′) and (b) wmax ≤ w(EH )/h. Let us show that w(OP T ′′) ≥ w(OP T ′)(1 − kδ) − kwmax. (2) 5To avoid inessential technicalities, we assume 1/ε ∈ N. 6As usual, by reducing we mean decreasing each budget Li by ℓi(EH) and removing all the elements of weight strictly larger than mine∈EH w(e). By guessing we mean trying all the O(mh) subsets of h elements. 5 Consider the following process: for each length function i, we remove from OP T ′ the element e with smallest ratio w(e)/ℓi(e) until ℓi(OP T ′) ≤ (1 − δ)L′ i. Let Ei be the set of elements removed. It is not hard to see that w(Ei) ≤ δw(OP T ′) + wmax. It follows that OP T ′ − ∪iEi is a feasible solution for P ′′ of weight at least w(OP T ′)(1 − δk) − kwmax, proving (2). We observe that EL is feasible for P ′ since, for each i, ℓi(EL) ≤ (1 + δ)L′′ i = (1 + δ)(1 − δ)L′ i ≤ L′ i. As a consequence, the returned solution EH ∪ EL is feasible. Moreover, when A is deterministic, we have w(EH ) + w(EL) ≥ w(EH ) + (1 − δ)w(OP T ′′) (2) ≥ w(EH ) + (1 − δ)(w(OP T ′)(1 − δk) − kwmax) (b) ≥ (1 − k/h)w(EH ) + (1 − δ(k + 1))w(OP T ′) ≥ (1 − ε)(w(EH ) + w(OP T ′)) (a) = (1 − ε)w(OP T ). The same bound holds in expectation when A is randomized. 3 A PTAS for k-Budgeted Matroid Independent Set It is convenient to consider weights w and lengths ℓi as vectors in QE. We denote by ℓ the matrix whose ith column is ℓi, and let L = (L1, . . . , Lk)T . To every matroid M = (E, I), a rank function r : 2E → N is associated; it is defined by r(S) = max{J J ⊆ S, J ∈ I}. The matroid polytope PI is the convex hull of the characteristic vectors χI of the independent sets I ∈ I and is described by the following set of inequalities (see [31] for more details): PI = conv{χI : I ∈ I} = {x ≥ 0 : x(S) ≤ r(S) ∀S ⊆ E}. Proof of Theorem 4. Let m = E. We assume that the matroid polytope has full dimension, i.e., dim(PI ) = m, which is equivalent to saying that every element e ∈ E is independent. This can be assumed without loss of generality since if {e} 6∈ I for some e ∈ E, then we can reduce the matroid by deleting element e. Since dim(PI ) = m and dim(F ) = d, F can be described by the inequality system of PI , where m − d linearly independent inequalities used in the description of PI are turned into equalities. More precisely, there are N ⊆ E and A1, . . . , Ak ⊆ E such that F = {x ∈ PI x(e) = 0 ∀e ∈ N, x(Ai) = r(Ai) ∀i ∈ {1, . . . , k}}, and N + k = m − d. By standard uncrossing arguments, we can assume that the sets Ai form a chain, i.e., A1 ( A2 ( · · · ( Ak (see for example [15, 18] for further information on combinatorial uncrossing). We prove the claim by induction on the number of elements of the matroid. The theorem clearly holds for matroids with a ground set of cardinality one. First assume N 6= ∅ and let e ∈ N . Let M ′ be the matroid obtained from M by deleting e, and let F ′ be the projection of F onto the coordinates corresponding to N \ {e}. Since F ′ is a face of M ′, the claim follows by induction. Henceforth, we assume N = ∅ which implies k = m − d. Let A0 = ∅ and Bi = Ai \ Ai−1 for i ∈ {1, . . . , k}. In the following we show that we can assume 0 < r(Ai) − r(Ai−1) < Bi ∀ i ∈ {1, . . . , k}. (3) Notice that 0 ≤ r(Ai) − r(Ai−1) ≤ Bi clearly holds by standard properties of rank functions (see [31] for more details). Assume that there is i ∈ {1, . . . , k} with r(Ai) = r(Ai−1). Since all 6 points x ∈ F satisfy x(Ai) = r(Ai) and x(Ai−1) = r(Ai−1), we have x(Bi) = 0. Hence for any e ∈ Bi, we have x(e) = 0 for x ∈ F . Again, we can delete e from the matroid, hence obtaining a smaller matroid for which the claim holds by the inductive hypothesis. Therefore, we can assume r(Ai) > r(Ai−1) which implies the left inequality in (3). For the right inequality assume that there is i ∈ {1, . . . , k} with r(Ai) − r(Ai−1) = Bi. Hence, every x ∈ F satisfies x(Bi) = Bi, implying x(e) = 1 for all e ∈ Bi. Let e ∈ Bi, and let F ′ be the projection of the face F onto the components N \ {e}. Since F ′ is a face of the matroid M ′ obtained from M by contracting e, the result follows again by the inductive hypothesis. Henceforth, we assume that (3) holds. This implies in particular that Bi > 1 for i ∈ {1, . . . , k}. i=1 Bi ≤ m, we have k ≤ m/2, which together with k = m − d implies d ≥ m/2. The claim of the theorem that x ∈ F has at most 2d non-integral components is thus trivial in this case. To prove the second part of the theorem we show that if (3) holds then x(E) ≤ d for x ∈ F . For x ∈ F we have Since Pk x(E) = x(E \ Ak) + ≤ E − Ak + k Xi=1 Xi=1 k x(Bi) ≤ E − Ak + (r(Ai) − r(Ai−1)) k Xi=1 (Ai − Ai−1 − 1) = m − k = d, where the first inequality follows from x(E \ Ak) ≤ E \ Ak and x(Bi) = r(Ai) − r(Ai−1), and the second inequality follows from (3). 4 A PTAS for 2-BUDGETED MATCHING In this section we present our PTAS for 2-budgeted matching. We denote by M the set of incidence vectors of matchings. With a slight abuse of terminology we call the elements in M matchings. Let PM be the matching polyhedron. Analogously to Section 3, let ℓ = (ℓ1, ℓ2) and L = (L1, L2)T . A feasible solution in this framework is a matching x ∈ M such that ℓT x ≤ L. For two elements z′, z′′ ∈ [0, 1]E , we define their symmetric difference z′∆z′′ ∈ [0, 1]E by (z′∆z′′)(e) = z′(e) − z′′(e) for all e ∈ E. In particular, if z′ and z′′ are incidence vectors, then their symmetric difference as defined above corresponds indeed to the symmetric difference in the usual sense. Recall that, when z′ and z′′ are matchings, z′∆z′′ consists of a set of node-disjoint paths and cycles. We start by presenting a property of curves in R2 (Section 4.1). This property is used to derive the mentioned patching procedure (Section 4.2). Eventually, we describe and analyze our PTAS (Section 4.3). 4.1 A Property of Curves in R2 We next describe a topological property of polygonal curves in R2, which will be crucial in our proof7. A curve in R2 is a continuous function f : [0, τ ] → R2 for some τ ∈ R+. A curve is called polygonal if it is piecewise linear. For a ∈ [0, τ ], let f a : [0, τ ] → R2 be the following curve. f a(t) =(f (t + a) − f (a) + f (0) f (τ ) − f (a) + f (a + t − τ ) if t + a < τ, if t + a ≥ τ. 7The lemma even holds for general (non-polygonal) curves. However, since we only need polygonal curves in our setting we restrict ourselves to this case since it simplifies the exposition. 7 Observe that f a(0) = f (0) and f a(τ ) = f (τ ) for any a ∈ [0, τ ]. The next lemma shows that any point x on the segment between f (0) and f (τ ) is contained in some curve f a. Lemma 7. Let f : [0, τ ] → R2 be a polygonal curve, and let µ ∈ [0, 1]. Then there are a, t ∈ [0, τ ] such that f a(t) = µf (0) + (1 − µ)f (τ ). We next give an intuitive description of the proof of the lemma: a formal proof is given in the appendix. Let f = (f1, f2). Since the statement of the lemma is independent of changes in the coordinate system (and the claim is trivial for f (0) = f (τ )), we can assume that f (0) = (0, 0) and f (τ ) = (r, 0) for some r > 0. The Gasoline Lemma [6] states that there is a1 ∈ [0, τ ] such that f a1 2 (t) ≥ 0 ∀t ∈ [0, τ ]. In particular, this condition is satisfied by choosing a1 ∈ arg min{f2(t) t ∈ [0, τ ]}. Analogously, for a2 ∈ arg max{f2(t) t ∈ [0, τ ]}, f a2 2 (t) ≤ 0 ∀t ∈ [0, τ ]. Hence, we have two curves, f a1 and f a2, one above and the other below the x-axis, both with the same endpoints (0, 0) and (r, 0). (See Figure 1). Furthermore, for a ranging from a1 to a2 (in a circular sense), the curve f a continuously transforms from f a1 to f a2, always maintaining the same endpoints. Then it is intuitively clear that the union of the curves f a spans all the points on the segment from (0, 0) to (r, 0), hence proving the claim. 4.2 The Patching Procedure In this section we describe a patching procedure which, given two matchings x′ and x′′ and a parameter µ ∈ [0, 1], computes a matching z satisfying ℓT z ≤ ℓT xµ, where xµ := µx′ + (1 − µ)x′′ is a convex combination of the first two matchings. Furthermore, the weight wT z is close to wT xµ, provided that x′ and x′′ have a sufficiently large Lagrangian weight, which is defined as follows. Let 2 ∈ R+ be a pair of optimal dual multipliers for the budgets in the linear program max{wT x 1, λ∗ λ∗ 2)(ℓT x − L). x ∈ PM, ℓT x ≤ L}. The Langrangian weight of x ∈ [0, 1]E is L(x) = wT x − (λ∗ Notice, that by the theory of Lagrangian duality we have w∗ = max{L(x) x ∈ PM}, where w∗ is the weight of an optimal LP solution, i.e., w∗ = max{wT x x ∈ PM, ℓT x ≤ L} (see [19] for more information on Lagrangian duality). We need the following notion of almost matching. Definition 8. For r ∈ N, an r-almost matching in G is a (possibly fractional) vector y ∈ [0, 1]E such that it is possible to set at most r components of y to zero to obtain a matching. 1, λ∗ We denote by Mr the set of all r-almost matchings in G. Given an r-almost matching y, we let a corresponding matching z ∈ M be a matching obtained by setting to zero the fractional components of y, and then computing a maximal matching in the resulting set of edges (in particular, we might need to set to 0 some 1 entries of y to obtain z). Notice that wT z ≥ wT y − rwmax, where wmax is the largest weight. Our patching procedure first constructs a 2-almost matching y, and then returns a corresponding matching z. We next show how to compute y. Let us restrict our attention to the following set of candidate 2-almost matchings. Recall that s = x′∆x′′ is a set of paths and cycles. We construct an auxiliary graph C, consisting of one cycle (e0, e1, . . . , eτ −1), with the following property: there is a bijective mapping between the edges of C and the edges of s such that two consecutive edges of C are either consecutive in some path/cycle or belong to different paths/cycles. This can be easily achieved by cutting each cycle, appending the resulting set of paths one to the other, and gluing together the endpoints of the obtained path. For t ∈ [0, τ ], we define s(t) ∈ [0, 1]E as (s(t))(e) =  1 t − ⌊t⌋ 0 if e = ei, i < ⌊t⌋; if e = ei, i = ⌊t⌋; otherwise. 8 Moreover, for a, t ∈ [0, τ ], we define [0, 1]E ∋ sa(t) =(s(a + t) − s(a) s(a + t − τ ) + s(τ ) − s(a) if a + t ≤ τ ; if a + t > τ. Intuitively, a and (a + t) (mod τ ) define a (fractional) subpath of C, and sa(t) is the (fractional) incidence vector corresponding to that subpath. Eventually we define ya(t) := x′△sa(t). Note that ya(t) is equal to x′ and x′′ for t = 0 and t = τ , respectively. Lemma 9. For any a, t ∈ [0, τ ], ya(t) is a 2-almost matching. Proof. One can easily observe that a matching can be obtained by setting the two components of ya(t) to zero that correspond to the edges e⌊a⌋ and e⌊(a+t) (mod τ )⌋. The following lemma shows that, in polynomial time, one can find a 2-almost matching y with lengths ℓT y equal to the lengths of any convex combination of the two matchings x′ and x′′. Lemma 10. Let µ ∈ [0, 1] and xµ = µx′ + (1 − µ)x′′. In polynomial time, a, t ∈ [0, τ ] can be determined such that ℓT ya(t) = ℓT xµ. Proof. Let f : [0, τ ] → R2 be the polygonal curve defined by f (t) = ℓT y0(t). Since f (0) = ℓT x′ and f (τ ) = ℓT x′′, we have by Lemma 7 that there exists a, t ∈ [0, τ ] such that f a(t) = ℓT xµ. Since f a(t) = ℓT ya(t), y := ya(t) satisfies the claim. The values of ⌊a⌋ and ⌊a + t⌋ can be guessed in polynomial time by considering O(n2) possibilities. Given those two rounded values, the actual values of a and t can be obtained by solving a linear program with a constant number of variables and constraints. Our patching procedure simply computes a 2-almost matching y = ya(t) with ℓT y = ℓT xµ, exploit- ing the lemma above, and then returns a corresponding matching z, by applying the procedure explained in the proof of Lemma 9. Trivially, ℓT z ≤ ℓT y = ℓT xµ. We next show that, if x′ and x′′ have sufficiently large Lagrangian weight, then the weight of z is close to the weight of xµ. Lemma 11. Assume L(x′) ≥ w∗ − Γ and L(x′′) ≥ w∗ − Γ for some Γ ∈ R+. Then the matching z returned by the patching procedure satisfies wT z ≥ wT xµ − 2wmax − Γ and ℓT z ≤ ℓT xµ. Proof. By Lemma 10 we have ℓT y = ℓT xµ, and since z ≤ y, we get ℓT z ≤ ℓT xµ. Let xµ = x′ + x′′ − xµ = (1 − µ)x′ + µx′′. Since L(x′) ≥ w∗ − Γ, L(x′′) ≥ w∗ − Γ and L is linear, we have L(xµ) ≥ w∗ − Γ and L(xµ) ≥ w∗ − Γ. Recall that y = ya(t) for a proper choice of a, t ∈ [0, τ ]. Let y := x′ + x′′ − y. Notice that y = ya′ (τ − t) where a′ = (a + t) (mod τ ), and hence, y is also a 2-almost matching by Lemma 9. Let z be the matching corresponding to y obtained by applying the procedure explained in the proof of Lemma 9 to y. Notice that the pairs (z, y) and (z, y) differ on the same two (or less) components. Hence wT z + wT z + 2wmax ≥ wT y + wT y = wT xµ + wT xµ. (4) Since y + y = xµ + xµ and ℓT y = ℓT xµ, we get ℓT y = ℓT xµ. Thus, ℓT z ≤ ℓT xµ since z ≤ y. This can be rewritten as L(z) − wT z ≥ L(xµ) − wT xµ. Since L(xµ) ≥ w∗ − Γ and L(z) ≤ w∗, we obtain wT z ≤ wT xµ + Γ. Combining this result with (4) implies wT z ≥ wT xµ − 2wmax − Γ. 9 4.3 The Algorithm Our PTAS works as follows. Initially it guesses the 6/ε heaviest edges EH in the optimum solution, and reduces the problem consequently. Then it computes a vertex x∗ ∈ PM of the polytope {x ∈ PM ℓT x ≤ L} of maximum weight w∗ := wT x∗. As x∗ is a vertex solution of the polytope PM with two additional constraints, it lies on a face of PM of dimension at most two. Hence, by Carath´eodory's Theorem, x∗ can be expressed as a convex combination x∗ = α1x1 + α2x2 + α3x3 of three matchings x1, x2, x3 ∈ PM. Let µ′ = α1/(α1 + α2) and µ′′ = (α1 + α2)/(α1 + α2 + α3). Applying Lemma 11 to x1 and x2 with µ = µ′, a matching z′ is obtained. Applying Lemma 11 to z′ and x3 with µ = µ′′, we obtain a matching z′′. The algorithm returns z′′ plus EH. Proof of Theorem 6. Consider the algorithm above. The initial guessing can be performed in O(E6/ε) time. Since it is possible to efficiently separate over PM, x∗ can be computed in poly- nomial time [31]. The same holds for the decomposition of x∗ into three matchings by standard techniques (see for example [30]). Lemma 10 implies that the patching can be done in polynomial time. Hence the proposed algorithm runs in polynomial time as claimed. Since L(x∗) = w∗ and L(x) ≤ w∗ for x ∈ PM, we get L(x1) = L(x2) = L(x3) = w∗. Let u := µ′x1 + (1 − µ′)x2 and v := µ′′z′ + (1 − µ′′)x3. By Lemma 11, matching z′ satisfies ℓT z′ ≤ ℓT u and wT z′ ≥ wT u − 2wmax. Since u is a convex combination of x1 and x2, we have L(u) = w∗. Furthermore, by the relations between the lengths and weight of z′ and u, we get L(z′) ≥ L(u) − 2wmax = w∗ − 2wmax. By Lemma 11, matching z′′ satisfies ℓT z′′ ≤ ℓT v and wT z′′ ≥ wT v − 4wmax. We observe that z′′ satisfies the budget constraints since ℓT z′′ ≤ ℓT v = ℓT ((α1 + α2)z′ + α3x3) ≤ ℓT ((α1 + α2)u + α3x3) = ℓT x∗ ≤ L. Furthermore, wT z′′ ≥ wT v − 4wmax = wT ((α1 + α2)z′ + α3x3) − 4wmax ≥ wT ((α1 + α2)u + α3x3) − 6wmax = w∗ − 6wmax. Let OP T ′ be an optimum solution to the reduced problem. Of course, w∗ ≥ w(OP T ′). Further- more, the weight of the guessed edges EH is at least 6/ε wmax. Since w(OP T ) = w(EH)+w(OP T ′), we can conclude that the solution returned by the algorithm has weight at least w(EH)(1 − ε) + w(OP T ′) ≥ (1 − ε)w(OP T ). 5 Conclusions A first obvious open problem is finding a PTAS for the k-budgeted matching problem for any k = O(1). It is interesting to notice that most parts of the approach presented in Section 4 can easily be generalized to an arbitrary constant number of budget constraints. More precisely, the only part that is tailored to two budgets is Lemma 7, which is only valid for curves in two dimensions. We believe that for every constant k ∈ N there is r(k) ∈ N such that the following generalized version of Lemma 7 holds. Conjecture 12. Let f : [0, τ ] → Rk be a curve, and let µ ∈ [0, τ ]. Then there are r(k) disjoint i=1 (f (bi)−f (ai)) = µf (0)+(1−µ)f (τ ). intervals [a1, b1], . . . , [ar(k), br(k)] ⊆ [0, τ ] such that f (0)+Pr(k) 10 In particular, for k = 2, the pair (a, t) given by Lemma 7 defines either one interval [a, a + t] or two intervals [a, τ ] and [0, a + t − τ ] satisfying the claim above. If Conjecture 12 holds, then a PTAS for the k-budgeted case can be obtained by following a procedure analogous to the one that we presented here. Another interesting direction for further research, is to check whether a similar technique can be applied to k-budgeted matroid intersection independent set. A crucial property that we exploited in this paper is the well-known fact that a matching can be transformed to another matching in the same graph by exchanging edges on alternating paths and cycles. Similar exchange properties are known for the intersection of matroids. However, they do not seem to allow for an easy adaption of the presented algorithm. Another set of questions involves the problems considered here but with one budget. Is there a fully-polynomial PTAS (FPTAS) for 1-budgeted spanning tree and 1-budgeted matching? We remark that, as noted in [6], an FPTAS for the second problem would imply a deterministic algorithm for exact matching with polynomial weights, which is a long-standing open problem. In the case of 1-budgeted perfect matching, a PTAS is not known. Acknowledgements. The authors wish to thank Friedrich Eisenbrand for supporting their visit to EPFL and for helpful discussions. References [1] V. Aggarwal, Y. P. Aneja, and K. P. K. Nair, Minimal Spanning Tree Subject to a Side Constraint, Computers & Operations Research, 9 (1982), pp. 287 -- 296. [2] N. Bansal, R. Khandekar, and V. Nagarajan. Additive Guarantees for Degree Bounded Directed Network Design. In STOC, pages 769 -- 778, 2008. [3] F. Barahona, and W. R. Pulleyblank, Exact arborescences, matchings and cycles, Discrete Appl. Math., 16(2): 91 -- 99, 1987. [4] V. Barichard, M. Ehrgott, X. Gandibleux, V. T'Kindt (Eds.) Multiobjective Programming and Goal Programming: Theoretical Results and Practical Applications Springer-Verlag Series: Lecture Notes in Economics and Mathematical Systems , Vol. 618, 2009. [5] A. Berger, V. Bonifaci, F. Grandoni, and G. Schafer. Budgeted Matching and Budgeted Matroid Intersection via the Gasoline Puzzle. In IPCO, pages 273 -- 287, 2008. [6] A. Berger, V. Bonifaci, F. Grandoni, and G. Schafer. Budgeted Matching and Budgeted Matroid Intersection via the Gasoline Puzzle. To appear in Mathematical Programming. [7] V. Bilu, V. Goyal, R. Ravi, and M. Singh. On the Crossing Spanning Tree Problem. In APPROX- RANDOM, pages 51 -- 64, 2004. [8] P. Camerini, G. Galbiati, and F. Maffioli, Random pseudo-polynomial algorithms for exact ma- troid problems, Journal of Algorithms 13: 258 -- 273, 1992. [9] C. Chekuri, J. Vondr´ak, and R. Zenklusen, Dependent Randomized Rounding for Matroid Poly- topes and Applications, 2009. http://arxiv.org/abs/0909.4348. [10] A. Chinchuluun, P. M. Pardalos, A. Migdalas, and L. Pitsoulis (Eds.) Pareto Optimality, Game Theory and Equilibria Springer-Verlag Series: Optimization and Its Applications , Vol. 17, 2008. [11] J. Climacao, Multicriteria Analysis. Springer-Verlag, 1997. 11 [12] M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP- Completeness, W.H. Freeman, 1979. [13] F. Grandoni, R. Ravi, and M. Singh, Iterative Rounding for Multi-Objective Optimization Prob- lems. In ESA, pages 95 -- 106, 2009. [14] R. Hartley, Survey of Algorithms for Vector Optimization Problems. Multiobjective Decision Making, In French S, Hartley R, Thomas LC, and White DJ (eds),1983, pages:1 -- 34, Academic Press. [15] C. A. Hurkens, L. Lov´asz, A. Schrijver, and E. Tardos, How to Tidy Up your Set System, Combinatorics, North-Holland, 309 -- 314, 1988. [16] R. Hassin, Approximation Schemes for the Restricted Shortest Path Problem, Mathematics of Opera- tion Research 17(1): 36 -- 42, 1992. [17] R. Hassin and A. Levi, An Efficient Polynomial Time Approximation Scheme for the Constrained Minimum Spanning Tree Problem Using Matroid Intersection, SIAM Journal on Computing 33(2): 261 -- 268, 2004. [18] K. Jain, A factor 2 Approximation Algorithm for the Generalized Steiner Network Problem, Combina- torica 21: 39 -- 60, 2001. [19] B. Korte and J. Vygen, Combinatorial Optimization, Springer, 2008. [20] L. C. Lau, J. Naor, M. R. Salavatipour, and M. Singh,Survivable Network Design with Degree or Order Constraints. In STOC, pages 651 -- 660, 2007. [21] D. Lorenz and D. Raz, A Simple Efficient Approximation Scheme for the Restricted Shortest Paths Problem, Operations Research Letters 28: 213 -- 219, 2001. [22] J. R. Munkres, Topology, second edition, Prentice Hall, 2000. [23] M. V. Marathe, R. Ravi, R. Sundaram, S. S. Ravi, D. J. Rosenkrantz, and H. B. Hunt III. Bicriteria network design problems. In ICALP, pages 487 -- 498, 1995. [24] K. Mulmuley, U. Vazirani, V. Vazirani, Matching is as Easy as Matrix Inversion. Combinatorica, 7(1):101 -- 104, 1987. [25] C. H. Papadimitriou and M. Yannakakis, On the approximability of trade-offs and optimal access of Web sources. In FOCS, pages 86 -- 92, 2000. [26] R. Ravi. Rapid rumor ramification: Approximating the minimum broadcast time. In FOCS, pages 202 -- 213, 1994. [27] R. Ravi. Matching Based Augmentations for Approximating Connectivity Problems. Invited Lecture, In LATIN, pages 13 -- 24, 2006. [28] R. Ravi and M. X. Goemans. The constrained minimum spanning tree problem (extended abstract). In SWAT, pages 66 -- 75, 1996. [29] R. Ravi, M. V. Marathe, S. S. Ravi, D. J. Rosenkrantz, and H. B. Hunt. Many Birds with One Stone: Multi-objective Approximation Algorithms. In STOC, pages 438-447, 1993. [30] A. Schrijver, Theory of Linear and Integer Programming, John Wiley & Sons, 1998. [31] A. Schrijver, Combinatorial Optimization, Polyhedra and Efficiency, Springer, 2003. [32] A. Warburton, Approximation of Pareto Optima in Multiple-Objective, Shortest Path Problems. Operations Research, 35: 70 -- 79, 1987. 12 Figure 1 The full line indicates f , and the dashed lines f a1 and f a2, respectively. 5 3 2 −2 −3 −5 4 8 10 2 12 Appendix Proof of Theorem 1. We show that deciding feasibility of the considered problems is N P -complete. It is sufficient to prove the claim for k = 2. Consider first 2-budgeted spanning tree: the claim for k-budgeted matroid basis and, consequently, for k-budgeted matroid intersection basis trivially follows. Let P + denote the problem, and P ± its variant with arbitrary (i.e., positive and/or negative) lengths. Of course, P ± includes P + as a special case. To see the opposite reduction, observe that a spanning tree contains exactly n−1 edges. Hence, by adding a sufficiently large value M to all the lengths, and adding (n − 1)M to the budgets, one obtains an equivalent problem with non-negative lengths. It is easy to see that P ± includes as a special case the problem P = of determining, for a given length function ℓ′(·) and target L′, whether there exists a spanning tree T of length ℓ′(S) = L′: a reduction is obtained by setting ℓ1(·) = −ℓ2(·) = ℓ′(·) and L1 = −L2 = L′. Hence it is sufficient to show that P = is NP-complete. We do that via the following reduction from partition: given α1, α2, . . . , αq ∈ Q and a target A ∈ Q, determine whether there exists a subset of αi's of total value A. Consider graph Gq, consisting of q cycles C1, C2, . . . , Cq, with Ci = (ai, bi, ci, di) and ci = ai+1 for i = 1, 2, . . . , q − 1. Let ℓ′(aibi) = αi, i = 1, 2, . . . , k, and set to zero all the other lengths. The target is L′ = A. Trivially, for each spanning tree T and each cycle Ci, the length of T ∩ Ci is either 0 or αi. Hence, the answer to the input partition problem is yes if and only if the same holds for the associated instance of P =. Consider now 2-budgeted perfect matching. Since each perfect matching contains exactly n/2 edges, with the same argument and notation as above it is sufficient to prove the N P -completeness of the problem P = of determining, for a given length function ℓ′(·) and target L′, whether there exists a perfect matching M of length ℓ′(M ) = L′. We use a similar reduction from partition as above. The graph is again given by the cycles C1, . . . , Cq. However, this time each cycles forms its own connected component. Furthermore, the lengths are given by ℓ′(aibi) = ℓ′(cidi) = αi, i = 1, 2, . . . , k, all the other lengths are zero, and L′ = 2A. It is easy to see that, for each perfect matching M and each cycle Ci, the length of T ∩ Ci is either 0 or 2αi. The claim follows. Eventually consider 2-budgeted shortest path. We restrict our attention to the graph Gq as used for the spanning tree reduction, and let (s, t) = (a1, cq). Since any s-t path in this graph uses exactly 2q edges, we have by the usual argument that it is sufficient to show the N P -completeness 13 of the problem P = of determining, for a given length function ℓ′(·) and target L′, whether there exists an s-t path P of length ℓ′(P ) = L′. The claim follows by essentially the same reduction as in the spanning tree case. Proof of Lemma 7. Without loss of generality, we can assume that f = (f1, f2) satisfies. (i) f (0) = (0, 0) and f (τ ) = (r, 0) for r > 0. (ii) f2(t) ≥ 0 ∀t ∈ [0, τ ], (iii) f is not self-intersecting (i.e., f is an injection). Let f = (f1, f2). Since the statement of the lemma is independent of changes in the coordinate system (and the claim is trivial for f (0) = f (τ )), we can assume that f (0) = (0, 0) and f (τ ) = (r, 0) for some r > 0. Hence, (i) holds. The Gasoline Lemma [6] states that there is ¯a ∈ [0, τ ] such that f ¯a 2 (t) ≥ 0 ∀t ∈ [0, τ ]. More precisely, this condition is satisfied by choosing ¯a ∈ arg min{f2(t) t ∈ [0, τ ]}. One can easily observe that if the lemma is true for f ¯a then it also holds for f . Hence, we can assume, by replacing f by f ¯a, that Property (ii) holds. Property (iii) can be enforced by removing loops. Furthermore, we assume µ ∈ (0, 1), otherwise the claim is trivially true. Let v = (v1, 0) = µf (0) + (1 − µ)f (τ ) = (1 − µ)f (τ ) and g : [0, τ ] → R2 be the translation of f by v: g(t) = f (t) + v ∀t ∈ [0, τ ]. Let u = max{f2(t) t ∈ [0, τ ]} and p = min{t ∈ [0, τ ] f2(t) = u}, i.e., f2 attains its maximum the first time at p. Let f ′ : [p, τ ] → R2 with f ′(t) = f (t) be the subcurve of f over the interval [p, τ ], and let g′ : [0, p] → R2 with g′(t) = g(t) be the subcurve of g over the interval [0, p]. In the following we show that f ′ and g′ intersect. Consider the endpoints of f ′ and g′. The endpoints f ′(τ ) = (r, 0) and g′(0) = (v1, 0) both lie on the x-axis, and since v1 = (1 − µ)r < r, f ′(τ ) lies to the right of g′(0). Similarly, the other two endpoints f ′(p) = (f1(p), u) and g′(p) = (f1(p) + v1, u) have the same y-components, where this time f ′(p) is to the left of g′(p). Since the second component of both curves lies between 0 and u, one can easily deduce that they have to cross. In more detail, one way to show this is to consider the polygonal curve h joining, in the given order, f ′(p) = (f1(p), u), (−M, u), (−M, −1), (r, −1) and (r, 0) = f ′(τ ), where M > 0 is a large value such that h does not intersect g′. The concatenation of h with f ′ forms a closed, not self-intersecting curve, which - by Jordan's Curve Theorem [22] - divides R2 into two regions, a bounded one and an unbounded one. Furthermore, g′ has one endpoint in one region and the other endpoint in the other region. Again by Jordan's curve theorem, we have that g′ and f ′ intersect (since we have by construction that g′ does not intersect h). Hence, there exists t1 ∈ [p, τ ] and t2 ∈ [0, p] such that f (t1) = g(t2). Since f (p) 6= g(p), we have t2 < t1. The claim is satisfied by f t2(t1 − t2) = f (t1 − t2 + t2) − f (t2) = g(t2) − f (t2) = v. 14
1103.1503
1
1103
2011-03-08T12:32:12
An Exact Algorithm for Side-Chain Placement in Protein Design
[ "cs.DS" ]
Computational protein design aims at constructing novel or improved functions on the structure of a given protein backbone and has important applications in the pharmaceutical and biotechnical industry. The underlying combinatorial side-chain placement problem consists of choosing a side-chain placement for each residue position such that the resulting overall energy is minimum. The choice of the side-chain then also determines the amino acid for this position. Many algorithms for this NP-hard problem have been proposed in the context of homology modeling, which, however, reach their limits when faced with large protein design instances. In this paper, we propose a new exact method for the side-chain placement problem that works well even for large instance sizes as they appear in protein design. Our main contribution is a dedicated branch-and-bound algorithm that combines tight upper and lower bounds resulting from a novel Lagrangian relaxation approach for side-chain placement. Our experimental results show that our method outperforms alternative state-of-the art exact approaches and makes it possible to optimally solve large protein design instances routinely.
cs.DS
cs
An Exact Algorithm for Side-Chain Placement in Protein Design Stefan Canzar1, Nora C. Toussaint2, and Gunnar W. Klau1 1CWI, Life Sciences group, Science Park 123, 1098 XG Amsterdam, the Netherlands, {stefan.canzar, gunnar.klau}@cwi.nl 2University of Tübingen, Center for Bioinformatics, Applied Bioinformatics, Sand 14, 72076 Tübingen, Germany, [email protected] Abstract Computational protein design aims at constructing novel or improved func- tions on the structure of a given protein backbone and has important applica- tions in the pharmaceutical and biotechnical industry. The underlying combi- natorial side-chain placement problem consists of choosing a side-chain place- ment for each residue position such that the resulting overall energy is mini- mum. The choice of the side-chain then also determines the amino acid for this position. Many algorithms for this(cid:78) (cid:80) -hard problem have been proposed in the context of homology modeling, which, however, reach their limits when faced with large protein design instances. In this paper, we propose a new exact method for the side-chain placement problem that works well even for large instance sizes as they appear in pro- tein design. Our main contribution is a dedicated branch-and-bound algorithm that combines tight upper and lower bounds resulting from a novel Lagrangian relaxation approach for side-chain placement. Our experimental results show that our method outperforms alternative state-of-the-art exact approaches and makes it possible to optimally solve large protein design instances routinely. 1 Introduction Protein design aims at constructing novel or improved functions on the structure of a given protein backbone. Since proteins are key players in virtually all biological processes, the ability to design proteins is of great practical interest, e.g., to the phar- maceutical and biotechnological industry. Experimental protein design methods, such as directed evolution [3], have been applied successfully. However, since ex- perimental methods are time- and money-consuming, computational approaches are an attractive alternative. Computational protein design is related to the side-chain placement (SCP) prob- lem in protein homology modeling. Given the modeled backbone of a protein, the amino acid side-chains have to be placed on this backbone in the energetically most 1 favorable conformation. Two assumptions are commonly made: (i) side-chains adopt only statistically dominant low-energy side-chain conformations, the so-called rotamers [10], and (ii) the energy of a protein is the sum of intrinsic side-chain en- ergies and pairwise interaction energies. These assumptions lead to the following discrete optimization problem: For each residue position choose a rotamer such that the total energy of the protein is minimum. This problem has been shown to be NP-hard [20] and inapproximable [5]. In protein design the candidate rotamers at each position do not only come from a single amino acid but from several potential amino acids, yielding very large problem instances. Previous in silico approaches to protein design differ in their choice of rotamer library, energy function, and optimization method. Utilization of a higher-resolution rotamer library and a more accurate energy function will im- prove the results. On the other hand, it will increase computation time and prob- lem size. Regarding the optimization methods, computational protein design ap- proaches generally employ computationally expensive heuristics such as the Monte Carlo method [7, 6, 21]. Other heuristics, which have been proposed for SCP in pro- tein homology modeling, could also be applied [24, 25, 9, 28, 22]. However, Voigt et al. [23] have shown that these inexact algorithms become less accurate with in- creasing problem size. Thus, exact methods capable of solving large protein de- sign instances are desirable. Several approaches to solving the SCP problem exactly have been proposed, including dead end elimination [8, 11, 19] (combined with sys- tematic search [17] or residue reduction [26]), integer linear programming [1, 14], branch-and-bound [4, 24] and tree decomposition [27]. While most of these ap- proaches work well for homology modeling, they reach their limits when applied to protein design. In this paper, we propose a novel exact method for SCP that works well even for large instance sizes as they appear in protein design. After presenting the combi- natorial problem formally in Section 2, we describe our new method in Section 3. Our main contribution is a dedicated branch-and-bound algorithm that combines tight upper and lower bounds resulting from a novel Lagrangian relaxation approach for SCP. In Section 4 we present and discuss our experimental results, in which we show that our method outperforms alternative state-of-the-art exact approaches and makes it possible to optimally solve large protein design instances routinely. 2 Combinatorial Problem Formulation and Notation We study the following graph-theoretic formulation of the side-chain placement problem: Problem 1 (SCP). Given a k -partite graph G = (V, E ), V = V1∪...∪Vk , with node costs cv , v ∈ V , and edge costs cu v , u v ∈ E , determine an assignment a :{1,...,k}→ V with a (i )∈ Vi , 1≤ i ≤ k , such that the cost k(cid:88) k−1(cid:88) k(cid:88) ca (i ) + ca (i )a (j ) i =1 i =1 j =i +1 2 of the induced graph is minimum. Here, each node set Vi corresponds to the candidate rotamers for the residue set at position i . Node costs model self energies of rotamers and edge costs model interaction energies between pairs of rotamers. A solution is given by selecting for each residue position i , 1 ≤ i ≤ k , exactly one rotamer a (i ). Clearly, the choice of In the description of our algorithm we will also use a function r : V → {1,...,k} that denotes the residue position of a rotamer v , that is, r (v ) = i if and only if v ∈ Vi . the rotamer determines also the amino acid at this position. 3 Lagrangian Relaxation Based Branch-and-Bound We now present our novel approach to solve the SCP problem to provable optimal- ity. Its core is the computation of sharp upper and lower bounds using a novel La- grangian relaxation technique within a dedicated branch-and-bound approach. 3.1 Upper and Lower Bounds by Lagrangian Relaxation Our relaxation builds on an integer linear programming (ILP) formulation for SCP that has been introduced by Althaus et al. [1] and extended by Kingsford et al. [14]: cu v yu v min s.t. u v∈E(cid:48) cv xv + (cid:88) v∈V v∈Vi xv = 1 (cid:88) (cid:88) (cid:88) (cid:88) u∈Vi xv ∈{0,1} cu v <0 yu v ∈{0,1} u∈Vi yu v = xv yu v ≤ xv 1≤ i ≤ k 1≤ i ≤ k , for all v ∈ Vj with j ∈(cid:78) + 1≤ i ≤ k , for all v ∈ Vj with j /∈(cid:78) + for all v ∈ V for all u v ∈ E (cid:48) i i (1) (2) (3) (4) (5) (6) The formulation contains binary variables xv , for nodes v ∈ V , and yu v , for edges u v ∈ E , with the interpretation that a variable is 1 if the corresponding node or edge is part of the induced subgraph and 0 otherwise. Constraints (2) express that exactly one rotamer must be chosen per residue position. Constraints (3) and (4) link node and edge variables. When a rotamer v of a residue position j is chosen, i.e., xv = 1, exactly one incident edge from each other residue position i (cid:54)= j must residue position j , i.e., j ∈ (cid:78) + := {(cid:96) ∈ {1,...,k} ∃u v ∈ E ,cu v > 0,u ∈ Vi ,v ∈ V(cid:96)}. If the two residue positions i and j are linked only by non-positive edges, i.e., j /∈(cid:78) + be chosen as well for residue positions i that share positively weighted edges with , the relaxed constraints (4) apply: zero-weighted edges do not have to be forced to be in the solution and the corresponding variables can be removed from the ILP. Let i i E(cid:48) := E \{u v ∈ E u ∈ Vi ,v ∈ Vj , j /∈(cid:78) + ,cu v = 0} be the set of remaining edges. i 3 i j /∈(cid:78) + The distinction between pairs of residues i , j with j ∈ (cid:78) + i and pairs i , j with in constraints (3) and (4) leads to a considerably smaller number of variables in practice and to a much better performance. Nevertheless, it is not crucial for the understanding of our approach and we thus drop this distinction in the remainder of this work and treat all pairs of residues as in constraint (3) for the sake of clarity of the presentation, that is, without removing any variables. In our implementation, however, we treat constraints (3) and (4) differently. While previous work [1, 14] focuses on solving the linear programming (LP) re- laxation of (1)–(6), we propose a Lagrangian relaxation approach. In the case of SCP this leads to a much more efficient algorithm, because we exploit structural knowl- edge of the SCP problem. The idea of Lagrangian relaxation is to relax constraints of an intractable problem, e.g., the SCP ILP, such that the relaxed problem can be solved efficiently. The relaxed constraints are moved to the objective function, penalized by so-called Lagrangian multipliers. An optimal solution of the original problem, i.e., an energy-minimum choice of candidate rotamers, is also a solution of the re- laxed problem, and every optimal solution of the relaxed problem provides a lower bound on the optimal score of the original problem. The Lagrangian multipliers are adjusted iteratively such that the lower bound increases gradually. Also, after each iteration, we can evaluate the solution of the relaxed problem and thus obtain a new upper bound to the SCP problem. During the iterative process, the lowest upper and highest lower bound move closer and closer together. If they coincide, a provably optimal SCP has been found. Otherwise, we stop the process after a fixed number of iterations and use the bounds within the branch-and-bound framework. The key idea of our Lagrangian relaxation approach is to define a total order, de- noted by <, on the residue positions, to split the constraints that link node and edge variables into a left and a right part and then relax the right part of the constraints. W.l.o.g. and for ease of notation we assume that the residue positions have already been ordered, that is, residue position i denotes the i th residue position according to <. First, we rewrite constraints (3) as left and right parts, that is, (3) becomes yu v = xv yu v = xv 1≤ i ≤ k − 1, for all v ∈ Vj with j > i 2≤ i ≤ k , for all v ∈ Vj with j < i (7) (8) (cid:88) (cid:88) u∈Vi u∈Vi We dualize constraints (8) for all non-neighboring residues, i.e., constraints for which i > j + 1, with Lagrangian multipliers λi v . To simplify notation, we further intro- v := 0 for neighboring residues, i.e., for which r (v ) + 1 = i holds. For fixed duce λi Lagrangian multipliers λi v we obtain the following relaxation, which we denote by 4 (LRλ): min s.t. cv + (cid:88) i >j +1 j =1 (cid:88) v∈Vj xv = 1 k(cid:88) (cid:88) (cid:88) (cid:88) yu v = xv u∈Vi xv ,yu v ∈{0,1} yu v = xv u∈Vi v∈Vi λi v u u v∈E r (u )<r (v ) xv + (cid:88) cu v − λr (v ) yu v 1≤ i ≤ k 1≤ i ≤ k − 1, for all v ∈ Vj with j > i 2≤ i ≤ k for all v ∈ Vi−1 (9) (10) (11) (12) (13) Note that a distinction between pairs of residues according to constraints (3) and (4) requires the Lagrangian multipliers λi v associated with constraints (4) to be restricted in sign in order to guarantee that an optimal solution to (LRλ) yields a lower bound on the optimal score of the SCP problem. An integral variable assignment that satisfies constraints (10), (12), and con- straints (11) for neighboring residues, i.e., for j = i + 1, encodes a path p in the corresponding k -partite graph from a node in V1 to a node in Vk that traverses ex- clusively edges between neighboring residues. The remaining constraints of (11) involve y -variables that do not appear in any other constraint and can thus be cho- sen independently of each other. In other words, we can determine the best possible contribution of a vertex v to the overall objective value, under the assumption that v lies on path p , by simply picking for every residue i < r (v )− 1 the edge of minimum weight between v and a node in Vi . More formally, we define the profit δ of a node v as δ(v ) = (cv + (cid:88) ) + λi v i >r (v )+1 r (v )−2(cid:88) i =1 (cu v − λr (v ) u ) , u∈Vi min where the first term in brackets denotes the coefficient of variable xv in the objective function. Then the score of a feasible solution to (LRλ) that induces a path p = (v1,v2,...,vk ) with vi ∈ Vi in graph G is k(cid:88) k−1(cid:88) δ(vi ) + cvi vi +1 . i =1 i =1 Let graph G(cid:48) be derived from G by removing all edges between non-neighboring residues, i.e., edges u(cid:48)v(cid:48) with r (u(cid:48))− r (v(cid:48)) > 1, and by defining the weights of the remaining edges u v as cu v + δ(v ). Then, an optimal solution to (LRλ) corresponds to a shortest path in G(cid:48) from a node in V1 to a node in Vk , see Figure 1. Theorem 1. An optimal solution to (LRλ) can be computed in time(cid:79) (V2). Proof. The profits of all nodes can clearly be computed in time (cid:79) (V2). Graph G(cid:48) is acyclic and thus a shortest path can be computed in time linear in the number of 5 edges in G(cid:48), i.e., (cid:79) ((cid:80)k−1 i =1 Vi·Vi +1). Note that a topological sorting of the vertices is Figure 1: The structure of a feasible solution to (LRλ). The polygon drawn in solid line denotes the corresponding path p = (v1,v2,v3,v4). Every node on path p has exactly one incident edge to every residue left of it, except to its direct neighbor, depicted by the dashed lines. implicitly given by the k -partition. We apply a standard subgradient optimization technique [12] to find those La- grangian multipliers λi v that yield the largest lower bound to our relaxation. This iterative adaption of the Lagrangian multipliers only requires the profits of a small fraction of the vertices to be recomputed from scratch in each iteration. In practice, the shortest path computation for given profits by a simple dynamic programming scheme dominates the overall running time needed to resolve the Lagrangian relax- ation (LRλ) for modified multipliers λi v . In other words, the running time will be linear in the number of edges in G(cid:48) rather than G . In order to improve the practical performance of our approach we sort the residues by increasing number of rotamers. This ordering results in a minimum total number of dualized constraints. 3.2 Branch-and-Bound We embed our Lagrangian bounding scheme into a branch-and-bound framework to obtain an energy-minimum rotamer assignment. The general idea is to divide the overall SCP problem into easier subproblems by fixing rotamers at individual residue positions and to solve the resulting problems recursively. To avoid a com- plete enumeration of all possible rotamer assignments, we employ our Lagrangian bounds to prune large parts of the enumeration tree. In particular, let Sk be a sub- problem in which certain residue positions have been assigned a rotamer, and let x be an arbitrary solution to the original SCP problem. If the lower bound z k on the minimal energy assignment for subproblem Sk is larger than z (x), i.e., the total energy of rotamer assignment x , then no optimal solution to the original problem can be obtained from Sk and we can prune the subtree rooted at Sk from the search space. Branching scheme. Starting from an SCP problem instance S, a straightforward branching rule is to impose the constraint xi j = 1 in the left child node of the search tree, and xi j = 0 in the right, i.e., fixing and forbidding a rotamer j at residue position i , respectively. However, since every rotamer j is contained in a constraint (2) for a 6 v1v2v3v4 residue position i , this leads to an unbalanced search tree, because the right child node leaves k − 1 possible rotamers for residue position i , whereas the left child leaves only one possibility. While partitioning the set of rotamers of a given residue position into two roughly equally sized sets avoids this imbalance, we experienced, however, a significantly smaller number of nodes in the tree with the following, al- ternative branching scheme. Instead of creating two subproblems, we create one for each rotamer of a selected residue position i , by fixing rotamer jk in subproblem k . Only for very large design instances, we first partitioned the sets of possible rotamers that were larger than some threshold p , into two smaller sets. The effectiveness of this scheme is mainly based on two properties. First, when fixing a rotamer j for a energy between rotamer j and any other rotamer j (cid:48) of all residue positions i(cid:48) (cid:54)= i residue position i , we reduce the problem instance by incorporating the interaction into the self energy of j (cid:48). In contrast, in our relaxation only the profits δ of rotamers of residue positions i(cid:48) > i would take into account a further subdivision of the set of rotamers of residue position i . The rotamer assignment to residue positions i(cid:48) < i would still rely on a correct choice of the incoming edges for the remaining rotamers of residue position i , which could only be accomplished by iteratively adapting the Lagrangian penalties. Second, a large enough set of child nodes will give our depth- first search traversal of the branch-and-bound tree the freedom to pick a promising node first. Choosing a constraint. The question remains which position constraint (2) to choose for a branching step. We adopt the idea of strong branching [2]. The rough idea is to estimate the progress, i.e., increase in lower bound, for the residue positions before actually branching on one of them. This is done by successively fixing each rotamer of a given residue position and solving the resulting Lagrangian subproblem. Based on the progress of the single rotamers, we compute an overall score of the residue position, see below, and pick the one with the highest score as the next residue po- sition to branch on. Since the computation time per node of this procedure would be enormous, we try to estimate the locally best residue position by simplifying this search in three different aspects. • First, we restrict the evaluation to the most promising residue positions. More precisely, we order the residue positions in increasing order of their maxi- mum (primal) fractional value of its rotamers. We recover the primal solu- tions by taking the convex combinations of the last k solutions x t produced in the course of the subgradient optimization. Then, at a node of depth l of the branch-and-bound tree, we consider the first γ(l ) percent of the sorted residue positions. Note that the concept of a residue position with minimal maximal fractional value of its rotamer variables can be considered as a gen- eralization of the most infeasible branching rule for binary variables, to con- straints of the form (2). • Second, to estimate the increase of the objective function when fixing a ro- tamer, only a few subgradient iterations are performed, along with an aggres- sive multiplier adjustment. 7 that they can be computed quickly while still giving a good estimate on the • Finally, we choose our scoring function of the residue positions in such a way, overall progress in the dual (lower) bound. Let (cid:81) be the subproblem corre- sponding to the current node of the tree and let problem(cid:81) j (cid:81) by fixing rotamer j in residue ri . Then the score of a residue position ri is i be obtained from given by ξ(ri ) = min j∈ri ∆j i , = z ((cid:81) j i )−z ((cid:81)). To determine the score of a given residue position i , where ∆j i we test the rotamers in decreasing order of their fractional values. The goal is to evaluate rotamers j with small progress ∆j i first, since the subgradient opti- mization for the remaining rotamers can be aborted as soon as their increase in objective function exceeds the smallest progress seen so far. Also notice that sorting the residue positions as described above is beneficial for the computa- tion of the residue scores. Whenever we encounter a rotamer with a progress ∆j position i(cid:48) (cid:54)= i , we do not have to consider the remaining rotamers of i(cid:48), since i that is smaller than the smallest progress determined for a previous residue we are interested in the residue position with maximal score. Choosing a node. A primal feasible solution that gives a good upper bound on the minimum total energy is necessary to prune the enumeration tree significantly. Therefore we follow a depth-first search (DFS) strategy to descend in the branch- and-bound tree as quickly as possible, increasing the chances of finding a new and hopefully better feasible solution. Furthermore, the Lagrangian subproblems cor- responding to a node and to one of its immediate descendants differ only in one residue position. Therefore, a subproblem can be resolved faster when starting from the multiplier vector λ determined in the immediate parent node. On the downside, once being in a wrong branch, one may spend a long time in this subtree before get- ting back on a path leading to an improved solution. We thus combine the advan- tages of DFS and a best-node first strategy. We fix the rotamers of a given residue position in increasing order of their dual (lower) bounds. Following this approach led to a considerably smaller number of nodes evaluated in the tree, and we were able to find the optimal solution much faster in most of the cases. 4 Experimental Results We have implemented our combinatorial algorithm for finding an optimal solution to the Lagrangian relaxation (LRλ) in C++ using the LEDA and BALL libraries [18, 13]. We iteratively improve the obtained lower bounds on the optimal solution of the SCP problem by applying a standard subgradient approach. In each iteration, we derive from the Lagrangian solution a feasible solution to the original problem and thus an upper bound on the optimal score by evaluating the subgraph induced by the nodes lying on the shortest path from V1 to Vk , see Section 3.1. We exploit the upper and lower bounds in a branch-and-bound manner to prune large parts of the search space and to derive a provably optimal solution to the SCP problem. 8 In order to determine an initial upper bound for the branch-and-bound frame- work, we employ a simple local search procedure: Given an initial configuration in which each residue position is assigned the rotamer with the lowest self energy, residue positions are selected randomly and optimized, i.e., the respective position is assigned the rotamer yielding the best energy within the current conformation. This minimization proceeds until the energy could not be improved several times in a row or a maximum of 100 iterations is reached. The only state-of-the-art exact method for SCP that can cope with protein design instances is the ILP based method proposed by Kingsford et al. [14]. Available soft- ware packages for DEE or treewidth based approaches such as R3 [26] or TreePack [27] do not allow several candidate amino acids at each position and are thus not ap- plicable to protein design instances. Furthermore, our experiments show that even small protein design instances already have treewidths of 10 to 20 as compared to 3 to 4 for most homology modeling instances [27]. Since the complexity of the TreeP- ack algorithm grows exponentially in the treewidth, a reasonable performance on protein design instances is not to be expected. For DEE-based methods, a similar ar- gument holds because reduced protein design instances are still too large to be pro- cessed in reasonable time by residue unification or other enumeration techniques. We therefore compare our Lagrangian based approach only to an implementation that solves the ILP proposed by Kingsford et al. [14] using CPLEX 12.21 with Concert Technology. In our experiments, we used two different benchmark sets. The first set con- sists of protein design energy files provided by Kingsford et al. [14]. It comprises 25 proteins with 11 to 124 flexible residue positions. Surface residues are fixed. At each core position up to six different amino acids are allowed. The employed energy function comprises statistical potentials and van der Waals interactions. We omit the experimental results on the simpler homology modeling instances, since almost all of these instances can be solved in a fraction of a second by both our Lagrangian relaxation approach and the CPLEX based method. The second set of protein de- sign instances was taken from Yanover et al. [28]. This set comprises 97 proteins with 40 to 180 amino acids. All residue positions are flexible and at each position all 20 amino acids are allowed yielding very large problem instances. Here, the more realistic Rosetta energy function [16] was used to determine self and interaction en- ergies. In a preprocessing phase, we apply established rules [11, 26] to decrease the size of the problem instances while preserving optimality properties. Tables 1 and 2 show the running times of our Lagrangian relaxation branch-and-bound approach and the CPLEX based method using default settings on the resulting instances on a compute cluster with two 2.26 GHz Intel Quad Core processors with 24 GB of RAM on each node, running 64 bit Linux. We applied a time limit of 12 hours and a mem- ory limit of 16 GB. Computations exceeding one of these limits were aborted. The first three columns of the table give the characteristics of the instances, i.e., their PDB identifier, the number of residues and the total number of rotamers. The following two columns give characteristics of the branch-and-bound proce- 1http://www.cplex.com 9 Name 1aac 1aho 1b9o 1c5e 1c9o 1cc7 1cex 1cku 1ctj 1cz9 1czp 1d4t 1igd 1mfm 1plc 1qj4 1qq4 1qtn 1qu9 1rcf 1vfy 2pth 3lzt 5p21 7rsa Instance #res 105 64 123 95 66 72 197 85 89 139 98 104 61 153 99 256 198 152 126 169 67 193 129 166 124 #rot 1523 981 2056 1108 1130 1396 2556 1093 1021 2332 1170 1636 926 2134 1156 4080 2045 2516 1817 2396 939 3077 2074 2874 1958 Lagrangian B&B N 2 1 3 1 2 1 9 1 1 1 1 1 1 25 2 313 16 1 2 2 1 66 7 52 1 H 1 0 1 0 1 0 2 0 0 0 0 0 0 5 1 10 4 0 1 1 0 6 2 4 0 time/s 1.73 0.01 2.09 0.12 0.33 0.28 13.37 0.03 0.07 3.7 0.54 0.37 0.01 21.89 1.50 8,424.56 32.56 1.50 0.31 4.76 0.01 322.28 3.20 106.09 0.78 CPLEX time/s 3.40 0.02 2.56 0.25 1.96 0.59 33.25 0.09 0.27 18.10 4.32 2.36 0.02 145.63 6.08 31,636.40 38.89 3.22 0.66 12.85 0.01 518.51 10.64 115.01 3.31 S 2.0 2.0 1.2 2.1 5.9 2.1 2.5 3.0 3.9 4.9 8.0 6.4 2.0 6.7 4.1 3.8 1.2 2.1 2.1 2.7 1.0 1.6 3.3 1.1 4.2 Table 1: Running times of our Lagrangian relaxation branch-and-bound approach and the CPLEX based method on the design instances from [14]. We further give the number of residues (#res) and the total number of rotamers (#rot) of the instance, the number of nodes (N) and height (H) of the branch-and-bound tree as well as the speedup S (ratio of running times). dure: Columns N and H give the total number of evaluated nodes and the height of the branch-and-bound tree, respectively. The remaining columns give the running times in seconds of our Lagrangian based approach and the CPLEX based method as well as the ratio of running times S. Note that we include the time spent in the local search heuristic for the Lagrangian branch-and-bound approach. On the first dataset, our Lagrangian based approach outperforms the state-of- the-art CPLEX based method on all 25 instances. The small number of nodes eval- uated in the course of the branch-and-bound procedure indicates sharp lower and upper bounds derived from the Lagrangian solutions. On the more challenging sec- ond dataset, our method could solve 52 of the 97 instances within 12 h, whereas the CPLEX based method could only finish 12 instances within the time and memory limits. 10 Name 1brf 1bx7 1d3b 1en2 1ezg 1g6x 1gcq 1i07 1kth 1rb9 1sem 1vfy 4rxn 1a8o 1b67 1bbz 1bf4 1c75 1cc8 1d3b 1fr3 1gut 1hg7 1i27 1igd 1igq 1iqz 1j75 1jo8 1kq1 1l9l 1ldd 1ljo 1mhn 1nkd 1oai 1plc 1pwt 1r69 1wap 2igd 1c4q 1c9o 1ctj 1dj7 1e0b 1erv 1fk5 1g2b 1mgq 1vie Instance #res 44 25 66 59 58 51 65 52 49 43 54 58 45 62 66 52 60 63 69 66 61 62 65 69 60 53 75 55 54 58 69 71 69 53 56 56 92 58 60 65 59 65 60 84 69 58 101 81 59 71 56 #rot 3524 1048 5732 2689 1653 3190 5442 3186 3330 3307 4348 3951 3636 4510 5543 3935 5289 4323 6515 5732 5100 4945 5047 5934 5207 4582 5412 4861 4680 5244 5518 6383 6428 4454 4148 4330 7955 4876 4926 5551 5262 5598 5305 6232 5571 4715 9150 5714 4926 6250 4803 Lagrangian B&B N 9 1 1 1 2 1 4 4 18 7 192 16 1 6 27 7 12 25 26 1 22 22 5 39 18 18 15 14 41 7 4 8 14 3 9 73 34 2 49 14 13 843 97 265 22 147 76 28 129 4 3 H 4 0 0 0 1 0 2 1 4 2 8 2 0 2 4 2 3 2 2 0 4 2 2 6 4 5 2 4 4 1 2 1 3 2 4 3 4 1 2 3 3 10 8 10 4 6 8 5 8 1 11 1 time/s 293.97 0.54 530.37 19.41 185.11 23.96 903.82 187.45 798.57 127.93 5,020.55 2,540.86 220.33 1,418.71 3,822.09 1,329.26 1,875.32 7,175.69 16,508.10 530.37 6,997.76 7,745.17 987.51 4,070.20 3,163.14 4,294.16 2,137.58 5,704.83 1,830.23 3,990.65 1,514.50 4,582.84 5,624.10 570.15 1,119.56 20,021.10 24,308.50 886.94 27,862.50 5,267.68 6,332.26 30,789 11,627.20 7,083.65 12,581.90 30,840.10 31,539.70 14,625.30 6,880.45 2,613.06 866.54 CPLEX time/s 469.87 5.77 9,577.68 39.94 441.23 160.64 5,270.08 166.20 642.42 9,535.72 6,470.37 † 3,034.57 † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † † S 1.6 10.7 18.1 2.1 2.4 6.7 9.8 0.9 0.8 74.5 1.3 n/a 13.8 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Table 2: Running times of our Lagrangian relaxation branch-and-bound approach and the CPLEX based method on the design instances from [28]. Instances which cannot be solved by both approaches within a time limit of 12 hours are omitted. The † sign indicates that a computation exceeded either the time limit (12 h) or the memory limit (16 GB). 5 Conclusions and Outlook We have constructed a Lagrangian relaxation of the Kingsford ILP formulation of the SCP problem that allowed us to obtain strong bounds by solving a modified shortest path problem on the underlying k -partite graph. By utilizing these bounds within a branch-and-bound framework we achieved running times that outperform a state-of-the-art exact method that uses the professional mathematical program- ming solver CPLEX. Our implementation of the Lagrangian branch-and-bound ap- proach as well as the data sets used in this paper are freely available as the package SCP of the planet lisa software library [15]. Future work on exact side-chain placement should explore possible connections to the recently introduced method by Sontag et al. [22], which is based on belief propagation. This heuristic algorithm is currently the best non-exact method and finds optimal solutions astonishingly often. In our opinion, underlying ideas from the area of belief propagation may be useful also in a truly exact method. The mathematical model of the SCP problem as studied in this work appears in a wide range of applications including image understanding, error correcting codes, and frequency assignment in telecommunications. We believe that our approach can be applied successfully in these areas, too. Acknowledgements. Much of the work has been carried out while NCT visited CWI on a CWI internship. The authors thank Inken Wohlers and Oliver Kohlbacher for useful discussions. Computational experiments were sponsored by the NCF for the use of supercomputer facilities, with financial support from NWO. References [1] E. Althaus, O. Kohlbacher, H.-P. Lenhof, and P. Müller. A combinatorial ap- proach to protein docking with flexible side chains. J Comput Biol, 9(4):597– 612, 2002. [2] D. Applegate, R. Bixby, V. Chvátal, and W. Cook. Finding cuts in the TSP. Tech- nical Report 95-05, DIMACS, 1995. [3] J. D. Bloom, M. M. Meyer, P. Meinhold, C. R. Otey, D. MacMillan, and F. H. Arnold. Evolving strategies for enzyme engineering. Curr Opin Struct Biol, 15(4):447–452, 2005. [4] A. A. Canutescu, A. A. Shelenkov, and R. L. Dunbrack. A graph-theory algorithm for rapid protein side-chain prediction. Protein Sci, 12(9):2001–2014, Sep 2003. [5] B. Chazelle, C. Kingsford, and M. Singh. A semidefinite programming approach to side chain positioning with new rounding strategies. INFORMS J. on Com- puting, 16(4):380–392, 2004. 12 [6] G. Dantas, C. Corrent, S. Reichow, J. Havranek, Z. Eletr, N. Isern, B. Kuhlman, G. Varani, E. Merritt, and D. Baker. High-resolution structural and thermo- dynamic analysis of extreme stabilization of human procarboxypeptidase by computational protein design. Journal of Molecular Biology, 366(4):1209–1221, 2007. [7] G. Dantas, B. Kuhlman, D. Callender, M. Wong, and D. Baker. A large scale test of computational protein design: folding and stability of nine completely redesigned globular proteins. J Mol Biol, 332(2):449–460, 2003. [8] J. Desmet, M. D. Maeyer, B. Hazes, and I. Lasters. The dead-end elimination theorem and its use in protein side-chain positioning. Nature, 356(6369):539– 542, 1992. [9] J. Desmet, J. Spriet, and I. Lasters. Fast and accurate side-chain topology and energy refinement (FASTER) as a new method for protein structure optimiza- tion. Proteins, 48(1):31–43, 2002. [10] R. L. Dunbrack. Rotamer libraries in the 21st century. Curr Opin Struct Biol, 12(4):431–440, 2002. [11] R. F. Goldstein. Efficient rotamer elimination applied to protein side-chains and related spin glasses. Biophys J, 66(5):1335–1340, 1994. [12] M. Held and R. Karp. The traveling salesman problem and minimum spanning trees: part II. Mathematical Programming, 1:6–25, 1971. [13] A. Hildebrandt, A. K. Dehof, A. Rurainski, A. Bertsch, M. Schumann, N. C. Toussaint, A. Moll, D. Stöckel, S. Nickels, S. C. Mueller, H.-P. Lenhof, and O. Kohlbacher. BALL – biochemical algorithms library 1.3. BMC Bioinformatics, 11:531, 2010. [14] C. L. Kingsford, B. Chazelle, and M. Singh. Solving and analyzing side-chain positioning problems using linear and integer programming. Bioinformatics, 21(7):1028–1036, 2005. [15] G. W. Klau et al. planet lisa software library. http://planet-lisa.net. [16] B. Kuhlman and D. Baker. Native protein sequences are close to optimal for their structures. Proc Natl Acad Sci U S A, 97(19):10383–10388, 2000. [17] A. R. Leach and A. P. Lemon. Exploring the conformational space of protein side chains using dead-end elimination and the A* algorithm. Proteins, 33(2):227– 239, 1998. [18] K. Mehlhorn and S. Näher. The LEDA Platform of Combinatorial and Geometric Computing. Cambridge University Press, Cambridge, 1999. [19] N. A. Pierce, J. A. Spriet, J. Desmet, and S. L. Mayo. Conformational splitting: A more powerful criterion for dead-end elimination. Journal of Computational Chemistry, 21:999–1009, 2000. 13 [20] N. A. Pierce and E. Winfree. Protein design is NP-hard. Protein Eng, 15(10):779– 782, 2002. [21] P. S. Shah, G. K. Hom, S. A. Ross, J. K. Lassila, K. A. Crowhurst, and S. L. Mayo. Full-sequence computational design and solution structure of a thermostable protein variant. J Mol Biol, 372(1):1–6, 2007. [22] D. Sontag, T. Meltzer, A. Globerson, T. Jaakkola, and Y. Weiss. Tightening LP relaxations for MAP using message passing. In D. McAllester and P. Myllymak, editors, Conference on Uncertainty in Artificial Intelligence. AUAI Press, Corval- lis, Oregon, 2008. [23] C. Voigt, D. Gordon, and S. Mayo. Trading accuracy for speed: a quantitative comparison of search algorithms in protein sequence design. Journal of Molec- ular Biology, 299(3):789–803, 2000. [24] L. Wernisch, S. Hery, and S. Wodak. Automatic protein design with all atom force-fields by exact and heuristic optimization. Journal of Molecular Biology, 301(3):713–736, 2000. [25] Z. Xiang and B. Honig. Extending the accuracy limits of prediction for side- chain conformations. J Mol Biol, 311(2):421–430, 2001. [26] W. Xie and N. V. Sahinidis. Residue-rotamer-reduction algorithm for the protein side-chain conformation problem. Bioinformatics, 22(2):188–194, 2006. [27] J. Xu and B. Berger. Fast and accurate algorithms for protein side-chain pack- ing. J. ACM, 53(4):533–557, 2006. [28] C. Yanover, T. Meltzer, and Y. Weiss. Linear programming relaxations and belief propagation-an empirical study. J Mach Learn Res, 7:1887–1907, 2006. 14
1901.00718
1
1901
2019-01-03T13:58:15
Mergeable Dictionaries With Shifts
[ "cs.DS" ]
We revisit the mergeable dictionaries with shift problem, where the goal is to maintain a family of sets subject to search, split, merge, make-set, and shift operations. The search, split, and make-set operations are the usual well-known textbook operations. The merge operation merges two sets and the shift operation adds or subtracts an integer from all elements in a set. Note that unlike the join operation on standard balanced search tree structures, such as AVL trees or 2-4 trees, the merge operation has no restriction on the key space of the input sets and supports merging arbitrarily interleaved sets. This problem is a key component in searching Lempel-Ziv compressed texts, in the mergeable trees problem, and in the union-split-find problem. We present the first solution achieving O(log U) amortized time for all operations, where {1, 2, ..., U} is the universe of the sets. This bound is optimal when the size of the universe is polynomially bounded by the sum of the sizes of the sets. Our solution is simple and based on a novel extension of biased search trees.
cs.DS
cs
Mergeable Dictionaries With Shifts Philip Bille Mikko Berggren Ettienne Inge Li Gørtz January 4, 2019 Abstract We revisit the mergeable dictionaries with shift problem, where the goal is to maintain a family of sets subject to search, split, merge, make-set, and shift operations. The search, split, and make-set operations are the usual well-known textbook operations. The merge operation merges two sets and the shift operation adds or subtracts an integer from all elements in a set. Note that unlike the join operation on standard balanced search tree structures, such as AVL trees or 2-4 trees, the merge operation has no restriction on the key space of the input sets and supports merging arbitrarily interleaved sets. This problem is a key component in searching Lempel-Ziv compressed texts, in the mergeable trees problem, and in the union-split-find problem. We present the first solution achieving O(log U) amortized time for all operations, where {1, 2, . . . , U } is the universe of the sets. This bound is optimal when the size of the universe is polynomially bounded by the sum of the sizes of the sets. Our solution is simple and based on a novel extension of biased search trees. 1 Introduction We consider the mergeable dictionary with shifts problem. A mergeable dictionary with shifts maintains a dynamic collection of sets G = {G1, G2, . . . , Gm} from a totally ordered universe {1, 2, . . . , U } subject to the following operations (the sets G1, . . . , Gm need not be disjoint): • Search(G, j): Return the largest element from G that is at most j if any such element exists. • Split(G, j): Split G into two sets A = {x ∈ S x ≤ j} and B = {x ∈ S x > j}, remove G from G and insert A and B. • Merge(A, B): Remove A and B from G and insert C = A ∪ B instead. • MakeSet(j): Insert a new singleton set G = {j} in G. • Shift(G, j): Shift all elements in G by j, i.e., G = {g + j g ∈ G}. This problem is a key component in searching Lempel-Ziv compressed text [2], the mergeable trees problem [3], and generalizations of the union-find-split problem [6]. Standard binary search trees, e.g., AVL-trees or 2-4 trees, support Search and Split in logarithmic time, while Shift and MakeSet take constant time. Most standard binary search trees can also be extended to support the Join operation that takes two sets where all the elements in one set are larger than the other and merge them into a single set. The Merge operation has no such restriction on the input sets and supports merging arbitrarily interleaved sets. It is easy to show that sublinear worst-case bounds for Merge are not possible. The Shift 1 operation is also straightforward to implement on most binary search trees but non-trivial in the combination with the Merge operation. The first non-trivial bound for mergeable dictionaries with shifts was given by Farach and Thorup [2] who showed that a simple folklore merge strategy called segment merge yields an O(lg U lg n) amortized time for the operations where n is the sum of the sizes of the sets. This solution uses standard binary search trees with logarithmic time Join and Split operations and constant time Shift. Lai [6] conjectured that this bound is optimal, but this was disproven by Iacono and Ozkan [4], who showed how to support all operations except Shift in O(log U ) amortized time1. Iacono and Ozkan claim that the Shift operation can also be supported by their data structure within the same complexity, but give no proof. We believe that this is true, but implementing Shift operation efficiently in their framework is non-trivial, in part because their solution requires sets to be disjoint. Furthermore, the implementation and analysis of their solution is quite involved and require 25+ pages in the full technical report. More recently, Karczmarz [5] gave a very simple solution without the Shift that achieves O(log U ) amortized time. This solution is based on binary trie representations of sets combined with word-level parallelism. As the author mentions, this approach does not extend to easily support the Shift operation. It does however handle infinite/dynamic universes. Obtaining amortized logarithmic time complexity for the mergeable dictionary problem while supporting both infinite universes and the Shift operation is still an open problem. 1.1 Our Results We show the following main result. Theorem 1. There exist a mergeable dictionary with shifts data structure supporting all oper- ations in O(lg U ) amortized time. For a set G, let UG = max(G) − min(G). The Search and Split operations take O(lg UG) worst-case and amortized time, and the MakeSet and Shift operations take O(1) worst-case and amortized time. The amortized time of the Merge operation is O(lg UG), where G is the set output by the operation. We note that the complexity of our mergeable dictionary operations only depends on the "local universe" of the sets involved in the operation. This implies that the O(log UG) bounds holds even if the upper bound U of the universe changes. This is the first solution to the mergeable dictionary with shift problem using O(log U ) amortized time (with an implementation and analysis of the Shift operation). For universes bounded in size by a polynomial in the sum of the sizes of the input, the bound is optimal [4]. Thm. 1 improves the result by Farach and Thorup [2] by a logarithmic factor. We match the bound of Iacono and Ozkan [4] and Karczmarz [5] but add support for the Shift operation. To obtain Thm. 1 we design a modified version of the segment merge strategy carefully designed to work with biased search trees. This leads to a surprisingly simple analysis relative to previous work. In particular we avoid complicated finger operations and analysis. 1.2 Outline In Section 2 we explain the folklore merge strategy in combination with binary search trees described in Farach and Thorup [2] and review the proof from Farach and Thorup [2] that yields an amortized O(lg n lg U ) solution to the mergeable dictionary problem. Section 3 revisits the biased search tree by Ben et al. [1] and Section 4 give the details our weighting scheme. 1The bound is stated as O(log n) in the paper since they assume U = n. 2 We then move on to describe and analyze our biased segment merge operation in Section 5. In Section 6 we describe how to support shifts and analyze the amortized complexity of the remaining operations. Finally, we show how to handle intersecting sets in Section 7. 2 Segment Merge In this section we explain the segment merge algorithm described in Farach and Thorup [2], which our biased segment merge is based on. The merge operation merges two arbitrarily interleaved ordered sets A and B. Assume that A ∩ B = ∅ (we show how to lift this assumption later). We first consider the case where min(A) < min(B) and max(A) < max(B). The segment merge algorithm merges the ordered sets A and B by partitioning the two sets into a minimal number of segments {A1, . . . , Ak} and {B1, . . . , Bk} such that Ai ⊆ A and Bi ⊆ B and max(Ai) < min(Bi) and max(Bi) < min(Ai+1) which are then subsequently joined together. Given a set data structure that supports Split and Join the merge operation is then performed as follows: Initially set C = ∅. For i = 1, . . . , k do: • Set Ai, A ← Split(A, min(B)) • Set Bi, B ← Split(B, min(A)) • Set Ci ← Join(Ai, Bi) • Set C ← Join(C, Ci) After this process it is clear that C is the ordered set A ∪ B. Using standard search trees the Split and Join operations can be implemented in O(lg n) worst-case time where n = PG∈G G. Thus the total time for a segment merge is O(k lg n) which in the worst case is O(n lg n). However, the amortized complexity of segment merge with standard binary trees is O(lg U lg n) as shown by Farach and Thorup [2]. As a warm-up we revisit their analysis, since we will reuse some of their definitions in our analysis. Let x− and x+ denote the predecessor and successor of x ∈ G and define the size of the left gap of x to be g−(x) = 1 if x = min(G) and g−(x) = x − x− otherwise. Similarly, define the size of the right gap of x as g+(x) = 1 if x = max(G) and g+(x) = x+ − x otherwise. Define the potential of a set G as and define the potential of the mergeable dictionary with shifts as (lg g+(x) + lg g−(x)) φ(G) = Xx∈G Ψ(G) = lg nXG∈G φ(G) Clearly, the potential is always non-negative. Now consider the potential of the data struc- ture before and after a merge operation C ← Merge(A, B). It is easy to see that the only gaps that increase are the left gap of the element min(B) and the right gap of the element max(A). Clearly, the increase is bounded by max(C) − min(C) ≤ UC causing a potential increase of O(lg n lg UC). Whenever we insert a segment of a set between to elements x and y where x < y in another set, we halve either g+(x) or g−(y) causing the potential to decrease by at least lg n. It follows that the potential decreases by Ω(k lg n − lg n lg UC) when there are k segments 3 and thus the amortized cost of the merge operation is O(lg n lg UC ). None of the operations MakeSet, Split, Shift and Search increase the potential of the data structure. If min(B) < min(A) we swap the arguments to merge. If max(A) > max(B) we execute the following operations B′, B′′ ← Split(B, max(A)), C ′ ← Merge(A, B′), and finally because max(C ′) = max(A) < min(B′′) we can produce C by joining C ′ and B′′. Now the assumption is true for the merge because max(A) < max(B′) and the extra split and join operations both take O(lg n) time. This shows that standard search trees solve the mergeable dictionary problem in O(lg n lg UC) amortized time. We now move on to explain how to improve this bound to O(lg UC) using biased search trees instead of standard search trees. 3 Biased Trees In this section we revisit the biased 2,3-trees by Bent et al. [1]. A biased 2,3-tree stores a set of n keys in the leaves of a tree where all internal vertices have 2 or 3 children. If x is the ith leaf in left to right order it stores the ith key when sorted in increasing order and internal vertices store the maximal and minimal key of its leaf descendants. The weight of a vertex x is denoted wx. Every leaf is assigned a weight and the weight of an internal vertex is the sum of the weights of its leaf descendants. The weight of a tree T denoted WT is the weight of its root. The rank of a vertex x is denoted r(x), and r(x) = ⌊lg wx⌋ if x is a leaf, whereas r(x) = 1 + max{r(y) y is a child of x} if x is not a leaf. The rank of a tree T denoted r(T ) is the rank of its root. Let y be the child of x. Then y is major if r(y) = r(x) − 1 and minor if r(y) < r(x) − 1. A 2,3-tree is biased when any neighboring sibling of a minor vertex is a major leaf. A biased 2,3-tree have the following properties: Lemma 1 (Lemma 1, Bent et al. [1]). For any vertex x, 2r(x)−1 ≤ wx, and if x is a leaf then 2r(x) ≤ wx < 2r(x)+1. Lemma 2 (Lemma 2, Bent et al. [1]). Let d be the depth of leaf x in tree T then d < lg(WT /wx)+ 2. Lemma 3 (Theorem 2, Bent et al. [1]). Two biased trees T and S can be joined in amortized r(T ) − r(S) time. Algorithm 1 describes the algorithm of Bent et al. [1] that joins two trees. We describe it here because we will refer to details of this algorithm later. We refer the reader to the Bent et al. [1] for the proofs of correctness and complexity. Lemma 4 (Theorem 5, Bent et al. [1]). The amortized time to split a tree T at leaf y is r(T ) − r(y). Lemma 5 (Theorem 6, Bent et al. [1]). The amortized time to split a tree T at a key i which min(wi−,wi+) ) where i− and i+ are the respective predecessor and is not in a leaf of T is O(lg successor of i in T . WT Lemma 6 (Theorem 7, Bent et al. [1]). The amortized time to change the weight of item x in tree T is O(lg max(WT ,W ′ T ) x) ) where WT , W ′ x are the weights of the tree before and after the min(wx,w′ update and the weight of x before and after the update, respectively. T , wx, w′ The lemmas above are proven by Bent et al. [1] using the accounting method and require that the trees satisfies the following credit invariant: Every minor vertex y with parent x contains 4 Algorithm 1: Joining Biased Trees Input: Let x and y be the roots of the trees we are joining and assume without loss of generality that r(x) ≥ r(y). Create and return a new vertex with vertices x and y as its two children. 1 if r(x) = r(y), or r(x) > r(y) and x is a leaf then 2 3 else if r(x) > r(y) and x is not a leaf then 4 /* Case 1 */ /* Case 2 */ Let u be the right child of x. Remove u as a child of x and recursively join the trees with roots u and y, producing a single tree, say with root v. if r(v) ≤ r(x) − 1 then /* Subcase 2a */ Attach v as the right child of x and return x. end if r(v) = r(x) then /* Subcase 2b */ In this case v has exactly two children. Attach these as children of x (to the right to the other children of x) and destroy v. Vertex x thus gains a child. if x has at most 3 children then return x. else /* x has 4 children */ Split x into two vertices with 2 children each, make them children of a new vertex w, and return w. The two vertices resulting from the split has the same rank as x while the rank of w is one greater. end end 5 6 7 8 9 10 11 12 13 14 15 16 end r(x) − r(y) − 1 credits. Clearly, a singleton tree satisfies this invariant, and Bent et al. shows that any tree produced by combinations of the above operations also does. The c-rank of a tree T denoted c(T ) is the rank of T plus the number of credits it has in its root, i.e., c(T ) = j if the root of T has j − r(T ) credits. It follows from Lemma 3 that if two trees S and T have c-rank j > max(r(S), r(T )) then we can join them in O(1) amortized time into a tree U where c(U ) = j. 4 Data Structure Our data structure maintains every set G ∈ G as a biased 2,3-tree [1]. We employ the weighting scheme, identical to the one used by Iacono and Ozkan [4], where the weight of a leaf x ∈ G is g+(x) + g−(x). Recall, that x− and x+ denote the predecessor and successor of x ∈ G and g−(x) = 1 if x = min(G) and g−(x) = x − x− otherwise. Similarly, g+(x) = 1 if x = max(G) and g+(x) = x+ − x otherwise. 5 Biased Segment Merge In this section we describe and analyze our merging algorithm. To obtain the desired complexity we will deviate from the sequential splitting strategy of segment merge. Instead of finding the segments Ai and Ni and then joining them before finding the next segments, we will first find all the segments and then merge them. This way, we can avoid to use finger versions of the operations and this allows us to make an overall analysis of the cost of the k merges. 5 Algorithm 2: Merge Biased Trees A and B into a single tree C 1 Split A and B into segments {A1, . . . , Ak} and {B1, . . . , Bk} where Ai ⊆ A and Bi ⊆ B and max(Ai) < min(Bi) and max(Bi) < min(Ai+1) and construct a biased tree for each segment: 2 3 4 5 6 7 8 Find the set of profiles for all the segments: (Al 1 Ar 1, . . . , Al k Ar k, Bl 1 Br 1, . . . , Bl k Br k) = FindProfiles(A,B) Construct the biased segment trees: for i = 1 to k do Ai = ConstructSegmentTree(Al Bi = ConstructSegmentTree(Bl i Ar i ) i Br i ) end 9 Reweight the rightmost and leftmost leaves of Ai and Bi: 10 11 12 13 14 15 for i = 1 to k do w(Ar w(Al w(Br w(Bl i ) ← g−(Ar i) ← g+(Ar i ) ← g−(Br i) ← g+(Br i ) + a′ i i ) + a′′ i ) + b′ i i ) + b′′ i−1 i−1 end 16 Join the segments A1, B1, A2, B2, . . . to produce a single biased tree C by repeatedly joining the minimal rank tree with its minimal rank neighbor (solve ties arbitrarily). The biased segment merge algorithm has three main steps. First we split A and B into segments {A1, . . . , Ak} and {B1, . . . , Bk} where Ai ⊆ A and Bi ⊆ B and max(Ai) < min(Bi) and max(Bi) < min(Ai+1) and construct a biased tree for each segment. This is done by first finding all the leaves correcponsding to the endpoints by doing a parallel search on the trees A and B and what we call the profile of each segment (a profile of a segment consists of all the subtrees from the original tree that only contains leaves in the segment). Then the trees of each profile is joined into a biased segment tree. Finally we reweight the segment trees and join them into a single tree. The full algorithm is described in Algorithm 2. In Section 5.1 we how to find the profiles and construct the segment trees. In Section 5.2 we bound the combined amortized complexity of the biased segment merge. Note For simplicity we will assume that A ∩ B = ∅, min(A) < min(B), and max(A) < max(B). We show in Section 5.3 and 7 how to lift these assumptions. 5.1 Splitting Into Segments i and Ar Let Al Bl Ar i and Br k and Bl i be the minimal and maximal element in segment Ai, respectively. Similarly, let 1 and i be respectively the minimal and maximal element in segment Bi. Note that Al 1 and Br k are the leftmost and rightmost leaves of A and B, respectively. i Ar i and Ar i are all the maximal subtrees of A whose keys are in the range (Al Denote by x y the simple path from vertex x to vertex y in a tree T . The profile of a i ) plus the i Ar i is defined in the same way. path Al leaves Al except for the subtrees Al We abuse notation and also call the profile of a path Al i . The root of each of these subtrees is a child of a vertex on the path Al i Br i i the profile of the segment Ai. i . The profile of a path Bl i Ar i and Ar i; Ar 6 Finding profiles We find the profiles of the segments as described in Procedure FindProfiles. Note that, rather than starting every search from the root, we continue from the leaf where the previous search ended (only the first search starts in the root). Procedure FindProfiles(A,B) 1 Find the leaves Al 1 and Bl 1 by walking from the root to the leftmost leaf in A and B, respectively. 2 for i = 1 to k − 1 do 3 4 i by searching for the predecessor of Bl Find the leaf Ar walking from Al i. From Ar i+1 which is the successor of Ar i . i find the leaf Al i in A. The search is done by 5 Walking from Bl i find the key Br i by searching for the predecessor of Al i+1 in B. 6 From Br i find the key Bl i+1 which is the successor of Br i . 7 end 8 While walking in the trees A and B it is straightforward to identify the profiles of the segments: When walking up from a node v add v's right siblings to the profile. When walking down from a node v add all v's left siblings to the profile. Constructing the segment trees We join the subtrees from each profile to produce a tree for each segment as described in Procedure ConstructSegmentTree. Procedure ConstructSegmentTree(Al i Ar i ) Input: The profile of Ai: Al i Ar highest vertex on the path. i = v1, v2, . . . , vj, uk, uk−1, uk−2, . . . u1, where vj is the Output: Biased tree for the segment Ai. 1 Initially let Li be the singleton tree v1. 2 for m = 2 to j: do /* Case 1 if vm−1 has two siblings x and y in the profile of segment Ai then */ Remove x and y as children of vm and make them children of a new vertex q with rank max(r(x), r(y)) + 1. Join the new tree rooted at q to the tree Li. /* Case 2 else if vm−1 has a single sibling q in the profile of segment Ai then */ Remove q as a child of vm Join the tree rooted at q to Li. end 3 4 5 6 7 8 9 10 end 11 Produce Ri symmetrically by considering the vertices u1, . . . , uk. 12 Join Li and Ri to obtain Ai. 13 return Ai To prove that the algorithm correctly produce a biased tree for each segment Ai we need to verify that the credit and bias invariant are true. It follows from Bent et al. that the join and split operations maintain both invariants. Thus we only need to prove that the new tree rooted in q in case 1 satisfy both the invariants. In case 1 at least one of x and y are major 7 vm−1 vm x X y Y vm vm−1 vm−1 q Q q L′ i x X y Y L′ i q Q Li Li vm q Q Figure 1: Case 1 and 2 from Procedure ConstructSegmentTree. (since the original tree satisfies the bias invariant) and r(q) = r(vm). If either x or y is minor then the other one is a major leaf (since the original tree satisfies the bias invariant) and thus the tree rooted at q is biased. If y is minor then y has r(vm) − r(y) + 1 credits due to the credit invariant in the original tree. Since r(vm) = r(q) this implies that the credit variant is satisfied in the tree rooted at q. The argument when x is minor is similar. 5.2 Biased Merge Complexity The cost of performing the biased segment merge is the sum of the cost of splitting A and B into segments, reweighting the segments, and joining them into a single tree. 5.2.1 Cost of constructing segment trees Consider the vertices of A that are visited in the search for the segment endpoints. This search visits vertices on the path Al i for i = 1, . . . , k along with any ancestor of such vertex at most O(1) times. It follows from the definition of a profile that the number of trees in the profile is linear in the length of the path. Having found the path Al i we can find the roots of the trees in the profile in linear time in the length of the path. After having removed all subtrees that are in the profiles from A, the remaining vertices are either branching, or were a parent i Ar i Ar 8 Ai−1 Ai Ai+1 ai−1 Bi−1 ai Bi ai+1 Bi+1 bi−2 bi−1 bi . . . . . . . . . A : . . . B : . . . C : . . . a′ i−1 = b′′ i−2 a′′ i−1 = b′ i−1 a′ i = b′′ i−1 a′′ i = b′ i a′ i+1 = b′′ i Figure 2: Illustration of segments and the surrounding gaps. These gaps are used for both weighting and as potential when analyzing complexity. of a subtree in the profile. The number of vertices visited during this traversal therefore is no more than the total number of substrees in the profile which is no more than the total number of joins. Let Wx y be the combined weight of the subtrees in the profile of x y. Observe that the keys in the profile of the path Al i Ar i are exactly the keys of Ai and thus WAl Ar i i = WAi. Before analyzing the cost of the joins we need some definitions. The following definition is similar to the one in Iacono and Ozkan [4]. Gaps For i = 1, . . . , k − 1 let ai = Al i . That is, ai and bi are the length of the gap between the ith and the (i + 1)th segment in A and B, respectively (see Figure 2.). Define a0 = bk = 1. We will abuse notation and let ai, resp. bi, denote both the gap and the length of the gap. i and bi = Bl i+1 − Br i+1 − Ar After the merge the gap ai is intersected by the segment Bi splitting the gap ai into two i by Ai+1. Thus, i and a′′ i and b′′ i . The gap bi is split similarly into two gaps b′ k = 1. i . We define a′′ i−1 = Bl i − Ar i = b′′ 0 = b′ smaller pieces a′ a′′ i = b′ i = Al i+1 − Br i and a′ We need the following property: Property 1. The weight of the segment trees can be bounded as follows: • WAi ≤ ai−1 + ai + 2bi−1 for i = 2, . . . , k and • WBi ≤ bi−1 + bi + 2ai for i = 1, . . . , k − 1. The weight of the segment tree Ai before the reweighting is two times the sum of the gaps in Ai + ai−1 + ai. The sum of the gaps in Ai is at most bi and the property follows. The argument for Bi is similar. Cost of the joins We now consider the amortized complexity of the joins performed on Li in a single iteration. The case for Ri is analogous, and the analysis is similar to the analysis of the split operation of Bent et al. [1]. Observe that vm−1 is an ancestor to all the trees we have joined into Li before this iteration. Let L′ i be the tree Li after this iteration, and assume that r(Li) ≤ r(vm−1) and that the root of Li has c-rank r(vm−1) + 1. We will prove that r(vm) − r(vm−1) + 3 new credits suffice to both pay for the iteration and leave enough credits 9 in the root of L′ true for the next iteration. i to make c(L′ i) = r(vm) + 1 and that r(L′ i) ≤ r(vm) making our assumptions In case 1 at least one of x and y are major (because of bias) and thus r(q) = r(vm). If we place r(vm) − r(vm−1) new credits in the root of Li and 1 new credit on q we have c(Li) = r(vm) + 1 = c(q). In case 2, if q is minor then it has r(vm) − r(q) − 1 credits by the credit invariant, otherwise it is major and thus r(q) = r(vm) − 1. In any case c(q) = r(vm) − 1. If we place 2 new credits on q and r(vm) − r(vm−1) new credits in the root of Li then again c(Li) = r(vm) + 1 = c(q). In case 3, we place r(vm) − r(vm−1) credits in the root of Li and thus c(L′ i) = r(vm). In all three cases we spend at most r(vm) − r(vm−1) + 2 new credits, in cases 1 and 2, the join of Li and q takes O(1) amortized time. Also, there is at least 1 unused new credit which pays for the O(1) work of every iteration and after the iteration c(L′ i) = r(vm) + 1. We now prove that our assumption r(Li) ≤ r(vm−1) holds. Initially, Li = v1 and thus r(Li) = r(v1). We will prove that if r(Li) ≤ r(vm−1) then r(L′ i) = r(vm) which makes our assumption true for the next iteration. In case 1, either x or y is major by local bias and thus r(q) = r(vm). This means that when joining q and Li we end up in case 2 of Algorithm 1. By inspecting cases 2a and 2b of Algorithm 1 and using the fact that q has two children, it is clear that q will be the root of L′ i) = r(vm). In case 2 we are joining the tree rooted at q and Li and because r(q) ≤ r(vm) and r(Li) ≤ r(vm−1) < r(vm) it follows from Algorithm 1 that r(L′ i) ≤ r(vm). Now let's look at the overall cost. The amortized cost of a single step of the algorithm is proportional to the rank difference between consecutive vertices on the path and thus the sum of these costs telescope and the total cost becomes r(vj) − r(v1), where vj is the maximal rank tree merged into Li and v1 = Al i. By the definition of rank and Lemma 1 we have r(vj) = ≥ lg ai−1. Therefore, the cost of of constructing O(lg wvj ) = O(lg WAi) and we also have lg wAl Li is O( i = Li and since r(Li) ≤ r(vm−1) it follows that r(L′ ). By a similar argument the cost of of constructing Ri is O( i) ≤ r(vm). In case 3, L′ i and thus r(L′ ). The amortized i lg WAi lg ai−1 lg WAi lg ai min(ai−1,ai) ). Since ai−1 ≤ r(Li) ≤ w(Ai)) and complexity of constructing Li and Ri is thus O(lg ai ≤ r(Ri) ≤ w(Ai)) the complexity of joining Li and Ri is also bounded by this, and thus it also bounds the complexity of constructing the segment tree Ai. Summing over all the segments of A this also bounds the number of vertices visited during the traversal. In summary we have proven the following lemma: WAi Lemma 7. The complexity of constructing the trees Ai, Bi for i = 1, . . . , k is O k Xi=1(cid:18)lg WAi min(ai−1, ai) + lg WBi min(bi−1, bi)(cid:19)! . 5.2.2 Cost of reweighting By Lemma 6 the total complexity of reweighting Ai is O(lg cost for all the segments is then WAi a′ i + lg WAi a′′ i−1 ), and total reweighting WAi a′ i + lg WAi a′′ i−1 + lg WBi b′ i + lg WBi b′′ i−1(cid:19)! = i−1)(cid:19)! . WBi i, b′′ min(b′ O k Xi=1(cid:18)lg O k Xi=1(cid:18)lg WAi min(a′ i, a′′ i−1) + lg 10 5.2.3 Cost of joining the segment trees Observe that there are exactly 2k − 1 joins. We bound the complexity of joining the segments A1, B1, A2, B2, . . . , Ak, Bk by considering the merge tree resulting from the sequence of joins in the algorithm. This is a binary tree with 2k − 1 vertices where the leaves in left-to-right order represent the segments in order and an internal vertex represents the tree given by joining its two children. We assign to each internal vertex the cost of joining its two children which by Lemma 3 is the difference in the rank of the two children. Thus the complexity of the join algorithm is no more than the sum of the costs assigned to the vertices in the merge tree. We need the following fact for the analysis, which is easily verified by considering the different cases of Algorithm 1. Property 2. Let T be the tree obtained by joining two trees P and S. Then T has rank r(T ) ∈ {max(r(P ), r(S)), 1 + max(r(P ), r(S))}. First consider an internal vertex in the merge tree where the difference in rank between its children is at most 2. The sum of the cost assigned to such vertices is at most 2(2k − 1) = O(k). Now consider an internal vertex v assigned a cost cv > 2. Let a and b be the children of cv and assume without loss of generality that cv = r(b) − r(a) and thus r(b) > r(a) + 2. We prove that either b is a leaf or the left child of b is a leaf with rank at least r(b) − 1. a v c b d e f Figure 3: Part of the subtree rooted at v. If b is a leaf, then we are done, so let c and d be its children as depicted in Figure 3. We must have r(d) ≤ r(a), otherwise, a and c would have been joined before c and d. As r(b) > r(a) + 2 and r(d) ≤ r(a) we must have r(c) > r(a) + 1 and r(c) ≥ r(b) − 1 by Property 2. If c is a leaf then we are done, so assume that c has children e and f as shown in Figure 3. Because r(c) > r(a) + 1 either r(e) > r(a) in which case f and d would have been joined before e and f , or r(f ) > r(a) in which case a and e would have been joined before e and f . In either case we have reached a contradiction, so we have proved that either b is a leaf or c is a leaf of rank at least r(b) − 1. The argument for r(a) > r(b) + 2 is symmetric. Observe that r(a) is at least as great as the rank of the rightmost leaf in the left subtree of v and that the leftmost leaf in the right subtree of v has rank r(b) or rank r(b) − 1. These leaves corresponds to consecutive segments Ai, Bi or Bi, Ai+1 for some i, and it follows that the cost cv is no greater than the cost of joining these two segments. If we charge the cost to these two segments, it is easy to see that no other vertex v′ with cost v′ c will be charged to the same 11 two same segments, thus the total cost is at most O k Xi=1 r(Ai) − r(Bi) + r(Bi) − r(Ai+1)! . k−1 Xi=1 Recall that WAi+1 ≥ ai ≥ a′′ i = b′ i and WBi ≥ bi−1 ≥ b′′ i−1 = a′ i which implies that O k Xi=1 = O k Xi=1 = O k Xi=1(cid:18)lg r(Ai) − r(Bi) + (lg WAi − lg a′ i) + WAi a′ i + lg WBi b′ r(Bi) − r(Ai+1)! i)! (lg WBi − lg b′ k−1 k−1 Xi=1 Xi=1 i (cid:19)! . 5.2.4 Amortized complexity of biased segment merge The total cost of performing the biased segment merge is the sum of the cost of splitting A and B into segments, reweighting the segments, and joining them into a single tree as described in the previous sections. Thus the total complexity is dominated by the reweighting of the segments endpoints which takes time (4) WAi min(a′ i, a′′ i−1) + lg WBi i, b′′ i−1)(cid:19)! (5) min(b′ (1) (2) (3) (6) (7) (8) i−1)(cid:19)! Xi=2(cid:18)lg k−1 + lg WAi i−1) i, a′′ min(b′ min(a′ WBi i, b′′ Xi=1(cid:18)lg O k = O lg WA1 + lg WB1 + lg WAk + lg WBk + = O lg WA + lg WB + = O lg WA + lg WB + = O lg WA + lg WB + Xi=2(cid:18)lg Xi=2(cid:18)lg Xi=2(cid:18)lg min(a′ min(a′ i, a′′ k−1 k−1 k−1 2bi−1 + ai + ai−1 + lg 2ai + bi + bi−1 min(b′ i, b′′ i−1) max(bi−1, ai, ai−1) max(ai, bi, bi−1) i, a′′ i−1) + lg min(b′ i−1) (cid:19)! i−1) (cid:19)! i, b′′ max(ai, ai−1, bi, bi−1) min(a′ i−1, b′ i, a′′ i, b′′ i−1)(cid:19)! where (6) follows from Property 1 and (7) follows from the relations between the gap sizes. Potential function We now analyze the amortized cost of this operation using the following potential function: Define the potential of a set G as (lg g+(x) + lg g−(x)) φ(G) = Xx∈G like before and let the potential function of the mergeable dictionary be Φ(G) = XG∈G φ(G) . 12 The potential of an empty data structure is 0 and clearly the potential remains non-negative. When performing a merge between two sets A, B ∈ G, only the potential of elements in A and B are affected. Furthermore, only the minimum and maximum element in each of the segments Ai, Bi are affected. The size of the right gap of Ar i and the size of the left gap of Al 1 and the right gap of Ar i−1. All gap sizes decrease except the left gap of Bl k. The total potential decrease is therefore at least i changes from ai−1 to a′′ i changes from ai to a′ k−1 i + lg ai−1 − lg a′′ i−1 + lg bi − lg b′ i + lg bi−1 − lg b′′ Xi=2(cid:0)lg ai − lg a′ = Ω k−1 Xi=2 lg max(ai, ai−1, bi, bi−1) min(a′ i−1, b′ i, a′′ i, b′′ i−1)! i−1(cid:1) (9) (10) (11) where (10) follows by the relations between the gap sizes. The potential increase is at most (lg b′′ 0 − lg b0) + (lg a′ k − lg ak) ≤ lg a0 − 0 + lg bk − 0 = lg a0 + lg bk ≤ lg WA + lg WB. It follows that the cost of the merge plus the change in potential is no more than O(lg WA + lg WB) = O(lg WC). Therefore, the amortized cost of the merge operation is O(lg UC) where UC is max(B) − min(A) = max(C) − min(C). 5.3 Lifting Assumptions Here we assumed that min(A) < min(B). It this is not the case, swap the arguments of the merge. We also assumed that max(A) < max(B). If this is not the case, we start by executing B′, B′′ ← Split(B, max(A)), we then perform C ′ ← Merge(A, B′), change the weight of the elements max(C ′) and min(B′′) according to our weighting scheme and finally because max(C ′) = max(A) < min(B′′) we can produce C by joining C ′ and B′′. It follows from Lemmas 1, 3, 5 and 6 that the total cost excluding the Merge(A, B′) operation is O(lg UC). We show how to handle the case where A ∩ B 6= ∅ in Section 7. 6 Split, MakeSet, Search, and Shift 6.1 Supporting Shift In order to support the Shift operation, we extend the biased trees by storing an integral offset with every vertex x denoted s(x) indicating that the subtree rooted at x is shifted by s(x). We then maintain the shift invariant: The key represented by a leaf y in a tree T is the sum of the offsets on the path from the root of T to y. Let TG be the biased tree representing the ordered set G. The set G is shifted by incrementing s(x) by j where x is the root of TG. The operation MakeSet(j) creates a tree with a single vertex x and sets s(x) := j. During navigation, whenever visiting an internal vertex x with s(x) 6= 0 we increment the values xl, xr and the shift of each of its children by s(x) and afterwards set s(x) := 0. This gives a constant time overhead at each step and maintains the shift invariant. Because all operations on a biased tree start at the root of TG it is then guaranteed that if we navigate to a vertex x, then the shift invariant is also true for the subtree rooted at x. Furthermore, since the only way to manipulate a biased tree is by manipulating its pointers, it follows that the shift invariant remains true under any operation. 13 6.2 Analysis The total weight of the tree representing a dictionary G is O(lg UG) where UG = max(G) − min(G). Search The potential is not affected by the Search operation which therefore by Lemma 2 takes O(lg UG) = O(lg UG) worst-case and amortized time. Split The A, B ← Split(G, x) operation takes O(lg UG) worst-case time by Lemma 5 and Lemma 1. The size of the left gap of Ar and the right gap of Bl decrease and no other gaps are affected, thus the amortized time of the operation is no worse than the worst-case time. MakeSet The MakeSet operation creates a new set G with a singleton element. Creating the biased tree with a singleton vertex takes O(1) worst-case time and requires no new credits. As both the left and right gap of the element is 1, the potential change is O(1). The amortized time of the operation is therefore no more than the worst-case time. Shift The potential is not affected by the Shift operation. Thus the worst case and amortized time of Split is O(1). 7 Intersecting Segments We now consider how to handle the case where the sets A and B are not disjoint. We will produce the set C = A ∪ B having only unique elements and can therefore inductively assume that A and B each consist of unique elements. Observe that our technique for identifying and splitting segments does not have any de- pendency on the keys of A and B being disjoint. However, we can now only guarantee the inequalities max(Ai) ≤ min(Bi) for i = 1, . . . , k and max(Bi) ≤ min(Ai+1) for i = 1, . . . , k − 1. We add a pruning step in between the splitting and reweighting. This is described in Procedure PruneTrees. Keeping track of the multiplicity of every key can easily be obtained by storing a counter in every leaf. This only implies a constant overhead in the running time. 7.1 Analysis We now analyze the amortized cost of the new merge operation. We first bound the cost of the pruning procedure. Cost of pruning The cost of running through all the segment trees and checking if they overlap is bounded by the cost of constructing the segment trees. The same is true for the deletion of the singleton trees. Note that the cost of deleting a singleton tree Ai is O(1) and causes the potential to decrease by lg WAi. It remains to account for the cost of the splits in line 8 and 18. By Lemma 4 the cost of splitting max(Ai) from Ai is O(cid:18)lg WAi w(max(Ai))(cid:19) = O(cid:18)lg WAi ai (cid:19) = O(cid:18)lg WAi min(a′ i, a′′ i−1)(cid:19) , since w(max(Ai) ≥ ai ≥ min(a′ i, a′′ i−1). By similar arguments the cost of splitting max(Bi) from Bi is O(cid:16)lg WBi i,b′′ min(b′ i−1)(cid:17). 14 Procedure PruneTrees(A1, . . . , Ak,B1, . . . , Bk) 1 for i = 1 to k do 2 if max(Ai) = min(Bi) then 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 . if Ai is a singleton tree and Bi is not a singleton tree then Delete Ai else if Bi is a singleton tree then Delete Bi else Split max(Ai) from Ai Delete the new singleton tree containing max(Ai). end end if max(Bi) = min(Ai+1) then if Bi is a singleton tree and Ai+1 is not a singleton tree then Delete Bi else if Ai+1 is a singleton tree then Delete Ai+1 else Split max(Bi) from Bi Delete the new singleton tree containing max(Bi). end end 22 end We note that the new maximum elements in the trees where we deleted the maximum now already have the correct weight, and we will therefore not reweight these during the reweighting step. The cost of the reweighting for all other elements is the same as in the previous analysis (see Section 5.2.2). That is, the cost of reweighting Al i)) and the cost of reweighting Ar i is O(lg(WAi/a′ i is O(lg(WAi/a′′ i−1)), etc. The total cost of pruning and reweighting is therefore O k Xi=1(cid:18)lg WAi min(a′ i, a′′ i−1) + lg WBi i, b′′ i−1)(cid:19)! . min(b′ Amortized cost of merge We will argue that the potential still decreases with at least Ω k−1 Xi=2 lg max(ai, ai−1, bi, bi−1) min(a′ i−1, b′ i, a′′ i, b′′ i−1)! . Consider segment Ai for some 2 ≤ i ≤ k − 2. There are 5 cases: • If Ai is deleted then we get a potential loss of lg ai + lg ai−1. • If the weight of Al i decreases then we the potential decreases by lg ai−1 − lg a′′ i−1. • If the weight of Ar i decreases then we the potential decreases by lg ai − lg a′ i. • If the weight of Al i does not decrease (and Ai is not deleted) then min(Bi−1) = max(Ai−1) and either Bi−1 is a singleton set and min(Bi−1) = max(Bi−1) or Bi−1 consists of exactly 15 two elements and max(Bi−1) = min(Ai). If Bi is a singleton set then bi−1 ≥ ai−1 and Bi−1 is deleted giving a potential decrease of at least lg bi−1 ≥ lg ai−1. Otherwise, Br i−1 is deleted (in line 19) giving potential decrease of at least lg ai−1. • If Ar i is deleted then we get a potential decrease of at least lg ai. • If the weight of Ar i does not decrease (and Ar i was not deleted) then either min(Ai+1) = min(Bi) = max(Bi) or min(Ai+1) = max(Ai+1) = min(Bi+1). These are the only two cases since if max(Ai) = min(Bi) < max(Bi) = min(Ai+1) then Ar i would have been deleted. In the first case either Ai+1 or Bi is deleted. In the second case either Ai+1 or Bi+1 is deleted. In all cases we get a potential decrease of at least lg ai. Thus we get a decrease in potential of at least lg ai−1−lg a′′ i. The potential decrease from the deleted elements are counted only when considering the neighbouring segments, that is, only a constant number of times. By a similar argument the decrease in potential for segment Bi is at least lg bi−1 − lg b′′ i. For 2 ≤ i ≤ k − 1 the potential decrease is therefore i−1+lg ai−lg a′ i−1 + lg bi − lg b′ Ω k−1 Xi=2 lg max(ai, ai−1, bi, bi−1) min(a′ i−1, b′ i, a′′ i−1)! . i, b′′ The potential increase is still bounded by lg WA + lg WB as previously. The cost of all the other parts of the merge operation can be bounded as before. Thus the amortized cost of the new merge operation is O(log UC). This concludes the proof of Thm. 1. References [1] Samuel W. Bent, Daniel Dominic Sleator, and Robert Endre Tarjan. Biased search trees. SIAM J. Comput., 14(3):545 -- 568, 1985. [2] M. Farach and M. Thorup. String Matching in Lempel-Ziv Compressed Strings. Algorith- mica, 20(4):388 -- 404, 1998. [3] Loukas Georgiadis, Haim Kaplan, Nira Shafrir, Robert E. Tarjan, and Renato F. Werneck. Data structures for mergeable trees. ACM Trans. Algorithms, 7(2):14:1 -- 14:30, March 2011. [4] J. Iacono and O. Ozkan. Mergeable dictionaries. In Proc. 37th ICALP, pages 164 -- 175, 2010. [5] Adam Karczmarz. A Simple Mergeable Dictionary. In Proc. 15th SWAT, pages 7:1 -- 7:13, 2016. [6] Jane Katherine Lai. Complexity of union-split-find problems. Master's thesis, Massachusetts Institute of Technology. 2008. 16
1509.03212
1
1509
2015-09-10T16:16:21
Online Buy-at-Bulk Network Design
[ "cs.DS" ]
We present the first non-trivial online algorithms for the non-uniform, multicommodity buy-at-bulk (MC-BB) network design problem in undirected and directed graphs. Our competitive ratios qualitatively match the best known approximation factors for the corresponding offline problems. The main engine for our results is an online reduction theorem of MC-BB problems to their single-sink (SS-BB) counterparts. We use the concept of junction-tree solutions (Chekuri et al., FOCS 2006) that play an important role in solving the offline versions of the problem via a greedy subroutine -- an inherently offline procedure. Our main technical contribution is in designing an online algorithm using only the existence of good junction-trees to reduce an MC-BB instance to multiple SS-BB sub-instances. Along the way, we also give the first non-trivial online node-weighted/directed single-sink buy-at-bulk algorithms. In addition to the new results, our generic reduction also yields new proofs of recent results for the online node-weighted Steiner forest and online group Steiner forest problems.
cs.DS
cs
Online Buy-at-Bulk Network Design Deeparnab Chakrabarty∗ Alina Ene† Ravishankar Krishnaswamy‡ Debmalya Panigrahi§ Abstract We present the first non-trivial online algorithms for the non-uniform, multicommodity buy-at-bulk (MC-BB) network design problem. Our competitive ratios qualitatively match the best known approxi- mation factors for the corresponding offline problems. In particular, we show problem in undirected edge-weighted graphs. BB problem in undirected node-weighted graphs. 1 • For any fixed  > 0, a polynomial time online algorithm with a competitive ratio of O(cid:0)k • A polynomial time online algorithm with a poly-logarithmic competitive ratio for the MC-BB • A quasi-polynomial time online algorithm with a poly-logarithmic competitive ratio for the MC- 2 +) (where k is the number of demands, and O(.) hides polylog factors) for MC-BB in directed graphs. • Algorithms with matching competitive ratios for the prize-collecting variants of all the above prob- Prior to our work, a logarithmic competitive ratio was known for undirected, edge-weighted graphs only for the special case of uniform costs (Awerbuch and Azar, FOCS 1997), and a polylogarithmic competitive ratio was known for the edge-weighted single-sink problem (Meyerson, SPAA 2004). To the best of our knowledge, no previous online algorithm was known, even for uniform costs, in the node-weighted and directed settings. lems. Our main engine for the results above is an online reduction theorem of MC-BB problems to their single-sink (SS-BB) counterparts. We use the concept of junction-tree solutions (Chekuri et al., FOCS 2006) that play an important role in solving the offline versions of the problem via a greedy subroutine -- an inherently offline procedure. Our main technical contribution is in designing an online algorithm using only the existence of good junction-trees to reduce an MC-BB instance to multiple SS-BB sub- instances. Along the way, we also give the first non-trivial online node-weighted/directed single-sink buy-at-bulk algorithms. In addition to the new results, our generic reduction also yields new proofs of recent results for the online node-weighted Steiner forest and online group Steiner forest problems. ∗Microsoft Research, 9 Lavelle Road, Bangalore, India. Email: [email protected]. †Department of Computer Science and DIMAP, University of Warwick, Coventry, UK. Email: [email protected]. ‡Microsoft Research, 9 Lavelle Road, Bangalore, India. Email: [email protected]. §Department of Computer Science, Duke University, Durham, NC, USA. Email: [email protected]. 1 Introduction In a typical network design problem, one has to find a minimum cost (sub) network satisfying various connectivity and routing requirements. These are fundamental problems in combinatorial optimization, operations research, and computer science. To model economies of scale in network design, Salman et al. [32] proposed the buy-at-bulk framework, which has been studied extensively over the last two decades (e.g., [6, 20, 33, 22, 29, 28, 15, 14]). In this framework, each network element is associated with a sub- additive function representing the cost for a given utilization. Given a set of connectivity demands com- prising k source-sink pairs, the goal is to route integral flows from the sources to the corresponding sinks concurrently to minimize the total cost of the routing. An important application of the problem is capacity planning in telecommunication networks or in the Internet. As observed by Awerbuch and Azar [6], this application is inherently "online" in that terminal- pairs arrive over time and need to be served without knowledge of future pairs. The authors of [6] give a logarithmic-competitive online algorithm for the uniform case where every edge is associated with the same cost function. However, uniformity is not always a feasible assumption, especially in heterogeneous, dynamic networks like the Internet. Indeed recent research (e.g., [29, 28, 15]) has focused on the non- uniform setting with a different sub-additive function for every network element. In this non-uniform setting, Meyerson [28] gives a polylogarithmic-competitive algorithm for the special case when all terminal-pairs share the same sink. To the best of our knowledge, no non-trivial online algorithm is known for the general multicommodity setting, which is the focus of our paper. We consider, in increasing order of generality, undirected edge-weighted graphs, undirected node- weighted graphs, and directed edge-weighted graphs.1 It is also convenient to classify the problems that we study into the single-sink version where all the terminal-pairs share a common sink, and the general multicommodity version where the sinks in the terminal-pairs may be distinct. For notational convenience, we use the following shorthand forms for our problems: X-Y-BB where X = SS or MC (single-sink and multicommodity, respectively) and Y = E or N or D (undirected edge-weighted, undirected node-weighted, and the general directed case, respectively). 1.1 Our Contributions We obtain the following new results (unless otherwise noted, our algorithms run in polynomial time): • A poly-logarithmic competitive online algorithm for the MC-E-BB problem. • A poly-logarithmic competitive online algorithm for MC-N-BB and SS-N-BB that runs in quasi- polynomial time. 1 • An O(k 2 +ε)-competitive online algorithm for MC-D-BB for any constant ε > 0 with running time nO(1/ε), where O(.) hides polylogarithmic factors. For SS-D-BB, the ratio improves to O(k), trans- lating to a polylogarithmic competitive ratio in quasi-polynomial time. • Online algorithms for prize-collecting versions of all the above problems with the same competitive ratio. Up to exponents in the logarithm, our online algorithms match the best known offline approximation al- gorithms (Chekuri et al. [15] for MC-E/N-BB and Antonakopoulos [5] for MC-D-BB); for MC-N-BB, 1In undirected graphs, node costs can simulate edge costs; in directed graphs they are equivalent. 2 however, a polynomial time, polylogarithmic approximation is known [14], whereas our algorithm runs in quasi-polynomial time. Furthermore, a logarithmic lower bound, even for SS-E-BB, follows from the lower bound for the online Steiner tree problem [26], and a polylogarithmic lower bound for online SS-N-BB follows from a matching one for set cover [3]. From a technical perspective, we derive all the multicommodity results using a generic online reduction theorem that reduces a multicommodity instance to several single-sink instances, for which we either use existing online algorithms or give new online algorithms. Informally, one can view this as the "online analog" of the junction-tree approach pioneered by Chekuri et al. [15] for offline multicommodity network design. We discuss this approach in the next subsection. 1.2 An Online Reduction to Single Sink Instances Multicommodity network design problems, both online and offline, are typically more challenging than their single-sink counterparts, and have historically2 required new ideas every time depending on the specific problem at hand. The situation is no different for buy-at-bulk, both for uniform and non-uniform costs. In the offline buy-at-bulk setting, this shortcoming is addressed by Chekuri et al. [15] (expanded to other problems by [14, 13, 5]), who introduce a generic combinatorial framework for mapping a single instance of a multicommodity problem to multiple instances of the corresponding single-sink problem. At the heart of this scheme is the following observation that holds for many multicommodity problems such as (edge/node) Steiner forest, directed Steiner network, buy-at-bulk, and set connectivity: there exists a near- optimal3 junction-tree solution for the multicommodity problem that decomposes into solutions to multiple single-sink problems where each single-sink problem connects some subset of the original terminal-pairs to a particular root. The problem now reduces to finding good junction-trees to cover all the terminal-pairs. The offline tech- niques [15, 13, 5] tackle this using a greedy algorithm for finding the single-sink solutions; more precisely, in each step they find the best density (cost per terminal-pair) solution that routes a subset of terminal- pairs via a single sink. A set cover style analysis then bounds the loss for repeating this procedure until all terminal-pairs are covered. However, as the reader may have already noticed, the greedy optimization approach is inherently offline, as finding the best-density solution requires knowledge of all terminal-pairs upfront. Our main technical contribution in this work is an online version of the junction-tree framework. Indeed, we show how to reduce any multicommodity buy-at-bulk instance to a collection of single-sink instances online. (Informal Theorem) If the junction-tree approximation factor of the MC-BB problem is α, the integrality gap of a natural LP relaxation of the SS-BB problem is β, and there is a γ-competitive online algorithm for the SS-BB problem, then there is an O(αβγ · polylog(n))-competitive algorithm for the MC-BB problem. To prove the above theorem, we first write a composite-LP, which has (a) an outer-LP comprising assign- ment variables that fractionally assign terminal-pairs to roots, and (b) many inner-LPs which correspond to the natural LP relaxations for the SS-BB problem for each root and the terminal-pairs fractionally assigned to it by the outer-LP. We then apply the framework of online primal-dual algorithms (see [10] for instance) to solve the composite-LP online. However, there are two main challenges we need to surmount. • First, the existing framework has been mostly applied to purely covering/packing LPs4 and our inner- 2For instance, compare [29] and [12] for the SS-E-BB and MC-E-BB problem, and compare Naor et al. [31] and Hajiaghayi et al. [24] for the online node-weighted Steiner tree and Steiner forest problem. 3We call the quality of such a solution the junction-tree approximation factor; e.g., it is O(log n) for MC-E-BB and MC-N- BB [15] 4Our current understanding of mixed packing-covering is limited [7] and does not capture the problem we want to solve. 3 LPs have both kinds of constraints, and moreover, there is an outer-LP encapsulating them. We show nonetheless that it can be extended to solving our LP fractionally up to polylogarithmic factors. Indeed, we use the specific flow-structure of the inner-LP, and each step of our algorithm solves many (auxiliary) min-cost max-flow problems. • The second difficulty is in rounding this fractional solution online. This is a hard problem, and cur- rently we do not know how to do so even for basic network design problems such as the Steiner tree problem. To circumvent this, we show that it suffices to only partially round the LP. More precisely, we round the LP solution so that only the outer-LP (assignment variables) become integral, and the inner-LPs remain fractional. This gives us an integral assignment of the terminal-pairs to different single-sink instances, with bounded total fractional cost. Now, from the bounded integrality gap of the inner-LPs, we know that there exist good single-sink solutions for our assignment of terminal-pairs to roots, even though we cannot find them online5. Using this knowledge, our final step is to run online single-sink algorithms for each root, and send the terminal-pairs to the root as determined by the outer-LP assignment. Figure 1 summarizes our overall approach. initialize multiple online algorithms for the single-sink problem (one for each vertex as root). when (si, ti) arrives update the fractional solution of the composite LP to satisfy the new request round the composite LP to get an integral solution to the outer LP, which gives us an assignment of (si, ti) to some root r send both si and ti to the instance of the single-sink online algorithm with root r Figure 1: Online Framework for Multicommodity Network Design Problems The results mentioned in Section 1.1 follow by bounding α, β, γ for the corresponding problems. For MC-E-BB, all of these are known to be O(polylog(n)) ([15, 29, 28] respectively). For MC-N-BB, it is known both α, β are bounded by O(polylog(n)) [14], and we bound γ in Section 5 by giving the first online algorithms for SS-N-BB. For MC-D-BB, we need some additional work. In this case we cannot directly bound β, since the integrality gap of the natural LP relaxation is not known to be bounded. Nevertheless, in Section 4, we show that it suffices to work only with more structured instances for which we can bound the integrality gap. Finally, we illustrate the generality of our reduction theorem by noting that, when combined with existing bounds on α, β, and γ, it immediately implies (up to polylogarithmic factors) some recent results in online network design, such as online node-weighted Steiner forest [24], and online edge-weighted group Steiner forest [31] -- two problems for which specialized techniques were needed, even though their single-sink counterparts were known earlier. 5The difficulty comes from the fact that the online solution we maintain must be monotonic, i.e., the decisions are irrevocable. 4 1.3 Related Work Buy-at-bulk network design problems have received considerable attention over the last two decades, both in the offline and online settings. For the uniform cost model, Awerbuch and Azar [6] give an O(log n)- approximation for MC-E-BB, while O(1)-approximations are known [20, 33, 22] for SS-E-BB. We also note that O(1)-approximations have been obtained in special cases for the multicommodity problem, such as in the rent-or-buy setting [21]. Meyerson et al. [29] give an O(log k) approximation for the general SS-E-BB, and the first non-trivial algorithm for MC-E-BB is an exp(O(√log n log log n))-approximation due to Charikar and Karagiozova [12]. This was improved to a poly-logarithmic factor by Chekuri et al. [15] who also solve MC-N-BB [14] with similar guarantees. For directed graphs, our knowledge is much sparser. Even for special cases like directed Steiner tree and forest, the best polytime approximation factors known are O(kε) [34, 11] and min(O(√k, n2/3)) [13, 18, 8] respectively, and these ideas were extended to MC-D-BB by Antonakopoulos [5]. On the hardness side, Andrews [4] shows that even the MC-E-BB problem is Ω(cid:0) log1/2−ε n)-hard, while MC-D-BB (in fact directed Steiner forest) is known to be label-cover hard [17]. The online Steiner tree problem (a special case of online SS-E-BB) was first studied by Imase and Waxman [26] who give an O(log k)-competitive algorithm. Berman and Coulston [9] give an O(log k)- competitive algorithm for online Steiner forest, and both these results are tight, i.e., there is an Ω(log k) lower bound. As mentioned earlier, Awerbuch and Azar's algorithm [6] can be seen as an O(log n)-competitive online algorithm for the uniform-cost MC-E-BB. For non-uniform buy-at-bulk, the only online algorithm that we are aware of is Meyerson's [28] polylog-competitive algorithm for the single-sink problem. For online node-weighted network design, developments are much more recent. A polylogarithmic approxima- tion for the node-weighted Steiner tree problem was first given by Naor et al. [31] and later extended to the online node-weighted Steiner forest problem [24] and prize-collecting versions [23]. These algorithms, like ours in this paper, utilize the online adaptation of the primal-dual and LP rounding schemas pioneered by the work of Alon et al. [3] for the online set cover problem (see also [2] for its adaptation to network design problems). We also note that in the node-weighted setting, the online lower bound can be strengthened to Ω(log n log k) using online set cover lower bounds [3, 27]. 2 Preliminaries and Results We now formally state the problem, set up notation that we use throughout the paper, and state our main theorems. 2.1 Our Problems Buy-at-bulk Network Design. In the most general setting of the MC-D-BB problem, an instance I = (G,X ) consists of a directed graph G = (V, E) and a collection X of terminal-pairs (si, ti) ∈ V × V ; each such si and ti is called a terminal. Each (si, ti) pair also has a positive integer demand di, which we assume to be 1 for clarity in presentation.6 Additionally, each edge e ∈ E is associated with a monotone, sub-additive7 cost function fe : R≥0 → R≥0. A feasible solution to the problem is a collection of paths {P1, . . . , Pk} where Pi is a directed path from si to ti carrying load di. Given a solution {P1, . . . , Pk}, we 6We can handle non-uniform demands by incurring an additional O(log D) factor in the competitive ratio and the running time (where D is the maximum demand) by having O(log D) "unit-demand" instances, where the ith instance deals with demands between 2i−1 and 2i. 7That is, fe(x) ≥ fe(y) whenever x ≥ y, and fe(x + y) ≤ fe(x) + fe(y) 5 let load(e) =(cid:80) the objective ObjBB :=(cid:80) Obj2M :=(cid:80) e∈(cid:83) (cid:80) i Pi ce +(cid:80) i i:e∈Pi di denote the total load on edge e. The goal is to find a feasible solution minimizing e∈E fe(load(e)). In the online problem, the offline input consists of the graph G and the cost functions fe. The pairs (si, ti) arrive online in an unknown, possibly adversarial, order. When a pair (si, ti) arrives, the algorithm must select the path Pi that connects them, and this decision is irrevocable. Reduction to the Two-metric Problem. Following previous work, throughout this paper we consider an equivalent problem (up to constant factors) known as two-metric network design. In this problem, instead of functions fe(.) on the edges, we are given two parameters ce and (cid:96)e on each edge. One can think of ce as a fixed buying cost, or just cost, of edge e, and (cid:96)e as a per-unit flow cost, or length, of edge e. The feasible solution space is the same as for the buy-at-bulk problem, and the goal is to minimize the objective e∈Pi (cid:96)e. The following lemma is well known (see e.g., [15]). Lemma 1. Given an instance of the buy-at-bulk problem, for any ε > 0 one can find an instance of the two-metric network design problem such that, for any feasible solution, Obj2M ≤ ObjBB ≤ (2 + ε)Obj2M. Remark. In light of the above lemma, henceforth we abuse notation and let the buy-at-bulk problem mean the two-metric network design problem. 2.2 Our Tools Junction-tree solutions. Given an instance I = (G,X ) of the buy-at-bulk problem, we consider junction- tree8 solutions, a specific kind of solution to the problem introduced by [15]. In such solutions, the collection of pairs are partitioned into groups and each group is indexed by a root vertex r ∈ V . For all terminal pairs (si, ti) in a group indexed by r, the path Pi from si to ti contains the root vertex r (see Figure 2). Figure 2: A group of terminal pairs routed via a junction-vertex in an undirected graph. Formally, consider an instance I = (G,X ) of the buy-at-bulk problem, and let Opt denote the objective value of the optimum solution. Given a partition Π := (πr1, . . . , πrq ) of terminal pairs indexed by q different root vertices, a junction-tree solution is one that uses single-sink solutions to connect the original terminal- pairs. Indeed, for each part πr indexed by root r, consider the optimal solutions to the single-sink problem on graph G with demands {(si, r) : (si, ti) ∈ πr} and the single-source problem9 with pairs {(r, ti) : (si, ti) ∈ πr}. Let Optr(πr) denote the sum of the objectives of the optimal solutions to the single-sink r∈V Optr(πr). Let Optjunc denote the minimum Opt(Π) 8The word tree is misleading since the final solution need not be a tree in directed graphs. Nevertheless, we continue using this and single-source problems, and let Opt(Π) :=(cid:80) term for historical reasons. Junction trees were originally proposed for undirected graphs, where the solution is indeed a tree. 9The single-source problem in a directed graph is identical to the single-sink problem with all the edges reversed in direction. For undirected graphs, both problems are on the same graph. 6 junctions1t1s2t2t3s3t4s4 over all partitions. We call this solution the optimum junction-tree solution for this instance.10 Clearly, Optjunc ≥ Opt. The junction-tree approximation factor of I is defined to be the ratio Optjunc/Opt. LP Relaxation. We now describe a natural flow-based LP relaxation for the single-sink buy-at-bulk problem for an instance I = (G,T ) where T is a set of terminals that need to be connected to the root r. minimize (cid:88) (cid:88) (cid:88) cexe + (cid:96)efi(e) s.t i e∈E e∈E {fi(e) : e ∈ E(G)} defines a flow from si to r of value 1 ∀si ∈ T ∀e ∈ E fi(e) ≤ xe xe ≥ 0, fi(e) ≥ 0 ∀e ∈ E (SS-BaB LP) Recall that the integrality gap of (SS-BaB LP) on the instance I = (G,T ) is defined to be the ratio of Opt to the optimal value of the LP (SS-BaB LP). Also, we define the integrality gap for the graph G to be the worst case integrality gap (over all requests T on graph G) of the corresponding instance I = (G,T ). 2.3 Our Results Main Technical Theorem and its Applications. Now we are ready to state our main theorem; the proof is in Section 3. We say that an online algorithm is γ-competitive for a graph G if, for any sequence of requests X , the online algorithm for buy-at-bulk returns a solution within a γ-factor of Opt(I), where I = (G,X ). Theorem 2 (Reduction to Single-Sink Online Algorithms). Fix an instance I = (G,X ) of the MC-BB problem. Suppose the following three conditions hold. (i) The junction-tree approximation factor of I is at most α. (ii) The integrality gap of (SS-BaB LP) on any single-sink instance on graph G is at most β. (iii) There is a γ-competitive online SS-BB algorithm for any instance on graph G that runs in time T . Then there is an online algorithm for I running in time poly(n, T ) whose competitive ratio is O(αβγ · polylog(n)). Using this theorem, we can immediately obtain the following new results mentioned in the introduction. Theorem 3 (Undirected Edge-weighted Buy-at-Bulk). There is a polylog(n)-competitive, polynomial time randomized online algorithm for the MC-E-BB problem. Proof: The theorem follows directly by combining Theorem 2 with the following results from previous work. Chekuri et al. [15] prove that the junction-tree approximation factor for the undirected edge-weighted buy-at-bulk problem is O(log k). Chekuri et al. [16] prove that the integrality gap of (SS-BaB LP) in undi- rected edge-weighted graphs is O(log k). Meyerson [28] gives a randomized polynomial time online algo- (cid:4) rithm for the single-sink buy-at-bulk problem with competitive ratio O(log4 n). Theorem 4 (Undirected Node-weighted Buy-at-Bulk). For any constant ε > 0, there is an O(kεpolylog(n))- competitive, randomized online algorithm for MC-N-BB with running time nO(1/ε). As a corollary, this yields a polylog(n)-competitive, quasi-polynomial time algorithm for this problem. 10Note that copies of the same edge appearing in multiple single-sink solutions are treated as distinct edges in the junction-tree solution. Hence, decomposing the optimal multicommodity solution into its constituent paths does not yield Optjunc = Opt. 7 Theorem 5 (Directed Buy-at-Bulk). For any constant ε > 0, there is an O(cid:0)k1/2+εpolylog(n))(cid:1)-competitive, polynomial time online algorithm for the MC-D-BB. We again use Theorem 2 to prove the above theorems. However, unlike for MC-E-BB, we are not aware of any online algorithms for the SS-N-BB and SS-D-BB problems. We therefore first give online algorithms for these problems, and then use Theorem 2; the details appear in Sections 5 and 4. Finally, we can almost directly use Theorem 2 to also obtain matching results for prize-collecting versions of the above problems. Recall that in a prize-collecting problem, every terminal-pair also comes with a penalty qi, and the algorithm can opt to not satisfy the request by incurring this value in the objective. We give the extension of our results to the corresponding prize-collecting problems in Section 6. Theorem 6. For each of the above problems, there is an online algorithm with matching running time and competitive ratio for the corresponding prize-collecting version. In addition to the new results mentioned above, we can also use Theorem 2 to give alternative proofs (with slightly worse polylog factors) of some recent results in online network design. By combining Theo- rem 2 with the polylog(n)-competitive algorithm for online group Steiner Tree due to Alon et al. [2], we ob- tain a polylog(n)-competitive online algorithm for the group Steiner forest problem -- a result shown earlier by Naor et al. [31]. Similarly, by combining Theorem 2 with the polylog(n)-competitive online algorithm for the node-weighted Steiner tree problem due to Naor et al. [31], we obtain a polylog(n)-competitive online algorithm for the node-weighted Steiner forest problem -- a result shown earlier by Hajiaghayi et al. [24]. Height Reduction Theorem. One of the technical tools that we use repeatedly in this paper is the following result, which builds on the work of Helvig et al. [25]. We give the proof in Appendix A. Theorem 7. Given a directed graph G = (V, E) with edge costs ce and lengths (cid:96)e, for all h > 0, we can efficiently find an upward directed, layered graph Gup h on (h + 1) levels and edges (with new costs and lengths) only between successive levels going from bottom (level h) to top (level 0), such that each layer has n vertices corresponding to the vertices of G, and, for any set of terminals X and any root vertex r, (i) the optimal objective value of the single-sink buy-at-bulk problem to connect X (at level h) with r (at level 0) on the graph Gup h is at most O(hk1/h)φ, where φ is the objective value of an optimal solution of the same instance on the original graph G; (ii) given a integral (resp. problem to connect X with r on the graph Gup solution) of objective value at most φ for the problem on the original graph G. fractional solution) of objective value φ for the single-sink buy-at-bulk h , we can efficiently recover an integral (resp. fractional Likewise, we can obtain a downward directed, layered graph Gdown top to bottom, with the same properties as above except for single-source instances instead. on (h + 1)-levels with edges going from h 3 Proof of Theorem 2 (Online Reduction to Single-Sink Instances) There are three main steps in the proof. In Section 3.1, we describe the composite LP which is a relaxation of optimal junction-tree solutions (for technical reasons, we first need to pre-process the graph). Next, in Section 3.2, we show how to fractionally solve the LP online. Third, in Section 3.3, we show how to partially round the LP online. The resulting solution then decomposes as fractional solutions to different single-sink instances. Finally, we use the bounded integrality gap and the online algorithm for SS-BB to wrap up the proof in Section 3.4. 8 3.1 The Composite-LP Relaxation: MC-BaB LP We first apply Theorem 7 with h = Θ(log n) to obtain layered graphs Gup (resp., Gdown) of height O(log n) where all the edges are directed upward (resp. downward); see Figure 3 for an illustration. The reason for this preprocessing is that the length of the (si, ti) paths appear as a factor in our final competitive ratio and the above step bounds it to a logarithmic factor. Recall that the graph Gup (resp., Gdown) approximately preserves the single-sink (resp., single-source) solutions for any set of terminals and any root. After this step, we can imagine that all the roots (of the single-sink instances we will solve) are vertices in level 0, and all the terminals will be vertices in level h = Θ(log n). For clarity of presentation, we refer to the root and terminal vertices by the same name in both Gup and Gdown (even though the graphs are completely disjoint). Overloading notation, let V denote the vertices in level 0 in both Gup and Gdown, and let E be the union of the edge sets of Gup and Gdown. Furthermore, the cost ce and length (cid:96)e of these edges are inherited from Theorem 7. Figure 3: The graphs Gup and Gdown with h = 3, where the original graph G has 6 vertices {v1, v2, . . . , v6}. Now, using the junction-tree decomposition with approximation factor α, we get the following lemma. } of the terminal- } rooted at r in Gup, and a collection of out-trees ⊆ V of root vertices, a partition Π∗ := {πr : r ∈ R∗ r r : r ∈ R∗ Lemma 8. There exists a set R∗ : r ∈ R∗ pairs in X , a collection of in-trees {T up {T down (i) Each (si, ti) ∈ X belongs to πr for some r ∈ R∗. (ii) For each r ∈ R∗, the in-tree T up } rooted at r in Gdown such that necting {si single-source buy-at-bulk problem connecting r to {ti : (si, ti) ∈ πr} in Gdown. : (si, ti) ∈ πr} to r in Gup; likewise, the out-tree T down r r is a feasible solution to the single-sink buy-at-bulk problem con- is a feasible solution to the (iii) The sum of objective values of the single-source and single-sink solutions is at most O(α log n) · Opt(I). Proof: Since the junction-tree approximation ratio of the given instance is α, there exists a junction-tree solution given by a set of roots R∗ and a partition Π∗ := {πr : r ∈ R∗ } such that the total objective value of all the single-sink and single-source junction-trees is at most αOpt(I). Moreover, by Theorem 7, because we choose the height h = Θ(log n), the objective value of each single-sink and single-source solution in G increases by a factor of O(log n) in Gup and Gdown respectively. Thus, the overall objective value of the (cid:4) resulting junction-trees in the graphs Gup and Gdown is O(α log n) · Opt(I). 9 level0level3Gupv3,0v4,0v5,0v6,0v1,0v2,0v1,3v2,3v3,3v4,3v5,3v6,3Vv3,0v4,0v5,0v6,0v1,0v2,0v1,3v2,3v3,3v4,3v5,3v6,3Gdown(rootsarehere)(terminalsarrivehere) The above lemma motivates the LP relaxation given in Fig. 4 which seeks to assign each (si, ti) pair to some rooted instance, and then minimizes the total fractional objective value of the rooted instances. Each individual rooted instance is represented by an inner-LP (see the boxed constraints in Fig. 4). (cid:88) (cid:88) (cid:88) (cid:16) (si,ti)∈X r∈R e∈E (cid:96)e (e,si) + f r f r (e,ti) (cid:17) (cid:88) minimize (cid:88) s.t (cid:88) r∈V e∈E zir ≥ 1 cexr e + r∈V zir ≥ 0 (MC-BaB LP) (2a) (2b) (2c) (2d) (2e) (2f) (2g) ∀i ∀i,∀r ∈ V ∀i,∀r ∈ V ∀i,∀e,∀r ∈ V ∀i,∀e,∀r ∈ V {f r (e,si)} define a flow from si to r of value zir in Gup {f r (e,ti)} define a flow from r to ti of value zir in Gdown f r (e,si) ≤ xr f r (e,ti) ≤ xr xr e ≥ 0, f r (·) ≥ 0 e e Figure 4: Composite LP for MC-BB. Equations (2a) and (2b) form the outer-LP; (2c)-(2g) form the inner- LPs. (e,si) (resp. f r (cid:48)) where X (cid:48) = {(si, r) : zir = 1} and the single-source instance I In the LP, zir denotes the extent to which the pair (si, ti) chooses root r to route its flow. Within each e} are the variables which denotes whether edge e is used to route flow inner-LP corresponding to a root r, {xr in the corresponding rooted instance, and f r (e,ti)) denotes the amount of flow si sends (resp., ti receives) along e to (resp., from) root r. Observe that if the zir variables are integral, then the inner-LP corresponding to every root r constitutes a feasible fractional solution to (SS-BaB LP) for the single-sink (cid:48)(cid:48)) (cid:48)(cid:48) = (Gdown,X (cid:48) = (Gup,X instance I (cid:48)(cid:48) = {(r, ti) : zir = 1}. The next lemma, which bounds the optimal value of the MC-BaB LP, where X follows directly from Lemma 8. Lemma 9. The optimum value of (MC-BaB LP) is O(α log n) · Opt(I). 3.2 An online fractional algorithm for the MC-BaB LP Theorem 10. There is a randomized, polynomial-time online algorithm that returns a feasible fractional solution for (MC-BaB LP) of value at most O(α log3 n) · Opt(I). In the remainder of the subsection, we prove the above theorem. We remark that the overall reduction uses Theorem 10 as a black-box and the time-constrained reader can skip the proof and move to Section 3.3. To simplify the exposition, we assume that we know the cost of an optimal solution Opt(I) up to a constant factor, using a standard doubling trick11. Once we know Opt(I), by re-scaling all the parameters 11Suppose our online algorithm has a competitive ratio of α, and the true cost of an optimal solution is c∗. Then, we begin with an initial guess for the optimal cost, and run the online algorithm assuming this guess is the correct estimate for c∗. If our online algorithm fails to find a feasible solution of cost at most α times the current guess, we double our guess and run the online algorithm again. Eventually, our guess will exceed the optimal cost c∗ by at most a factor of two, and for this guess, the algorithm 10 in the problem, we may assume that it equals 1. Next, we delete any edge in Gup or Gdown that has cost ce or length (cid:96)e larger than 1 as such edges cannot participate in any optimal solution. Subsequently, we initialize all xr e variables to 1/n5. Likewise, we initialize all zir variables to 1/n5 and also send an initial flow of 1/n5 from each si to r in Gup on an arbitrary flow path from si to r and likewise from r to ti in Gdown. This setting ensures that the cost of the initial solution is o(1). In the following, we partition the edge set E into disjoint sets {Ej : 0 ≤ j ≤ h − 1}, where Ej denotes the set of edges in E between levels j and j + 1. Furthermore, for clarity of exposition, we describe a 'continuous-time' version of the algorithm where we increase the variables as a function of time. We note that this algorithm can easily be discretized for a polynomial-time12 implementation. The algorithm is given as Algorithm 1. Algorithm 1 Online Fractional Algorithm for (MC-BaB LP) When a terminal-pair (si, ti) arrives, we update the LP solution using the following steps: (1) Let Ri denote the set of roots r in level 0 such that si is connected to r in Gup and r is connected to ti in Gdown. For each r ∈ Ri, initialize a flow of value 1/n5 using any arbitrary flow path from si to r in Gup and likewise from r to ti in Gdown. Also set zir = 1/n5 for these roots. (2) Repeat the following while(cid:80) r∈Ri zir < 1: (a) Call an edge e ∈ E tight for root r if xr (b) Edge Update: For all tight edges e ∈ E, update xr (c) Flow Update: Solve the following min-cost max-flow problem for each r ∈ Ri: maximize ∆ such (e,ti). e at the rate dxr (e,si) or xr := xr e ce e = f r e = f r e dt . that - there exists a flow {gr - there exists a flow {gr - Capacity constraints: gr - Cost constraint:(cid:80) for all tight edges e, (d) Update f r (e,si) at the rate dt = ∆. zir at the rate dzir (e,si)} sending ∆ units of flow from si to r in Gup, (e,ti)} sending ∆ units of flow from r to ti in Gdown, (e,si) ≤ TheAlgorithm(Algorithm 1).xr e/ce and gr (e,ti) ≤ xr e/ce (e,si) ≤ zir and(cid:80) e (cid:96)e · gr df r (e,ti) ≤ zir. e (cid:96)e · gr (e,ti) at the rate df r (e,si) dt := gr (e,si), and f r dt = gr (e,ti) (e,ti) for all e, and update We increase the x variables on tight edges at a rate inversely proportional to their cost, similar to the well- known online set cover algorithm [3]. However, the "flow constraints" are not pure packing (or covering) constraints and there is no general-purpose way of handling them. Indeed, we determine the rate of increase of the flow variables by solving an auxiliary min-cost max-flow subroutine which routes incremental flows of equal value from si to r in Gup and from r to ti in Gdown respecting capacity constraints (i.e., for edges that are tight, the incremental flow is at most the rate of increase of x). This maintains feasibility in the inner LP. Moreover, to bound the rate of increase in objective, we enforce that the total length of the incremental flow will compute a feasible solution of cost at most 2αc∗. Moreover, since our guesses double every time, the total cost of the edges bought by the online algorithm over all the runs across different guesses is at most Θ(αc∗). 12The polynomial is in the size of the input to this algorithm, which for some of our algorithms/results is quasi-polynomial in the size of the actual problem instance as stated in the introduction. 11 is at most zir (this is the "cost" constraint in the min-cost max-flow problem). We stress that the incremental flows from the auxiliary problem dictate the rate at which we increase the original flow variables in the LP. The final solution is feasible since the algorithm runs until the outer-LP constraint is satisfied. First, note that the total cost of initialization is o(1) over all the edge and flow variables. So it suffices to bound the cost of the updates. The next lemma relates the total cost of the updates to the total time τ for which the algorithm runs, and the subsequent lemma bounds τ in terms of Opt(I). Lemma 11. The LP objective value at the end of the above algorithm is O(log n) · τ, where τ is the (continuous) time for which the algorithm runs. j Proof: We show that at any time t, the rate of the increase of the LP objective value in the algorithm is at most O(log n); this proves the lemma.13 The objective increases because of increase in x variables and flow variables f; we bound these separately. We first upper bound the objective increase due to the changes in the x variables. Fix a level j and let Etgt e) j ∩Gdown xr equals the total flow on these edges for the pair (si, ti). Since the edges in Ej form a cut separating si from e < 2. Now, the xr e/ce, which implies that the total rate of increase of the denote the set of tight edges in Ej at time t. By definition,(cid:80) r zir < 1, we have(cid:80) ti, the total flow across this cut is at most zir. Since(cid:80) LP value due to the increase of x is at most(cid:88) (cid:88) (cid:88) (cid:88) e (resp.,(cid:80) (cid:80) rate of increase of each such tight edge is precisely xr j ∩Gup xr e∈Etgt e∈Etgt e∈Etgt r j ce dxr e dt ≤ r e∈Etgt j r e∈Etgt j xr e ≤ 2. Summing over all levels gives the desired O(log n) bound. Next, we upper bound the objective increase due to the changes in the f variables. When these variables are updated, the total rate of increase of the objective due to the lengths of the (si, r) and (r, ti) flow paths is at most zir -- this is precisely the "cost" constraint in the auxiliary flow problem. Hence the total rate of (cid:4) increase of flow lengths is at most 2, completing the proof. Given the above lemma, we are left to relate τ to Opt(I) in order to complete the proof of Theorem 10. Lemma 12. The time duration τ of the above algorithm satisfies τ = O(α log2 n) · Opt(I). We will need several new definitions and auxiliary lemmas in order to prove Lemma 12. Recall from Lemma 8 r that we can assume that the solution that we are comparing against is the set of junction-trees defined by T up for r ∈ R∗. Also, recall that the terminal-pairs are partitioned by the groups Π∗ = {πr : r ∈ R∗ }. and T down For every (si, ti) ∈ X , let P ∗ such that (si, ti) ∈ πr. Similarly, let P ∗ e∈P (cid:96)e for any path P . Lemma 8 asserts that (cid:88) . Let (cid:96)(P ) =(cid:80) (cid:88) (cid:0)(cid:96)(P ti)(cid:1) = O(α log n) · Opt(I) si denote the path from si to the root r in T up ti denote the path from r to ti in T down  (cid:88) ∗ si) + (cid:96)(P ce + (3) ∗ r r r r∈R∗ e∈T up r ∪T down r (si,ti)∈X To bound τ against the optimal junction-tree solution, we use two sets of charging clocks: 13We remark that the "log n" corresponds to the number of levels in Gh justifying the preprocessing step before the LP descrip- tion. 12 • We maintain an edge clock on every (e, r) pair such that e ∈ T up , i.e., if e is used by the optimal junction-tree solution in the single-source (or single-sink) instance corresponding to r. In particular, note that if an edge e is in multiple junction-trees, then it has a separate clock for each such tree. r or e ∈ T down r • We maintain a terminal clock on every terminal-pair (si, ti) ∈ X . The crucial invariant that we maintain is the following: at any time instant t, at least one clock "ticks," i.e., augments its counter at unit rate. The overall goal would then be to bound the total time for which all the charging clocks can cumulatively tick. First, we describe the rule for the ticking of the clocks. Fix a time t, and let the terminal-pair (si, ti) be the pair that is active at time t. Let r denote the root vertex which (si, ti) has been assigned to in the optimal junction-tree solution from Lemma 8, i.e., (si, ti) ∈ πr. Now, consider the flow-paths P ∗ ti in Gdown. We can have one of two situations: si in Gup and P ∗ - If any variable xr e is tight for any edge e ∈ P ∗ si ∪ P ∗ ticks at time t. If there are multiple such edges, then all the corresponding clocks tick. ti at time t, then the edge clock on the pair (e, r) - Otherwise, both paths are free of tight edges. In this case, the terminal clock for (si, ti) ticks at time t. Lemma 13. For any pair (e, r) such that e ∈ T up Proof: Notice that xr r ∪ T down r e is initialized to 1/n5 for all roots r, and increases at the rate , its edge clock ticks for O(ce log n) time. dxr e dt = xr e ce (4) e = f r (e,si) or xr e = f r (e,ti). But in this case, we increase such variables at rate xr at all times when the edge clock on (e, r) ticks. To see why, consider a time t when the clock on (e, r) ticks, and let (si, ti) denote the active terminal-pair at time t. It must be that (i) (si, ti) has been assigned to root r in Π∗, and (ii) either xr e/ce in our algorithm (Step (2a)). Therefore, we can infer that the value of xr e would be 1 after the edge clock on e has ticked for time O(ce log n). But clearly, e cannot be a tight edge for any subsequent terminal-pair (si, ti) once xe reaches 1; therefore, the edge clock on (e, r) ticks for O(ce log n) time overall. Lemma 14. For every terminal-pair (si, ti) connected by the optimal junction-tree solution through the root vertex r, the total time for which the terminal clock ticks is at most O(log n) · max((cid:96)(P ∗ Proof: Recall that if the terminal clock for (si, ti) is ticking at time t, then it must mean that no edge is tight on either path P ∗ ti. In this case, we show that the variable zir increases at a fast enough rate, where r is the root (si, ti) is assigned to in the optimal junction-tree, i.e., (si, ti) ∈ πr. We show this by exhibiting a feasible solution to the auxiliary LP considered in Step (2b) of the algorithm for root r. Indeed, send the flow from si to r along P ∗ ti. Also set the value of ∆ to be zir/ max((cid:96)(P ∗ ti)). Clearly, on the edges of these flow paths, we do not have any capacity constraints since no edge is tight. So, the only constraints are the cost constraints which are satisfied by the choice of ∆. Hence, the rate of increase of zir is at least si, and likewise from r to ti along P ∗ si), (cid:96)(P ∗ si), (cid:96)(P ∗ si or P ∗ ti)). (cid:4) dzir dt ≥ zir si), (cid:96)(P ∗ max((cid:96)(P ∗ ti)) 13 (5) at all times when the terminal clock on (si, ti) ticks. This proves the claim, for otherwise the variable zir (cid:4) would have reached 1, and the algorithm would have completed processing (si, ti). Since at least one clock ticks at all times, the total time clocked is at least τ, the duration of the algorithm. Lemma 13 and Lemma 14 imply that  (cid:88) (cid:88) r∈R∗ e∈T up r ∪T down r (cid:88) (si,ti)∈X (cid:0)(cid:96)(P ce + ti)(cid:1) ∗ ∗ si) + (cid:96)(P τ ≤ O(log n) which together with (3) completes the proof of Lemma 12. Theorem 10 follows from Lemma 11 and Lemma 12. 3.3 Partial Online LP Rounding We partially round the fractional solution returned by Theorem 10 to obtain integral values for only the outer-LP variables zir, i.e., each (si, ti) pair is integrally assigned to a root. The inner-LP variables x and f continue to be fractional but represent unit fractional flow from si to r and r to ti for the (si, ti) pairs assigned to r. The partial rounding algorithm is given as Algorithm 2. Algorithm 2 Online Partial Rounding Algorithm (1) Initialization: Each root chooses a threshold τr ∈ [1/2n, 1/(3 log n)] uniformly at random. (2) Partial Rounding: At each time, maintain the scaled solution xr e = min (1, xr (cid:16) (cid:17) e/τr), f r (·) = min 1, f r (·)/τr . Also set zir = 1 if zir ≥ τr. Theorem 15. The scaled solution (x, f ) component-wise dominates a feasible solution to the outer-LP, and the expected objective value of the scaled solution (x, f ) is at most O(α log5 n) · Opt(I). Moreover, for each (si, ti), there exists at least one root r such that zir ≥ 1 with probability at least 1 − 1/n3. Proof: Since each root r chooses its threshold τr independently and uniformly at random from [1/2n, 1/ log n], the probability that zir = 1 is at least zir log n (since zir = 1 if and only if τr ≤ zir). Since this is indepen- dent for different roots, a standard Chernoff-Hoeffding bound application (see, e.g., [30]) shows that each (si, ti) pair has zir = 1 for some root r with probability at least 1 − 1/n3. Moreover, the expected value of any variable xr e is given by (cid:90) log n E [xr e] ≤ τr=1/2n xr e τr log ndτr ≤ O(log2 n)xr e. A similar argument shows that the expected values of scaled flow variables are also bounded by O(log2 n) times their values in the fractional solution. This shows that the expected objective value of the (x, f ) solu- tion is at most O(log2 n) times the value of (x, f ); by Theorem 10, the latter is at most O(α log3 n)Opt(I). Combining these facts gives us the desired bound on the value of the scaled solution. It remains to show that the scaled solution dominates a feasible solution to the LP. To this end, fix some root r and let Xr denote the set of (si, ti) pairs for which zir = 1. We need to show that installing capacities of { f r (e,si)} on the edges can support unit flow from si to r in Gup for all (si, ti) ∈ Xr. Suppose 14 (cid:17) e∈Q f r (e,si) (e,si) ≤ τr; otherwise, we would have an edge e with f r (cid:16)(cid:80) (e,si)} is a feasible flow from si to r of value zir and hence it must be that(cid:80) for contradiction that there is is a cut Q separating si from r of capacity strictly smaller than 1. This implies that every edge e ∈ Q must have f r (e,si) = 1, which contradicts our assumption on the cut capacity. But then the value of the min-cut is precisely /τr, which must be at least 1 because of the following two observations: (i) we know that (e,si) ≥ zir, and (ii) {f r since zir = 1, it must be that zir ≥ τr. This contradicts the assumption that the cut capacity is strictly smaller than 1. A similar argument shows that the variables { f r (e,ti)} can support unit flow from r to ti for (cid:4) every (si, ti) with zir = 1. e∈Q f r 3.4 Wrapping up: Invoking the Single-Sink Online Algorithm We are now ready to put all the pieces together and present our overall online multicommodity buy-at-bulk algorithm as Algorithm 3. SingleSinkAlg is the online algorithm for SS-BB alluded to in point (iii) of the statement of Theorem 2. Algorithm 3 Online Multicommodity Buy-at-Bulk Algorithm when (si, ti) arrives (1) update the fractional solution of the composite LP using the algorithm (Algorithm 1, Section 3.2). (2) partially round the solution using algorithm in (Fig. 2, Section 3.3). (3) if(∃r : zir ≥ 1): send both si and ti to the instance of SingleSinkAlg with root r. (4) else: buy a trivial shortest path between si and ti on the metric (c + (cid:96)) and route along this path we get(cid:80) Clearly the algorithm produces a feasible solution; so we now argue about the expected objective value. Fix an (si, ti) pair. Since the probability that a terminal-pair is not assigned to a root is ≤ 1/n3 (by The- orem 15), the expected total contribution of such unassigned terminal-pairs is ≤ 1 = Opt(I). For a root r, let πr be the terminal-pairs assigned to r. We know that (x, f ) restricted to πr dominates a feasible solution in (SS-BaB LP). Letting LPr denote the contribution of this restriction to the overall LP value, r LPr = O(α log5 n) · Opt(I). By the integrality gap condition, we get that Optr, i.e. the in- tegral optimum objective value of the instance generated by r and πr, is at most β · LPr. (Here we are using the fact from Theorem 7 that moving to the layered instance does not increase the integrality gap.) The objective value of the solution produced by SingleSinkAlg is at most γ · Optr, where γ is the com- petitive ratio of SingleSinkAlg. Putting these observations together, we conclude that the overall objective value of the solution returned by the online algorithm is O(αβγ log5 n) · Opt(I). This completes the proof of Theorem 2. 4 Online Directed Buy-at-Bulk In this section, we prove Theorem 5. A natural approach is to use the reduction given by Theorem 2. To this end, we need to establish the following: the existence of a junction-tree scheme with a good approximation; a good upper bound on the integrality gap for single-sink instances of the LP given in Section 2; and an online algorithm for single-sink instances with a good competitive ratio. 15 Extending the work of Chekuri et al. [13], Antonakopoulos [5] shows the existence of a junction-tree scheme with approximation O(√k). Unfortunately, the integrality gap of the LP relaxation is not very well understood even for Steiner tree instances; [35] gives an Ω(√k) lower bound14 on the integrality gap for the Steiner tree problem and no suitable upper bound is known. We overcome this difficulty as follows. Instead of working with general graphs, we pre-process the instance and obtain a tree-like graph for which we can show that the LP has a good integrality gap. Finally, we give the first non-trivial online algorithm for the directed single-sink buy-at-bulk problem. These results, together with our reduction (Theorem 2), imply the online algorithm for MC-D-BB. We devote the rest of this section to the proof of Theorem 5; to aid the reader, we restate the theorem below. Theorem 16. For any constant ε > 0, there is a O(k domized online algorithm for the general buy-at-bulk problem. 1 2 +εpolylog(n))-competitive, polynomial time ran- Pre-processing step. We first give our reduction from general instances of the directed buy-at-bulk problem to much more structured instances; the reduction loses a factor of O(k 2 +ε) in the approximation ratio. 1 Let h = (cid:100)1/ε(cid:101). Given an instance I = (G,X ) of the directed buy-at-bulk problem, we map it to a tree-like instance J = (H,X ) as follows. We start by applying Theorem 7 to G to obtain the graphs Gup and Gdown; recall that these graphs are layered (h + 1)-level graphs with n vertices (corresponding to the vertices in G) in each level, and the levels are numbered 0, 1, . . . , h with 0 being called the root level. The graph Gup has edges directed from higher numbered levels to lower numbered levels, and Gdown has edges in the opposite direction. To facilitate the construction of the graph H, we now create n trees from Gup and n trees from Gdown as follows. For every "root vertex" r at level 0 in Gup (resp. Gdown), the tree T up r (resp. T down r ) is constructed as follows: • The 0th layer of T up r has just one vertex -- the root r. • For each i such that 1 ≤ i ≤ h, the i-th layer of T up r where vj is a vertex present in the j-th layer of Gup. contains all (i + 1)-length tuples (r, v1, . . . , vi) • For every edge e = (vi, vi−1) ∈ Gup, there is an arc from (r, v1, . . . , vi−1, vi) to (r, v1, . . . , vi−1) inheriting the same cost ce and length (cid:96)e. Therefore each tree T up is constructed analogously except all edges are directed away from the root. In the following, we use the term leaves to refer to the vertices on layer h of these trees. is an in-arborescence, with all edges directed towards the root. The tree T down r r After performing the above operation for every root vertex r in level 0 of Gup , we have 2n trees. Then the final graph H is obtained as follows (see Figure 5). For each root r ∈ V , we first add an arc from the root of T up of zero cost and length. Finally, for every (si, ti) pair, we add the vertices si and ti to H and the following arcs connecting them to the trees: for each tree T up r , we add an arc from si to each leaf of T up , we add an arc to ti from each leaf of T up r of the form (r, v1, . . . , vh) with vh = ti. These new arcs have zero cost and length (i.e., ce = (cid:96)e = 0). r of the form (r, v1, . . . , vh) with vh = si; for each tree T down r and Gdown to T down r r This completes the construction of H. Note that the graph H has nO(h) vertices and a similar number r r of edges. Our new instance is J = (H,X ) and we will apply Theorem 2 to this instance. We first relate the objective values of J and I. 14However, in these instances, n is exponentially large in k. So, they do not rule out a polylog(n) upper bound. 16 Figure 5: Construction of graph H. r r Lemma 17. Every feasible solution for J is a junction-tree solution. Proof: Note that any (si, ti) path in H has the following structure: si connects to a leaf node of T up for r some r ∈ V , then continues to the root r, then traverse the edge to the root of T down , then goes down to a leaf of T down and finally connects to ti. Thus, for any feasible solution for J , the (si, ti) pairs can be (cid:4) partitioned based on the root r through which they connect. Lemma 18. Any feasible solution for J can be mapped to a feasible solution -- in fact, a junction-tree solution -- for I of equal or smaller objective value. Proof: Note that from the previous lemma, any feasible solution S in J is a junction-tree solution. There- fore, there is a partition ΠS of the (si, ti) pairs depending on which root vertex they are using to connect. Moreover, it follows from our construction of the trees in H that any edge in T up ) corresponds to an edge in Gup (resp. Gdown). Therefore, if we map each edge appearing in solution S to its correspond- ing edge in Gup or Gdown, we obtain a mapping from each junction tree of S rooted at r to a junction tree in Gup ∪ Gdown rooted at r that is connecting the same subset of pairs. Finally, by Theorem 7, each junction tree in Gup ∪ Gdown rooted at r can be mapped, without increasing the objective value, to a junction tree in (cid:4) G rooted at r that is connecting the same subset of pairs. This completes the proof of the lemma. Lemma 19. Opt(J ) ≤ O(hk1/h)Optjunc(I), where Optjunc(I) is the objective value of an optimal junction- tree solution for I. Proof: Consider the optimal junction tree solution for I. Let the optimum partition be Π = (πr1, . . . , πrq ) where R∗ = {r1, r2, . . . , rq} is the set of roots of the junction trees. For each r ∈ R∗, let Xr = {si : (si, ti) ∈ πr} be the set of sources of πr and Yr be the corresponding sinks. From Theorem 7, we know that the optimum objective value of any one single-sink problem connecting Xr to r in Gup is at most O(hk1/h) times the objective value of the optimum solution connecting each source in Xr to r. An analo- gous upper bound holds for every optimal single-source solution connecting r to each sink in Yr. Therefore, we get that the total sum of objective values of each of the junction trees in Gup and Gdown is at most (resp. T down r r 17 Tupr1···Tdownr1···Tupr2Tdownr2r1r2s1s2skt1t2tkr2r2 1 r O(hk1/h)Optjunc(I). Now notice that any solution SG for (Gup, Xr) can easily be "simulated" by a solu- tion ST in the tree T up r : indeed, for every root-vertex path (r, v1, v2, . . . , vi) in the solution SG, include the edge from (r, v1, v2, . . . , vi) to (r, v1, v2, . . . , vi−1) in ST (recall the vertices in T up exactly correspond to r such root-vertex paths). It is easy to see that the objective value of the solution ST in T up is the same as that r of SG. Similarly, any solution for (Gdown, Yr) can be simulated in T down with the same objective value. It (cid:4) follows that there is a feasible solution in J of objective value at most O(hk1/h)Optjunc(I). Corollary 20. Opt(J ) ≤ O(k Proof Sketch: Antonakopoulos [5] shows that there exists a junction-tree solution of cost at most O(√k)Opt(I). (cid:4) The corollary follows from this work and the fact that we set h = Θ(1/ε). Now we are ready to show that the new instance J has the properties required by the reduction, i.e., single-sink) sub-instance Theorem 2 can be applied. (cid:48) = (H,T , v) of J = (H,X ) is a single-source (resp. single-sink) instance of the following form: J the graph is the same as in J , namely H; the set of terminals T is a subset of the sources (resp. sinks) of X ; the terminals T need to be connected to a root vertex v ∈ V (H) \ {si, ti : i ∈ [k]}. Lemma 21. Let J be the instance described above. Let α, β, γ be as in the statement of Theorem 2. We have In the following lemma, a single-source (resp. 2 +ε)Opt(I). (i) The junction-tree approximation factor of J is 1 (i.e., α = 1). (ii) The integrality gap of (SS-BaB LP) for any single-sink/source sub-instance J (i.e., β = O(h log n log k)). (cid:48) = (H,T , v) is O(h log n log k) (cid:48) = (iii) There is a O(h2 log2 n log k)-competitive algorithm for any single-sink/source sub-instance J (H,T , v) (i.e., γ = O(h2 log2 n log k)). In order to show (ii) and (iii), we will map the sub-instance J Proof: Property (i) follows from Lemma 17. Thus we focus on proving (ii) and (iii). In the following, we (cid:48) of J ; the proof is very similar for single- assume that we are working with a single-sink sub-instance J source sub-instances and we omit it. (cid:48) = (H,T , v) to an instance of the group Steiner tree problem on a tree as follows. Since v ∈ V (H) \ {si, ti : i ∈ [k]}, we have v ∈ T up r ∪ T down for some r. We first consider the case when v ∈ T up r . In order to define the tree of the group Steiner tree instance, we start with the subtree Tv of T up rooted at v. We add the following 'dangling' edges to Tv for r each source si ∈ T : for each leaf vertex u ∈ T up such that si has an edge in T up to u, we add a new vertex r r u(cid:48) to Tv and connect it to u. Let T be the resulting tree. We assign weights to the edges of T as follows. Each of the old edges e ∈ Tv receives a weight equal to ce. Each of the new edges uu(cid:48) ∈ E(T )\ E(Tv) receives a weight equal to (cid:96)(Pu), where Pu is the path of T up from u to v. Finally, we define the following groups: for r each source si ∈ T , we introduce a group Si consisting of all the new vertices u(cid:48) ∈ V (T )\ V (Tv) such that si is connected to its partner u in T up r has an edge from si to u). In the resulting group Steiner r tree instance, the goal is to connect all of the groups S = {Si : si ∈ T } to the root v using a minimum weight subtree of T ; we let (T,S, v) denote this instance. Now the key claim is that the feasible solutions to the single-sink buy-at-bulk (H,T , v) are in a one- to-one correspondence with feasible solution to the group Steiner tree instance (T,S, v); moreover, the objective value of a solution to the former is equal to the weight of the solution to the latter. To see this, consider a feasible solution P for the single-sink buy-at-bulk instance. Note that, for each source si ∈ T , P has a path connecting si to v; it follows from our construction of H that this path consists of an edge from (that is, T up r 18 r r followed by the unique path in T up si to a leaf u of T up from u to v. Thus we can construct a feasible group r Steiner tree solution by connecting each group Si using the path of T from u(cid:48) to v, where u(cid:48) is the partner of the leaf u of T up through which si connects to the root in the buy-at-bulk solution. The weight of the edge u(cid:48)u captures the (cid:96)-cost of si's path and the weight of the path from u to v captures the c-cost of si's path. Moreover, we can apply the same argument to fractional solutions to the two problems and show that there is a bijection between feasible fractional solutions to (SS-BaB LP) and feasible fractional solutions to the LP relaxation for group Steiner tree of Garg, Konjevod, and Ravi [19]; as before, these corre- sponding solutions have the same objective values. Now the desired upper bound on the integrality gap of (SS-BaB LP) follows from the work of [19] who showed that the integrality gap of the group Steiner tree LP is O(log N log K) where N = maxi Si is the maximum size of a group and K is the number of groups. In our setting, K ≤ X ≤ k and N ≤ nh. Therefore the integrality gap is O(h log n log k), which establishes property (ii). Moreover, notice that the above reduction can also be used to obtain an online algorithm for the single- sink (and single-source) sub-instances. Indeed, we simply use the online group Steiner tree algorithm of Alon et al. [1] which has a competitive ratio O(log2 N log K) = O(h2 log2 n log k). This proves property (cid:4) (iii). Now we are ready to complete the proof of Theorem 16. Proof of Theorem 16: Given the instance I = (G,X ), we construct the graph H as described above; the time taken to do so is nO(h). We pass the instance (H,X ) to Theorem 2 and, using Lemma 21, we obtain an online algorithm that, for any collection of pairs X and any adversarial ordering of X , returns a solution of cost O(polylog(n)) · Opt(J ). By Lemma 19 and Corollary 20, we can map solutions for (H,X ) to (cid:4) solutions for (G,X ). We note that the approach described above also gives us new online algorithms for the single-sink buy-at- bulk problem on directed graphs. For single-sink instances, the junction-tree approximation is equal to 1 and thus we save a factor of √k. Corollary 22. There is a polynomial time O(kε · polylog(n))-competitive online algorithm for the single- sink (or single-source) buy-at-bulk problem on directed graphs. The competitive ratio can be improved to polylog(n) if the running time can be quasi-polynomial in n. 5 Online Single-sink, Undirected, Node-weighted Buy-at-Bulk In this section, we prove Theorem 4. Again, we use our main theorem (Theorem 2) and reduce the multi- commodity buy-at-bulk problem to the single-sink version of the problem. We combine the reduction theo- rem with the following results from previous work. Chekuri et al. [13] show the existence of a junction-tree scheme with approximation factor O(log k). Moreover, the natural LP relaxation for the single-sink buy- at-bulk problem on graphs with node costs is also O(log k) [15]. For the single-source online algorithm, we resort to the algorithms from the previous section for the more general directed single-sink buy-at-bulk problem (see Corollary 22). We now obtain the desired result by the following parameter settings: α = O(log k) β = O(log k) γ = O(polylog(n)) T = nO(log n). 19 6 Online Prize-Collecting Buy-at-Bulk In the prize-collecting version of the buy-at-bulk problem, each terminal pair (si, ti) also comes with a penalty qi and the algorithm may choose not to serve this request and incur the penalty in the total cost. We show that our online reduction framework (Theorem 2) can be easily modified to handle prize-collecting versions as follows. Theorem 23. Let I be a buy-at-bulk instance and suppose the three conditions of Theorem 2 hold. Then there is an O(αβγ · polylog(n))-competitive online algorithm for the online, prize-collecting buy-at-bulk problem on I with arbitrary penalties. Proof: We closely follow the proof of Theorem 2. The first difference is in the LP-formulation. Now, for each (si, ti) pair we have an extra variable zi,0 which indicates whether we choose to discard this pair (and pay the corresponding penalty) or not. We point out the differences with (MC-BaB LP). The new objective function is (cid:88) (cid:88) (cid:88) (cid:16) (cid:17) (cid:88) minimize (cid:88) (cid:88) and (2a) is replaced by cexr e + r∈V e∈E (si,ti)∈X r∈R e∈E (cid:96)e f r (e,si) + f r (e,ti) + qizi,0 (si,ti)∈X (cid:88) r∈V zir + zi,0 ≥ 1 ∀i Observe that the optimum value of this modified LP is at most O(α log n) times the optimum: set zi,0 = 1 for the pairs the integral optimum solution does not connect, and for the rest apply Lemma 9. Also observe that the modified LP can be thought of the old LP on a modified instance where the graphs Gup and Gdown (obtained from Theorem 7) have another vertex "0" at the root level, and each si has a direct path from si to "0" in Gup with total length qi/2 and no fixed cost, and similarly, each ti has a path from "0" to ti in Gdown with total length qi/2 and no fixed cost. The rest of the proof now follows exactly as in Section 3, by also including the special vertex as a possible root while rounding to make the outer LP variables integral. (cid:4) 7 Conclusion In this paper, we gave the first polylogarithmic-competitive online algorithms for the non-uniform multi- commodity buy-at-bulk problem. Our result is a corollary of a generic online reduction technique that we proposed in this paper for converting a multicommodity instance into several single-sink instances, which are often easier to design algorithms for. We believe that this reduction will have other applications be- yond the buy-at-bulk framework, and illustrate this by showing that recent results on online node-weighted Steiner forest and online generalized connectivity directly follow from our reduction theorem. Our work also opens up new directions for future research. For instance, our algorithm for the node-weighted problem runs in quasi-polynomial time, and a concrete open question is to get a polynomial-time polylogarithmic- competitive algorithm for the SS-N-BB problem (this suffices for MC-N-BB as well by our main theorem). Another technical question concerns non-uniform demands. While our algorithm can be extended to the case of non-uniform demands, the approximation ratio incurs an additional O(log D) factor, where D is the ratio of the largest to the smallest demand. It would be interesting to eliminate this dependence on D since the corresponding offline results do not have this dependence. More generally, a broader question is to investigate other mixed packing-covering LPs that can be solved and rounded online. 20 Acknowledgements D. Panigrahi is supported in part by NSF Award CCF-1527084, a Google Faculty Research Award, and a Yahoo FREP Award. References [1] N. Alon, B. Awerbuch, Y. Azar, N. Buchbinder, and J. Naor. A general approach to online network op- timization problems. In Proceedings, ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 577 -- 586, 2004. [2] N. Alon, B. Awerbuch, Y. Azar, N. Buchbinder, and J. Naor. A general approach to online network optimization problems. ACM Trans. on Alg., 2(4):640 -- 660, 2006. [3] N. Alon, B. Awerbuch, Y. Azar, N. Buchbinder, and J. Naor. The online set cover problem. SIAM J. Comput., 39(2):361 -- 370, 2009. [4] M. Andrews. Hardness of buy-at-bulk network design. In Proceedings, IEEE Symposium on Founda- tions of Computer Science (FOCS), pages 115 -- 124, 2004. [5] S. Antonakopoulos. Approximating directed buy-at-bulk network design. In Proceedings, Workshop on Approximation and Online Algorithms (WAOA), pages 13 -- 24, 2010. [6] B. Awerbuch and Y. Azar. Buy-at-bulk network design. In Proceedings, IEEE Symposium on Founda- tions of Computer Science (FOCS), pages 542 -- 547, 1997. [7] Y. Azar, U. Bhaskar, L. Fleischer, and D. Panigrahi. Online mixed packing and covering. In Proceed- ings, ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 85 -- 100, 2013. [8] P. Berman, A. Bhattacharyya, K. Makarychev, S. Raskhodnikova, and G. Yaroslavtsev. Approximation algorithms for spanner problems and directed steiner forest. Inform. and Comput., 222:93 -- 107, 2013. [9] P. Berman and C. Coulston. On-line algorithms for steiner tree problems (extended abstract). In Proceedings, ACM Symp. on Theory of Computing (STOC), pages 344 -- 353, 1997. [10] N. Buchbinder and J. Naor. Online primal-dual algorithms for covering and packing. Math. Oper. Res., 34(2):270 -- 286, 2009. [11] M. Charikar, C. Chekuri, T. Cheung, Z. Dai, A. Goel, S. Guha, and M. Li. Approximation algorithms for directed steiner problems. J. Algorithms, 33(1):73 -- 91, 1999. [12] M. Charikar and A. Karagiozova. On non-uniform multicommodity buy-at-bulk network design. In Proceedings, ACM Symp. on Theory of Computing (STOC), pages 176 -- 182, 2005. [13] C. Chekuri, G. Even, A. Gupta, and D. Segev. Set connectivity problems in undirected graphs and the directed steiner network problem. ACM Transactions on Algorithms, 7(2):18, 2011. [14] C. Chekuri, M. T. Hajiaghayi, G. Kortsarz, and M. R. Salavatipour. Approximation algorithms for node-weighted buy-at-bulk network design. In Proceedings, ACM-SIAM Symposium on Discrete Al- gorithms (SODA), pages 1265 -- 1274, 2007. 21 [15] C. Chekuri, M. T. Hajiaghayi, G. Kortsarz, and M. R. Salavatipour. Approximation algorithms for nonuniform buy-at-bulk network design. SIAM J. Comput., 39(5):1772 -- 1798, 2010. [16] C. Chekuri, S. Khanna, and J. Naor. A deterministic algorithm for the cost-distance problem. In Pro- ceedings, ACM-SIAM Symposium on Discrete Algorithms (SODA), volume 7, pages 232 -- 233, 2001. [17] Y. Dodis and S. Khanna. Design networks with bounded pairwise distance. Proceedings, ACM Symp. on Theory of Computing (STOC), pages 750 -- 759, 1999. [18] M. Feldman, G. Kortsarz, and Z. Nutov. Improved approximation algorithms for directed steiner forest. J. Comput. System Sci., 78(1):279 -- 292, 2012. [19] N. Garg, G. Konjevod, and R. Ravi. A polylogarithmic approximation algorithm for the group steiner tree problem. J. Algorithms, 37(1):66 -- 84, 2000. [20] S. Guha, A. Meyerson, and K. Munagala. A constant factor approximation for the single sink edge installation problem. SIAM J. Comput., 38(6):2426 -- 2442, 2009. [21] A. Gupta, A. Kumar, M. P´al, and T. Roughgarden. Approximation via cost-sharing: A simple approx- imation algorithm for the multicommodity rent-or-buy problem. In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 606 -- 615, 2003. [22] A. Gupta, A. Kumar, and T. Roughgarden. Simpler and better approximation algorithms for network design. In Proceedings, ACM Symp. on Theory of Computing (STOC), pages 365 -- 372, 2003. [23] M. Hajiaghayi, V. Liaghat, and D. Panigrahi. Near-optimal online algorithms for prize-collecting steiner problems. In Proceedings, International Colloquium on Automata, Languages and Processing (ICALP), pages 576 -- 587, 2014. [24] M. T. Hajiaghayi, V. Liaghat, and D. Panigrahi. Online node-weighted steiner forest and extensions via disk paintings. In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 558 -- 567, 2013. [25] C. S. Helvig, G. Robins, and A. Zelikovsky. An improved approximation scheme for the group steiner problem. Networks, 37(1):8 -- 20, 2001. [26] M. Imase and B. M. Waxman. Dynamic steiner tree problem. SIAM J. Discrete Math., 4(3):369 -- 384, 1991. [27] S. Korman. On the use of randomization in the online set cover problem. M.S. thesis, Weizmann Institute of Science, 2005. [28] A. Meyerson. Online algorithms for network design. In Proceedings, ACM Symposium on Parallelism in Algorithms and Architectures (SPAA), pages 275 -- 280, 2004. [29] A. Meyerson, K. Munagala, and S. A. Plotkin. Cost-distance: Two metric network design. SIAM J. Comput., 38(4):1648 -- 1659, 2008. [30] R. Motwani and P. Raghavan. Randomized Algorithms. Cambridge University Press, 1997. [31] J. Naor, D. Panigrahi, and M. Singh. Online node-weighted steiner tree and related problems. In Proceedings, IEEE Symposium on Foundations of Computer Science (FOCS), pages 210 -- 219, 2011. 22 [32] F. S. Salman, J. Cheriyan, R. Ravi, and S. Subramanian. Approximating the single-sink link- installation problem in network design. SIAM J. Optimization, 11(3):595 -- 610, 2001. [33] K. Talwar. The single-sink buy-at-bulk LP has constant integrality gap. In Proceedings, MPS Confer- ence on Integer Programming and Combinatorial Optimization (IPCO), pages 475 -- 486, 2002. [34] A. Zelikovsky. A series of approximation algorithms for the acyclic directed steiner tree problem. Algorithmica, 18(1):99 -- 110, 1997. [35] L. Zosin and S. Khuller. On directed steiner trees. In Proceedings, ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 59 -- 63, 2002. A Reduction to Layered Instances (Proof of Theorem 7) In this section, we prove Theorem 7, which is an extension of Zelikovsky's 'height reduction lemma' for the buy-at-bulk problem; Zelikovsky's original Lemma was for a single metric, whereas in our setting there is both a cost and a length metric. We prove the up-ward case; the down-ward case follows analogously. In order to simplify the notation, we remove the superscript up. For this reduction, we will adapt the notion of layered expansion of a graph, which has been in the folklore for many years and has been used recently by several papers (see, e.g.,[13, 31]). The h-level layered expansion of G is a layered DAG Gh of h+1 levels (we index the level 0, 1, . . . , h) defined as follows: (i) For each i such that 0 ≤ i ≤ h, the vertices in level i are copies of the vertices of G; we let vi to denote the copy of vertex v ∈ V at level i. (ii) For each i such that 1 ≤ i ≤ h, there is a directed edge from every vertex in level i to every vertex in level i − 1. The fixed cost of an edge (ui, vi−1) is given by that of the shortest directed path P i uv from ui to vi−1 in G according to the metric ce + k1−i/h(cid:96)e. The length of this edge is set to be the length of the path P i uv in the (cid:96) metric. We now relate the optimal objective values for the two instances. One of the directions of the reduction is straightforward. Lemma 24. For any root r and any set of terminals X, if there is a feasible integral/fractional solution of objective/LP value φ for the single-sink buy-at-bulk problem connecting X to r on the h-level layered expansion Gh, then there is a feasible integral/fractional solution of objective/LP at most φ for the same problem in G. Proof: Note that for every edge in Gh, there is a corresponding path in G with the property that the sum of edge costs and lengths on the path is at most the cost and length of the edge in G. Therefore, replacing the edges in the solution for the layered graph by the corresponding paths in G yields a feasible solution in G without increasing the overall cost and length. Notice that the same "embedding" of edges in Gh to paths in G can be applied to the fractional solution on Gh as well. This shows property (ii) of the theorem statement. (cid:4) The more interesting direction is to show that the optimal objective value on the layered graph Gh can be bounded in terms of the optimal objective value on the original graph G. To show this, we will re-purpose the so-called "height reduction" lemma of Helvig, Robins, and Zelikovsky [25]. We restate the lemma in a form that will be useful for us. 23 Lemma 25. For any in-tree T defined on the edges of G that is rooted at r and contains all the terminals in X, and for any integer h ≥ 1, there is an in-tree T (cid:48) (on the same vertices as G but over a different edge set) that is also rooted at r and contains all the terminals, and has the following properties: ∈ T (cid:48). (i) T (cid:48) contains h + 1 levels of vertices, i.e., has height h. (ii) T (cid:48) is an k1/h-ary tree, i.e., each non-leaf vertex has k1/h children. (iii) Each edge e(cid:48) = (u(cid:48), v(cid:48)) in tree T (cid:48) corresponds to the unique directed path pe(cid:48) in T from u(cid:48) to v(cid:48). Moreover, the number of terminals in the subtree of T rooted at u(cid:48) is exactly k1−i/h, where e(cid:48) is an edge between levels i − 1 and i of T . (iv) Each edge in T is in at most 2hk1/h such paths pe(cid:48) for edges e(cid:48) For an edge e(cid:48) ∈ T (cid:48), suppose we define its cost to be the cost of the path pe(cid:48), and its length to be the length of the path pe(cid:48). Then it is easy to see that the overall cost φT (cid:48) of tree T (cid:48) is O(hk1/h) times that of tree T ; this is due to the following implications of the above lemma: (a) the total (buying) cost of all edges in T (cid:48) is at most 2hk1/h times that of T since each edge is reused at most 2hk1/h times, and (b) for any terminal x ∈ X, the edges on its path to the root in T (cid:48) correspond to disjoint sub-paths in the unique path between x and r in T , and hence the total length cost in T (cid:48) is at most that in T . Using this lemma, we can now complete the reduction by "embedding" the tree T (cid:48) in the layered graph Gh. Lemma 26. If there is a feasible solution of overall cost φ for the single-sink buy-at-bulk problem on G, then there is a feasible solution of overall cost O(hk1/hφ) for the same problem on the h-level layered extension Gh. Proof: Let T be the union of the paths in the optimum solution on the graph G. It's easy to see that T is a directed in-tree. First, we use Lemma 25 to transform T to tree T (cid:48) of height h. As noted earlier, the overall cost φT (cid:48) of T (cid:48) is O(hk1/hφ). Now, we construct a feasible tree Th in Gh using this solution T (cid:48) as follows: consider each edge (u, v) in T (cid:48) where u is at level i and v is at level (i− 1). Then, include the edge (ui, vi−1) in Th. Clearly, since T (cid:48) connects all the terminals to the root, so does Th. Moreover, notice that there is a 1-to-1 mapping between edges in T (cid:48) and edges in Th. To bound the objective value of the subtree, we relate the objective value for each edge of the subtree in Gh to its corresponding mapped edge in T (cid:48). First, note that the overall contribution of an edge e(cid:48) = (u(cid:48), v(cid:48)) between layers i and i + 1 towards φT (cid:48) is equal to the sum of costs and k1−i/h times the lengths of the edges on the associated path pe(cid:48) from u(cid:48) to v(cid:48). This is because, by property (iii) of Lemma 25, the number of demands in the subtree rooted at u(cid:48) is exactly k1−i/h and all of them traverse this edge to reach r. Next, we note that, by definition, the cost of the edge (u(cid:48) i, v(cid:48) i+1) between layers i and i + 1 in Th is equal to the shortest directed path from u(cid:48) to v(cid:48) in G according to the metric ce + k1−i/h(cid:96)e. Since we chose the shortest path, we get that the buying cost of edge (u(cid:48) i, v(cid:48) i+1) ∈ Th is at most the contribution of (u(cid:48), v(cid:48)) towards φT (cid:48). Moreover, the total length cost is at most k1−i/h times the length of the shortest path, which is at most i+1) ∈ Th (again, this uses the fact that there are exactly k1−i/h terminals which the fixed cost of (u(cid:48) route through this edge in Th also). It therefore follows that the overall cost of the solution that we have inductively constructed in Gh is at most twice the overall cost of T (cid:48), which is at most O(hk1/h)φ. (cid:4) Theorem 7 follows from Lemmas 24 and 26. i, v(cid:48) 24